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 -------------------------------------------------------------------------------
10 License
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 "UIndirectList.H"
30 
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 
33 template<class Type>
36 (
37  const fvPatch& p,
39 )
40 :
42 {}
43 
44 
45 template<class Type>
48 (
50  const fvPatch& p,
52  const fvPatchFieldMapper& mapper
53 )
54 :
55  mappedFixedValueFvPatchField<Type>(ptf, p, iF, mapper)
56 {}
57 
58 
59 template<class Type>
62 (
63  const fvPatch& p,
65  const dictionary& dict
66 )
67 :
69 {}
70 
71 
72 template<class Type>
75 (
77 )
78 :
80 {}
81 
82 
83 template<class Type>
86 (
89 )
90 :
92 {}
93 
94 
95 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
96 
97 template<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  {
124  case mappedPatchBase::NEARESTCELL:
125  {
127  << "Cannot apply "
128  << mappedPatchBase::sampleModeNames_
129  [
130  mappedPatchBase::NEARESTCELL
131  ]
132  << " mapping mode for patch " << this->patch().name()
133  << exit(FatalError);
134 
135  break;
136  }
137  case mappedPatchBase::NEARESTPATCHFACE:
138  case mappedPatchBase::NEARESTPATCHFACEAMI:
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  }
148  case mappedPatchBase::NEARESTFACE:
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 
189 template<class Type>
191 (
192  Ostream& os
193 ) const
194 {
196 }
197 
198 
199 // ************************************************************************* //
Foam::fvPatchField
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: volSurfaceMapping.H:51
p
volScalarField & p
Definition: createFieldRefs.H:8
UIndirectList.H
Foam::mappedFixedValueFvPatchField
This boundary condition maps the value at a set of cells or patch faces back to *this.
Definition: mappedFixedValueFvPatchField.H:125
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
Foam::mappedPatchBase::samplePolyPatch
const polyPatch & samplePolyPatch() const
Get the patch on the region.
Definition: mappedPatchBase.C:1662
Foam::mappedPatchBase
Determines a mapping between patch face centres and mesh cell or face centres and processors they're ...
Definition: mappedPatchBase.H:112
Foam::mappedFixedInternalValueFvPatchField
This boundary condition maps the boundary and internal values of a neighbour patch field to the bound...
Definition: mappedFixedInternalValueFvPatchField.H:105
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::mappedPatchBase::sampleMesh
const polyMesh & sampleMesh() const
Get the region mesh.
Definition: mappedPatchBase.C:1649
Foam::Field
Generic templated field type.
Definition: Field.H:63
Foam::mappedPatchBase::distribute
void distribute(List< Type > &lst) const
Wrapper around map/interpolate data distribution.
Definition: mappedPatchBaseTemplates.C:30
Foam::mappedPatchBase::mode
sampleMode mode() const noexcept
What to sample.
Definition: mappedPatchBaseI.H:30
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:65
Foam::fvPatchField::patchInternalField
virtual tmp< Field< Type > > patchInternalField() const
Return internal field next to patch as patch field.
Definition: fvPatchField.C:233
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
os
OBJstream os(runTime.globalPath()/outputName)
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
Foam::patchIdentifier::index
label index() const noexcept
The index of this patch in the boundaryMesh.
Definition: patchIdentifier.H:147
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:144
Foam::mappedFixedInternalValueFvPatchField::mappedFixedInternalValueFvPatchField
mappedFixedInternalValueFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
Definition: mappedFixedInternalValueFvPatchField.C:36
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
mappedFixedInternalValueFvPatchField.H
Foam::vtk::write
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
Definition: foamVtkOutputTemplates.C:36
Foam::UIndirectList
A List with indirect addressing.
Definition: faMatrix.H:60
Foam::primitiveMesh::nFaces
label nFaces() const noexcept
Number of mesh faces.
Definition: primitiveMeshI.H:90
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:47
Foam::fvPatchField::patch
const fvPatch & patch() const
Return patch.
Definition: fvPatchField.H:357
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::mappedFixedInternalValueFvPatchField::write
virtual void write(Ostream &os) const
Write.
Definition: mappedFixedInternalValueFvPatchField.C:191
Foam::GeometricField< Type, fvPatchField, volMesh >
Foam::faceCells
Smooth ATC in cells next to a set of patches supplied by type.
Definition: faceCells.H:56
Foam::mappedFixedInternalValueFvPatchField::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: mappedFixedInternalValueFvPatchField.C:98
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54