1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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.
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
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/>.
25 Foam::codedFixedValueFvPatchField
28 Constructs on-the-fly a new boundary condition (derived from
29 fixedValueFvPatchField) which is then used to evaluate.
37 redirectType rampedFixedValue; // name of generated bc
41 operator==(min(10, 0.1*this->db().time().value()));
51 // -I$(LIB_SRC)/finiteVolume/lnInclude
56 A special form is if the 'code' section is not supplied. In this case
57 the code gets read from a (runTimeModifiable!) dictionary system/codeDict
58 which would have a corresponding entry
65 operator==(min(10, 0.1*this->db().time().value()));
71 Foam::dynamicCode and Foam::functionEntries::codeStream
74 codedFixedValueFvPatchField.C
76 \*---------------------------------------------------------------------------*/
78 #ifndef codedFixedValueFvPatchField_H
79 #define codedFixedValueFvPatchField_H
81 #include "fixedValueFvPatchFields.H"
86 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
91 // Forward declaration of classes
93 class dynamicCodeContext;
96 /*---------------------------------------------------------------------------*\
97 Class codedFixedValueFvPatch Declaration
98 \*---------------------------------------------------------------------------*/
101 class codedFixedValueFvPatchField
103 public fixedValueFvPatchField<Type>
107 //- Dictionary contents for the boundary condition
108 mutable dictionary dict_;
110 const word redirectType_;
112 //- Previously loaded library
113 mutable fileName oldLibPath_;
115 mutable autoPtr<fvPatchField<Type> > redirectPatchFieldPtr_;
118 // Private Member Functions
120 const IOdictionary& dict() const;
122 //- Global loader/unloader function type
123 typedef void (*loaderFunctionType)(bool);
125 static int collectLibsCallback
127 struct dl_phdr_info *info,
132 //- Load specified library and execute globalFuncName(true)
135 const fileName& libPath,
136 const string& globalFuncName,
137 const dictionary& contextDict
140 //- Execute globalFuncName(false) and unload specified library
143 const fileName& libPath,
144 const string& globalFuncName,
145 const dictionary& contextDict
148 //- Set the rewrite vars controlling the Type
149 static void setFieldTemplates(dynamicCode& dynCode);
151 //- Create library based on the dynamicCodeContext
152 void createLibrary(dynamicCode&, const dynamicCodeContext&) const;
154 //- Update library as required
155 void updateLibrary() const;
160 // Static data members
162 //- Name of the C code template to be used
163 static const word codeTemplateC;
165 //- Name of the H code template to be used
166 static const word codeTemplateH;
169 //- Runtime type information
170 TypeName("codedFixedValue");
175 //- Construct from patch and internal field
176 codedFixedValueFvPatchField
179 const DimensionedField<Type, volMesh>&
182 //- Construct from patch, internal field and dictionary
183 codedFixedValueFvPatchField
186 const DimensionedField<Type, volMesh>&,
190 //- Construct by mapping given codedFixedValueFvPatchField
192 codedFixedValueFvPatchField
194 const codedFixedValueFvPatchField<Type>&,
196 const DimensionedField<Type, volMesh>&,
197 const fvPatchFieldMapper&
200 //- Construct as copy
201 codedFixedValueFvPatchField
203 const codedFixedValueFvPatchField<Type>&
206 //- Construct and return a clone
207 virtual tmp<fvPatchField<Type> > clone() const
209 return tmp<fvPatchField<Type> >
211 new codedFixedValueFvPatchField<Type>(*this)
215 //- Construct as copy setting internal field reference
216 codedFixedValueFvPatchField
218 const codedFixedValueFvPatchField<Type>&,
219 const DimensionedField<Type, volMesh>&
222 //- Construct and return a clone setting internal field reference
223 virtual tmp<fvPatchField<Type> > clone
225 const DimensionedField<Type, volMesh>& iF
228 return tmp<fvPatchField<Type> >
230 new codedFixedValueFvPatchField<Type>(*this, iF)
239 //- Get reference to the underlying patch
240 const fvPatchField<Type>& redirectPatchField() const;
242 //- Update the coefficients associated with the patch field
243 virtual void updateCoeffs();
245 //- Evaluate the patch field, sets Updated to false
246 virtual void evaluate
248 const Pstream::commsTypes commsType=Pstream::blocking
252 virtual void write(Ostream&) const;
256 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
258 } // End namespace Foam
260 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
263 # include "codedFixedValueFvPatchField.C"
266 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
270 // ************************************************************************* //