ENH: ensure that content changes in coded objects are noticed (#1293)

- for codedFunctionObject and CodedSource the main code snippets
  were not included in the SHA1 calculation, which meant that many
  changes would not be noticed and no new library would be compiled.

  As a workaround, a dummy 'code' entry could be used solely for the
  purposes of generating a SHA1, but this is easily forgotten.

  We now allow tracking of the dynamicCodeContext for the coded
  objects and append to the SHA1 hasher with specific entries.
  This should solve the previous misbehaviour.

  We additionally add information about the ordering of the code
  sections. Suppose we have a coded function object (all code
  segments are optional) with the following:

      codeExecute "";
      codeWrite   #{ Info<< "Called\n"; #};

  which we subsequently change to this:

      codeExecute #{ Info<< "Called\n"; #};
      codeWrite   "";

  If the code strings are simply concatenated together, the SHA1 hashes
  will be identical. We thus 'salt' with their semantic locations,
  choosing tags that are unlikely to occur within the code strings
  themselves.

- simplify the coded templates with constexpr for the SHA1sum
  information.

- Correct the CodedSource to use 'codeConstrain' instead of
  'codeSetValue' for consistency with the underlying functions.
This commit is contained in:
Mark Olesen
2019-05-01 14:00:54 +02:00
committed by Andrew Heather
parent 23e5d43e4e
commit a85c55bbb5
34 changed files with 1040 additions and 992 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) YEAR AUTHOR,AFFILIATION
@ -51,18 +51,11 @@ ${localCode}
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
extern "C"
extern "C" void ${typeName}(Ostream& os, const dictionary& dict)
{
void ${typeName}
(
Ostream& os,
const dictionary& dict
)
{
//{{{ begin code
${code}
${code}
//}}} end code
}
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) YEAR AUTHOR,AFFILIATION
@ -42,7 +42,6 @@ ${codeInclude}
namespace Foam
{
namespace fv
{
@ -55,33 +54,26 @@ ${localCode}
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
extern "C"
// dynamicCode:
// SHA1 = ${SHA1sum}
//
// unique function name that can be checked if the correct library version
// has been loaded
extern "C" void ${typeName}_${SHA1sum}(bool load)
{
// dynamicCode:
// SHA1 = ${SHA1sum}
//
// unique function name that can be checked if the correct library version
// has been loaded
void ${typeName}_${SHA1sum}(bool load)
if (load)
{
if (load)
{
// code that can be explicitly executed after loading
}
else
{
// code that can be explicitly executed before unloading
}
// Code that can be explicitly executed after loading
}
else
{
// Code that can be explicitly executed before unloading
}
}
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
//makeRemovablePatchTypeField
//(
// fvPatch${FieldType},
// ${typeName}FvOption${SourceType}
//);
defineTypeNameAndDebug(${typeName}FvOption${SourceType}, 0);
addRemovableToRunTimeSelectionTable
(
@ -91,10 +83,6 @@ addRemovableToRunTimeSelectionTable
);
const char* const ${typeName}FvOption${SourceType}::SHA1sum =
"${SHA1sum}";
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
${typeName}FvOption${SourceType}::
@ -110,8 +98,7 @@ ${typeName}FvOption${SourceType}
{
if (${verbose:-false})
{
Info<<"construct ${typeName} sha1: ${SHA1sum}"
" from components\n";
printMessage("Construct ${typeName} from components");
}
}
@ -123,7 +110,7 @@ ${typeName}FvOption${SourceType}::
{
if (${verbose:-false})
{
Info<<"destroy ${typeName} sha1: ${SHA1sum}\n";
printMessage("Destroy ${typeName}");
}
}
@ -193,14 +180,14 @@ void ${typeName}FvOption${SourceType}::constrain
}
//{{{ begin code
${codeSetValue}
${codeConstrain}
//}}} end code
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace fv
} // End namespace Foam
} // End namespace fv
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) YEAR AUTHOR,AFFILIATION
@ -27,6 +27,7 @@ Description
Template for use with dynamic code generation of a source.
The hook functions take the following arguments:
\verbatim
codeCorrect
(
GeometricField<Type, fvPatchField, volMesh>& fld
@ -38,16 +39,18 @@ Description
const label fieldi
)
constrain
codeConstrain
(
fvMatrix<Type>& eqn,
const label fieldi
)
\endverbatim
where :
fieldi is the index in the fields entry
eqn is the fvMatrix
\verbatim
energySource
{
type scalarCodedSource;
@ -62,7 +65,6 @@ Description
codeInclude
#{
#};
codeCorrect
@ -78,18 +80,9 @@ Description
heSource -= 0.1*sqr(time.value())*V;
#};
codeSetValue
codeConstrain
#{
Pout<< "**codeSetValue**" << endl;
#};
// Dummy entry. Make dependent on above to trigger recompilation
code
#{
$codeInclude
$codeCorrect
$codeAddSup
$codeSetValue
Pout<< "**codeConstrain**" << endl;
#};
}
@ -98,6 +91,7 @@ Description
// Dummy entry
}
}
\endverbatim
SourceFiles
codedFvOptionTemplate.C
@ -113,7 +107,6 @@ SourceFiles
namespace Foam
{
namespace fv
{
@ -125,10 +118,18 @@ class ${typeName}FvOption${SourceType}
:
public cellSetOption
{
// Private Member Functions
//- Report a message with the SHA1sum
inline static void printMessage(const char* message)
{
Info<< message << " sha1: " << SHA1sum << '\n';
}
public:
//- Information about the SHA1 of the code itself
static const char* const SHA1sum;
//- SHA1 representation of the code content
static constexpr const char* const SHA1sum = "${SHA1sum}";
//- Runtime type information
TypeName("${typeName}");
@ -149,44 +150,42 @@ public:
virtual ~${typeName}FvOption${SourceType}();
// Member functions
// Member Functions
//- Correct field
virtual void correct
(
GeometricField<${TemplateType}, fvPatchField, volMesh>&
);
//- Correct field
virtual void correct
(
GeometricField<${TemplateType}, fvPatchField, volMesh>& fld
);
//- Explicit and implicit matrix contributions
virtual void addSup
(
fvMatrix<${TemplateType}>& eqn,
const label fieldi
);
//- Explicit/implicit matrix contributions
virtual void addSup
(
fvMatrix<${TemplateType}>& eqn,
const label fieldi
);
//- Explicit and implicit matrix contributions for compressible
// equations
virtual void addSup
(
const volScalarField& rho,
fvMatrix<${TemplateType}>& eqn,
const label fieldi
);
//- Explicit/implicit matrix contributions for compressible equations
virtual void addSup
(
const volScalarField& rho,
fvMatrix<${TemplateType}>& eqn,
const label fieldi
);
//- Set value
virtual void constrain
(
fvMatrix<${TemplateType}>& eqn,
const label fieldi
);
//- Set value
virtual void constrain
(
fvMatrix<${TemplateType}>& eqn,
const label fieldi
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
} // End namespace fv
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2018-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) YEAR AUTHOR,AFFILIATION
@ -49,23 +49,20 @@ addRemovableToRunTimeSelectionTable
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
extern "C"
// dynamicCode:
// SHA1 = ${SHA1sum}
//
// unique function name that can be checked if the correct library version
// has been loaded
extern "C" void ${typeName}_${SHA1sum}(bool load)
{
// dynamicCode:
// SHA1 = ${SHA1sum}
//
// unique function name that can be checked if the correct library version
// has been loaded
void ${typeName}_${SHA1sum}(bool load)
if (load)
{
if (load)
{
// code that can be explicitly executed after loading
}
else
{
// code that can be explicitly executed before unloading
}
// Code that can be explicitly executed after loading
}
else
{
// Code that can be explicitly executed before unloading
}
}
@ -101,7 +98,7 @@ tmp<pointField> ${typeName}Points0MotionSolver::curPoints() const
{
if (${verbose:-false})
{
Info<<"curPoints ${typeName} sha1: ${SHA1sum}\n";
printMessage("curPoints ${typeName}");
}
//{{{ begin code

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2018-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) YEAR AUTHOR,AFFILIATION
@ -56,6 +56,12 @@ class ${typeName}Points0MotionSolver
{
// Private Member Functions
//- Report a message with the SHA1sum
inline static void printMessage(const char* message)
{
Info<< message << " sha1: " << SHA1sum << '\n';
}
//- No copy construct
${typeName}Points0MotionSolver
(
@ -68,6 +74,9 @@ class ${typeName}Points0MotionSolver
public:
//- SHA1 representation of the code content
static constexpr const char* const SHA1sum = "${SHA1sum}";
//- Runtime type information
TypeName("${typeName}");

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) YEAR AUTHOR,AFFILIATION
@ -31,6 +31,7 @@ License
#include "volFields.H"
#include "surfaceFields.H"
#include "unitConversion.H"
//{{{ begin codeInclude
${codeInclude}
//}}} end codeInclude
@ -50,23 +51,20 @@ ${localCode}
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
extern "C"
// dynamicCode:
// SHA1 = ${SHA1sum}
//
// unique function name that can be checked if the correct library version
// has been loaded
extern "C" void ${typeName}_${SHA1sum}(bool load)
{
// dynamicCode:
// SHA1 = ${SHA1sum}
//
// unique function name that can be checked if the correct library version
// has been loaded
void ${typeName}_${SHA1sum}(bool load)
if (load)
{
if (load)
{
// code that can be explicitly executed after loading
}
else
{
// code that can be explicitly executed before unloading
}
// Code that can be explicitly executed after loading
}
else
{
// Code that can be explicitly executed before unloading
}
}
@ -79,10 +77,6 @@ makeRemovablePatchTypeField
);
const char* const ${typeName}FixedValueFvPatch${FieldType}::SHA1sum =
"${SHA1sum}";
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
${typeName}FixedValueFvPatch${FieldType}::
@ -96,8 +90,7 @@ ${typeName}FixedValueFvPatch${FieldType}
{
if (${verbose:-false})
{
Info<<"construct ${typeName} sha1: ${SHA1sum}"
" from patch/DimensionedField\n";
printMessage("Construct ${typeName} : patch/DimensionedField");
}
}
@ -115,8 +108,7 @@ ${typeName}FixedValueFvPatch${FieldType}
{
if (${verbose:-false})
{
Info<<"construct ${typeName} sha1: ${SHA1sum}"
" from patch/DimensionedField/mapper\n";
printMessage("Construct ${typeName} : patch/DimensionedField/mapper");
}
}
@ -133,8 +125,7 @@ ${typeName}FixedValueFvPatch${FieldType}
{
if (${verbose:-false})
{
Info<<"construct ${typeName} sha1: ${SHA1sum}"
" from patch/dictionary\n";
printMessage("Construct ${typeName} : patch/dictionary");
}
}
@ -149,8 +140,7 @@ ${typeName}FixedValueFvPatch${FieldType}
{
if (${verbose:-false})
{
Info<<"construct ${typeName} sha1: ${SHA1sum}"
" as copy\n";
printMessage("Copy construct ${typeName}");
}
}
@ -166,8 +156,7 @@ ${typeName}FixedValueFvPatch${FieldType}
{
if (${verbose:-false})
{
Info<<"construct ${typeName} sha1: ${SHA1sum} "
"as copy/DimensionedField\n";
printMessage("Construct ${typeName} : copy/DimensionedField");
}
}
@ -179,7 +168,7 @@ ${typeName}FixedValueFvPatch${FieldType}::
{
if (${verbose:-false})
{
Info<<"destroy ${typeName} sha1: ${SHA1sum}\n";
printMessage("Destroy ${typeName}");
}
}
@ -195,7 +184,7 @@ void ${typeName}FixedValueFvPatch${FieldType}::updateCoeffs()
if (${verbose:-false})
{
Info<<"updateCoeffs ${typeName} sha1: ${SHA1sum}\n";
printMessage("updateCoeffs ${typeName}");
}
//{{{ begin code

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) YEAR AUTHOR,AFFILIATION
@ -52,10 +52,18 @@ class ${typeName}FixedValueFvPatch${FieldType}
:
public fixedValueFvPatchField<${TemplateType}>
{
// Private Member Functions
//- Report a message with the SHA1sum
inline static void printMessage(const char* message)
{
Info<< message << " sha1: " << SHA1sum << '\n';
}
public:
//- Information about the SHA1 of the code itself
static const char* const SHA1sum;
//- SHA1 representation of the code content
static constexpr const char* const SHA1sum = "${SHA1sum}";
//- Runtime type information
TypeName("${typeName}");
@ -126,7 +134,7 @@ public:
virtual ~${typeName}FixedValueFvPatch${FieldType}();
// Member functions
// Member Functions
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) YEAR AUTHOR,AFFILIATION
@ -30,6 +30,7 @@ License
#include "pointPatchFieldMapper.H"
#include "pointFields.H"
#include "unitConversion.H"
//{{{ begin codeInclude
${codeInclude}
//}}} end codeInclude
@ -49,23 +50,20 @@ ${localCode}
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
extern "C"
// dynamicCode:
// SHA1 = ${SHA1sum}
//
// unique function name that can be checked if the correct library version
// has been loaded
extern "C" void ${typeName}_${SHA1sum}(bool load)
{
// dynamicCode:
// SHA1 = ${SHA1sum}
//
// unique function name that can be checked if the correct library version
// has been loaded
void ${typeName}_${SHA1sum}(bool load)
if (load)
{
if (load)
{
// code that can be explicitly executed after loading
}
else
{
// code that can be explicitly executed before unloading
}
// Code that can be explicitly executed after loading
}
else
{
// Code that can be explicitly executed before unloading
}
}
@ -78,10 +76,6 @@ makePointPatchTypeField
);
const char* const ${typeName}FixedValuePointPatch${FieldType}::SHA1sum =
"${SHA1sum}";
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
${typeName}FixedValuePointPatch${FieldType}::
@ -95,8 +89,7 @@ ${typeName}FixedValuePointPatch${FieldType}
{
if (${verbose:-false})
{
Info<<"construct ${typeName} sha1: ${SHA1sum}"
" from patch/DimensionedField\n";
printMessage("Construct ${typeName} : patch/DimensionedField");
}
}
@ -114,8 +107,7 @@ ${typeName}FixedValuePointPatch${FieldType}
{
if (${verbose:-false})
{
Info<<"construct ${typeName} sha1: ${SHA1sum}"
" from patch/DimensionedField/mapper\n";
printMessage("Construct ${typeName} : patch/DimensionedField/mapper");
}
}
@ -133,8 +125,7 @@ ${typeName}FixedValuePointPatch${FieldType}
{
if (${verbose:-false})
{
Info<<"construct ${typeName} sha1: ${SHA1sum}"
" from patch/dictionary\n";
printMessage("Construct ${typeName} : patch/dictionary");
}
}
@ -149,8 +140,7 @@ ${typeName}FixedValuePointPatch${FieldType}
{
if (${verbose:-false})
{
Info<<"construct ${typeName} sha1: ${SHA1sum}"
" as copy\n";
printMessage("Copy construct ${typeName}");
}
}
@ -166,8 +156,7 @@ ${typeName}FixedValuePointPatch${FieldType}
{
if (${verbose:-false})
{
Info<<"construct ${typeName} sha1: ${SHA1sum} "
"as copy/DimensionedField\n";
printMessage("Construct ${typeName} : copy/DimensionedField");
}
}
@ -179,7 +168,7 @@ ${typeName}FixedValuePointPatch${FieldType}::
{
if (${verbose:-false})
{
Info<<"destroy ${typeName} sha1: ${SHA1sum}\n";
printMessage("Destroy ${typeName}");
}
}
@ -195,7 +184,7 @@ void ${typeName}FixedValuePointPatch${FieldType}::updateCoeffs()
if (${verbose:-false})
{
Info<<"updateCoeffs ${typeName} sha1: ${SHA1sum}\n";
printMessage("updateCoeffs ${typeName}");
}
//{{{ begin code

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) YEAR AUTHOR,AFFILIATION
@ -52,10 +52,18 @@ class ${typeName}FixedValuePointPatch${FieldType}
:
public fixedValuePointPatchField<${TemplateType}>
{
// Private Member Functions
//- Report a message with the SHA1sum
inline static void printMessage(const char* message)
{
Info<< message << " sha1: " << SHA1sum << '\n';
}
public:
//- Information about the SHA1 of the code itself
static const char* const SHA1sum;
//- SHA1 representation of the code content
static constexpr const char* const SHA1sum = "${SHA1sum}";
//- Runtime type information
TypeName("${typeName}");
@ -127,7 +135,7 @@ public:
virtual ~${typeName}FixedValuePointPatch${FieldType}();
// Member functions
// Member Functions
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) YEAR AUTHOR,AFFILIATION
@ -49,23 +49,20 @@ addRemovableToRunTimeSelectionTable
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
extern "C"
// dynamicCode:
// SHA1 = ${SHA1sum}
//
// unique function name that can be checked if the correct library version
// has been loaded
extern "C" void ${typeName}_${SHA1sum}(bool load)
{
// dynamicCode:
// SHA1 = ${SHA1sum}
//
// unique function name that can be checked if the correct library version
// has been loaded
void ${typeName}_${SHA1sum}(bool load)
if (load)
{
if (load)
{
// code that can be explicitly executed after loading
}
else
{
// code that can be explicitly executed before unloading
}
// Code that can be explicitly executed after loading
}
else
{
// Code that can be explicitly executed before unloading
}
}
@ -112,7 +109,7 @@ bool ${typeName}FunctionObject::read(const dictionary& dict)
{
if (${verbose:-false})
{
Info<<"read ${typeName} sha1: ${SHA1sum}\n";
printMessage("read ${typeName}");
}
//{{{ begin code
@ -127,7 +124,7 @@ bool ${typeName}FunctionObject::execute()
{
if (${verbose:-false})
{
Info<<"execute ${typeName} sha1: ${SHA1sum}\n";
printMessage("execute ${typeName}");
}
//{{{ begin code
@ -142,7 +139,7 @@ bool ${typeName}FunctionObject::write()
{
if (${verbose:-false})
{
Info<<"write ${typeName} sha1: ${SHA1sum}\n";
printMessage("write ${typeName}");
}
//{{{ begin code
@ -157,7 +154,7 @@ bool ${typeName}FunctionObject::end()
{
if (${verbose:-false})
{
Info<<"end ${typeName} sha1: ${SHA1sum}\n";
printMessage("end ${typeName}");
}
//{{{ begin code

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) YEAR AUTHOR,AFFILIATION
@ -24,8 +24,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Description
Template for use with dynamic code generation of a
OutputFilter functionObject.
Template for use with dynamic code generation of a functionObject.
SourceFiles
functionObjectTemplate.C
@ -57,7 +56,7 @@ class ${typeName}FunctionObject
:
public functionObjects::regionFunctionObject
{
// Private data
// Private Data
//{{{ begin codeData
${codeData}
@ -66,6 +65,13 @@ class ${typeName}FunctionObject
// Private Member Functions
//- Report a message with the SHA1sum
inline static void printMessage(const char* message)
{
Info<< message << " sha1: " << SHA1sum << '\n';
}
//- Cast reference of objectRegistry to fvMesh
const fvMesh& mesh() const;
//- No copy construct
@ -74,9 +80,11 @@ class ${typeName}FunctionObject
//- No copy assignment
void operator=(const ${typeName}FunctionObject&) = delete;
public:
//- SHA1 representation of the code content
static constexpr const char* const SHA1sum = "${SHA1sum}";
//- Runtime type information
TypeName("${typeName}");
@ -98,17 +106,17 @@ public:
// Member Functions
//- Read the system calls
//- Read the dictionary
virtual bool read(const dictionary& dict);
//- Execute the "executeCalls" at each time-step
//- Execute (at time-step)
virtual bool execute();
//- Execute the "endCalls" at the final time-loop
virtual bool end();
//- Write, execute the "writeCalls"
//- Write (at write interval)
virtual bool write();
//- Executed at the final time-loop
virtual bool end();
};

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) YEAR AUTHOR,AFFILIATION
@ -31,6 +31,7 @@ License
#include "volFields.H"
#include "surfaceFields.H"
#include "unitConversion.H"
//{{{ begin codeInclude
${codeInclude}
//}}} end codeInclude
@ -47,26 +48,22 @@ namespace Foam
${localCode}
//}}} end localCode
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
extern "C"
// dynamicCode:
// SHA1 = ${SHA1sum}
//
// unique function name that can be checked if the correct library version
// has been loaded
extern "C" void ${typeName}_${SHA1sum}(bool load)
{
// dynamicCode:
// SHA1 = ${SHA1sum}
//
// unique function name that can be checked if the correct library version
// has been loaded
void ${typeName}_${SHA1sum}(bool load)
if (load)
{
if (load)
{
// code that can be explicitly executed after loading
}
else
{
// code that can be explicitly executed before unloading
}
// Code that can be explicitly executed after loading
}
else
{
// Code that can be explicitly executed before unloading
}
}
@ -79,10 +76,6 @@ makeRemovablePatchTypeField
);
const char* const ${typeName}MixedValueFvPatch${FieldType}::SHA1sum =
"${SHA1sum}";
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
${typeName}MixedValueFvPatch${FieldType}::
@ -96,8 +89,7 @@ ${typeName}MixedValueFvPatch${FieldType}
{
if (${verbose:-false})
{
Info<<"construct ${typeName} sha1: ${SHA1sum}"
" from patch/DimensionedField\n";
printMessage("Construct ${typeName} : patch/DimensionedField");
}
}
@ -115,8 +107,7 @@ ${typeName}MixedValueFvPatch${FieldType}
{
if (${verbose:-false})
{
Info<<"construct ${typeName} sha1: ${SHA1sum}"
" from patch/DimensionedField/mapper\n";
printMessage("Construct ${typeName} : patch/DimensionedField/mapper");
}
}
@ -133,8 +124,7 @@ ${typeName}MixedValueFvPatch${FieldType}
{
if (${verbose:-false})
{
Info<<"construct ${typeName} sha1: ${SHA1sum}"
" from patch/dictionary\n";
printMessage("Construct ${typeName} : patch/dictionary");
}
}
@ -149,8 +139,7 @@ ${typeName}MixedValueFvPatch${FieldType}
{
if (${verbose:-false})
{
Info<<"construct ${typeName} sha1: ${SHA1sum}"
" as copy\n";
printMessage("Copy construct ${typeName}");
}
}
@ -166,8 +155,7 @@ ${typeName}MixedValueFvPatch${FieldType}
{
if (${verbose:-false})
{
Info<<"construct ${typeName} sha1: ${SHA1sum} "
"as copy/DimensionedField\n";
printMessage("Construct ${typeName} : copy/DimensionedField");
}
}
@ -179,7 +167,7 @@ ${typeName}MixedValueFvPatch${FieldType}::
{
if (${verbose:-false})
{
Info<<"destroy ${typeName} sha1: ${SHA1sum}\n";
printMessage("Destroy ${typeName}");
}
}
@ -195,7 +183,7 @@ void ${typeName}MixedValueFvPatch${FieldType}::updateCoeffs()
if (${verbose:-false})
{
Info<<"updateCoeffs ${typeName} sha1: ${SHA1sum}\n";
printMessage("updateCoeffs ${typeName}");
}
//{{{ begin code

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) YEAR AUTHOR,AFFILIATION
@ -52,10 +52,18 @@ class ${typeName}MixedValueFvPatch${FieldType}
:
public mixedFvPatchField<${TemplateType}>
{
// Private Member Functions
//- Report a message with the SHA1sum
inline static void printMessage(const char* message)
{
Info<< message << " sha1: " << SHA1sum << '\n';
}
public:
//- Information about the SHA1 of the code itself
static const char* const SHA1sum;
//- SHA1 representation of the code content
static constexpr const char* const SHA1sum = "${SHA1sum}";
//- Runtime type information
TypeName("${typeName}");
@ -126,7 +134,7 @@ public:
virtual ~${typeName}MixedValueFvPatch${FieldType}();
// Member functions
// Member Functions
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();