diff --git a/etc/codeTemplates/dynamicCode/fixedValuePointPatchFieldTemplate.C b/etc/codeTemplates/dynamicCode/fixedValuePointPatchFieldTemplate.C new file mode 100644 index 0000000000000000000000000000000000000000..f474cbbd73cdcba5a7197e8427fc3f6b8554845d --- /dev/null +++ b/etc/codeTemplates/dynamicCode/fixedValuePointPatchFieldTemplate.C @@ -0,0 +1,211 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +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 "fixedValuePointPatchFieldTemplate.H" +#include "addToRunTimeSelectionTable.H" +#include "pointPatchFieldMapper.H" +#include "pointFields.H" +#include "unitConversion.H" +//{{{ begin codeInclude +${codeInclude} +//}}} end codeInclude + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * // + +//{{{ begin localCode +${localCode} +//}}} end localCode + + +// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * // + +extern "C" +{ + // dynamicCode: + // SHA1 = ${SHA1sum} + // + // unique function name that can be checked if the correct library version + // has been loaded + void ${typeName}_${SHA1sum}(bool load) + { + if (load) + { + // code that can be explicitly executed after loading + } + else + { + // code that can be explicitly executed before unloading + } + } +} + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +makePointPatchTypeField +( + pointPatch${FieldType}, + ${typeName}FixedValuePointPatch${FieldType} +); + + +const char* const ${typeName}FixedValuePointPatch${FieldType}::SHA1sum = + "${SHA1sum}"; + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +${typeName}FixedValuePointPatch${FieldType}:: +${typeName}FixedValuePointPatch${FieldType} +( + const pointPatch& p, + const DimensionedField<${TemplateType}, pointMesh>& iF +) +: + fixedValuePointPatchField<${TemplateType}>(p, iF) +{ + if (${verbose:-false}) + { + Info<<"construct ${typeName} sha1: ${SHA1sum}" + " from patch/DimensionedField\n"; + } +} + + +${typeName}FixedValuePointPatch${FieldType}:: +${typeName}FixedValuePointPatch${FieldType} +( + const ${typeName}FixedValuePointPatch${FieldType}& ptf, + const pointPatch& p, + const DimensionedField<${TemplateType}, pointMesh>& iF, + const pointPatchFieldMapper& mapper +) +: + fixedValuePointPatchField<${TemplateType}>(ptf, p, iF, mapper) +{ + if (${verbose:-false}) + { + Info<<"construct ${typeName} sha1: ${SHA1sum}" + " from patch/DimensionedField/mapper\n"; + } +} + + +${typeName}FixedValuePointPatch${FieldType}:: +${typeName}FixedValuePointPatch${FieldType} +( + const pointPatch& p, + const DimensionedField<${TemplateType}, pointMesh>& iF, + const dictionary& dict, + const bool valueRequired +) +: + fixedValuePointPatchField<${TemplateType}>(p, iF, dict, valueRequired) +{ + if (${verbose:-false}) + { + Info<<"construct ${typeName} sha1: ${SHA1sum}" + " from patch/dictionary\n"; + } +} + + +${typeName}FixedValuePointPatch${FieldType}:: +${typeName}FixedValuePointPatch${FieldType} +( + const ${typeName}FixedValuePointPatch${FieldType}& ptf +) +: + fixedValuePointPatchField<${TemplateType}>(ptf) +{ + if (${verbose:-false}) + { + Info<<"construct ${typeName} sha1: ${SHA1sum}" + " as copy\n"; + } +} + + +${typeName}FixedValuePointPatch${FieldType}:: +${typeName}FixedValuePointPatch${FieldType} +( + const ${typeName}FixedValuePointPatch${FieldType}& ptf, + const DimensionedField<${TemplateType}, pointMesh>& iF +) +: + fixedValuePointPatchField<${TemplateType}>(ptf, iF) +{ + if (${verbose:-false}) + { + Info<<"construct ${typeName} sha1: ${SHA1sum} " + "as copy/DimensionedField\n"; + } +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +${typeName}FixedValuePointPatch${FieldType}:: +~${typeName}FixedValuePointPatch${FieldType}() +{ + if (${verbose:-false}) + { + Info<<"destroy ${typeName} sha1: ${SHA1sum}\n"; + } +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void ${typeName}FixedValuePointPatch${FieldType}::updateCoeffs() +{ + if (this->updated()) + { + return; + } + + if (${verbose:-false}) + { + Info<<"updateCoeffs ${typeName} sha1: ${SHA1sum}\n"; + } + +//{{{ begin code + ${code} +//}}} end code + + this->fixedValuePointPatchField<${TemplateType}>::updateCoeffs(); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/etc/codeTemplates/dynamicCode/fixedValuePointPatchFieldTemplate.H b/etc/codeTemplates/dynamicCode/fixedValuePointPatchFieldTemplate.H new file mode 100644 index 0000000000000000000000000000000000000000..1b1baf40c673c815cee4ad0d6442345613bdc4cf --- /dev/null +++ b/etc/codeTemplates/dynamicCode/fixedValuePointPatchFieldTemplate.H @@ -0,0 +1,143 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +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/>. + +Description + Template for use with dynamic code generation of a + fixedValue pointPatchField. + + - without state + +SourceFiles + fixedValuePointPatchFieldTemplate.C + +\*---------------------------------------------------------------------------*/ + +#ifndef fixedValuePointPatchTemplate${FieldType}_H +#define fixedValuePointPatchTemplate${FieldType}_H + +#include "fixedValuePointPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + A templated FixedValuePointPatchField +\*---------------------------------------------------------------------------*/ + +class ${typeName}FixedValuePointPatch${FieldType} +: + public fixedValuePointPatchField<${TemplateType}> +{ +public: + + //- Information about the SHA1 of the code itself + static const char* const SHA1sum; + + //- Runtime type information + TypeName("${typeName}"); + + + // Constructors + + //- Construct from patch and internal field + ${typeName}FixedValuePointPatch${FieldType} + ( + const pointPatch&, + const DimensionedField<${TemplateType}, pointMesh>& + ); + + //- Construct from patch, internal field and dictionary + ${typeName}FixedValuePointPatch${FieldType} + ( + const pointPatch&, + const DimensionedField<${TemplateType}, pointMesh>&, + const dictionary&, + const bool valueRequired=true + ); + + //- Construct by mapping a copy onto a new patch + ${typeName}FixedValuePointPatch${FieldType} + ( + const ${typeName}FixedValuePointPatch${FieldType}&, + const pointPatch&, + const DimensionedField<${TemplateType}, pointMesh>&, + const pointPatchFieldMapper& + ); + + //- Construct as copy + ${typeName}FixedValuePointPatch${FieldType} + ( + const ${typeName}FixedValuePointPatch${FieldType}& + ); + + //- Construct and return a clone + virtual autoPtr< pointPatchField<${TemplateType}> > clone() const + { + return autoPtr< pointPatchField<${TemplateType}> > + ( + new ${typeName}FixedValuePointPatch${FieldType}(*this) + ); + } + + //- Construct as copy setting internal field reference + ${typeName}FixedValuePointPatch${FieldType} + ( + const ${typeName}FixedValuePointPatch${FieldType}&, + const DimensionedField<${TemplateType}, pointMesh>& + ); + + //- Construct and return a clone setting internal field reference + virtual autoPtr< pointPatchField<${TemplateType}> > clone + ( + const DimensionedField<${TemplateType}, pointMesh>& iF + ) const + { + return autoPtr< pointPatchField<${TemplateType}> > + ( + new ${typeName}FixedValuePointPatch${FieldType}(*this, iF) + ); + } + + + //- Destructor + virtual ~${typeName}FixedValuePointPatch${FieldType}(); + + + // Member functions + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files index b08260f813cfb42c7c6b525cb2cb0d23a25d5461..c58cf1afc292006cb18bc77bdd9e82540d2663c7 100644 --- a/src/OpenFOAM/Make/files +++ b/src/OpenFOAM/Make/files @@ -493,9 +493,6 @@ $(constraintPointPatches)/wedge/wedgePointPatch.C derivedPointPatches = $(pointPatches)/derived $(derivedPointPatches)/coupled/coupledFacePointPatch.C -/* -$(derivedPointPatches)/global/globalPointPatch.C -*/ $(derivedPointPatches)/wall/wallPointPatch.C pointBoundaryMesh = $(pointMesh)/pointBoundaryMesh @@ -562,11 +559,9 @@ $(constraintPointPatchFields)/wedge/wedgePointPatchFields.C derivedPointPatchFields = $(pointPatchFields)/derived $(derivedPointPatchFields)/slip/slipPointPatchFields.C $(derivedPointPatchFields)/fixedNormalSlip/fixedNormalSlipPointPatchFields.C -/* -$(derivedPointPatchFields)/global/globalPointPatchFields.C -*/ $(derivedPointPatchFields)/uniformFixedValue/uniformFixedValuePointPatchFields.C $(derivedPointPatchFields)/timeVaryingUniformFixedValue/timeVaryingUniformFixedValuePointPatchFields.C +$(derivedPointPatchFields)/codedFixedValue/codedFixedValuePointPatchFields.C fields/GeometricFields/pointFields/pointFields.C diff --git a/src/OpenFOAM/fields/pointPatchFields/derived/codedFixedValue/codedFixedValuePointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/derived/codedFixedValue/codedFixedValuePointPatchField.C new file mode 100644 index 0000000000000000000000000000000000000000..f56a8cf1e708dfad82db96c510e10aa6b85ffb00 --- /dev/null +++ b/src/OpenFOAM/fields/pointPatchFields/derived/codedFixedValue/codedFixedValuePointPatchField.C @@ -0,0 +1,386 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +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 "codedFixedValuePointPatchField.H" +#include "addToRunTimeSelectionTable.H" +#include "pointPatchFieldMapper.H" +#include "pointFields.H" +#include "dynamicCode.H" +#include "dynamicCodeContext.H" +#include "stringOps.H" + +// * * * * * * * * * * * * * * 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 * * * * * * * * * * * // + +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> +Foam::dlLibraryTable& Foam::codedFixedValuePointPatchField<Type>::libs() const +{ + return const_cast<dlLibraryTable&>(this->db().time().libs()); +} + + +template<class Type> +void Foam::codedFixedValuePointPatchField<Type>::prepare +( + dynamicCode& dynCode, + const dynamicCodeContext& context +) const +{ + // take no chances - typeName must be identical to redirectType_ + dynCode.setFilterVariable("typeName", redirectType_); + + // set TemplateType and FieldType filter variables + // (for pointPatchField) + setFieldTemplates(dynCode); + + // compile filtered C template + dynCode.addCompileFile(codeTemplateC); + + // copy filtered H template + dynCode.addCopyFile(codeTemplateH); + + + // debugging: make BC verbose + // dynCode.setFilterVariable("verbose", "true"); + // Info<<"compile " << redirectType_ << " sha1: " + // << context.sha1() << endl; + + // define Make/options + 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") + ? dict_ + : this->dict().subDict(redirectType_) + ); +} + + +template<class Type> +Foam::string Foam::codedFixedValuePointPatchField<Type>::description() const +{ + return + "patch " + + this->patch().name() + + " on field " + + this->dimensionedInternalField().name(); +} + + +template<class Type> +void Foam::codedFixedValuePointPatchField<Type>::clearRedirect() const +{ + // remove instantiation of pointPatchField provided by library + redirectPatchFieldPtr_.clear(); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template<class Type> +Foam::codedFixedValuePointPatchField<Type>::codedFixedValuePointPatchField +( + const pointPatch& p, + const DimensionedField<Type, pointMesh>& iF +) +: + fixedValuePointPatchField<Type>(p, iF), + codedBase(), + redirectPatchFieldPtr_() +{} + + +template<class Type> +Foam::codedFixedValuePointPatchField<Type>::codedFixedValuePointPatchField +( + const codedFixedValuePointPatchField<Type>& ptf, + const pointPatch& p, + const DimensionedField<Type, pointMesh>& iF, + const pointPatchFieldMapper& mapper +) +: + fixedValuePointPatchField<Type>(ptf, p, iF, mapper), + codedBase(), + dict_(ptf.dict_), + redirectType_(ptf.redirectType_), + redirectPatchFieldPtr_() +{} + + +template<class Type> +Foam::codedFixedValuePointPatchField<Type>::codedFixedValuePointPatchField +( + const pointPatch& p, + const DimensionedField<Type, pointMesh>& iF, + const dictionary& dict, + const bool valueRequired +) +: + fixedValuePointPatchField<Type>(p, iF, dict, valueRequired), + codedBase(), + dict_(dict), + redirectType_(dict.lookup("redirectType")), + redirectPatchFieldPtr_() +{ + updateLibrary(redirectType_); +} + + +template<class Type> +Foam::codedFixedValuePointPatchField<Type>::codedFixedValuePointPatchField +( + const codedFixedValuePointPatchField<Type>& ptf +) +: + fixedValuePointPatchField<Type>(ptf), + codedBase(), + dict_(ptf.dict_), + redirectType_(ptf.redirectType_), + redirectPatchFieldPtr_() +{} + + +template<class Type> +Foam::codedFixedValuePointPatchField<Type>::codedFixedValuePointPatchField +( + const codedFixedValuePointPatchField<Type>& ptf, + const DimensionedField<Type, pointMesh>& iF +) +: + fixedValuePointPatchField<Type>(ptf, iF), + codedBase(), + dict_(ptf.dict_), + redirectType_(ptf.redirectType_), + redirectPatchFieldPtr_() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class Type> +const Foam::pointPatchField<Type>& +Foam::codedFixedValuePointPatchField<Type>::redirectPatchField() const +{ + if (!redirectPatchFieldPtr_.valid()) + { + // Construct a patch + // Make sure to construct the patchfield with up-to-date value + + OStringStream os; + os.writeKeyword("type") << redirectType_ << token::END_STATEMENT + << nl; + static_cast<const Field<Type>&>(*this).writeEntry("value", os); + IStringStream is(os.str()); + dictionary dict(is); + + redirectPatchFieldPtr_.set + ( + pointPatchField<Type>::New + ( + this->patch(), + this->dimensionedInternalField(), + dict + ).ptr() + ); + } + return redirectPatchFieldPtr_(); +} + + +template<class Type> +void Foam::codedFixedValuePointPatchField<Type>::updateCoeffs() +{ + if (this->updated()) + { + return; + } + + // Make sure library containing user-defined pointPatchField is up-to-date + updateLibrary(redirectType_); + + const pointPatchField<Type>& fvp = redirectPatchField(); + + const_cast<pointPatchField<Type>&>(fvp).updateCoeffs(); + + // Copy through value + this->operator==(fvp); + + fixedValuePointPatchField<Type>::updateCoeffs(); +} + + +template<class Type> +void Foam::codedFixedValuePointPatchField<Type>::evaluate +( + const Pstream::commsTypes commsType +) +{ + // Make sure library containing user-defined pointPatchField is up-to-date + updateLibrary(redirectType_); + + const pointPatchField<Type>& fvp = redirectPatchField(); + + const_cast<pointPatchField<Type>&>(fvp).evaluate(commsType); + + fixedValuePointPatchField<Type>::evaluate(commsType); +} + + +template<class Type> +void Foam::codedFixedValuePointPatchField<Type>::write(Ostream& os) const +{ + fixedValuePointPatchField<Type>::write(os); + os.writeKeyword("redirectType") << redirectType_ + << token::END_STATEMENT << nl; + + if (dict_.found("codeInclude")) + { + os.writeKeyword("codeInclude") + << token::HASH << token::BEGIN_BLOCK; + + os.writeQuoted(string(dict_["codeInclude"]), false) + << token::HASH << token::END_BLOCK + << token::END_STATEMENT << nl; + } + + if (dict_.found("localCode")) + { + os.writeKeyword("localCode") + << token::HASH << token::BEGIN_BLOCK; + + os.writeQuoted(string(dict_["localCode"]), false) + << token::HASH << token::END_BLOCK + << token::END_STATEMENT << nl; + } + + if (dict_.found("code")) + { + os.writeKeyword("code") + << token::HASH << token::BEGIN_BLOCK; + + os.writeQuoted(string(dict_["code"]), false) + << token::HASH << token::END_BLOCK + << token::END_STATEMENT << nl; + } + + if (dict_.found("codeOptions")) + { + os.writeKeyword("codeOptions") + << token::HASH << token::BEGIN_BLOCK; + + os.writeQuoted(string(dict_["codeOptions"]), false) + << token::HASH << token::END_BLOCK + << token::END_STATEMENT << nl; + } + + if (dict_.found("codeLibs")) + { + os.writeKeyword("codeLibs") + << token::HASH << token::BEGIN_BLOCK; + + os.writeQuoted(string(dict_["codeLibs"]), false) + << token::HASH << token::END_BLOCK + << token::END_STATEMENT << nl; + } +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/fields/pointPatchFields/derived/codedFixedValue/codedFixedValuePointPatchField.H b/src/OpenFOAM/fields/pointPatchFields/derived/codedFixedValue/codedFixedValuePointPatchField.H new file mode 100644 index 0000000000000000000000000000000000000000..563f1aadab506cab474e48de6360cfb065737695 --- /dev/null +++ b/src/OpenFOAM/fields/pointPatchFields/derived/codedFixedValue/codedFixedValuePointPatchField.H @@ -0,0 +1,251 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +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/>. + +Class + Foam::codedFixedValuePointPatchField + +Description + Constructs on-the-fly a new boundary condition (derived from + fixedValuePointPatchField) which is then used to evaluate. + + Example: + \verbatim + movingWall + { + type codedFixedValue; + value uniform 0; + redirectType rampedFixedValue; // name of generated bc + + code + #{ + operator==(min(10, 0.1*this->db().time().value())); + #}; + + //codeInclude + //#{ + // #include "fvCFD.H" + //#}; + + //codeOptions + //#{ + // -I$(LIB_SRC)/finiteVolume/lnInclude + //#}; + } + \endverbatim + + A special form is if the 'code' section is not supplied. In this case + the code gets read from a (runTimeModifiable!) dictionary system/codeDict + which would have a corresponding entry + + \verbatim + rampedFixedValue + { + code + #{ + operator==(min(10, 0.1*this->db().time().value())); + #}; + } + \endverbatim + +SeeAlso + codedFixedValueFvPatchField + +SourceFiles + codedFixedValuePointPatchField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef codedFixedValuePointPatchField_H +#define codedFixedValuePointPatchField_H + +#include "fixedValuePointPatchFields.H" +#include "codedBase.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of classes +class dynamicCode; +class dynamicCodeContext; +class IOdictionary; + +/*---------------------------------------------------------------------------*\ + Class codedFixedValuePointPatchField Declaration +\*---------------------------------------------------------------------------*/ + +template<class Type> +class codedFixedValuePointPatchField +: + public fixedValuePointPatchField<Type>, + public codedBase +{ + // Private data + + //- Dictionary contents for the boundary condition + mutable dictionary dict_; + + const word redirectType_; + + mutable autoPtr<pointPatchField<Type> > redirectPatchFieldPtr_; + + // Private Member Functions + + const IOdictionary& dict() const; + + //- Set the rewrite vars controlling the Type + static void setFieldTemplates(dynamicCode& dynCode); + + //- get the loaded dynamic libraries + virtual dlLibraryTable& libs() const; + + //- adapt the context for the current object + 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 + virtual void clearRedirect() const; + + // Get the dictionary to initialize the codeContext + virtual const dictionary& codeDict() const; + +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 + TypeName("codedFixedValue"); + + + // Constructors + + //- Construct from patch and internal field + codedFixedValuePointPatchField + ( + const pointPatch&, + const DimensionedField<Type, pointMesh>& + ); + + //- Construct from patch, internal field and dictionary + codedFixedValuePointPatchField + ( + const pointPatch&, + const DimensionedField<Type, pointMesh>&, + const dictionary&, + const bool valueRequired=true + ); + + //- Construct by mapping given codedFixedValuePointPatchField + // onto a new patch + codedFixedValuePointPatchField + ( + const codedFixedValuePointPatchField<Type>&, + const pointPatch&, + const DimensionedField<Type, pointMesh>&, + const pointPatchFieldMapper& + ); + + //- Construct as copy + codedFixedValuePointPatchField + ( + const codedFixedValuePointPatchField<Type>& + ); + + //- Construct and return a clone + virtual autoPtr<pointPatchField<Type> > clone() const + { + return autoPtr<pointPatchField<Type> > + ( + new codedFixedValuePointPatchField<Type>(*this) + ); + } + + //- Construct as copy setting internal field reference + codedFixedValuePointPatchField + ( + const codedFixedValuePointPatchField<Type>&, + const DimensionedField<Type, pointMesh>& + ); + + //- Construct and return a clone setting internal field reference + virtual autoPtr<pointPatchField<Type> > clone + ( + const DimensionedField<Type, pointMesh>& iF + ) const + { + return autoPtr<pointPatchField<Type> > + ( + new codedFixedValuePointPatchField<Type> + ( + *this, + iF + ) + ); + } + + + + // Member functions + + //- Get reference to the underlying patch + const pointPatchField<Type>& redirectPatchField() const; + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + //- Evaluate the patch field, sets Updated to false + virtual void evaluate + ( + const Pstream::commsTypes commsType=Pstream::blocking + ); + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "codedFixedValuePointPatchField.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/fields/pointPatchFields/derived/codedFixedValue/codedFixedValuePointPatchFields.C b/src/OpenFOAM/fields/pointPatchFields/derived/codedFixedValue/codedFixedValuePointPatchFields.C new file mode 100644 index 0000000000000000000000000000000000000000..bbce9c55f1d9aeb7d83af5748c559cd8cd415af2 --- /dev/null +++ b/src/OpenFOAM/fields/pointPatchFields/derived/codedFixedValue/codedFixedValuePointPatchFields.C @@ -0,0 +1,43 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +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 "codedFixedValuePointPatchFields.H" +#include "pointPatchFields.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +makePointPatchFields(codedFixedValue); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/OpenFOAM/fields/pointPatchFields/derived/codedFixedValue/codedFixedValuePointPatchFields.H b/src/OpenFOAM/fields/pointPatchFields/derived/codedFixedValue/codedFixedValuePointPatchFields.H new file mode 100644 index 0000000000000000000000000000000000000000..89f197fe4e19bb3634ad667752a70c257fafae61 --- /dev/null +++ b/src/OpenFOAM/fields/pointPatchFields/derived/codedFixedValue/codedFixedValuePointPatchFields.H @@ -0,0 +1,49 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +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/>. + +\*---------------------------------------------------------------------------*/ + +#ifndef codedFixedValuePointPatchFields_H +#define codedFixedValuePointPatchFields_H + +#include "codedFixedValuePointPatchField.H" +#include "fieldTypes.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePointPatchFieldTypedefs(codedFixedValue); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/fields/pointPatchFields/derived/codedFixedValue/codedFixedValuePointPatchFieldsFwd.H b/src/OpenFOAM/fields/pointPatchFields/derived/codedFixedValue/codedFixedValuePointPatchFieldsFwd.H new file mode 100644 index 0000000000000000000000000000000000000000..9bcc95da4b95d1f4e5451862b8161e2721b5030d --- /dev/null +++ b/src/OpenFOAM/fields/pointPatchFields/derived/codedFixedValue/codedFixedValuePointPatchFieldsFwd.H @@ -0,0 +1,50 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +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/>. + +\*---------------------------------------------------------------------------*/ + +#ifndef codedFixedValuePointPatchFieldsFwd_H +#define codedFixedValuePointPatchFieldsFwd_H + +#include "fieldTypes.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template<class Type> class codedFixedValuePointPatchField; + +makePatchTypeFieldTypedefs(codedFixedValue); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* //