immersedBoundaryWallFunctionFvPatchField.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | foam-extend: Open Source CFD
4  \\ / O peration | Version: 3.2
5  \\ / A nd | Web: http://www.foam-extend.org
6  \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
8 License
9  This file is part of foam-extend.
10 
11  foam-extend is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by the
13  Free Software Foundation, either version 3 of the License, or (at your
14  option) any later version.
15 
16  foam-extend is distributed in the hope that it will be useful, but
17  WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  General Public License for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
27 #include "fvPatchFieldMapper.H"
29 #include "wallFvPatch.H"
30 
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35 namespace incompressible
36 {
37 namespace RASModels
38 {
39 
40 // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
41 
42 
43 
44 template<class Type>
46 (
47  const Field<Type>& ibcValues
48 ) const
49 {
50  const labelList& ibc = this->ibPatch().ibCells();
51 
52  if (ibcValues.size() != ibc.size())
53  {
55  (
56  "template<class Type>\n"
57  "void immersedBoundaryWallFunctionFvPatchField<Type>::"
58  "setIbCellValues\n"
59  "(\n"
60  " const Field<Type>& ibcValues\n"
61  ") const"
62  ) << "Size of ibcValues field not equal to the number of IB cells."
63  << nl << "ibcValues: " << ibcValues.size()
64  << " ibc: " << ibc.size()
65  << abort(FatalError);
66  }
67 
68  // Get non-const access to internal field
69  Field<Type>& psiI = const_cast<Field<Type>&>(this->internalField());
70 
71  if (wallValue_.empty() || wallMask_.empty())
72  {
74  }
75  else
76  {
77  forAll (ibcValues, cellI)
78  {
79  // If mask is set use the wall value, otherwise use the
80  // fitted value
81  if (wallMask_[cellI])
82  {
83  psiI[ibc[cellI]] = wallValue_[cellI];
84  }
85  else
86  {
87  psiI[ibc[cellI]] = ibcValues[cellI];
88  }
89  }
90  }
91 }
92 
93 
94 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
95 
96 template<class Type>
99 (
100  const fvPatch& p,
102 )
103 :
105  wallValue_(),
106  wallMask_()
107 {}
108 
109 
110 template<class Type>
113 (
114  const fvPatch& p,
116  const dictionary& dict
117 )
118 :
120  wallValue_(),
121  wallMask_()
122 {}
123 
124 
125 template<class Type>
128 (
130  const fvPatch& p,
132  const fvPatchFieldMapper& mapper
133 )
134 :
135  immersedBoundaryFvPatchField<Type>(ptf, p, iF, mapper),
136  wallValue_(),
137  wallMask_()
138 {}
139 
140 
141 template<class Type>
144 (
146 )
147 :
149  wallValue_(),
150  wallMask_()
151 {}
152 
153 
154 template<class Type>
157 (
160 )
161 :
163  wallValue_(),
164  wallMask_()
165 {}
166 
167 
168 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
169 
170 template<class Type>
172 {
173  // Note: on a moving mesh, the intersection has changed and
174  // wallValue fields should be cleared and recalculated.
175  // This should happen only once, but I cannot see the mechanism
176  // HJ, 17/Oct/2012
177  // Bugfix 30/OCT/2015 - check if the mesh is moving
178 
179  const immersedBoundaryFvPatch& ibFvP =
181 
182  if
183  (
184  wallValue_.empty()
185  || (ibFvP.movingIb() || ibFvP.boundaryMesh().mesh().moving())
186  )
187  {
188  wallValue_.setSize
189  (
190  this->ibPatch().ibCells().size(),
192  );
193  }
194 
195  return wallValue_;
196 }
197 
198 
199 template<class Type>
201 {
202  // Note: on a moving mesh, the intersection has changed and
203  // wallValue fields should be cleared and recalculated.
204  // This should happen only once, but I cannot see the mechanism
205  // HJ, 17/Oct/2012
206  // Bugfix 30/OCT/2015 - check if the mesh is moving
207  const immersedBoundaryFvPatch& ibFvP =
209 
210  if
211  (
212  wallMask_.empty()
213  || (ibFvP.movingIb() || ibFvP.boundaryMesh().mesh().moving())
214  )
215  {
216  wallMask_.setSize
217  (
218  this->ibPatch().ibCells().size(),
219  false
220  );
221  }
222 
223  return wallMask_;
224 }
225 
226 
227 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
228 
229 } // End namespace RASModels
230 } // End namespace incompressible
231 } // End namespace Foam
232 
233 // ************************************************************************* //
p
p
Definition: pEqn.H:62
Foam::immersedBoundaryFvPatch::movingIb
bool movingIb() const
Is the immersed boundary patch moving?
Definition: immersedBoundaryFvPatch.H:378
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::polyMesh::moving
bool moving() const
Is mesh moving.
Definition: polyMesh.H:493
wallFvPatch.H
Foam::incompressible::RASModels::immersedBoundaryWallFunctionFvPatchField::immersedBoundaryWallFunctionFvPatchField
immersedBoundaryWallFunctionFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
Definition: immersedBoundaryWallFunctionFvPatchField.C:99
fvPatchFieldMapper.H
Foam::incompressible::RASModels::immersedBoundaryWallFunctionFvPatchField
Boundary condition for passive turbulence variables (U, k, q, R, nut) when using wall functions on an...
Definition: immersedBoundaryWallFunctionFvPatchField.H:71
Foam::fvBoundaryMesh::mesh
const fvMesh & mesh() const
Return the mesh reference.
Definition: fvBoundaryMesh.H:99
Foam::fvPatch::boundaryMesh
const fvBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
Definition: fvPatch.H:185
Foam::Field< Type >
Foam::immersedBoundaryFvPatch
Immersed boundary FV patch.
Definition: immersedBoundaryFvPatch.H:66
Foam::immersedBoundaryFvPatchField::ibPatch
const immersedBoundaryFvPatch & ibPatch() const
Return reference to immersed boundary patch.
Definition: immersedBoundaryFvPatchField.H:235
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::incompressible::RASModels::immersedBoundaryWallFunctionFvPatchField::wallValue
Field< Type > & wallValue() const
Access to value to fix in IB cell. Note non-const access.
Definition: immersedBoundaryWallFunctionFvPatchField.C:171
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:131
internalField
conserve internalField()+
Foam::immersedBoundaryFvPatchField::setIbCellValues
virtual void setIbCellValues(const Field< Type > &) const
Set IB cell values.
Definition: immersedBoundaryFvPatchField.C:725
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::pTraits
Traits class for primitives.
Definition: pTraits.H:50
Foam::immersedBoundaryFvPatchField
Foam::immersedBoundaryFvPatchField.
Definition: immersedBoundaryFvPatchField.H:53
Foam::incompressible::RASModels::immersedBoundaryWallFunctionFvPatchField::wallMask
boolList & wallMask() const
Access to indicator on fixed values. Note non-const access.
Definition: immersedBoundaryWallFunctionFvPatchField.C:200
Foam::incompressible::RASModels::immersedBoundaryWallFunctionFvPatchField::setIbCellValues
virtual void setIbCellValues(const Field< Type > &) const
Set IB cell values: contains data manipulation.
Definition: immersedBoundaryWallFunctionFvPatchField.C:46
FatalErrorIn
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:313
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:45
Foam::List::size
void size(const label)
Override size to be inconsistent with allocated storage.
immersedBoundaryWallFunctionFvPatchField.H
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:51