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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -124,7 +124,7 @@ Foam::codedFixedValuePointPatchField<Type>::codedFixedValuePointPatchField
const DimensionedField<Type, pointMesh>& iF const DimensionedField<Type, pointMesh>& iF
) )
: :
fixedValuePointPatchField<Type>(p, iF), parent_bctype(p, iF),
codedBase(), codedBase(),
redirectPatchFieldPtr_(nullptr) redirectPatchFieldPtr_(nullptr)
{} {}
@ -133,17 +133,17 @@ Foam::codedFixedValuePointPatchField<Type>::codedFixedValuePointPatchField
template<class Type> template<class Type>
Foam::codedFixedValuePointPatchField<Type>::codedFixedValuePointPatchField Foam::codedFixedValuePointPatchField<Type>::codedFixedValuePointPatchField
( (
const codedFixedValuePointPatchField<Type>& ptf, const codedFixedValuePointPatchField<Type>& rhs,
const pointPatch& p, const pointPatch& p,
const DimensionedField<Type, pointMesh>& iF, const DimensionedField<Type, pointMesh>& iF,
const pointPatchFieldMapper& mapper const pointPatchFieldMapper& mapper
) )
: :
fixedValuePointPatchField<Type>(ptf, p, iF, mapper), parent_bctype(rhs, p, iF, mapper),
codedBase(), codedBase(),
dict_(ptf.dict_), dict_(rhs.dict_),
name_(ptf.name_), name_(rhs.name_),
redirectPatchFieldPtr_() redirectPatchFieldPtr_(nullptr)
{} {}
@ -156,7 +156,7 @@ Foam::codedFixedValuePointPatchField<Type>::codedFixedValuePointPatchField
const bool valueRequired const bool valueRequired
) )
: :
fixedValuePointPatchField<Type>(p, iF, dict, valueRequired), parent_bctype(p, iF, dict, valueRequired),
codedBase(), codedBase(),
dict_ dict_
( (
@ -182,29 +182,29 @@ Foam::codedFixedValuePointPatchField<Type>::codedFixedValuePointPatchField
template<class Type> template<class Type>
Foam::codedFixedValuePointPatchField<Type>::codedFixedValuePointPatchField Foam::codedFixedValuePointPatchField<Type>::codedFixedValuePointPatchField
( (
const codedFixedValuePointPatchField<Type>& ptf const codedFixedValuePointPatchField<Type>& rhs
) )
: :
fixedValuePointPatchField<Type>(ptf), parent_bctype(rhs),
codedBase(), codedBase(),
dict_(ptf.dict_), dict_(rhs.dict_),
name_(ptf.name_), name_(rhs.name_),
redirectPatchFieldPtr_() redirectPatchFieldPtr_(nullptr)
{} {}
template<class Type> template<class Type>
Foam::codedFixedValuePointPatchField<Type>::codedFixedValuePointPatchField Foam::codedFixedValuePointPatchField<Type>::codedFixedValuePointPatchField
( (
const codedFixedValuePointPatchField<Type>& ptf, const codedFixedValuePointPatchField<Type>& rhs,
const DimensionedField<Type, pointMesh>& iF const DimensionedField<Type, pointMesh>& iF
) )
: :
fixedValuePointPatchField<Type>(ptf, iF), parent_bctype(rhs, iF),
codedBase(), codedBase(),
dict_(ptf.dict_), dict_(rhs.dict_),
name_(ptf.name_), name_(rhs.name_),
redirectPatchFieldPtr_() redirectPatchFieldPtr_(nullptr)
{} {}
@ -220,10 +220,11 @@ Foam::codedFixedValuePointPatchField<Type>::redirectPatchField() const
// Make sure to construct the patchfield with up-to-date value // Make sure to construct the patchfield with up-to-date value
OStringStream os; OStringStream os;
os.writeEntry("type", name_);
static_cast<const Field<Type>&>(*this).writeEntry("value", os); static_cast<const Field<Type>&>(*this).writeEntry("value", os);
IStringStream is(os.str()); IStringStream is(os.str());
dictionary dict(is); dictionary constructDict(is);
constructDict.set("type", name_);
redirectPatchFieldPtr_.reset redirectPatchFieldPtr_.reset
( (
@ -231,7 +232,7 @@ Foam::codedFixedValuePointPatchField<Type>::redirectPatchField() const
( (
this->patch(), this->patch(),
this->internalField(), this->internalField(),
dict constructDict
).ptr() ).ptr()
); );
} }
@ -257,7 +258,7 @@ void Foam::codedFixedValuePointPatchField<Type>::updateCoeffs()
// Copy through value // Copy through value
this->operator==(fvp); this->operator==(fvp);
fixedValuePointPatchField<Type>::updateCoeffs(); parent_bctype::updateCoeffs();
} }
@ -274,14 +275,14 @@ void Foam::codedFixedValuePointPatchField<Type>::evaluate
const_cast<pointPatchField<Type>&>(fvp).evaluate(commsType); const_cast<pointPatchField<Type>&>(fvp).evaluate(commsType);
fixedValuePointPatchField<Type>::evaluate(commsType); parent_bctype::evaluate(commsType);
} }
template<class Type> template<class Type>
void Foam::codedFixedValuePointPatchField<Type>::write(Ostream& os) const void Foam::codedFixedValuePointPatchField<Type>::write(Ostream& os) const
{ {
fixedValuePointPatchField<Type>::write(os); this->parent_bctype::write(os);
os.writeEntry("name", name_); os.writeEntry("name", name_);
codedBase::writeCodeDict(os, dict_); codedBase::writeCodeDict(os, dict_);

View File

@ -31,6 +31,15 @@ Description
Constructs on-the-fly a new boundary condition (derived from Constructs on-the-fly a new boundary condition (derived from
fixedValuePointPatchField) which is then used to evaluate. fixedValuePointPatchField) which is then used to evaluate.
The code entries:
\plaintable
codeInclude | include files
codeOptions | compiler line: added to EXE_INC (Make/options)
codeLibs | linker line: added to LIB_LIBS (Make/options)
localCode | c++; local static functions
code | c++; patch value assignment
\endplaintable
Example: Example:
\verbatim \verbatim
movingWall movingWall
@ -102,6 +111,10 @@ class codedFixedValuePointPatchField
public fixedValuePointPatchField<Type>, public fixedValuePointPatchField<Type>,
protected codedBase protected codedBase
{ {
//- The parent boundary condition type
typedef fixedValuePointPatchField<Type> parent_bctype;
// Private Data // Private Data
//- Dictionary contents for the boundary condition //- Dictionary contents for the boundary condition

View File

@ -35,10 +35,10 @@ Description
The entries are: The entries are:
\plaintable \plaintable
codeInclude | include files codeInclude | include files
codeOptions | include paths; inserted into EXE_INC in Make/options codeOptions | compiler line: added to EXE_INC (Make/options)
codeLibs | link line; inserted into LIB_LIBS in Make/options codeLibs | linker line: added to LIB_LIBS (Make/options)
localCode | c++; local static functions; localCode | c++; local static functions
code | c++; upon motionSolver::curPoints(); code | c++; upon motionSolver::curPoints()
\endplaintable \endplaintable
Note that the dynamically generated motionSolver is an points0MotionSolver, Note that the dynamically generated motionSolver is an points0MotionSolver,

View File

@ -124,7 +124,7 @@ Foam::codedFixedValueFvPatchField<Type>::codedFixedValueFvPatchField
const DimensionedField<Type, volMesh>& iF const DimensionedField<Type, volMesh>& iF
) )
: :
fixedValueFvPatchField<Type>(p, iF), parent_bctype(p, iF),
codedBase(), codedBase(),
redirectPatchFieldPtr_(nullptr) redirectPatchFieldPtr_(nullptr)
{} {}
@ -133,17 +133,17 @@ Foam::codedFixedValueFvPatchField<Type>::codedFixedValueFvPatchField
template<class Type> template<class Type>
Foam::codedFixedValueFvPatchField<Type>::codedFixedValueFvPatchField Foam::codedFixedValueFvPatchField<Type>::codedFixedValueFvPatchField
( (
const codedFixedValueFvPatchField<Type>& ptf, const codedFixedValueFvPatchField<Type>& rhs,
const fvPatch& p, const fvPatch& p,
const DimensionedField<Type, volMesh>& iF, const DimensionedField<Type, volMesh>& iF,
const fvPatchFieldMapper& mapper const fvPatchFieldMapper& mapper
) )
: :
fixedValueFvPatchField<Type>(ptf, p, iF, mapper), parent_bctype(rhs, p, iF, mapper),
codedBase(), codedBase(),
dict_(ptf.dict_), dict_(rhs.dict_),
name_(ptf.name_), name_(rhs.name_),
redirectPatchFieldPtr_() redirectPatchFieldPtr_(nullptr)
{} {}
@ -155,7 +155,7 @@ Foam::codedFixedValueFvPatchField<Type>::codedFixedValueFvPatchField
const dictionary& dict const dictionary& dict
) )
: :
fixedValueFvPatchField<Type>(p, iF, dict), parent_bctype(p, iF, dict),
codedBase(), codedBase(),
dict_ dict_
( (
@ -181,29 +181,29 @@ Foam::codedFixedValueFvPatchField<Type>::codedFixedValueFvPatchField
template<class Type> template<class Type>
Foam::codedFixedValueFvPatchField<Type>::codedFixedValueFvPatchField Foam::codedFixedValueFvPatchField<Type>::codedFixedValueFvPatchField
( (
const codedFixedValueFvPatchField<Type>& ptf const codedFixedValueFvPatchField<Type>& rhs
) )
: :
fixedValueFvPatchField<Type>(ptf), parent_bctype(rhs),
codedBase(), codedBase(),
dict_(ptf.dict_), dict_(rhs.dict_),
name_(ptf.name_), name_(rhs.name_),
redirectPatchFieldPtr_() redirectPatchFieldPtr_(nullptr)
{} {}
template<class Type> template<class Type>
Foam::codedFixedValueFvPatchField<Type>::codedFixedValueFvPatchField Foam::codedFixedValueFvPatchField<Type>::codedFixedValueFvPatchField
( (
const codedFixedValueFvPatchField<Type>& ptf, const codedFixedValueFvPatchField<Type>& rhs,
const DimensionedField<Type, volMesh>& iF const DimensionedField<Type, volMesh>& iF
) )
: :
fixedValueFvPatchField<Type>(ptf, iF), parent_bctype(rhs, iF),
codedBase(), codedBase(),
dict_(ptf.dict_), dict_(rhs.dict_),
name_(ptf.name_), name_(rhs.name_),
redirectPatchFieldPtr_() redirectPatchFieldPtr_(nullptr)
{} {}
@ -219,10 +219,11 @@ Foam::codedFixedValueFvPatchField<Type>::redirectPatchField() const
// Make sure to construct the patchfield with up-to-date value // Make sure to construct the patchfield with up-to-date value
OStringStream os; OStringStream os;
os.writeEntry("type", name_);
static_cast<const Field<Type>&>(*this).writeEntry("value", os); static_cast<const Field<Type>&>(*this).writeEntry("value", os);
IStringStream is(os.str()); IStringStream is(os.str());
dictionary dict(is); dictionary constructDict(is);
constructDict.set("type", name_);
redirectPatchFieldPtr_.reset redirectPatchFieldPtr_.reset
( (
@ -230,7 +231,7 @@ Foam::codedFixedValueFvPatchField<Type>::redirectPatchField() const
( (
this->patch(), this->patch(),
this->internalField(), this->internalField(),
dict constructDict
).ptr() ).ptr()
); );
} }
@ -256,7 +257,7 @@ void Foam::codedFixedValueFvPatchField<Type>::updateCoeffs()
// Copy through value // Copy through value
this->operator==(fvp); this->operator==(fvp);
fixedValueFvPatchField<Type>::updateCoeffs(); parent_bctype::updateCoeffs();
} }
@ -273,14 +274,14 @@ void Foam::codedFixedValueFvPatchField<Type>::evaluate
const_cast<fvPatchField<Type>&>(fvp).evaluate(commsType); const_cast<fvPatchField<Type>&>(fvp).evaluate(commsType);
fixedValueFvPatchField<Type>::evaluate(commsType); parent_bctype::evaluate(commsType);
} }
template<class Type> template<class Type>
void Foam::codedFixedValueFvPatchField<Type>::write(Ostream& os) const void Foam::codedFixedValueFvPatchField<Type>::write(Ostream& os) const
{ {
fixedValueFvPatchField<Type>::write(os); this->parent_bctype::write(os);
os.writeEntry("name", name_); os.writeEntry("name", name_);
codedBase::writeCodeDict(os, dict_); codedBase::writeCodeDict(os, dict_);

View File

@ -34,6 +34,15 @@ Description
Constructs on-the-fly a new boundary condition (derived from Constructs on-the-fly a new boundary condition (derived from
fixedValueFvPatchField) which is then used to evaluate. fixedValueFvPatchField) which is then used to evaluate.
The code entries:
\plaintable
codeInclude | include files
codeOptions | compiler line: added to EXE_INC (Make/options)
codeLibs | linker line: added to LIB_LIBS (Make/options)
localCode | c++; local static functions
code | c++; patch value assignment
\endplaintable
Usage Usage
Example: Example:
\verbatim \verbatim
@ -104,6 +113,10 @@ class codedFixedValueFvPatchField
public fixedValueFvPatchField<Type>, public fixedValueFvPatchField<Type>,
protected codedBase protected codedBase
{ {
//- The parent boundary condition type
typedef fixedValueFvPatchField<Type> parent_bctype;
// Private Data // Private Data
//- Dictionary contents for the boundary condition //- Dictionary contents for the boundary condition

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2020 OpenCFD Ltd. Copyright (C) 2016-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -124,7 +124,7 @@ Foam::codedMixedFvPatchField<Type>::codedMixedFvPatchField
const DimensionedField<Type, volMesh>& iF const DimensionedField<Type, volMesh>& iF
) )
: :
mixedFvPatchField<Type>(p, iF), parent_bctype(p, iF),
codedBase(), codedBase(),
redirectPatchFieldPtr_(nullptr) redirectPatchFieldPtr_(nullptr)
{} {}
@ -133,17 +133,17 @@ Foam::codedMixedFvPatchField<Type>::codedMixedFvPatchField
template<class Type> template<class Type>
Foam::codedMixedFvPatchField<Type>::codedMixedFvPatchField Foam::codedMixedFvPatchField<Type>::codedMixedFvPatchField
( (
const codedMixedFvPatchField<Type>& ptf, const codedMixedFvPatchField<Type>& rhs,
const fvPatch& p, const fvPatch& p,
const DimensionedField<Type, volMesh>& iF, const DimensionedField<Type, volMesh>& iF,
const fvPatchFieldMapper& mapper const fvPatchFieldMapper& mapper
) )
: :
mixedFvPatchField<Type>(ptf, p, iF, mapper), parent_bctype(rhs, p, iF, mapper),
codedBase(), codedBase(),
dict_(ptf.dict_), dict_(rhs.dict_),
name_(ptf.name_), name_(rhs.name_),
redirectPatchFieldPtr_() redirectPatchFieldPtr_(nullptr)
{} {}
@ -155,7 +155,7 @@ Foam::codedMixedFvPatchField<Type>::codedMixedFvPatchField
const dictionary& dict const dictionary& dict
) )
: :
mixedFvPatchField<Type>(p, iF, dict), parent_bctype(p, iF, dict),
codedBase(), codedBase(),
dict_ dict_
( (
@ -181,29 +181,29 @@ Foam::codedMixedFvPatchField<Type>::codedMixedFvPatchField
template<class Type> template<class Type>
Foam::codedMixedFvPatchField<Type>::codedMixedFvPatchField Foam::codedMixedFvPatchField<Type>::codedMixedFvPatchField
( (
const codedMixedFvPatchField<Type>& ptf const codedMixedFvPatchField<Type>& rhs
) )
: :
mixedFvPatchField<Type>(ptf), parent_bctype(rhs),
codedBase(), codedBase(),
dict_(ptf.dict_), dict_(rhs.dict_),
name_(ptf.name_), name_(rhs.name_),
redirectPatchFieldPtr_() redirectPatchFieldPtr_(nullptr)
{} {}
template<class Type> template<class Type>
Foam::codedMixedFvPatchField<Type>::codedMixedFvPatchField Foam::codedMixedFvPatchField<Type>::codedMixedFvPatchField
( (
const codedMixedFvPatchField<Type>& ptf, const codedMixedFvPatchField<Type>& rhs,
const DimensionedField<Type, volMesh>& iF const DimensionedField<Type, volMesh>& iF
) )
: :
mixedFvPatchField<Type>(ptf, iF), parent_bctype(rhs, iF),
codedBase(), codedBase(),
dict_(ptf.dict_), dict_(rhs.dict_),
name_(ptf.name_), name_(rhs.name_),
redirectPatchFieldPtr_() redirectPatchFieldPtr_(nullptr)
{} {}
@ -220,24 +220,23 @@ Foam::codedMixedFvPatchField<Type>::redirectPatchField() const
// Write the data from the mixed b.c. // Write the data from the mixed b.c.
OStringStream os; OStringStream os;
mixedFvPatchField<Type>::write(os); this->parent_bctype::write(os);
IStringStream is(os.str()); IStringStream is(os.str());
// Construct dictionary from it. // Construct dictionary from it.
dictionary dict(is); dictionary constructDict(is);
// Override the type to enforce the fvPatchField::New constructor // Override type
// to choose our type constructDict.set("type", name_);
dict.set("type", name_);
redirectPatchFieldPtr_.reset redirectPatchFieldPtr_.reset
( (
dynamic_cast<mixedFvPatchField<Type>*> dynamic_cast<parent_bctype*>
( (
fvPatchField<Type>::New fvPatchField<Type>::New
( (
this->patch(), this->patch(),
this->internalField(), this->internalField(),
dict constructDict
).ptr() ).ptr()
) )
); );
@ -257,16 +256,15 @@ void Foam::codedMixedFvPatchField<Type>::updateCoeffs()
// Make sure library containing user-defined fvPatchField is up-to-date // Make sure library containing user-defined fvPatchField is up-to-date
updateLibrary(name_); updateLibrary(name_);
const mixedFvPatchField<Type>& fvp = redirectPatchField(); const parent_bctype& fvp = redirectPatchField();
const_cast<parent_bctype&>(fvp).updateCoeffs();
const_cast<mixedFvPatchField<Type>&>(fvp).updateCoeffs();
// Copy through coefficients // Copy through coefficients
this->refValue() = fvp.refValue(); this->refValue() = fvp.refValue();
this->refGrad() = fvp.refGrad(); this->refGrad() = fvp.refGrad();
this->valueFraction() = fvp.valueFraction(); this->valueFraction() = fvp.valueFraction();
mixedFvPatchField<Type>::updateCoeffs(); this->parent_bctype::updateCoeffs();
} }
@ -279,21 +277,21 @@ void Foam::codedMixedFvPatchField<Type>::evaluate
// Make sure library containing user-defined fvPatchField is up-to-date // Make sure library containing user-defined fvPatchField is up-to-date
updateLibrary(name_); updateLibrary(name_);
const mixedFvPatchField<Type>& fvp = redirectPatchField(); const parent_bctype& fvp = redirectPatchField();
// - updates the value of fvp (though not used) // - updates the value of fvp (though not used)
// - resets the updated() flag // - resets the updated() flag
const_cast<mixedFvPatchField<Type>&>(fvp).evaluate(commsType); const_cast<parent_bctype&>(fvp).evaluate(commsType);
// Update the value (using the coefficients) locally // Update the value (using the coefficients) locally
mixedFvPatchField<Type>::evaluate(commsType); parent_bctype::evaluate(commsType);
} }
template<class Type> template<class Type>
void Foam::codedMixedFvPatchField<Type>::write(Ostream& os) const void Foam::codedMixedFvPatchField<Type>::write(Ostream& os) const
{ {
mixedFvPatchField<Type>::write(os); this->parent_bctype::write(os);
os.writeEntry("name", name_); os.writeEntry("name", name_);
codedBase::writeCodeDict(os, dict_); codedBase::writeCodeDict(os, dict_);

View File

@ -31,8 +31,17 @@ Group
grpGenericBoundaryConditions grpGenericBoundaryConditions
Description Description
Constructs on-the-fly a new boundary condition (derived from Constructs on-the-fly a new boundary condition
mixedFvPatchField) which is then used to evaluate. (derived from mixedFvPatchField) which is then used to evaluate.
The code entries:
\plaintable
codeInclude | include files
codeOptions | compiler line: added to EXE_INC (Make/options)
codeLibs | linker line: added to LIB_LIBS (Make/options)
localCode | c++; local static functions;
code | c++; patch value assignment
\endplaintable
Usage Usage
Example: Example:
@ -114,6 +123,10 @@ class codedMixedFvPatchField
public mixedFvPatchField<Type>, public mixedFvPatchField<Type>,
public codedBase public codedBase
{ {
//- The parent boundary condition type
typedef mixedFvPatchField<Type> parent_bctype;
// Private Data // Private Data
//- Dictionary contents for the boundary condition //- Dictionary contents for the boundary condition

View File

@ -32,6 +32,7 @@ License
#include "Time.H" #include "Time.H"
#include "dynamicCode.H" #include "dynamicCode.H"
#include "dynamicCodeContext.H" #include "dynamicCodeContext.H"
#include "dictionaryContent.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -47,8 +48,8 @@ namespace functionObjects
codedFunctionObject, codedFunctionObject,
dictionary dictionary
); );
} } // End namespace functionObjects
} } // End namespace Foam
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //

