From b0891824fa0cee458098b3c55b496d55d3b7f6f9 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 1 Jun 2021 12:07:20 +0200 Subject: [PATCH] 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 --- .../dynamicCode/codedFvOptionTemplate.C | 26 ++++---- .../dynamicCode/codedFvOptionTemplate.H | 10 +-- .../dynamicCode/codedPatchFunction1Template.C | 12 ++-- .../dynamicCode/codedPatchFunction1Template.H | 7 +- .../codedPoints0MotionSolverTemplate.C | 3 +- .../codedPoints0MotionSolverTemplate.H | 8 ++- .../fixedValueFvPatchFieldTemplate.C | 24 +++---- .../fixedValueFvPatchFieldTemplate.H | 7 +- .../fixedValuePointPatchFieldTemplate.C | 24 +++---- .../fixedValuePointPatchFieldTemplate.H | 11 ++-- .../dynamicCode/functionObjectTemplate.C | 15 +++-- .../dynamicCode/functionObjectTemplate.H | 14 ++-- .../dynamicCode/mixedFvPatchFieldTemplate.C | 24 +++---- .../dynamicCode/mixedFvPatchFieldTemplate.H | 11 ++-- .../codedFixedValuePointPatchField.C | 47 +++++++------- .../codedFixedValuePointPatchField.H | 13 ++++ .../codedPoints0/codedPoints0MotionSolver.H | 8 +-- .../codedFixedValueFvPatchField.C | 47 +++++++------- .../codedFixedValueFvPatchField.H | 13 ++++ .../codedMixed/codedMixedFvPatchField.C | 64 +++++++++---------- .../codedMixed/codedMixedFvPatchField.H | 17 ++++- .../codedFunctionObject/codedFunctionObject.C | 5 +- .../codedFunctionObject/codedFunctionObject.H | 14 ++-- .../PatchFunction1/CodedField/CodedField.C | 17 +++-- .../PatchFunction1/CodedField/CodedField.H | 36 ++++++----- .../twoSimpleRotors/system/controlDict | 6 +- .../rutlandVortex2D/system/preProcess | 19 ++---- .../poolEvaporation/0.orig/T | 7 +- 28 files changed, 289 insertions(+), 220 deletions(-) diff --git a/etc/codeTemplates/dynamicCode/codedFvOptionTemplate.C b/etc/codeTemplates/dynamicCode/codedFvOptionTemplate.C index 8ad0375798..d6c4f935d6 100644 --- a/etc/codeTemplates/dynamicCode/codedFvOptionTemplate.C +++ b/etc/codeTemplates/dynamicCode/codedFvOptionTemplate.C @@ -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 diff --git a/etc/codeTemplates/dynamicCode/codedFvOptionTemplate.H b/etc/codeTemplates/dynamicCode/codedFvOptionTemplate.H index cafab99cdb..c9d397e1d1 100644 --- a/etc/codeTemplates/dynamicCode/codedFvOptionTemplate.H +++ b/etc/codeTemplates/dynamicCode/codedFvOptionTemplate.H @@ -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 . 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}(); diff --git a/etc/codeTemplates/dynamicCode/codedPatchFunction1Template.C b/etc/codeTemplates/dynamicCode/codedPatchFunction1Template.C index 06e5eb00d7..cc7cc9e1cd 100644 --- a/etc/codeTemplates/dynamicCode/codedPatchFunction1Template.C +++ b/etc/codeTemplates/dynamicCode/codedPatchFunction1Template.C @@ -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> +Foam::tmp> ${typeName}PatchFunction1${FieldType}::value ( const scalar x diff --git a/etc/codeTemplates/dynamicCode/codedPatchFunction1Template.H b/etc/codeTemplates/dynamicCode/codedPatchFunction1Template.H index 0aeaf7059e..21b712f356 100644 --- a/etc/codeTemplates/dynamicCode/codedPatchFunction1Template.H +++ b/etc/codeTemplates/dynamicCode/codedPatchFunction1Template.H @@ -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 diff --git a/etc/codeTemplates/dynamicCode/codedPoints0MotionSolverTemplate.C b/etc/codeTemplates/dynamicCode/codedPoints0MotionSolverTemplate.C index 386b870923..d38ef18c97 100644 --- a/etc/codeTemplates/dynamicCode/codedPoints0MotionSolverTemplate.C +++ b/etc/codeTemplates/dynamicCode/codedPoints0MotionSolverTemplate.C @@ -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 #include "fvCFD.H" #include "unitConversion.H" #include "addToRunTimeSelectionTable.H" diff --git a/etc/codeTemplates/dynamicCode/codedPoints0MotionSolverTemplate.H b/etc/codeTemplates/dynamicCode/codedPoints0MotionSolverTemplate.H index 8bcca47ad3..5a8c45b430 100644 --- a/etc/codeTemplates/dynamicCode/codedPoints0MotionSolverTemplate.H +++ b/etc/codeTemplates/dynamicCode/codedPoints0MotionSolverTemplate.H @@ -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: diff --git a/etc/codeTemplates/dynamicCode/fixedValueFvPatchFieldTemplate.C b/etc/codeTemplates/dynamicCode/fixedValueFvPatchFieldTemplate.C index 71494cf806..a9db42f5fd 100644 --- a/etc/codeTemplates/dynamicCode/fixedValueFvPatchFieldTemplate.C +++ b/etc/codeTemplates/dynamicCode/fixedValueFvPatchFieldTemplate.C @@ -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(); } diff --git a/etc/codeTemplates/dynamicCode/fixedValueFvPatchFieldTemplate.H b/etc/codeTemplates/dynamicCode/fixedValueFvPatchFieldTemplate.H index 4be5ca0425..ca1d2e5c49 100644 --- a/etc/codeTemplates/dynamicCode/fixedValueFvPatchFieldTemplate.H +++ b/etc/codeTemplates/dynamicCode/fixedValueFvPatchFieldTemplate.H @@ -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 diff --git a/etc/codeTemplates/dynamicCode/fixedValuePointPatchFieldTemplate.C b/etc/codeTemplates/dynamicCode/fixedValuePointPatchFieldTemplate.C index d093268726..c91a478c62 100644 --- a/etc/codeTemplates/dynamicCode/fixedValuePointPatchFieldTemplate.C +++ b/etc/codeTemplates/dynamicCode/fixedValuePointPatchFieldTemplate.C @@ -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(); } diff --git a/etc/codeTemplates/dynamicCode/fixedValuePointPatchFieldTemplate.H b/etc/codeTemplates/dynamicCode/fixedValuePointPatchFieldTemplate.H index cf412c02d0..164d625d14 100644 --- a/etc/codeTemplates/dynamicCode/fixedValuePointPatchFieldTemplate.H +++ b/etc/codeTemplates/dynamicCode/fixedValuePointPatchFieldTemplate.H @@ -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 diff --git a/etc/codeTemplates/dynamicCode/functionObjectTemplate.C b/etc/codeTemplates/dynamicCode/functionObjectTemplate.C index 207e2dc3c9..274fd29f7c 100644 --- a/etc/codeTemplates/dynamicCode/functionObjectTemplate.C +++ b/etc/codeTemplates/dynamicCode/functionObjectTemplate.C @@ -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 #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}) { diff --git a/etc/codeTemplates/dynamicCode/functionObjectTemplate.H b/etc/codeTemplates/dynamicCode/functionObjectTemplate.H index e56ae69538..3b2c2b238d 100644 --- a/etc/codeTemplates/dynamicCode/functionObjectTemplate.H +++ b/etc/codeTemplates/dynamicCode/functionObjectTemplate.H @@ -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) diff --git a/etc/codeTemplates/dynamicCode/mixedFvPatchFieldTemplate.C b/etc/codeTemplates/dynamicCode/mixedFvPatchFieldTemplate.C index d7658f52b5..8602b151be 100644 --- a/etc/codeTemplates/dynamicCode/mixedFvPatchFieldTemplate.C +++ b/etc/codeTemplates/dynamicCode/mixedFvPatchFieldTemplate.C @@ -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(); } diff --git a/etc/codeTemplates/dynamicCode/mixedFvPatchFieldTemplate.H b/etc/codeTemplates/dynamicCode/mixedFvPatchFieldTemplate.H index 7588639539..5b915c4b78 100644 --- a/etc/codeTemplates/dynamicCode/mixedFvPatchFieldTemplate.H +++ b/etc/codeTemplates/dynamicCode/mixedFvPatchFieldTemplate.H @@ -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 diff --git a/src/OpenFOAM/fields/pointPatchFields/derived/codedFixedValue/codedFixedValuePointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/derived/codedFixedValue/codedFixedValuePointPatchField.C index 1d6e60bd79..b3a8be6b26 100644 --- a/src/OpenFOAM/fields/pointPatchFields/derived/codedFixedValue/codedFixedValuePointPatchField.C +++ b/src/OpenFOAM/fields/pointPatchFields/derived/codedFixedValue/codedFixedValuePointPatchField.C @@ -124,7 +124,7 @@ Foam::codedFixedValuePointPatchField::codedFixedValuePointPatchField const DimensionedField& iF ) : - fixedValuePointPatchField(p, iF), + parent_bctype(p, iF), codedBase(), redirectPatchFieldPtr_(nullptr) {} @@ -133,17 +133,17 @@ Foam::codedFixedValuePointPatchField::codedFixedValuePointPatchField template Foam::codedFixedValuePointPatchField::codedFixedValuePointPatchField ( - const codedFixedValuePointPatchField& ptf, + const codedFixedValuePointPatchField& rhs, const pointPatch& p, const DimensionedField& iF, const pointPatchFieldMapper& mapper ) : - fixedValuePointPatchField(ptf, p, iF, mapper), + parent_bctype(rhs, p, iF, mapper), codedBase(), - dict_(ptf.dict_), - name_(ptf.name_), - redirectPatchFieldPtr_() + dict_(rhs.dict_), + name_(rhs.name_), + redirectPatchFieldPtr_(nullptr) {} @@ -156,7 +156,7 @@ Foam::codedFixedValuePointPatchField::codedFixedValuePointPatchField const bool valueRequired ) : - fixedValuePointPatchField(p, iF, dict, valueRequired), + parent_bctype(p, iF, dict, valueRequired), codedBase(), dict_ ( @@ -182,29 +182,29 @@ Foam::codedFixedValuePointPatchField::codedFixedValuePointPatchField template Foam::codedFixedValuePointPatchField::codedFixedValuePointPatchField ( - const codedFixedValuePointPatchField& ptf + const codedFixedValuePointPatchField& rhs ) : - fixedValuePointPatchField(ptf), + parent_bctype(rhs), codedBase(), - dict_(ptf.dict_), - name_(ptf.name_), - redirectPatchFieldPtr_() + dict_(rhs.dict_), + name_(rhs.name_), + redirectPatchFieldPtr_(nullptr) {} template Foam::codedFixedValuePointPatchField::codedFixedValuePointPatchField ( - const codedFixedValuePointPatchField& ptf, + const codedFixedValuePointPatchField& rhs, const DimensionedField& iF ) : - fixedValuePointPatchField(ptf, iF), + parent_bctype(rhs, iF), codedBase(), - dict_(ptf.dict_), - name_(ptf.name_), - redirectPatchFieldPtr_() + dict_(rhs.dict_), + name_(rhs.name_), + redirectPatchFieldPtr_(nullptr) {} @@ -220,10 +220,11 @@ Foam::codedFixedValuePointPatchField::redirectPatchField() const // Make sure to construct the patchfield with up-to-date value OStringStream os; - os.writeEntry("type", name_); static_cast&>(*this).writeEntry("value", os); IStringStream is(os.str()); - dictionary dict(is); + dictionary constructDict(is); + + constructDict.set("type", name_); redirectPatchFieldPtr_.reset ( @@ -231,7 +232,7 @@ Foam::codedFixedValuePointPatchField::redirectPatchField() const ( this->patch(), this->internalField(), - dict + constructDict ).ptr() ); } @@ -257,7 +258,7 @@ void Foam::codedFixedValuePointPatchField::updateCoeffs() // Copy through value this->operator==(fvp); - fixedValuePointPatchField::updateCoeffs(); + parent_bctype::updateCoeffs(); } @@ -274,14 +275,14 @@ void Foam::codedFixedValuePointPatchField::evaluate const_cast&>(fvp).evaluate(commsType); - fixedValuePointPatchField::evaluate(commsType); + parent_bctype::evaluate(commsType); } template void Foam::codedFixedValuePointPatchField::write(Ostream& os) const { - fixedValuePointPatchField::write(os); + this->parent_bctype::write(os); os.writeEntry("name", name_); codedBase::writeCodeDict(os, dict_); diff --git a/src/OpenFOAM/fields/pointPatchFields/derived/codedFixedValue/codedFixedValuePointPatchField.H b/src/OpenFOAM/fields/pointPatchFields/derived/codedFixedValue/codedFixedValuePointPatchField.H index 927bde50bf..3a891d0b33 100644 --- a/src/OpenFOAM/fields/pointPatchFields/derived/codedFixedValue/codedFixedValuePointPatchField.H +++ b/src/OpenFOAM/fields/pointPatchFields/derived/codedFixedValue/codedFixedValuePointPatchField.H @@ -31,6 +31,15 @@ Description Constructs on-the-fly a new boundary condition (derived from 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: \verbatim movingWall @@ -102,6 +111,10 @@ class codedFixedValuePointPatchField public fixedValuePointPatchField, protected codedBase { + //- The parent boundary condition type + typedef fixedValuePointPatchField parent_bctype; + + // Private Data //- Dictionary contents for the boundary condition diff --git a/src/dynamicMesh/motionSolvers/displacement/codedPoints0/codedPoints0MotionSolver.H b/src/dynamicMesh/motionSolvers/displacement/codedPoints0/codedPoints0MotionSolver.H index e99e543441..7cc0c374af 100644 --- a/src/dynamicMesh/motionSolvers/displacement/codedPoints0/codedPoints0MotionSolver.H +++ b/src/dynamicMesh/motionSolvers/displacement/codedPoints0/codedPoints0MotionSolver.H @@ -35,10 +35,10 @@ Description The entries are: \plaintable codeInclude | include files - codeOptions | include paths; inserted into EXE_INC in Make/options - codeLibs | link line; inserted into LIB_LIBS in Make/options - localCode | c++; local static functions; - code | c++; upon motionSolver::curPoints(); + 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++; upon motionSolver::curPoints() \endplaintable Note that the dynamically generated motionSolver is an points0MotionSolver, diff --git a/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchField.C index 2a3a1702f7..6882ded6ea 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchField.C @@ -124,7 +124,7 @@ Foam::codedFixedValueFvPatchField::codedFixedValueFvPatchField const DimensionedField& iF ) : - fixedValueFvPatchField(p, iF), + parent_bctype(p, iF), codedBase(), redirectPatchFieldPtr_(nullptr) {} @@ -133,17 +133,17 @@ Foam::codedFixedValueFvPatchField::codedFixedValueFvPatchField template Foam::codedFixedValueFvPatchField::codedFixedValueFvPatchField ( - const codedFixedValueFvPatchField& ptf, + const codedFixedValueFvPatchField& rhs, const fvPatch& p, const DimensionedField& iF, const fvPatchFieldMapper& mapper ) : - fixedValueFvPatchField(ptf, p, iF, mapper), + parent_bctype(rhs, p, iF, mapper), codedBase(), - dict_(ptf.dict_), - name_(ptf.name_), - redirectPatchFieldPtr_() + dict_(rhs.dict_), + name_(rhs.name_), + redirectPatchFieldPtr_(nullptr) {} @@ -155,7 +155,7 @@ Foam::codedFixedValueFvPatchField::codedFixedValueFvPatchField const dictionary& dict ) : - fixedValueFvPatchField(p, iF, dict), + parent_bctype(p, iF, dict), codedBase(), dict_ ( @@ -181,29 +181,29 @@ Foam::codedFixedValueFvPatchField::codedFixedValueFvPatchField template Foam::codedFixedValueFvPatchField::codedFixedValueFvPatchField ( - const codedFixedValueFvPatchField& ptf + const codedFixedValueFvPatchField& rhs ) : - fixedValueFvPatchField(ptf), + parent_bctype(rhs), codedBase(), - dict_(ptf.dict_), - name_(ptf.name_), - redirectPatchFieldPtr_() + dict_(rhs.dict_), + name_(rhs.name_), + redirectPatchFieldPtr_(nullptr) {} template Foam::codedFixedValueFvPatchField::codedFixedValueFvPatchField ( - const codedFixedValueFvPatchField& ptf, + const codedFixedValueFvPatchField& rhs, const DimensionedField& iF ) : - fixedValueFvPatchField(ptf, iF), + parent_bctype(rhs, iF), codedBase(), - dict_(ptf.dict_), - name_(ptf.name_), - redirectPatchFieldPtr_() + dict_(rhs.dict_), + name_(rhs.name_), + redirectPatchFieldPtr_(nullptr) {} @@ -219,10 +219,11 @@ Foam::codedFixedValueFvPatchField::redirectPatchField() const // Make sure to construct the patchfield with up-to-date value OStringStream os; - os.writeEntry("type", name_); static_cast&>(*this).writeEntry("value", os); IStringStream is(os.str()); - dictionary dict(is); + dictionary constructDict(is); + + constructDict.set("type", name_); redirectPatchFieldPtr_.reset ( @@ -230,7 +231,7 @@ Foam::codedFixedValueFvPatchField::redirectPatchField() const ( this->patch(), this->internalField(), - dict + constructDict ).ptr() ); } @@ -256,7 +257,7 @@ void Foam::codedFixedValueFvPatchField::updateCoeffs() // Copy through value this->operator==(fvp); - fixedValueFvPatchField::updateCoeffs(); + parent_bctype::updateCoeffs(); } @@ -273,14 +274,14 @@ void Foam::codedFixedValueFvPatchField::evaluate const_cast&>(fvp).evaluate(commsType); - fixedValueFvPatchField::evaluate(commsType); + parent_bctype::evaluate(commsType); } template void Foam::codedFixedValueFvPatchField::write(Ostream& os) const { - fixedValueFvPatchField::write(os); + this->parent_bctype::write(os); os.writeEntry("name", name_); codedBase::writeCodeDict(os, dict_); diff --git a/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchField.H index 9f2c91e072..8ae89cdc44 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchField.H @@ -34,6 +34,15 @@ Description Constructs on-the-fly a new boundary condition (derived from 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 Example: \verbatim @@ -104,6 +113,10 @@ class codedFixedValueFvPatchField public fixedValueFvPatchField, protected codedBase { + //- The parent boundary condition type + typedef fixedValueFvPatchField parent_bctype; + + // Private Data //- Dictionary contents for the boundary condition diff --git a/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchField.C index 1bb9e078ad..8f73c44288 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchField.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2016-2020 OpenCFD Ltd. + Copyright (C) 2016-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -124,7 +124,7 @@ Foam::codedMixedFvPatchField::codedMixedFvPatchField const DimensionedField& iF ) : - mixedFvPatchField(p, iF), + parent_bctype(p, iF), codedBase(), redirectPatchFieldPtr_(nullptr) {} @@ -133,17 +133,17 @@ Foam::codedMixedFvPatchField::codedMixedFvPatchField template Foam::codedMixedFvPatchField::codedMixedFvPatchField ( - const codedMixedFvPatchField& ptf, + const codedMixedFvPatchField& rhs, const fvPatch& p, const DimensionedField& iF, const fvPatchFieldMapper& mapper ) : - mixedFvPatchField(ptf, p, iF, mapper), + parent_bctype(rhs, p, iF, mapper), codedBase(), - dict_(ptf.dict_), - name_(ptf.name_), - redirectPatchFieldPtr_() + dict_(rhs.dict_), + name_(rhs.name_), + redirectPatchFieldPtr_(nullptr) {} @@ -155,7 +155,7 @@ Foam::codedMixedFvPatchField::codedMixedFvPatchField const dictionary& dict ) : - mixedFvPatchField(p, iF, dict), + parent_bctype(p, iF, dict), codedBase(), dict_ ( @@ -181,29 +181,29 @@ Foam::codedMixedFvPatchField::codedMixedFvPatchField template Foam::codedMixedFvPatchField::codedMixedFvPatchField ( - const codedMixedFvPatchField& ptf + const codedMixedFvPatchField& rhs ) : - mixedFvPatchField(ptf), + parent_bctype(rhs), codedBase(), - dict_(ptf.dict_), - name_(ptf.name_), - redirectPatchFieldPtr_() + dict_(rhs.dict_), + name_(rhs.name_), + redirectPatchFieldPtr_(nullptr) {} template Foam::codedMixedFvPatchField::codedMixedFvPatchField ( - const codedMixedFvPatchField& ptf, + const codedMixedFvPatchField& rhs, const DimensionedField& iF ) : - mixedFvPatchField(ptf, iF), + parent_bctype(rhs, iF), codedBase(), - dict_(ptf.dict_), - name_(ptf.name_), - redirectPatchFieldPtr_() + dict_(rhs.dict_), + name_(rhs.name_), + redirectPatchFieldPtr_(nullptr) {} @@ -220,24 +220,23 @@ Foam::codedMixedFvPatchField::redirectPatchField() const // Write the data from the mixed b.c. OStringStream os; - mixedFvPatchField::write(os); + this->parent_bctype::write(os); IStringStream is(os.str()); // Construct dictionary from it. - dictionary dict(is); + dictionary constructDict(is); - // Override the type to enforce the fvPatchField::New constructor - // to choose our type - dict.set("type", name_); + // Override type + constructDict.set("type", name_); redirectPatchFieldPtr_.reset ( - dynamic_cast*> + dynamic_cast ( fvPatchField::New ( this->patch(), this->internalField(), - dict + constructDict ).ptr() ) ); @@ -257,16 +256,15 @@ void Foam::codedMixedFvPatchField::updateCoeffs() // Make sure library containing user-defined fvPatchField is up-to-date updateLibrary(name_); - const mixedFvPatchField& fvp = redirectPatchField(); - - const_cast&>(fvp).updateCoeffs(); + const parent_bctype& fvp = redirectPatchField(); + const_cast(fvp).updateCoeffs(); // Copy through coefficients this->refValue() = fvp.refValue(); this->refGrad() = fvp.refGrad(); this->valueFraction() = fvp.valueFraction(); - mixedFvPatchField::updateCoeffs(); + this->parent_bctype::updateCoeffs(); } @@ -279,21 +277,21 @@ void Foam::codedMixedFvPatchField::evaluate // Make sure library containing user-defined fvPatchField is up-to-date updateLibrary(name_); - const mixedFvPatchField& fvp = redirectPatchField(); + const parent_bctype& fvp = redirectPatchField(); // - updates the value of fvp (though not used) // - resets the updated() flag - const_cast&>(fvp).evaluate(commsType); + const_cast(fvp).evaluate(commsType); // Update the value (using the coefficients) locally - mixedFvPatchField::evaluate(commsType); + parent_bctype::evaluate(commsType); } template void Foam::codedMixedFvPatchField::write(Ostream& os) const { - mixedFvPatchField::write(os); + this->parent_bctype::write(os); os.writeEntry("name", name_); codedBase::writeCodeDict(os, dict_); diff --git a/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchField.H index 2ca033652e..63430f2d34 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchField.H @@ -31,8 +31,17 @@ Group grpGenericBoundaryConditions Description - Constructs on-the-fly a new boundary condition (derived from - mixedFvPatchField) which is then used to evaluate. + Constructs on-the-fly a new boundary condition + (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 Example: @@ -114,6 +123,10 @@ class codedMixedFvPatchField public mixedFvPatchField, public codedBase { + //- The parent boundary condition type + typedef mixedFvPatchField parent_bctype; + + // Private Data //- Dictionary contents for the boundary condition diff --git a/src/functionObjects/utilities/codedFunctionObject/codedFunctionObject.C b/src/functionObjects/utilities/codedFunctionObject/codedFunctionObject.C index 829df54868..9914a37f41 100644 --- a/src/functionObjects/utilities/codedFunctionObject/codedFunctionObject.C +++ b/src/functionObjects/utilities/codedFunctionObject/codedFunctionObject.C @@ -32,6 +32,7 @@ License #include "Time.H" #include "dynamicCode.H" #include "dynamicCodeContext.H" +#include "dictionaryContent.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -47,8 +48,8 @@ namespace functionObjects codedFunctionObject, dictionary ); -} -} +} // End namespace functionObjects +} // End namespace Foam // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // diff --git a/src/functionObjects/utilities/codedFunctionObject/codedFunctionObject.H b/src/functionObjects/utilities/codedFunctionObject/codedFunctionObject.H index 0ef530cb99..202365ca33 100644 --- a/src/functionObjects/utilities/codedFunctionObject/codedFunctionObject.H +++ b/src/functionObjects/utilities/codedFunctionObject/codedFunctionObject.H @@ -36,14 +36,14 @@ Description The entries are: \plaintable codeInclude | include files - codeOptions | include paths; inserted into EXE_INC in Make/options - codeLibs | link line; inserted into LIB_LIBS in Make/options - codeData | c++; local member data (default constructed); - localCode | c++; local static functions; - codeRead | c++; upon functionObject::read(); - codeExecute | c++; upon functionObject::execute(); + codeOptions | compiler line: added to EXE_INC (Make/options) + codeLibs | linker line: added to LIB_LIBS (Make/options) + codeData | c++; local member data (default constructed) + localCode | c++; local static functions + codeRead | c++; upon functionObject::read() + codeExecute | c++; upon functionObject::execute() codeWrite | c++; upon functionObject::write() - codeEnd | c++; upon functionObject::end(); + codeEnd | c++; upon functionObject::end() \endplaintable Usage diff --git a/src/meshTools/PatchFunction1/CodedField/CodedField.C b/src/meshTools/PatchFunction1/CodedField/CodedField.C index 40c0c4588b..b97e16c714 100644 --- a/src/meshTools/PatchFunction1/CodedField/CodedField.C +++ b/src/meshTools/PatchFunction1/CodedField/CodedField.C @@ -27,6 +27,7 @@ License #include "dynamicCode.H" #include "dynamicCodeContext.H" +#include "dictionaryContent.H" // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // @@ -183,15 +184,13 @@ Foam::PatchFunction1Types::CodedField::redirectFunction() const { if (!redirectFunctionPtr_) { - // Construct a PatchFunction1 containing the input code - dictionary completeDict(dict_); + dictionary constructDict; + // Force 'name_' sub-dictionary into existence + dictionary& coeffs = constructDict.subDictOrAdd(name_); - // Override the type to enforce the PatchFunction1::New constructor - // to choose our type - completeDict.set("type", name_); - - dictionary dict; - dict.add(name_, completeDict); + coeffs = dict_; // Copy input code and coefficients + coeffs.remove("name"); // Redundant + coeffs.set("type", name_); // Specify our new (redirect) type redirectFunctionPtr_.reset ( @@ -199,7 +198,7 @@ Foam::PatchFunction1Types::CodedField::redirectFunction() const ( this->patch(), name_, - dict, + constructDict, this->faceValues() ) ); diff --git a/src/meshTools/PatchFunction1/CodedField/CodedField.H b/src/meshTools/PatchFunction1/CodedField/CodedField.H index d034c5337e..5751215f07 100644 --- a/src/meshTools/PatchFunction1/CodedField/CodedField.H +++ b/src/meshTools/PatchFunction1/CodedField/CodedField.H @@ -30,6 +30,15 @@ Description PatchFunction1 with the code supplied by an on-the-fly compiled C++ 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 Example: \verbatim @@ -38,11 +47,8 @@ Usage type uniformFixedValue; uniformValue { - type coded; - // Explictly supply name of generated PatchFunction1. Only needed - // if entryname ('uniformValue') would clash with existing - // runtime selection tables. - name myExpression; + type coded; + name myExpression; // Name of generated PatchFunction1 code #{ @@ -50,17 +56,17 @@ Usage Pout<< "** Patch size:" << pp.size() << endl; return tmp::New(pp.size(), vector(1, 0, 0)) #}; + + //codeInclude + //#{ + // #include "volFields.H" + //#}; + + //codeOptions + //#{ + // -I$(LIB_SRC)/finiteVolume/lnInclude + //#}; } - - //codeInclude - //#{ - // #include "fvCFD.H" - //#}; - - //codeOptions - //#{ - // -I$(LIB_SRC)/finiteVolume/lnInclude - //#}; } \endverbatim diff --git a/tutorials/compressible/overRhoPimpleDyMFoam/twoSimpleRotors/system/controlDict b/tutorials/compressible/overRhoPimpleDyMFoam/twoSimpleRotors/system/controlDict index fa36ef0362..47912f4c9b 100644 --- a/tutorials/compressible/overRhoPimpleDyMFoam/twoSimpleRotors/system/controlDict +++ b/tutorials/compressible/overRhoPimpleDyMFoam/twoSimpleRotors/system/controlDict @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: v2012 | +| \\ / O peration | Version: v2106 | | \\ / A nd | Website: www.openfoam.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ @@ -59,7 +59,6 @@ maxCo 1.2; functions { - // #include "catalyst" probes { type probes; @@ -82,7 +81,6 @@ functions ( (0.015 0.005 0.005) ); - } mass @@ -114,12 +112,10 @@ functions codeWrite #{ - const volScalarField& rho = mesh().lookupObject("rho"); Info<< "rho volume = " << rho.weightedAverage(mesh().Vsc()) << endl; - #}; } } diff --git a/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/system/preProcess b/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/system/preProcess index f0c0ed10cf..18112454bc 100644 --- a/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/system/preProcess +++ b/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/system/preProcess @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: v2012 | +| \\ / O peration | Version: v2106 | | \\ / A nd | Website: www.openfoam.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ @@ -24,19 +24,14 @@ functions libs (utilityFunctionObjects); enabled yes; - codeInclude - #{ - #include "volFields.H" - #}; - codeWrite #{ - scalar D = 0.57; - scalar UInf = 50; - scalar pInf = 101325; - scalar TInf = 224; - scalar gamma = 1.4; - scalar A = -0.3*D*UInf; + const scalar D = 0.57; + const scalar UInf = 50; + const scalar pInf = 101325; + const scalar TInf = 224; + const scalar gamma = 1.4; + const scalar A = -0.3*D*UInf; const dimensionedScalar rhoRef("rhoRef", dimDensity, 1); const auto& rho = mesh().lookupObject("rho"); diff --git a/tutorials/multiphase/icoReactingMultiPhaseInterFoam/poolEvaporation/0.orig/T b/tutorials/multiphase/icoReactingMultiPhaseInterFoam/poolEvaporation/0.orig/T index 9ba5c45f94..acce5d6b0e 100644 --- a/tutorials/multiphase/icoReactingMultiPhaseInterFoam/poolEvaporation/0.orig/T +++ b/tutorials/multiphase/icoReactingMultiPhaseInterFoam/poolEvaporation/0.orig/T @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: v2012 | +| \\ / O peration | Version: v2106 | | \\ / A nd | Website: www.openfoam.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ @@ -29,11 +29,6 @@ boundaryField { type coded; - codeInclude - #{ - #include "volFields.H" - #}; - code #{ const auto& T =