Merge branch 'feature-functionObject-Function1' into 'develop'

Function1 objectRegistry access

See merge request Development/openfoam!499
This commit is contained in:
Mark Olesen
2021-11-26 11:24:13 +00:00
198 changed files with 3809 additions and 1104 deletions

View File

@ -123,7 +123,7 @@ Foam::fv::VoFSolidificationMeltingSource::VoFSolidificationMeltingSource
)
:
fv::cellSetOption(sourceName, modelType, dict, mesh),
alphaSolidT_(Function1<scalar>::New("alphaSolidT", coeffs_)),
alphaSolidT_(Function1<scalar>::New("alphaSolidT", coeffs_, &mesh)),
L_("L", dimEnergy/dimMass, coeffs_),
relax_(coeffs_.getOrDefault("relax", 0.9)),
Cu_(coeffs_.getOrDefault<scalar>("Cu", 100000)),

View File

@ -33,7 +33,7 @@ bool Foam::fv::VoFSolidificationMeltingSource::read(const dictionary& dict)
{
if (fv::cellSetOption::read(dict))
{
alphaSolidT_ = Function1<scalar>::New("alphaSolidT", coeffs_);
alphaSolidT_ = Function1<scalar>::New("alphaSolidT", coeffs_, &mesh_);
coeffs_.readEntry("L", L_);
coeffs_.readIfPresent("relax", relax_);
coeffs_.readIfPresent("Cu", Cu_);

View File

@ -343,12 +343,12 @@ Foam::radiation::laserDTRM::laserDTRM(const volScalarField& T)
focalLaserPosition_
(
Function1<point>::New("focalLaserPosition", *this)
Function1<point>::New("focalLaserPosition", *this, &mesh_)
),
laserDirection_
(
Function1<vector>::New("laserDirection", *this)
Function1<vector>::New("laserDirection", *this, &mesh_)
),
focalLaserRadius_(get<scalar>("focalLaserRadius")),
@ -359,7 +359,7 @@ Foam::radiation::laserDTRM::laserDTRM(const volScalarField& T)
sigma_(0),
I0_(0),
laserPower_(Function1<scalar>::New("laserPower", *this)),
laserPower_(Function1<scalar>::New("laserPower", *this, &mesh_)),
powerDistribution_(),
reflectionSwitch_(false),
@ -441,11 +441,11 @@ Foam::radiation::laserDTRM::laserDTRM
focalLaserPosition_
(
Function1<point>::New("focalLaserPosition", *this)
Function1<point>::New("focalLaserPosition", *this, &mesh_)
),
laserDirection_
(
Function1<vector>::New("laserDirection", *this)
Function1<vector>::New("laserDirection", *this, &mesh_)
),
focalLaserRadius_(get<scalar>("focalLaserRadius")),
@ -456,7 +456,7 @@ Foam::radiation::laserDTRM::laserDTRM
sigma_(0),
I0_(0),
laserPower_(Function1<scalar>::New("laserPower", *this)),
laserPower_(Function1<scalar>::New("laserPower", *this, &mesh_)),
powerDistribution_(),
reflectionSwitch_(false),

View File

@ -16,7 +16,7 @@ const vector L(dict.get<vector>("L"));
const Vector<label> N(dict.get<Vector<label>>("N"));
// Wave number vs energy profile
autoPtr<Function1<scalar>> Ek(Function1<scalar>::New("Ek", dict));
autoPtr<Function1<scalar>> Ek(Function1<scalar>::New("Ek", dict, &runTime));
// Number of modes
const label nModes = dict.get<label>("nModes");

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Version: v2106
\\ / O peration | Version: v2112
\\ / A nd | Website: www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
@ -15,11 +15,12 @@ Description
\*---------------------------------------------------------------------------*/
type dsmcFields;
libs ("liblagrangianFunctionObjects.so");
type dsmcFields;
libs ("liblagrangianFunctionObjects.so");
fields (rhoNMean rhoMMean momentumMean linearKEMean internalEMean
iDofMean fDMean);
// Names for reference purposes only
fields ( rhoNMean rhoMMean momentumMean linearKEMean internalEMean
iDofMean fDMean );
executeControl writeTime;
writeControl writeTime;

View File

@ -78,7 +78,7 @@ CONSTRUCT
scalarData_(dict.get<scalar>("scalarData")),
data_(dict.get<TYPE>("data")),
fieldData_("fieldData", dict, p.size()),
timeVsData_(Function1<TYPE>::New("timeVsData", dict)),
timeVsData_(Function1<TYPE>::New("timeVsData", dict, &this->db())),
wordData_(dict.getOrDefault<word>("wordName", "wordDefault")),
labelData_(-1),
boolData_(false)

View File

@ -354,6 +354,7 @@ $(dll)/codedBase/codedBase.C
funcObjs = db/functionObjects
$(funcObjs)/functionObject/functionObject.C
$(funcObjs)/functionObjectProperties/functionObjectProperties.C
$(funcObjs)/functionObjectList/functionObjectList.C
$(funcObjs)/stateFunctionObject/stateFunctionObject.C
$(funcObjs)/timeFunctionObject/timeFunctionObject.C

View File

@ -48,15 +48,25 @@ Foam::word Foam::functionObject::outputPrefix("postProcessing");
Foam::word Foam::functionObject::scopedName(const word& name) const
{
return name_ + ":" + name;
if (scopedNames_)
{
return IOobject::scopedName(name_, name);
}
return name_;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::functionObject::functionObject(const word& name)
Foam::functionObject::functionObject
(
const word& name,
const bool scopedNames
)
:
name_(name),
scopedNames_(scopedNames),
log(postProcess)
{}
@ -128,16 +138,23 @@ Foam::autoPtr<Foam::functionObject> Foam::functionObject::New
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::word& Foam::functionObject::name() const
const Foam::word& Foam::functionObject::name() const noexcept
{
return name_;
}
bool Foam::functionObject::scopedNames() const noexcept
{
return scopedNames_;
}
bool Foam::functionObject::read(const dictionary& dict)
{
if (!postProcess)
{
scopedNames_ = dict.getOrDefault("scopedNames", true);
log = dict.getOrDefault("log", true);
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2020 OpenCFD Ltd.
Copyright (C) 2017-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -221,6 +221,9 @@ class functionObject
//- Name
const word name_;
//- Flag to indicate that names should be scoped
bool scopedNames_;
protected:
@ -266,7 +269,11 @@ public:
// Constructors
//- Construct from components
functionObject(const word& name);
explicit functionObject
(
const word& name,
const bool scopedNames = true
);
//- Return clone
autoPtr<functionObject> clone() const
@ -294,7 +301,10 @@ public:
// Member Functions
//- Return the name of this functionObject
const word& name() const;
const word& name() const noexcept;
//- Return the scoped names flag
bool scopedNames() const noexcept;
//- Read and set the function object if its data have changed
virtual bool read(const dictionary& dict);
@ -347,7 +357,7 @@ class functionObject::unavailableFunctionObject
protected:
//- Construct with name
unavailableFunctionObject(const word& name);
explicit unavailableFunctionObject(const word& name);
//- Report it is unavailable, emitting a FatalError for try/catch
//- in the caller

View File

@ -97,13 +97,13 @@ namespace Foam
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
void Foam::functionObjectList::createStateDict() const
void Foam::functionObjectList::createPropertiesDict() const
{
// Cannot set the state dictionary on construction since Time has not
// Cannot set the properties dictionary on construction since Time has not
// been fully initialised
stateDictPtr_.reset
propsDictPtr_.reset
(
new IOdictionary
new functionObjects::properties
(
IOobject
(
@ -412,7 +412,7 @@ Foam::functionObjectList::functionObjectList
warnings_(),
time_(runTime),
parentDict_(parentDict),
stateDictPtr_(nullptr),
propsDictPtr_(nullptr),
objectsRegistryPtr_(nullptr),
execution_(execution),
updated_(false)
@ -509,37 +509,38 @@ Foam::autoPtr<Foam::functionObjectList> Foam::functionObjectList::New
Foam::label Foam::functionObjectList::triggerIndex() const
{
return stateDict().getOrDefault<label>("triggerIndex", labelMin);
return propsDict().getTrigger();
}
void Foam::functionObjectList::resetState()
void Foam::functionObjectList::resetPropertiesDict()
{
// Reset (re-read) the state dictionary
stateDictPtr_.reset(nullptr);
createStateDict();
// Reset (re-read) the properties dictionary
propsDictPtr_.reset(nullptr);
createPropertiesDict();
}
Foam::IOdictionary& Foam::functionObjectList::stateDict()
Foam::functionObjects::properties& Foam::functionObjectList::propsDict()
{
if (!stateDictPtr_)
if (!propsDictPtr_)
{
createStateDict();
createPropertiesDict();
}
return *stateDictPtr_;
return *propsDictPtr_;
}
const Foam::IOdictionary& Foam::functionObjectList::stateDict() const
const Foam::functionObjects::properties&
Foam::functionObjectList::propsDict() const
{
if (!stateDictPtr_)
if (!propsDictPtr_)
{
createStateDict();
createPropertiesDict();
}
return *stateDictPtr_;
return *propsDictPtr_;
}
@ -768,13 +769,13 @@ bool Foam::functionObjectList::execute()
}
}
// Force writing of state dictionary after function object execution
// Force writing of properties dictionary after function object execution
if (time_.writeTime())
{
const auto oldPrecision = IOstream::precision_;
IOstream::precision_ = 16;
stateDictPtr_->writeObject
propsDictPtr_->writeObject
(
IOstreamOption(IOstream::ASCII, time_.writeCompression()),
true
@ -930,9 +931,9 @@ bool Foam::functionObjectList::adjustTimeStep()
bool Foam::functionObjectList::read()
{
if (!stateDictPtr_)
if (!propsDictPtr_)
{
createStateDict();
createPropertiesDict();
}
updated_ = execution_;

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2015-2020 OpenCFD Ltd.
Copyright (C) 2015-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -87,6 +87,7 @@ SourceFiles
#include "HashTable.H"
#include "IOdictionary.H"
#include "HashSet.H"
#include "functionObjectProperties.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -145,7 +146,7 @@ class functionObjectList
const dictionary& parentDict_;
//- Function object properties - stores state information
mutable autoPtr<IOdictionary> stateDictPtr_;
mutable autoPtr<functionObjects::properties> propsDictPtr_;
//- Function objects output registry
mutable autoPtr<objectRegistry> objectsRegistryPtr_;
@ -165,8 +166,8 @@ class functionObjectList
//- List of functions
PtrList<functionObject>& functions() { return *this; }
//- Create state dictionary - attached to Time.
void createStateDict() const;
//- Create properties dictionary - attached to Time.
void createPropertiesDict() const;
//- Create registry for output objects - attached to Time.
void createOutputRegistry() const;
@ -262,19 +263,19 @@ public:
//- Access to the functionObjects
using PtrList<functionObject>::operator[];
//- Return the current trigger index (read from the stateDict)
//- Return the current trigger index (read from the propsDict)
label triggerIndex() const;
//- Reset/read state dictionary for current time
void resetState();
//- Reset/read properties dictionary for current time
void resetPropertiesDict();
//- Write access to the state dictionary ("functionObjectProperties")
//- registered on Time
IOdictionary& stateDict();
//- Write access to the properties dictionary
//- ("functionObjectProperties") registered on Time
functionObjects::properties& propsDict();
//- Const access to the state dictionary ("functionObjectProperties")
//- registered on Time
const IOdictionary& stateDict() const;
//- Const access to the properties dictionary
//- ("functionObjectProperties") registered on Time
const Foam::functionObjects::properties& propsDict() const;
//- Write access to the output objects ("functionObjectObjects")
//- registered on Time

View File

@ -0,0 +1,320 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "functionObjectProperties.H"
#include "SHA1.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
const Foam::word Foam::functionObjects::properties::resultsName_ =
SHA1("results").str();
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::functionObjects::properties::properties
(
const IOobject& io
)
:
IOdictionary(io)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::wordList Foam::functionObjects::properties::objectNames() const
{
// TODO
// - remove resultsName_ dict from results?
// - or put objects into their own subdictionary?
return sortedToc();
}
bool Foam::functionObjects::properties::hasObjectDict
(
const word& objectName
) const
{
return found(objectName);
}
Foam::dictionary& Foam::functionObjects::properties::getObjectDict
(
const word& objectName
)
{
if (!found(objectName))
{
add(objectName, dictionary());
}
return subDict(objectName);
}
void Foam::functionObjects::properties::clearTrigger()
{
remove("triggerIndex");
}
Foam::label Foam::functionObjects::properties::getTrigger() const
{
// Like getOrDefault, but without reporting missing entry (noisy)
label idx = labelMin;
readIfPresent("triggerIndex", idx);
return idx;
}
bool Foam::functionObjects::properties::setTrigger
(
const label triggeri,
bool increaseOnly
)
{
const label currTriggeri = getTrigger();
if (increaseOnly ? (triggeri > currTriggeri) : (triggeri != currTriggeri))
{
set("triggerIndex", triggeri);
return true;
}
// TBD: any special handling for triggeri == labelMin - eg, clearTrigger()
return false;
}
bool Foam::functionObjects::properties::foundObjectProperty
(
const word& objectName,
const word& entryName
) const
{
if (found(objectName))
{
const dictionary& baseDict = subDict(objectName);
return baseDict.found(entryName);
}
return false;
}
bool Foam::functionObjects::properties::getObjectDict
(
const word& objectName,
const word& entryName,
dictionary& dict
) const
{
if (found(objectName))
{
const dictionary& baseDict = subDict(objectName);
if (baseDict.found(entryName) && baseDict.isDict(entryName))
{
dict = baseDict.subDict(entryName);
return true;
}
}
return false;
}
bool Foam::functionObjects::properties::hasResultObject
(
const word& objectName
) const
{
if (found(resultsName_))
{
return subDict(resultsName_).found(objectName);
}
return false;
}
Foam::wordList Foam::functionObjects::properties::objectResultNames() const
{
if (found(resultsName_))
{
return subDict(resultsName_).sortedToc();
}
return wordList();
}
bool Foam::functionObjects::properties::hasResultObjectEntry
(
const word& objectName,
const word& entryName
) const
{
if (found(resultsName_))
{
const dictionary& resultsDict = subDict(resultsName_);
if (resultsDict.found(objectName))
{
const dictionary& objectDict = resultsDict.subDict(objectName);
for (const entry& dEntry : objectDict)
{
const dictionary& dict = dEntry.dict();
if (dict.found(entryName))
{
return true;
}
}
}
}
return false;
}
Foam::word Foam::functionObjects::properties::objectResultType
(
const word& objectName,
const word& entryName
) const
{
if (found(resultsName_))
{
const dictionary& resultsDict = subDict(resultsName_);
if (resultsDict.found(objectName))
{
const dictionary& objectDict = resultsDict.subDict(objectName);
for (const entry& dEntry : objectDict)
{
const dictionary& dict = dEntry.dict();
if (dict.found(entryName))
{
return dict.dictName();
}
}
}
}
return word::null;
}
Foam::wordList Foam::functionObjects::properties::objectResultEntries
(
const word& objectName
) const
{
DynamicList<word> result;
if (found(resultsName_))
{
const dictionary& resultsDict = subDict(resultsName_);
if (resultsDict.found(objectName))
{
const dictionary& objectDict = resultsDict.subDict(objectName);
for (const entry& dEntry : objectDict)
{
const dictionary& dict = dEntry.dict();
result.append(dict.toc());
}
}
}
wordList entries;
entries.transfer(result);
return entries;
}
void Foam::functionObjects::properties::writeResultEntries
(
const word& objectName,
Ostream& os
) const
{
if (found(resultsName_))
{
const dictionary& resultsDict = subDict(resultsName_);
if (resultsDict.found(objectName))
{
const dictionary& objectDict = resultsDict.subDict(objectName);
for (const word& dataFormat : objectDict.sortedToc())
{
os << " Type: " << dataFormat << nl;
const dictionary& resultDict = objectDict.subDict(dataFormat);
for (const word& result : resultDict.sortedToc())
{
os << " " << result << nl;
}
}
}
}
}
void Foam::functionObjects::properties::writeAllResultEntries
(
Ostream& os
) const
{
if (found(resultsName_))
{
const dictionary& resultsDict = subDict(resultsName_);
for (const word& objectName : resultsDict.sortedToc())
{
os << "Object: " << objectName << endl;
writeResultEntries(objectName, os);
}
}
}
// ************************************************************************* //

View File

@ -0,0 +1,250 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::functionObjects::properties
Description
Storage for function object properties, derived from IOdictionary.
Provides functionality to read/write state information (data required for
smooth restart behaviour) and results to/from the state dictionary
Note: cannot be accessed until after construction of thefunction objects,
since the owner container functionObjectList is owned by time, and time owns
[this] i.e. need to wait for time to be fully constructed.
See also
Foam::functionObject
SourceFiles
functionObjectProperties.C
functionObjectPropertiesTemplates.C
\*---------------------------------------------------------------------------*/
#ifndef functionObjects_properties_H
#define functionObjects_properties_H
#include "IOdictionary.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace functionObjects
{
/*---------------------------------------------------------------------------*\
Class properties Declaration
\*---------------------------------------------------------------------------*/
class properties
:
public IOdictionary
{
// Private Member Data
//- Name of the results dictionary
static const word resultsName_;
protected:
// Protected Member Functions
//- No copy construct
properties(const properties&) = delete;
//- No copy assignment
void operator=(const properties&) = delete;
public:
// Constructors
//- Construct from components
explicit properties(const IOobject& io);
//- Destructor
virtual ~properties() = default;
// Member Functions
//- Return list of object names
wordList objectNames() const;
//- Return true if the object with objectName exists
bool hasObjectDict(const word& objectName) const;
//- Return access to the property dictionary
dictionary& propertyDict(const word& objectName);
// Properties
//- Get dictionary for named object. Creates one if required
dictionary& getObjectDict(const word& objectName);
//- Return true if the property exists
bool foundObjectProperty
(
const word& objectName,
const word& entryName
) const;
//- Remove the trigger index from the properties
void clearTrigger();
//- Get the current trigger index
label getTrigger() const;
//- Set the trigger index. Normally only if greater than current
//
// \param triggeri the new trigger index
// \param increaseOnly (default) only change if new index
// is greater than the current index.
//
// \return True if the index changed
bool setTrigger(const label triggeri, bool increaseOnly = true);
//- Set dictionary from named object, return true if set
bool getObjectDict
(
const word& objectName,
const word& entryName,
dictionary& dict
) const;
//- Retrieve generic property from named object
template<class Type>
Type getObjectProperty
(
const word& objectName,
const word& entryName,
const Type& defaultValue = Type(Zero)
) const;
//- Set generic property from named object, return true if set
template<class Type>
bool getObjectProperty
(
const word& objectName,
const word& entryName,
Type& value
) const;
//- Add generic property from named object
template<class Type>
void setObjectProperty
(
const word& objectName,
const word& entryName,
const Type& value
);
// Results
//- Add result from named object
template<class Type>
void setObjectResult
(
const word& objectName,
const word& entryName,
const Type& value
);
//- Retrieve result from named object
template<class Type>
Type getObjectResult
(
const word& objectName,
const word& entryName,
const Type& defaultValue = Type(Zero)
) const;
//- Set result from named object, return true if set
template<class Type>
bool getObjectResult
(
const word& objectName,
const word& entryName,
Type& value
) const;
//- Return true if the object with objectName exists in results
bool hasResultObject(const word& objectName) const;
//- Return list of objects with results
wordList objectResultNames() const;
//- Return true if the object with objectName exists and has
//- entryName in its results
bool hasResultObjectEntry
(
const word& objectName,
const word& entryName
) const;
//- Return the type of result
word objectResultType
(
const word& objectName,
const word& entryName
) const;
//- Return result entries for named object
wordList objectResultEntries(const word& objectName) const;
//- Write the results entries for all objects to stream
void writeResultEntries(Ostream& os) const;
//- Write the results entries for named object to stream
void writeResultEntries(const word& objectName, Ostream& os) const;
//- Write the results entries for all objects to stream
void writeAllResultEntries(Ostream& os) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace functionObjects
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "functionObjectPropertiesTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,163 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "IOdictionary.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type>
Type Foam::functionObjects::properties::getObjectProperty
(
const word& objectName,
const word& entryName,
const Type& defaultValue
) const
{
Type result = defaultValue;
getObjectProperty(objectName, entryName, result);
return result;
}
template<class Type>
bool Foam::functionObjects::properties::getObjectProperty
(
const word& objectName,
const word& entryName,
Type& value
) const
{
if (this->found(objectName))
{
const dictionary& baseDict = this->subDict(objectName);
return baseDict.readIfPresent(entryName, value);
}
return false;
}
template<class Type>
void Foam::functionObjects::properties::setObjectProperty
(
const word& objectName,
const word& entryName,
const Type& value
)
{
if (!this->found(objectName))
{
this->add(objectName, dictionary());
}
dictionary& baseDict = this->subDict(objectName);
baseDict.add(entryName, value, true);
}
template<class Type>
void Foam::functionObjects::properties::setObjectResult
(
const word& objectName,
const word& entryName,
const Type& value
)
{
if (!this->found(resultsName_))
{
this->add(resultsName_, dictionary());
}
dictionary& resultsDict = this->subDict(resultsName_);
if (!resultsDict.found(objectName))
{
resultsDict.add(objectName, dictionary());
}
dictionary& objectDict = resultsDict.subDict(objectName);
const word& dictTypeName = pTraits<Type>::typeName;
if (!objectDict.found(dictTypeName))
{
objectDict.add(dictTypeName, dictionary());
}
dictionary& resultTypeDict = objectDict.subDict(dictTypeName);
resultTypeDict.add(entryName, value, true);
}
template<class Type>
Type Foam::functionObjects::properties::getObjectResult
(
const word& objectName,
const word& entryName,
const Type& defaultValue
) const
{
Type result = defaultValue;
(void)getObjectResult(objectName, entryName, result);
return result;
}
template<class Type>
bool Foam::functionObjects::properties::getObjectResult
(
const word& objectName,
const word& entryName,
Type& value
) const
{
if (this->found(resultsName_))
{
const dictionary& resultsDict = this->subDict(resultsName_);
if (resultsDict.found(objectName))
{
const dictionary& objectDict = resultsDict.subDict(objectName);
const word& dictTypeName = pTraits<Type>::typeName;
if (objectDict.found(dictTypeName))
{
const dictionary& resultTypeDict =
objectDict.subDict(dictTypeName);
return resultTypeDict.readIfPresent<Type>(entryName, value);
}
}
}
return false;
}
// ************************************************************************* //

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2015 OpenFOAM Foundation
Copyright (C) 2015-2020 OpenCFD Ltd.
Copyright (C) 2015-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -37,16 +37,20 @@ const Foam::word Foam::functionObjects::stateFunctionObject::resultsName_ =
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
const Foam::IOdictionary&
const Foam::functionObjects::properties&
Foam::functionObjects::stateFunctionObject::stateDict() const
{
return time_.functionObjects().stateDict();
return time_.functionObjects().propsDict();
}
Foam::IOdictionary& Foam::functionObjects::stateFunctionObject::stateDict()
Foam::functionObjects::properties&
Foam::functionObjects::stateFunctionObject::stateDict()
{
return const_cast<IOdictionary&>(time_.functionObjects().stateDict());
return const_cast<functionObjects::properties&>
(
time_.functionObjects().propsDict()
);
}
@ -66,42 +70,29 @@ Foam::functionObjects::stateFunctionObject::stateFunctionObject
Foam::dictionary& Foam::functionObjects::stateFunctionObject::propertyDict()
{
IOdictionary& stateDict = this->stateDict();
if (!stateDict.found(name()))
{
stateDict.add(name(), dictionary());
}
return stateDict.subDict(name());
return stateDict().getObjectDict(name());
}
bool Foam::functionObjects::stateFunctionObject::setTrigger
(
const label triggeri
)
void Foam::functionObjects::stateFunctionObject::clearTrigger()
{
IOdictionary& stateDict = this->stateDict();
label oldTriggeri =
stateDict.getOrDefault<label>("triggerIndex", labelMin);
if (triggeri > oldTriggeri)
{
stateDict.set("triggerIndex", triggeri);
return true;
}
return false;
return stateDict().clearTrigger();
}
Foam::label Foam::functionObjects::stateFunctionObject::getTrigger() const
{
const IOdictionary& stateDict = this->stateDict();
return stateDict().getTrigger();
}
return stateDict.getOrDefault<label>("triggerIndex", labelMin);
bool Foam::functionObjects::stateFunctionObject::setTrigger
(
const label triggeri,
bool increaseOnly
)
{
return stateDict().setTrigger(triggeri, increaseOnly);
}
@ -110,15 +101,7 @@ bool Foam::functionObjects::stateFunctionObject::foundProperty
const word& entryName
) const
{
const IOdictionary& stateDict = this->stateDict();
if (stateDict.found(name()))
{
const dictionary& baseDict = stateDict.subDict(name());
return baseDict.found(entryName);
}
return false;
return stateDict().foundObjectProperty(name(), entryName);
}
@ -128,7 +111,7 @@ bool Foam::functionObjects::stateFunctionObject::getDict
dictionary& dict
) const
{
return getObjectDict(name(), entryName, dict);
return stateDict().getObjectDict(name(), entryName, dict);
}
@ -139,19 +122,7 @@ bool Foam::functionObjects::stateFunctionObject::getObjectDict
dictionary& dict
) const
{
const IOdictionary& stateDict = this->stateDict();
if (stateDict.found(objectName))
{
const dictionary& baseDict = stateDict.subDict(objectName);
if (baseDict.found(entryName) && baseDict.isDict(entryName))
{
dict = baseDict.subDict(entryName);
return true;
}
}
return false;
return stateDict().getObjectDict(objectName, entryName, dict);
}
@ -160,7 +131,7 @@ Foam::word Foam::functionObjects::stateFunctionObject::resultType
const word& entryName
) const
{
return objectResultType(name(), entryName);
return stateDict().objectResultType(name(), entryName);
}
@ -170,79 +141,33 @@ Foam::word Foam::functionObjects::stateFunctionObject::objectResultType
const word& entryName
) const
{
word result = word::null;
const IOdictionary& stateDict = this->stateDict();
if (stateDict.found(resultsName_))
{
const dictionary& resultsDict = stateDict.subDict(resultsName_);
if (resultsDict.found(objectName))
{
const dictionary& objectDict = resultsDict.subDict(objectName);
for (const entry& dEntry : objectDict)
{
const dictionary& dict = dEntry.dict();
if (dict.found(entryName))
{
return dict.dictName();
}
}
}
}
return result;
return stateDict().objectResultType(objectName, entryName);
}
Foam::List<Foam::word>
Foam::wordList
Foam::functionObjects::stateFunctionObject::objectResultEntries() const
{
return objectResultEntries(name());
return stateDict().objectResultEntries(name());
}
Foam::List<Foam::word>
Foam::wordList
Foam::functionObjects::stateFunctionObject::objectResultEntries
(
const word& objectName
) const
{
DynamicList<word> result(2);
const IOdictionary& stateDict = this->stateDict();
if (stateDict.found(resultsName_))
{
const dictionary& resultsDict = stateDict.subDict(resultsName_);
if (resultsDict.found(objectName))
{
const dictionary& objectDict = resultsDict.subDict(objectName);
for (const entry& dEntry : objectDict)
{
const dictionary& dict = dEntry.dict();
result.append(dict.toc());
}
}
}
wordList entries;
entries.transfer(result);
return entries;
return stateDict().objectResultEntries(objectName);
}
void Foam::functionObjects::stateFunctionObject::writeResultEntries
(
Ostream& os
) const
{
writeResultEntries(name(), os);
return stateDict().writeResultEntries(name(), os);
}
@ -252,29 +177,7 @@ void Foam::functionObjects::stateFunctionObject::writeResultEntries
Ostream& os
) const
{
const IOdictionary& stateDict = this->stateDict();
if (stateDict.found(resultsName_))
{
const dictionary& resultsDict = stateDict.subDict(resultsName_);
if (resultsDict.found(objectName))
{
const dictionary& objectDict = resultsDict.subDict(objectName);
for (const word& dataFormat : objectDict.sortedToc())
{
os << " Type: " << dataFormat << nl;
const dictionary& resultDict = objectDict.subDict(dataFormat);
for (const word& result : resultDict.sortedToc())
{
os << " " << result << nl;
}
}
}
}
return stateDict().writeResultEntries(objectName, os);
}
@ -283,21 +186,7 @@ void Foam::functionObjects::stateFunctionObject::writeAllResultEntries
Ostream& os
) const
{
const IOdictionary& stateDict = this->stateDict();
if (stateDict.found(resultsName_))
{
const dictionary& resultsDict = stateDict.subDict(resultsName_);
const wordList allObjectNames = resultsDict.sortedToc();
for (const word& objectName : allObjectNames)
{
os << "Object: " << objectName << endl;
writeResultEntries(objectName, os);
}
}
return stateDict().writeAllResultEntries(os);
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2015 OpenFOAM Foundation
Copyright (C) 2015-2019 OpenCFD Ltd.
Copyright (C) 2015-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -50,12 +50,14 @@ SourceFiles
#define functionObjects_stateFunctionObject_H
#include "timeFunctionObject.H"
#include "functionObjectProperties.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward Declarations
class IOdictionary;
namespace functionObjects
@ -80,10 +82,10 @@ protected:
// Protected Member Functions
//- Return a const reference to the state dictionary
const IOdictionary& stateDict() const;
const functionObjects::properties& stateDict() const;
//- Return non-const access to the state dictionary
IOdictionary& stateDict();
functionObjects::properties& stateDict();
//- No copy construct
@ -116,11 +118,20 @@ public:
//- Return true if the property exists
bool foundProperty(const word& entryName) const;
//- Remove the trigger index from the properties
void clearTrigger();
//- Get the current trigger index
label getTrigger() const;
//- Set the current trigger index
bool setTrigger(const label triggeri);
//- Set the trigger index. Normally only if greater than current
//
// \param triggeri the new trigger index
// \param increaseOnly (default) only change if new index
// is greater than the current index.
//
// \return True if the index changed
bool setTrigger(const label triggeri, bool increaseOnly = true);
//- Set dictionary, return true if set
bool getDict
@ -237,10 +248,10 @@ public:
) const;
//- Retrieve the result entries
List<word> objectResultEntries() const;
wordList objectResultEntries() const;
//- Return result entries for named object
List<word> objectResultEntries(const word& objectName) const;
wordList objectResultEntries(const word& objectName) const;
//- Write the results entries for all objects to stream
void writeResultEntries(Ostream& os) const;

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2015 OpenFOAM Foundation
Copyright (C) 2015-2016 OpenCFD Ltd.
Copyright (C) 2015-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -87,15 +87,7 @@ bool Foam::functionObjects::stateFunctionObject::getObjectProperty
Type& value
) const
{
const IOdictionary& stateDict = this->stateDict();
if (stateDict.found(objectName))
{
const dictionary& baseDict = stateDict.subDict(objectName);
return baseDict.readIfPresent(entryName, value);
}
return false;
return stateDict().getObjectProperty(objectName, entryName, value);
}
@ -107,15 +99,7 @@ void Foam::functionObjects::stateFunctionObject::setObjectProperty
const Type& value
)
{
IOdictionary& stateDict = this->stateDict();
if (!stateDict.found(objectName))
{
stateDict.add(objectName, dictionary());
}
dictionary& baseDict = stateDict.subDict(objectName);
baseDict.add(entryName, value, true);
stateDict().setObjectProperty(objectName, entryName, value);
}
@ -138,32 +122,7 @@ void Foam::functionObjects::stateFunctionObject::setObjectResult
const Type& value
)
{
IOdictionary& stateDict = this->stateDict();
if (!stateDict.found(resultsName_))
{
stateDict.add(resultsName_, dictionary());
}
dictionary& resultsDict = stateDict.subDict(resultsName_);
if (!resultsDict.found(objectName))
{
resultsDict.add(name(), dictionary());
}
dictionary& objectDict = resultsDict.subDict(objectName);
const word& dictTypeName = pTraits<Type>::typeName;
if (!objectDict.found(dictTypeName))
{
objectDict.add(dictTypeName, dictionary());
}
dictionary& resultTypeDict = objectDict.subDict(dictTypeName);
resultTypeDict.add(entryName, value, true);
stateDict().setObjectResult(objectName, entryName, value);
}
@ -200,29 +159,7 @@ bool Foam::functionObjects::stateFunctionObject::getObjectResult
Type& value
) const
{
const IOdictionary& stateDict = this->stateDict();
if (stateDict.found(resultsName_))
{
const dictionary& resultsDict = stateDict.subDict(resultsName_);
if (resultsDict.found(objectName))
{
const dictionary& objectDict = resultsDict.subDict(objectName);
const word& dictTypeName = pTraits<Type>::typeName;
if (objectDict.found(dictTypeName))
{
const dictionary& resultTypeDict =
objectDict.subDict(dictTypeName);
return resultTypeDict.readIfPresent<Type>(entryName, value);
}
}
}
return false;
return stateDict().getObjectResult(objectName, entryName, value);
}

View File

@ -80,8 +80,7 @@ class timeControl
{
public:
// Public enumerations
// Public Enumerations
//- Control mode
enum class controlMode
@ -97,7 +96,7 @@ public:
private:
// Private data
// Private Data
//- Input dictionary
dictionary dict_;
@ -108,13 +107,13 @@ private:
//- Control mode (combination of time/trigger behaviour)
controlMode controlMode_;
//- Activation time - defaults to -VGREAT
//- Activation time - defaults to -VGREAT (ie, active)
scalar timeStart_;
//- De-activation time - defaults to VGREAT
scalar timeEnd_;
//- Activation trigger index - defaults to labelMin
//- Activation trigger index - defaults to labelMax (ie, inactive)
label triggerStart_;
//- De-activation trigger index - defaults to labelMax

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -33,10 +33,11 @@ template<class Type>
Foam::Function1Types::Function1Expression<Type>::Function1Expression
(
const word& entryName,
const dictionary& dict
const dictionary& dict,
const objectRegistry* obrPtr
)
:
Function1<Type>(entryName, dict),
Function1<Type>(entryName, dict, obrPtr),
dict_(dict),
valueExpr_(),
driver_(1, dict_)
@ -88,6 +89,8 @@ Type Foam::Function1Types::Function1Expression<Type>::value
driver_.setArgument(x);
driver_.resetDb(this->whichDb());
driver_.parse(this->valueExpr_);
expressions::exprResult result(driver_.result());
@ -98,7 +101,9 @@ Type Foam::Function1Types::Function1Expression<Type>::value
if (!result.hasValue() || !result.size() || !result.isType<Type>())
{
FatalErrorInFunction
<< "Could not evaluate: " << this->valueExpr_
<< "Could not evaluate: " << this->valueExpr_ << nl
<< "Result size:" << result.size()
<< " type:" << result.valueType() << nl
<< exit(FatalError);
}
@ -124,7 +129,7 @@ void Foam::Function1Types::Function1Expression<Type>::writeData
Ostream& os
) const
{
// Function1-from-subdict so out dictionary contains
// Function1-from-subdict so output dictionary contains
// only the relevant entries.
dict_.writeEntry(this->name(), os);
}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -113,8 +113,13 @@ public:
// Constructors
//- Construct from entry name and dictionary
Function1Expression(const word& entryName, const dictionary& dict);
//- Construct from entry name, dictionary and optional registry
Function1Expression
(
const word& entryName,
const dictionary& dict,
const objectRegistry* obrPtr = nullptr
);
//- Copy construct
explicit Function1Expression(const Function1Expression<Type>& rhs);

View File

@ -210,10 +210,11 @@ Foam::Function1Types::CSV<Type>::CSV
(
const word& entryName,
const dictionary& dict,
const objectRegistry* obrPtr,
const fileName& fName
)
:
TableBase<Type>(entryName, dict),
TableBase<Type>(entryName, dict, obrPtr),
nHeaderLine_(dict.get<label>("nHeaderLine")),
refColumn_(dict.get<label>("refColumn")),
componentColumns_(getComponentColumns("componentColumns", dict)),
@ -223,7 +224,7 @@ Foam::Function1Types::CSV<Type>::CSV
{
read();
TableBase<Type>::check();
TableBase<Type>::initialise();
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2017-2020 OpenCFD Ltd.
Copyright (C) 2017-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -125,11 +125,12 @@ public:
// Constructors
//- Construct from entry name and dictionary
//- Construct from entry name, dictionary and optional registry
CSV
(
const word& entryName,
const dictionary& dict,
const objectRegistry* obrPtr = nullptr,
const fileName& fName = fileName::null
);

View File

@ -34,10 +34,11 @@ template<class Type>
Foam::Function1Types::Constant<Type>::Constant
(
const word& entryName,
const Type& value
const Type& value,
const objectRegistry* obrPtr
)
:
Function1<Type>(entryName),
Function1<Type>(entryName, obrPtr),
value_(value)
{}
@ -46,10 +47,11 @@ template<class Type>
Foam::Function1Types::Constant<Type>::Constant
(
const word& entryName,
const dictionary& dict
const dictionary& dict,
const objectRegistry* obrPtr
)
:
Function1<Type>(entryName, dict),
Function1<Type>(entryName, dict, obrPtr),
value_(Zero)
{
const entry* eptr = dict.findEntry(entryName, keyType::LITERAL);

View File

@ -95,10 +95,20 @@ public:
// Constructors
//- Construct from components
Constant(const word& entryName, const Type& value);
Constant
(
const word& entryName,
const Type& value,
const objectRegistry* obrPtr = nullptr
);
//- Construct from entry name and dictionary
Constant(const word& entryName, const dictionary& dict);
//- Construct from entry name, dictionary and optional registry
Constant
(
const word& entryName,
const dictionary& dict,
const objectRegistry* obrPtr = nullptr
);
//- Construct from entry name and Istream
// Reads the constant value without the Function1 type
@ -121,6 +131,9 @@ public:
// Member Functions
//- Change the constant value
inline void reset(const Type& val);
//- Return constant value
virtual inline Type value(const scalar) const;

View File

@ -31,7 +31,14 @@ License
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
inline Type Foam::Function1Types::Constant<Type>::value(const scalar x) const
inline void Foam::Function1Types::Constant<Type>::reset(const Type& val)
{
value_ = val;
}
template<class Type>
inline Type Foam::Function1Types::Constant<Type>::value(const scalar) const
{
return value_;
}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -131,10 +131,15 @@ public:
// Constructors
//- Construct from entry name and dictionary
Cosine(const word& entryName, const dictionary& dict)
//- Construct from entry name, dictionary and optional registry
Cosine
(
const word& entryName,
const dictionary& dict,
const objectRegistry* obrPtr = nullptr
)
:
Sine<Type>(entryName, dict)
Sine<Type>(entryName, dict, obrPtr)
{}
//- Copy construct

View File

@ -34,16 +34,25 @@ License
// * * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * //
template<class Type>
Foam::Function1<Type>::Function1(const word& entryName)
Foam::Function1<Type>::Function1
(
const word& entryName,
const objectRegistry* obrPtr
)
:
function1Base(entryName)
function1Base(entryName, obrPtr)
{}
template<class Type>
Foam::Function1<Type>::Function1(const word& entryName, const dictionary& dict)
Foam::Function1<Type>::Function1
(
const word& entryName,
const dictionary& dict,
const objectRegistry* obrPtr
)
:
function1Base(entryName, dict)
function1Base(entryName, dict, obrPtr)
{}
@ -65,8 +74,7 @@ Type Foam::Function1<Type>::value(const scalar x) const
template<class Type>
Foam::tmp<Foam::Field<Type>>
Foam::Function1<Type>::value
Foam::tmp<Foam::Field<Type>> Foam::Function1<Type>::value
(
const scalarField& x
) const
@ -85,8 +93,7 @@ Type Foam::Function1<Type>::integrate(const scalar x1, const scalar x2) const
template<class Type>
Foam::tmp<Foam::Field<Type>>
Foam::Function1<Type>::integrate
Foam::tmp<Foam::Field<Type>> Foam::Function1<Type>::integrate
(
const scalarField& x1,
const scalarField& x2
@ -119,10 +126,11 @@ template<class Function1Type>
Foam::FieldFunction1<Function1Type>::FieldFunction1
(
const word& entryName,
const dictionary& dict
const dictionary& dict,
const objectRegistry* obrPtr
)
:
Function1Type(entryName, dict)
Function1Type(entryName, dict, obrPtr)
{}

View File

@ -37,7 +37,7 @@ Description
It accepts primitive or dictionary entries for dispatching to different
function types, but wraps unspecified types as "constant".
In the dictionary form, the coefficents are the dictionary itself.
In the dictionary form, the coefficients are the dictionary itself.
This is arguably the more readable form.
For example,
\verbatim
@ -49,7 +49,7 @@ Description
}
\endverbatim
In the primitive form, the coefficents are provided separately.
In the primitive form, the coefficients are provided separately.
For example,
\verbatim
<entryName> linearRamp;
@ -84,8 +84,6 @@ namespace Foam
{
// Forward Declarations
class Time;
template<class Type> class Function1;
template<class Type> Ostream& operator<<(Ostream&, const Function1<Type>&);
/*---------------------------------------------------------------------------*\
@ -106,6 +104,7 @@ class Function1
const entry* eptr, // Eg, dict.findEntry(entryName)
const dictionary& dict,
const word& redirectType,
const objectRegistry* obrPtr,
const bool mandatory
);
@ -133,19 +132,30 @@ public:
dictionary,
(
const word& entryName,
const dictionary& dict
const dictionary& dict,
const objectRegistry* obrPtr
),
(entryName, dict)
(entryName, dict, obrPtr)
);
// Constructors
//- Construct from entry name
explicit Function1(const word& entryName);
explicit Function1
(
const word& entryName,
const objectRegistry* obrPtr = nullptr
);
//- Construct from entry name and dictionary (unused)
Function1(const word& entryName, const dictionary& dict);
//- Construct from entry name, (unused) dictionary
//- and optional registry
Function1
(
const word& entryName,
const dictionary& dict,
const objectRegistry* obrPtr = nullptr
);
//- Copy construct
explicit Function1(const Function1<Type>& rhs);
@ -162,6 +172,7 @@ public:
const word& entryName,
const dictionary& dict,
const word& redirectType,
const objectRegistry* obrPtr = nullptr,
const bool mandatory = true
);
@ -172,6 +183,7 @@ public:
std::initializer_list<std::pair<const char*,int>> compat,
const dictionary& dict,
const word& redirectType = word::null,
const objectRegistry* obrPtr = nullptr,
const bool mandatory = true
);
@ -180,6 +192,7 @@ public:
(
const word& entryName,
const dictionary& dict,
const objectRegistry* obrPtr = nullptr,
const bool mandatory = true
);
@ -188,7 +201,8 @@ public:
(
const word& entryName,
const dictionary& dict,
const word& redirectType = word::null
const word& redirectType = word::null,
const objectRegistry* obrPtr = nullptr
);
@ -202,6 +216,7 @@ public:
const word& entryName,
const dictionary& dict,
enum keyType::option matchOpt = keyType::LITERAL,
const objectRegistry* obrPtr = nullptr,
const bool mandatory = true
);
@ -214,7 +229,8 @@ public:
/// const word& entryName,
/// const dictionary& dict,
/// const Type& deflt,
/// enum keyType::option matchOpt = keyType::LITERAL
/// enum keyType::option matchOpt = keyType::LITERAL,
/// const objectRegistry* obrPtr = nullptr
/// );
@ -279,7 +295,12 @@ public:
// Constructors
//- Construct from entry name and dictionary
FieldFunction1(const word& entryName, const dictionary& dict);
FieldFunction1
(
const word& entryName,
const dictionary& dict,
const objectRegistry* obrPtr = nullptr
);
//- Construct and return a clone
virtual tmp<Function1<Type>> clone() const;

View File

@ -38,6 +38,7 @@ Foam::Function1<Type>::New
const entry* eptr,
const dictionary& dict,
const word& redirectType,
const objectRegistry* obrPtr,
const bool mandatory
)
{
@ -86,7 +87,12 @@ Foam::Function1<Type>::New
return autoPtr<Function1<Type>>
(
new Function1Types::Constant<Type>(entryName, constValue)
new Function1Types::Constant<Type>
(
entryName,
constValue,
obrPtr
)
);
}
@ -135,7 +141,7 @@ Foam::Function1<Type>::New
<< exit(FatalIOError);
}
return ctorPtr(entryName, *coeffs);
return ctorPtr(entryName, *coeffs, obrPtr);
}
@ -146,6 +152,7 @@ Foam::Function1<Type>::New
const word& entryName,
const dictionary& dict,
const word& redirectType,
const objectRegistry* obrPtr,
const bool mandatory
)
{
@ -155,6 +162,7 @@ Foam::Function1<Type>::New
dict.findEntry(entryName, keyType::LITERAL),
dict,
redirectType,
obrPtr,
mandatory
);
}
@ -168,6 +176,7 @@ Foam::Function1<Type>::NewCompat
std::initializer_list<std::pair<const char*,int>> compat,
const dictionary& dict,
const word& redirectType,
const objectRegistry* obrPtr,
const bool mandatory
)
{
@ -177,6 +186,7 @@ Foam::Function1<Type>::NewCompat
dict.findCompat(entryName, compat, keyType::LITERAL),
dict,
redirectType,
obrPtr,
mandatory
);
}
@ -188,10 +198,11 @@ Foam::Function1<Type>::New
(
const word& entryName,
const dictionary& dict,
const objectRegistry* obrPtr,
const bool mandatory
)
{
return Function1<Type>::New(entryName, dict, word::null, mandatory);
return Function1<Type>::New(entryName, dict, word::null, obrPtr, mandatory);
}
@ -201,11 +212,12 @@ Foam::Function1<Type>::NewIfPresent
(
const word& entryName,
const dictionary& dict,
const word& redirectType
const word& redirectType,
const objectRegistry* obrPtr
)
{
// mandatory = false
return Function1<Type>::New(entryName, dict, redirectType, false);
return Function1<Type>::New(entryName, dict, redirectType, obrPtr, false);
}
@ -218,6 +230,7 @@ Foam::Function1<Type>::New
const word& entryName,
const dictionary& dict,
enum keyType::option matchOpt,
const objectRegistry* obrPtr,
const bool mandatory
)
{
@ -259,6 +272,7 @@ Foam::Function1<Type>::New
eptr, // Already resolved
dict,
word::null,
obrPtr,
mandatory
)
);
@ -292,12 +306,13 @@ Foam::Function1<Type>::New
/// const word& entryName,
/// const dictionary& dict,
/// const Type& deflt,
/// enum keyType::option matchOpt
/// enum keyType::option matchOpt,
/// const objectRegistry* obrPtr
/// )
/// {
/// auto fref
/// (
/// Function1<Type>::New(entryName, dict, cache, matchOpt, false)
/// Function1<Type>::New(entryName, dict, cache, matchOpt, obrPtr,false)
/// );
///
/// if (!fref)
@ -308,5 +323,4 @@ Foam::Function1<Type>::New
/// return fref;
/// }
// ************************************************************************* //

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -26,38 +26,113 @@ License
\*---------------------------------------------------------------------------*/
#include "function1Base.H"
#include "objectRegistry.H"
#include "Time.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
const Foam::objectRegistry* Foam::function1Base::whichDb
(
const bool useTime
) const noexcept
{
if (obrPtr_ && useTime)
{
return &(obrPtr_->time());
}
return obrPtr_;
}
// * * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * //
Foam::function1Base::function1Base(const word& entryName)
Foam::function1Base::function1Base
(
const word& entryName,
const objectRegistry* obrPtr
)
:
refCount(),
name_(entryName)
name_(entryName),
obrPtr_(obrPtr)
{}
Foam::function1Base::function1Base
(
const word& entryName,
const dictionary& dict
const dictionary& dict,
const objectRegistry* obrPtr
)
:
refCount(),
name_(entryName)
name_(entryName),
obrPtr_(obrPtr)
{}
Foam::function1Base::function1Base(const function1Base& rhs)
:
refCount(),
name_(rhs.name_)
name_(rhs.name_),
obrPtr_(rhs.obrPtr_)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
// NOTE : do not delete obrPtr_ (no ownership)
Foam::function1Base::~function1Base()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::function1Base::convertTimeBase(const Time& t)
const Foam::objectRegistry& Foam::function1Base::obr() const
{
if (!obrPtr_)
{
FatalErrorInFunction
<< "Object registry not set"
<< abort(FatalError);
}
return *obrPtr_;
}
const Foam::Time& Foam::function1Base::time() const
{
if (!obrPtr_)
{
FatalErrorInFunction
<< "Object registry not set"
<< abort(FatalError);
}
return obrPtr_->time();
}
bool Foam::function1Base::isTime() const noexcept
{
return (obrPtr_ && obrPtr_->isTimeDb());
}
void Foam::function1Base::resetDb(const objectRegistry* obrPtr) noexcept
{
obrPtr_ = obrPtr;
}
void Foam::function1Base::resetDb(const objectRegistry& db) noexcept
{
obrPtr_ = &db;
}
void Foam::function1Base::userTimeToTime(const Time& t)
{}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -27,12 +27,7 @@ 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
Base class for template-invariant parts of Function1
SourceFiles
function1Base.C
@ -43,6 +38,7 @@ SourceFiles
#define function1Base_H
#include "dictionary.H"
#include "objectRegistry.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -50,7 +46,7 @@ namespace Foam
{
// Forward Declarations
class Time;
template<class Type> class Function1;
/*---------------------------------------------------------------------------*\
Class function1Base Declaration
@ -60,6 +56,12 @@ class function1Base
:
public refCount
{
// Private Member Functions
//- The associated registry, the time registry or nullptr
const objectRegistry* whichDb(const bool useTime) const noexcept;
protected:
// Protected Data
@ -67,6 +69,9 @@ protected:
//- Name of entry
const word name_;
//- Pointer to an object registry
const objectRegistry* obrPtr_;
// Protected Member Functions
@ -78,18 +83,27 @@ public:
// Constructors
//- Construct from entry name
explicit function1Base(const word& entryName);
//- Construct from entry name and optional registry
explicit function1Base
(
const word& entryName,
const objectRegistry* obrPtr = nullptr
);
//- Construct from entry name and dictionary (unused)
function1Base(const word& entryName, const dictionary& dict);
//- Construct from entry name, dictionary (unused) and optional registry
function1Base
(
const word& entryName,
const dictionary& dict,
const objectRegistry* obrPtr = nullptr
);
//- Copy construct
explicit function1Base(const function1Base& rhs);
//- Destructor
virtual ~function1Base() = default;
virtual ~function1Base();
// Member Functions
@ -97,16 +111,63 @@ public:
// Access
//- The name of the entry
const word& name() const
const word& name() const noexcept
{
return name_;
}
//- Return the associated registry or nullptr.
const objectRegistry* whichDb() const noexcept
{
return obrPtr_;
}
//- Reset the associated objectRegistry
void resetDb(const objectRegistry* obrPtr = nullptr) noexcept;
//- Reset the associated objectRegistry
void resetDb(const objectRegistry& db) noexcept;
//- Return the object registry
// FatalError if object registry is not set
const objectRegistry& obr() const;
//- Return true if this function was created with the time database
bool isTime() const noexcept;
//- Return the time database
// FatalError if object registry is not set
const Time& time() const;
//- Return the mesh database if this Function1 was created using a mesh
// Note: relies on refCast failure if the type is not correct
template<class MeshType>
const MeshType& mesh(const word& regionName = word::null) const
{
const objectRegistry* ptr = whichDb(!regionName.empty());
if (!ptr)
{
FatalErrorInFunction
<< "Object registry not set"
<< abort(FatalError);
}
if (regionName.empty())
{
return refCast<const MeshType>(*ptr);
}
else
{
return ptr->lookupObject<MeshType>(regionName);
}
}
// Manipulation
//- Convert time
virtual void convertTimeBase(const Time& t);
virtual void userTimeToTime(const Time& t);
};

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -25,55 +25,74 @@ License
\*---------------------------------------------------------------------------*/
#include "LimitRange.H"
#include "FunctionObjectTrigger.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
void Foam::Function1Types::LimitRange<Type>::read(const dictionary& coeffs)
void Foam::Function1Types::FunctionObjectTrigger<Type>::read
(
const dictionary& coeffs
)
{
min_ = coeffs.get<scalar>("min");
max_ = coeffs.get<scalar>("max");
value_ = Function1<Type>::New("value", coeffs);
triggers_ = coeffs.get<labelList>("triggers", keyType::LITERAL);
defaultValue_ =
coeffs.getOrDefault("defaultValue", false, keyType::LITERAL);
}
template<class Type>
Foam::Function1Types::LimitRange<Type>::LimitRange
Foam::Function1Types::FunctionObjectTrigger<Type>::FunctionObjectTrigger
(
const word& entryName,
const dictionary& dict
const dictionary& dict,
const objectRegistry* obrPtr
)
:
Function1<Type>(entryName)
Function1<Type>(entryName, dict, obrPtr),
triggers_(),
defaultValue_(false)
{
read(dict);
}
template<class Type>
Foam::Function1Types::LimitRange<Type>::LimitRange(const LimitRange<Type>& rhs)
Foam::Function1Types::FunctionObjectTrigger<Type>::FunctionObjectTrigger
(
const FunctionObjectTrigger<Type>& rhs
)
:
Function1<Type>(rhs),
min_(rhs.min_),
max_(rhs.max_),
value_(rhs.value_.clone())
triggers_(rhs.triggers_),
defaultValue_(rhs.defaultValue_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::Function1Types::LimitRange<Type>::writeEntries(Ostream& os) const
void Foam::Function1Types::FunctionObjectTrigger<Type>::writeEntries
(
Ostream& os
) const
{
os.writeEntry("min", min_);
os.writeEntry("max", max_);
value_->writeData(os);
os.writeKeyword("triggers");
flatOutput(triggers_);
os.endEntry();
if (defaultValue_)
{
os.writeEntry("default", "true");
}
}
template<class Type>
void Foam::Function1Types::LimitRange<Type>::writeData(Ostream& os) const
void Foam::Function1Types::FunctionObjectTrigger<Type>::writeData
(
Ostream& os
) const
{
Function1<Type>::writeData(os);
os.endEntry();

View File

@ -0,0 +1,178 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::Function1Types::FunctionObjectTrigger
Description
Returns a 0/1 value corresponding to function object trigger levels.
Usage:
\verbatim
<entryName> functionObjectTrigger;
<entryName>Coeffs
{
triggers (1 3 5);
defaultValue false; // Optional
}
\endverbatim
Where:
\table
Property | Description | Required
triggers | List of active trigger states to check for | yes |
defaultValue | Treatment for unactivated trigger state | no | false
\endtable
In some circumstances, it can be useful to treat an unactivated trigger
as being true. This is the role of the "defaultValue" keyword.
Note
- does not implement integrate()
SourceFiles
FunctionObjectTrigger.C
FunctionObjectTriggerI.H
\*---------------------------------------------------------------------------*/
#ifndef Function1Types_FunctionObjectTrigger_H
#define Function1Types_FunctionObjectTrigger_H
#include "Function1.H"
#include "labelList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace Function1Types
{
/*---------------------------------------------------------------------------*\
Class FunctionObjectTrigger Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class FunctionObjectTrigger
:
public Function1<Type>
{
// Private Data
//- Trigger indices when it is considered active
labelList triggers_;
//- Treatment for unactivated trigger state (true/false)
bool defaultValue_;
// Private Member Functions
//- Is the trigger considered active?
inline bool active() const;
//- Read the coefficients from the given dictionary
void read(const dictionary& coeffs);
public:
//- Runtime type information
TypeName("functionObjectTrigger");
// Generated Methods
//- No copy assignment
void operator=(const FunctionObjectTrigger<Type>&) = delete;
// Constructors
//- Construct from entry name, dictionary and optional registry
FunctionObjectTrigger
(
const word& entryName,
const dictionary& dict,
const objectRegistry* obrPtr = nullptr
);
//- Copy construct
explicit FunctionObjectTrigger(const FunctionObjectTrigger<Type>& rhs);
//- Construct and return a clone
virtual tmp<Function1<Type>> clone() const
{
return tmp<Function1<Type>>(new FunctionObjectTrigger<Type>(*this));
}
//- Destructor
virtual ~FunctionObjectTrigger() = default;
// Member Functions
//- Return the trigger indices
inline const labelList& triggers() const noexcept;
//- Change the trigger indices
inline void resetTriggers(const labelUList& indices);
//- Return 0/1 value at current time
virtual inline Type value(const scalar /*unused*/) const;
//- Integrate between two (scalar) values. Not implemented!
virtual inline Type integrate(const scalar, const scalar) const;
//- Write in dictionary format
virtual void writeData(Ostream& os) const;
//- Write coefficient entries in dictionary format
void writeEntries(Ostream& os) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Function1Types
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "FunctionObjectTriggerI.H"
#ifdef NoRepository
#include "FunctionObjectTrigger.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -25,42 +25,64 @@ License
\*---------------------------------------------------------------------------*/
#include "LimitRange.H"
#include "FunctionObjectTrigger.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
inline Type Foam::Function1Types::LimitRange<Type>::value(const scalar t) const
inline bool Foam::Function1Types::FunctionObjectTrigger<Type>::active() const
{
scalar tlim = min(max(t, min_), max_);
if (triggers_.empty())
{
return false;
}
return value_->value(tlim);
const label idx = this->time().functionObjects().triggerIndex();
return
(
idx == labelMin ? defaultValue_ : triggers_.found(idx)
);
}
template<class Type>
Type Foam::Function1Types::LimitRange<Type>::integrate
inline const Foam::labelList&
Foam::Function1Types::FunctionObjectTrigger<Type>::triggers() const noexcept
{
return triggers_;
}
template<class Type>
inline void Foam::Function1Types::FunctionObjectTrigger<Type>::resetTriggers
(
const labelUList& indices
)
{
triggers_ = indices;
}
template<class Type>
inline Type Foam::Function1Types::FunctionObjectTrigger<Type>::value
(
const scalar /*unused*/
) const
{
return this->active() ? pTraits<Type>::one : pTraits<Type>::zero;
}
template<class Type>
inline Type Foam::Function1Types::FunctionObjectTrigger<Type>::integrate
(
const scalar x1,
const scalar x2
) const
{
scalar xlim0 = min(max(x1, min_), max_);
scalar xlim1 = min(max(x2, min_), max_);
Type intValue = value_->integrate(xlim0, xlim1);
if (x1 < min_)
{
intValue += (min(min_, x2) - x1)*this->value(min_);
}
if (x2 > max_)
{
intValue += (x2 - max(max_, x1))*this->value(max_);
}
return intValue;
NotImplemented;
return pTraits<Type>::zero;
}

View File

@ -0,0 +1,109 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "FunctionObjectValue.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
void Foam::Function1Types::FunctionObjectValue<Type>::read
(
const dictionary& coeffs
)
{
foName_ = coeffs.get<word>("functionObject");
foResultName_ = coeffs.get<word>("functionObjectResult");
haveDefaultValue_ = coeffs.readIfPresent("defaultValue", defaultValue_);
}
template<class Type>
Foam::Function1Types::FunctionObjectValue<Type>::FunctionObjectValue
(
const word& entryName,
const dictionary& dict,
const objectRegistry* obrPtr
)
:
Function1<Type>(entryName, dict, obrPtr),
foName_(),
foResultName_(),
defaultValue_(Zero),
haveDefaultValue_(false)
{
read(dict);
}
template<class Type>
Foam::Function1Types::FunctionObjectValue<Type>::FunctionObjectValue
(
const FunctionObjectValue<Type>& rhs
)
:
Function1<Type>(rhs),
foName_(rhs.foName_),
foResultName_(rhs.foResultName_),
defaultValue_(rhs.defaultValue_),
haveDefaultValue_(rhs.haveDefaultValue_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::Function1Types::FunctionObjectValue<Type>::writeEntries
(
Ostream& os
) const
{
os.writeEntry("functionObject", foName_);
os.writeEntry("functionObjectResult", foResultName_);
if (haveDefaultValue_)
{
os.writeEntry("defaultValue", defaultValue_);
}
}
template<class Type>
void Foam::Function1Types::FunctionObjectValue<Type>::writeData
(
Ostream& os
) const
{
Function1<Type>::writeData(os);
os.endEntry();
os.beginBlock(word(this->name() + "Coeffs"));
writeEntries(os);
os.endBlock();
}
// ************************************************************************* //

View File

@ -0,0 +1,163 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::Function1Types::FunctionObjectValue
Description
Returns a value retrieved from a function object result.
Usage:
\verbatim
<entryName> functionObjectValue;
<entryName>Coeffs
{
functionObject <name>;
functionObjectResult <function object result field>;
defaultValue <value>; // optional
}
\endverbatim
Note
- does not implement integrate()
SourceFiles
FunctionObjectValue.C
FunctionObjectValueI.H
\*---------------------------------------------------------------------------*/
#ifndef Function1Types_FunctionObjectValue_H
#define Function1Types_FunctionObjectValue_H
#include "Function1.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace Function1Types
{
/*---------------------------------------------------------------------------*\
Class FunctionObjectValue Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class FunctionObjectValue
:
public Function1<Type>
{
// Private Data
//- Function object name
word foName_;
//- Function object result name
word foResultName_;
//- Default value when function object result is unavailable
Type defaultValue_;
//- Flag to indicate that default value is available
bool haveDefaultValue_;
// Private Member Functions
//- Read the coefficients from the given dictionary
void read(const dictionary& coeffs);
public:
//- Runtime type information
TypeName("functionObjectValue");
// Generated Methods
//- No copy assignment
void operator=(const FunctionObjectValue<Type>&) = delete;
// Constructors
//- Construct from entry name, dictionary and optional registry
FunctionObjectValue
(
const word& entryName,
const dictionary& dict,
const objectRegistry* obrPtr = nullptr
);
//- Copy construct
explicit FunctionObjectValue(const FunctionObjectValue<Type>& rhs);
//- Construct and return a clone
virtual tmp<Function1<Type>> clone() const
{
return tmp<Function1<Type>>(new FunctionObjectValue<Type>(*this));
}
//- Destructor
virtual ~FunctionObjectValue() = default;
// Member Functions
//- Return value at current time
virtual inline Type value(const scalar /*unused*/) const;
//- Integrate between two (scalar) values. Not implemented!
virtual Type integrate(const scalar x1, const scalar x2) const;
//- Write in dictionary format
virtual void writeData(Ostream& os) const;
//- Write coefficient entries in dictionary format
void writeEntries(Ostream& os) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Function1Types
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "FunctionObjectValueI.H"
#ifdef NoRepository
#include "FunctionObjectValue.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,102 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "FunctionObjectValue.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
inline Type Foam::Function1Types::FunctionObjectValue<Type>::value
(
const scalar /*unused*/
) const
{
const auto& props = this->time().functionObjects().propsDict();
if (!props.hasResultObject(foName_))
{
if (haveDefaultValue_)
{
DebugInfo
<< " Function object " << foName_
<< " not found; using default value " << defaultValue_
<< endl;
return defaultValue_;
}
FatalErrorInFunction
<< "Function object " << foName_
<< " results not found. Valid objects with results include: "
<< props.objectResultNames()
<< exit(FatalError);
}
if (!props.hasResultObjectEntry(foName_, foResultName_))
{
if (haveDefaultValue_)
{
DebugInfo
<< " Function object " << foName_
<< " result " << foResultName_
<< " not found; using default value " << defaultValue_
<< endl;
return defaultValue_;
}
FatalErrorInFunction
<< "Function object " << foName_
<< " does not have a result field " << foResultName_ << nl
<< " Available result fields include: "
<< props.objectResultEntries(foName_)
<< exit(FatalError);
}
Type value = props.template getObjectResult<Type>(foName_, foResultName_);
DebugInfo
<< " Using " << foName_ << " function object value: " << value
<< endl;
return value;
}
template<class Type>
inline Type Foam::Function1Types::FunctionObjectValue<Type>::integrate
(
const scalar x1,
const scalar x2
) const
{
NotImplemented;
return pTraits<Type>::zero;
}
// ************************************************************************* //

View File

@ -0,0 +1,178 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "InputValueMapper.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
template<class Type>
const Foam::Enum
<
typename Foam::Function1Types::InputValueMapper<Type>::mappingMode
>
Foam::Function1Types::InputValueMapper<Type>::mappingModeNames_
({
{ mappingMode::NONE, "none" },
{ mappingMode::FUNCTION1, "function" },
{ mappingMode::MINMAX, "minMax" },
});
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
void Foam::Function1Types::InputValueMapper<Type>::read
(
const dictionary& coeffs
)
{
mappingMode_ = mappingModeNames_.get("mode", coeffs);
switch (mappingMode_)
{
case mappingMode::NONE:
{
break;
}
case mappingMode::FUNCTION1:
{
mappingValuePtr_.reset
(
Function1<scalar>::New("function", coeffs, this->obrPtr_)
);
break;
}
case mappingMode::MINMAX:
{
min_ = coeffs.get<scalar>("min");
max_ = coeffs.get<scalar>("max");
break;
}
default:
{
FatalErrorInFunction
<< "Unhandled enumeration " << mappingModeNames_[mappingMode_]
<< ". Available options are: " << mappingModeNames_.sortedToc()
<< abort(FatalError);
}
}
value_ = Function1<Type>::New("value", coeffs, this->obrPtr_);
}
template<class Type>
Foam::Function1Types::InputValueMapper<Type>::InputValueMapper
(
const word& entryName,
const dictionary& dict,
const objectRegistry* obrPtr
)
:
Function1<Type>(entryName, obrPtr),
mappingMode_(mappingMode::NONE),
mappingValuePtr_(nullptr),
min_(0),
max_(0),
value_(nullptr)
{
read(dict);
}
template<class Type>
Foam::Function1Types::InputValueMapper<Type>::InputValueMapper
(
const InputValueMapper<Type>& rhs
)
:
Function1<Type>(rhs),
mappingMode_(rhs.mappingMode_),
mappingValuePtr_(rhs.mappingValuePtr_.clone()),
min_(rhs.min_),
max_(rhs.max_),
value_(rhs.value_.clone())
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::Function1Types::InputValueMapper<Type>::writeEntries
(
Ostream& os
) const
{
os.writeEntry("mode", mappingModeNames_[mappingMode_]);
switch (mappingMode_)
{
case mappingMode::NONE:
{
break;
}
case mappingMode::FUNCTION1:
{
mappingValuePtr_->writeData(os);
break;
}
case mappingMode::MINMAX:
{
os.writeEntry("min", min_);
os.writeEntry("max", max_);
break;
}
default:
{
FatalErrorInFunction
<< "Unhandled enumeration " << mappingModeNames_[mappingMode_]
<< ". Available options are: " << mappingModeNames_.sortedToc()
<< abort(FatalError);
}
}
value_->writeData(os);
}
template<class Type>
void Foam::Function1Types::InputValueMapper<Type>::writeData(Ostream& os) const
{
Function1<Type>::writeData(os);
os.endEntry();
os.beginBlock(word(this->name() + "Coeffs"));
writeEntries(os);
os.endBlock();
}
// ************************************************************************* //

View File

@ -24,18 +24,21 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::Function1Types::LimitRange
Foam::Function1Types::InputValueMapper
Description
Function1 wrapper that limits the input range of another Function1
Function1 wrapper that maps the input value prior to it being used by
another Function1.
Example usage for limiting a polynomial:
\verbatim
<entryName>
{
type limitRange;
min 0.4;
max 1.4;
type inputValueMapper;
mode minMax;
min 0.4;
max 1.4;
value polynomial
(
@ -53,18 +56,24 @@ Description
- poly(x) for 0.4 < x < 1.4.
Example usage for limiting a file-based table:
Example usage for supplying a patch mass flux for a table lookup:
\verbatim
<entryName>
{
type limitRange;
min 0.4;
max 1.4;
type inputValueMapper;
mode function;
function
{
type functionObjectValue;
functionObject surfaceFieldValue1;
functionObjectResult sum(outlet,phi);
}
value
{
type table;
file "<system>/fanCurve.txt";
type table;
file "<system>/fanCurve.txt";
}
}
\endverbatim
@ -72,20 +81,34 @@ Description
Where:
\table
Property | Description | Required
min | Minimum input value | yes
max | Maximum input value | yes
mode | Mapping mode (see below) | yes
function | Mapping Function1 | no*
min | Minimum input value | no*
max | Maximum input value | no*
value | Function of type Function1<Type> | yes
\endtable
Mapping modes include
- none : the input value is simply passed to the 'value' Function1
- function : the input value is passed through the 'function' Function1
before being passed to the 'value' Function1
- minMax : limits the input value to 'min' and 'max' values before being
passed to the 'value' Function1
Note
Replaces the LimitRange Function1 (v2106 and earlier)
SourceFiles
LimitRange.C
InputValueMapper.C
InputValueMapperI.H
\*---------------------------------------------------------------------------*/
#ifndef Function1Types_LimitRange_H
#define Function1Types_LimitRange_H
#ifndef Function1Types_InputValueMapper_H
#define Function1Types_InputValueMapper_H
#include "Function1.H"
#include "Enum.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -95,24 +118,56 @@ namespace Function1Types
{
/*---------------------------------------------------------------------------*\
Class LimitRange Declaration
Class InputValueMapper Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class LimitRange
class InputValueMapper
:
public Function1<Type>
{
public:
// Public Enumerations
//- Input value mapping mode
enum class mappingMode
{
NONE,
FUNCTION1,
MINMAX
};
//- Names for the input value mapping modes
static const Enum<mappingMode> mappingModeNames_;
private:
// Private Data
//- Minimum input value
scalar min_;
//- Mapping mode
mappingMode mappingMode_;
//- Maximum input value
scalar max_;
// Function1 mapping
//- Value function
autoPtr<Function1<Type>> value_;
//- Input value Function1
autoPtr<Function1<scalar>> mappingValuePtr_;
// Min/max mapping
//- Minimum input value
scalar min_;
//- Maximum input value
scalar max_;
// Function being wrapped
//- Value function
autoPtr<Function1<Type>> value_;
// Private Member Functions
@ -124,26 +179,31 @@ class LimitRange
public:
//- Runtime type information
TypeName("limitRange");
TypeName("inputValueMapper");
// Generated Methods
//- No copy assignment
void operator=(const LimitRange<Type>&) = delete;
void operator=(const InputValueMapper<Type>&) = delete;
// Constructors
//- Construct from entry name and dictionary
LimitRange(const word& entryName, const dictionary& dict);
//- Construct from entry name, dictionary and optional registry
InputValueMapper
(
const word& entryName,
const dictionary& dict,
const objectRegistry* obrPtr = nullptr
);
//- Copy construct
explicit LimitRange(const LimitRange<Type>& rhs);
explicit InputValueMapper(const InputValueMapper<Type>& rhs);
//- Destructor
virtual ~LimitRange() = default;
virtual ~InputValueMapper() = default;
// Member Functions
@ -169,10 +229,10 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "LimitRangeI.H"
#include "InputValueMapperI.H"
#ifdef NoRepository
#include "LimitRange.C"
#include "InputValueMapper.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -0,0 +1,119 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "InputValueMapper.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
inline Type Foam::Function1Types::InputValueMapper<Type>::value
(
const scalar t
) const
{
switch (mappingMode_)
{
case mappingMode::NONE:
{
return value_->value(t);;
}
case mappingMode::FUNCTION1:
{
return value_->value(mappingValuePtr_->value(t));
}
case mappingMode::MINMAX:
{
scalar tlim = min(max(t, min_), max_);
return value_->value(tlim);
}
default:
{
FatalErrorInFunction
<< "Unhandled enumeration " << mappingModeNames_[mappingMode_]
<< ". Available options are: " << mappingModeNames_.sortedToc()
<< abort(FatalError);
}
}
return pTraits<Type>::zero;
}
template<class Type>
Type Foam::Function1Types::InputValueMapper<Type>::integrate
(
const scalar x1,
const scalar x2
) const
{
switch (mappingMode_)
{
case mappingMode::NONE:
{
return value_->integrate(x1, x2);
}
case mappingMode::FUNCTION1:
{
scalar x1Dash = mappingValuePtr_->value(x1);
scalar x2Dash = mappingValuePtr_->value(x2);
return value_->integrate(x1Dash, x2Dash);
}
case mappingMode::MINMAX:
{
scalar xlim0 = min(max(x1, min_), max_);
scalar xlim1 = min(max(x2, min_), max_);
Type intValue = value_->integrate(xlim0, xlim1);
if (x1 < min_)
{
intValue += (min(min_, x2) - x1)*this->value(min_);
}
if (x2 > max_)
{
intValue += (x2 - max(max_, x1))*this->value(max_);
}
return intValue;
}
default:
{
FatalErrorInFunction
<< "Unhandled enumeration " << mappingModeNames_[mappingMode_]
<< ". Available options are: " << mappingModeNames_.sortedToc()
<< abort(FatalError);
}
}
return pTraits<Type>::zero;
}
// ************************************************************************* //

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -30,9 +31,13 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::Function1Types::OneConstant<Type>::OneConstant(const word& entryName)
Foam::Function1Types::OneConstant<Type>::OneConstant
(
const word& entryName,
const objectRegistry* obrPtr
)
:
Function1<Type>(entryName)
Function1<Type>(entryName, obrPtr)
{}
@ -40,10 +45,11 @@ template<class Type>
Foam::Function1Types::OneConstant<Type>::OneConstant
(
const word& entryName,
const dictionary& dict
const dictionary& dict,
const objectRegistry* obrPtr
)
:
Function1<Type>(entryName, dict)
Function1<Type>(entryName, dict, obrPtr)
{}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -75,11 +75,20 @@ public:
// Constructors
//- Construct from entry name
explicit OneConstant(const word& entryName);
//- Construct from entry name and optional registry
explicit OneConstant
(
const word& entryName,
const objectRegistry* obrPtr = nullptr
);
//- Construct from entry name and dictionary
OneConstant(const word& entryName, const dictionary& dict);
//- Construct from entry name, dictionary and optional registry
OneConstant
(
const word& entryName,
const dictionary& dict,
const objectRegistry* obrPtr = nullptr
);
//- Construct and return a clone
virtual tmp<Function1<Type>> clone() const

View File

@ -65,10 +65,11 @@ template<class Type>
Foam::Function1Types::Polynomial<Type>::Polynomial
(
const word& entryName,
const dictionary& dict
const dictionary& dict,
const objectRegistry* obrPtr
)
:
Function1<Type>(entryName, dict),
Function1<Type>(entryName, dict, obrPtr),
coeffs_(),
canIntegrate_(true)
{
@ -104,10 +105,11 @@ template<class Type>
Foam::Function1Types::Polynomial<Type>::Polynomial
(
const word& entryName,
const List<Tuple2<Type, Type>>& coeffs
const List<Tuple2<Type, Type>>& coeffs,
const objectRegistry* obrPtr
)
:
Function1<Type>(entryName),
Function1<Type>(entryName, obrPtr),
coeffs_(coeffs),
canIntegrate_(true)
{
@ -127,7 +129,7 @@ Foam::Function1Types::Polynomial<Type>::Polynomial(const Polynomial& poly)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::Function1Types::Polynomial<Type>::convertTimeBase(const Time& t)
void Foam::Function1Types::Polynomial<Type>::userTimeToTime(const Time& t)
{
forAll(coeffs_, i)
{

View File

@ -108,14 +108,20 @@ public:
// Constructors
//- Construct from entry name and dictionary
Polynomial(const word& entryName, const dictionary& dict);
//- Construct from entry name, dictionary and optional registry
Polynomial
(
const word& entryName,
const dictionary& dict,
const objectRegistry* obrPtr = nullptr
);
//- Construct from components
Polynomial
(
const word& entryName,
const List<Tuple2<Type, Type>>& coeffs
const List<Tuple2<Type, Type>>& coeffs,
const objectRegistry* obrPtr = nullptr
);
//- Copy constructor
@ -135,7 +141,7 @@ public:
// Member Functions
//- Convert time
virtual void convertTimeBase(const Time& t);
virtual void userTimeToTime(const Time& t);
//- Return Polynomial value
virtual Type value(const scalar x) const;

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -28,24 +28,27 @@ License
#include "Scale.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Type>
void Foam::Function1Types::Scale<Type>::read(const dictionary& coeffs)
{
scale_ = Function1<scalar>::New("scale", coeffs);
value_ = Function1<Type>::New("value", coeffs);
scale_ = Function1<scalar>::New("scale", coeffs, this->obrPtr_);
value_ = Function1<Type>::New("value", coeffs, this->obrPtr_);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::Function1Types::Scale<Type>::Scale
(
const word& entryName,
const dictionary& dict
const dictionary& dict,
const objectRegistry* obrPtr
)
:
Function1<Type>(entryName)
Function1<Type>(entryName, obrPtr)
{
read(dict);
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -122,11 +122,12 @@ public:
// Constructors
//- Construct from entry name and dictionary
//- Construct from entry name, dictionary and optional registry
Scale
(
const word& entryName,
const dictionary& dict
const dictionary& dict,
const objectRegistry* obrPtr = nullptr
);
//- Copy construct

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2017 OpenFOAM Foundation
Copyright (C) 2016-2020 OpenCFD Ltd.
Copyright (C) 2016-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -34,20 +34,27 @@ template<class Type>
Foam::Function1Types::Sine<Type>::Sine
(
const word& entryName,
const dictionary& dict
const dictionary& dict,
const objectRegistry* obrPtr
)
:
Function1<Type>(entryName, dict),
Function1<Type>(entryName, dict, obrPtr),
t0_(dict.getOrDefault<scalar>("t0", 0)),
amplitude_(Function1<scalar>::NewIfPresent("amplitude", dict)),
period_(Function1<scalar>::NewIfPresent("period", dict)),
amplitude_
(
Function1<scalar>::NewIfPresent("amplitude", dict, word::null, obrPtr)
),
period_
(
Function1<scalar>::NewIfPresent("period", dict, word::null, obrPtr)
),
frequency_(nullptr),
scale_(Function1<Type>::New("scale", dict)),
level_(Function1<Type>::New("level", dict))
scale_(Function1<Type>::New("scale", dict, obrPtr)),
level_(Function1<Type>::New("level", dict, obrPtr))
{
if (!period_)
{
frequency_ = Function1<scalar>::New("frequency", dict);
frequency_ = Function1<scalar>::New("frequency", dict, obrPtr);
}
}
@ -68,9 +75,9 @@ Foam::Function1Types::Sine<Type>::Sine(const Sine<Type>& rhs)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::Function1Types::Sine<Type>::convertTimeBase(const Time& t)
void Foam::Function1Types::Sine<Type>::userTimeToTime(const Time& t)
{
t0_ = t.timeToUserTime(t0_);
t0_ = t.userTimeToTime(t0_);
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2017 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -181,8 +181,13 @@ public:
// Constructors
//- Construct from entry name and dictionary
Sine(const word& entryName, const dictionary& dict);
//- Construct from entry name, dictionary and optional registry
Sine
(
const word& entryName,
const dictionary& dict,
const objectRegistry* obrPtr = nullptr
);
//- Copy construct
explicit Sine(const Sine<Type>& rhs);
@ -195,7 +200,7 @@ public:
// Member Functions
//- Convert time
virtual void convertTimeBase(const Time& t);
virtual void userTimeToTime(const Time& t);
//- Return value for time t
virtual inline Type value(const scalar t) const

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2017 OpenFOAM Foundation
Copyright (C) 2016-2020 OpenCFD Ltd.
Copyright (C) 2016-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -34,10 +34,11 @@ template<class Type>
Foam::Function1Types::Square<Type>::Square
(
const word& entryName,
const dictionary& dict
const dictionary& dict,
const objectRegistry* obrPtr
)
:
Sine<Type>(entryName, dict),
Sine<Type>(entryName, dict, obrPtr),
mark_(dict.getOrDefaultCompat<scalar>("mark", {{"markSpace", 2006}}, 1)),
space_(dict.getOrDefault<scalar>("space", 1))
{}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2017 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -144,8 +144,13 @@ public:
// Constructors
//- Construct from entry name and dictionary
Square(const word& entryName, const dictionary& dict);
//- Construct from entry name, dictionary and optional registry
Square
(
const word& entryName,
const dictionary& dict,
const objectRegistry* obrPtr = nullptr
);
//- Copy construct
explicit Square(const Square<Type>& rhs);

View File

@ -34,10 +34,11 @@ template<class Type>
Foam::Function1Types::Table<Type>::Table
(
const word& entryName,
const dictionary& dict
const dictionary& dict,
const objectRegistry* obrPtr
)
:
TableBase<Type>(entryName, dict),
TableBase<Type>(entryName, dict, obrPtr),
fName_()
{
const entry* eptr = dict.findEntry(entryName, keyType::LITERAL);
@ -84,7 +85,7 @@ Foam::Function1Types::Table<Type>::Table
dict.readEntry("values", this->table_);
}
TableBase<Type>::check();
TableBase<Type>::initialise();
}

View File

@ -119,8 +119,13 @@ public:
// Constructors
//- Construct from entry name and dictionary.
Table(const word& entryName, const dictionary& dict);
//- Construct from entry name, dictionary and optional registry
Table
(
const word& entryName,
const dictionary& dict,
const objectRegistry* obrPtr = nullptr
);
//- Copy construct
explicit Table(const Table<Type>& tbl);

View File

@ -62,10 +62,11 @@ template<class Type>
Foam::Function1Types::TableBase<Type>::TableBase
(
const word& name,
const dictionary& dict
const dictionary& dict,
const objectRegistry* obrPtr
)
:
Function1<Type>(name, dict),
Function1<Type>(name, dict, obrPtr),
bounding_
(
bounds::repeatableBoundingNames.getOrDefault
@ -103,17 +104,10 @@ Foam::Function1Types::TableBase<Type>::TableBase(const TableBase<Type>& tbl)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class Type>
Foam::Function1Types::TableBase<Type>::~TableBase()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::Function1Types::TableBase<Type>::check() const
void Foam::Function1Types::TableBase<Type>::initialise()
{
if (!table_.size())
{
@ -260,7 +254,7 @@ bool Foam::Function1Types::TableBase<Type>::checkMaxBounds
template<class Type>
void Foam::Function1Types::TableBase<Type>::convertTimeBase(const Time& t)
void Foam::Function1Types::TableBase<Type>::userTimeToTime(const Time& t)
{
for (auto& item : table_)
{

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -101,20 +101,25 @@ public:
// Constructors
//- Construct from dictionary - note table is not populated
TableBase(const word& name, const dictionary& dict);
TableBase
(
const word& name,
const dictionary& dict,
const objectRegistry* obrPtr = nullptr
);
//- Copy constructor. Note: steals interpolator, tableSamples
explicit TableBase(const TableBase<Type>& tbl);
//- Destructor
virtual ~TableBase();
virtual ~TableBase() = default;
// Member Functions
//- Check the table for size and consistency
void check() const;
void initialise();
//- Check minimum table bounds
bool checkMinBounds(const scalar x, scalar& xDash) const;
@ -123,7 +128,7 @@ public:
bool checkMaxBounds(const scalar x, scalar& xDash) const;
//- Convert time
virtual void convertTimeBase(const Time& t);
virtual void userTimeToTime(const Time& t);
//- Return Table value
virtual Type value(const scalar x) const;

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2016-2019 OpenCFD Ltd.
Copyright (C) 2016-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -34,10 +34,11 @@ template<class Type>
Foam::Function1Types::TableFile<Type>::TableFile
(
const word& entryName,
const dictionary& dict
const dictionary& dict,
const objectRegistry* obrPtr
)
:
TableBase<Type>(entryName, dict),
TableBase<Type>(entryName, dict, obrPtr),
fName_()
{
dict.readEntry("file", fName_);
@ -56,7 +57,7 @@ Foam::Function1Types::TableFile<Type>::TableFile
is >> this->table_;
TableBase<Type>::check();
TableBase<Type>::initialise();
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2019-2020 OpenCFD Ltd.
Copyright (C) 2019-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -101,7 +101,12 @@ public:
// Constructors
//- Construct from entry name and "file" found in dictionary
TableFile(const word& entryName, const dictionary& dict);
TableFile
(
const word& entryName,
const dictionary& dict,
const objectRegistry* obrPtr = nullptr
);
//- Copy construct
explicit TableFile(const TableFile<Type>& tbl);

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -38,15 +38,12 @@ Description
<entryName> uniform <value>
\endverbatim
SourceFiles
Uniform.C
\*---------------------------------------------------------------------------*/
#ifndef Function1Types_Uniform_H
#define Function1Types_Uniform_H
#include "Function1.H"
#include "Constant.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -81,8 +78,16 @@ public:
// Constructors
//- Construct from entry name and dictionary
Uniform(const word& entryName, const dictionary& dict);
//- Construct from entry name, dictionary and optional registry
Uniform
(
const word& entryName,
const dictionary& dict,
const objectRegistry* obrPtr = nullptr
)
:
Constant<Type>(entryName, dict, obrPtr)
{}
};
@ -93,12 +98,6 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "Uniform.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -31,9 +31,13 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::Function1Types::ZeroConstant<Type>::ZeroConstant(const word& entryName)
Foam::Function1Types::ZeroConstant<Type>::ZeroConstant
(
const word& entryName,
const objectRegistry* obrPtr
)
:
Function1<Type>(entryName)
Function1<Type>(entryName, obrPtr)
{}
@ -41,10 +45,11 @@ template<class Type>
Foam::Function1Types::ZeroConstant<Type>::ZeroConstant
(
const word& entryName,
const dictionary& dict
const dictionary& dict,
const objectRegistry* obrPtr
)
:
Function1<Type>(entryName, dict)
Function1<Type>(entryName, dict, obrPtr)
{}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -84,11 +84,20 @@ public:
// Constructors
//- Construct from entry name
explicit ZeroConstant(const word& entryName);
//- Construct from entry name and optional registry
explicit ZeroConstant
(
const word& entryName,
const objectRegistry* obrPtr = nullptr
);
//- Construct from entry name and dictionary
ZeroConstant(const word& entryName, const dictionary& dict);
//- Construct from entry name, dictionary and optional registry
ZeroConstant
(
const word& entryName,
const dictionary& dict,
const objectRegistry* obrPtr = nullptr
);
//- Destructor

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -43,10 +44,11 @@ namespace Function1Types
Foam::Function1Types::halfCosineRamp::halfCosineRamp
(
const word& entryName,
const dictionary& dict
const dictionary& dict,
const objectRegistry* obrPtr
)
:
ramp(entryName, dict)
ramp(entryName, dict, obrPtr)
{}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -67,8 +67,13 @@ public:
// Constructors
//- Construct from entry name and dictionary
halfCosineRamp(const word& entryName, const dictionary& dict);
//- Construct from entry name, dictionary and optional registry
halfCosineRamp
(
const word& entryName,
const dictionary& dict,
const objectRegistry* obrPtr = nullptr
);
//- Destructor

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -43,10 +44,11 @@ namespace Function1Types
Foam::Function1Types::linearRamp::linearRamp
(
const word& entryName,
const dictionary& dict
const dictionary& dict,
const objectRegistry* obrPtr
)
:
ramp(entryName, dict)
ramp(entryName, dict, obrPtr)
{}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -67,8 +67,13 @@ public:
// Constructors
//- Construct from entry name and dictionary
linearRamp(const word& entryName, const dictionary& dict);
//- Construct from entry name, dictionary and optional registry
linearRamp
(
const word& entryName,
const dictionary& dict,
const objectRegistry* obrPtr = nullptr
);
//- Destructor

View File

@ -38,7 +38,9 @@ License
#include "Table.H"
#include "TableFile.H"
#include "Scale.H"
#include "LimitRange.H"
#include "InputValueMapper.H"
#include "FunctionObjectTrigger.H"
#include "FunctionObjectValue.H"
#include "fieldTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -57,7 +59,8 @@ License
makeFunction1Type(Table, Type); \
makeFunction1Type(TableFile, Type); \
makeFunction1Type(Scale, Type); \
makeFunction1Type(LimitRange, Type);
makeFunction1Type(InputValueMapper, Type); \
makeFunction1Type(FunctionObjectValue, Type);
#define makeFieldFunction1s(Type) \
makeFunction1(Type); \
@ -71,6 +74,10 @@ namespace Foam
makeFunction1(label);
makeFunction1Type(Constant, label);
makeFunction1Type(FunctionObjectTrigger, label);
makeFunction1Type(FunctionObjectTrigger, scalar);
// Only (label/scalar) makes sense for triggers
makeFunction1s(scalar);
makeFunction1s(vector);
makeFunction1s(sphericalTensor);

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -43,10 +44,11 @@ namespace Function1Types
Foam::Function1Types::quadraticRamp::quadraticRamp
(
const word& entryName,
const dictionary& dict
const dictionary& dict,
const objectRegistry* obrPtr
)
:
ramp(entryName, dict)
ramp(entryName, dict, obrPtr)
{}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -67,8 +67,13 @@ public:
// Constructors
//- Construct from entry name and dictionary
quadraticRamp(const word& entryName, const dictionary& dict);
//- Construct from entry name, dictionary and optional registry
quadraticRamp
(
const word& entryName,
const dictionary& dict,
const objectRegistry* obrPtr = nullptr
);
//- Destructor

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -43,7 +44,8 @@ namespace Function1Types
Foam::Function1Types::quarterCosineRamp::quarterCosineRamp
(
const word& entryName,
const dictionary& dict
const dictionary& dict,
const objectRegistry* obrPtr
)
:
ramp(entryName, dict)

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -67,8 +67,13 @@ public:
// Constructors
//- Construct from entry name and dictionary
quarterCosineRamp(const word& entryName, const dictionary& dict);
//- Construct from entry name, dictionary and optional registry
quarterCosineRamp
(
const word& entryName,
const dictionary& dict,
const objectRegistry* obrPtr = nullptr
);
//- Destructor

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -43,10 +44,11 @@ namespace Function1Types
Foam::Function1Types::quarterSineRamp::quarterSineRamp
(
const word& entryName,
const dictionary& dict
const dictionary& dict,
const objectRegistry* obrPtr
)
:
ramp(entryName, dict)
ramp(entryName, dict, obrPtr)
{}

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -66,8 +67,13 @@ public:
// Constructors
//- Construct from entry name and dictionary
quarterSineRamp(const word& entryName, const dictionary& dict);
//- Construct from entry name, dictionary and optional registry
quarterSineRamp
(
const word& entryName,
const dictionary& dict,
const objectRegistry* obrPtr = nullptr
);
//- Destructor

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -40,10 +40,11 @@ void Foam::Function1Types::ramp::read(const dictionary& coeffs)
Foam::Function1Types::ramp::ramp
(
const word& entryName,
const dictionary& dict
const dictionary& dict,
const objectRegistry* obrPtr
)
:
Function1<scalar>(entryName, dict)
Function1<scalar>(entryName, dict, obrPtr)
{
read(dict);
}
@ -58,10 +59,10 @@ void Foam::Function1Types::ramp::writeEntries(Ostream& os) const
}
void Foam::Function1Types::ramp::convertTimeBase(const Time& t)
void Foam::Function1Types::ramp::userTimeToTime(const Time& t)
{
start_ = t.timeToUserTime(start_);
duration_ = t.timeToUserTime(duration_);
start_ = t.userTimeToTime(start_);
duration_ = t.userTimeToTime(duration_);
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -119,11 +119,12 @@ public:
// Constructors
//- Construct from entry name and dictionary
//- Construct from entry name, dictionary and optional registry
ramp
(
const word& entryName,
const dictionary& dict
const dictionary& dict,
const objectRegistry* obrPtr = nullptr
);
@ -134,7 +135,7 @@ public:
// Member Functions
//- Convert time
virtual void convertTimeBase(const Time& t);
virtual void userTimeToTime(const Time& t);
//- Return value for time t
virtual scalar value(const scalar t) const = 0;

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -43,10 +43,11 @@ namespace Function1Types
Foam::Function1Types::stepFunction::stepFunction
(
const word& entryName,
const dictionary& dict
const dictionary& dict,
const objectRegistry* obrPtr
)
:
ramp(entryName, dict)
ramp(entryName, dict, obrPtr)
{}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -66,8 +66,13 @@ public:
// Constructors
//- Construct from entry name and dictionary
stepFunction(const word& entryName, const dictionary& dict);
//- Construct from entry name, dictionary and optional registry
stepFunction
(
const word& entryName,
const dictionary& dict,
const objectRegistry* obrPtr = nullptr
);
//- Destructor

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -40,9 +40,10 @@ Foam::TimeFunction1<Type>::TimeFunction1
:
time_(runTime),
name_(entryName),
entry_(Function1<Type>::New(entryName, dict))
entry_(Function1<Type>::New(entryName, dict, &runTime))
{
entry_->convertTimeBase(runTime);
// Time conversion now handled by Function1 directly
// entry_->userTimeToTime(runTime);
}
@ -81,8 +82,8 @@ Foam::TimeFunction1<Type>::TimeFunction1
template<class Type>
void Foam::TimeFunction1<Type>::reset(const dictionary& dict)
{
entry_ = Function1<Type>::New(name_, dict);
entry_->convertTimeBase(time_);
entry_ = Function1<Type>::New(name_, dict, &time_);
entry_->userTimeToTime(time_);
}

View File

@ -110,7 +110,7 @@ externalWallHeatFluxTemperatureFvPatchScalarField
{
case fixedPower:
{
Q_ = Function1<scalar>::New("Q", dict);
Q_ = Function1<scalar>::New("Q", dict, &db());
break;
}
case fixedHeatFlux:
@ -121,7 +121,7 @@ externalWallHeatFluxTemperatureFvPatchScalarField
case fixedHeatTransferCoeff:
{
h_ = PatchFunction1<scalar>::New(patch().patch(), "h", dict);
Ta_ = Function1<scalar>::New("Ta", dict);
Ta_ = Function1<scalar>::New("Ta", dict, &db());
if (dict.readIfPresent("thicknessLayers", thicknessLayers_))
{

View File

@ -59,8 +59,8 @@ Foam::porousBafflePressureFvPatchField::porousBafflePressureFvPatchField
fixedJumpFvPatchField<scalar>(p, iF),
phiName_(dict.getOrDefault<word>("phi", "phi")),
rhoName_(dict.getOrDefault<word>("rho", "rho")),
D_(Function1<scalar>::New("D", dict)),
I_(Function1<scalar>::New("I", dict)),
D_(Function1<scalar>::New("D", dict, &db())),
I_(Function1<scalar>::New("I", dict, &db())),
length_(dict.get<scalar>("length")),
uniformJump_(dict.getOrDefault("uniformJump", false))
{

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2014-2016 OpenFOAM Foundation
Copyright (C) 2018-2020 OpenCFD Ltd.
Copyright (C) 2018-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -45,10 +45,10 @@ atmBoundaryLayer::atmBoundaryLayer(const Time& time, const polyPatch& pp)
ppMin_((boundBox(pp.points())).min()),
time_(time),
patch_(pp),
flowDir_(time, "flowDir"),
zDir_(time, "zDir"),
Uref_(time, "Uref"),
Zref_(time, "Zref"),
flowDir_(nullptr),
zDir_(nullptr),
Uref_(nullptr),
Zref_(nullptr),
z0_(nullptr),
d_(nullptr)
{}
@ -72,10 +72,10 @@ atmBoundaryLayer::atmBoundaryLayer
ppMin_((boundBox(pp.points())).min()),
time_(time),
patch_(pp),
flowDir_(TimeFunction1<vector>(time, "flowDir", dict)),
zDir_(TimeFunction1<vector>(time, "zDir", dict)),
Uref_(TimeFunction1<scalar>(time, "Uref", dict)),
Zref_(TimeFunction1<scalar>(time, "Zref", dict)),
flowDir_(Function1<vector>::New("flowDir", dict, &time)),
zDir_(Function1<vector>::New("zDir", dict, &time)),
Uref_(Function1<scalar>::New("Uref", dict, &time)),
Zref_(Function1<scalar>::New("Zref", dict, &time)),
z0_(PatchFunction1<scalar>::New(pp, "z0", dict)),
d_(PatchFunction1<scalar>::New(pp, "d", dict))
{}
@ -96,10 +96,10 @@ atmBoundaryLayer::atmBoundaryLayer
ppMin_(abl.ppMin_),
time_(abl.time_),
patch_(patch.patch()),
flowDir_(abl.flowDir_),
zDir_(abl.zDir_),
Uref_(abl.Uref_),
Zref_(abl.Zref_),
flowDir_(abl.flowDir_.clone()),
zDir_(abl.zDir_.clone()),
Uref_(abl.Uref_.clone()),
Zref_(abl.Zref_.clone()),
z0_(abl.z0_.clone(patch_)),
d_(abl.d_.clone(patch_))
{}
@ -129,13 +129,13 @@ atmBoundaryLayer::atmBoundaryLayer(const atmBoundaryLayer& abl)
vector atmBoundaryLayer::flowDir() const
{
const scalar t = time_.timeOutputValue();
const vector dir(flowDir_.value(t));
const vector dir(flowDir_->value(t));
const scalar magDir = mag(dir);
if (magDir < SMALL)
{
FatalErrorInFunction
<< "magnitude of " << flowDir_.name() << " = " << magDir
<< "magnitude of " << flowDir_->name() << " = " << magDir
<< " vector must be greater than zero"
<< abort(FatalError);
}
@ -147,13 +147,13 @@ vector atmBoundaryLayer::flowDir() const
vector atmBoundaryLayer::zDir() const
{
const scalar t = time_.timeOutputValue();
const vector dir(zDir_.value(t));
const vector dir(zDir_->value(t));
const scalar magDir = mag(dir);
if (magDir < SMALL)
{
FatalErrorInFunction
<< "magnitude of " << zDir_.name() << " = " << magDir
<< "magnitude of " << zDir_->name() << " = " << magDir
<< " vector must be greater than zero"
<< abort(FatalError);
}
@ -165,13 +165,13 @@ vector atmBoundaryLayer::zDir() const
tmp<scalarField> atmBoundaryLayer::Ustar(const scalarField& z0) const
{
const scalar t = time_.timeOutputValue();
const scalar Uref = Uref_.value(t);
const scalar Zref = Zref_.value(t);
const scalar Uref = Uref_->value(t);
const scalar Zref = Zref_->value(t);
if (Zref < 0)
{
FatalErrorInFunction
<< "Negative entry in " << Zref_.name() << " = " << Zref
<< "Negative entry in " << Zref_->name() << " = " << Zref
<< abort(FatalError);
}
@ -274,10 +274,10 @@ void atmBoundaryLayer::write(Ostream& os) const
os.writeEntry("Cmu", Cmu_);
os.writeEntry("C1", C1_);
os.writeEntry("C2", C2_);
flowDir_.writeData(os);
zDir_.writeData(os);
Uref_.writeData(os);
Zref_.writeData(os);
flowDir_->writeData(os);
zDir_->writeData(os);
Uref_->writeData(os);
Zref_->writeData(os);
if (z0_)
{
z0_->writeData(os) ;

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2014-2018 OpenFOAM Foundation
Copyright (C) 2015-2020 OpenCFD Ltd.
Copyright (C) 2015-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -157,12 +157,12 @@ Usage
where the entries mean:
\table
Property | Description | Type | Reqd | Deflt
flowDir | Flow direction | TimeFunction1<vector> | yes | -
zDir | Ground-normal direction | TimeFunction1<vector> | yes | -
flowDir | Flow direction | Function1<vector> | yes | -
zDir | Ground-normal direction | Function1<vector> | yes | -
Uref | Reference mean streamwise flow speed being used in <!--
--> \f$u^*\f$ estimations [m/s] | TimeFunction1<scalar> | yes | -
--> \f$u^*\f$ estimations [m/s] | Function1<scalar> | yes | -
Zref | Reference height being used in \f$u^*\f$ estimations [m] <!--
--> | TimeFunction1<scalar> | yes | -
--> | Function1<scalar> | yes | -
z0 | Surface roughness length [m] <!--
--> | PatchFunction1<scalar> | yes | -
d | Displacement height [m] - see Notes <!--
@ -217,7 +217,7 @@ SourceFiles
#define atmBoundaryLayer_H
#include "fvPatchFields.H"
#include "TimeFunction1.H"
#include "Function1.H"
#include "PatchFunction1.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -266,16 +266,16 @@ private:
const polyPatch& patch_;
//- Streamwise flow direction
TimeFunction1<vector> flowDir_;
autoPtr<Function1<vector>> flowDir_;
//- Direction of the ground-normal coordinate
TimeFunction1<vector> zDir_;
autoPtr<Function1<vector>> zDir_;
//- Reference mean streamwise flow speed being used in Ustar estimations
TimeFunction1<scalar> Uref_;
autoPtr<Function1<scalar>> Uref_;
//- Reference height being used in Ustar estimations
TimeFunction1<scalar> Zref_;
autoPtr<Function1<scalar>> Zref_;
//- Surface roughness length
autoPtr<PatchFunction1<scalar>> z0_;

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2020 ENERCON GmbH
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -62,7 +62,7 @@ atmTurbulentHeatFluxTemperatureFvPatchScalarField
fixedGradientFvPatchScalarField(p, iF),
heatSource_(heatSourceType::POWER),
alphaEffName_("undefinedAlphaEff"),
Cp0_(db().time(), "Cp0"),
Cp0_(nullptr),
q_(nullptr)
{}
@ -79,7 +79,7 @@ atmTurbulentHeatFluxTemperatureFvPatchScalarField
fixedGradientFvPatchScalarField(ptf, p, iF, mapper),
heatSource_(ptf.heatSource_),
alphaEffName_(ptf.alphaEffName_),
Cp0_(ptf.Cp0_),
Cp0_(ptf.Cp0_.clone()),
q_(ptf.q_.clone(p.patch()))
{}
@ -103,7 +103,7 @@ atmTurbulentHeatFluxTemperatureFvPatchScalarField
)
),
alphaEffName_(dict.get<word>("alphaEff")),
Cp0_(TimeFunction1<scalar>(db().time(), "Cp0", dict)),
Cp0_(Function1<scalar>::New("Cp0", dict, &db())),
q_(PatchFunction1<scalar>::New(p.patch(), "q", dict))
{
if (dict.found("value") && dict.found("gradient"))
@ -189,7 +189,7 @@ void atmTurbulentHeatFluxTemperatureFvPatchScalarField::updateCoeffs()
patch().lookupPatchField<volScalarField, scalar>(alphaEffName_);
const scalar t = db().time().timeOutputValue();
const scalar Cp0 = Cp0_.value(t);
const scalar Cp0 = Cp0_->value(t);
if (Cp0 < SMALL)
{
@ -233,7 +233,7 @@ void atmTurbulentHeatFluxTemperatureFvPatchScalarField::write(Ostream& os) const
fixedGradientFvPatchScalarField::write(os);
os.writeEntry("heatSource", heatSourceTypeNames[heatSource_]);
os.writeEntry("alphaEff", alphaEffName_);
Cp0_.writeData(os);
Cp0_->writeData(os);
q_->writeData(os);
writeEntry("value", os);
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2020 ENERCON GmbH
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -67,14 +67,14 @@ Usage
alphaEff | Name of turbulent thermal diff. field [kg/m/s] <!--
--> | word | yes | -
Cp0 | Specific heat capacity [m2/s2/K] <!--
--> | TimeFunction1<scalar> | yes | -
--> | Function1<scalar> | yes | -
q | Heat source value [W (power) or W/m2 (flux)] <!--
--> | PatchFunction1<scalar> | yes | -
\endtable
The inherited entries are elaborated in:
- \link fixedGradientFvPatchScalarField.H \endlink
- \link TimeFunction1.H \endlink
- \link Function1.H \endlink
- \link PatchFunction1.H \endlink
Options for the \c heatSource entry:
@ -93,7 +93,7 @@ SourceFiles
#include "fvPatchFields.H"
#include "fixedGradientFvPatchFields.H"
#include "TimeFunction1.H"
#include "Function1.H"
#include "PatchFunction1.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -131,7 +131,7 @@ class atmTurbulentHeatFluxTemperatureFvPatchScalarField
word alphaEffName_;
//- Specific heat capacity [m2/s2/K]
TimeFunction1<scalar> Cp0_;
autoPtr<Function1<scalar>> Cp0_;
//- Heat power [W] or flux [W/m2]
// Divided by density, rho, if used in kinematic form

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2020 ENERCON GmbH
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -73,7 +73,7 @@ atmAlphatkWallFunctionFvPatchScalarField
fixedValueFvPatchScalarField(p, iF),
Cmu_(0.09),
kappa_(0.41),
Pr_(db().time(), "Pr"),
Pr_(nullptr),
Prt_(nullptr),
z0_(nullptr)
{
@ -93,7 +93,7 @@ atmAlphatkWallFunctionFvPatchScalarField
fixedValueFvPatchScalarField(ptf, p, iF, mapper),
Cmu_(ptf.Cmu_),
kappa_(ptf.kappa_),
Pr_(ptf.Pr_),
Pr_(ptf.Pr_.clone()),
Prt_(ptf.Prt_.clone(p.patch())),
z0_(ptf.z0_.clone(p.patch()))
{
@ -128,7 +128,7 @@ atmAlphatkWallFunctionFvPatchScalarField
scalarMinMax::ge(SMALL)
)
),
Pr_(TimeFunction1<scalar>(db().time(), "Pr", dict)),
Pr_(Function1<scalar>::New("Pr", dict, &db())),
Prt_(PatchFunction1<scalar>::New(p.patch(), "Prt", dict)),
z0_(PatchFunction1<scalar>::New(p.patch(), "z0", dict))
{
@ -204,7 +204,7 @@ void atmAlphatkWallFunctionFvPatchScalarField::updateCoeffs()
const scalar Cmu25 = pow025(Cmu_);
const scalar t = db().time().timeOutputValue();
const scalar Pr = Pr_.value(t);
const scalar Pr = Pr_->value(t);
#ifdef FULLDEBUG
if (Pr < VSMALL)
@ -289,7 +289,7 @@ void atmAlphatkWallFunctionFvPatchScalarField::write(Ostream& os) const
fvPatchField<scalar>::write(os);
os.writeEntry("Cmu", Cmu_);
os.writeEntry("kappa", kappa_);
Pr_.writeData(os);
Pr_->writeData(os);
Prt_->writeData(os);
z0_->writeData(os);
writeEntry("value", os);

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2020 ENERCON GmbH
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -67,7 +67,7 @@ Usage
\table
Property | Description | Type | Reqd | Dflt
type | Type name: atmAlphatkWallFunction | word | yes | -
Pr | Molecular Prandtl number | TimeFunction1<scalar> | yes | -
Pr | Molecular Prandtl number | Function1<scalar> | yes | -
Prt | Turbulent Prandtl number | PatchFunction1<scalar> | yes | -
z0 | Surface roughness length [m] | PatchFunction1<scalar> | yes | -
Cmu | Empirical model constant | scalar | no | 0.09
@ -76,7 +76,7 @@ Usage
The inherited entries are elaborated in:
- \link fixedValueFvPatchField.H \endlink
- \link TimeFunction1.H \endlink
- \link Function1.H \endlink
- \link PatchFunction1.H \endlink
See also
@ -91,7 +91,7 @@ SourceFiles
#define atmAlphatkWallFunctionFvPatchScalarField_H
#include "fixedValueFvPatchFields.H"
#include "TimeFunction1.H"
#include "Function1.H"
#include "PatchFunction1.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -120,7 +120,7 @@ protected:
const scalar kappa_;
//- Molecular Prandtl number
TimeFunction1<scalar> Pr_;
autoPtr<Function1<scalar>> Pr_;
//- Turbulent Prandtl number field
autoPtr<PatchFunction1<scalar>> Prt_;

View File

@ -76,7 +76,7 @@ Foam::porosityModels::powerLawLopesdaCostaZone::powerLawLopesdaCostaZone
// function of the normalized vertical position
autoPtr<Function1<scalar>> SigmaFunc
(
Function1<scalar>::New("Sigma", dict)
Function1<scalar>::New("Sigma", dict, &mesh)
);
// Searchable triSurface for the top of the porous region

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -57,7 +57,7 @@ Foam::solidBodyMotionFunctions::rotatingMotion::rotatingMotion
solidBodyMotionFunction(SBMFCoeffs, runTime),
origin_(SBMFCoeffs_.get<vector>("origin")),
axis_(SBMFCoeffs_.get<vector>("axis")),
omega_(Function1<scalar>::New("omega", SBMFCoeffs_))
omega_(Function1<scalar>::New("omega", SBMFCoeffs_, &runTime))
{}
@ -89,7 +89,7 @@ bool Foam::solidBodyMotionFunctions::rotatingMotion::read
omega_.reset
(
Function1<scalar>::New("omega", SBMFCoeffs_)
Function1<scalar>::New("omega", SBMFCoeffs_, &time_)
);
return true;

View File

@ -74,7 +74,7 @@ Foam::fa::externalHeatFluxSource::externalHeatFluxSource
Q_(0),
q_(0),
h_(0),
Ta_(),
Ta_(nullptr),
emissivity_(dict.getOrDefault<scalar>("emissivity", 0))
{
fieldNames_.resize(1, TName_);
@ -194,7 +194,7 @@ bool Foam::fa::externalHeatFluxSource::read(const dictionary& dict)
case fixedHeatTransferCoeff:
{
dict.readEntry("h", h_);
Ta_ = Function1<scalar>::New("Ta", dict);
Ta_ = Function1<scalar>::New("Ta", dict, &mesh_);
break;
}
}

View File

@ -41,7 +41,7 @@ void Foam::fa::jouleHeatingSource::initialiseSigma
if (dict.found("sigma"))
{
// Sigma to be defined using a Function1 type
sigmaVsTPtr = Function1<Type>::New("sigma", dict);
sigmaVsTPtr = Function1<Type>::New("sigma", dict, &mesh_);
auto tsigma = tmp<AreaFieldType>::New
(

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018-2020 OpenCFD Ltd.
Copyright (C) 2018-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -256,7 +256,7 @@ Foam::MRFZone::MRFZone
),
origin_(coeffs_.get<vector>("origin")),
axis_(coeffs_.get<vector>("axis").normalise()),
omega_(Function1<scalar>::New("omega", coeffs_))
omega_(Function1<scalar>::New("omega", coeffs_, &mesh_))
{
if (cellZoneName_ == word::null)
{

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -58,7 +58,7 @@ Foam::porosityModels::solidification::solidification
TName_(coeffs_.getOrDefault<word>("T", "T")),
alphaName_(coeffs_.getOrDefault<word>("alpha", "none")),
rhoName_(coeffs_.getOrDefault<word>("rho", "rho")),
D_(Function1<scalar>::New("D", coeffs_))
D_(Function1<scalar>::New("D", coeffs_, &mesh))
{}

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -79,9 +80,12 @@ cylindricalInletVelocityFvPatchVectorField
fixedValueFvPatchField<vector>(p, iF, dict),
origin_(dict.getCompat<vector>("origin", {{"centre", 1712}})),
axis_(dict.lookup("axis")),
axialVelocity_(Function1<scalar>::New("axialVelocity", dict)),
radialVelocity_(Function1<scalar>::New("radialVelocity", dict)),
rpm_(Function1<scalar>::New("rpm", dict))
axialVelocity_(Function1<scalar>::New("axialVelocity", dict, &db())),
radialVelocity_
(
Function1<scalar>::New("radialVelocity", dict, &db())
),
rpm_(Function1<scalar>::New("rpm", dict, &db()))
{}

View File

@ -84,7 +84,7 @@ Foam::fanFvPatchField<Type>::fanFvPatchField
if (this->cyclicPatch().owner())
{
this->jumpTable_ = Function1<Type>::New("jumpTable", dict);
this->jumpTable_ = Function1<Type>::New("jumpTable", dict, &this->db());
}
if (dict.found("value"))

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2020 OpenCFD Ltd
Copyright (C) 2017-2021 OpenCFD Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -103,10 +103,7 @@ Foam::fanPressureFvPatchScalarField::fanPressureFvPatchScalarField
}
else
{
fanCurve_.reset
(
Function1<scalar>::New("fanCurve", dict)
);
fanCurve_.reset(Function1<scalar>::New("fanCurve", dict, &db()));
}
if (nonDimensional_)

View File

@ -52,7 +52,7 @@ Foam::fixedMeanFvPatchField<Type>::fixedMeanFvPatchField
)
:
fixedValueFvPatchField<Type>(p, iF, dict),
meanValue_(Function1<Type>::New("meanValue", dict))
meanValue_(Function1<Type>::New("meanValue", dict, &this->db()))
{
this->patchType() = dict.getOrDefault<word>("patchType", word::null);
}

View File

@ -53,7 +53,7 @@ Foam::fixedMeanOutletInletFvPatchField<Type>::fixedMeanOutletInletFvPatchField
)
:
outletInletFvPatchField<Type>(p, iF),
meanValue_(Function1<Type>::New("meanValue", dict))
meanValue_(Function1<Type>::New("meanValue", dict, &this->db()))
{
this->phiName_ = dict.getOrDefault<word>("phi", "phi");

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2015-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -68,7 +68,7 @@ Foam::fixedProfileFvPatchField<Type>::fixedProfileFvPatchField
)
:
fixedValueFvPatchField<Type>(p, iF, dict, false),
profile_(Function1<Type>::New("profile", dict)),
profile_(Function1<Type>::New("profile", dict, &this->db())),
dir_(dict.lookup("direction")),
origin_(dict.get<scalar>("origin"))
{

View File

@ -70,12 +70,13 @@ flowRateInletVelocityFvPatchVectorField
if (dict.found("volumetricFlowRate"))
{
volumetric_ = true;
flowRate_ = Function1<scalar>::New("volumetricFlowRate", dict);
flowRate_ =
Function1<scalar>::New("volumetricFlowRate", dict, &db());
}
else if (dict.found("massFlowRate"))
{
volumetric_ = false;
flowRate_ = Function1<scalar>::New("massFlowRate", dict);
flowRate_ = Function1<scalar>::New("massFlowRate", dict, &db());
rhoName_ = dict.getOrDefault<word>("rho", "rho");
}
else

View File

@ -62,13 +62,14 @@ flowRateOutletVelocityFvPatchVectorField
if (dict.found("volumetricFlowRate"))
{
volumetric_ = true;
flowRate_ = Function1<scalar>::New("volumetricFlowRate", dict);
flowRate_ =
Function1<scalar>::New("volumetricFlowRate", dict, &db());
rhoName_ = "rho";
}
else if (dict.found("massFlowRate"))
{
volumetric_ = false;
flowRate_ = Function1<scalar>::New("massFlowRate", dict);
flowRate_ = Function1<scalar>::New("massFlowRate", dict, &db());
rhoName_ = dict.getOrDefault<word>("rho", "rho");
}
else

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2020 OpenCFD Ltd.
Copyright (C) 2017-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -89,7 +89,7 @@ rotatingPressureInletOutletVelocityFvPatchVectorField
)
:
pressureInletOutletVelocityFvPatchVectorField(p, iF, dict),
omega_(Function1<vector>::New("omega", dict))
omega_(Function1<vector>::New("omega", dict, &db()))
{
patchType() = dict.getOrDefault<word>("patchType", word::null);
calcTangentialVelocity();

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -68,7 +69,7 @@ rotatingTotalPressureFvPatchScalarField
)
:
totalPressureFvPatchScalarField(p, iF, dict),
omega_(Function1<vector>::New("omega", dict))
omega_(Function1<vector>::New("omega", dict, &db()))
{}

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -57,7 +58,7 @@ rotatingWallVelocityFvPatchVectorField
fixedValueFvPatchField<vector>(p, iF, dict, false),
origin_(dict.lookup("origin")),
axis_(dict.lookup("axis")),
omega_(Function1<scalar>::New("omega", dict))
omega_(Function1<scalar>::New("omega", dict, &db()))
{
if (dict.found("value"))
{

Some files were not shown because too many files have changed in this diff Show More