View File

@ -36,14 +36,14 @@ Description
The entries are: The entries are:
\plaintable \plaintable
codeInclude | include files codeInclude | include files
codeOptions | include paths; inserted into EXE_INC in Make/options codeOptions | compiler line: added to EXE_INC (Make/options)
codeLibs | link line; inserted into LIB_LIBS in Make/options codeLibs | linker line: added to LIB_LIBS (Make/options)
codeData | c++; local member data (default constructed); codeData | c++; local member data (default constructed)
localCode | c++; local static functions; localCode | c++; local static functions
codeRead | c++; upon functionObject::read(); codeRead | c++; upon functionObject::read()
codeExecute | c++; upon functionObject::execute(); codeExecute | c++; upon functionObject::execute()
codeWrite | c++; upon functionObject::write() codeWrite | c++; upon functionObject::write()
codeEnd | c++; upon functionObject::end(); codeEnd | c++; upon functionObject::end()
\endplaintable \endplaintable
Usage Usage

View File

@ -27,6 +27,7 @@ License
#include "dynamicCode.H" #include "dynamicCode.H"
#include "dynamicCodeContext.H" #include "dynamicCodeContext.H"
#include "dictionaryContent.H"
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
@ -183,15 +184,13 @@ Foam::PatchFunction1Types::CodedField<Type>::redirectFunction() const
{ {
if (!redirectFunctionPtr_) if (!redirectFunctionPtr_)
{ {
// Construct a PatchFunction1 containing the input code dictionary constructDict;
dictionary completeDict(dict_); // Force 'name_' sub-dictionary into existence
dictionary& coeffs = constructDict.subDictOrAdd(name_);
// Override the type to enforce the PatchFunction1::New constructor coeffs = dict_; // Copy input code and coefficients
// to choose our type coeffs.remove("name"); // Redundant
completeDict.set("type", name_); coeffs.set("type", name_); // Specify our new (redirect) type
dictionary dict;
dict.add(name_, completeDict);
redirectFunctionPtr_.reset redirectFunctionPtr_.reset
( (
@ -199,7 +198,7 @@ Foam::PatchFunction1Types::CodedField<Type>::redirectFunction() const
( (
this->patch(), this->patch(),
name_, name_,
dict, constructDict,
this->faceValues() this->faceValues()
) )
); );

View File

@ -30,6 +30,15 @@ Description
PatchFunction1 with the code supplied by an on-the-fly compiled C++ PatchFunction1 with the code supplied by an on-the-fly compiled C++
expression. expression.
The code entries:
\plaintable
codeInclude | include files
codeOptions | compiler line: added to EXE_INC (Make/options)
codeLibs | linker line: added to LIB_LIBS (Make/options)
localCode | c++; local static functions
code | c++; return the patch values at (scalar x)
\endplaintable
Usage Usage
Example: Example:
\verbatim \verbatim
@ -39,10 +48,7 @@ Usage
uniformValue uniformValue
{ {
type coded; type coded;
// Explictly supply name of generated PatchFunction1. Only needed name myExpression; // Name of generated PatchFunction1
// if entryname ('uniformValue') would clash with existing
// runtime selection tables.
name myExpression;
code code
#{ #{
@ -50,11 +56,10 @@ Usage
Pout<< "** Patch size:" << pp.size() << endl; Pout<< "** Patch size:" << pp.size() << endl;
return tmp<vectorField>::New(pp.size(), vector(1, 0, 0)) return tmp<vectorField>::New(pp.size(), vector(1, 0, 0))
#}; #};
}
//codeInclude //codeInclude
//#{ //#{
// #include "fvCFD.H" // #include "volFields.H"
//#}; //#};
//codeOptions //codeOptions
@ -62,6 +67,7 @@ Usage
// -I$(LIB_SRC)/finiteVolume/lnInclude // -I$(LIB_SRC)/finiteVolume/lnInclude
//#}; //#};
} }
}
\endverbatim \endverbatim
See also See also

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\ /*--------------------------------*- C++ -*----------------------------------*\
| ========= | | | ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2012 | | \\ / O peration | Version: v2106 |
| \\ / A nd | Website: www.openfoam.com | | \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | | | \\/ M anipulation | |
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -59,7 +59,6 @@ maxCo 1.2;
functions functions
{ {
// #include "catalyst"
probes probes
{ {
type probes; type probes;
@ -82,7 +81,6 @@ functions
( (
(0.015 0.005 0.005) (0.015 0.005 0.005)
); );
} }
mass mass
@ -114,12 +112,10 @@ functions
codeWrite codeWrite
#{ #{
const volScalarField& rho = const volScalarField& rho =
mesh().lookupObject<volScalarField>("rho"); mesh().lookupObject<volScalarField>("rho");
Info<< "rho volume = " << rho.weightedAverage(mesh().Vsc()) << endl; Info<< "rho volume = " << rho.weightedAverage(mesh().Vsc()) << endl;
#}; #};
} }
} }

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\ /*--------------------------------*- C++ -*----------------------------------*\
| ========= | | | ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2012 | | \\ / O peration | Version: v2106 |
| \\ / A nd | Website: www.openfoam.com | | \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | | | \\/ M anipulation | |
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -24,19 +24,14 @@ functions
libs (utilityFunctionObjects); libs (utilityFunctionObjects);
enabled yes; enabled yes;
codeInclude
#{
#include "volFields.H"
#};
codeWrite codeWrite
#{ #{
scalar D = 0.57; const scalar D = 0.57;
scalar UInf = 50; const scalar UInf = 50;
scalar pInf = 101325; const scalar pInf = 101325;
scalar TInf = 224; const scalar TInf = 224;
scalar gamma = 1.4; const scalar gamma = 1.4;
scalar A = -0.3*D*UInf; const scalar A = -0.3*D*UInf;
const dimensionedScalar rhoRef("rhoRef", dimDensity, 1); const dimensionedScalar rhoRef("rhoRef", dimDensity, 1);
const auto& rho = mesh().lookupObject<volScalarField>("rho"); const auto& rho = mesh().lookupObject<volScalarField>("rho");

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\ /*--------------------------------*- C++ -*----------------------------------*\
| ========= | | | ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2012 | | \\ / O peration | Version: v2106 |
| \\ / A nd | Website: www.openfoam.com | | \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | | | \\/ M anipulation | |
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -29,11 +29,6 @@ boundaryField
{ {
type coded; type coded;
codeInclude
#{
#include "volFields.H"
#};
code code
#{ #{
const auto& T = const auto& T =