mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: refactor fixedValueFvPatchFieldTemplate
- can be reused for other (vector, tensor, ...) field types
This commit is contained in:
@ -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<scalar, volMesh>& 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<scalar, volMesh>& 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<scalar, volMesh>& 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<scalar, volMesh>& 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();
|
||||
}
|
||||
|
||||
|
||||
@ -21,21 +21,19 @@ License
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
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<scalar, volMesh>&
|
||||
const DimensionedField<${TemplateType}, volMesh>&
|
||||
);
|
||||
|
||||
//- Construct from patch, internal field and dictionary
|
||||
${typeName}FixedValueFvPatchScalarField
|
||||
${typeName}FixedValueFvPatch${FieldType}
|
||||
(
|
||||
const fvPatch&,
|
||||
const DimensionedField<scalar, volMesh>&,
|
||||
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<scalar, volMesh>&,
|
||||
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<fvPatchScalarField> clone() const
|
||||
virtual tmp< fvPatch${FieldType} > clone() const
|
||||
{
|
||||
return tmp<fvPatchScalarField>
|
||||
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<scalar, volMesh>&
|
||||
const ${typeName}FixedValueFvPatch${FieldType}&,
|
||||
const DimensionedField<${TemplateType}, volMesh>&
|
||||
);
|
||||
|
||||
//- Construct and return a clone setting internal field reference
|
||||
virtual tmp<fvPatchScalarField> clone
|
||||
virtual tmp< fvPatch${FieldType} > clone
|
||||
(
|
||||
const DimensionedField<scalar, volMesh>& iF
|
||||
const DimensionedField<${TemplateType}, volMesh>& iF
|
||||
) const
|
||||
{
|
||||
return tmp<fvPatchScalarField>
|
||||
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();
|
||||
};
|
||||
|
||||
|
||||
@ -36,14 +36,16 @@ License
|
||||
#include "dynamicCode.H"
|
||||
#include "dynamicCodeContext.H"
|
||||
#include "stringOps.H"
|
||||
#include <cstring>
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * 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<class Type>
|
||||
void Foam::codedFixedValueFvPatchScalarField::setFieldTemplates
|
||||
(
|
||||
dynamicCode& dynCode
|
||||
)
|
||||
{
|
||||
word fieldType(pTraits<Type>::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<scalar>(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
|
||||
|
||||
@ -136,6 +136,11 @@ class codedFixedValueFvPatchScalarField
|
||||
);
|
||||
|
||||
|
||||
//- Set TemplateType and FieldType filter variables
|
||||
template<class Type>
|
||||
static void setFieldTemplates(dynamicCode&);
|
||||
|
||||
|
||||
//- Create library based on the dynamicCodeContext
|
||||
void createLibrary(dynamicCode&, const dynamicCodeContext&) const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user