codedFixedValuePointPatchField.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) 2012-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 #include "fieldMapper.H"
29 #include "pointFields.H"
30 #include "dynamicCode.H"
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 template<class Type>
36 (
37  {"code", "codeInclude", "localCode"}
38 );
39 
40 template<class Type>
42 (
43  {word::null, word::null, word::null}
44 );
45 
46 template<class Type>
48 (
49  "codedFixedValuePointPatchFieldOptions"
50 );
51 
52 template<class Type>
54 {
55  "codedFixedValuePointPatchFieldTemplate.C"
56 };
57 
58 template<class Type>
60 {
61  "codedFixedValuePointPatchFieldTemplate.H"
62 };
63 
64 
65 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
66 
67 template<class Type>
69 (
70  const pointPatch& p,
72  const dictionary& dict
73 )
74 :
75  fixedValuePointPatchField<Type>(p, iF, dict),
76  codedBase
77  (
78  dict.lookup("name"),
79  dict,
80  codeKeys,
81  codeDictVars,
82  codeOptions,
83  compileFiles,
84  copyFiles
85  )
86 {
87  const word fieldType(pTraits<Type>::typeName);
88 
89  // Set variable substitutions
90  varSubstitutions().set
91  (
92  {
93  {"TemplateType", fieldType},
94  {"FieldType", fieldType.capitalise() + "Field"},
95  {"verbose", Foam::name(bool(debug))}
96  }
97  );
98 
99  // Compile the library containing user-defined pointPatchField
101 }
102 
103 
104 template<class Type>
106 (
108  const pointPatch& p,
110  const fieldMapper& mapper
111 )
112 :
113  fixedValuePointPatchField<Type>(ptf, p, iF, mapper),
114  codedBase(ptf)
115 {}
116 
117 
118 template<class Type>
120 (
123 )
124 :
125  fixedValuePointPatchField<Type>(ptf, iF),
126  codedBase(ptf)
127 {}
128 
129 
130 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
131 
132 template<class Type>
135 {
136  if (!redirectPatchFieldPtr_.valid())
137  {
138  OStringStream os;
139  writeEntry(os, "type", codeName());
140  writeEntry(os, "value", static_cast<const Field<Type>&>(*this));
141  IStringStream is(os.str());
142  dictionary dict(is);
143 
144  redirectPatchFieldPtr_.set
145  (
147  (
148  this->patch(),
149  this->internalField(),
150  dict
151  ).ptr()
152  );
153  }
154 
155  return redirectPatchFieldPtr_();
156 }
157 
158 
159 template<class Type>
161 {
162  if (this->updated())
163  {
164  return;
165  }
166 
167  const pointPatchField<Type>& fvp = redirectPatchField();
168 
169  const_cast<pointPatchField<Type>&>(fvp).updateCoeffs();
170 
171  // Copy through value
172  this->operator==(fvp);
173 
175 }
176 
177 
178 template<class Type>
180 (
181  const Pstream::commsTypes commsType
182 )
183 {
184  const pointPatchField<Type>& fvp = redirectPatchField();
185 
186  const_cast<pointPatchField<Type>&>(fvp).evaluate(commsType);
187 
189 }
190 
191 
192 template<class Type>
194 {
196  codedBase::write(os);
197 }
198 
199 
200 // ************************************************************************* //
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...
Pre-declare SubField and related Field type.
Definition: Field.H:83
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
Constructs on-the-fly a new boundary condition (derived from fixedValuePointPatchField) which is then...
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Evaluate the patch field, sets Updated to false.
codedFixedValuePointPatchField(const pointPatch &, const DimensionedField< Type, pointMesh > &, const dictionary &)
Construct from patch, internal field and dictionary.
virtual void write(Ostream &) const
Write.
const pointPatchField< Type > & redirectPatchField() const
Get reference to the underlying patch.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
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
A FixedValue boundary condition for pointField.
Traits class for primitives.
Definition: pTraits.H:53
Abstract base class for point-mesh patch fields.
Basic pointPatch represents a set of points from the mesh.
Definition: pointPatch.H:61
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Evaluate the patch field.
virtual void write(Ostream &) const
Write.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
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
const unitSet & lookup(const word &unitName)
Lookup and return the named unit from the table.
Definition: units.C:346
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)
dictionary dict
volScalarField & p