codedFixedValueFvPatchField.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2026 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
28 
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
30 
31 template<class Type>
33 (
34  {"code", "codeInclude", "localCode"}
35 );
36 
37 template<class Type>
39 (
40  {word::null, word::null, word::null}
41 );
42 
43 template<class Type>
45 (
46  "codedFixedValueFvPatchFieldOptions"
47 );
48 
49 template<class Type>
51 {
52  "codedFixedValueFvPatchFieldTemplate.C"
53 };
54 
55 template<class Type>
57 {
58  "codedFixedValueFvPatchFieldTemplate.H"
59 };
60 
61 
62 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
63 
64 template<class Type>
66 (
67  const fvPatch& p,
69  const dictionary& dict
70 )
71 :
72  fixedValueFvPatchField<Type>(p, iF, dict),
73  codedBase
74  (
75  dict.lookupOrDefault<word>
76  (
77  "name",
78  (
79  iF.mesh().name() == polyMesh::defaultRegion
80  ? word::null
81  : word(iF.mesh().name() + '_')
82  )
83  + iF.name() + '_' + p.name()
84  ),
85  dict,
86  codeKeys,
87  codeDictVars,
88  codeOptions,
89  compileFiles,
90  copyFiles
91  )
92 {
93  const word fieldType(pTraits<Type>::typeName);
94 
95  // Set variable substitutions
96  varSubstitutions().set
97  (
98  {
99  {"TemplateType", fieldType},
100  {"FieldType", fieldType.capitalise() + "Field"},
101  {"verbose", Foam::name(bool(debug))}
102  }
103  );
104 
106 }
107 
108 
109 template<class Type>
111 (
113  const fvPatch& p,
115  const fieldMapper& mapper
116 )
117 :
118  fixedValueFvPatchField<Type>(ptf, p, iF, mapper),
119  codedBase(ptf)
120 {}
121 
122 
123 template<class Type>
125 (
128 )
129 :
130  fixedValueFvPatchField<Type>(ptf, iF),
131  codedBase(ptf)
132 {}
133 
134 
135 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
136 
137 template<class Type>
140 {
141  if (!redirectPatchFieldPtr_.valid())
142  {
143  OStringStream os;
144  writeEntry(os, "type", codeName());
145 
146  if (this->overridesConstraint())
147  {
148  writeEntry(os, "patchType", this->patch().type());
149  }
150 
151  writeEntry(os, "value", *this);
152 
153  IStringStream is(os.str());
154  dictionary dict(is);
155 
156  redirectPatchFieldPtr_.set
157  (
159  (
160  this->patch(),
161  this->internalField(),
162  dict
163  ).ptr()
164  );
165  }
166 
167  return redirectPatchFieldPtr_();
168 }
169 
170 
171 template<class Type>
173 {
174  if (this->updated())
175  {
176  return;
177  }
178 
179  const fvPatchField<Type>& fvp = redirectPatchField();
180 
181  const_cast<fvPatchField<Type>&>(fvp).updateCoeffs();
182 
183  // Copy through value
184  this->operator==(fvp);
185 
187 }
188 
189 
190 template<class Type>
192 (
193  const Pstream::commsTypes commsType
194 )
195 {
196  const fvPatchField<Type>& fvp = redirectPatchField();
197 
198  const_cast<fvPatchField<Type>&>(fvp).evaluate(commsType);
199 
201 }
202 
203 
204 template<class Type>
206 {
208  codedBase::write(os);
209 }
210 
211 
212 // ************************************************************************* //
Macros for easy insertion into run-time selection tables.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Input from memory buffer stream.
Definition: IStringStream.H:52
Output to memory buffer stream.
Definition: OStringStream.H:52
string str() const
Return the string.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
commsTypes
Types of communications.
Definition: UPstream.H:65
Base class for coded functionObjects, fvModels, Function1, Function2.
Definition: codedBase.H:53
bool updateLibrary(const dictionary &dict) const
Update library from given updated dictionary as required.
Definition: codedBase.C:230
Fixed value boundary condition evaluated from the code provided.
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Evaluate the patch field, sets Updated to false.
virtual void write(Ostream &) const
Write.
codedFixedValueFvPatchField(const fvPatch &, const DimensionedField< Type, fvMesh > &, const dictionary &)
Construct from patch, internal field and dictionary.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
const fvPatchField< Type > & redirectPatchField() const
Get reference to the underlying patch.
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
HashTable< string > & varSubstitutions()
Definition: dynamicCode.H:252
void write(Ostream &os) const
Write the code for restart.
Definition: dynamicCode.C:744
Abstract base class for field mapping.
Definition: fieldMapper.H:48
This boundary condition supplies a fixed value constraint, and is the base class for a number of othe...
virtual void write(Ostream &) const
Write.
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:90
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Evaluate the patch field, sets Updated to false.
Definition: fvPatchField.C:215
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: fvPatchField.C:208
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:58
Traits class for primitives.
Definition: pTraits.H:53
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:78
A class for handling words, derived from string.
Definition: word.H:63
word capitalise() const
Return the word with the first letter capitalised.
Definition: wordI.H:131
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
tmp< fvMatrix< Type > > operator==(const fvMatrix< Type > &, const fvMatrix< Type > &)
void evaluate(GeometricField< Type, GeoMesh > &result, const Function1< Type > &func, const GeometricField< Type, GeoMesh > &x)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
void writeEntry(Ostream &os, const word &key, const DimensionedFieldFunction< DimensionedFieldType > &f)
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488
dictionary dict
volScalarField & p