mappedFixedInternalValueFvPatchField.C
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2016 OpenFOAM Foundation
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26\*---------------------------------------------------------------------------*/
27
29#include "IndirectList.H"
30
31// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32
33template<class Type>
36(
37 const fvPatch& p,
39)
40:
42{}
43
44
45template<class Type>
48(
50 const fvPatch& p,
52 const fvPatchFieldMapper& mapper
53)
54:
55 mappedFixedValueFvPatchField<Type>(ptf, p, iF, mapper)
56{}
57
58
59template<class Type>
62(
63 const fvPatch& p,
65 const dictionary& dict
66)
67:
69{}
70
71
72template<class Type>
75(
77)
78:
80{}
81
82
83template<class Type>
86(
89)
90:
91 mappedFixedValueFvPatchField<Type>(ptf, iF)
92{}
93
94
95// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
96
97template<class Type>
99{
101
102 if (this->updated())
103 {
104 return;
105 }
106
107 // Since we're inside initEvaluate/evaluate there might be processor
108 // comms underway. Change the tag we use.
109 int oldTag = UPstream::msgType();
110 UPstream::msgType() = oldTag + 1;
111
112 // Retrieve the neighbour values and assign to this patch boundary field
114
115 // Get the coupling information from the mappedPatchBase
116 const mappedPatchBase& mpp =
117 refCast<const mappedPatchBase>(this->patch().patch());
118 const fvMesh& nbrMesh = refCast<const fvMesh>(mpp.sampleMesh());
119
120 Field<Type> nbrIntFld;
121
122 switch (mpp.mode())
123 {
125 {
127 << "Cannot apply "
129 [
131 ]
132 << " mapping mode for patch " << this->patch().name()
133 << exit(FatalError);
134
135 break;
136 }
139 {
140 const label samplePatchi = mpp.samplePolyPatch().index();
141 const fvPatchField<Type>& nbrPatchField =
142 this->sampleField().boundaryField()[samplePatchi];
143 nbrIntFld = nbrPatchField.patchInternalField();
144 mpp.distribute(nbrIntFld);
145
146 break;
147 }
149 {
150 Field<Type> allValues(nbrMesh.nFaces(), Zero);
151
152 const FieldType& nbrField = this->sampleField();
153
154 forAll(nbrField.boundaryField(), patchi)
155 {
156 const fvPatchField<Type>& pf = nbrField.boundaryField()[patchi];
157 const Field<Type> pif(pf.patchInternalField());
158
159 label faceStart = pf.patch().start();
160
161 forAll(pf, facei)
162 {
163 allValues[faceStart++] = pif[facei];
164 }
165 }
166
167 mpp.distribute(allValues);
168 nbrIntFld.transfer(allValues);
169
170 break;
171 }
172 default:
173 {
175 << "Unknown sampling mode: " << mpp.mode()
176 << abort(FatalError);
177 }
178 }
179
180 // Restore tag
181 UPstream::msgType() = oldTag;
182
183 // Assign to (this) patch internal field its neighbour values
184 Field<Type>& intFld = const_cast<Field<Type>&>(this->primitiveField());
185 UIndirectList<Type>(intFld, this->patch().faceCells()) = nbrIntFld;
186}
187
188
189template<class Type>
191(
192 Ostream& os
193) const
194{
196}
197
198
199// ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Generic templated field type.
Definition: Field.H:82
Generic GeometricField class.
void transfer(List< T > &list)
Definition: List.C:447
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
A List with indirect addressing. Like IndirectList but does not store addressing.
Definition: IndirectList.H:79
static int & msgType() noexcept
Message tag of standard messages.
Definition: UPstream.H:556
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Smooth ATC in cells next to a set of patches supplied by type.
Definition: faceCells.H:59
virtual bool write()
Write the output fields.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
A FieldMapper for finite-volume patch fields.
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:82
virtual tmp< Field< Type > > patchInternalField() const
Return internal field next to patch as patch field.
Definition: fvPatchField.C:237
const fvPatch & patch() const
Return patch.
Definition: fvPatchField.H:362
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:71
virtual label start() const
Return start label of this patch in the polyMesh face list.
Definition: fvPatch.H:179
This boundary condition maps the boundary and internal values of a neighbour patch field to the bound...
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
This boundary condition maps the value at a set of cells or patch faces back to *this.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Determines a mapping between patch face centres and mesh cell or face centres and processors they're ...
@ NEARESTCELL
nearest cell containing sample
@ NEARESTPATCHFACE
nearest face on selected patch
@ NEARESTPATCHFACEAMI
nearest patch face + AMI interpolation
@ NEARESTFACE
nearest face
static const Enum< sampleMode > sampleModeNames_
const polyMesh & sampleMesh() const
Get the region mesh.
const polyPatch & samplePolyPatch() const
Get the patch on the region.
void distribute(List< Type > &lst) const
Wrapper around map/interpolate data distribution.
sampleMode mode() const noexcept
What to sample.
label index() const noexcept
The index of this patch in the boundaryMesh.
label nFaces() const noexcept
Number of mesh faces.
volScalarField & p
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
OBJstream os(runTime.globalPath()/outputName)
errorManip< error > abort(error &err)
Definition: errorManip.H:144
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
error FatalError
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333