From 2f2dcdcf6f133f3bf161af71ce06143afa0a1626 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 12 Nov 2020 10:16:06 +0100 Subject: [PATCH] ENH: Function1 and PatchFunction1 improvements (#1917) - easier support for non-mandatory functions. In some boundary conditions it can be desirable to support additional functions, but not necessarily require them. Make this easier to support with a Function1, PatchFunction1 NewIfPresent() selector. - support for compatibility lookups - harmonize branching logic and error handling between Function1 and PatchFunction1. ENH: refactor a base class for Function1, PatchFunction1 - includes base characteristics, patch or scalar information ENH: additional creation macros - makeConcreteFunction1, makeConcretePatchFunction1Type for adding a non-templated function into the correct templated selection table. makeScalarPatchFunction1 for similarity with makeScalarFunction1 --- .../dynamicCode/codedPatchFunction1Template.C | 2 +- .../dynamicCode/codedPatchFunction1Template.H | 6 +- src/OpenFOAM/Make/files | 1 + .../Function1/Function1Expression.C | 2 +- .../Function1/Function1Expression.H | 21 +- .../primitives/functions/Function1/CSV/CSV.C | 17 +- .../primitives/functions/Function1/CSV/CSV.H | 3 + .../functions/Function1/Constant/Constant.C | 4 +- .../functions/Function1/Constant/Constant.H | 17 +- .../functions/Function1/Function1/Function1.C | 37 +-- .../functions/Function1/Function1/Function1.H | 123 ++++++---- .../Function1/Function1/Function1New.C | 150 +++++++++--- .../Function1/Function1/function1Base.C | 64 +++++ .../Function1/Function1/function1Base.H | 121 ++++++++++ .../functions/Function1/One/OneConstant.C | 2 +- .../functions/Function1/One/OneConstant.H | 12 +- .../PolynomialEntry/PolynomialEntry.C | 17 +- .../functions/Function1/Scale/Scale.C | 14 +- .../functions/Function1/Scale/Scale.H | 13 +- .../functions/Function1/Sine/Sine.C | 21 +- .../functions/Function1/Sine/Sine.H | 14 +- .../functions/Function1/Square/Square.C | 19 +- .../functions/Function1/Square/Square.H | 13 +- .../functions/Function1/Table/TableBase.C | 6 +- .../functions/Function1/Table/TableBase.H | 4 +- .../functions/Function1/TableFile/TableFile.H | 2 - .../functions/Function1/Zero/ZeroConstant.C | 2 +- .../functions/Function1/Zero/ZeroConstant.H | 12 +- .../Function1/quadraticRamp/quadraticRamp.H | 2 +- .../functions/Function1/ramp/ramp.C | 14 +- .../functions/Function1/ramp/ramp.H | 3 + .../PatchFunction1/PatchFunction1Expression.C | 9 +- .../PatchFunction1/PatchFunction1Expression.H | 14 +- .../derived/mappedField/Sampled/Sampled.C | 27 +-- .../derived/mappedField/Sampled/Sampled.H | 23 +- ...urfaceNormalFixedValueFvPatchVectorField.C | 9 +- ...niformNormalFixedValueFvPatchVectorField.C | 9 +- ...meVaryingMappedFixedValuePointPatchField.C | 7 +- src/meshTools/Make/files | 4 +- .../PatchFunction1/CodedField/CodedField.C | 9 +- .../PatchFunction1/CodedField/CodedField.H | 12 +- .../ConstantField/ConstantField.C | 83 ++++--- .../ConstantField/ConstantField.H | 24 +- .../PatchFunction1/MappedFile/MappedFile.C | 77 +++--- .../PatchFunction1/MappedFile/MappedFile.H | 26 ++- .../{ => PatchFunction1}/PatchFunction1.C | 71 ++---- .../{ => PatchFunction1}/PatchFunction1.H | 121 ++++++---- .../PatchFunction1/PatchFunction1New.C | 219 ++++++++++++++++++ .../PatchFunction1/patchFunction1Base.C | 88 +++++++ .../PatchFunction1/patchFunction1Base.H | 164 +++++++++++++ .../PatchFunction1/PatchFunction1New.C | 143 ------------ .../UniformValueField/UniformValueField.C | 17 +- .../UniformValueField/UniformValueField.H | 25 +- .../UniformValueField/UniformValueFieldI.H | 10 +- .../coordinateScaling.C | 0 .../coordinateScaling.H | 0 .../coordinateScalings.C} | 0 .../rigidBodyMeshMotion/rigidBodyMeshMotion.C | 14 +- 58 files changed, 1295 insertions(+), 648 deletions(-) create mode 100644 src/OpenFOAM/primitives/functions/Function1/Function1/function1Base.C create mode 100644 src/OpenFOAM/primitives/functions/Function1/Function1/function1Base.H rename src/meshTools/PatchFunction1/{ => PatchFunction1}/PatchFunction1.C (79%) rename src/meshTools/PatchFunction1/{ => PatchFunction1}/PatchFunction1.H (73%) create mode 100644 src/meshTools/PatchFunction1/PatchFunction1/PatchFunction1New.C create mode 100644 src/meshTools/PatchFunction1/PatchFunction1/patchFunction1Base.C create mode 100644 src/meshTools/PatchFunction1/PatchFunction1/patchFunction1Base.H delete mode 100644 src/meshTools/PatchFunction1/PatchFunction1New.C rename src/meshTools/PatchFunction1/{ => coordinateScaling}/coordinateScaling.C (100%) rename src/meshTools/PatchFunction1/{ => coordinateScaling}/coordinateScaling.H (100%) rename src/meshTools/PatchFunction1/{coordinateLabelScaling.C => coordinateScaling/coordinateScalings.C} (100%) diff --git a/etc/codeTemplates/dynamicCode/codedPatchFunction1Template.C b/etc/codeTemplates/dynamicCode/codedPatchFunction1Template.C index 79bc49b9ed..06e5eb00d7 100644 --- a/etc/codeTemplates/dynamicCode/codedPatchFunction1Template.C +++ b/etc/codeTemplates/dynamicCode/codedPatchFunction1Template.C @@ -90,7 +90,7 @@ ${typeName}PatchFunction1${FieldType}:: ${typeName}PatchFunction1${FieldType} ( const polyPatch& pp, - const word& type, + const word& redirectType, const word& entryName, const dictionary& dict, const bool faceValues diff --git a/etc/codeTemplates/dynamicCode/codedPatchFunction1Template.H b/etc/codeTemplates/dynamicCode/codedPatchFunction1Template.H index af479f3344..0aeaf7059e 100644 --- a/etc/codeTemplates/dynamicCode/codedPatchFunction1Template.H +++ b/etc/codeTemplates/dynamicCode/codedPatchFunction1Template.H @@ -75,7 +75,7 @@ public: ${typeName}PatchFunction1${FieldType} ( const polyPatch& pp, - const word& type, + const word& redirectType, const word& entryName, const dictionary& dict, const bool faceValues = true @@ -84,13 +84,13 @@ public: //- Copy construct ${typeName}PatchFunction1${FieldType} ( - const ${typeName}PatchFunction1${FieldType}& + const ${typeName}PatchFunction1${FieldType}& rhs ); //- Copy construct, resetting patch ${typeName}PatchFunction1${FieldType} ( - const ${typeName}PatchFunction1${FieldType}&, + const ${typeName}PatchFunction1${FieldType}& rhs, const polyPatch& pp ); diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files index 5706312424..5382d32670 100644 --- a/src/OpenFOAM/Make/files +++ b/src/OpenFOAM/Make/files @@ -106,6 +106,7 @@ primitives/septernion/septernion.C primitives/triad/triad.C /* Run-time selectable functions */ +primitives/functions/Function1/Function1/function1Base.C primitives/functions/Function1/makeFunction1s.C primitives/functions/Function1/ramp/ramp.C primitives/functions/Function1/step/stepFunction.C diff --git a/src/OpenFOAM/expressions/Function1/Function1Expression.C b/src/OpenFOAM/expressions/Function1/Function1Expression.C index 92b935381b..2575e0cb01 100644 --- a/src/OpenFOAM/expressions/Function1/Function1Expression.C +++ b/src/OpenFOAM/expressions/Function1/Function1Expression.C @@ -36,7 +36,7 @@ Foam::Function1Types::Function1Expression::Function1Expression const dictionary& dict ) : - Function1(entryName), + Function1(entryName, dict), dict_(dict), valueExpr_(), driver_(1, dict_) diff --git a/src/OpenFOAM/expressions/Function1/Function1Expression.H b/src/OpenFOAM/expressions/Function1/Function1Expression.H index d0f7f8f348..de3d101514 100644 --- a/src/OpenFOAM/expressions/Function1/Function1Expression.H +++ b/src/OpenFOAM/expressions/Function1/Function1Expression.H @@ -99,27 +99,22 @@ class Function1Expression mutable expressions::fieldExprDriver driver_; - // Private Member Functions - - //- No copy assignment - void operator=(const Function1Expression&) = delete; - - public: //- Runtime type information TypeName("expression"); + // Generated Methods + + //- No copy assignment + void operator=(const Function1Expression&) = delete; + + // Constructors - //- Construct from patch, entry name and dictionary - // The patch must correspond to an fvPatch! - Function1Expression - ( - const word& entryName, - const dictionary& dict - ); + //- Construct from entry name and dictionary + Function1Expression(const word& entryName, const dictionary& dict); //- Copy construct explicit Function1Expression(const Function1Expression& rhs); diff --git a/src/OpenFOAM/primitives/functions/Function1/CSV/CSV.C b/src/OpenFOAM/primitives/functions/Function1/CSV/CSV.C index 3ace21c0a6..1aaedfa1d5 100644 --- a/src/OpenFOAM/primitives/functions/Function1/CSV/CSV.C +++ b/src/OpenFOAM/primitives/functions/Function1/CSV/CSV.C @@ -250,13 +250,8 @@ const Foam::fileName& Foam::Function1Types::CSV::fName() const template -void Foam::Function1Types::CSV::writeData(Ostream& os) const +void Foam::Function1Types::CSV::writeEntries(Ostream& os) const { - Function1::writeData(os); - os.endEntry(); - - os.beginBlock(word(this->name() + "Coeffs")); - // Note: for TableBase write the dictionary entries it needs but not // the values themselves TableBase::writeEntries(os); @@ -273,7 +268,17 @@ void Foam::Function1Types::CSV::writeData(Ostream& os) const os.writeEntry("separator", string(separator_)); os.writeEntry("mergeSeparators", mergeSeparators_); os.writeEntry("file", fName_); +} + +template +void Foam::Function1Types::CSV::writeData(Ostream& os) const +{ + Function1::writeData(os); + os.endEntry(); + + os.beginBlock(word(this->name() + "Coeffs")); + writeEntries(os); os.endBlock(); } diff --git a/src/OpenFOAM/primitives/functions/Function1/CSV/CSV.H b/src/OpenFOAM/primitives/functions/Function1/CSV/CSV.H index e6025db72f..6b7a451a17 100644 --- a/src/OpenFOAM/primitives/functions/Function1/CSV/CSV.H +++ b/src/OpenFOAM/primitives/functions/Function1/CSV/CSV.H @@ -154,6 +154,9 @@ public: //- Write in dictionary format virtual void writeData(Ostream& os) const; + + //- Write coefficient entries in dictionary format + void writeEntries(Ostream& os) const; }; diff --git a/src/OpenFOAM/primitives/functions/Function1/Constant/Constant.C b/src/OpenFOAM/primitives/functions/Function1/Constant/Constant.C index 869dc2a1b8..36c85f7f71 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Constant/Constant.C +++ b/src/OpenFOAM/primitives/functions/Function1/Constant/Constant.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2015 OpenCFD Ltd. + Copyright (C) 2015-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -49,7 +49,7 @@ Foam::Function1Types::Constant::Constant const dictionary& dict ) : - Function1(entryName), + Function1(entryName, dict), value_(Zero) { Istream& is = dict.lookup(entryName); diff --git a/src/OpenFOAM/primitives/functions/Function1/Constant/Constant.H b/src/OpenFOAM/primitives/functions/Function1/Constant/Constant.H index e2b063aeef..978c39db31 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Constant/Constant.H +++ b/src/OpenFOAM/primitives/functions/Function1/Constant/Constant.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2015 OpenCFD Ltd. + Copyright (C) 2015-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -61,24 +61,25 @@ class Constant : public Function1 { - // Private data + // Private Data //- Constant value Type value_; - // Private Member Functions - - //- No copy assignment - void operator=(const Constant&) = delete; - - public: // Runtime type information TypeName("constant"); + + // Generated Methods + + //- No copy assignment + void operator=(const Constant&) = delete; + + // Constructors //- Construct from components diff --git a/src/OpenFOAM/primitives/functions/Function1/Function1/Function1.C b/src/OpenFOAM/primitives/functions/Function1/Function1/Function1.C index 266008530c..f635078a46 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Function1/Function1.C +++ b/src/OpenFOAM/primitives/functions/Function1/Function1/Function1.C @@ -36,32 +36,26 @@ License template Foam::Function1::Function1(const word& entryName) : - name_(entryName) + function1Base(entryName) +{} + + +template +Foam::Function1::Function1(const word& entryName, const dictionary& dict) +: + function1Base(entryName, dict) {} template Foam::Function1::Function1(const Function1& rhs) : - refCount(), - name_(rhs.name_) + function1Base(rhs) {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -template -const Foam::word& Foam::Function1::name() const -{ - return name_; -} - - -template -void Foam::Function1::convertTimeBase(const Time&) -{} - - template Type Foam::Function1::value(const scalar x) const { @@ -71,7 +65,8 @@ Type Foam::Function1::value(const scalar x) const template -Foam::tmp> Foam::Function1::value +Foam::tmp> +Foam::Function1::value ( const scalarField& x ) const @@ -90,7 +85,8 @@ Type Foam::Function1::integrate(const scalar x1, const scalar x2) const template -Foam::tmp> Foam::Function1::integrate +Foam::tmp> +Foam::Function1::integrate ( const scalarField& x1, const scalarField& x2 @@ -161,6 +157,11 @@ Foam::FieldFunction1::integrate } +template +void Foam::Function1::writeEntries(Ostream& os) const +{} + + template void Foam::Function1::writeData(Ostream& os) const { @@ -179,7 +180,7 @@ Foam::Ostream& Foam::operator<< { os.check(FUNCTION_NAME); - os << rhs.name_; + os << rhs.name(); rhs.writeData(os); return os; diff --git a/src/OpenFOAM/primitives/functions/Function1/Function1/Function1.H b/src/OpenFOAM/primitives/functions/Function1/Function1/Function1.H index 8ac9135b68..5ff592788b 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Function1/Function1.H +++ b/src/OpenFOAM/primitives/functions/Function1/Function1/Function1.H @@ -74,7 +74,7 @@ SourceFiles #ifndef Function1_H #define Function1_H -#include "dictionary.H" +#include "function1Base.H" #include "Field.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -94,16 +94,23 @@ template Ostream& operator<<(Ostream&, const Function1&); template class Function1 : - public refCount + public function1Base { + // Private Member Functions + + //- Selector, with alternative entry, fallback redirection, etc + static autoPtr> New + ( + const word& entryName, // Entry name for function + const entry* eptr, // Eg, dict.findEntry(entryName) + const dictionary& dict, + const word& redirectType, + const bool mandatory + ); + + protected: - // Protected Data - - //- Name of entry - const word name_; - - // Protected Member Functions //- No copy assignment @@ -136,20 +143,52 @@ public: //- Construct from entry name explicit Function1(const word& entryName); - //- Copy constructor + //- Construct from entry name and dictionary + Function1(const word& entryName, const dictionary& dict); + + //- Copy construct explicit Function1(const Function1& rhs); //- Construct and return a clone virtual tmp> clone() const = 0; - //- Selector - static autoPtr> New - ( - const word& entryName, - const dictionary& dict, - const word& redirectType = word::null - ); + // Selectors + + //- Selector, with fallback redirection + static autoPtr> New + ( + const word& entryName, + const dictionary& dict, + const word& redirectType, + const bool mandatory = true + ); + + //- Compatibility selector, with fallback redirection + static autoPtr> NewCompat + ( + const word& entryName, + std::initializer_list> compat, + const dictionary& dict, + const word& redirectType = word::null, + const bool mandatory = true + ); + + //- Selector, without fallback redirection + static autoPtr> New + ( + const word& entryName, + const dictionary& dict, + const bool mandatory = true + ); + + //- An optional selector + static autoPtr> NewIfPresent + ( + const word& entryName, + const dictionary& dict, + const word& redirectType = word::null + ); //- Destructor @@ -158,18 +197,6 @@ public: // Member Functions - // Access - - //- Return the name of the entry - const word& name() const; - - - // Manipulation - - //- Convert time - virtual void convertTimeBase(const Time& t); - - // Evaluation //- Return value as a function of (scalar) independent variable @@ -189,17 +216,22 @@ public: ) const; - // I/O + // I/O - //- Ostream Operator - friend Ostream& operator<< - ( - Ostream& os, - const Function1& func - ); + //- Ostream Operator + friend Ostream& operator<< + ( + Ostream& os, + const Function1& func + ); - //- Write in dictionary format - virtual void writeData(Ostream& os) const; + + //- Write in dictionary format. + // \note The base output is \em without an END_STATEMENT + virtual void writeData(Ostream& os) const; + + //- Write coefficient entries in dictionary format + void writeEntries(Ostream& os) const; }; @@ -212,7 +244,6 @@ class FieldFunction1 : public Function1Type { - public: typedef typename Function1Type::returnType Type; @@ -256,6 +287,7 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// Define Function1 run-time selection #define makeFunction1(Type) \ \ defineNamedTemplateTypeNameAndDebug(Function1, 0); \ @@ -267,6 +299,7 @@ public: ); +// Define (templated) Function1, add to (templated) run-time selection #define makeFunction1Type(SS, Type) \ \ defineNamedTemplateTypeNameAndDebug(Function1Types::SS, 0); \ @@ -276,12 +309,20 @@ public: add##SS##Type##ConstructorToTable_; -#define makeScalarFunction1(SS) \ +// Define a non-templated Function1 and add to (templated) run-time selection +#define makeConcreteFunction1(SS, Type) \ \ defineTypeNameAndDebug(SS, 0); \ \ - Function1::adddictionaryConstructorToTable> \ - add##SS##ConstructorToTable_; + Function1::adddictionaryConstructorToTable \ + > \ + add##SS##Type##ConstructorToTable_; + + +// Define scalar Function1 and add to (templated) run-time selection +#define makeScalarFunction1(SS) \ + \ + makeConcreteFunction1(SS, scalar); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/primitives/functions/Function1/Function1/Function1New.C b/src/OpenFOAM/primitives/functions/Function1/Function1/Function1New.C index 85084f82a2..3f01384ce7 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Function1/Function1New.C +++ b/src/OpenFOAM/primitives/functions/Function1/Function1/Function1New.C @@ -35,59 +35,43 @@ Foam::autoPtr> Foam::Function1::New ( const word& entryName, + const entry* eptr, const dictionary& dict, - const word& redirectType + const word& redirectType, + const bool mandatory ) { word modelType(redirectType); - const entry* eptr = dict.findEntry(entryName, keyType::LITERAL); + const dictionary* coeffs = (eptr ? eptr->dictPtr() : nullptr); - if (!eptr) + if (coeffs) { - if (modelType.empty()) - { - FatalIOErrorInFunction(dict) - << "No Function1 dictionary entry: " - << entryName << nl << nl - << exit(FatalIOError); - } - } - else if (eptr->isDict()) - { - const dictionary& coeffsDict = eptr->dict(); + // Dictionary entry - coeffsDict.readEntry + coeffs->readEntry ( "type", modelType, keyType::LITERAL, - redirectType.empty() // mandatory when redirectType is empty + modelType.empty() // "type" entry is mandatory if no 'redirect' ); - auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); - - if (!cstrIter.found()) - { - FatalIOErrorInFunction(dict) - << "Unknown Function1 type " - << modelType << " for " << entryName - << "\n\nValid Function1 types :\n" - << dictionaryConstructorTablePtr_->sortedToc() << nl - << exit(FatalIOError); - } - - return cstrIter()(entryName, coeffsDict); + // Fallthrough } - else + else if (eptr) { + // Primitive entry + // - non-word : value for constant function + // - word : the modelType + Istream& is = eptr->stream(); token firstToken(is); if (!firstToken.isWord()) { - // Backwards-compatibility for reading straight fields + // A value is.putBack(firstToken); const Type constValue = pTraits(is); @@ -97,8 +81,40 @@ Foam::Function1::New new Function1Types::Constant(entryName, constValue) ); } + else + { + modelType = firstToken.wordToken(); + } - modelType = firstToken.wordToken(); + // Fallthrough + } + + + if (modelType.empty()) + { + // Entry missing + + if (mandatory) + { + FatalIOErrorInFunction(dict) + << "Missing or invalid Function1 entry: " + << entryName << nl + << exit(FatalIOError); + } + + return nullptr; + } + else if (!coeffs) + { + // Primitive entry. Coeffs dictionary is optional. + // Use keyword() - not entryName - for compatibility lookup! + + coeffs = + &dict.optionalSubDict + ( + eptr->keyword() + "Coeffs", + keyType::LITERAL + ); } @@ -114,12 +130,78 @@ Foam::Function1::New << exit(FatalIOError); } - return cstrIter() + return cstrIter()(entryName, *coeffs); +} + + +template +Foam::autoPtr> +Foam::Function1::New +( + const word& entryName, + const dictionary& dict, + const word& redirectType, + const bool mandatory +) +{ + return Function1::New ( entryName, - dict.optionalSubDict(entryName + "Coeffs") + dict.findEntry(entryName, keyType::LITERAL), + dict, + redirectType, + mandatory ); } +template +Foam::autoPtr> +Foam::Function1::NewCompat +( + const word& entryName, + std::initializer_list> compat, + const dictionary& dict, + const word& redirectType, + const bool mandatory +) +{ + return Function1::New + ( + entryName, + dict.findCompat(entryName, compat, keyType::LITERAL), + dict, + redirectType, + mandatory + ); +} + + +template +Foam::autoPtr> +Foam::Function1::New +( + const word& entryName, + const dictionary& dict, + const bool mandatory +) +{ + return Function1::New(entryName, dict, word::null, mandatory); +} + + +template +Foam::autoPtr> +Foam::Function1::NewIfPresent +( + const word& entryName, + const dictionary& dict, + const word& redirectType +) +{ + // mandatory = false + return Function1::New(entryName, dict, redirectType, false); +} + + // ************************************************************************* // diff --git a/src/OpenFOAM/primitives/functions/Function1/Function1/function1Base.C b/src/OpenFOAM/primitives/functions/Function1/Function1/function1Base.C new file mode 100644 index 0000000000..c4a6e0a194 --- /dev/null +++ b/src/OpenFOAM/primitives/functions/Function1/Function1/function1Base.C @@ -0,0 +1,64 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "function1Base.H" +#include "Time.H" + +// * * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * // + +Foam::function1Base::function1Base(const word& entryName) +: + refCount(), + name_(entryName) +{} + + +Foam::function1Base::function1Base +( + const word& entryName, + const dictionary& dict +) +: + refCount(), + name_(entryName) +{} + + +Foam::function1Base::function1Base(const function1Base& rhs) +: + refCount(), + name_(rhs.name_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::function1Base::convertTimeBase(const Time& t) +{} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/primitives/functions/Function1/Function1/function1Base.H b/src/OpenFOAM/primitives/functions/Function1/Function1/function1Base.H new file mode 100644 index 0000000000..4aa9bf68ea --- /dev/null +++ b/src/OpenFOAM/primitives/functions/Function1/Function1/function1Base.H @@ -0,0 +1,121 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::function1Base + +Description + Top level data entry class for use in dictionaries. Provides a mechanism + to specify a variable as a certain type, e.g. constant or time varying, and + provide functions to return the (interpolated) value, and integral between + limits. + + Extends the Function1 class by adding autoMap and rMap functions + +SourceFiles + function1Base.C + +\*---------------------------------------------------------------------------*/ + +#ifndef function1Base_H +#define function1Base_H + +#include "dictionary.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward Declarations +class Time; + +/*---------------------------------------------------------------------------*\ + Class function1Base Declaration +\*---------------------------------------------------------------------------*/ + +class function1Base +: + public refCount +{ +protected: + + // Protected Data + + //- Name of entry + const word name_; + + + // Protected Member Functions + + //- No copy assignment + void operator=(const function1Base&) = delete; + + +public: + + // Constructors + + //- Construct from entry name + explicit function1Base(const word& entryName); + + //- Construct from entry name and dictionary + function1Base(const word& entryName, const dictionary& dict); + + //- Copy construct + explicit function1Base(const function1Base& rhs); + + + //- Destructor + virtual ~function1Base() = default; + + + // Member Functions + + // Access + + //- The name of the entry + const word& name() const + { + return name_; + } + + + // Manipulation + + //- Convert time + virtual void convertTimeBase(const Time& t); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/primitives/functions/Function1/One/OneConstant.C b/src/OpenFOAM/primitives/functions/Function1/One/OneConstant.C index 4c121a5249..f95259c446 100644 --- a/src/OpenFOAM/primitives/functions/Function1/One/OneConstant.C +++ b/src/OpenFOAM/primitives/functions/Function1/One/OneConstant.C @@ -43,7 +43,7 @@ Foam::Function1Types::OneConstant::OneConstant const dictionary& dict ) : - Function1(entryName) + Function1(entryName, dict) {} diff --git a/src/OpenFOAM/primitives/functions/Function1/One/OneConstant.H b/src/OpenFOAM/primitives/functions/Function1/One/OneConstant.H index f883624b41..9c19abc14b 100644 --- a/src/OpenFOAM/primitives/functions/Function1/One/OneConstant.H +++ b/src/OpenFOAM/primitives/functions/Function1/One/OneConstant.H @@ -61,18 +61,18 @@ class OneConstant : public Function1 { - // Private Member Functions - - //- No copy assignment - void operator=(const OneConstant&) = delete; - - public: //- Runtime type information TypeName("one"); + // Generated Methods + + //- No copy assignment + void operator=(const OneConstant&) = delete; + + // Constructors //- Construct from entry name diff --git a/src/OpenFOAM/primitives/functions/Function1/PolynomialEntry/PolynomialEntry.C b/src/OpenFOAM/primitives/functions/Function1/PolynomialEntry/PolynomialEntry.C index c82b62c628..a219703556 100644 --- a/src/OpenFOAM/primitives/functions/Function1/PolynomialEntry/PolynomialEntry.C +++ b/src/OpenFOAM/primitives/functions/Function1/PolynomialEntry/PolynomialEntry.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -36,7 +37,7 @@ Foam::Function1Types::Polynomial::Polynomial const dictionary& dict ) : - Function1(entryName), + Function1(entryName, dict), coeffs_(), canIntegrate_(true) { @@ -48,8 +49,9 @@ Foam::Function1Types::Polynomial::Polynomial if (!coeffs_.size()) { FatalErrorInFunction - << "Polynomial coefficients for entry " << this->name_ - << " are invalid (empty)" << nl << exit(FatalError); + << "Invalid (empty) polynomial coefficients for " + << this->name() << nl + << exit(FatalError); } forAll(coeffs_, i) @@ -66,7 +68,7 @@ Foam::Function1Types::Polynomial::Polynomial if (!canIntegrate_) { WarningInFunction - << "Polynomial " << this->name_ << " cannot be integrated" + << "Polynomial " << this->name() << " cannot be integrated" << endl; } } @@ -87,8 +89,9 @@ Foam::Function1Types::Polynomial::Polynomial if (!coeffs_.size()) { FatalErrorInFunction - << "Polynomial coefficients for entry " << this->name_ - << " are invalid (empty)" << nl << exit(FatalError); + << "Invalid (empty) polynomial coefficients for " + << this->name() << nl + << exit(FatalError); } forAll(coeffs_, i) @@ -105,7 +108,7 @@ Foam::Function1Types::Polynomial::Polynomial if (!canIntegrate_) { WarningInFunction - << "Polynomial " << this->name_ << " cannot be integrated" + << "Polynomial " << this->name() << " cannot be integrated" << endl; } } diff --git a/src/OpenFOAM/primitives/functions/Function1/Scale/Scale.C b/src/OpenFOAM/primitives/functions/Function1/Scale/Scale.C index a5d71d884a..76bb810eee 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Scale/Scale.C +++ b/src/OpenFOAM/primitives/functions/Function1/Scale/Scale.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2017 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -61,6 +62,14 @@ Foam::Function1Types::Scale::Scale(const Scale& rhs) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +template +void Foam::Function1Types::Scale::writeEntries(Ostream& os) const +{ + scale_->writeData(os); + value_->writeData(os); +} + + template void Foam::Function1Types::Scale::writeData(Ostream& os) const { @@ -68,10 +77,7 @@ void Foam::Function1Types::Scale::writeData(Ostream& os) const os << token::END_STATEMENT << nl; os.beginBlock(word(this->name() + "Coeffs")); - - scale_->writeData(os); - value_->writeData(os); - + writeEntries(os); os.endBlock(); } diff --git a/src/OpenFOAM/primitives/functions/Function1/Scale/Scale.H b/src/OpenFOAM/primitives/functions/Function1/Scale/Scale.H index 22efae6afd..86186109cd 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Scale/Scale.H +++ b/src/OpenFOAM/primitives/functions/Function1/Scale/Scale.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2017 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -106,9 +107,6 @@ class Scale //- Read the coefficients from the given dictionary void read(const dictionary& coeffs); - //- No copy assignment - void operator=(const Scale&) = delete; - public: @@ -116,6 +114,12 @@ public: TypeName("scale"); + // Generated Methods + + //- No copy assignment + void operator=(const Scale&) = delete; + + // Constructors //- Construct from entry name and dictionary @@ -140,6 +144,9 @@ public: //- Write in dictionary format virtual void writeData(Ostream& os) const; + + //- Write coefficient entries in dictionary format + void writeEntries(Ostream& os) const; }; diff --git a/src/OpenFOAM/primitives/functions/Function1/Sine/Sine.C b/src/OpenFOAM/primitives/functions/Function1/Sine/Sine.C index f592100361..38948f029c 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Sine/Sine.C +++ b/src/OpenFOAM/primitives/functions/Function1/Sine/Sine.C @@ -48,7 +48,7 @@ Foam::Function1Types::Sine::Sine const dictionary& dict ) : - Function1(entryName) + Function1(entryName, dict) { read(dict); } @@ -68,6 +68,17 @@ Foam::Function1Types::Sine::Sine(const Sine& se) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +template +void Foam::Function1Types::Sine::writeEntries(Ostream& os) const +{ + os.writeEntry("t0", t0_); + amplitude_->writeData(os); + frequency_->writeData(os); + scale_->writeData(os); + level_->writeData(os); +} + + template void Foam::Function1Types::Sine::writeData(Ostream& os) const { @@ -75,13 +86,7 @@ void Foam::Function1Types::Sine::writeData(Ostream& os) const os.endEntry(); os.beginBlock(word(this->name() + "Coeffs")); - - os.writeEntry("t0", t0_); - amplitude_->writeData(os); - frequency_->writeData(os); - scale_->writeData(os); - level_->writeData(os); - + writeEntries(os); os.endBlock(); } diff --git a/src/OpenFOAM/primitives/functions/Function1/Sine/Sine.H b/src/OpenFOAM/primitives/functions/Function1/Sine/Sine.H index 200f9dc19d..746385a04c 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Sine/Sine.H +++ b/src/OpenFOAM/primitives/functions/Function1/Sine/Sine.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2016-2017 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -118,16 +119,18 @@ class Sine //- Read the coefficients from the given dictionary void read(const dictionary& coeffs); - //- No copy assignment - void operator=(const Sine&) = delete; - - public: // Runtime type information TypeName("sine"); + // Generated Methods + + //- No copy assignment + void operator=(const Sine&) = delete; + + // Constructors //- Construct from entry name and dictionary @@ -152,6 +155,9 @@ public: //- Write in dictionary format virtual void writeData(Ostream& os) const; + + //- Write coefficient entries in dictionary format + void writeEntries(Ostream& os) const; }; diff --git a/src/OpenFOAM/primitives/functions/Function1/Square/Square.C b/src/OpenFOAM/primitives/functions/Function1/Square/Square.C index 93715bdfe6..0016bbb5ec 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Square/Square.C +++ b/src/OpenFOAM/primitives/functions/Function1/Square/Square.C @@ -49,7 +49,7 @@ Foam::Function1Types::Square::Square const dictionary& dict ) : - Function1(entryName) + Function1(entryName, dict) { read(dict); } @@ -71,20 +71,25 @@ Foam::Function1Types::Square::Square(const Square& se) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template -void Foam::Function1Types::Square::writeData(Ostream& os) const +void Foam::Function1Types::Square::writeEntries(Ostream& os) const { - Function1::writeData(os); - os.endEntry(); - - os.beginBlock(word(this->name() + "Coeffs")); - os.writeEntry("t0", t0_); os.writeEntry("markSpace", markSpace_); amplitude_->writeData(os); frequency_->writeData(os); scale_->writeData(os); level_->writeData(os); +} + +template +void Foam::Function1Types::Square::writeData(Ostream& os) const +{ + Function1::writeData(os); + os.endEntry(); + + os.beginBlock(word(this->name() + "Coeffs")); + writeEntries(os); os.endBlock(); } diff --git a/src/OpenFOAM/primitives/functions/Function1/Square/Square.H b/src/OpenFOAM/primitives/functions/Function1/Square/Square.H index 08bc6984f9..a0055da1ac 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Square/Square.H +++ b/src/OpenFOAM/primitives/functions/Function1/Square/Square.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2016-2017 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -125,9 +126,6 @@ class Square //- Read the coefficients from the given dictionary void read(const dictionary& coeffs); - //- No copy assignment - void operator=(const Square&) = delete; - public: @@ -135,6 +133,12 @@ public: TypeName("square"); + // Generated Methods + + //- No copy assignment + void operator=(const Square&) = delete; + + // Constructors //- Construct from entry name and dictionary @@ -159,6 +163,9 @@ public: //- Write in dictionary format virtual void writeData(Ostream& os) const; + + //- Write coefficient entries in dictionary format + void writeEntries(Ostream& os) const; }; diff --git a/src/OpenFOAM/primitives/functions/Function1/Table/TableBase.C b/src/OpenFOAM/primitives/functions/Function1/Table/TableBase.C index 114dac54c4..8c1fdb2595 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Table/TableBase.C +++ b/src/OpenFOAM/primitives/functions/Function1/Table/TableBase.C @@ -65,8 +65,7 @@ Foam::Function1Types::TableBase::TableBase const dictionary& dict ) : - Function1(name), - name_(name), + Function1(name, dict), bounding_ ( bounds::repeatableBoundingNames.getOrDefault @@ -91,7 +90,6 @@ template Foam::Function1Types::TableBase::TableBase(const TableBase& tbl) : Function1(tbl), - name_(tbl.name_), bounding_(tbl.bounding_), interpolationScheme_(tbl.interpolationScheme_), table_(tbl.table_), @@ -115,7 +113,7 @@ void Foam::Function1Types::TableBase::check() const if (!table_.size()) { FatalErrorInFunction - << "Table for entry " << this->name_ << " is invalid (empty)" + << "Table for entry " << this->name() << " is invalid (empty)" << nl << exit(FatalError); } diff --git a/src/OpenFOAM/primitives/functions/Function1/Table/TableBase.H b/src/OpenFOAM/primitives/functions/Function1/Table/TableBase.H index ce324b91d2..82361382bd 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Table/TableBase.H +++ b/src/OpenFOAM/primitives/functions/Function1/Table/TableBase.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -65,9 +66,6 @@ protected: // Protected Data - //- Table name - const word name_; - //- Handling for out-of-bound values const bounds::repeatableBounding bounding_; diff --git a/src/OpenFOAM/primitives/functions/Function1/TableFile/TableFile.H b/src/OpenFOAM/primitives/functions/Function1/TableFile/TableFile.H index d588b8eed4..76d210a786 100644 --- a/src/OpenFOAM/primitives/functions/Function1/TableFile/TableFile.H +++ b/src/OpenFOAM/primitives/functions/Function1/TableFile/TableFile.H @@ -59,9 +59,7 @@ SourceFiles #ifndef TableFile_H #define TableFile_H -#include "Function1.H" #include "TableBase.H" -#include "Tuple2.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/primitives/functions/Function1/Zero/ZeroConstant.C b/src/OpenFOAM/primitives/functions/Function1/Zero/ZeroConstant.C index d043ad1338..591e430f62 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Zero/ZeroConstant.C +++ b/src/OpenFOAM/primitives/functions/Function1/Zero/ZeroConstant.C @@ -44,7 +44,7 @@ Foam::Function1Types::ZeroConstant::ZeroConstant const dictionary& dict ) : - Function1(entryName) + Function1(entryName, dict) {} diff --git a/src/OpenFOAM/primitives/functions/Function1/Zero/ZeroConstant.H b/src/OpenFOAM/primitives/functions/Function1/Zero/ZeroConstant.H index 88c79e1e4c..2393d949dc 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Zero/ZeroConstant.H +++ b/src/OpenFOAM/primitives/functions/Function1/Zero/ZeroConstant.H @@ -61,18 +61,18 @@ class ZeroConstant : public Function1 { - // Private Member Functions - - //- No copy assignment - void operator=(const ZeroConstant&) = delete; - - public: //- Runtime type information TypeName("zero"); + // Generated Methods + + //- No copy assignment + void operator=(const ZeroConstant&) = delete; + + // Constructors //- Construct from entry name diff --git a/src/OpenFOAM/primitives/functions/Function1/quadraticRamp/quadraticRamp.H b/src/OpenFOAM/primitives/functions/Function1/quadraticRamp/quadraticRamp.H index 5de2c76084..8d4b6f524b 100644 --- a/src/OpenFOAM/primitives/functions/Function1/quadraticRamp/quadraticRamp.H +++ b/src/OpenFOAM/primitives/functions/Function1/quadraticRamp/quadraticRamp.H @@ -29,7 +29,7 @@ Class Description Quadratic ramp function starting from 0 and increasing quadratically - to 1 from \c t_0 over the \c duration and remaining at 1 thereafter. + to 1 from \c start over the \c duration and remaining at 1 thereafter. See also Foam::Function1Types::ramp diff --git a/src/OpenFOAM/primitives/functions/Function1/ramp/ramp.C b/src/OpenFOAM/primitives/functions/Function1/ramp/ramp.C index 8b3999861c..9570edb905 100644 --- a/src/OpenFOAM/primitives/functions/Function1/ramp/ramp.C +++ b/src/OpenFOAM/primitives/functions/Function1/ramp/ramp.C @@ -43,7 +43,7 @@ Foam::Function1Types::ramp::ramp const dictionary& dict ) : - Function1(entryName) + Function1(entryName, dict) { read(dict); } @@ -51,16 +51,20 @@ Foam::Function1Types::ramp::ramp // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +void Foam::Function1Types::ramp::writeEntries(Ostream& os) const +{ + os.writeEntry("start", start_); + os.writeEntry("duration", duration_); +} + + void Foam::Function1Types::ramp::writeData(Ostream& os) const { Function1::writeData(os); os << token::END_STATEMENT << nl; os.beginBlock(word(this->name() + "Coeffs")); - - os.writeEntry("start", start_); - os.writeEntry("duration", duration_); - + writeEntries(os); os.endBlock(); } diff --git a/src/OpenFOAM/primitives/functions/Function1/ramp/ramp.H b/src/OpenFOAM/primitives/functions/Function1/ramp/ramp.H index 768caa21bf..339da7de4e 100644 --- a/src/OpenFOAM/primitives/functions/Function1/ramp/ramp.H +++ b/src/OpenFOAM/primitives/functions/Function1/ramp/ramp.H @@ -138,6 +138,9 @@ public: //- Write in dictionary format virtual void writeData(Ostream& os) const; + + //- Write coefficient entries in dictionary format + void writeEntries(Ostream& os) const; }; diff --git a/src/finiteVolume/expressions/PatchFunction1/PatchFunction1Expression.C b/src/finiteVolume/expressions/PatchFunction1/PatchFunction1Expression.C index 2ff54719b5..72211dba9e 100644 --- a/src/finiteVolume/expressions/PatchFunction1/PatchFunction1Expression.C +++ b/src/finiteVolume/expressions/PatchFunction1/PatchFunction1Expression.C @@ -34,7 +34,7 @@ template Foam::PatchFunction1Types::PatchExprField::PatchExprField ( const polyPatch& pp, - const word& type, + const word& redirectType, const word& entryName, const dictionary& dict, const bool faceValues @@ -72,10 +72,7 @@ Foam::PatchFunction1Types::PatchExprField::PatchExprField const PatchExprField& rhs ) : - PatchFunction1(rhs), - dict_(rhs.dict_), - valueExpr_(rhs.valueExpr_), - driver_(fvPatch::lookupPatch(this->patch()), rhs.driver_) + PatchExprField(rhs, rhs.patch()) {} @@ -156,7 +153,7 @@ void Foam::PatchFunction1Types::PatchExprField::writeData Ostream& os ) const { - // PatchFunction1-from-subdict so out dictionary contains + // PatchFunction1-from-subdict so output dictionary contains // only the relevant entries. dict_.writeEntry(this->name(), os); } diff --git a/src/finiteVolume/expressions/PatchFunction1/PatchFunction1Expression.H b/src/finiteVolume/expressions/PatchFunction1/PatchFunction1Expression.H index d8f8f1881a..4a66dbc669 100644 --- a/src/finiteVolume/expressions/PatchFunction1/PatchFunction1Expression.H +++ b/src/finiteVolume/expressions/PatchFunction1/PatchFunction1Expression.H @@ -97,18 +97,18 @@ class PatchExprField mutable expressions::patchExpr::parseDriver driver_; - // Private Member Functions - - //- No copy assignment - void operator=(const PatchExprField&) = delete; - - public: //- Runtime type information TypeName("expression"); + // Generated Methods + + //- No copy assignment + void operator=(const PatchExprField&) = delete; + + // Constructors //- Construct from patch, entry name and dictionary @@ -116,7 +116,7 @@ public: PatchExprField ( const polyPatch& pp, - const word& type, + const word& redirectType, const word& entryName, const dictionary& dict, const bool faceValues = true diff --git a/src/finiteVolume/fields/fvPatchFields/derived/mappedField/Sampled/Sampled.C b/src/finiteVolume/fields/fvPatchFields/derived/mappedField/Sampled/Sampled.C index 341636606a..5fbd999c1f 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/mappedField/Sampled/Sampled.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/mappedField/Sampled/Sampled.C @@ -53,7 +53,7 @@ template Foam::PatchFunction1Types::Sampled::Sampled ( const polyPatch& pp, - const word& type, + const word& redirectType, const word& entryName, const dictionary& dict, const bool faceValues @@ -76,31 +76,26 @@ Foam::PatchFunction1Types::Sampled::Sampled template Foam::PatchFunction1Types::Sampled::Sampled ( - const Sampled& ut + const Sampled& rhs ) : - PatchFunction1(ut), - mappedPatchBase(ut), - fieldName_(ut.fieldName_), - setAverage_(ut.setAverage_), - average_(ut.average_), - interpolationScheme_(ut.interpolationScheme_) + Sampled(rhs, rhs.patch()) {} template Foam::PatchFunction1Types::Sampled::Sampled ( - const Sampled& ut, + const Sampled& rhs, const polyPatch& pp ) : - PatchFunction1(ut, pp), - mappedPatchBase(pp, ut), - fieldName_(ut.fieldName_), - setAverage_(ut.setAverage_), - average_(ut.average_), - interpolationScheme_(ut.interpolationScheme_) + PatchFunction1(rhs, pp), + mappedPatchBase(pp, rhs), + fieldName_(rhs.fieldName_), + setAverage_(rhs.setAverage_), + average_(rhs.average_), + interpolationScheme_(rhs.interpolationScheme_) {} @@ -286,7 +281,7 @@ Foam::PatchFunction1Types::Sampled::value if (setAverage_ && returnReduce(newValues.size(), sumOp