codedMixedFvPatchField, codedFixedValuePointPatchField: Updated and simplified using the new CodedBase class
reducing code duplication and maintenance overhead.
This commit is contained in:
@ -103,7 +103,7 @@ public:
|
|||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
//- Name of the dynamically generated CodedType
|
//- Name of the dynamically generated CodedType
|
||||||
const word& codeName() const;
|
virtual const word& codeName() const;
|
||||||
|
|
||||||
//- Get the dictionary to initialize the codeContext
|
//- Get the dictionary to initialize the codeContext
|
||||||
virtual const dictionary& codeDict() const;
|
virtual const dictionary& codeDict() const;
|
||||||
|
|||||||
@ -280,12 +280,10 @@ void Foam::codedBase::createLibrary
|
|||||||
|
|
||||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::codedBase::updateLibrary
|
void Foam::codedBase::updateLibrary() const
|
||||||
(
|
|
||||||
const word& name
|
|
||||||
) const
|
|
||||||
{
|
{
|
||||||
const dictionary& dict = this->codeDict();
|
const word& name = codeName();
|
||||||
|
const dictionary& dict = codeDict();
|
||||||
|
|
||||||
dynamicCode::checkSecurity
|
dynamicCode::checkSecurity
|
||||||
(
|
(
|
||||||
|
|||||||
@ -86,23 +86,26 @@ class codedBase
|
|||||||
protected:
|
protected:
|
||||||
|
|
||||||
//- Update library as required
|
//- Update library as required
|
||||||
void updateLibrary(const word& name) const;
|
void updateLibrary() const;
|
||||||
|
|
||||||
//- Adapt the context for the current object
|
//- Name of the dynamically generated CodedType
|
||||||
virtual void prepare(dynamicCode&, const dynamicCodeContext&) const = 0;
|
virtual const word& codeName() const = 0;
|
||||||
|
|
||||||
//- Return a description (type + name) for the output
|
//- Return a description (type + name) for the output
|
||||||
virtual string description() const = 0;
|
virtual string description() const = 0;
|
||||||
|
|
||||||
//- Clear any redirected objects
|
|
||||||
virtual void clearRedirect() const = 0;
|
|
||||||
|
|
||||||
//- Get the dictionary to initialize the codeContext
|
//- Get the dictionary to initialize the codeContext
|
||||||
virtual const dictionary& codeDict() const = 0;
|
virtual const dictionary& codeDict() const = 0;
|
||||||
|
|
||||||
//- Get the keywords associated with source code
|
//- Get the keywords associated with source code
|
||||||
virtual const wordList& codeKeys() const = 0;
|
virtual const wordList& codeKeys() const = 0;
|
||||||
|
|
||||||
|
//- Adapt the context for the current object
|
||||||
|
virtual void prepare(dynamicCode&, const dynamicCodeContext&) const = 0;
|
||||||
|
|
||||||
|
//- Clear any redirected objects
|
||||||
|
virtual void clearRedirect() const = 0;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|||||||
@ -29,77 +29,9 @@ License
|
|||||||
#include "pointFields.H"
|
#include "pointFields.H"
|
||||||
#include "dynamicCode.H"
|
#include "dynamicCode.H"
|
||||||
#include "dynamicCodeContext.H"
|
#include "dynamicCodeContext.H"
|
||||||
#include "stringOps.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * Private Static Data Members * * * * * * * * * * * //
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
const Foam::wordList Foam::codedFixedValuePointPatchField<Type>::codeKeys_ =
|
|
||||||
{"code", "codeInclude", "localCode"};
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
const Foam::word Foam::codedFixedValuePointPatchField<Type>::codeTemplateC =
|
|
||||||
"fixedValuePointPatchFieldTemplate.C";
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
const Foam::word Foam::codedFixedValuePointPatchField<Type>::codeTemplateH =
|
|
||||||
"fixedValuePointPatchFieldTemplate.H";
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
void Foam::codedFixedValuePointPatchField<Type>::setFieldTemplates
|
|
||||||
(
|
|
||||||
dynamicCode& dynCode
|
|
||||||
)
|
|
||||||
{
|
|
||||||
word fieldType(pTraits<Type>::typeName);
|
|
||||||
|
|
||||||
// Template type for pointPatchField
|
|
||||||
dynCode.setFilterVariable("TemplateType", fieldType);
|
|
||||||
|
|
||||||
// Name for pointPatchField - eg, ScalarField, VectorField, ...
|
|
||||||
fieldType[0] = toupper(fieldType[0]);
|
|
||||||
dynCode.setFilterVariable("FieldType", fieldType + "Field");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
const Foam::IOdictionary& Foam::codedFixedValuePointPatchField<Type>::dict()
|
|
||||||
const
|
|
||||||
{
|
|
||||||
const objectRegistry& obr = this->db();
|
|
||||||
|
|
||||||
if (obr.foundObject<IOdictionary>("codeDict"))
|
|
||||||
{
|
|
||||||
return obr.lookupObject<IOdictionary>("codeDict");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return obr.store
|
|
||||||
(
|
|
||||||
new IOdictionary
|
|
||||||
(
|
|
||||||
IOobject
|
|
||||||
(
|
|
||||||
"codeDict",
|
|
||||||
this->db().time().system(),
|
|
||||||
this->db(),
|
|
||||||
IOobject::MUST_READ_IF_MODIFIED,
|
|
||||||
IOobject::NO_WRITE
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void Foam::codedFixedValuePointPatchField<Type>::prepare
|
void Foam::codedFixedValuePointPatchField<Type>::prepare
|
||||||
(
|
(
|
||||||
@ -107,12 +39,19 @@ void Foam::codedFixedValuePointPatchField<Type>::prepare
|
|||||||
const dynamicCodeContext& context
|
const dynamicCodeContext& context
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
// Take no chances - typeName must be identical to name_
|
// Take no chances - typeName must be identical to codeName()
|
||||||
dynCode.setFilterVariable("typeName", name_);
|
dynCode.setFilterVariable("typeName", codeName());
|
||||||
|
|
||||||
// Set TemplateType and FieldType filter variables
|
// Set TemplateType and FieldType filter variables
|
||||||
// (for pointPatchField)
|
// (for pointPatchField)
|
||||||
setFieldTemplates(dynCode);
|
word fieldType(pTraits<Type>::typeName);
|
||||||
|
|
||||||
|
// Template type for pointPatchField
|
||||||
|
dynCode.setFilterVariable("TemplateType", fieldType);
|
||||||
|
|
||||||
|
// Name for pointPatchField - eg, ScalarField, VectorField, ...
|
||||||
|
fieldType[0] = toupper(fieldType[0]);
|
||||||
|
dynCode.setFilterVariable("FieldType", fieldType + "Field");
|
||||||
|
|
||||||
// Compile filtered C template
|
// Compile filtered C template
|
||||||
dynCode.addCompileFile(codeTemplateC);
|
dynCode.addCompileFile(codeTemplateC);
|
||||||
@ -120,59 +59,29 @@ void Foam::codedFixedValuePointPatchField<Type>::prepare
|
|||||||
// Copy filtered H template
|
// Copy filtered H template
|
||||||
dynCode.addCopyFile(codeTemplateH);
|
dynCode.addCopyFile(codeTemplateH);
|
||||||
|
|
||||||
|
|
||||||
// Debugging: make BC verbose
|
// Debugging: make BC verbose
|
||||||
// dynCode.setFilterVariable("verbose", "true");
|
if (debug)
|
||||||
// Info<<"compile " << name_ << " sha1: "
|
{
|
||||||
// << context.sha1() << endl;
|
// Debugging: make BC verbose
|
||||||
|
dynCode.setFilterVariable("verbose", "true");
|
||||||
|
Info<<"compile " << codeName() << " sha1: "
|
||||||
|
<< context.sha1() << endl;
|
||||||
|
}
|
||||||
|
|
||||||
// Define Make/options
|
// Define Make/options
|
||||||
dynCode.setMakeOptions
|
dynCode.setMakeOptions
|
||||||
(
|
|
||||||
"EXE_INC = -g \\\n"
|
|
||||||
"-I$(LIB_SRC)/finiteVolume/lnInclude \\\n"
|
|
||||||
+ context.options()
|
|
||||||
+ "\n\nLIB_LIBS = \\\n"
|
|
||||||
+ " -lOpenFOAM \\\n"
|
|
||||||
+ " -lfiniteVolume \\\n"
|
|
||||||
+ context.libs()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
const Foam::dictionary&
|
|
||||||
Foam::codedFixedValuePointPatchField<Type>::codeDict() const
|
|
||||||
{
|
|
||||||
// Use system/codeDict or in-line
|
|
||||||
return
|
|
||||||
(
|
(
|
||||||
dict_.found("code")
|
"EXE_INC = -g \\\n"
|
||||||
? dict_
|
"-I$(LIB_SRC)/finiteVolume/lnInclude \\\n"
|
||||||
: this->dict().subDict(name_)
|
+ context.options()
|
||||||
|
+ "\n\nLIB_LIBS = \\\n"
|
||||||
|
+ " -lOpenFOAM \\\n"
|
||||||
|
+ " -lfiniteVolume \\\n"
|
||||||
|
+ context.libs()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
const Foam::wordList&
|
|
||||||
Foam::codedFixedValuePointPatchField<Type>::codeKeys() const
|
|
||||||
{
|
|
||||||
return codeKeys_;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
Foam::string Foam::codedFixedValuePointPatchField<Type>::description() const
|
|
||||||
{
|
|
||||||
return
|
|
||||||
"patch "
|
|
||||||
+ this->patch().name()
|
|
||||||
+ " on field "
|
|
||||||
+ this->internalField().name();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void Foam::codedFixedValuePointPatchField<Type>::clearRedirect() const
|
void Foam::codedFixedValuePointPatchField<Type>::clearRedirect() const
|
||||||
{
|
{
|
||||||
@ -191,7 +100,7 @@ Foam::codedFixedValuePointPatchField<Type>::codedFixedValuePointPatchField
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
fixedValuePointPatchField<Type>(p, iF),
|
fixedValuePointPatchField<Type>(p, iF),
|
||||||
codedBase(),
|
CodedBase<codedFixedValuePointPatchFieldBase>(),
|
||||||
redirectPatchFieldPtr_()
|
redirectPatchFieldPtr_()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -206,9 +115,7 @@ Foam::codedFixedValuePointPatchField<Type>::codedFixedValuePointPatchField
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
fixedValuePointPatchField<Type>(ptf, p, iF, mapper),
|
fixedValuePointPatchField<Type>(ptf, p, iF, mapper),
|
||||||
codedBase(),
|
CodedBase<codedFixedValuePointPatchFieldBase>(ptf),
|
||||||
dict_(ptf.dict_),
|
|
||||||
name_(ptf.name_),
|
|
||||||
redirectPatchFieldPtr_()
|
redirectPatchFieldPtr_()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -222,17 +129,10 @@ Foam::codedFixedValuePointPatchField<Type>::codedFixedValuePointPatchField
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
fixedValuePointPatchField<Type>(p, iF, dict),
|
fixedValuePointPatchField<Type>(p, iF, dict),
|
||||||
codedBase(),
|
CodedBase<codedFixedValuePointPatchFieldBase>(dict),
|
||||||
dict_(dict),
|
|
||||||
name_
|
|
||||||
(
|
|
||||||
dict.found("redirectType")
|
|
||||||
? dict.lookup("redirectType")
|
|
||||||
: dict.lookup("name")
|
|
||||||
),
|
|
||||||
redirectPatchFieldPtr_()
|
redirectPatchFieldPtr_()
|
||||||
{
|
{
|
||||||
updateLibrary(name_);
|
updateLibrary();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -243,9 +143,7 @@ Foam::codedFixedValuePointPatchField<Type>::codedFixedValuePointPatchField
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
fixedValuePointPatchField<Type>(ptf),
|
fixedValuePointPatchField<Type>(ptf),
|
||||||
codedBase(),
|
CodedBase<codedFixedValuePointPatchFieldBase>(ptf),
|
||||||
dict_(ptf.dict_),
|
|
||||||
name_(ptf.name_),
|
|
||||||
redirectPatchFieldPtr_()
|
redirectPatchFieldPtr_()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -258,9 +156,7 @@ Foam::codedFixedValuePointPatchField<Type>::codedFixedValuePointPatchField
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
fixedValuePointPatchField<Type>(ptf, iF),
|
fixedValuePointPatchField<Type>(ptf, iF),
|
||||||
codedBase(),
|
CodedBase<codedFixedValuePointPatchFieldBase>(ptf),
|
||||||
dict_(ptf.dict_),
|
|
||||||
name_(ptf.name_),
|
|
||||||
redirectPatchFieldPtr_()
|
redirectPatchFieldPtr_()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -273,11 +169,8 @@ Foam::codedFixedValuePointPatchField<Type>::redirectPatchField() const
|
|||||||
{
|
{
|
||||||
if (!redirectPatchFieldPtr_.valid())
|
if (!redirectPatchFieldPtr_.valid())
|
||||||
{
|
{
|
||||||
// Construct a patch
|
|
||||||
// Make sure to construct the patchfield with up-to-date value
|
|
||||||
|
|
||||||
OStringStream os;
|
OStringStream os;
|
||||||
writeEntry(os, "type", name_);
|
writeEntry(os, "type", codeName());
|
||||||
writeEntry(os, "value", static_cast<const Field<Type>&>(*this));
|
writeEntry(os, "value", static_cast<const Field<Type>&>(*this));
|
||||||
IStringStream is(os.str());
|
IStringStream is(os.str());
|
||||||
dictionary dict(is);
|
dictionary dict(is);
|
||||||
@ -292,6 +185,7 @@ Foam::codedFixedValuePointPatchField<Type>::redirectPatchField() const
|
|||||||
).ptr()
|
).ptr()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirectPatchFieldPtr_();
|
return redirectPatchFieldPtr_();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -305,7 +199,7 @@ void Foam::codedFixedValuePointPatchField<Type>::updateCoeffs()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Make sure library containing user-defined pointPatchField is up-to-date
|
// Make sure library containing user-defined pointPatchField is up-to-date
|
||||||
updateLibrary(name_);
|
updateLibrary();
|
||||||
|
|
||||||
const pointPatchField<Type>& fvp = redirectPatchField();
|
const pointPatchField<Type>& fvp = redirectPatchField();
|
||||||
|
|
||||||
@ -325,7 +219,7 @@ void Foam::codedFixedValuePointPatchField<Type>::evaluate
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Make sure library containing user-defined pointPatchField is up-to-date
|
// Make sure library containing user-defined pointPatchField is up-to-date
|
||||||
updateLibrary(name_);
|
updateLibrary();
|
||||||
|
|
||||||
const pointPatchField<Type>& fvp = redirectPatchField();
|
const pointPatchField<Type>& fvp = redirectPatchField();
|
||||||
|
|
||||||
@ -339,42 +233,7 @@ template<class Type>
|
|||||||
void Foam::codedFixedValuePointPatchField<Type>::write(Ostream& os) const
|
void Foam::codedFixedValuePointPatchField<Type>::write(Ostream& os) const
|
||||||
{
|
{
|
||||||
fixedValuePointPatchField<Type>::write(os);
|
fixedValuePointPatchField<Type>::write(os);
|
||||||
writeEntry(os, "name", name_);
|
writeCode(os);
|
||||||
|
|
||||||
if (dict_.found("codeInclude"))
|
|
||||||
{
|
|
||||||
writeKeyword(os, "codeInclude");
|
|
||||||
os.write(verbatimString(dict_["codeInclude"]))
|
|
||||||
<< token::END_STATEMENT << nl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dict_.found("localCode"))
|
|
||||||
{
|
|
||||||
writeKeyword(os, "localCode");
|
|
||||||
os.write(verbatimString(dict_["localCode"]))
|
|
||||||
<< token::END_STATEMENT << nl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dict_.found("code"))
|
|
||||||
{
|
|
||||||
writeKeyword(os, "code");
|
|
||||||
os.write(verbatimString(dict_["code"]))
|
|
||||||
<< token::END_STATEMENT << nl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dict_.found("codeOptions"))
|
|
||||||
{
|
|
||||||
writeKeyword(os, "codeOptions");
|
|
||||||
os.write(verbatimString(dict_["codeOptions"]))
|
|
||||||
<< token::END_STATEMENT << nl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dict_.found("codeLibs"))
|
|
||||||
{
|
|
||||||
writeKeyword(os, "codeLibs");
|
|
||||||
os.write(verbatimString(dict_["codeLibs"]))
|
|
||||||
<< token::END_STATEMENT << nl;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -83,15 +83,24 @@ SourceFiles
|
|||||||
#define codedFixedValuePointPatchField_H
|
#define codedFixedValuePointPatchField_H
|
||||||
|
|
||||||
#include "fixedValuePointPatchFields.H"
|
#include "fixedValuePointPatchFields.H"
|
||||||
#include "codedBase.H"
|
#include "CodedBase.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
// Forward declaration of classes
|
/*---------------------------------------------------------------------------*\
|
||||||
class IOdictionary;
|
Class codedFixedValueFvPatchFieldBase Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class codedFixedValuePointPatchFieldBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
ClassNameNoDebug("fixedValuePointPatchField");
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class codedFixedValuePointPatchField Declaration
|
Class codedFixedValuePointPatchField Declaration
|
||||||
@ -101,58 +110,24 @@ template<class Type>
|
|||||||
class codedFixedValuePointPatchField
|
class codedFixedValuePointPatchField
|
||||||
:
|
:
|
||||||
public fixedValuePointPatchField<Type>,
|
public fixedValuePointPatchField<Type>,
|
||||||
public codedBase
|
public CodedBase<codedFixedValuePointPatchFieldBase>
|
||||||
{
|
{
|
||||||
// Private static data
|
|
||||||
|
|
||||||
//- The keywords associated with source code
|
|
||||||
static const wordList codeKeys_;
|
|
||||||
|
|
||||||
|
|
||||||
// Private Data
|
// Private Data
|
||||||
|
|
||||||
//- Dictionary contents for the boundary condition
|
|
||||||
mutable dictionary dict_;
|
|
||||||
|
|
||||||
const word name_;
|
|
||||||
|
|
||||||
mutable autoPtr<pointPatchField<Type>> redirectPatchFieldPtr_;
|
mutable autoPtr<pointPatchField<Type>> redirectPatchFieldPtr_;
|
||||||
|
|
||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
const IOdictionary& dict() const;
|
|
||||||
|
|
||||||
//- Set the rewrite vars controlling the Type
|
|
||||||
static void setFieldTemplates(dynamicCode& dynCode);
|
|
||||||
|
|
||||||
//- Adapt the context for the current object
|
//- Adapt the context for the current object
|
||||||
virtual void prepare(dynamicCode&, const dynamicCodeContext&) const;
|
virtual void prepare(dynamicCode&, const dynamicCodeContext&) const;
|
||||||
|
|
||||||
//- Return a description (type + name) for the output
|
|
||||||
virtual string description() const;
|
|
||||||
|
|
||||||
//- Clear the ptr to the redirected object
|
//- Clear the ptr to the redirected object
|
||||||
virtual void clearRedirect() const;
|
virtual void clearRedirect() const;
|
||||||
|
|
||||||
//- Get the dictionary to initialize the codeContext
|
|
||||||
virtual const dictionary& codeDict() const;
|
|
||||||
|
|
||||||
//- Get the keywords associated with source code
|
|
||||||
virtual const wordList& codeKeys() const;
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Static Data Members
|
|
||||||
|
|
||||||
//- Name of the C code template to be used
|
|
||||||
static const word codeTemplateC;
|
|
||||||
|
|
||||||
//- Name of the H code template to be used
|
|
||||||
static const word codeTemplateH;
|
|
||||||
|
|
||||||
|
|
||||||
//- Runtime type information
|
//- Runtime type information
|
||||||
TypeName("codedFixedValue");
|
TypeName("codedFixedValue");
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2012-2018 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2012-2020 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -24,20 +24,26 @@ License
|
|||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "codedFixedValuePointPatchFields.H"
|
#include "codedFixedValuePointPatchFields.H"
|
||||||
#include "pointPatchFields.H"
|
|
||||||
#include "addToRunTimeSelectionTable.H"
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
#include "pointPatchFields.H"
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
makePointPatchFields(codedFixedValue);
|
defineTypeName(Foam::codedFixedValuePointPatchFieldBase);
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
template<>
|
||||||
|
const Foam::wordList
|
||||||
|
Foam::CodedBase<Foam::codedFixedValuePointPatchFieldBase>::codeKeys_ =
|
||||||
|
{
|
||||||
|
"code",
|
||||||
|
"codeInclude",
|
||||||
|
"localCode"
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
makePointPatchFields(codedFixedValue);
|
||||||
|
}
|
||||||
|
|
||||||
} // End namespace Foam
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -91,7 +91,7 @@ template<class Type>
|
|||||||
Foam::autoPtr<Foam::Function1<Type>>
|
Foam::autoPtr<Foam::Function1<Type>>
|
||||||
Foam::Function1s::Coded<Type>::compileNew()
|
Foam::Function1s::Coded<Type>::compileNew()
|
||||||
{
|
{
|
||||||
this->updateLibrary(codeName());
|
this->updateLibrary();
|
||||||
|
|
||||||
dictionary redirectDict(codeDict());
|
dictionary redirectDict(codeDict());
|
||||||
redirectDict.set(codeName(), codeName());
|
redirectDict.set(codeName(), codeName());
|
||||||
|
|||||||
@ -31,7 +31,7 @@ template<class Type>
|
|||||||
inline Type Foam::Function1s::Coded<Type>::value(const scalar x) const
|
inline Type Foam::Function1s::Coded<Type>::value(const scalar x) const
|
||||||
{
|
{
|
||||||
// Make sure library containing user-defined Function1 is up-to-date
|
// Make sure library containing user-defined Function1 is up-to-date
|
||||||
this->updateLibrary(codeName());
|
this->updateLibrary();
|
||||||
|
|
||||||
return redirectFunction1Ptr_->value(x);
|
return redirectFunction1Ptr_->value(x);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,7 +29,6 @@ License
|
|||||||
#include "volFields.H"
|
#include "volFields.H"
|
||||||
#include "dynamicCode.H"
|
#include "dynamicCode.H"
|
||||||
#include "dynamicCodeContext.H"
|
#include "dynamicCodeContext.H"
|
||||||
#include "stringOps.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -131,7 +130,7 @@ Foam::codedFixedValueFvPatchField<Type>::codedFixedValueFvPatchField
|
|||||||
CodedBase<codedFixedValueFvPatchFieldBase>(dict),
|
CodedBase<codedFixedValueFvPatchFieldBase>(dict),
|
||||||
redirectPatchFieldPtr_()
|
redirectPatchFieldPtr_()
|
||||||
{
|
{
|
||||||
updateLibrary(codeName());
|
updateLibrary();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -168,9 +167,6 @@ Foam::codedFixedValueFvPatchField<Type>::redirectPatchField() const
|
|||||||
{
|
{
|
||||||
if (!redirectPatchFieldPtr_.valid())
|
if (!redirectPatchFieldPtr_.valid())
|
||||||
{
|
{
|
||||||
// Construct a patch
|
|
||||||
// Make sure to construct the patchfield with up-to-date value
|
|
||||||
|
|
||||||
OStringStream os;
|
OStringStream os;
|
||||||
writeEntry(os, "type", codeName());
|
writeEntry(os, "type", codeName());
|
||||||
writeEntry(os, "value", *this);
|
writeEntry(os, "value", *this);
|
||||||
@ -201,7 +197,7 @@ void Foam::codedFixedValueFvPatchField<Type>::updateCoeffs()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Make sure library containing user-defined fvPatchField is up-to-date
|
// Make sure library containing user-defined fvPatchField is up-to-date
|
||||||
updateLibrary(codeName());
|
updateLibrary();
|
||||||
|
|
||||||
const fvPatchField<Type>& fvp = redirectPatchField();
|
const fvPatchField<Type>& fvp = redirectPatchField();
|
||||||
|
|
||||||
@ -221,7 +217,7 @@ void Foam::codedFixedValueFvPatchField<Type>::evaluate
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Make sure library containing user-defined fvPatchField is up-to-date
|
// Make sure library containing user-defined fvPatchField is up-to-date
|
||||||
updateLibrary(codeName());
|
updateLibrary();
|
||||||
|
|
||||||
const fvPatchField<Type>& fvp = redirectPatchField();
|
const fvPatchField<Type>& fvp = redirectPatchField();
|
||||||
|
|
||||||
|
|||||||
@ -117,9 +117,6 @@ class codedFixedValueFvPatchField
|
|||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
//- Set the rewrite vars controlling the Type
|
|
||||||
static void setFieldTemplates(dynamicCode& dynCode);
|
|
||||||
|
|
||||||
//- Adapt the context for the current object
|
//- Adapt the context for the current object
|
||||||
virtual void prepare(dynamicCode&, const dynamicCodeContext&) const;
|
virtual void prepare(dynamicCode&, const dynamicCodeContext&) const;
|
||||||
|
|
||||||
|
|||||||
@ -27,7 +27,7 @@ License
|
|||||||
#include "addToRunTimeSelectionTable.H"
|
#include "addToRunTimeSelectionTable.H"
|
||||||
#include "volFields.H"
|
#include "volFields.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * Private Static Data Members * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
defineTypeName(Foam::codedFixedValueFvPatchFieldBase);
|
defineTypeName(Foam::codedFixedValueFvPatchFieldBase);
|
||||||
|
|
||||||
@ -40,18 +40,10 @@ Foam::CodedBase<Foam::codedFixedValueFvPatchFieldBase>::codeKeys_ =
|
|||||||
"localCode"
|
"localCode"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
makePatchFields(codedFixedValue);
|
||||||
|
}
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
makePatchFields(codedFixedValue);
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
} // End namespace Foam
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -29,76 +29,9 @@ License
|
|||||||
#include "volFields.H"
|
#include "volFields.H"
|
||||||
#include "dynamicCode.H"
|
#include "dynamicCode.H"
|
||||||
#include "dynamicCodeContext.H"
|
#include "dynamicCodeContext.H"
|
||||||
#include "stringOps.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * Private Static Data Members * * * * * * * * * * * //
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
const Foam::wordList Foam::codedMixedFvPatchField<Type>::codeKeys_ =
|
|
||||||
{"code", "codeInclude", "localCode"};
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
const Foam::word Foam::codedMixedFvPatchField<Type>::codeTemplateC =
|
|
||||||
"mixedFvPatchFieldTemplate.C";
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
const Foam::word Foam::codedMixedFvPatchField<Type>::codeTemplateH =
|
|
||||||
"mixedFvPatchFieldTemplate.H";
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
void Foam::codedMixedFvPatchField<Type>::setFieldTemplates
|
|
||||||
(
|
|
||||||
dynamicCode& dynCode
|
|
||||||
)
|
|
||||||
{
|
|
||||||
word fieldType(pTraits<Type>::typeName);
|
|
||||||
|
|
||||||
// template type for fvPatchField
|
|
||||||
dynCode.setFilterVariable("TemplateType", fieldType);
|
|
||||||
|
|
||||||
// Name for fvPatchField - eg, ScalarField, VectorField, ...
|
|
||||||
fieldType[0] = toupper(fieldType[0]);
|
|
||||||
dynCode.setFilterVariable("FieldType", fieldType + "Field");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
const Foam::IOdictionary& Foam::codedMixedFvPatchField<Type>::dict() const
|
|
||||||
{
|
|
||||||
const objectRegistry& obr = this->db();
|
|
||||||
|
|
||||||
if (obr.foundObject<IOdictionary>("codeDict"))
|
|
||||||
{
|
|
||||||
return obr.lookupObject<IOdictionary>("codeDict");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return obr.store
|
|
||||||
(
|
|
||||||
new IOdictionary
|
|
||||||
(
|
|
||||||
IOobject
|
|
||||||
(
|
|
||||||
"codeDict",
|
|
||||||
this->db().time().system(),
|
|
||||||
this->db(),
|
|
||||||
IOobject::MUST_READ_IF_MODIFIED,
|
|
||||||
IOobject::NO_WRITE
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void Foam::codedMixedFvPatchField<Type>::prepare
|
void Foam::codedMixedFvPatchField<Type>::prepare
|
||||||
(
|
(
|
||||||
@ -106,75 +39,51 @@ void Foam::codedMixedFvPatchField<Type>::prepare
|
|||||||
const dynamicCodeContext& context
|
const dynamicCodeContext& context
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
// take no chances - typeName must be identical to name_
|
dynCode.setFilterVariable("typeName", codeName());
|
||||||
dynCode.setFilterVariable("typeName", name_);
|
|
||||||
|
|
||||||
// set TemplateType and FieldType filter variables
|
// Set TemplateType and FieldType filter variables
|
||||||
// (for fvPatchField)
|
// (for fvPatchField)
|
||||||
setFieldTemplates(dynCode);
|
word fieldType(pTraits<Type>::typeName);
|
||||||
|
|
||||||
// compile filtered C template
|
// Template type for fvPatchField
|
||||||
|
dynCode.setFilterVariable("TemplateType", fieldType);
|
||||||
|
|
||||||
|
// Name for fvPatchField - eg, ScalarField, VectorField, ...
|
||||||
|
fieldType[0] = toupper(fieldType[0]);
|
||||||
|
dynCode.setFilterVariable("FieldType", fieldType + "Field");
|
||||||
|
|
||||||
|
// Compile filtered C template
|
||||||
dynCode.addCompileFile(codeTemplateC);
|
dynCode.addCompileFile(codeTemplateC);
|
||||||
|
|
||||||
// copy filtered H template
|
// Copy filtered H template
|
||||||
dynCode.addCopyFile(codeTemplateH);
|
dynCode.addCopyFile(codeTemplateH);
|
||||||
|
|
||||||
|
// Debugging: make BC verbose
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
dynCode.setFilterVariable("verbose", "true");
|
||||||
|
Info<<"compile " << codeName() << " sha1: "
|
||||||
|
<< context.sha1() << endl;
|
||||||
|
}
|
||||||
|
|
||||||
// debugging: make BC verbose
|
// Define Make/options
|
||||||
// dynCode.setFilterVariable("verbose", "true");
|
|
||||||
// Info<<"compile " << name_ << " sha1: "
|
|
||||||
// << context.sha1() << endl;
|
|
||||||
|
|
||||||
// define Make/options
|
|
||||||
dynCode.setMakeOptions
|
dynCode.setMakeOptions
|
||||||
(
|
|
||||||
"EXE_INC = -g \\\n"
|
|
||||||
"-I$(LIB_SRC)/finiteVolume/lnInclude \\\n"
|
|
||||||
+ context.options()
|
|
||||||
+ "\n\nLIB_LIBS = \\\n"
|
|
||||||
+ " -lOpenFOAM \\\n"
|
|
||||||
+ " -lfiniteVolume \\\n"
|
|
||||||
+ context.libs()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
const Foam::dictionary& Foam::codedMixedFvPatchField<Type>::codeDict()
|
|
||||||
const
|
|
||||||
{
|
|
||||||
// use system/codeDict or in-line
|
|
||||||
return
|
|
||||||
(
|
(
|
||||||
dict_.found("code")
|
"EXE_INC = -g \\\n"
|
||||||
? dict_
|
"-I$(LIB_SRC)/finiteVolume/lnInclude \\\n"
|
||||||
: this->dict().subDict(name_)
|
+ context.options()
|
||||||
|
+ "\n\nLIB_LIBS = \\\n"
|
||||||
|
+ " -lOpenFOAM \\\n"
|
||||||
|
+ " -lfiniteVolume \\\n"
|
||||||
|
+ context.libs()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
const Foam::wordList& Foam::codedMixedFvPatchField<Type>::codeKeys() const
|
|
||||||
{
|
|
||||||
return codeKeys_;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
Foam::string Foam::codedMixedFvPatchField<Type>::description() const
|
|
||||||
{
|
|
||||||
return
|
|
||||||
"patch "
|
|
||||||
+ this->patch().name()
|
|
||||||
+ " on field "
|
|
||||||
+ this->internalField().name();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void Foam::codedMixedFvPatchField<Type>::clearRedirect() const
|
void Foam::codedMixedFvPatchField<Type>::clearRedirect() const
|
||||||
{
|
{
|
||||||
// remove instantiation of fvPatchField provided by library
|
// Remove instantiation of fvPatchField provided by library
|
||||||
redirectPatchFieldPtr_.clear();
|
redirectPatchFieldPtr_.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,7 +98,7 @@ Foam::codedMixedFvPatchField<Type>::codedMixedFvPatchField
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
mixedFvPatchField<Type>(p, iF),
|
mixedFvPatchField<Type>(p, iF),
|
||||||
codedBase(),
|
CodedBase<codedMixedFvPatchFieldBase>(),
|
||||||
redirectPatchFieldPtr_()
|
redirectPatchFieldPtr_()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -204,9 +113,7 @@ Foam::codedMixedFvPatchField<Type>::codedMixedFvPatchField
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
mixedFvPatchField<Type>(ptf, p, iF, mapper),
|
mixedFvPatchField<Type>(ptf, p, iF, mapper),
|
||||||
codedBase(),
|
CodedBase<codedMixedFvPatchFieldBase>(ptf),
|
||||||
dict_(ptf.dict_),
|
|
||||||
name_(ptf.name_),
|
|
||||||
redirectPatchFieldPtr_()
|
redirectPatchFieldPtr_()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -220,17 +127,10 @@ Foam::codedMixedFvPatchField<Type>::codedMixedFvPatchField
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
mixedFvPatchField<Type>(p, iF, dict),
|
mixedFvPatchField<Type>(p, iF, dict),
|
||||||
codedBase(),
|
CodedBase<codedMixedFvPatchFieldBase>(dict),
|
||||||
dict_(dict),
|
|
||||||
name_
|
|
||||||
(
|
|
||||||
dict.found("redirectType")
|
|
||||||
? dict.lookup("redirectType")
|
|
||||||
: dict.lookup("name")
|
|
||||||
),
|
|
||||||
redirectPatchFieldPtr_()
|
redirectPatchFieldPtr_()
|
||||||
{
|
{
|
||||||
updateLibrary(name_);
|
updateLibrary();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -241,9 +141,7 @@ Foam::codedMixedFvPatchField<Type>::codedMixedFvPatchField
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
mixedFvPatchField<Type>(ptf),
|
mixedFvPatchField<Type>(ptf),
|
||||||
codedBase(),
|
CodedBase<codedMixedFvPatchFieldBase>(ptf),
|
||||||
dict_(ptf.dict_),
|
|
||||||
name_(ptf.name_),
|
|
||||||
redirectPatchFieldPtr_()
|
redirectPatchFieldPtr_()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -256,9 +154,7 @@ Foam::codedMixedFvPatchField<Type>::codedMixedFvPatchField
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
mixedFvPatchField<Type>(ptf, iF),
|
mixedFvPatchField<Type>(ptf, iF),
|
||||||
codedBase(),
|
CodedBase<codedMixedFvPatchFieldBase>(ptf),
|
||||||
dict_(ptf.dict_),
|
|
||||||
name_(ptf.name_),
|
|
||||||
redirectPatchFieldPtr_()
|
redirectPatchFieldPtr_()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -271,19 +167,14 @@ Foam::codedMixedFvPatchField<Type>::redirectPatchField() const
|
|||||||
{
|
{
|
||||||
if (!redirectPatchFieldPtr_.valid())
|
if (!redirectPatchFieldPtr_.valid())
|
||||||
{
|
{
|
||||||
// Construct a patch
|
|
||||||
// Make sure to construct the patchfield with up-to-date value
|
|
||||||
|
|
||||||
// Write the data from the mixed b.c.
|
|
||||||
OStringStream os;
|
OStringStream os;
|
||||||
mixedFvPatchField<Type>::write(os);
|
mixedFvPatchField<Type>::write(os);
|
||||||
IStringStream is(os.str());
|
IStringStream is(os.str());
|
||||||
// Construct dictionary from it.
|
|
||||||
dictionary dict(is);
|
dictionary dict(is);
|
||||||
|
|
||||||
// Override the type to enforce the fvPatchField::New constructor
|
// Override the type to enforce the fvPatchField::New constructor
|
||||||
// to choose our type
|
// to choose our type
|
||||||
dict.set("type", name_);
|
dict.set("type", codeName());
|
||||||
|
|
||||||
redirectPatchFieldPtr_.set
|
redirectPatchFieldPtr_.set
|
||||||
(
|
(
|
||||||
@ -298,6 +189,7 @@ Foam::codedMixedFvPatchField<Type>::redirectPatchField() const
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirectPatchFieldPtr_();
|
return redirectPatchFieldPtr_();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -311,7 +203,7 @@ void Foam::codedMixedFvPatchField<Type>::updateCoeffs()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Make sure library containing user-defined fvPatchField is up-to-date
|
// Make sure library containing user-defined fvPatchField is up-to-date
|
||||||
updateLibrary(name_);
|
updateLibrary();
|
||||||
|
|
||||||
const mixedFvPatchField<Type>& fvp = redirectPatchField();
|
const mixedFvPatchField<Type>& fvp = redirectPatchField();
|
||||||
|
|
||||||
@ -333,7 +225,7 @@ void Foam::codedMixedFvPatchField<Type>::evaluate
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Make sure library containing user-defined fvPatchField is up-to-date
|
// Make sure library containing user-defined fvPatchField is up-to-date
|
||||||
updateLibrary(name_);
|
updateLibrary();
|
||||||
|
|
||||||
const mixedFvPatchField<Type>& fvp = redirectPatchField();
|
const mixedFvPatchField<Type>& fvp = redirectPatchField();
|
||||||
|
|
||||||
@ -350,42 +242,7 @@ template<class Type>
|
|||||||
void Foam::codedMixedFvPatchField<Type>::write(Ostream& os) const
|
void Foam::codedMixedFvPatchField<Type>::write(Ostream& os) const
|
||||||
{
|
{
|
||||||
mixedFvPatchField<Type>::write(os);
|
mixedFvPatchField<Type>::write(os);
|
||||||
writeEntry(os, "name", name_);
|
writeCode(os);
|
||||||
|
|
||||||
if (dict_.found("codeInclude"))
|
|
||||||
{
|
|
||||||
writeKeyword(os, "codeInclude");
|
|
||||||
os.write(verbatimString(dict_["codeInclude"]))
|
|
||||||
<< token::END_STATEMENT << nl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dict_.found("localCode"))
|
|
||||||
{
|
|
||||||
writeKeyword(os, "localCode");
|
|
||||||
os.write(verbatimString(dict_["localCode"]))
|
|
||||||
<< token::END_STATEMENT << nl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dict_.found("code"))
|
|
||||||
{
|
|
||||||
writeKeyword(os, "code");
|
|
||||||
os.write(verbatimString(dict_["code"]))
|
|
||||||
<< token::END_STATEMENT << nl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dict_.found("codeOptions"))
|
|
||||||
{
|
|
||||||
writeKeyword(os, "codeOptions");
|
|
||||||
os.write(verbatimString(dict_["codeOptions"]))
|
|
||||||
<< token::END_STATEMENT << nl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dict_.found("codeLibs"))
|
|
||||||
{
|
|
||||||
writeKeyword(os, "codeLibs");
|
|
||||||
os.write(verbatimString(dict_["codeLibs"]))
|
|
||||||
<< token::END_STATEMENT << nl;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -91,15 +91,24 @@ SourceFiles
|
|||||||
#define codedMixedFvPatchField_H
|
#define codedMixedFvPatchField_H
|
||||||
|
|
||||||
#include "mixedFvPatchFields.H"
|
#include "mixedFvPatchFields.H"
|
||||||
#include "codedBase.H"
|
#include "CodedBase.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
// Forward declaration of classes
|
/*---------------------------------------------------------------------------*\
|
||||||
class IOdictionary;
|
Class codedMixedFvPatchFieldBase Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class codedMixedFvPatchFieldBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
ClassNameNoDebug("mixedFvPatchField");
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class codedMixedFvPatchField Declaration
|
Class codedMixedFvPatchField Declaration
|
||||||
@ -109,58 +118,24 @@ template<class Type>
|
|||||||
class codedMixedFvPatchField
|
class codedMixedFvPatchField
|
||||||
:
|
:
|
||||||
public mixedFvPatchField<Type>,
|
public mixedFvPatchField<Type>,
|
||||||
public codedBase
|
public CodedBase<codedMixedFvPatchFieldBase>
|
||||||
{
|
{
|
||||||
// Private static data
|
|
||||||
|
|
||||||
//- The keywords associated with source code
|
|
||||||
static const wordList codeKeys_;
|
|
||||||
|
|
||||||
|
|
||||||
// Private Data
|
// Private Data
|
||||||
|
|
||||||
//- Dictionary contents for the boundary condition
|
|
||||||
mutable dictionary dict_;
|
|
||||||
|
|
||||||
const word name_;
|
|
||||||
|
|
||||||
mutable autoPtr<mixedFvPatchField<Type>> redirectPatchFieldPtr_;
|
mutable autoPtr<mixedFvPatchField<Type>> redirectPatchFieldPtr_;
|
||||||
|
|
||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
const IOdictionary& dict() const;
|
|
||||||
|
|
||||||
//- Set the rewrite vars controlling the Type
|
|
||||||
static void setFieldTemplates(dynamicCode& dynCode);
|
|
||||||
|
|
||||||
//- Adapt the context for the current object
|
//- Adapt the context for the current object
|
||||||
virtual void prepare(dynamicCode&, const dynamicCodeContext&) const;
|
virtual void prepare(dynamicCode&, const dynamicCodeContext&) const;
|
||||||
|
|
||||||
//- Return a description (type + name) for the output
|
|
||||||
virtual string description() const;
|
|
||||||
|
|
||||||
//- Clear the ptr to the redirected object
|
//- Clear the ptr to the redirected object
|
||||||
virtual void clearRedirect() const;
|
virtual void clearRedirect() const;
|
||||||
|
|
||||||
//- Get the dictionary to initialize the codeContext
|
|
||||||
virtual const dictionary& codeDict() const;
|
|
||||||
|
|
||||||
//- Get the keywords associated with source code
|
|
||||||
virtual const wordList& codeKeys() const;
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Static Data Members
|
|
||||||
|
|
||||||
//- Name of the C code template to be used
|
|
||||||
static const word codeTemplateC;
|
|
||||||
|
|
||||||
//- Name of the H code template to be used
|
|
||||||
static const word codeTemplateH;
|
|
||||||
|
|
||||||
|
|
||||||
//- Runtime type information
|
//- Runtime type information
|
||||||
TypeName("codedMixed");
|
TypeName("codedMixed");
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -27,17 +27,23 @@ License
|
|||||||
#include "addToRunTimeSelectionTable.H"
|
#include "addToRunTimeSelectionTable.H"
|
||||||
#include "volFields.H"
|
#include "volFields.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
defineTypeName(Foam::codedMixedFvPatchFieldBase);
|
||||||
|
|
||||||
|
template<>
|
||||||
|
const Foam::wordList
|
||||||
|
Foam::CodedBase<Foam::codedMixedFvPatchFieldBase>::codeKeys_ =
|
||||||
|
{
|
||||||
|
"code",
|
||||||
|
"codeInclude",
|
||||||
|
"localCode"
|
||||||
|
};
|
||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
makePatchFields(codedMixed);
|
||||||
|
}
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
makePatchFields(codedMixed);
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
} // End namespace Foam
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -154,28 +154,28 @@ Foam::functionObject& Foam::codedFunctionObject::redirectFunctionObject() const
|
|||||||
|
|
||||||
bool Foam::codedFunctionObject::execute()
|
bool Foam::codedFunctionObject::execute()
|
||||||
{
|
{
|
||||||
updateLibrary(codeName());
|
updateLibrary();
|
||||||
return redirectFunctionObject().execute();
|
return redirectFunctionObject().execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Foam::codedFunctionObject::write()
|
bool Foam::codedFunctionObject::write()
|
||||||
{
|
{
|
||||||
updateLibrary(codeName());
|
updateLibrary();
|
||||||
return redirectFunctionObject().write();
|
return redirectFunctionObject().write();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Foam::codedFunctionObject::end()
|
bool Foam::codedFunctionObject::end()
|
||||||
{
|
{
|
||||||
updateLibrary(codeName());
|
updateLibrary();
|
||||||
return redirectFunctionObject().end();
|
return redirectFunctionObject().end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Foam::codedFunctionObject::read(const dictionary& dict)
|
bool Foam::codedFunctionObject::read(const dictionary& dict)
|
||||||
{
|
{
|
||||||
updateLibrary(codeName());
|
updateLibrary();
|
||||||
return redirectFunctionObject().read(dict);
|
return redirectFunctionObject().read(dict);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -33,7 +33,13 @@ License
|
|||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
const Foam::wordList Foam::fv::CodedSource<Type>::codeKeys_ =
|
const Foam::wordList Foam::fv::CodedSource<Type>::codeKeys_ =
|
||||||
{"codeAddSup", "codeCorrect", "codeInclude", "codeSetValue", "localCode"};
|
{
|
||||||
|
"codeAddSup",
|
||||||
|
"codeCorrect",
|
||||||
|
"codeInclude",
|
||||||
|
"codeSetValue",
|
||||||
|
"localCode"
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||||
@ -160,7 +166,7 @@ void Foam::fv::CodedSource<Type>::correct
|
|||||||
<< ">::correct for source " << name_ << endl;
|
<< ">::correct for source " << name_ << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateLibrary(name_);
|
updateLibrary();
|
||||||
redirectFvOption().correct(field);
|
redirectFvOption().correct(field);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,7 +184,7 @@ void Foam::fv::CodedSource<Type>::addSup
|
|||||||
<< ">::addSup for source " << name_ << endl;
|
<< ">::addSup for source " << name_ << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateLibrary(name_);
|
updateLibrary();
|
||||||
redirectFvOption().addSup(eqn, fieldi);
|
redirectFvOption().addSup(eqn, fieldi);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,7 +203,7 @@ void Foam::fv::CodedSource<Type>::addSup
|
|||||||
<< ">::addSup for source " << name_ << endl;
|
<< ">::addSup for source " << name_ << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateLibrary(name_);
|
updateLibrary();
|
||||||
redirectFvOption().addSup(rho, eqn, fieldi);
|
redirectFvOption().addSup(rho, eqn, fieldi);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,7 +221,7 @@ void Foam::fv::CodedSource<Type>::constrain
|
|||||||
<< ">::constrain for source " << name_ << endl;
|
<< ">::constrain for source " << name_ << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateLibrary(name_);
|
updateLibrary();
|
||||||
redirectFvOption().constrain(eqn, fieldi);
|
redirectFvOption().constrain(eqn, fieldi);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -149,6 +149,12 @@ protected:
|
|||||||
//- Adapt the context for the current object
|
//- Adapt the context for the current object
|
||||||
virtual void prepare(dynamicCode&, const dynamicCodeContext&) const;
|
virtual void prepare(dynamicCode&, const dynamicCodeContext&) const;
|
||||||
|
|
||||||
|
//- Name of the dynamically generated CodedType
|
||||||
|
virtual const word& codeName() const
|
||||||
|
{
|
||||||
|
return name_;
|
||||||
|
}
|
||||||
|
|
||||||
//- Return a description (type + name) for the output
|
//- Return a description (type + name) for the output
|
||||||
virtual string description() const;
|
virtual string description() const;
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2012-2019 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2012-2020 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -47,7 +47,7 @@ bool Foam::fv::CodedSource<Type>::read(const dictionary& dict)
|
|||||||
dict.lookup("name"); // <-- generate error message with "name" in it
|
dict.lookup("name"); // <-- generate error message with "name" in it
|
||||||
}
|
}
|
||||||
|
|
||||||
updateLibrary(name_);
|
updateLibrary();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user