ENH: refactor fixedValueFvPatchFieldTemplate

- can be reused for other (vector, tensor, ...) field types
This commit is contained in:
Mark Olesen
2011-03-11 17:28:51 +01:00
parent 12d965ead9
commit 7a0d3ebd64
4 changed files with 100 additions and 76 deletions

View File

@ -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();
}

View File

@ -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();
};