From 50b2b78d83614138fc72d33e5d9bc7b2907a1aa0 Mon Sep 17 00:00:00 2001 From: mattijs Date: Thu, 1 Dec 2011 15:56:13 +0000 Subject: [PATCH] ENH: codedMixed: coded variant of mixed --- .../dynamicCode/mixedFvPatchFieldTemplate.C | 211 +++++++++++ .../dynamicCode/mixedFvPatchFieldTemplate.H | 142 +++++++ src/finiteVolume/Make/files | 1 + .../codedMixed/codedMixedFvPatchField.C | 356 ++++++++++++++++++ .../codedMixed/codedMixedFvPatchField.H | 249 ++++++++++++ .../codedMixed/codedMixedFvPatchFields.C | 43 +++ .../codedMixed/codedMixedFvPatchFields.H | 49 +++ .../codedMixed/codedMixedFvPatchFieldsFwd.H | 50 +++ 8 files changed, 1101 insertions(+) create mode 100644 etc/codeTemplates/dynamicCode/mixedFvPatchFieldTemplate.C create mode 100644 etc/codeTemplates/dynamicCode/mixedFvPatchFieldTemplate.H create mode 100644 src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchField.C create mode 100644 src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchField.H create mode 100644 src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchFields.C create mode 100644 src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchFields.H create mode 100644 src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchFieldsFwd.H diff --git a/etc/codeTemplates/dynamicCode/mixedFvPatchFieldTemplate.C b/etc/codeTemplates/dynamicCode/mixedFvPatchFieldTemplate.C new file mode 100644 index 0000000000..ded11e8929 --- /dev/null +++ b/etc/codeTemplates/dynamicCode/mixedFvPatchFieldTemplate.C @@ -0,0 +1,211 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011 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 . + +\*---------------------------------------------------------------------------*/ + +#include "mixedFvPatchFieldTemplate.H" +#include "addToRunTimeSelectionTable.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "surfaceFields.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 * * * * * * * * * * * * * // + +makeRemovablePatchTypeField +( + fvPatch${FieldType}, + ${typeName}FixedValueFvPatch${FieldType} +); + + +const char* const ${typeName}FixedValueFvPatch${FieldType}::SHA1sum = + "${SHA1sum}"; + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +${typeName}FixedValueFvPatch${FieldType}:: +${typeName}FixedValueFvPatch${FieldType} +( + const fvPatch& p, + const DimensionedField<${TemplateType}, volMesh>& iF +) +: + mixedFvPatchField<${TemplateType}>(p, iF) +{ + if (${verbose:-false}) + { + Info<<"construct ${typeName} sha1: ${SHA1sum}" + " from patch/DimensionedField\n"; + } +} + + +${typeName}FixedValueFvPatch${FieldType}:: +${typeName}FixedValueFvPatch${FieldType} +( + const ${typeName}FixedValueFvPatch${FieldType}& ptf, + const fvPatch& p, + const DimensionedField<${TemplateType}, volMesh>& iF, + const fvPatchFieldMapper& mapper +) +: + mixedFvPatchField<${TemplateType}>(ptf, p, iF, mapper) +{ + if (${verbose:-false}) + { + Info<<"construct ${typeName} sha1: ${SHA1sum}" + " from patch/DimensionedField/mapper\n"; + } +} + + +${typeName}FixedValueFvPatch${FieldType}:: +${typeName}FixedValueFvPatch${FieldType} +( + const fvPatch& p, + const DimensionedField<${TemplateType}, volMesh>& iF, + const dictionary& dict +) +: + mixedFvPatchField<${TemplateType}>(p, iF, dict) +{ + if (${verbose:-false}) + { + Info<<"construct ${typeName} sha1: ${SHA1sum}" + " from patch/dictionary\n"; + } +} + + +${typeName}FixedValueFvPatch${FieldType}:: +${typeName}FixedValueFvPatch${FieldType} +( + const ${typeName}FixedValueFvPatch${FieldType}& ptf +) +: + mixedFvPatchField<${TemplateType}>(ptf) +{ + if (${verbose:-false}) + { + Info<<"construct ${typeName} sha1: ${SHA1sum}" + " as copy\n"; + } +} + + +${typeName}FixedValueFvPatch${FieldType}:: +${typeName}FixedValueFvPatch${FieldType} +( + const ${typeName}FixedValueFvPatch${FieldType}& ptf, + const DimensionedField<${TemplateType}, volMesh>& iF +) +: + mixedFvPatchField<${TemplateType}>(ptf, iF) +{ + if (${verbose:-false}) + { + Info<<"construct ${typeName} sha1: ${SHA1sum} " + "as copy/DimensionedField\n"; + } +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +${typeName}FixedValueFvPatch${FieldType}:: +~${typeName}FixedValueFvPatch${FieldType}() +{ + if (${verbose:-false}) + { + Info<<"destroy ${typeName} sha1: ${SHA1sum}\n"; + } +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void ${typeName}FixedValueFvPatch${FieldType}::updateCoeffs() +{ + if (this->updated()) + { + return; + } + + if (${verbose:-false}) + { + Info<<"updateCoeffs ${typeName} sha1: ${SHA1sum}\n"; + } + +//{{{ begin code + ${code} +//}}} end code + + this->mixedFvPatchField<${TemplateType}>::updateCoeffs(); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/etc/codeTemplates/dynamicCode/mixedFvPatchFieldTemplate.H b/etc/codeTemplates/dynamicCode/mixedFvPatchFieldTemplate.H new file mode 100644 index 0000000000..7c0b654618 --- /dev/null +++ b/etc/codeTemplates/dynamicCode/mixedFvPatchFieldTemplate.H @@ -0,0 +1,142 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011 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 . + +Description + Template for use with dynamic code generation of a + mixed fvPatchField. + + - without state + +SourceFiles + mixedFvPatchFieldTemplate.C + +\*---------------------------------------------------------------------------*/ + +#ifndef mixedFvPatchTemplate${FieldType}_H +#define mixedFvPatchTemplate${FieldType}_H + +#include "mixedFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + A templated FixedValueFvPatch +\*---------------------------------------------------------------------------*/ + +class ${typeName}FixedValueFvPatch${FieldType} +: + public mixedFvPatchField<${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}FixedValueFvPatch${FieldType} + ( + const fvPatch&, + const DimensionedField<${TemplateType}, volMesh>& + ); + + //- Construct from patch, internal field and dictionary + ${typeName}FixedValueFvPatch${FieldType} + ( + const fvPatch&, + const DimensionedField<${TemplateType}, volMesh>&, + const dictionary& + ); + + //- Construct by mapping a copy onto a new patch + ${typeName}FixedValueFvPatch${FieldType} + ( + const ${typeName}FixedValueFvPatch${FieldType}&, + const fvPatch&, + const DimensionedField<${TemplateType}, volMesh>&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + ${typeName}FixedValueFvPatch${FieldType} + ( + const ${typeName}FixedValueFvPatch${FieldType}& + ); + + //- Construct and return a clone + virtual tmp< fvPatch${FieldType} > clone() const + { + return tmp< fvPatch${FieldType} > + ( + new ${typeName}FixedValueFvPatch${FieldType}(*this) + ); + } + + //- Construct as copy setting internal field reference + ${typeName}FixedValueFvPatch${FieldType} + ( + const ${typeName}FixedValueFvPatch${FieldType}&, + const DimensionedField<${TemplateType}, volMesh>& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp< fvPatch${FieldType} > clone + ( + const DimensionedField<${TemplateType}, volMesh>& iF + ) const + { + return tmp< fvPatch${FieldType} > + ( + new ${typeName}FixedValueFvPatch${FieldType}(*this, iF) + ); + } + + + //- Destructor + virtual ~${typeName}FixedValueFvPatch${FieldType}(); + + + // Member functions + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files index 14de7bc1e7..f887555f19 100644 --- a/src/finiteVolume/Make/files +++ b/src/finiteVolume/Make/files @@ -116,6 +116,7 @@ derivedFvPatchFields = $(fvPatchFields)/derived $(derivedFvPatchFields)/activeBaffleVelocity/activeBaffleVelocityFvPatchVectorField.C $(derivedFvPatchFields)/activePressureForceBaffleVelocity/activePressureForceBaffleVelocityFvPatchVectorField.C $(derivedFvPatchFields)/advective/advectiveFvPatchFields.C +$(derivedFvPatchFields)/codedMixed/codedMixedFvPatchFields.C $(derivedFvPatchFields)/codedFixedValue/codedFixedValueFvPatchFields.C $(derivedFvPatchFields)/mappedField/mappedFieldFvPatchFields.C $(derivedFvPatchFields)/mappedFixedInternalValue/mappedFixedInternalValueFvPatchFields.C diff --git a/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchField.C new file mode 100644 index 0000000000..80ff420632 --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchField.C @@ -0,0 +1,356 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011 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 . + +\*---------------------------------------------------------------------------*/ + +#include "codedMixedFvPatchField.H" +#include "addToRunTimeSelectionTable.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "dynamicCode.H" +#include "dynamicCodeContext.H" +#include "stringOps.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +template +const Foam::word Foam::codedMixedFvPatchField::codeTemplateC + = "mixedFvPatchFieldTemplate.C"; + +template +const Foam::word Foam::codedMixedFvPatchField::codeTemplateH + = "mixedFvPatchFieldTemplate.H"; + + +// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // + +template +void Foam::codedMixedFvPatchField::setFieldTemplates +( + dynamicCode& dynCode +) +{ + word fieldType(pTraits::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 * * * * * * * * * * * // + +template +const Foam::IOdictionary& Foam::codedMixedFvPatchField::dict() const +{ + const objectRegistry& obr = this->db(); + + if (obr.foundObject("codeDict")) + { + return obr.lookupObject("codeDict"); + } + else + { + return obr.store + ( + new IOdictionary + ( + IOobject + ( + "codeDict", + this->db().time().system(), + this->db(), + IOobject::MUST_READ_IF_MODIFIED, + IOobject::NO_WRITE + ) + ) + ); + } +} + + +template +Foam::dlLibraryTable& Foam::codedMixedFvPatchField::libs() const +{ + return const_cast(this->db().time().libs()); +} + + +template +void Foam::codedMixedFvPatchField::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 fvPatchField) + 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 +const Foam::dictionary& Foam::codedMixedFvPatchField::codeDict() +const +{ + // use system/codeDict or in-line + return + ( + dict_.found("code") + ? dict_ + : this->dict().subDict(redirectType_) + ); +} + + +template +Foam::string Foam::codedMixedFvPatchField::description() const +{ + return + "patch " + + this->patch().name() + + " on field " + + this->dimensionedInternalField().name(); +} + + +template +void Foam::codedMixedFvPatchField::clearRedirect() const +{ + // remove instantiation of fvPatchField provided by library + redirectPatchFieldPtr_.clear(); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +Foam::codedMixedFvPatchField::codedMixedFvPatchField +( + const fvPatch& p, + const DimensionedField& iF +) +: + mixedFvPatchField(p, iF), + codedBase(), + redirectPatchFieldPtr_() +{} + + +template +Foam::codedMixedFvPatchField::codedMixedFvPatchField +( + const codedMixedFvPatchField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + mixedFvPatchField(ptf, p, iF, mapper), + codedBase(), + dict_(ptf.dict_), + redirectType_(ptf.redirectType_), + redirectPatchFieldPtr_() +{} + + +template +Foam::codedMixedFvPatchField::codedMixedFvPatchField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + mixedFvPatchField(p, iF, dict), + codedBase(), + dict_(dict), + redirectType_(dict.lookup("redirectType")), + redirectPatchFieldPtr_() +{ + updateLibrary(redirectType_); +} + + +template +Foam::codedMixedFvPatchField::codedMixedFvPatchField +( + const codedMixedFvPatchField& ptf +) +: + mixedFvPatchField(ptf), + codedBase(), + dict_(ptf.dict_), + redirectType_(ptf.redirectType_), + redirectPatchFieldPtr_() +{} + + +template +Foam::codedMixedFvPatchField::codedMixedFvPatchField +( + const codedMixedFvPatchField& ptf, + const DimensionedField& iF +) +: + mixedFvPatchField(ptf, iF), + codedBase(), + dict_(ptf.dict_), + redirectType_(ptf.redirectType_), + redirectPatchFieldPtr_() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +const Foam::mixedFvPatchField& +Foam::codedMixedFvPatchField::redirectPatchField() const +{ + 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; + mixedFvPatchField::write(os); + IStringStream is(os.str()); + // Construct dictionary from it. + dictionary dict(is); + + // Override the type to enforce the fvPatchField::New constructor + // to choose our type + dict.set("type", redirectType_); + + redirectPatchFieldPtr_.set + ( + dynamic_cast*> + ( + fvPatchField::New + ( + this->patch(), + this->dimensionedInternalField(), + dict + ).ptr() + ) + ); + } + return redirectPatchFieldPtr_(); +} + + +template +void Foam::codedMixedFvPatchField::updateCoeffs() +{ + if (this->updated()) + { + return; + } + + // Make sure library containing user-defined fvPatchField is up-to-date + updateLibrary(redirectType_); + + const mixedFvPatchField& fvp = redirectPatchField(); + + const_cast&>(fvp).updateCoeffs(); + + // Copy through coefficients + this->refValue() = fvp.refValue(); + this->refGrad() = fvp.refGrad(); + this->valueFraction() = fvp.valueFraction(); + + mixedFvPatchField::updateCoeffs(); +} + + +template +void Foam::codedMixedFvPatchField::evaluate +( + const Pstream::commsTypes commsType +) +{ + // Make sure library containing user-defined fvPatchField is up-to-date + updateLibrary(redirectType_); + + const mixedFvPatchField& fvp = redirectPatchField(); + + // - updates the value of fvp (though not used) + // - resets the updated() flag + const_cast&>(fvp).evaluate(commsType); + + // Update the value (using the coefficients) locally + mixedFvPatchField::evaluate(commsType); +} + + +template +void Foam::codedMixedFvPatchField::write(Ostream& os) const +{ + mixedFvPatchField::write(os); + os.writeKeyword("redirectType") << redirectType_ + << 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; + } +} + + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchField.H new file mode 100644 index 0000000000..40038efeed --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchField.H @@ -0,0 +1,249 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011 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 . + +Class + Foam::codedMixedFvPatchField + +Description + Constructs on-the-fly a new boundary condition (derived from + mixedFvPatchField) which is then used to evaluate. + + Example: + \verbatim + movingWall + { + type codedMixed; + value uniform 0; + redirectType rampedMixed; // 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 + rampedMixed + { + code + #{ + operator==(min(10, 0.1*this->db().time().value())); + #}; + } + \endverbatim + +SeeAlso + Foam::dynamicCode and Foam::functionEntries::codeStream + +SourceFiles + codedMixedFvPatchField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef codedMixedFvPatchField_H +#define codedMixedFvPatchField_H + +#include "mixedFvPatchFields.H" +#include "codedBase.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of classes +class dynamicCode; +class dynamicCodeContext; +class IOdictionary; + +/*---------------------------------------------------------------------------*\ + Class codedMixedFvPatch Declaration +\*---------------------------------------------------------------------------*/ + +template +class codedMixedFvPatchField +: + public mixedFvPatchField, + public codedBase +{ + // Private data + + //- Dictionary contents for the boundary condition + mutable dictionary dict_; + + const word redirectType_; + + mutable autoPtr > 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("codedMixed"); + + + // Constructors + + //- Construct from patch and internal field + codedMixedFvPatchField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + codedMixedFvPatchField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given codedMixedFvPatchField + // onto a new patch + codedMixedFvPatchField + ( + const codedMixedFvPatchField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + codedMixedFvPatchField + ( + const codedMixedFvPatchField& + ); + + //- Construct and return a clone + virtual tmp > clone() const + { + return tmp > + ( + new codedMixedFvPatchField(*this) + ); + } + + //- Construct as copy setting internal field reference + codedMixedFvPatchField + ( + const codedMixedFvPatchField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp > clone + ( + const DimensionedField& iF + ) const + { + return tmp > + ( + new codedMixedFvPatchField(*this, iF) + ); + } + + + + + // Member functions + + //- Get reference to the underlying patchField + const mixedFvPatchField& redirectPatchField() const; + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + //- Evaluate the patch field + // This is only needed to set the updated() flag of the redirectType + // to false. + virtual void evaluate + ( + const Pstream::commsTypes commsType=Pstream::blocking + ); + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "codedMixedFvPatchField.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchFields.C b/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchFields.C new file mode 100644 index 0000000000..3a84911fb8 --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchFields.C @@ -0,0 +1,43 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011 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 . + +\*---------------------------------------------------------------------------*/ + +#include "codedMixedFvPatchFields.H" +#include "addToRunTimeSelectionTable.H" +#include "volFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +makePatchFields(codedMixed); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchFields.H b/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchFields.H new file mode 100644 index 0000000000..a4ef604fba --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchFields.H @@ -0,0 +1,49 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011 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 . + +\*---------------------------------------------------------------------------*/ + +#ifndef codedMixedFvPatchFields_H +#define codedMixedFvPatchFields_H + +#include "codedMixedFvPatchField.H" +#include "fieldTypes.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeFieldTypedefs(codedMixed); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchFieldsFwd.H b/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchFieldsFwd.H new file mode 100644 index 0000000000..b4011445c4 --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchFieldsFwd.H @@ -0,0 +1,50 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011 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 . + +\*---------------------------------------------------------------------------*/ + +#ifndef codedMixedFvPatchFieldsFwd_H +#define codedMixedFvPatchFieldsFwd_H + +#include "fieldTypes.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template class codedMixedFvPatchField; + +makePatchTypeFieldTypedefs(codedMixed); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* //