mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'issue-1922-user-access-to-dictionary' into 'develop'
add access to dictionary context for dynamic-coded items. See merge request Development/openfoam!466
This commit is contained in:
@ -144,10 +144,11 @@ Foam::fv::VoFSolidificationMeltingSource::VoFSolidificationMeltingSource
|
||||
),
|
||||
curTimeIndex_(-1)
|
||||
{
|
||||
fieldNames_.setSize(2);
|
||||
fieldNames_.resize(2);
|
||||
fieldNames_[0] = "U";
|
||||
fieldNames_[1] = "T";
|
||||
applied_.setSize(fieldNames_.size(), false);
|
||||
|
||||
fv::option::resetApplied();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -41,10 +41,6 @@ bool Foam::fv::VoFSolidificationMeltingSource::read(const dictionary& dict)
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
@ -5,8 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
Copyright (C) YEAR AUTHOR, AFFILIATION
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -25,7 +24,7 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Description
|
||||
Template for use with dynamic code generation of a source.
|
||||
Template for use with dynamic code generation of a finiteVolume source.
|
||||
The hook functions take the following arguments:
|
||||
|
||||
\verbatim
|
||||
@ -103,6 +102,7 @@ SourceFiles
|
||||
#define codedFvOptionTemplate_H
|
||||
|
||||
#include "cellSetOption.H"
|
||||
#include "dictionaryContent.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -117,7 +117,8 @@ namespace fv
|
||||
|
||||
class ${typeName}FvOption${SourceType}
|
||||
:
|
||||
public cellSetOption
|
||||
public fv::cellSetOption,
|
||||
public dictionaryContent
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
@ -138,7 +139,7 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from patch and internal field
|
||||
//- Construct from mesh
|
||||
${typeName}FvOption${SourceType}
|
||||
(
|
||||
const word& name,
|
||||
@ -147,12 +148,19 @@ public:
|
||||
const fvMesh& mesh
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~${typeName}FvOption${SourceType}();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Code context as a dictionary
|
||||
const dictionary& codeContext() const
|
||||
{
|
||||
return dictionaryContent::dict();
|
||||
}
|
||||
|
||||
//- Correct field
|
||||
virtual void correct
|
||||
(
|
||||
|
||||
@ -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,25 +98,15 @@ ${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");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
${typeName}PatchFunction1${FieldType}::
|
||||
${typeName}PatchFunction1${FieldType}
|
||||
(
|
||||
const ${typeName}PatchFunction1${FieldType}& rhs
|
||||
)
|
||||
:
|
||||
PatchFunction1<${TemplateType}>(rhs)
|
||||
{}
|
||||
|
||||
|
||||
${typeName}PatchFunction1${FieldType}::
|
||||
${typeName}PatchFunction1${FieldType}
|
||||
(
|
||||
@ -122,13 +114,13 @@ ${typeName}PatchFunction1${FieldType}
|
||||
const polyPatch& pp
|
||||
)
|
||||
:
|
||||
PatchFunction1<${TemplateType}>(rhs, pp)
|
||||
parent_bctype(rhs, pp)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
tmp<Field<${TemplateType}>>
|
||||
Foam::tmp<Foam::Field<Foam::${TemplateType}>>
|
||||
${typeName}PatchFunction1${FieldType}::value
|
||||
(
|
||||
const scalar x
|
||||
|
||||
@ -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.
|
||||
@ -36,6 +35,7 @@ SourceFiles
|
||||
#define codedPatchFunction1Template${FieldType}_H
|
||||
|
||||
#include "PatchFunction1.H"
|
||||
#include "dictionaryContent.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -50,8 +50,12 @@ namespace PatchFunction1Types
|
||||
|
||||
class ${typeName}PatchFunction1${FieldType}
|
||||
:
|
||||
public PatchFunction1<${TemplateType}>
|
||||
public PatchFunction1<${TemplateType}>,
|
||||
public dictionaryContent
|
||||
{
|
||||
//- The parent PatchFunction1 type
|
||||
typedef PatchFunction1<${TemplateType}> parent_bctype;
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Report a message with the SHA1sum
|
||||
@ -85,7 +89,7 @@ public:
|
||||
${typeName}PatchFunction1${FieldType}
|
||||
(
|
||||
const ${typeName}PatchFunction1${FieldType}& rhs
|
||||
);
|
||||
) = default;
|
||||
|
||||
//- Copy construct, resetting patch
|
||||
${typeName}PatchFunction1${FieldType}
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2018-2019 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2021 OpenCFD Ltd.
|
||||
Copyright (C) YEAR AUTHOR, AFFILIATION
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -27,6 +27,7 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "codedPoints0MotionSolverTemplate.H"
|
||||
#define namespaceFoam // Suppress <using namespace Foam;>
|
||||
#include "fvCFD.H"
|
||||
#include "unitConversion.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
@ -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.
|
||||
@ -37,6 +36,7 @@ SourceFiles
|
||||
#define codedPoints0MotionSolverTemplate_H
|
||||
|
||||
#include "points0MotionSolver.H"
|
||||
#include "dictionaryContent.H"
|
||||
|
||||
//{{{ begin codeInclude
|
||||
${codeInclude}
|
||||
@ -53,7 +53,8 @@ namespace Foam
|
||||
|
||||
class ${typeName}Points0MotionSolver
|
||||
:
|
||||
public points0MotionSolver
|
||||
public points0MotionSolver,
|
||||
public dictionaryContent
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
@ -70,7 +71,10 @@ class ${typeName}Points0MotionSolver
|
||||
) = delete;
|
||||
|
||||
//- No copy assignment
|
||||
void operator=(const ${typeName}Points0MotionSolver&) = delete;
|
||||
void operator=
|
||||
(
|
||||
const ${typeName}Points0MotionSolver&
|
||||
) = delete;
|
||||
|
||||
|
||||
public:
|
||||
@ -98,6 +102,12 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Code context as a dictionary
|
||||
const dictionary& codeContext() const
|
||||
{
|
||||
return dictionaryContent::dict();
|
||||
}
|
||||
|
||||
//- Provide current points for motion. Uses current motion field
|
||||
virtual tmp<pointField> curPoints() const;
|
||||
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -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.
|
||||
@ -39,6 +38,7 @@ SourceFiles
|
||||
#define fixedValueFvPatchTemplate${FieldType}_H
|
||||
|
||||
#include "fixedValueFvPatchFields.H"
|
||||
#include "dictionaryContent.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -51,8 +51,13 @@ namespace Foam
|
||||
|
||||
class ${typeName}FixedValueFvPatch${FieldType}
|
||||
:
|
||||
public fixedValueFvPatchField<${TemplateType}>
|
||||
public fixedValueFvPatchField<${TemplateType}>,
|
||||
public dictionaryContent
|
||||
{
|
||||
//- The parent boundary condition type
|
||||
typedef fixedValueFvPatchField<${TemplateType}> parent_bctype;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Report a message with the SHA1sum
|
||||
@ -137,6 +142,12 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Code context as a dictionary
|
||||
const dictionary& codeContext() const
|
||||
{
|
||||
return dictionaryContent::dict();
|
||||
}
|
||||
|
||||
//- Update the coefficients associated with the patch field
|
||||
virtual void updateCoeffs();
|
||||
};
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -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,10 +34,11 @@ SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef fixedValuePointPatchTemplate${FieldType}_H
|
||||
#define fixedValuePointPatchTemplate${FieldType}_H
|
||||
#ifndef coded_fixedValuePointPatchTemplate${FieldType}_H
|
||||
#define coded_fixedValuePointPatchTemplate${FieldType}_H
|
||||
|
||||
#include "fixedValuePointPatchFields.H"
|
||||
#include "dictionaryContent.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -51,8 +51,13 @@ namespace Foam
|
||||
|
||||
class ${typeName}FixedValuePointPatch${FieldType}
|
||||
:
|
||||
public fixedValuePointPatchField<${TemplateType}>
|
||||
public fixedValuePointPatchField<${TemplateType}>,
|
||||
public dictionaryContent
|
||||
{
|
||||
//- The parent boundary condition type
|
||||
typedef fixedValuePointPatchField<${TemplateType}> parent_bctype;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Report a message with the SHA1sum
|
||||
@ -138,6 +143,12 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Code context as a dictionary
|
||||
const dictionary& codeContext() const
|
||||
{
|
||||
return dictionaryContent::dict();
|
||||
}
|
||||
|
||||
//- Update the coefficients associated with the patch field
|
||||
virtual void updateCoeffs();
|
||||
};
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
Copyright (C) YEAR AUTHOR, AFFILIATION
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -27,6 +27,7 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "functionObjectTemplate.H"
|
||||
#define namespaceFoam // Suppress <using namespace Foam;>
|
||||
#include "fvCFD.H"
|
||||
#include "unitConversion.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
@ -106,7 +107,8 @@ ${typeName}FunctionObject::~${typeName}FunctionObject()
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool ${typeName}FunctionObject::read(const dictionary& dict)
|
||||
bool
|
||||
${typeName}FunctionObject::read(const dictionary& dict)
|
||||
{
|
||||
if (${verbose:-false})
|
||||
{
|
||||
@ -121,7 +123,8 @@ bool ${typeName}FunctionObject::read(const dictionary& dict)
|
||||
}
|
||||
|
||||
|
||||
bool ${typeName}FunctionObject::execute()
|
||||
bool
|
||||
${typeName}FunctionObject::execute()
|
||||
{
|
||||
if (${verbose:-false})
|
||||
{
|
||||
@ -136,7 +139,8 @@ bool ${typeName}FunctionObject::execute()
|
||||
}
|
||||
|
||||
|
||||
bool ${typeName}FunctionObject::write()
|
||||
bool
|
||||
${typeName}FunctionObject::write()
|
||||
{
|
||||
if (${verbose:-false})
|
||||
{
|
||||
@ -151,7 +155,8 @@ bool ${typeName}FunctionObject::write()
|
||||
}
|
||||
|
||||
|
||||
bool ${typeName}FunctionObject::end()
|
||||
bool
|
||||
${typeName}FunctionObject::end()
|
||||
{
|
||||
if (${verbose:-false})
|
||||
{
|
||||
|
||||
@ -36,6 +36,7 @@ SourceFiles
|
||||
#define functionObjectTemplate_H
|
||||
|
||||
#include "regionFunctionObject.H"
|
||||
#include "dictionaryContent.H"
|
||||
|
||||
//{{{ begin codeInclude
|
||||
${codeInclude}
|
||||
@ -55,7 +56,8 @@ class fvMesh;
|
||||
|
||||
class ${typeName}FunctionObject
|
||||
:
|
||||
public functionObjects::regionFunctionObject
|
||||
public functionObjects::regionFunctionObject,
|
||||
public dictionaryContent
|
||||
{
|
||||
// Private Data
|
||||
|
||||
@ -76,10 +78,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 +105,7 @@ public:
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary&
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
@ -107,7 +115,13 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read the dictionary
|
||||
//- Code context as a dictionary
|
||||
const dictionary& codeContext() const
|
||||
{
|
||||
return dictionaryContent::dict();
|
||||
}
|
||||
|
||||
//- Read optional controls
|
||||
virtual bool read(const dictionary& dict);
|
||||
|
||||
//- Execute (at time-step)
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -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,10 +34,11 @@ SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef mixedFvPatchTemplate${FieldType}_H
|
||||
#define mixedFvPatchTemplate${FieldType}_H
|
||||
#ifndef coded_mixedFvPatchTemplate${FieldType}_H
|
||||
#define coded_mixedFvPatchTemplate${FieldType}_H
|
||||
|
||||
#include "mixedFvPatchFields.H"
|
||||
#include "dictionaryContent.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -51,8 +51,13 @@ namespace Foam
|
||||
|
||||
class ${typeName}MixedValueFvPatch${FieldType}
|
||||
:
|
||||
public mixedFvPatchField<${TemplateType}>
|
||||
public mixedFvPatchField<${TemplateType}>,
|
||||
public dictionaryContent
|
||||
{
|
||||
//- The parent boundary condition type
|
||||
typedef mixedFvPatchField<${TemplateType}> parent_bctype;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Report a message with the SHA1sum
|
||||
@ -137,6 +142,12 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Code context as a dictionary
|
||||
const dictionary& codeContext() const
|
||||
{
|
||||
return dictionaryContent::dict();
|
||||
}
|
||||
|
||||
//- Update the coefficients associated with the patch field
|
||||
virtual void updateCoeffs();
|
||||
};
|
||||
|
||||
@ -60,6 +60,15 @@ void Foam::codedFixedValuePointPatchField<Type>::clearRedirect() const
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
const Foam::dictionary&
|
||||
Foam::codedFixedValuePointPatchField<Type>::codeContext() const
|
||||
{
|
||||
const dictionary* ptr = dict_.findDict("codeContext", keyType::LITERAL);
|
||||
return (ptr ? *ptr : dictionary::null);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
const Foam::dictionary&
|
||||
Foam::codedFixedValuePointPatchField<Type>::codeDict() const
|
||||
@ -124,7 +133,7 @@ Foam::codedFixedValuePointPatchField<Type>::codedFixedValuePointPatchField
|
||||
const DimensionedField<Type, pointMesh>& iF
|
||||
)
|
||||
:
|
||||
fixedValuePointPatchField<Type>(p, iF),
|
||||
parent_bctype(p, iF),
|
||||
codedBase(),
|
||||
redirectPatchFieldPtr_(nullptr)
|
||||
{}
|
||||
@ -133,17 +142,17 @@ Foam::codedFixedValuePointPatchField<Type>::codedFixedValuePointPatchField
|
||||
template<class Type>
|
||||
Foam::codedFixedValuePointPatchField<Type>::codedFixedValuePointPatchField
|
||||
(
|
||||
const codedFixedValuePointPatchField<Type>& ptf,
|
||||
const codedFixedValuePointPatchField<Type>& rhs,
|
||||
const pointPatch& p,
|
||||
const DimensionedField<Type, pointMesh>& iF,
|
||||
const pointPatchFieldMapper& mapper
|
||||
)
|
||||
:
|
||||
fixedValuePointPatchField<Type>(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 +165,7 @@ Foam::codedFixedValuePointPatchField<Type>::codedFixedValuePointPatchField
|
||||
const bool valueRequired
|
||||
)
|
||||
:
|
||||
fixedValuePointPatchField<Type>(p, iF, dict, valueRequired),
|
||||
parent_bctype(p, iF, dict, valueRequired),
|
||||
codedBase(),
|
||||
dict_
|
||||
(
|
||||
@ -182,29 +191,29 @@ Foam::codedFixedValuePointPatchField<Type>::codedFixedValuePointPatchField
|
||||
template<class Type>
|
||||
Foam::codedFixedValuePointPatchField<Type>::codedFixedValuePointPatchField
|
||||
(
|
||||
const codedFixedValuePointPatchField<Type>& ptf
|
||||
const codedFixedValuePointPatchField<Type>& rhs
|
||||
)
|
||||
:
|
||||
fixedValuePointPatchField<Type>(ptf),
|
||||
parent_bctype(rhs),
|
||||
codedBase(),
|
||||
dict_(ptf.dict_),
|
||||
name_(ptf.name_),
|
||||
redirectPatchFieldPtr_()
|
||||
dict_(rhs.dict_),
|
||||
name_(rhs.name_),
|
||||
redirectPatchFieldPtr_(nullptr)
|
||||
{}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::codedFixedValuePointPatchField<Type>::codedFixedValuePointPatchField
|
||||
(
|
||||
const codedFixedValuePointPatchField<Type>& ptf,
|
||||
const codedFixedValuePointPatchField<Type>& rhs,
|
||||
const DimensionedField<Type, pointMesh>& iF
|
||||
)
|
||||
:
|
||||
fixedValuePointPatchField<Type>(ptf, iF),
|
||||
parent_bctype(rhs, iF),
|
||||
codedBase(),
|
||||
dict_(ptf.dict_),
|
||||
name_(ptf.name_),
|
||||
redirectPatchFieldPtr_()
|
||||
dict_(rhs.dict_),
|
||||
name_(rhs.name_),
|
||||
redirectPatchFieldPtr_(nullptr)
|
||||
{}
|
||||
|
||||
|
||||
@ -220,10 +229,11 @@ Foam::codedFixedValuePointPatchField<Type>::redirectPatchField() const
|
||||
// Make sure to construct the patchfield with up-to-date value
|
||||
|
||||
OStringStream os;
|
||||
os.writeEntry("type", name_);
|
||||
static_cast<const Field<Type>&>(*this).writeEntry("value", os);
|
||||
IStringStream is(os.str());
|
||||
dictionary dict(is);
|
||||
dictionary constructDict(is);
|
||||
|
||||
constructDict.set("type", name_);
|
||||
|
||||
redirectPatchFieldPtr_.reset
|
||||
(
|
||||
@ -231,9 +241,25 @@ Foam::codedFixedValuePointPatchField<Type>::redirectPatchField() const
|
||||
(
|
||||
this->patch(),
|
||||
this->internalField(),
|
||||
dict
|
||||
constructDict
|
||||
).ptr()
|
||||
);
|
||||
|
||||
|
||||
// Forward copy of codeContext to the code template
|
||||
auto* contentPtr =
|
||||
dynamic_cast<dictionaryContent*>(redirectPatchFieldPtr_.get());
|
||||
|
||||
if (contentPtr)
|
||||
{
|
||||
contentPtr->dict(this->codeContext());
|
||||
}
|
||||
else
|
||||
{
|
||||
WarningInFunction
|
||||
<< name_ << " Did not derive from dictionaryContent"
|
||||
<< nl << nl;
|
||||
}
|
||||
}
|
||||
return *redirectPatchFieldPtr_;
|
||||
}
|
||||
@ -257,7 +283,7 @@ void Foam::codedFixedValuePointPatchField<Type>::updateCoeffs()
|
||||
// Copy through value
|
||||
this->operator==(fvp);
|
||||
|
||||
fixedValuePointPatchField<Type>::updateCoeffs();
|
||||
parent_bctype::updateCoeffs();
|
||||
}
|
||||
|
||||
|
||||
@ -274,14 +300,14 @@ void Foam::codedFixedValuePointPatchField<Type>::evaluate
|
||||
|
||||
const_cast<pointPatchField<Type>&>(fvp).evaluate(commsType);
|
||||
|
||||
fixedValuePointPatchField<Type>::evaluate(commsType);
|
||||
parent_bctype::evaluate(commsType);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::codedFixedValuePointPatchField<Type>::write(Ostream& os) const
|
||||
{
|
||||
fixedValuePointPatchField<Type>::write(os);
|
||||
this->parent_bctype::write(os);
|
||||
os.writeEntry("name", name_);
|
||||
|
||||
codedBase::writeCodeDict(os, dict_);
|
||||
|
||||
@ -31,6 +31,16 @@ 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
|
||||
codeContext | additional dictionary context for the code
|
||||
\endplaintable
|
||||
|
||||
Example:
|
||||
\verbatim
|
||||
movingWall
|
||||
@ -47,6 +57,11 @@ Description
|
||||
);
|
||||
#};
|
||||
|
||||
codeContext
|
||||
{
|
||||
...
|
||||
}
|
||||
|
||||
//codeInclude
|
||||
//#{
|
||||
// #include "fvCFD.H"
|
||||
@ -73,6 +88,10 @@ Description
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
Note
|
||||
The code context dictionary can be supplied separately as the
|
||||
\c codeContext entry.
|
||||
|
||||
See also
|
||||
codedFixedValueFvPatchField
|
||||
|
||||
@ -102,6 +121,10 @@ class codedFixedValuePointPatchField
|
||||
public fixedValuePointPatchField<Type>,
|
||||
protected codedBase
|
||||
{
|
||||
//- The parent boundary condition type
|
||||
typedef fixedValuePointPatchField<Type> parent_bctype;
|
||||
|
||||
|
||||
// Private Data
|
||||
|
||||
//- Dictionary contents for the boundary condition
|
||||
@ -123,6 +146,9 @@ class codedFixedValuePointPatchField
|
||||
//- Clear redirected object(s)
|
||||
virtual void clearRedirect() const;
|
||||
|
||||
//- Additional 'codeContext' dictionary to pass through
|
||||
virtual const dictionary& codeContext() const;
|
||||
|
||||
//- The code dictionary. Inline "code" or from system/codeDict
|
||||
virtual const dictionary& codeDict() const;
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2020 ENERCON GmbH
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -107,7 +107,7 @@ Foam::fv::atmAmbientTurbSource::atmAmbientTurbSource
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
fieldNames_.setSize(2, "undefined");
|
||||
fieldNames_.resize(2);
|
||||
|
||||
tmp<volScalarField> tepsilon = turbPtr->epsilon();
|
||||
tmp<volScalarField> tomega = turbPtr->omega();
|
||||
@ -140,7 +140,7 @@ Foam::fv::atmAmbientTurbSource::atmAmbientTurbSource
|
||||
|
||||
fieldNames_[1] = turbPtr->k()().name();
|
||||
|
||||
applied_.setSize(fieldNames_.size(), false);
|
||||
fv::option::resetApplied();
|
||||
|
||||
Log << " Applying atmAmbientTurbSource to: "
|
||||
<< fieldNames_[0] << " and " << fieldNames_[1]
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2020 ENERCON GmbH
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -198,7 +198,7 @@ Foam::fv::atmBuoyancyTurbSource::atmBuoyancyTurbSource
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
fieldNames_.setSize(2, "undefined");
|
||||
fieldNames_.resize(2);
|
||||
|
||||
tmp<volScalarField> tepsilon = turbPtr->epsilon();
|
||||
tmp<volScalarField> tomega = turbPtr->omega();
|
||||
@ -232,7 +232,7 @@ Foam::fv::atmBuoyancyTurbSource::atmBuoyancyTurbSource
|
||||
|
||||
fieldNames_[1] = turbPtr->k()().name();
|
||||
|
||||
applied_.setSize(fieldNames_.size(), false);
|
||||
fv::option::resetApplied();
|
||||
|
||||
Log << " Applying atmBuoyancyTurbSource to: "
|
||||
<< fieldNames_[0] << " and " << fieldNames_[1]
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2020 CENER
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -109,9 +109,9 @@ Foam::fv::atmCoriolisUSource::atmCoriolisUSource
|
||||
<< endl;
|
||||
}
|
||||
|
||||
fieldNames_.setSize(1, "U");
|
||||
fieldNames_.resize(1, "U");
|
||||
|
||||
applied_.setSize(fieldNames_.size(), false);
|
||||
fv::option::resetApplied();
|
||||
|
||||
Log << " Applying atmCoriolisUSource to: " << fieldNames_[0] << endl;
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2020 ENERCON GmbH
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -134,7 +134,7 @@ Foam::fv::atmLengthScaleTurbSource::atmLengthScaleTurbSource
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
fieldNames_.setSize(1, "undefined");
|
||||
fieldNames_.resize(1);
|
||||
|
||||
tmp<volScalarField> tepsilon = turbPtr->epsilon();
|
||||
tmp<volScalarField> tomega = turbPtr->omega();
|
||||
@ -165,7 +165,7 @@ Foam::fv::atmLengthScaleTurbSource::atmLengthScaleTurbSource
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
applied_.setSize(fieldNames_.size(), false);
|
||||
fv::option::resetApplied();
|
||||
|
||||
Log << " Applying atmLengthScaleTurbSource to: " << fieldNames_[0]
|
||||
<< endl;
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2020 ENERCON GmbH
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -88,7 +88,7 @@ Foam::fv::atmNutSource::atmNutSource
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
fieldNames_.setSize(1, "undefined");
|
||||
fieldNames_.resize(1);
|
||||
|
||||
const tmp<volScalarField>& tnut = turbPtr->nut();
|
||||
|
||||
@ -104,7 +104,7 @@ Foam::fv::atmNutSource::atmNutSource
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
applied_.setSize(fieldNames_.size(), false);
|
||||
fv::option::resetApplied();
|
||||
|
||||
Log << " Applying atmNutSource to: " << fieldNames_[0] << endl;
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2020 ENERCON GmbH
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -79,9 +79,9 @@ Foam::fv::atmPlantCanopyTSource::atmPlantCanopyTSource
|
||||
mesh
|
||||
)
|
||||
{
|
||||
fieldNames_.setSize(1, "T");
|
||||
fieldNames_.resize(1, "T");
|
||||
|
||||
applied_.setSize(fieldNames_.size(), false);
|
||||
fv::option::resetApplied();
|
||||
|
||||
Log << " Applying atmPlantCanopyTSource to: " << fieldNames_[0] << endl;
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2020 ENERCON GmbH
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -108,7 +108,7 @@ Foam::fv::atmPlantCanopyTurbSource::atmPlantCanopyTurbSource
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
fieldNames_.setSize(1, "undefined");
|
||||
fieldNames_.resize(1);
|
||||
|
||||
tmp<volScalarField> tepsilon = turbPtr->epsilon();
|
||||
tmp<volScalarField> tomega = turbPtr->omega();
|
||||
@ -138,7 +138,7 @@ Foam::fv::atmPlantCanopyTurbSource::atmPlantCanopyTurbSource
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
applied_.setSize(fieldNames_.size(), false);
|
||||
fv::option::resetApplied();
|
||||
|
||||
Log << " Applying atmPlantCanopyTurbSource to: " << fieldNames_[0]
|
||||
<< endl;
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2020 ENERCON GmbH
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -78,9 +78,9 @@ Foam::fv::atmPlantCanopyUSource::atmPlantCanopyUSource
|
||||
mesh
|
||||
)
|
||||
{
|
||||
fieldNames_.setSize(1, "U");
|
||||
fieldNames_.resize(1, "U");
|
||||
|
||||
applied_.setSize(fieldNames_.size(), false);
|
||||
fv::option::resetApplied();
|
||||
|
||||
Log << " Applying atmPlantCanopyUSource to: " << fieldNames_[0] << endl;
|
||||
}
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -40,6 +40,15 @@ namespace Foam
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::fa::option::resetApplied()
|
||||
{
|
||||
applied_.resize(fieldNames_.size());
|
||||
applied_ = false;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::fa::option::option
|
||||
|
||||
@ -132,6 +132,13 @@ protected:
|
||||
//- Region name (finite-area)
|
||||
word regionName_;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Resize/reset applied flag list for all fieldNames_ entries
|
||||
void resetApplied();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// Private Data
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -38,33 +38,27 @@ namespace fa
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
const Foam::dictionary& Foam::fa::optionList::optionsDict
|
||||
(
|
||||
const dictionary& dict
|
||||
) const
|
||||
)
|
||||
{
|
||||
if (dict.found("options"))
|
||||
{
|
||||
return dict.subDict("options");
|
||||
}
|
||||
else
|
||||
{
|
||||
return dict;
|
||||
}
|
||||
return dict.optionalSubDict("options", keyType::LITERAL);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
bool Foam::fa::optionList::readOptions(const dictionary& dict)
|
||||
{
|
||||
checkTimeIndex_ = mesh_.time().timeIndex() + 2;
|
||||
|
||||
bool allOk = true;
|
||||
forAll(*this, i)
|
||||
for (fa::option& opt : *this)
|
||||
{
|
||||
option& bs = this->operator[](i);
|
||||
bool ok = bs.read(dict.subDict(bs.name()));
|
||||
bool ok = opt.read(dict.subDict(opt.name()));
|
||||
allOk = (allOk && ok);
|
||||
}
|
||||
return allOk;
|
||||
@ -75,10 +69,9 @@ void Foam::fa::optionList::checkApplied() const
|
||||
{
|
||||
if (mesh_.time().timeIndex() == checkTimeIndex_)
|
||||
{
|
||||
forAll(*this, i)
|
||||
for (const fa::option& opt : *this)
|
||||
{
|
||||
const option& bs = this->operator[](i);
|
||||
bs.checkApplied();
|
||||
opt.checkApplied();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -144,6 +137,22 @@ void Foam::fa::optionList::reset(const dictionary& dict)
|
||||
}
|
||||
|
||||
|
||||
bool Foam::fa::optionList::appliesToField(const word& fieldName) const
|
||||
{
|
||||
for (const fa::option& source : *this)
|
||||
{
|
||||
const label fieldi = source.applyToField(fieldName);
|
||||
|
||||
if (fieldi != -1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::fa::optionList::read(const dictionary& dict)
|
||||
{
|
||||
return readOptions(optionsDict(dict));
|
||||
@ -153,12 +162,12 @@ bool Foam::fa::optionList::read(const dictionary& dict)
|
||||
bool Foam::fa::optionList::writeData(Ostream& os) const
|
||||
{
|
||||
// Write list contents
|
||||
forAll(*this, i)
|
||||
for (const fa::option& opt : *this)
|
||||
{
|
||||
os << nl;
|
||||
this->operator[](i).writeHeader(os);
|
||||
this->operator[](i).writeData(os);
|
||||
this->operator[](i).writeFooter(os);
|
||||
opt.writeHeader(os);
|
||||
opt.writeData(os);
|
||||
opt.writeFooter(os);
|
||||
}
|
||||
|
||||
// Check state of IOstream
|
||||
|
||||
@ -83,8 +83,8 @@ protected:
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Return the "options" sub-dictionary if present otherwise return dict
|
||||
const dictionary& optionsDict(const dictionary& dict) const;
|
||||
//- Return "options" sub-dictionary (if present) or return dict
|
||||
static const dictionary& optionsDict(const dictionary& dict);
|
||||
|
||||
//- Read options dictionary
|
||||
bool readOptions(const dictionary& dict);
|
||||
@ -117,11 +117,11 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from patch
|
||||
optionList(const fvPatch& p);
|
||||
//- Default construct from patch
|
||||
explicit optionList(const fvPatch& p);
|
||||
|
||||
//- Construct from mesh and dictionary
|
||||
optionList(const fvPatch&, const dictionary& );
|
||||
//- Construct from patch and dictionary
|
||||
optionList(const fvPatch& p, const dictionary&);
|
||||
|
||||
|
||||
//- Destructor
|
||||
@ -133,6 +133,9 @@ public:
|
||||
//- Reset the source list
|
||||
void reset(const dictionary& dict);
|
||||
|
||||
//- Return whether there is something to apply to the field
|
||||
bool appliesToField(const word& fieldName) const;
|
||||
|
||||
|
||||
// Sources
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -44,11 +44,9 @@ Foam::tmp<Foam::faMatrix<Type>> Foam::fa::optionList::source
|
||||
tmp<faMatrix<Type>> tmtx(new faMatrix<Type>(field, ds));
|
||||
faMatrix<Type>& mtx = tmtx.ref();
|
||||
|
||||
forAll(*this, i)
|
||||
for (fa::option& source : *this)
|
||||
{
|
||||
option& source = this->operator[](i);
|
||||
|
||||
label fieldi = source.applyToField(fieldName);
|
||||
const label fieldi = source.applyToField(fieldName);
|
||||
|
||||
if (fieldi != -1)
|
||||
{
|
||||
@ -56,14 +54,24 @@ Foam::tmp<Foam::faMatrix<Type>> Foam::fa::optionList::source
|
||||
|
||||
source.setApplied(fieldi);
|
||||
|
||||
if (source.isActive())
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Applying source " << source.name() << " to field "
|
||||
<< fieldName << endl;
|
||||
}
|
||||
const bool ok = source.isActive();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
if (ok)
|
||||
{
|
||||
Info<< "Apply";
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "(Inactive)";
|
||||
}
|
||||
Info<< " source " << source.name()
|
||||
<< " for field " << fieldName << endl;
|
||||
}
|
||||
|
||||
if (ok)
|
||||
{
|
||||
source.addSup(h, mtx, fieldi);
|
||||
}
|
||||
}
|
||||
@ -127,11 +135,9 @@ Foam::tmp<Foam::faMatrix<Type>> Foam::fa::optionList::operator()
|
||||
tmp<faMatrix<Type>> tmtx(new faMatrix<Type>(field, ds));
|
||||
faMatrix<Type>& mtx = tmtx.ref();
|
||||
|
||||
forAll(*this, i)
|
||||
for (fa::option& source : *this)
|
||||
{
|
||||
option& source = this->operator[](i);
|
||||
|
||||
label fieldi = source.applyToField(fieldName);
|
||||
const label fieldi = source.applyToField(fieldName);
|
||||
|
||||
if (fieldi != -1)
|
||||
{
|
||||
@ -139,14 +145,24 @@ Foam::tmp<Foam::faMatrix<Type>> Foam::fa::optionList::operator()
|
||||
|
||||
source.setApplied(fieldi);
|
||||
|
||||
if (source.isActive())
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Applying source " << source.name() << " to field "
|
||||
<< fieldName << endl;
|
||||
}
|
||||
const bool ok = source.isActive();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
if (ok)
|
||||
{
|
||||
Info<< "Apply";
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "(Inactive)";
|
||||
}
|
||||
Info<< " source " << source.name()
|
||||
<< " for field " << fieldName << endl;
|
||||
}
|
||||
|
||||
if (ok)
|
||||
{
|
||||
source.addSup(h, rho, mtx, fieldi);
|
||||
}
|
||||
}
|
||||
@ -171,11 +187,9 @@ Foam::tmp<Foam::faMatrix<Type>> Foam::fa::optionList::operator()
|
||||
tmp<faMatrix<Type>> tmtx(new faMatrix<Type>(field, dsMat));
|
||||
faMatrix<Type>& mtx = tmtx.ref();
|
||||
|
||||
forAll(*this, i)
|
||||
for (fa::option& source : *this)
|
||||
{
|
||||
option& source = this->operator[](i);
|
||||
|
||||
label fieldi = source.applyToField(field.name());
|
||||
const label fieldi = source.applyToField(field.name());
|
||||
|
||||
if (fieldi != -1)
|
||||
{
|
||||
@ -183,14 +197,24 @@ Foam::tmp<Foam::faMatrix<Type>> Foam::fa::optionList::operator()
|
||||
|
||||
source.setApplied(fieldi);
|
||||
|
||||
if (source.isActive())
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Applying source " << source.name() << " to field "
|
||||
<< field.name() << endl;
|
||||
}
|
||||
const bool ok = source.isActive();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
if (ok)
|
||||
{
|
||||
Info<< "Apply";
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "(Inactive)";
|
||||
}
|
||||
Info<< " source " << source.name()
|
||||
<< " for field " << field.name() << endl;
|
||||
}
|
||||
|
||||
if (ok)
|
||||
{
|
||||
source.addSup(rho, mtx, fieldi);
|
||||
}
|
||||
}
|
||||
@ -226,11 +250,9 @@ void Foam::fa::optionList::constrain(faMatrix<Type>& eqn)
|
||||
{
|
||||
checkApplied();
|
||||
|
||||
forAll(*this, i)
|
||||
for (fa::option& source : *this)
|
||||
{
|
||||
option& source = this->operator[](i);
|
||||
|
||||
label fieldi = source.applyToField(eqn.psi().name());
|
||||
const label fieldi = source.applyToField(eqn.psi().name());
|
||||
|
||||
if (fieldi != -1)
|
||||
{
|
||||
@ -238,14 +260,24 @@ void Foam::fa::optionList::constrain(faMatrix<Type>& eqn)
|
||||
|
||||
source.setApplied(fieldi);
|
||||
|
||||
if (source.isActive())
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Applying constraint " << source.name()
|
||||
<< " to field " << eqn.psi().name() << endl;
|
||||
}
|
||||
const bool ok = source.isActive();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
if (ok)
|
||||
{
|
||||
Info<< "Constrain";
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "(Inactive constrain)";
|
||||
}
|
||||
Info<< " source " << source.name()
|
||||
<< " for field " << eqn.psi().name() << endl;
|
||||
}
|
||||
|
||||
if (ok)
|
||||
{
|
||||
source.constrain(eqn, fieldi);
|
||||
}
|
||||
}
|
||||
@ -261,11 +293,9 @@ void Foam::fa::optionList::correct
|
||||
{
|
||||
const word& fieldName = field.name();
|
||||
|
||||
forAll(*this, i)
|
||||
for (fa::option& source : *this)
|
||||
{
|
||||
option& source = this->operator[](i);
|
||||
|
||||
label fieldi = source.applyToField(fieldName);
|
||||
const label fieldi = source.applyToField(fieldName);
|
||||
|
||||
if (fieldi != -1)
|
||||
{
|
||||
@ -273,14 +303,24 @@ void Foam::fa::optionList::correct
|
||||
|
||||
source.setApplied(fieldi);
|
||||
|
||||
if (source.isActive())
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Correcting source " << source.name()
|
||||
<< " for field " << fieldName << endl;
|
||||
}
|
||||
const bool ok = source.isActive();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
if (ok)
|
||||
{
|
||||
Info<< "Correct";
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "(Inactive correct)";
|
||||
}
|
||||
Info<< " source " << source.name()
|
||||
<< " for field " << fieldName << endl;
|
||||
}
|
||||
|
||||
if (ok)
|
||||
{
|
||||
source.correct(field);
|
||||
}
|
||||
}
|
||||
|
||||
@ -204,7 +204,7 @@ Foam::fa::faceSetOption::faceSetOption
|
||||
|
||||
bool Foam::fa::faceSetOption::isActive()
|
||||
{
|
||||
if (option::isActive() && inTimeLimits(mesh_.time().value()))
|
||||
if (fa::option::isActive() && inTimeLimits(mesh_.time().value()))
|
||||
{
|
||||
// Update the face set if the mesh is changing
|
||||
if (mesh_.changing())
|
||||
@ -229,7 +229,7 @@ bool Foam::fa::faceSetOption::isActive()
|
||||
|
||||
bool Foam::fa::faceSetOption::read(const dictionary& dict)
|
||||
{
|
||||
if (option::read(dict))
|
||||
if (fa::option::read(dict))
|
||||
{
|
||||
if (coeffs_.readIfPresent("timeStart", timeStart_))
|
||||
{
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -78,9 +78,9 @@ Foam::fa::contactHeatFluxSource::contactHeatFluxSource
|
||||
contactRes_(0),
|
||||
curTimeIndex_(-1)
|
||||
{
|
||||
fieldNames_.setSize(1, TName_);
|
||||
fieldNames_.resize(1, TName_);
|
||||
|
||||
applied_.setSize(fieldNames_.size(), false);
|
||||
fa::option::resetApplied();
|
||||
|
||||
read(dict);
|
||||
}
|
||||
|
||||
@ -83,9 +83,9 @@ Foam::fa::externalFileSource::externalFileSource
|
||||
),
|
||||
curTimeIndex_(-1)
|
||||
{
|
||||
fieldNames_.setSize(1, fieldName_);
|
||||
fieldNames_.resize(1, fieldName_);
|
||||
|
||||
applied_.setSize(fieldNames_.size(), false);
|
||||
fa::option::resetApplied();
|
||||
|
||||
read(dict);
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -77,9 +77,9 @@ Foam::fa::externalHeatFluxSource::externalHeatFluxSource
|
||||
Ta_(),
|
||||
emissivity_(dict.getOrDefault<scalar>("emissivity", 0))
|
||||
{
|
||||
fieldNames_.setSize(1, TName_);
|
||||
fieldNames_.resize(1, TName_);
|
||||
|
||||
applied_.setSize(fieldNames_.size(), false);
|
||||
fa::option::resetApplied();
|
||||
|
||||
read(dict);
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -72,9 +72,9 @@ Foam::fa::jouleHeatingSource::jouleHeatingSource
|
||||
nIter_(1),
|
||||
anisotropicElectricalConductivity_(false)
|
||||
{
|
||||
fieldNames_.setSize(1, TName_);
|
||||
fieldNames_.resize(1, TName_);
|
||||
|
||||
applied_.setSize(fieldNames_.size(), false);
|
||||
fa::option::resetApplied();
|
||||
|
||||
if (anisotropicElectricalConductivity_)
|
||||
{
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2020 PCOpt/NTUA
|
||||
Copyright (C) 2020 FOSS GP
|
||||
-------------------------------------------------------------------------------
|
||||
@ -43,6 +43,15 @@ namespace Foam
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::fv::option::resetApplied()
|
||||
{
|
||||
applied_.resize(fieldNames_.size());
|
||||
applied_ = false;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::fv::option::option
|
||||
|
||||
@ -123,6 +123,12 @@ protected:
|
||||
bool active_;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Resize/reset applied flag list for all fieldNames_ entries
|
||||
void resetApplied();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Switch write log to Info
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
Copyright (C) 2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -39,33 +40,27 @@ namespace fv
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
const Foam::dictionary& Foam::fv::optionList::optionsDict
|
||||
(
|
||||
const dictionary& dict
|
||||
) const
|
||||
)
|
||||
{
|
||||
if (dict.found("options"))
|
||||
{
|
||||
return dict.subDict("options");
|
||||
}
|
||||
else
|
||||
{
|
||||
return dict;
|
||||
}
|
||||
return dict.optionalSubDict("options", keyType::LITERAL);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
bool Foam::fv::optionList::readOptions(const dictionary& dict)
|
||||
{
|
||||
checkTimeIndex_ = mesh_.time().timeIndex() + 2;
|
||||
|
||||
bool allOk = true;
|
||||
forAll(*this, i)
|
||||
for (fv::option& opt : *this)
|
||||
{
|
||||
option& bs = this->operator[](i);
|
||||
bool ok = bs.read(dict.subDict(bs.name()));
|
||||
bool ok = opt.read(dict.subDict(opt.name()));
|
||||
allOk = (allOk && ok);
|
||||
}
|
||||
return allOk;
|
||||
@ -76,10 +71,9 @@ void Foam::fv::optionList::checkApplied() const
|
||||
{
|
||||
if (mesh_.time().timeIndex() == checkTimeIndex_)
|
||||
{
|
||||
forAll(*this, i)
|
||||
for (const fv::option& opt : *this)
|
||||
{
|
||||
const option& bs = this->operator[](i);
|
||||
bs.checkApplied();
|
||||
opt.checkApplied();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -141,11 +135,9 @@ void Foam::fv::optionList::reset(const dictionary& dict)
|
||||
|
||||
bool Foam::fv::optionList::appliesToField(const word& fieldName) const
|
||||
{
|
||||
forAll(*this, i)
|
||||
for (const fv::option& source : *this)
|
||||
{
|
||||
const option& source = this->operator[](i);
|
||||
|
||||
label fieldi = source.applyToField(fieldName);
|
||||
const label fieldi = source.applyToField(fieldName);
|
||||
|
||||
if (fieldi != -1)
|
||||
{
|
||||
@ -166,12 +158,12 @@ bool Foam::fv::optionList::read(const dictionary& dict)
|
||||
bool Foam::fv::optionList::writeData(Ostream& os) const
|
||||
{
|
||||
// Write list contents
|
||||
forAll(*this, i)
|
||||
for (const fv::option& opt : *this)
|
||||
{
|
||||
os << nl;
|
||||
this->operator[](i).writeHeader(os);
|
||||
this->operator[](i).writeData(os);
|
||||
this->operator[](i).writeFooter(os);
|
||||
opt.writeHeader(os);
|
||||
opt.writeData(os);
|
||||
opt.writeFooter(os);
|
||||
}
|
||||
|
||||
// Check state of IOstream
|
||||
|
||||
@ -84,8 +84,8 @@ protected:
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Return the "options" sub-dictionary if present otherwise return dict
|
||||
const dictionary& optionsDict(const dictionary& dict) const;
|
||||
//- Return "options" sub-dictionary (if present) or return dict
|
||||
static const dictionary& optionsDict(const dictionary& dict);
|
||||
|
||||
//- Read options dictionary
|
||||
bool readOptions(const dictionary& dict);
|
||||
@ -117,8 +117,8 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
optionList(const fvMesh& mesh);
|
||||
//- Default construct from mesh
|
||||
explicit optionList(const fvMesh& mesh);
|
||||
|
||||
//- Construct from mesh and dictionary
|
||||
optionList(const fvMesh& mesh, const dictionary& dict);
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2016 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2020 PCOpt/NTUA
|
||||
Copyright (C) 2020 FOSS GP
|
||||
-------------------------------------------------------------------------------
|
||||
@ -45,11 +45,9 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::fv::optionList::source
|
||||
tmp<fvMatrix<Type>> tmtx(new fvMatrix<Type>(field, ds));
|
||||
fvMatrix<Type>& mtx = tmtx.ref();
|
||||
|
||||
forAll(*this, i)
|
||||
for (fv::option& source : *this)
|
||||
{
|
||||
option& source = this->operator[](i);
|
||||
|
||||
label fieldi = source.applyToField(fieldName);
|
||||
const label fieldi = source.applyToField(fieldName);
|
||||
|
||||
if (fieldi != -1)
|
||||
{
|
||||
@ -57,14 +55,24 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::fv::optionList::source
|
||||
|
||||
source.setApplied(fieldi);
|
||||
|
||||
if (source.isActive())
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Applying source " << source.name() << " to field "
|
||||
<< fieldName << endl;
|
||||
}
|
||||
const bool ok = source.isActive();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
if (ok)
|
||||
{
|
||||
Info<< "Apply";
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "(Inactive)";
|
||||
}
|
||||
Info<< " source " << source.name()
|
||||
<< " for field " << fieldName << endl;
|
||||
}
|
||||
|
||||
if (ok)
|
||||
{
|
||||
source.addSup(mtx, fieldi);
|
||||
}
|
||||
}
|
||||
@ -124,11 +132,9 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::fv::optionList::operator()
|
||||
tmp<fvMatrix<Type>> tmtx(new fvMatrix<Type>(field, ds));
|
||||
fvMatrix<Type>& mtx = tmtx.ref();
|
||||
|
||||
forAll(*this, i)
|
||||
for (fv::option& source : *this)
|
||||
{
|
||||
option& source = this->operator[](i);
|
||||
|
||||
label fieldi = source.applyToField(fieldName);
|
||||
const label fieldi = source.applyToField(fieldName);
|
||||
|
||||
if (fieldi != -1)
|
||||
{
|
||||
@ -136,14 +142,24 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::fv::optionList::operator()
|
||||
|
||||
source.setApplied(fieldi);
|
||||
|
||||
if (source.isActive())
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Applying source " << source.name() << " to field "
|
||||
<< fieldName << endl;
|
||||
}
|
||||
const bool ok = source.isActive();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
if (ok)
|
||||
{
|
||||
Info<< "Apply";
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "(Inactive)";
|
||||
}
|
||||
Info<< " source " << source.name()
|
||||
<< " for field " << fieldName << endl;
|
||||
}
|
||||
|
||||
if (ok)
|
||||
{
|
||||
source.addSup(rho, mtx, fieldi);
|
||||
}
|
||||
}
|
||||
@ -185,11 +201,9 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::fv::optionList::operator()
|
||||
tmp<fvMatrix<Type>> tmtx(new fvMatrix<Type>(field, ds));
|
||||
fvMatrix<Type>& mtx = tmtx.ref();
|
||||
|
||||
forAll(*this, i)
|
||||
for (fv::option& source : *this)
|
||||
{
|
||||
option& source = this->operator[](i);
|
||||
|
||||
label fieldi = source.applyToField(fieldName);
|
||||
const label fieldi = source.applyToField(fieldName);
|
||||
|
||||
if (fieldi != -1)
|
||||
{
|
||||
@ -197,14 +211,24 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::fv::optionList::operator()
|
||||
|
||||
source.setApplied(fieldi);
|
||||
|
||||
if (source.isActive())
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Applying source " << source.name() << " to field "
|
||||
<< fieldName << endl;
|
||||
}
|
||||
const bool ok = source.isActive();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
if (ok)
|
||||
{
|
||||
Info<< "Apply";
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "(Inactive)";
|
||||
}
|
||||
Info<< " source " << source.name()
|
||||
<< " for field " << fieldName << endl;
|
||||
}
|
||||
|
||||
if (ok)
|
||||
{
|
||||
source.addSup(alpha, rho, mtx, fieldi);
|
||||
}
|
||||
}
|
||||
@ -291,11 +315,9 @@ void Foam::fv::optionList::constrain(fvMatrix<Type>& eqn)
|
||||
{
|
||||
checkApplied();
|
||||
|
||||
forAll(*this, i)
|
||||
for (fv::option& source : *this)
|
||||
{
|
||||
option& source = this->operator[](i);
|
||||
|
||||
label fieldi = source.applyToField(eqn.psi().name());
|
||||
const label fieldi = source.applyToField(eqn.psi().name());
|
||||
|
||||
if (fieldi != -1)
|
||||
{
|
||||
@ -303,14 +325,24 @@ void Foam::fv::optionList::constrain(fvMatrix<Type>& eqn)
|
||||
|
||||
source.setApplied(fieldi);
|
||||
|
||||
if (source.isActive())
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Applying constraint " << source.name()
|
||||
<< " to field " << eqn.psi().name() << endl;
|
||||
}
|
||||
const bool ok = source.isActive();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
if (ok)
|
||||
{
|
||||
Info<< "Constrain";
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "(Inactive constrain)";
|
||||
}
|
||||
Info<< " source " << source.name()
|
||||
<< " for field " << eqn.psi().name() << endl;
|
||||
}
|
||||
|
||||
if (ok)
|
||||
{
|
||||
source.constrain(eqn, fieldi);
|
||||
}
|
||||
}
|
||||
@ -326,11 +358,9 @@ void Foam::fv::optionList::correct
|
||||
{
|
||||
const word& fieldName = field.name();
|
||||
|
||||
forAll(*this, i)
|
||||
for (fv::option& source : *this)
|
||||
{
|
||||
option& source = this->operator[](i);
|
||||
|
||||
label fieldi = source.applyToField(fieldName);
|
||||
const label fieldi = source.applyToField(fieldName);
|
||||
|
||||
if (fieldi != -1)
|
||||
{
|
||||
@ -338,14 +368,24 @@ void Foam::fv::optionList::correct
|
||||
|
||||
source.setApplied(fieldi);
|
||||
|
||||
if (source.isActive())
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Correcting source " << source.name()
|
||||
<< " for field " << fieldName << endl;
|
||||
}
|
||||
const bool ok = source.isActive();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
if (ok)
|
||||
{
|
||||
Info<< "Correct";
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "(Inactive correct)";
|
||||
}
|
||||
Info<< " source " << source.name()
|
||||
<< " for field " << fieldName << endl;
|
||||
}
|
||||
|
||||
if (ok)
|
||||
{
|
||||
source.correct(field);
|
||||
}
|
||||
}
|
||||
@ -361,25 +401,24 @@ void Foam::fv::optionList::postProcessSens
|
||||
const word& designVariablesName
|
||||
)
|
||||
{
|
||||
forAll(*this, i)
|
||||
for (fv::option& source : *this)
|
||||
{
|
||||
option& source = this->operator[](i);
|
||||
|
||||
label fieldi = source.applyToField(fieldName);
|
||||
const label fieldi = source.applyToField(fieldName);
|
||||
|
||||
if (fieldi != -1)
|
||||
{
|
||||
addProfiling(fvopt, "fvOption::postProcessSens." + source.name());
|
||||
|
||||
if (source.isActive())
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Post processing sensitivity from source "
|
||||
<< source.name()
|
||||
<< " for field " << fieldName << endl;
|
||||
}
|
||||
const bool ok = source.isActive();
|
||||
|
||||
if (debug && ok)
|
||||
{
|
||||
Info<< "Post processing sensitivity source "
|
||||
<< source.name() << " for field " << fieldName << endl;
|
||||
}
|
||||
|
||||
if (ok)
|
||||
{
|
||||
source.postProcessSens
|
||||
(
|
||||
sensField,
|
||||
|
||||
@ -60,6 +60,15 @@ void Foam::codedFixedValueFvPatchField<Type>::clearRedirect() const
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
const Foam::dictionary&
|
||||
Foam::codedFixedValueFvPatchField<Type>::codeContext() const
|
||||
{
|
||||
const dictionary* ptr = dict_.findDict("codeContext", keyType::LITERAL);
|
||||
return (ptr ? *ptr : dictionary::null);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
const Foam::dictionary&
|
||||
Foam::codedFixedValueFvPatchField<Type>::codeDict() const
|
||||
@ -124,7 +133,7 @@ Foam::codedFixedValueFvPatchField<Type>::codedFixedValueFvPatchField
|
||||
const DimensionedField<Type, volMesh>& iF
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchField<Type>(p, iF),
|
||||
parent_bctype(p, iF),
|
||||
codedBase(),
|
||||
redirectPatchFieldPtr_(nullptr)
|
||||
{}
|
||||
@ -133,17 +142,17 @@ Foam::codedFixedValueFvPatchField<Type>::codedFixedValueFvPatchField
|
||||
template<class Type>
|
||||
Foam::codedFixedValueFvPatchField<Type>::codedFixedValueFvPatchField
|
||||
(
|
||||
const codedFixedValueFvPatchField<Type>& ptf,
|
||||
const codedFixedValueFvPatchField<Type>& rhs,
|
||||
const fvPatch& p,
|
||||
const DimensionedField<Type, volMesh>& iF,
|
||||
const fvPatchFieldMapper& mapper
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchField<Type>(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 +164,7 @@ Foam::codedFixedValueFvPatchField<Type>::codedFixedValueFvPatchField
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchField<Type>(p, iF, dict),
|
||||
parent_bctype(p, iF, dict),
|
||||
codedBase(),
|
||||
dict_
|
||||
(
|
||||
@ -181,29 +190,29 @@ Foam::codedFixedValueFvPatchField<Type>::codedFixedValueFvPatchField
|
||||
template<class Type>
|
||||
Foam::codedFixedValueFvPatchField<Type>::codedFixedValueFvPatchField
|
||||
(
|
||||
const codedFixedValueFvPatchField<Type>& ptf
|
||||
const codedFixedValueFvPatchField<Type>& rhs
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchField<Type>(ptf),
|
||||
parent_bctype(rhs),
|
||||
codedBase(),
|
||||
dict_(ptf.dict_),
|
||||
name_(ptf.name_),
|
||||
redirectPatchFieldPtr_()
|
||||
dict_(rhs.dict_),
|
||||
name_(rhs.name_),
|
||||
redirectPatchFieldPtr_(nullptr)
|
||||
{}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::codedFixedValueFvPatchField<Type>::codedFixedValueFvPatchField
|
||||
(
|
||||
const codedFixedValueFvPatchField<Type>& ptf,
|
||||
const codedFixedValueFvPatchField<Type>& rhs,
|
||||
const DimensionedField<Type, volMesh>& iF
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchField<Type>(ptf, iF),
|
||||
parent_bctype(rhs, iF),
|
||||
codedBase(),
|
||||
dict_(ptf.dict_),
|
||||
name_(ptf.name_),
|
||||
redirectPatchFieldPtr_()
|
||||
dict_(rhs.dict_),
|
||||
name_(rhs.name_),
|
||||
redirectPatchFieldPtr_(nullptr)
|
||||
{}
|
||||
|
||||
|
||||
@ -219,10 +228,11 @@ Foam::codedFixedValueFvPatchField<Type>::redirectPatchField() const
|
||||
// Make sure to construct the patchfield with up-to-date value
|
||||
|
||||
OStringStream os;
|
||||
os.writeEntry("type", name_);
|
||||
static_cast<const Field<Type>&>(*this).writeEntry("value", os);
|
||||
IStringStream is(os.str());
|
||||
dictionary dict(is);
|
||||
dictionary constructDict(is);
|
||||
|
||||
constructDict.set("type", name_);
|
||||
|
||||
redirectPatchFieldPtr_.reset
|
||||
(
|
||||
@ -230,9 +240,25 @@ Foam::codedFixedValueFvPatchField<Type>::redirectPatchField() const
|
||||
(
|
||||
this->patch(),
|
||||
this->internalField(),
|
||||
dict
|
||||
constructDict
|
||||
).ptr()
|
||||
);
|
||||
|
||||
|
||||
// Forward copy of codeContext to the code template
|
||||
auto* contentPtr =
|
||||
dynamic_cast<dictionaryContent*>(redirectPatchFieldPtr_.get());
|
||||
|
||||
if (contentPtr)
|
||||
{
|
||||
contentPtr->dict(this->codeContext());
|
||||
}
|
||||
else
|
||||
{
|
||||
WarningInFunction
|
||||
<< name_ << " Did not derive from dictionaryContent"
|
||||
<< nl << nl;
|
||||
}
|
||||
}
|
||||
return *redirectPatchFieldPtr_;
|
||||
}
|
||||
@ -256,7 +282,7 @@ void Foam::codedFixedValueFvPatchField<Type>::updateCoeffs()
|
||||
// Copy through value
|
||||
this->operator==(fvp);
|
||||
|
||||
fixedValueFvPatchField<Type>::updateCoeffs();
|
||||
parent_bctype::updateCoeffs();
|
||||
}
|
||||
|
||||
|
||||
@ -273,14 +299,14 @@ void Foam::codedFixedValueFvPatchField<Type>::evaluate
|
||||
|
||||
const_cast<fvPatchField<Type>&>(fvp).evaluate(commsType);
|
||||
|
||||
fixedValueFvPatchField<Type>::evaluate(commsType);
|
||||
parent_bctype::evaluate(commsType);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::codedFixedValueFvPatchField<Type>::write(Ostream& os) const
|
||||
{
|
||||
fixedValueFvPatchField<Type>::write(os);
|
||||
this->parent_bctype::write(os);
|
||||
os.writeEntry("name", name_);
|
||||
|
||||
codedBase::writeCodeDict(os, dict_);
|
||||
|
||||
@ -34,6 +34,16 @@ 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
|
||||
codeContext | additional dictionary context for the code
|
||||
\endplaintable
|
||||
|
||||
Usage
|
||||
Example:
|
||||
\verbatim
|
||||
@ -43,6 +53,11 @@ Usage
|
||||
value uniform 0;
|
||||
name rampedFixedValue; // name of generated BC
|
||||
|
||||
codeContext
|
||||
{
|
||||
...
|
||||
}
|
||||
|
||||
code
|
||||
#{
|
||||
operator==(min(10, 0.1*this->db().time().value()));
|
||||
@ -74,6 +89,10 @@ Usage
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
Note
|
||||
The code context dictionary can be supplied separately as the
|
||||
\c codeContext entry.
|
||||
|
||||
See also
|
||||
Foam::dynamicCode
|
||||
Foam::functionEntries::codeStream
|
||||
@ -104,6 +123,10 @@ class codedFixedValueFvPatchField
|
||||
public fixedValueFvPatchField<Type>,
|
||||
protected codedBase
|
||||
{
|
||||
//- The parent boundary condition type
|
||||
typedef fixedValueFvPatchField<Type> parent_bctype;
|
||||
|
||||
|
||||
// Private Data
|
||||
|
||||
//- Dictionary contents for the boundary condition
|
||||
@ -125,6 +148,9 @@ class codedFixedValueFvPatchField
|
||||
//- Clear redirected object(s)
|
||||
virtual void clearRedirect() const;
|
||||
|
||||
//- Additional 'codeContext' dictionary to pass through
|
||||
virtual const dictionary& codeContext() const;
|
||||
|
||||
//- The code dictionary. Inline "code" or from system/codeDict
|
||||
virtual const dictionary& codeDict() const;
|
||||
|
||||
|
||||
@ -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.
|
||||
@ -60,6 +60,15 @@ void Foam::codedMixedFvPatchField<Type>::clearRedirect() const
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
const Foam::dictionary&
|
||||
Foam::codedMixedFvPatchField<Type>::codeContext() const
|
||||
{
|
||||
const dictionary* ptr = dict_.findDict("codeContext", keyType::LITERAL);
|
||||
return (ptr ? *ptr : dictionary::null);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
const Foam::dictionary&
|
||||
Foam::codedMixedFvPatchField<Type>::codeDict() const
|
||||
@ -124,7 +133,7 @@ Foam::codedMixedFvPatchField<Type>::codedMixedFvPatchField
|
||||
const DimensionedField<Type, volMesh>& iF
|
||||
)
|
||||
:
|
||||
mixedFvPatchField<Type>(p, iF),
|
||||
parent_bctype(p, iF),
|
||||
codedBase(),
|
||||
redirectPatchFieldPtr_(nullptr)
|
||||
{}
|
||||
@ -133,17 +142,17 @@ Foam::codedMixedFvPatchField<Type>::codedMixedFvPatchField
|
||||
template<class Type>
|
||||
Foam::codedMixedFvPatchField<Type>::codedMixedFvPatchField
|
||||
(
|
||||
const codedMixedFvPatchField<Type>& ptf,
|
||||
const codedMixedFvPatchField<Type>& rhs,
|
||||
const fvPatch& p,
|
||||
const DimensionedField<Type, volMesh>& iF,
|
||||
const fvPatchFieldMapper& mapper
|
||||
)
|
||||
:
|
||||
mixedFvPatchField<Type>(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 +164,7 @@ Foam::codedMixedFvPatchField<Type>::codedMixedFvPatchField
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
mixedFvPatchField<Type>(p, iF, dict),
|
||||
parent_bctype(p, iF, dict),
|
||||
codedBase(),
|
||||
dict_
|
||||
(
|
||||
@ -181,29 +190,29 @@ Foam::codedMixedFvPatchField<Type>::codedMixedFvPatchField
|
||||
template<class Type>
|
||||
Foam::codedMixedFvPatchField<Type>::codedMixedFvPatchField
|
||||
(
|
||||
const codedMixedFvPatchField<Type>& ptf
|
||||
const codedMixedFvPatchField<Type>& rhs
|
||||
)
|
||||
:
|
||||
mixedFvPatchField<Type>(ptf),
|
||||
parent_bctype(rhs),
|
||||
codedBase(),
|
||||
dict_(ptf.dict_),
|
||||
name_(ptf.name_),
|
||||
redirectPatchFieldPtr_()
|
||||
dict_(rhs.dict_),
|
||||
name_(rhs.name_),
|
||||
redirectPatchFieldPtr_(nullptr)
|
||||
{}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::codedMixedFvPatchField<Type>::codedMixedFvPatchField
|
||||
(
|
||||
const codedMixedFvPatchField<Type>& ptf,
|
||||
const codedMixedFvPatchField<Type>& rhs,
|
||||
const DimensionedField<Type, volMesh>& iF
|
||||
)
|
||||
:
|
||||
mixedFvPatchField<Type>(ptf, iF),
|
||||
parent_bctype(rhs, iF),
|
||||
codedBase(),
|
||||
dict_(ptf.dict_),
|
||||
name_(ptf.name_),
|
||||
redirectPatchFieldPtr_()
|
||||
dict_(rhs.dict_),
|
||||
name_(rhs.name_),
|
||||
redirectPatchFieldPtr_(nullptr)
|
||||
{}
|
||||
|
||||
|
||||
@ -220,27 +229,41 @@ Foam::codedMixedFvPatchField<Type>::redirectPatchField() const
|
||||
|
||||
// Write the data from the mixed b.c.
|
||||
OStringStream os;
|
||||
mixedFvPatchField<Type>::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<mixedFvPatchField<Type>*>
|
||||
dynamic_cast<parent_bctype*>
|
||||
(
|
||||
fvPatchField<Type>::New
|
||||
(
|
||||
this->patch(),
|
||||
this->internalField(),
|
||||
dict
|
||||
constructDict
|
||||
).ptr()
|
||||
)
|
||||
);
|
||||
|
||||
// Forward copy of dictionary content to the code template
|
||||
auto* contentPtr =
|
||||
dynamic_cast<dictionaryContent*>(redirectPatchFieldPtr_.get());
|
||||
|
||||
if (contentPtr)
|
||||
{
|
||||
contentPtr->dict(this->codeContext());
|
||||
}
|
||||
else
|
||||
{
|
||||
WarningInFunction
|
||||
<< name_ << " Did not derive from dictionaryContent"
|
||||
<< nl << nl;
|
||||
}
|
||||
}
|
||||
return *redirectPatchFieldPtr_;
|
||||
}
|
||||
@ -257,16 +280,15 @@ void Foam::codedMixedFvPatchField<Type>::updateCoeffs()
|
||||
// Make sure library containing user-defined fvPatchField is up-to-date
|
||||
updateLibrary(name_);
|
||||
|
||||
const mixedFvPatchField<Type>& fvp = redirectPatchField();
|
||||
|
||||
const_cast<mixedFvPatchField<Type>&>(fvp).updateCoeffs();
|
||||
const parent_bctype& fvp = redirectPatchField();
|
||||
const_cast<parent_bctype&>(fvp).updateCoeffs();
|
||||
|
||||
// Copy through coefficients
|
||||
this->refValue() = fvp.refValue();
|
||||
this->refGrad() = fvp.refGrad();
|
||||
this->valueFraction() = fvp.valueFraction();
|
||||
|
||||
mixedFvPatchField<Type>::updateCoeffs();
|
||||
this->parent_bctype::updateCoeffs();
|
||||
}
|
||||
|
||||
|
||||
@ -279,21 +301,21 @@ void Foam::codedMixedFvPatchField<Type>::evaluate
|
||||
// Make sure library containing user-defined fvPatchField is up-to-date
|
||||
updateLibrary(name_);
|
||||
|
||||
const mixedFvPatchField<Type>& fvp = redirectPatchField();
|
||||
const parent_bctype& fvp = redirectPatchField();
|
||||
|
||||
// - updates the value of fvp (though not used)
|
||||
// - 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
|
||||
mixedFvPatchField<Type>::evaluate(commsType);
|
||||
parent_bctype::evaluate(commsType);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::codedMixedFvPatchField<Type>::write(Ostream& os) const
|
||||
{
|
||||
mixedFvPatchField<Type>::write(os);
|
||||
this->parent_bctype::write(os);
|
||||
os.writeEntry("name", name_);
|
||||
|
||||
codedBase::writeCodeDict(os, dict_);
|
||||
|
||||
@ -31,8 +31,18 @@ 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
|
||||
codeContext | additional dictionary context for the code
|
||||
\endplaintable
|
||||
|
||||
Usage
|
||||
Example:
|
||||
@ -84,6 +94,10 @@ Usage
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
Note
|
||||
The code context dictionary can be supplied separately as the
|
||||
\c codeContext entry.
|
||||
|
||||
See also
|
||||
Foam::dynamicCode
|
||||
Foam::functionEntries::codeStream
|
||||
@ -114,6 +128,10 @@ class codedMixedFvPatchField
|
||||
public mixedFvPatchField<Type>,
|
||||
public codedBase
|
||||
{
|
||||
//- The parent boundary condition type
|
||||
typedef mixedFvPatchField<Type> parent_bctype;
|
||||
|
||||
|
||||
// Private Data
|
||||
|
||||
//- Dictionary contents for the boundary condition
|
||||
@ -137,6 +155,9 @@ protected:
|
||||
//- Clear redirected object(s)
|
||||
virtual void clearRedirect() const;
|
||||
|
||||
//- Additional 'codeContext' dictionary to pass through
|
||||
virtual const dictionary& codeContext() const;
|
||||
|
||||
//- The code dictionary. Inline "code" or from system/codeDict
|
||||
virtual const dictionary& codeDict() const;
|
||||
|
||||
|
||||
@ -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 * * * * * * * * * * * //
|
||||
@ -71,6 +72,14 @@ void Foam::functionObjects::codedFunctionObject::clearRedirect() const
|
||||
}
|
||||
|
||||
|
||||
const Foam::dictionary&
|
||||
Foam::functionObjects::codedFunctionObject::codeContext() const
|
||||
{
|
||||
const dictionary* ptr = dict_.findDict("codeContext", keyType::LITERAL);
|
||||
return (ptr ? *ptr : dictionary::null);
|
||||
}
|
||||
|
||||
|
||||
const Foam::dictionary&
|
||||
Foam::functionObjects::codedFunctionObject::codeDict() const
|
||||
{
|
||||
@ -156,6 +165,22 @@ Foam::functionObjects::codedFunctionObject::redirectFunctionObject() const
|
||||
time_,
|
||||
constructDict
|
||||
);
|
||||
|
||||
|
||||
// Forward copy of codeContext to the code template
|
||||
auto* contentPtr =
|
||||
dynamic_cast<dictionaryContent*>(redirectFunctionObjectPtr_.get());
|
||||
|
||||
if (contentPtr)
|
||||
{
|
||||
contentPtr->dict(this->codeContext());
|
||||
}
|
||||
else
|
||||
{
|
||||
WarningInFunction
|
||||
<< name_ << " Did not derive from dictionaryContent"
|
||||
<< nl << nl;
|
||||
}
|
||||
}
|
||||
return *redirectFunctionObjectPtr_;
|
||||
}
|
||||
|
||||
@ -36,14 +36,15 @@ 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()
|
||||
codeContext | additional dictionary context for the code
|
||||
\endplaintable
|
||||
|
||||
Usage
|
||||
@ -67,6 +68,10 @@ Usage
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
Note
|
||||
The code context dictionary can be supplied separately as the
|
||||
\c codeContext entry.
|
||||
|
||||
See also
|
||||
Foam::functionObject
|
||||
Foam::codedBase
|
||||
@ -128,6 +133,9 @@ protected:
|
||||
//- Clear redirected object(s)
|
||||
virtual void clearRedirect() const;
|
||||
|
||||
//- Additional 'codeContext' dictionary to pass through
|
||||
virtual const dictionary& codeContext() const;
|
||||
|
||||
//- The code dictionary
|
||||
virtual const dictionary& codeDict() const;
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@ interRegionOption/interRegionOption.C
|
||||
/* Sources */
|
||||
|
||||
generalSources=sources/general
|
||||
$(generalSources)/codedSource/codedSource.C
|
||||
$(generalSources)/codedSource/codedFvSources.C
|
||||
$(generalSources)/semiImplicitSource/semiImplicitSource.C
|
||||
|
||||
derivedSources=sources/derived
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2012-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -101,9 +101,9 @@ Foam::fv::fixedTemperatureConstraint::fixedTemperatureConstraint
|
||||
|
||||
const auto& thermo = mesh_.lookupObject<basicThermo>(basicThermo::dictName);
|
||||
|
||||
fieldNames_.setSize(1, thermo.he().name());
|
||||
fieldNames_.resize(1, thermo.he().name());
|
||||
|
||||
applied_.setSize(1, false);
|
||||
fv::option::resetApplied();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2015 OpenFOAM Foundation
|
||||
Copyright (C) 2015 OpenCFD Ltd.
|
||||
Copyright (C) 2015-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -132,7 +132,7 @@ bool Foam::fv::velocityDampingConstraint::read(const dictionary& dict)
|
||||
fieldNames_.first() = coeffs_.getOrDefault<word>("U", "U");
|
||||
}
|
||||
|
||||
applied_.setSize(fieldNames_.size(), false);
|
||||
fv::option::resetApplied();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016 OpenFOAM Foundation
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -59,9 +59,10 @@ bool Foam::fv::FixedValueConstraint<Type>::read(const dictionary& dict)
|
||||
|
||||
label count = fieldValuesDict.size();
|
||||
|
||||
fieldNames_.setSize(count);
|
||||
fieldValues_.setSize(count);
|
||||
applied_.setSize(count, false);
|
||||
fieldNames_.resize(count);
|
||||
fieldValues_.resize(count);
|
||||
|
||||
fv::option::resetApplied();
|
||||
|
||||
count = 0;
|
||||
for (const entry& dEntry : fieldValuesDict)
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2012-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2018-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -66,9 +66,9 @@ Foam::fv::limitTemperature::limitTemperature
|
||||
IOobject::groupName(basicThermo::dictName, phase_)
|
||||
);
|
||||
|
||||
fieldNames_.setSize(1, thermo.he().name());
|
||||
fieldNames_.resize(1, thermo.he().name());
|
||||
|
||||
applied_.setSize(1, false);
|
||||
fv::option::resetApplied();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2018-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -56,8 +56,8 @@ Foam::fv::limitVelocity::limitVelocity
|
||||
UName_(coeffs_.getOrDefault<word>("U", "U")),
|
||||
max_(coeffs_.get<scalar>("max"))
|
||||
{
|
||||
fieldNames_.setSize(1, UName_);
|
||||
applied_.setSize(1, false);
|
||||
fieldNames_.resize(1, UName_);
|
||||
fv::option::resetApplied();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -182,7 +182,7 @@ bool Foam::fv::acousticDampingSource::read(const dictionary& dict)
|
||||
fieldNames_.first() = coeffs_.getOrDefault<word>("U", "U");
|
||||
}
|
||||
|
||||
applied_.setSize(fieldNames_.size(), false);
|
||||
fv::option::resetApplied();
|
||||
|
||||
coeffs_.readEntry("frequency", frequency_.value());
|
||||
coeffs_.readEntry("URef", URefName_);
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2020 ENERCON GmbH
|
||||
Copyright (C) 2018-2020 OpenCFD Ltd
|
||||
Copyright (C) 2018-2021 OpenCFD Ltd
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -219,9 +219,9 @@ Foam::fv::actuationDiskSource::actuationDiskSource
|
||||
{
|
||||
setMonitorCells(coeffs_);
|
||||
|
||||
fieldNames_.setSize(1, "U");
|
||||
fieldNames_.resize(1, "U");
|
||||
|
||||
applied_.setSize(fieldNames_.size(), false);
|
||||
fv::option::resetApplied();
|
||||
|
||||
Info<< " - creating actuation disk zone: " << this->name() << endl;
|
||||
|
||||
|
||||
@ -64,7 +64,7 @@ Foam::fv::buoyancyEnergy::buoyancyEnergy
|
||||
<< "settings are:" << fieldNames_ << exit(FatalError);
|
||||
}
|
||||
|
||||
applied_.setSize(fieldNames_.size(), false);
|
||||
fv::option::resetApplied();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2015-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2018-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -64,7 +64,7 @@ Foam::fv::buoyancyForce::buoyancyForce
|
||||
<< "settings are:" << fieldNames_ << exit(FatalError);
|
||||
}
|
||||
|
||||
applied_.setSize(fieldNames_.size(), false);
|
||||
fv::option::resetApplied();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -178,7 +178,7 @@ Foam::fv::buoyancyTurbSource::buoyancyTurbSource
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
fieldNames_.setSize(2, "undefined");
|
||||
fieldNames_.resize(2);
|
||||
|
||||
tmp<volScalarField> tepsilon = turbPtr->epsilon();
|
||||
tmp<volScalarField> tomega = turbPtr->omega();
|
||||
@ -202,7 +202,8 @@ Foam::fv::buoyancyTurbSource::buoyancyTurbSource
|
||||
}
|
||||
|
||||
fieldNames_[1] = turbPtr->k()().name();
|
||||
applied_.setSize(fieldNames_.size(), false);
|
||||
|
||||
fv::option::resetApplied();
|
||||
|
||||
Log << " Applying buoyancyTurbSource to: "
|
||||
<< fieldNames_[0] << " and " << fieldNames_[1]
|
||||
|
||||
@ -223,7 +223,7 @@ directionalPressureGradientExplicitSource
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
applied_.setSize(fieldNames_.size(), false);
|
||||
fv::option::resetApplied();
|
||||
|
||||
// Read the initial pressure gradient from file if it exists
|
||||
IFstream propsFile
|
||||
|
||||
@ -160,9 +160,9 @@ Foam::fv::effectivenessHeatExchangerSource::effectivenessHeatExchangerSource
|
||||
|
||||
const auto& thermo = mesh_.lookupObject<basicThermo>(basicThermo::dictName);
|
||||
|
||||
fieldNames_.setSize(1, thermo.he().name());
|
||||
fieldNames_.resize(1, thermo.he().name());
|
||||
|
||||
applied_.setSize(1, false);
|
||||
fv::option::resetApplied();
|
||||
|
||||
eTable_.reset(new interpolation2DTable<scalar>(coeffs_));
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2012-2018 OpenFOAM Foundation
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -123,7 +123,7 @@ bool Foam::fv::explicitPorositySource::read(const dictionary& dict)
|
||||
fieldNames_.first() = coeffs_.getOrDefault<word>("U", "U");
|
||||
}
|
||||
|
||||
applied_.setSize(fieldNames_.size(), false);
|
||||
fv::option::resetApplied();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -134,9 +134,9 @@ Foam::fv::jouleHeatingSource::jouleHeatingSource
|
||||
|
||||
const auto& thermo = mesh_.lookupObject<basicThermo>(basicThermo::dictName);
|
||||
|
||||
fieldNames_.setSize(1, thermo.he().name());
|
||||
fieldNames_.resize(1, thermo.he().name());
|
||||
|
||||
applied_.setSize(fieldNames_.size(), false);
|
||||
fv::option::resetApplied();
|
||||
|
||||
read(dict);
|
||||
}
|
||||
|
||||
@ -98,7 +98,7 @@ Foam::fv::meanVelocityForce::meanVelocityForce
|
||||
<< "settings are:" << fieldNames_ << exit(FatalError);
|
||||
}
|
||||
|
||||
applied_.setSize(fieldNames_.size(), false);
|
||||
fv::option::resetApplied();
|
||||
|
||||
// Read the initial pressure gradient from file if it exists
|
||||
IFstream propsFile
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -96,7 +96,7 @@ Foam::fv::multiphaseStabilizedTurbulence::multiphaseStabilizedTurbulence
|
||||
)
|
||||
)
|
||||
{
|
||||
fieldNames_.setSize(2, "undefined");
|
||||
fieldNames_.resize(2);
|
||||
|
||||
// Note: incompressible only
|
||||
const auto* turbPtr =
|
||||
@ -123,7 +123,7 @@ Foam::fv::multiphaseStabilizedTurbulence::multiphaseStabilizedTurbulence
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
applied_.setSize(fieldNames_.size(), false);
|
||||
fv::option::resetApplied();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017 OpenFOAM Foundation
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -47,8 +47,8 @@ Foam::fv::PhaseLimitStabilization<Type>::PhaseLimitStabilization
|
||||
rateName_(coeffs_.get<word>("rate")),
|
||||
residualAlpha_(coeffs_.get<scalar>("residualAlpha"))
|
||||
{
|
||||
fieldNames_.setSize(1, fieldName_);
|
||||
applied_.setSize(1, false);
|
||||
fieldNames_.resize(1, fieldName_);
|
||||
fv::option::resetApplied();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2018-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -548,7 +548,7 @@ bool Foam::fv::rotorDiskSource::read(const dictionary& dict)
|
||||
if (cellSetOption::read(dict))
|
||||
{
|
||||
coeffs_.readEntry("fields", fieldNames_);
|
||||
applied_.setSize(fieldNames_.size(), false);
|
||||
fv::option::resetApplied();
|
||||
|
||||
// Read coordinate system/geometry invariant properties
|
||||
omega_ = rpmToRads(coeffs_.get<scalar>("rpm"));
|
||||
|
||||
@ -192,7 +192,7 @@ Foam::fv::solidificationMeltingSource::solidificationMeltingSource
|
||||
curTimeIndex_(-1),
|
||||
deltaT_(cells_.size(), 0)
|
||||
{
|
||||
fieldNames_.setSize(2);
|
||||
fieldNames_.resize(2);
|
||||
fieldNames_[0] = UName_;
|
||||
|
||||
switch (mode_)
|
||||
@ -218,7 +218,7 @@ Foam::fv::solidificationMeltingSource::solidificationMeltingSource
|
||||
}
|
||||
}
|
||||
|
||||
applied_.setSize(fieldNames_.size(), false);
|
||||
fv::option::resetApplied();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2015-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -59,8 +59,8 @@ Foam::fv::tabulatedAccelerationSource::tabulatedAccelerationSource
|
||||
UName_(coeffs_.getOrDefault<word>("U", "U")),
|
||||
g0_("g0", dimAcceleration, Zero)
|
||||
{
|
||||
fieldNames_.setSize(1, UName_);
|
||||
applied_.setSize(1, false);
|
||||
fieldNames_.resize(1, UName_);
|
||||
fv::option::resetApplied();
|
||||
|
||||
if (mesh.time().foundObject<uniformDimensionedVectorField>("g"))
|
||||
{
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -106,7 +106,7 @@ Foam::fv::viscousDissipation::viscousDissipation
|
||||
|
||||
if (thermoPtr)
|
||||
{
|
||||
fieldNames_.setSize(1, thermoPtr->he().name());
|
||||
fieldNames_.resize(1, thermoPtr->he().name());
|
||||
}
|
||||
|
||||
if (fieldNames_.empty())
|
||||
@ -120,7 +120,7 @@ Foam::fv::viscousDissipation::viscousDissipation
|
||||
<< "settings are:" << fieldNames_ << exit(FatalError);
|
||||
}
|
||||
|
||||
applied_.setSize(fieldNames_.size(), false);
|
||||
fv::option::resetApplied();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -26,7 +26,7 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "CodedSource.H"
|
||||
#include "CodedFvSource.H"
|
||||
#include "fvMesh.H"
|
||||
#include "fvMatrices.H"
|
||||
#include "dynamicCode.H"
|
||||
@ -52,7 +52,7 @@ Foam::string Foam::fv::CodedSource<Type>::description() const
|
||||
template<class Type>
|
||||
void Foam::fv::CodedSource<Type>::clearRedirect() const
|
||||
{
|
||||
redirectFvOptionPtr_.reset(nullptr);
|
||||
redirectOptionPtr_.reset(nullptr);
|
||||
}
|
||||
|
||||
|
||||
@ -124,7 +124,7 @@ Foam::fv::CodedSource<Type>::CodedSource
|
||||
const fvMesh& mesh
|
||||
)
|
||||
:
|
||||
cellSetOption(name, modelType, dict, mesh)
|
||||
fv::cellSetOption(name, modelType, dict, mesh)
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
@ -133,22 +133,62 @@ Foam::fv::CodedSource<Type>::CodedSource
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::fv::option& Foam::fv::CodedSource<Type>::redirectFvOption() const
|
||||
bool Foam::fv::CodedSource<Type>::read(const dictionary& dict)
|
||||
{
|
||||
if (!redirectFvOptionPtr_)
|
||||
codedBase::setCodeContext(coeffs_);
|
||||
|
||||
if (!fv::cellSetOption::read(dict))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
coeffs_.readEntry("fields", fieldNames_);
|
||||
|
||||
fv::option::resetApplied();
|
||||
|
||||
dict.readCompat<word>("name", {{"redirectType", 1706}}, name_);
|
||||
|
||||
|
||||
// Code context chunks
|
||||
|
||||
auto& ctx = codedBase::codeContext();
|
||||
|
||||
ctx.readEntry("codeCorrect", codeCorrect_);
|
||||
ctx.readEntry("codeAddSup", codeAddSup_);
|
||||
|
||||
// ctx.readEntry("codeConstrain", codeConstrain_);
|
||||
ctx.readEntry // Compatibility
|
||||
(
|
||||
coeffs_.lookupEntryCompat
|
||||
(
|
||||
"codeConstrain",
|
||||
{{ "codeSetValue", 1812 }},
|
||||
keyType::LITERAL
|
||||
).keyword(),
|
||||
codeConstrain_
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::fv::option& Foam::fv::CodedSource<Type>::redirectOption() const
|
||||
{
|
||||
if (!redirectOptionPtr_)
|
||||
{
|
||||
dictionary constructDict(dict_);
|
||||
constructDict.set("type", name_);
|
||||
constructDict.changeKeyword(modelType_ & "Coeffs", name_ & "Coeffs");
|
||||
|
||||
redirectFvOptionPtr_ = fv::option::New
|
||||
redirectOptionPtr_ = fv::option::New
|
||||
(
|
||||
name_,
|
||||
constructDict,
|
||||
mesh_
|
||||
);
|
||||
}
|
||||
return *redirectFvOptionPtr_;
|
||||
return *redirectOptionPtr_;
|
||||
}
|
||||
|
||||
|
||||
@ -159,11 +199,11 @@ void Foam::fv::CodedSource<Type>::correct
|
||||
)
|
||||
{
|
||||
DebugInfo
|
||||
<< "CodedSource<" << pTraits<Type>::typeName
|
||||
<< "fv::CodedSource<" << pTraits<Type>::typeName
|
||||
<< ">::correct for source " << name_ << endl;
|
||||
|
||||
updateLibrary(name_);
|
||||
redirectFvOption().correct(field);
|
||||
redirectOption().correct(field);
|
||||
}
|
||||
|
||||
|
||||
@ -175,11 +215,11 @@ void Foam::fv::CodedSource<Type>::addSup
|
||||
)
|
||||
{
|
||||
DebugInfo
|
||||
<< "CodedSource<" << pTraits<Type>::typeName
|
||||
<< "fv::CodedSource<" << pTraits<Type>::typeName
|
||||
<< ">::addSup for source " << name_ << endl;
|
||||
|
||||
updateLibrary(name_);
|
||||
redirectFvOption().addSup(eqn, fieldi);
|
||||
redirectOption().addSup(eqn, fieldi);
|
||||
}
|
||||
|
||||
|
||||
@ -192,11 +232,11 @@ void Foam::fv::CodedSource<Type>::addSup
|
||||
)
|
||||
{
|
||||
DebugInfo
|
||||
<< "CodedSource<" << pTraits<Type>::typeName
|
||||
<< "fv::CodedSource<" << pTraits<Type>::typeName
|
||||
<< ">::addSup for source " << name_ << endl;
|
||||
|
||||
updateLibrary(name_);
|
||||
redirectFvOption().addSup(rho, eqn, fieldi);
|
||||
redirectOption().addSup(rho, eqn, fieldi);
|
||||
}
|
||||
|
||||
|
||||
@ -208,11 +248,11 @@ void Foam::fv::CodedSource<Type>::constrain
|
||||
)
|
||||
{
|
||||
DebugInfo
|
||||
<< "CodedSource<" << pTraits<Type>::typeName
|
||||
<< "fv::CodedSource<" << pTraits<Type>::typeName
|
||||
<< ">::constrain for source " << name_ << endl;
|
||||
|
||||
updateLibrary(name_);
|
||||
redirectFvOption().constrain(eqn, fieldi);
|
||||
redirectOption().constrain(eqn, fieldi);
|
||||
}
|
||||
|
||||
|
||||
@ -58,6 +58,14 @@ Description
|
||||
field is the name of the field in the fields list
|
||||
eqn is the fvMatrix
|
||||
|
||||
These are in addition to the usual 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
|
||||
\endplaintable
|
||||
|
||||
Usage
|
||||
Example usage in controlDict:
|
||||
\verbatim
|
||||
@ -89,7 +97,7 @@ Usage
|
||||
heSource -= 0.1*sqr(time.value())*V;
|
||||
#};
|
||||
|
||||
codeContrain
|
||||
codeConstrain
|
||||
#{
|
||||
Pout<< "**codeConstrain**" << endl;
|
||||
#};
|
||||
@ -97,14 +105,13 @@ Usage
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
|
||||
SourceFiles
|
||||
codedSource.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef CodedSource_H
|
||||
#define CodedSource_H
|
||||
#ifndef fv_CodedFvSource_H
|
||||
#define fv_CodedFvSource_H
|
||||
|
||||
#include "cellSetOption.H"
|
||||
#include "codedBase.H"
|
||||
@ -137,7 +144,7 @@ protected:
|
||||
string codeConstrain_;
|
||||
|
||||
//- Underlying code
|
||||
mutable autoPtr<fv::option> redirectFvOptionPtr_;
|
||||
mutable autoPtr<fv::option> redirectOptionPtr_;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
@ -190,7 +197,7 @@ public:
|
||||
// Member Functions
|
||||
|
||||
//- Dynamically compiled fvOption
|
||||
option& redirectFvOption() const;
|
||||
fv::option& redirectOption() const;
|
||||
|
||||
|
||||
// Evaluation
|
||||
@ -239,8 +246,7 @@ public:
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "CodedSource.C"
|
||||
#include "CodedSourceIO.C"
|
||||
#include "CodedFvSource.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -1,72 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2012-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "CodedSource.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
bool Foam::fv::CodedSource<Type>::read(const dictionary& dict)
|
||||
{
|
||||
codedBase::setCodeContext(coeffs_);
|
||||
|
||||
if (!cellSetOption::read(dict))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
coeffs_.readEntry("fields", fieldNames_);
|
||||
applied_.resize(fieldNames_.size(), false);
|
||||
|
||||
dict.readCompat<word>("name", {{"redirectType", 1706}}, name_);
|
||||
|
||||
|
||||
// Code context chunks
|
||||
|
||||
auto& ctx = codedBase::codeContext();
|
||||
|
||||
ctx.readEntry("codeCorrect", codeCorrect_);
|
||||
ctx.readEntry("codeAddSup", codeAddSup_);
|
||||
|
||||
// ctx.readEntry("codeConstrain", codeConstrain_);
|
||||
ctx.readEntry // Compatibility
|
||||
(
|
||||
coeffs_.lookupEntryCompat
|
||||
(
|
||||
"codeConstrain",
|
||||
{{ "codeSetValue", 1812 }},
|
||||
keyType::LITERAL
|
||||
).keyword(),
|
||||
codeConstrain_
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -26,7 +26,7 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "makeFvOption.H"
|
||||
#include "CodedSource.H"
|
||||
#include "CodedFvSource.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -54,10 +54,10 @@ void Foam::fv::SemiImplicitSource<Type>::setFieldData(const dictionary& dict)
|
||||
label count = dict.size();
|
||||
|
||||
fieldNames_.resize(count);
|
||||
Su_.resize(count);
|
||||
Sp_.resize(count);
|
||||
Su_.resize(fieldNames_.size());
|
||||
Sp_.resize(fieldNames_.size());
|
||||
|
||||
applied_.resize(count, false);
|
||||
fv::option::resetApplied();
|
||||
|
||||
count = 0;
|
||||
for (const entry& dEntry : dict)
|
||||
|
||||
@ -126,8 +126,8 @@ Foam::fv::interRegionExplicitPorositySource::interRegionExplicitPorositySource
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
fieldNames_.setSize(1, UName_);
|
||||
applied_.setSize(1, false);
|
||||
fieldNames_.resize(1, UName_);
|
||||
fv::option::resetApplied();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -147,9 +147,8 @@ Foam::fv::interRegionHeatTransferModel::interRegionHeatTransferModel
|
||||
if (active())
|
||||
{
|
||||
coeffs_.readEntry("fields", fieldNames_);
|
||||
applied_.setSize(fieldNames_.size(), false);
|
||||
|
||||
coeffs_.readEntry("semiImplicit", semiImplicit_);
|
||||
fv::option::resetApplied();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -27,6 +27,7 @@ License
|
||||
|
||||
#include "dynamicCode.H"
|
||||
#include "dynamicCodeContext.H"
|
||||
#include "dictionaryContent.H"
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
@ -53,6 +54,15 @@ void Foam::PatchFunction1Types::CodedField<Type>::clearRedirect() const
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
const Foam::dictionary&
|
||||
Foam::PatchFunction1Types::CodedField<Type>::codeContext() const
|
||||
{
|
||||
// What else would make sense?
|
||||
return dict_;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
const Foam::dictionary&
|
||||
Foam::PatchFunction1Types::CodedField<Type>::codeDict
|
||||
@ -147,6 +157,10 @@ Foam::PatchFunction1Types::CodedField<Type>::CodedField
|
||||
dict_(dict),
|
||||
name_(dict.getOrDefault<word>("name", entryName))
|
||||
{
|
||||
this->codedBase::setCodeContext(dict_);
|
||||
|
||||
// No additional code chunks...
|
||||
|
||||
updateLibrary(name_);
|
||||
}
|
||||
|
||||
@ -183,15 +197,13 @@ Foam::PatchFunction1Types::CodedField<Type>::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,10 +211,25 @@ Foam::PatchFunction1Types::CodedField<Type>::redirectFunction() const
|
||||
(
|
||||
this->patch(),
|
||||
name_,
|
||||
dict,
|
||||
constructDict,
|
||||
this->faceValues()
|
||||
)
|
||||
);
|
||||
|
||||
// Forward copy of codeContext to the code template
|
||||
auto* contentPtr =
|
||||
dynamic_cast<dictionaryContent*>(redirectFunctionPtr_.get());
|
||||
|
||||
if (contentPtr)
|
||||
{
|
||||
contentPtr->dict(this->codeContext());
|
||||
}
|
||||
else
|
||||
{
|
||||
WarningInFunction
|
||||
<< name_ << " Did not derive from dictionaryContent"
|
||||
<< nl << nl;
|
||||
}
|
||||
}
|
||||
return *redirectFunctionPtr_;
|
||||
}
|
||||
|
||||
@ -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,20 +56,24 @@ Usage
|
||||
Pout<< "** Patch size:" << pp.size() << endl;
|
||||
return tmp<vectorField>::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
|
||||
|
||||
Note
|
||||
The code context dictionary is simply the dictionary used to specify
|
||||
the PatchFunction1 coefficients.
|
||||
|
||||
See also
|
||||
Foam::dynamicCode
|
||||
Foam::codedFixedValue
|
||||
@ -126,6 +136,9 @@ protected:
|
||||
//- Clear redirected object(s)
|
||||
virtual void clearRedirect() const;
|
||||
|
||||
//- Additional 'codeContext' dictionary to pass through
|
||||
virtual const dictionary& codeContext() const;
|
||||
|
||||
// Get the code (sub)dictionary
|
||||
virtual const dictionary& codeDict(const dictionary& dict) const;
|
||||
|
||||
|
||||
@ -57,9 +57,9 @@ Foam::fv::radiation::radiation
|
||||
{
|
||||
const auto& thermo = mesh_.lookupObject<basicThermo>(basicThermo::dictName);
|
||||
|
||||
fieldNames_.setSize(1);
|
||||
fieldNames_.resize(1);
|
||||
fieldNames_[0] = thermo.he().name();
|
||||
applied_.setSize(fieldNames_.size(), false);
|
||||
fv::option::resetApplied();
|
||||
|
||||
radiation_ = Foam::radiation::radiationModel::New(thermo.T());
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017 IH-Cantabria
|
||||
Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -213,8 +213,7 @@ bool Foam::fv::multiphaseMangrovesSource::read(const dictionary& dict)
|
||||
fieldNames_.resize(1);
|
||||
fieldNames_.first() = coeffs_.getOrDefault<word>("U", "U");
|
||||
}
|
||||
|
||||
applied_.setSize(fieldNames_.size(), false);
|
||||
fv::option::resetApplied();
|
||||
|
||||
// Create the Mangroves models - 1 per region
|
||||
const dictionary& regionsDict(coeffs_.subDict("regions"));
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017 IH-Cantabria
|
||||
Copyright (C) 2017-2018 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -243,8 +243,7 @@ bool Foam::fv::multiphaseMangrovesTurbulenceModel::read(const dictionary& dict)
|
||||
fieldNames_[1] = "k";
|
||||
}
|
||||
}
|
||||
|
||||
applied_.setSize(fieldNames_.size(), false);
|
||||
fv::option::resetApplied();
|
||||
|
||||
// Create the Mangroves models - 1 per region
|
||||
const dictionary& regionsDict(coeffs_.subDict("regions"));
|
||||
|
||||
@ -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<volScalarField>("rho");
|
||||
|
||||
Info<< "rho volume = " << rho.weightedAverage(mesh().Vsc()) << endl;
|
||||
|
||||
#};
|
||||
}
|
||||
}
|
||||
|
||||
@ -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<volScalarField>("rho");
|
||||
|
||||
|
||||
@ -51,4 +51,9 @@ maxCo 1;
|
||||
|
||||
maxDeltaT 1;
|
||||
|
||||
functions
|
||||
{
|
||||
#include "relVelocity"
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -0,0 +1,118 @@
|
||||
// --------------------------------*- C++ -*-------------------------------- //
|
||||
//
|
||||
// File
|
||||
// OpenFOAM coded function object
|
||||
//
|
||||
// Description
|
||||
// Write relative rotational speed
|
||||
//
|
||||
// ------------------------------------------------------------------------- //
|
||||
|
||||
relVelocity
|
||||
{
|
||||
type coded;
|
||||
name relVelocity;
|
||||
libs ( utilityFunctionObjects );
|
||||
|
||||
coeffs
|
||||
{
|
||||
// User input (duplicate of constant/dynamicMeshDict)
|
||||
// origin (-3 2 2.6);
|
||||
// axis (0 0 1);
|
||||
// omega 10;
|
||||
// zones ( rotatingZone );
|
||||
|
||||
#sinclude "<constant>/dynamicMeshDict"
|
||||
}
|
||||
|
||||
// Additional context for code execute/write
|
||||
codeContext
|
||||
{
|
||||
verbose true;
|
||||
}
|
||||
|
||||
codeData
|
||||
#{
|
||||
vector origin;
|
||||
vector omega;
|
||||
wordRes zoneNames;
|
||||
#};
|
||||
|
||||
codeRead
|
||||
#{
|
||||
const dictionary& coeffs = dict.optionalSubDict("coeffs");
|
||||
const dictionary& context = this->codeContext();
|
||||
|
||||
origin = coeffs.get<vector>("origin");
|
||||
|
||||
omega =
|
||||
(
|
||||
// speed
|
||||
(
|
||||
coeffs.found("rpm")
|
||||
? degToRad(coeffs.get<scalar>("rpm") / 60.0)
|
||||
: coeffs.get<scalar>("omega")
|
||||
)
|
||||
// axis
|
||||
* normalised(coeffs.getOrDefault<vector>("axis", vector(0,0,1)))
|
||||
);
|
||||
|
||||
if (!coeffs.readIfPresent("zones", zoneNames))
|
||||
{
|
||||
if (coeffs.found("cellZone"))
|
||||
{
|
||||
zoneNames.resize(1);
|
||||
coeffs.readEntry("cellZone", zoneNames[0]);
|
||||
}
|
||||
}
|
||||
|
||||
if (context.getOrDefault<bool>("verbose", false))
|
||||
{
|
||||
Log<< "Relative velocity at origin " << origin << "\n";
|
||||
}
|
||||
#};
|
||||
|
||||
codeExecute // codeWrite
|
||||
#{
|
||||
const dictionary& context = this->codeContext();
|
||||
|
||||
if (context.getOrDefault<bool>("verbose", false))
|
||||
{
|
||||
Log<< "Calculate relative velocity\n";
|
||||
}
|
||||
|
||||
const auto& cc = mesh().C();
|
||||
const auto& U = mesh().lookupObject<volVectorField>("U");
|
||||
|
||||
auto trelVel = volVectorField::New
|
||||
(
|
||||
"relVelocity",
|
||||
mesh(),
|
||||
dimensionedVector(dimVelocity, Zero),
|
||||
"zeroGradient"
|
||||
);
|
||||
auto& relVel = trelVel.ref();
|
||||
auto& relVelField = relVel.primitiveFieldRef();
|
||||
|
||||
if (zoneNames.empty())
|
||||
{
|
||||
for (label celli = 0; celli < mesh().nCells(); ++celli)
|
||||
{
|
||||
relVelField[celli] = U[celli] - (omega ^ (cc[celli] - origin));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (const label celli : mesh().cellZones().selection(zoneNames))
|
||||
{
|
||||
relVelField[celli] = U[celli] - (omega ^ (cc[celli] - origin));
|
||||
}
|
||||
}
|
||||
|
||||
relVel.correctBoundaryConditions();
|
||||
relVel.write();
|
||||
#};
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,14 +1,14 @@
|
||||
/*--------------------------------*- 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 | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
FoamFile
|
||||
{
|
||||
version 2.0;
|
||||
format binary;
|
||||
format ascii;
|
||||
class volVectorField;
|
||||
object U;
|
||||
}
|
||||
@ -25,13 +25,82 @@ boundaryField
|
||||
type uniformFixedValue;
|
||||
value $internalField;
|
||||
|
||||
uniformValue table
|
||||
(
|
||||
(0 (0 0 0.1))
|
||||
(1 (0 0 0.1))
|
||||
(4 (0 0 0.3))
|
||||
(14 (0 0 0.5))
|
||||
);
|
||||
uniformValue
|
||||
{
|
||||
type coded;
|
||||
name examplePatchFunction1;
|
||||
|
||||
// Example code to combine/adapt Function1 to PatchFunction1
|
||||
|
||||
// User inputs
|
||||
|
||||
/// verbose true;
|
||||
|
||||
timeFunction
|
||||
{
|
||||
type table;
|
||||
|
||||
values
|
||||
(
|
||||
(0 0.1)
|
||||
(1 0.1)
|
||||
(4 0.3)
|
||||
(14 0.5)
|
||||
);
|
||||
}
|
||||
|
||||
// ... or a function of time
|
||||
directionFunction (0 0 1);
|
||||
|
||||
// Code implementation.
|
||||
code
|
||||
#{
|
||||
// Persistent (Member) Data
|
||||
static autoPtr<Function1<scalar>> baseVel;
|
||||
static autoPtr<Function1<vector>> baseDir;
|
||||
|
||||
// Base settings
|
||||
const dictionary& dict = this->dictionaryContent::dict();
|
||||
|
||||
const polyPatch& pp = this->patch();
|
||||
|
||||
vector velDir(0, 0, 1);
|
||||
|
||||
if (!baseVel)
|
||||
{
|
||||
baseVel = Function1<scalar>::New("timeFunction", dict);
|
||||
}
|
||||
|
||||
const bool verbose = dict.getOrDefault<bool>("verbose", false);
|
||||
|
||||
if (!baseDir && dict.found("directionFunction"))
|
||||
{
|
||||
// ie, NewIfPresent
|
||||
baseDir = Function1<vector>::New("directionFunction", dict);
|
||||
|
||||
InfoErr
|
||||
<< "Function1 for direction" << nl;
|
||||
}
|
||||
|
||||
if (baseDir)
|
||||
{
|
||||
velDir = normalised(baseDir->value(x));
|
||||
}
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
InfoErr
|
||||
<< "vel: " << baseVel->value(x)
|
||||
<< " dir:" << velDir << nl;
|
||||
}
|
||||
|
||||
return tmp<vectorField>::New
|
||||
(
|
||||
pp.size(),
|
||||
baseVel->value(x) * velDir
|
||||
);
|
||||
#};
|
||||
}
|
||||
}
|
||||
|
||||
outlet
|
||||
|
||||
@ -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 =
|
||||
|
||||
Reference in New Issue
Block a user