diff --git a/etc/codeTemplates/dynamicCode/fixedValueFvPatchScalarFieldTemplate.C b/etc/codeTemplates/dynamicCode/fixedValueFvPatchFieldTemplate.C similarity index 71% rename from etc/codeTemplates/dynamicCode/fixedValueFvPatchScalarFieldTemplate.C rename to etc/codeTemplates/dynamicCode/fixedValueFvPatchFieldTemplate.C index d41c4162e6..0d110e7469 100644 --- a/etc/codeTemplates/dynamicCode/fixedValueFvPatchScalarFieldTemplate.C +++ b/etc/codeTemplates/dynamicCode/fixedValueFvPatchFieldTemplate.C @@ -23,7 +23,7 @@ License \*---------------------------------------------------------------------------*/ -#include "fixedValueFvPatchScalarFieldTemplate.H" +#include "fixedValueFvPatchFieldTemplate.H" #include "addToRunTimeSelectionTable.H" #include "fvPatchFieldMapper.H" #include "volFields.H" @@ -71,25 +71,25 @@ extern "C" makeRemovablePatchTypeField ( - fvPatchScalarField, - ${typeName}FixedValueFvPatchScalarField + fvPatch${FieldType}, + ${typeName}FixedValueFvPatch${FieldType} ); -const char* const ${typeName}FixedValueFvPatchScalarField::SHA1sum = +const char* const ${typeName}FixedValueFvPatch${FieldType}::SHA1sum = "${SHA1sum}"; // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -${typeName}FixedValueFvPatchScalarField:: -${typeName}FixedValueFvPatchScalarField +${typeName}FixedValueFvPatch${FieldType}:: +${typeName}FixedValueFvPatch${FieldType} ( const fvPatch& p, - const DimensionedField& iF + const DimensionedField<${TemplateType}, volMesh>& iF ) : - fixedValueFvPatchScalarField(p, iF) + fixedValueFvPatchField<${TemplateType}>(p, iF) { if (${verbose:-false}) { @@ -99,16 +99,16 @@ ${typeName}FixedValueFvPatchScalarField } -${typeName}FixedValueFvPatchScalarField:: -${typeName}FixedValueFvPatchScalarField +${typeName}FixedValueFvPatch${FieldType}:: +${typeName}FixedValueFvPatch${FieldType} ( - const ${typeName}FixedValueFvPatchScalarField& ptf, + const ${typeName}FixedValueFvPatch${FieldType}& ptf, const fvPatch& p, - const DimensionedField& iF, + const DimensionedField<${TemplateType}, volMesh>& iF, const fvPatchFieldMapper& mapper ) : - fixedValueFvPatchScalarField(ptf, p, iF, mapper) + fixedValueFvPatchField<${TemplateType}>(ptf, p, iF, mapper) { if (${verbose:-false}) { @@ -118,15 +118,15 @@ ${typeName}FixedValueFvPatchScalarField } -${typeName}FixedValueFvPatchScalarField:: -${typeName}FixedValueFvPatchScalarField +${typeName}FixedValueFvPatch${FieldType}:: +${typeName}FixedValueFvPatch${FieldType} ( const fvPatch& p, - const DimensionedField& iF, + const DimensionedField<${TemplateType}, volMesh>& iF, const dictionary& dict ) : - fixedValueFvPatchScalarField(p, iF, dict) + fixedValueFvPatchField<${TemplateType}>(p, iF, dict) { if (${verbose:-false}) { @@ -136,13 +136,13 @@ ${typeName}FixedValueFvPatchScalarField } -${typeName}FixedValueFvPatchScalarField:: -${typeName}FixedValueFvPatchScalarField +${typeName}FixedValueFvPatch${FieldType}:: +${typeName}FixedValueFvPatch${FieldType} ( - const ${typeName}FixedValueFvPatchScalarField& ptf + const ${typeName}FixedValueFvPatch${FieldType}& ptf ) : - fixedValueFvPatchScalarField(ptf) + fixedValueFvPatchField<${TemplateType}>(ptf) { if (${verbose:-false}) { @@ -152,14 +152,14 @@ ${typeName}FixedValueFvPatchScalarField } -${typeName}FixedValueFvPatchScalarField:: -${typeName}FixedValueFvPatchScalarField +${typeName}FixedValueFvPatch${FieldType}:: +${typeName}FixedValueFvPatch${FieldType} ( - const ${typeName}FixedValueFvPatchScalarField& ptf, - const DimensionedField& iF + const ${typeName}FixedValueFvPatch${FieldType}& ptf, + const DimensionedField<${TemplateType}, volMesh>& iF ) : - fixedValueFvPatchScalarField(ptf, iF) + fixedValueFvPatchField<${TemplateType}>(ptf, iF) { if (${verbose:-false}) { @@ -171,8 +171,8 @@ ${typeName}FixedValueFvPatchScalarField // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // -${typeName}FixedValueFvPatchScalarField:: -~${typeName}FixedValueFvPatchScalarField() +${typeName}FixedValueFvPatch${FieldType}:: +~${typeName}FixedValueFvPatch${FieldType}() { if (${verbose:-false}) { @@ -183,7 +183,7 @@ ${typeName}FixedValueFvPatchScalarField:: // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void ${typeName}FixedValueFvPatchScalarField::updateCoeffs() +void ${typeName}FixedValueFvPatch${FieldType}::updateCoeffs() { if (this->updated()) { @@ -199,7 +199,7 @@ void ${typeName}FixedValueFvPatchScalarField::updateCoeffs() ${code} //}}} end code - fixedValueFvPatchScalarField::updateCoeffs(); + this->fixedValueFvPatchField<${TemplateType}>::updateCoeffs(); } diff --git a/etc/codeTemplates/dynamicCode/fixedValueFvPatchScalarFieldTemplate.H b/etc/codeTemplates/dynamicCode/fixedValueFvPatchFieldTemplate.H similarity index 60% rename from etc/codeTemplates/dynamicCode/fixedValueFvPatchScalarFieldTemplate.H rename to etc/codeTemplates/dynamicCode/fixedValueFvPatchFieldTemplate.H index 9fe2d88f70..5031d042c5 100644 --- a/etc/codeTemplates/dynamicCode/fixedValueFvPatchScalarFieldTemplate.H +++ b/etc/codeTemplates/dynamicCode/fixedValueFvPatchFieldTemplate.H @@ -21,21 +21,19 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see . -Class - Foam::fixedValueFvPatchScalarFieldTemplate - Description - Template for use with onTheFlyFixedValue. - - fixedValueFvPatchScalarField + Template for use with dynamic code generation of a + fixedValue fvPatchField. + - without state SourceFiles - fixedValueFvPatchScalarFieldTemplate.C + fixedValueFvPatchFieldTemplate.C \*---------------------------------------------------------------------------*/ -#ifndef fixedValueFvPatchScalarFieldTemplate_H -#define fixedValueFvPatchScalarFieldTemplate_H +#ifndef fixedValueFvPatchTemplate${FieldType}_H +#define fixedValueFvPatchTemplate${FieldType}_H #include "fixedValueFvPatchFields.H" @@ -45,14 +43,13 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class fixedValueFvPatchScalarField Declaration + A templated FixedValueFvPatch \*---------------------------------------------------------------------------*/ -class ${typeName}FixedValueFvPatchScalarField +class ${typeName}FixedValueFvPatch${FieldType} : - public fixedValueFvPatchScalarField + public fixedValueFvPatchField<${TemplateType}> { - public: //- Information about the SHA1 of the code itself @@ -65,75 +62,72 @@ public: // Constructors //- Construct from patch and internal field - ${typeName}FixedValueFvPatchScalarField + ${typeName}FixedValueFvPatch${FieldType} ( const fvPatch&, - const DimensionedField& + const DimensionedField<${TemplateType}, volMesh>& ); //- Construct from patch, internal field and dictionary - ${typeName}FixedValueFvPatchScalarField + ${typeName}FixedValueFvPatch${FieldType} ( const fvPatch&, - const DimensionedField&, + const DimensionedField<${TemplateType}, volMesh>&, const dictionary& ); - //- Construct by mapping given - // ${typeName}FixedValueFvPatchScalarField - // onto a new patch - ${typeName}FixedValueFvPatchScalarField + //- Construct by mapping a copy onto a new patch + ${typeName}FixedValueFvPatch${FieldType} ( - const ${typeName}FixedValueFvPatchScalarField&, + const ${typeName}FixedValueFvPatch${FieldType}&, const fvPatch&, - const DimensionedField&, + const DimensionedField<${TemplateType}, volMesh>&, const fvPatchFieldMapper& ); //- Construct as copy - ${typeName}FixedValueFvPatchScalarField + ${typeName}FixedValueFvPatch${FieldType} ( - const ${typeName}FixedValueFvPatchScalarField& + const ${typeName}FixedValueFvPatch${FieldType}& ); //- Construct and return a clone - virtual tmp clone() const + virtual tmp< fvPatch${FieldType} > clone() const { - return tmp + return tmp< fvPatch${FieldType} > ( - new ${typeName}FixedValueFvPatchScalarField(*this) + new ${typeName}FixedValueFvPatch${FieldType}(*this) ); } //- Construct as copy setting internal field reference - ${typeName}FixedValueFvPatchScalarField + ${typeName}FixedValueFvPatch${FieldType} ( - const ${typeName}FixedValueFvPatchScalarField&, - const DimensionedField& + const ${typeName}FixedValueFvPatch${FieldType}&, + const DimensionedField<${TemplateType}, volMesh>& ); //- Construct and return a clone setting internal field reference - virtual tmp clone + virtual tmp< fvPatch${FieldType} > clone ( - const DimensionedField& iF + const DimensionedField<${TemplateType}, volMesh>& iF ) const { - return tmp + return tmp< fvPatch${FieldType} > ( - new ${typeName}FixedValueFvPatchScalarField(*this, iF) + new ${typeName}FixedValueFvPatch${FieldType}(*this, iF) ); } + //- Destructor - virtual ~${typeName}FixedValueFvPatchScalarField(); + virtual ~${typeName}FixedValueFvPatch${FieldType}(); // Member functions - // Evaluation functions - - //- Update the coefficients associated with the patch field - virtual void updateCoeffs(); + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); }; diff --git a/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchScalarField.C index fb4fdbef83..0f738d022a 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchScalarField.C @@ -36,14 +36,16 @@ License #include "dynamicCode.H" #include "dynamicCodeContext.H" #include "stringOps.H" +#include + // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // const Foam::word Foam::codedFixedValueFvPatchScalarField::codeTemplateC - = "fixedValueFvPatchScalarFieldTemplate.C"; + = "fixedValueFvPatchFieldTemplate.C"; const Foam::word Foam::codedFixedValueFvPatchScalarField::codeTemplateH - = "fixedValueFvPatchScalarFieldTemplate.H"; + = "fixedValueFvPatchFieldTemplate.H"; // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // @@ -172,6 +174,24 @@ void Foam::codedFixedValueFvPatchScalarField::unloadLibrary } + +template +void Foam::codedFixedValueFvPatchScalarField::setFieldTemplates +( + dynamicCode& dynCode +) +{ + word fieldType(pTraits::typeName); + + // template type for fvPatchField + dynCode.setFilterVariable("TemplateType", fieldType); + + // Name for fvPatchField - eg, ScalarField, VectorField, ... + fieldType[0] = toupper(fieldType[0]); + dynCode.setFilterVariable("FieldType", fieldType + "Field"); +} + + // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // const Foam::IOdictionary& Foam::codedFixedValueFvPatchScalarField::dict() const @@ -216,19 +236,24 @@ void Foam::codedFixedValueFvPatchScalarField::createLibrary // filter with this context dynCode.reset(context); + // take no chances - typeName must be identical to redirectType_ + dynCode.setFilterVariable("typeName", redirectType_); + + // set TemplateType and FieldType filter variables + // (for fvPatchField) + setFieldTemplates(dynCode); + // compile filtered C template dynCode.addCompileFile(codeTemplateC); // copy filtered H template dynCode.addCopyFile(codeTemplateH); - // take no chances - typeName must be identical to redirectType_ - dynCode.setFilterVariable("typeName", redirectType_); // debugging: make BC verbose - // dynCode.setFilterVariable("verbose", "true"); - // Info<<"compile " << redirectType_ << " sha1: " - // << context.sha1() << endl; + // dynCode.setFilterVariable("verbose", "true"); + // Info<<"compile " << redirectType_ << " sha1: " + // << context.sha1() << endl; // define Make/options dynCode.setMakeOptions diff --git a/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchScalarField.H b/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchScalarField.H index 003f03dc6c..6eb8e9c533 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchScalarField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchScalarField.H @@ -136,6 +136,11 @@ class codedFixedValueFvPatchScalarField ); + //- Set TemplateType and FieldType filter variables + template + static void setFieldTemplates(dynamicCode&); + + //- Create library based on the dynamicCodeContext void createLibrary(dynamicCode&, const dynamicCodeContext&) const;