ENH: improve codeTemplates

- meshTools include/library for many (most) coded items

- add PatchFunction1 include for coded BCs to provide ready access
  to Function1 and PatchFunction1
This commit is contained in:
Mark Olesen
2021-06-01 12:07:20 +02:00
parent 2f6739b140
commit b0891824fa
28 changed files with 289 additions and 220 deletions

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2021 OpenCFD Ltd.
Copyright (C) YEAR AUTHOR, AFFILIATION
-------------------------------------------------------------------------------
License
@ -95,11 +95,11 @@ ${typeName}FvOption${SourceType}
const fvMesh& mesh
)
:
cellSetOption(name, modelType, dict, mesh)
fv::cellSetOption(name, modelType, dict, mesh)
{
if (${verbose:-false})
{
printMessage("Construct ${typeName} from components");
printMessage("Construct ${typeName} fvOption from dictionary");
}
}
@ -118,14 +118,15 @@ ${typeName}FvOption${SourceType}::
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void ${typeName}FvOption${SourceType}::correct
void
${typeName}FvOption${SourceType}::correct
(
GeometricField<${TemplateType}, fvPatchField, volMesh>& fld
)
{
if (${verbose:-false})
{
Info<<"${typeName}FvOption${SourceType}::correct()\n";
Info<< "${typeName}FvOption${SourceType}::correct()\n";
}
//{{{ begin code
@ -134,7 +135,8 @@ void ${typeName}FvOption${SourceType}::correct
}
void ${typeName}FvOption${SourceType}::addSup
void
${typeName}FvOption${SourceType}::addSup
(
fvMatrix<${TemplateType}>& eqn,
const label fieldi
@ -142,7 +144,7 @@ void ${typeName}FvOption${SourceType}::addSup
{
if (${verbose:-false})
{
Info<<"${typeName}FvOption${SourceType}::addSup()\n";
Info<< "${typeName}FvOption${SourceType}::addSup()\n";
}
//{{{ begin code
@ -151,7 +153,8 @@ void ${typeName}FvOption${SourceType}::addSup
}
void ${typeName}FvOption${SourceType}::addSup
void
${typeName}FvOption${SourceType}::addSup
(
const volScalarField& rho,
fvMatrix<${TemplateType}>& eqn,
@ -160,7 +163,7 @@ void ${typeName}FvOption${SourceType}::addSup
{
if (${verbose:-false})
{
Info<<"${typeName}FvOption${SourceType}::addSup()\n";
Info<< "${typeName}FvOption${SourceType}::addSup()\n";
}
//{{{ begin code
@ -169,7 +172,8 @@ void ${typeName}FvOption${SourceType}::addSup
}
void ${typeName}FvOption${SourceType}::constrain
void
${typeName}FvOption${SourceType}::constrain
(
fvMatrix<${TemplateType}>& eqn,
const label fieldi
@ -177,7 +181,7 @@ void ${typeName}FvOption${SourceType}::constrain
{
if (${verbose:-false})
{
Info<<"${typeName}FvOption${SourceType}::constrain()\n";
Info<< "${typeName}FvOption${SourceType}::constrain()\n";
}
//{{{ begin code

View File

@ -5,8 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) YEAR AUTHOR, AFFILIATION
Copyright (C) 2019-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -25,7 +24,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Description
Template for use with dynamic code generation of a source.
Template for use with dynamic code generation of a finiteVolume source.
The hook functions take the following arguments:
\verbatim
@ -117,7 +116,7 @@ namespace fv
class ${typeName}FvOption${SourceType}
:
public cellSetOption
public fv::cellSetOption
{
// Private Member Functions
@ -138,7 +137,7 @@ public:
// Constructors
//- Construct from patch and internal field
//- Construct from mesh
${typeName}FvOption${SourceType}
(
const word& name,
@ -147,6 +146,7 @@ public:
const fvMesh& mesh
);
//- Destructor
virtual ~${typeName}FvOption${SourceType}();

View File

@ -5,6 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021 OpenCFD Ltd.
Copyright (C) YEAR AUTHOR,AFFILIATION
-------------------------------------------------------------------------------
License
@ -37,6 +38,7 @@ License
${codeInclude}
//}}} end codeInclude
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
@ -96,11 +98,11 @@ ${typeName}PatchFunction1${FieldType}
const bool faceValues
)
:
PatchFunction1<${TemplateType}>(pp, entryName, dict, faceValues)
parent_bctype(pp, entryName, dict, faceValues)
{
if (${verbose:-false})
{
printMessage("Construct ${typeName} from components");
printMessage("Construct ${typeName} PatchFunction1 from dictionary");
}
}
@ -111,7 +113,7 @@ ${typeName}PatchFunction1${FieldType}
const ${typeName}PatchFunction1${FieldType}& rhs
)
:
PatchFunction1<${TemplateType}>(rhs)
parent_bctype(rhs)
{}
@ -122,13 +124,13 @@ ${typeName}PatchFunction1${FieldType}
const polyPatch& pp
)
:
PatchFunction1<${TemplateType}>(rhs, pp)
parent_bctype(rhs, pp)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
tmp<Field<${TemplateType}>>
Foam::tmp<Foam::Field<Foam::${TemplateType}>>
${typeName}PatchFunction1${FieldType}::value
(
const scalar x

View File

@ -5,8 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) YEAR AUTHOR, AFFILIATION
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -52,6 +51,10 @@ class ${typeName}PatchFunction1${FieldType}
:
public PatchFunction1<${TemplateType}>
{
//- The parent PatchFunction1 type
typedef PatchFunction1<${TemplateType}> parent_bctype;
// Private Member Functions
//- Report a message with the SHA1sum

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2019 OpenCFD Ltd.
Copyright (C) 2018-2021 OpenCFD Ltd.
Copyright (C) YEAR AUTHOR, AFFILIATION
-------------------------------------------------------------------------------
License
@ -27,6 +27,7 @@ License
\*---------------------------------------------------------------------------*/
#include "codedPoints0MotionSolverTemplate.H"
#define namespaceFoam // Suppress <using namespace Foam;>
#include "fvCFD.H"
#include "unitConversion.H"
#include "addToRunTimeSelectionTable.H"

View File

@ -5,8 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2019 OpenCFD Ltd.
Copyright (C) YEAR AUTHOR, AFFILIATION
Copyright (C) 2018-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -70,7 +69,10 @@ class ${typeName}Points0MotionSolver
) = delete;
//- No copy assignment
void operator=(const ${typeName}Points0MotionSolver&) = delete;
void operator=
(
const ${typeName}Points0MotionSolver&
) = delete;
public:

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2021 OpenCFD Ltd.
Copyright (C) YEAR AUTHOR, AFFILIATION
-------------------------------------------------------------------------------
License
@ -32,6 +32,7 @@ License
#include "volFields.H"
#include "surfaceFields.H"
#include "unitConversion.H"
#include "PatchFunction1.H"
//{{{ begin codeInclude
${codeInclude}
@ -87,7 +88,7 @@ ${typeName}FixedValueFvPatch${FieldType}
const DimensionedField<${TemplateType}, volMesh>& iF
)
:
fixedValueFvPatchField<${TemplateType}>(p, iF)
parent_bctype(p, iF)
{
if (${verbose:-false})
{
@ -99,13 +100,13 @@ ${typeName}FixedValueFvPatch${FieldType}
${typeName}FixedValueFvPatch${FieldType}::
${typeName}FixedValueFvPatch${FieldType}
(
const ${typeName}FixedValueFvPatch${FieldType}& ptf,
const ${typeName}FixedValueFvPatch${FieldType}& rhs,
const fvPatch& p,
const DimensionedField<${TemplateType}, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
fixedValueFvPatchField<${TemplateType}>(ptf, p, iF, mapper)
parent_bctype(rhs, p, iF, mapper)
{
if (${verbose:-false})
{
@ -122,7 +123,7 @@ ${typeName}FixedValueFvPatch${FieldType}
const dictionary& dict
)
:
fixedValueFvPatchField<${TemplateType}>(p, iF, dict)
parent_bctype(p, iF, dict)
{
if (${verbose:-false})
{
@ -134,10 +135,10 @@ ${typeName}FixedValueFvPatch${FieldType}
${typeName}FixedValueFvPatch${FieldType}::
${typeName}FixedValueFvPatch${FieldType}
(
const ${typeName}FixedValueFvPatch${FieldType}& ptf
const ${typeName}FixedValueFvPatch${FieldType}& rhs
)
:
fixedValueFvPatchField<${TemplateType}>(ptf)
parent_bctype(rhs)
{
if (${verbose:-false})
{
@ -149,11 +150,11 @@ ${typeName}FixedValueFvPatch${FieldType}
${typeName}FixedValueFvPatch${FieldType}::
${typeName}FixedValueFvPatch${FieldType}
(
const ${typeName}FixedValueFvPatch${FieldType}& ptf,
const ${typeName}FixedValueFvPatch${FieldType}& rhs,
const DimensionedField<${TemplateType}, volMesh>& iF
)
:
fixedValueFvPatchField<${TemplateType}>(ptf, iF)
parent_bctype(rhs, iF)
{
if (${verbose:-false})
{
@ -176,7 +177,8 @@ ${typeName}FixedValueFvPatch${FieldType}::
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void ${typeName}FixedValueFvPatch${FieldType}::updateCoeffs()
void
${typeName}FixedValueFvPatch${FieldType}::updateCoeffs()
{
if (this->updated())
{
@ -192,7 +194,7 @@ void ${typeName}FixedValueFvPatch${FieldType}::updateCoeffs()
${code}
//}}} end code
this->fixedValueFvPatchField<${TemplateType}>::updateCoeffs();
this->parent_bctype::updateCoeffs();
}

View File

@ -5,8 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) YEAR AUTHOR, AFFILIATION
Copyright (C) 2019-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -53,6 +52,10 @@ class ${typeName}FixedValueFvPatch${FieldType}
:
public fixedValueFvPatchField<${TemplateType}>
{
//- The parent boundary condition type
typedef fixedValueFvPatchField<${TemplateType}> parent_bctype;
// Private Member Functions
//- Report a message with the SHA1sum

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2021 OpenCFD Ltd.
Copyright (C) YEAR AUTHOR, AFFILIATION
-------------------------------------------------------------------------------
License
@ -31,6 +31,7 @@ License
#include "pointPatchFieldMapper.H"
#include "pointFields.H"
#include "unitConversion.H"
#include "PatchFunction1.H"
//{{{ begin codeInclude
${codeInclude}
@ -86,7 +87,7 @@ ${typeName}FixedValuePointPatch${FieldType}
const DimensionedField<${TemplateType}, pointMesh>& iF
)
:
fixedValuePointPatchField<${TemplateType}>(p, iF)
parent_bctype(p, iF)
{
if (${verbose:-false})
{
@ -98,13 +99,13 @@ ${typeName}FixedValuePointPatch${FieldType}
${typeName}FixedValuePointPatch${FieldType}::
${typeName}FixedValuePointPatch${FieldType}
(
const ${typeName}FixedValuePointPatch${FieldType}& ptf,
const ${typeName}FixedValuePointPatch${FieldType}& rhs,
const pointPatch& p,
const DimensionedField<${TemplateType}, pointMesh>& iF,
const pointPatchFieldMapper& mapper
)
:
fixedValuePointPatchField<${TemplateType}>(ptf, p, iF, mapper)
parent_bctype(rhs, p, iF, mapper)
{
if (${verbose:-false})
{
@ -122,7 +123,7 @@ ${typeName}FixedValuePointPatch${FieldType}
const bool valueRequired
)
:
fixedValuePointPatchField<${TemplateType}>(p, iF, dict, valueRequired)
parent_bctype(p, iF, dict, valueRequired)
{
if (${verbose:-false})
{
@ -134,10 +135,10 @@ ${typeName}FixedValuePointPatch${FieldType}
${typeName}FixedValuePointPatch${FieldType}::
${typeName}FixedValuePointPatch${FieldType}
(
const ${typeName}FixedValuePointPatch${FieldType}& ptf
const ${typeName}FixedValuePointPatch${FieldType}& rhs
)
:
fixedValuePointPatchField<${TemplateType}>(ptf)
parent_bctype(rhs)
{
if (${verbose:-false})
{
@ -149,11 +150,11 @@ ${typeName}FixedValuePointPatch${FieldType}
${typeName}FixedValuePointPatch${FieldType}::
${typeName}FixedValuePointPatch${FieldType}
(
const ${typeName}FixedValuePointPatch${FieldType}& ptf,
const ${typeName}FixedValuePointPatch${FieldType}& rhs,
const DimensionedField<${TemplateType}, pointMesh>& iF
)
:
fixedValuePointPatchField<${TemplateType}>(ptf, iF)
parent_bctype(rhs, iF)
{
if (${verbose:-false})
{
@ -176,7 +177,8 @@ ${typeName}FixedValuePointPatch${FieldType}::
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void ${typeName}FixedValuePointPatch${FieldType}::updateCoeffs()
void
${typeName}FixedValuePointPatch${FieldType}::updateCoeffs()
{
if (this->updated())
{
@ -192,7 +194,7 @@ void ${typeName}FixedValuePointPatch${FieldType}::updateCoeffs()
${code}
//}}} end code
this->fixedValuePointPatchField<${TemplateType}>::updateCoeffs();
this->parent_bctype::updateCoeffs();
}

View File

@ -5,8 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) YEAR AUTHOR, AFFILIATION
Copyright (C) 2019-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -35,8 +34,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef fixedValuePointPatchTemplate${FieldType}_H
#define fixedValuePointPatchTemplate${FieldType}_H
#ifndef coded_fixedValuePointPatchTemplate${FieldType}_H
#define coded_fixedValuePointPatchTemplate${FieldType}_H
#include "fixedValuePointPatchFields.H"
@ -53,6 +52,10 @@ class ${typeName}FixedValuePointPatch${FieldType}
:
public fixedValuePointPatchField<${TemplateType}>
{
//- The parent boundary condition type
typedef fixedValuePointPatchField<${TemplateType}> parent_bctype;
// Private Member Functions
//- Report a message with the SHA1sum

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2021 OpenCFD Ltd.
Copyright (C) YEAR AUTHOR, AFFILIATION
-------------------------------------------------------------------------------
License
@ -27,6 +27,7 @@ License
\*---------------------------------------------------------------------------*/
#include "functionObjectTemplate.H"
#define namespaceFoam // Suppress <using namespace Foam;>
#include "fvCFD.H"
#include "unitConversion.H"
#include "addToRunTimeSelectionTable.H"
@ -106,7 +107,8 @@ ${typeName}FunctionObject::~${typeName}FunctionObject()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool ${typeName}FunctionObject::read(const dictionary& dict)
bool
${typeName}FunctionObject::read(const dictionary& dict)
{
if (${verbose:-false})
{
@ -121,7 +123,8 @@ bool ${typeName}FunctionObject::read(const dictionary& dict)
}
bool ${typeName}FunctionObject::execute()
bool
${typeName}FunctionObject::execute()
{
if (${verbose:-false})
{
@ -136,7 +139,8 @@ bool ${typeName}FunctionObject::execute()
}
bool ${typeName}FunctionObject::write()
bool
${typeName}FunctionObject::write()
{
if (${verbose:-false})
{
@ -151,7 +155,8 @@ bool ${typeName}FunctionObject::write()
}
bool ${typeName}FunctionObject::end()
bool
${typeName}FunctionObject::end()
{
if (${verbose:-false})
{

View File

@ -76,10 +76,16 @@ class ${typeName}FunctionObject
const fvMesh& mesh() const;
//- No copy construct
${typeName}FunctionObject(const ${typeName}FunctionObject&) = delete;
${typeName}FunctionObject
(
const ${typeName}FunctionObject&
) = delete;
//- No copy assignment
void operator=(const ${typeName}FunctionObject&) = delete;
void operator=
(
const ${typeName}FunctionObject&
) = delete;
public:
@ -97,7 +103,7 @@ public:
(
const word& name,
const Time& runTime,
const dictionary&
const dictionary& dict
);
@ -107,7 +113,7 @@ public:
// Member Functions
//- Read the dictionary
//- Read optional controls
virtual bool read(const dictionary& dict);
//- Execute (at time-step)

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2021 OpenCFD Ltd.
Copyright (C) YEAR AUTHOR, AFFILIATION
-------------------------------------------------------------------------------
License
@ -32,6 +32,7 @@ License
#include "volFields.H"
#include "surfaceFields.H"
#include "unitConversion.H"
#include "PatchFunction1.H"
//{{{ begin codeInclude
${codeInclude}
@ -86,7 +87,7 @@ ${typeName}MixedValueFvPatch${FieldType}
const DimensionedField<${TemplateType}, volMesh>& iF
)
:
mixedFvPatchField<${TemplateType}>(p, iF)
parent_bctype(p, iF)
{
if (${verbose:-false})
{
@ -98,13 +99,13 @@ ${typeName}MixedValueFvPatch${FieldType}
${typeName}MixedValueFvPatch${FieldType}::
${typeName}MixedValueFvPatch${FieldType}
(
const ${typeName}MixedValueFvPatch${FieldType}& ptf,
const ${typeName}MixedValueFvPatch${FieldType}& rhs,
const fvPatch& p,
const DimensionedField<${TemplateType}, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
mixedFvPatchField<${TemplateType}>(ptf, p, iF, mapper)
parent_bctype(rhs, p, iF, mapper)
{
if (${verbose:-false})
{
@ -121,7 +122,7 @@ ${typeName}MixedValueFvPatch${FieldType}
const dictionary& dict
)
:
mixedFvPatchField<${TemplateType}>(p, iF, dict)
parent_bctype(p, iF, dict)
{
if (${verbose:-false})
{
@ -133,10 +134,10 @@ ${typeName}MixedValueFvPatch${FieldType}
${typeName}MixedValueFvPatch${FieldType}::
${typeName}MixedValueFvPatch${FieldType}
(
const ${typeName}MixedValueFvPatch${FieldType}& ptf
const ${typeName}MixedValueFvPatch${FieldType}& rhs
)
:
mixedFvPatchField<${TemplateType}>(ptf)
parent_bctype(rhs)
{
if (${verbose:-false})
{
@ -148,11 +149,11 @@ ${typeName}MixedValueFvPatch${FieldType}
${typeName}MixedValueFvPatch${FieldType}::
${typeName}MixedValueFvPatch${FieldType}
(
const ${typeName}MixedValueFvPatch${FieldType}& ptf,
const ${typeName}MixedValueFvPatch${FieldType}& rhs,
const DimensionedField<${TemplateType}, volMesh>& iF
)
:
mixedFvPatchField<${TemplateType}>(ptf, iF)
parent_bctype(rhs, iF)
{
if (${verbose:-false})
{
@ -175,7 +176,8 @@ ${typeName}MixedValueFvPatch${FieldType}::
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void ${typeName}MixedValueFvPatch${FieldType}::updateCoeffs()
void
${typeName}MixedValueFvPatch${FieldType}::updateCoeffs()
{
if (this->updated())
{
@ -191,7 +193,7 @@ void ${typeName}MixedValueFvPatch${FieldType}::updateCoeffs()
${code}
//}}} end code
this->mixedFvPatchField<${TemplateType}>::updateCoeffs();
this->parent_bctype::updateCoeffs();
}

View File

@ -5,8 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) YEAR AUTHOR, AFFILIATION
Copyright (C) 2019-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -35,8 +34,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef mixedFvPatchTemplate${FieldType}_H
#define mixedFvPatchTemplate${FieldType}_H
#ifndef coded_mixedFvPatchTemplate${FieldType}_H
#define coded_mixedFvPatchTemplate${FieldType}_H
#include "mixedFvPatchFields.H"
@ -53,6 +52,10 @@ class ${typeName}MixedValueFvPatch${FieldType}
:
public mixedFvPatchField<${TemplateType}>
{
//- The parent boundary condition type
typedef mixedFvPatchField<${TemplateType}> parent_bctype;
// Private Member Functions
//- Report a message with the SHA1sum