mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: add Function1 constant() member
- marks if the value is considered to be independent of 'x'. Propagate into PatchFunction1 instead ad hoc checks there. - adjust method name in PatchFunction1 to 'whichDb()' to reflect final changes in Function1 method names. ENH: add a Function1 'none' placeholder function - This is principally useful for interfaces that expect a Function1 but where it is not necessarily used by a particular submodel. TUT: update Function1 creation to use objectRegistry
This commit is contained in:
@ -129,12 +129,6 @@ public:
|
|||||||
//- Return value as a function of (scalar) independent variable
|
//- Return value as a function of (scalar) independent variable
|
||||||
virtual tmp<Field<${TemplateType}>> value(const scalar x) const;
|
virtual tmp<Field<${TemplateType}>> value(const scalar x) const;
|
||||||
|
|
||||||
//- Is value constant (i.e. independent of x)
|
|
||||||
virtual bool constant() const
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Is value uniform (i.e. independent of coordinate)
|
//- Is value uniform (i.e. independent of coordinate)
|
||||||
virtual bool uniform() const
|
virtual bool uniform() const
|
||||||
{
|
{
|
||||||
|
|||||||
@ -117,7 +117,8 @@ void Foam::Function1Types::Constant<Type>::writeData(Ostream& os) const
|
|||||||
{
|
{
|
||||||
Function1<Type>::writeData(os);
|
Function1<Type>::writeData(os);
|
||||||
|
|
||||||
os << token::SPACE << value_ << token::END_STATEMENT << nl;
|
os << token::SPACE << value_;
|
||||||
|
os.endEntry();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -134,6 +134,9 @@ public:
|
|||||||
//- Change the constant value
|
//- Change the constant value
|
||||||
inline void reset(const Type& val);
|
inline void reset(const Type& val);
|
||||||
|
|
||||||
|
//- Value is independent of x
|
||||||
|
virtual inline bool constant() const { return true; }
|
||||||
|
|
||||||
//- Return constant value
|
//- Return constant value
|
||||||
virtual inline Type value(const scalar) const;
|
virtual inline Type value(const scalar) const;
|
||||||
|
|
||||||
|
|||||||
@ -240,6 +240,13 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
|
//- Is value constant (i.e. independent of x)
|
||||||
|
virtual bool constant() const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Evaluation
|
// Evaluation
|
||||||
|
|
||||||
//- Return value as a function of (scalar) independent variable
|
//- Return value as a function of (scalar) independent variable
|
||||||
@ -312,8 +319,6 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
// Evaluation
|
|
||||||
|
|
||||||
using Function1Type::value;
|
using Function1Type::value;
|
||||||
using Function1Type::integrate;
|
using Function1Type::integrate;
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,97 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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 "NoneFunction1.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
Foam::Function1Types::None<Type>::None
|
||||||
|
(
|
||||||
|
const word& entryName,
|
||||||
|
const dictionary& dict,
|
||||||
|
const objectRegistry* obrPtr
|
||||||
|
)
|
||||||
|
:
|
||||||
|
Function1<Type>(entryName, dict, obrPtr),
|
||||||
|
context_(dict.relativeName())
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
Type Foam::Function1Types::None<Type>::value(const scalar) const
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "Function " << this->name() << " is 'none' in " << context_ << nl
|
||||||
|
<< exit(FatalError);
|
||||||
|
|
||||||
|
return pTraits<Type>::zero;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
Type Foam::Function1Types::None<Type>::integral
|
||||||
|
(
|
||||||
|
const scalar x1,
|
||||||
|
const scalar x2
|
||||||
|
)
|
||||||
|
const
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "Function " << this->name() << " is 'none' in " << context_ << nl
|
||||||
|
<< exit(FatalError);
|
||||||
|
|
||||||
|
return pTraits<Type>::zero;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
Foam::tmp<Foam::Field<Type>> Foam::Function1Types::None<Type>::value
|
||||||
|
(
|
||||||
|
const scalarField& x
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "Function " << this->name() << " is 'none' in " << context_ << nl
|
||||||
|
<< exit(FatalError);
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void Foam::Function1Types::None<Type>::writeData(Ostream& os) const
|
||||||
|
{
|
||||||
|
// OR: os.writeEntry(this->name(), this->type());
|
||||||
|
Function1<Type>::writeData(os);
|
||||||
|
os.endEntry();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
132
src/OpenFOAM/primitives/functions/Function1/None/NoneFunction1.H
Normal file
132
src/OpenFOAM/primitives/functions/Function1/None/NoneFunction1.H
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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::None
|
||||||
|
|
||||||
|
Description
|
||||||
|
Templated placeholder function that returns an error message if called.
|
||||||
|
|
||||||
|
This is principally useful for interfaces that expect a Function1
|
||||||
|
but where it is not necessarily used by a particular submodel.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef Function1Types_None_H
|
||||||
|
#define Function1Types_None_H
|
||||||
|
|
||||||
|
#include "Function1.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
namespace Function1Types
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class None Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
class None
|
||||||
|
:
|
||||||
|
public Function1<Type>
|
||||||
|
{
|
||||||
|
// Private Member Data
|
||||||
|
|
||||||
|
//- Context (eg, dictionary name) for the function
|
||||||
|
string context_;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("none");
|
||||||
|
|
||||||
|
|
||||||
|
// Generated Methods
|
||||||
|
|
||||||
|
//- Default copy constructor
|
||||||
|
None(const None<Type>& rhs) = default;
|
||||||
|
|
||||||
|
//- No copy assignment
|
||||||
|
void operator=(const None<Type>&) = delete;
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from entry name, dictionary and optional registry
|
||||||
|
None
|
||||||
|
(
|
||||||
|
const word& entryName,
|
||||||
|
const dictionary& dict,
|
||||||
|
const objectRegistry* obrPtr = nullptr
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct and return a clone
|
||||||
|
virtual tmp<Function1<Type>> clone() const
|
||||||
|
{
|
||||||
|
return tmp<Function1<Type>>(new None<Type>(*this));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~None() = default;
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
//- Value is independent of x
|
||||||
|
virtual inline bool constant() const { return true; }
|
||||||
|
|
||||||
|
//- Placeholder: generates an error if called
|
||||||
|
virtual Type value(const scalar x) const;
|
||||||
|
|
||||||
|
//- Placeholder: generates an error if called
|
||||||
|
virtual Type integral(const scalar x1, const scalar x2) const;
|
||||||
|
|
||||||
|
//- Placeholder: generates an error if called
|
||||||
|
virtual tmp<Field<Type>> value(const scalarField& x) const;
|
||||||
|
|
||||||
|
//- Write as primitive (inline) format
|
||||||
|
virtual void writeData(Ostream& os) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Function1Types
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
#ifdef NoRepository
|
||||||
|
#include "NoneFunction1.C"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -103,6 +103,9 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
|
//- Value is independent of x
|
||||||
|
virtual inline bool constant() const { return true; }
|
||||||
|
|
||||||
//- Return constant value
|
//- Return constant value
|
||||||
virtual inline Type value(const scalar) const;
|
virtual inline Type value(const scalar) const;
|
||||||
|
|
||||||
|
|||||||
@ -90,7 +90,7 @@ Foam::Function1Types::Polynomial<Type>::Polynomial
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Dictionary format - "values" lookup. Eg,
|
// Dictionary format - "coeffs" lookup. Eg,
|
||||||
//
|
//
|
||||||
// key { type polynomial; coeffs ((0 0) (10 1)); }
|
// key { type polynomial; coeffs ((0 0) (10 1)); }
|
||||||
|
|
||||||
@ -203,7 +203,8 @@ void Foam::Function1Types::Polynomial<Type>::writeData(Ostream& os) const
|
|||||||
{
|
{
|
||||||
Function1<Type>::writeData(os);
|
Function1<Type>::writeData(os);
|
||||||
|
|
||||||
os << nl << indent << coeffs_ << token::END_STATEMENT << nl;
|
os << nl << indent << coeffs_;
|
||||||
|
os.endEntry();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -369,7 +369,10 @@ template<class Type>
|
|||||||
void Foam::Function1Types::TableBase<Type>::writeData(Ostream& os) const
|
void Foam::Function1Types::TableBase<Type>::writeData(Ostream& os) const
|
||||||
{
|
{
|
||||||
Function1<Type>::writeData(os);
|
Function1<Type>::writeData(os);
|
||||||
os << nl << indent << table_ << token::END_STATEMENT << nl;
|
|
||||||
|
os << nl << indent << table_;
|
||||||
|
os.endEntry();
|
||||||
|
|
||||||
writeEntries(os);
|
writeEntries(os);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -106,6 +106,9 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
|
//- Value is independent of x
|
||||||
|
virtual inline bool constant() const { return true; }
|
||||||
|
|
||||||
//- Return constant value
|
//- Return constant value
|
||||||
virtual inline Type value(const scalar) const;
|
virtual inline Type value(const scalar) const;
|
||||||
|
|
||||||
|
|||||||
@ -30,6 +30,7 @@ License
|
|||||||
#include "Uniform.H"
|
#include "Uniform.H"
|
||||||
#include "ZeroConstant.H"
|
#include "ZeroConstant.H"
|
||||||
#include "OneConstant.H"
|
#include "OneConstant.H"
|
||||||
|
#include "NoneFunction1.H"
|
||||||
#include "PolynomialEntry.H"
|
#include "PolynomialEntry.H"
|
||||||
#include "Sine.H"
|
#include "Sine.H"
|
||||||
#include "Cosine.H"
|
#include "Cosine.H"
|
||||||
@ -49,6 +50,7 @@ License
|
|||||||
makeFunction1(Type); \
|
makeFunction1(Type); \
|
||||||
makeFunction1Type(Constant, Type); \
|
makeFunction1Type(Constant, Type); \
|
||||||
makeFunction1Type(Uniform, Type); \
|
makeFunction1Type(Uniform, Type); \
|
||||||
|
makeFunction1Type(None, Type); \
|
||||||
makeFunction1Type(ZeroConstant, Type); \
|
makeFunction1Type(ZeroConstant, Type); \
|
||||||
makeFunction1Type(OneConstant, Type); \
|
makeFunction1Type(OneConstant, Type); \
|
||||||
makeFunction1Type(Polynomial, Type); \
|
makeFunction1Type(Polynomial, Type); \
|
||||||
@ -73,6 +75,7 @@ namespace Foam
|
|||||||
{
|
{
|
||||||
makeFunction1(label);
|
makeFunction1(label);
|
||||||
makeFunction1Type(Constant, label);
|
makeFunction1Type(Constant, label);
|
||||||
|
makeFunction1Type(None, label);
|
||||||
|
|
||||||
makeFunction1Type(FunctionObjectTrigger, label);
|
makeFunction1Type(FunctionObjectTrigger, label);
|
||||||
makeFunction1Type(FunctionObjectTrigger, scalar);
|
makeFunction1Type(FunctionObjectTrigger, scalar);
|
||||||
|
|||||||
@ -291,8 +291,8 @@ void Foam::PatchFunction1Types::ConstantField<Type>::writeData
|
|||||||
if (isUniform_)
|
if (isUniform_)
|
||||||
{
|
{
|
||||||
os.writeKeyword(this->name())
|
os.writeKeyword(this->name())
|
||||||
<< word("constant") << token::SPACE << uniformValue_
|
<< word("constant") << token::SPACE << uniformValue_;
|
||||||
<< token::END_STATEMENT << nl;
|
os.endEntry();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2018-2020 OpenCFD Ltd.
|
Copyright (C) 2018-2021 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -170,12 +170,7 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
// Evaluation
|
//- Value is independent of x
|
||||||
|
|
||||||
//- Return constant value
|
|
||||||
virtual inline tmp<Field<Type>> value(const scalar x) const;
|
|
||||||
|
|
||||||
//- Is value constant (i.e. independent of x)
|
|
||||||
virtual inline bool constant() const
|
virtual inline bool constant() const
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
@ -187,6 +182,12 @@ public:
|
|||||||
return isUniform_ && PatchFunction1<Type>::uniform();
|
return isUniform_ && PatchFunction1<Type>::uniform();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Evaluation
|
||||||
|
|
||||||
|
//- Return constant value
|
||||||
|
virtual inline tmp<Field<Type>> value(const scalar x) const;
|
||||||
|
|
||||||
//- Integrate between two values
|
//- Integrate between two values
|
||||||
virtual inline tmp<Field<Type>> integrate
|
virtual inline tmp<Field<Type>> integrate
|
||||||
(
|
(
|
||||||
|
|||||||
@ -64,8 +64,8 @@ SourceFiles
|
|||||||
#define PatchFunction1Types_MappedFile_H
|
#define PatchFunction1Types_MappedFile_H
|
||||||
|
|
||||||
#include "PatchFunction1.H"
|
#include "PatchFunction1.H"
|
||||||
#include "pointToPointPlanarInterpolation.H"
|
|
||||||
#include "Function1.H"
|
#include "Function1.H"
|
||||||
|
#include "pointToPointPlanarInterpolation.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -204,23 +204,24 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
// Evaluation
|
//- Value is independent of x if there is only a single sample time
|
||||||
|
|
||||||
//- Return MappedFile value
|
|
||||||
virtual tmp<Field<Type>> value(const scalar) const;
|
|
||||||
|
|
||||||
//- Is value constant (i.e. independent of x)
|
|
||||||
virtual bool constant() const
|
virtual bool constant() const
|
||||||
{
|
{
|
||||||
return sampleTimes_.size() == 1;
|
return sampleTimes_.size() == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Is value uniform (i.e. independent of coordinate)
|
//- Is value uniform (i.e. independent of coordinate)
|
||||||
virtual bool uniform() const
|
virtual inline bool uniform() const
|
||||||
{
|
{
|
||||||
return PatchFunction1<Type>::uniform();
|
return PatchFunction1<Type>::uniform();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Evaluation
|
||||||
|
|
||||||
|
//- Return MappedFile value
|
||||||
|
virtual tmp<Field<Type>> value(const scalar) const;
|
||||||
|
|
||||||
//- Integrate between two values
|
//- Integrate between two values
|
||||||
virtual tmp<Field<Type>> integrate
|
virtual tmp<Field<Type>> integrate
|
||||||
(
|
(
|
||||||
|
|||||||
@ -79,6 +79,13 @@ Foam::PatchFunction1<Type>::PatchFunction1
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
bool Foam::PatchFunction1<Type>::uniform() const
|
||||||
|
{
|
||||||
|
return !coordSys_.active();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
Foam::tmp<Foam::Field<Type>> Foam::PatchFunction1<Type>::value
|
Foam::tmp<Foam::Field<Type>> Foam::PatchFunction1<Type>::value
|
||||||
(
|
(
|
||||||
@ -89,12 +96,6 @@ Foam::tmp<Foam::Field<Type>> Foam::PatchFunction1<Type>::value
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
bool Foam::PatchFunction1<Type>::uniform() const
|
|
||||||
{
|
|
||||||
return !coordSys_.active();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
Foam::tmp<Foam::Field<Type>> Foam::PatchFunction1<Type>::integrate
|
Foam::tmp<Foam::Field<Type>> Foam::PatchFunction1<Type>::integrate
|
||||||
|
|||||||
@ -90,7 +90,7 @@ protected:
|
|||||||
|
|
||||||
// Protected Data
|
// Protected Data
|
||||||
|
|
||||||
//- Optional local co-ordinate system and scaling
|
//- Optional local coordinate system and scaling
|
||||||
coordinateScaling<Type> coordSys_;
|
coordinateScaling<Type> coordSys_;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -84,7 +84,7 @@ Foam::patchFunction1Base::patchFunction1Base
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
const Foam::objectRegistry* Foam::patchFunction1Base::obrPtr() const
|
const Foam::objectRegistry* Foam::patchFunction1Base::whichDb() const
|
||||||
{
|
{
|
||||||
return &(patch_.boundaryMesh().mesh()); // mesh registry
|
return &(patch_.boundaryMesh().mesh()); // mesh registry
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2020 OpenCFD Ltd.
|
Copyright (C) 2020-2021 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -78,9 +78,6 @@ protected:
|
|||||||
|
|
||||||
// Protected Member Functions
|
// Protected Member Functions
|
||||||
|
|
||||||
//- Return the object registry (ie, the mesh) as pointer
|
|
||||||
const objectRegistry* obrPtr() const;
|
|
||||||
|
|
||||||
//- No copy assignment
|
//- No copy assignment
|
||||||
void operator=(const patchFunction1Base&) = delete;
|
void operator=(const patchFunction1Base&) = delete;
|
||||||
|
|
||||||
@ -149,16 +146,14 @@ public:
|
|||||||
return (faceValues_ ? patch_.size() : patch_.nPoints());
|
return (faceValues_ ? patch_.size() : patch_.nPoints());
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Has an associated objectRegistry (ie, from mesh)
|
|
||||||
/// bool hasDb() const noexcept
|
//- Return the associated registry (ie, the mesh)
|
||||||
/// {
|
const objectRegistry* whichDb() const;
|
||||||
/// return true;
|
|
||||||
/// }
|
|
||||||
|
|
||||||
//- Return the object registry (ie, the mesh)
|
//- Return the object registry (ie, the mesh)
|
||||||
const objectRegistry& obr() const;
|
const objectRegistry& obr() const;
|
||||||
|
|
||||||
//- False: not created with time
|
//- Return false: function not created with time database
|
||||||
/// bool isTime() const noexcept
|
/// bool isTime() const noexcept
|
||||||
/// {
|
/// {
|
||||||
/// return false;
|
/// return false;
|
||||||
|
|||||||
@ -48,7 +48,7 @@ Foam::PatchFunction1Types::UniformValueField<Type>::UniformValueField
|
|||||||
entryName,
|
entryName,
|
||||||
dict,
|
dict,
|
||||||
redirectType,
|
redirectType,
|
||||||
patchFunction1Base::obrPtr() // mesh registry
|
patchFunction1Base::whichDb() // mesh registry
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
{}
|
{}
|
||||||
@ -76,7 +76,7 @@ Foam::PatchFunction1Types::UniformValueField<Type>::UniformValueField
|
|||||||
{
|
{
|
||||||
if (uniformValuePtr_)
|
if (uniformValuePtr_)
|
||||||
{
|
{
|
||||||
uniformValuePtr_->resetDb(patchFunction1Base::obrPtr());
|
uniformValuePtr_->resetDb(patchFunction1Base::whichDb());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -67,6 +67,7 @@ class UniformValueField
|
|||||||
//- Source of uniform values (in local coordinate system)
|
//- Source of uniform values (in local coordinate system)
|
||||||
autoPtr<Foam::Function1<Type>> uniformValuePtr_;
|
autoPtr<Foam::Function1<Type>> uniformValuePtr_;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Runtime type information
|
// Runtime type information
|
||||||
@ -126,13 +127,11 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
// Evaluation
|
|
||||||
|
|
||||||
//- Return UniformValueField value
|
|
||||||
virtual inline tmp<Field<Type>> value(const scalar x) const;
|
|
||||||
|
|
||||||
//- Is value constant (i.e. independent of x)
|
//- Is value constant (i.e. independent of x)
|
||||||
virtual inline bool constant() const;
|
virtual inline bool constant() const
|
||||||
|
{
|
||||||
|
return uniformValuePtr_ && uniformValuePtr_->constant();
|
||||||
|
}
|
||||||
|
|
||||||
//- Is value uniform (i.e. independent of coordinate)
|
//- Is value uniform (i.e. independent of coordinate)
|
||||||
virtual inline bool uniform() const
|
virtual inline bool uniform() const
|
||||||
@ -140,6 +139,12 @@ public:
|
|||||||
return PatchFunction1<Type>::uniform();
|
return PatchFunction1<Type>::uniform();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Evaluation
|
||||||
|
|
||||||
|
//- Return UniformValueField value
|
||||||
|
virtual inline tmp<Field<Type>> value(const scalar x) const;
|
||||||
|
|
||||||
//- Integrate between two values
|
//- Integrate between two values
|
||||||
virtual inline tmp<Field<Type>> integrate
|
virtual inline tmp<Field<Type>> integrate
|
||||||
(
|
(
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2018-2020 OpenCFD Ltd.
|
Copyright (C) 2018-2021 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -26,19 +26,10 @@ License
|
|||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "UniformValueField.H"
|
#include "UniformValueField.H"
|
||||||
#include "SubField.H"
|
#include "Field.H"
|
||||||
#include "Constant.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
inline bool
|
|
||||||
Foam::PatchFunction1Types::UniformValueField<Type>::constant() const
|
|
||||||
{
|
|
||||||
return uniformValuePtr_->type() == Function1Types::Constant<Type>::typeName;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
inline Foam::tmp<Foam::Field<Type>>
|
inline Foam::tmp<Foam::Field<Type>>
|
||||||
Foam::PatchFunction1Types::UniformValueField<Type>::value
|
Foam::PatchFunction1Types::UniformValueField<Type>::value
|
||||||
|
|||||||
@ -30,6 +30,7 @@ License
|
|||||||
#include "ConstantField.H"
|
#include "ConstantField.H"
|
||||||
#include "UniformValueField.H"
|
#include "UniformValueField.H"
|
||||||
#include "FunctionObjectValue.H"
|
#include "FunctionObjectValue.H"
|
||||||
|
#include "NoneFunction1.H"
|
||||||
#include "MappedFile.H"
|
#include "MappedFile.H"
|
||||||
#include "Table.H"
|
#include "Table.H"
|
||||||
#include "addToRunTimeSelectionTable.H"
|
#include "addToRunTimeSelectionTable.H"
|
||||||
@ -57,6 +58,14 @@ namespace Foam
|
|||||||
//- Option1 : add UniformFieldValue under the same name as Function1
|
//- Option1 : add UniformFieldValue under the same name as Function1
|
||||||
// See makeFunction1s.C. Note that we do not need
|
// See makeFunction1s.C. Note that we do not need
|
||||||
// Constant & Uniform
|
// Constant & Uniform
|
||||||
|
|
||||||
|
/// Undecided if we actually need 'none':
|
||||||
|
/// addUniformValueFieldFunction1s(none, scalar);
|
||||||
|
/// addUniformValueFieldFunction1s(none, vector);
|
||||||
|
/// addUniformValueFieldFunction1s(none, sphericalTensor);
|
||||||
|
/// addUniformValueFieldFunction1s(none, symmTensor);
|
||||||
|
/// addUniformValueFieldFunction1s(none, tensor);
|
||||||
|
|
||||||
addUniformValueFieldFunction1s(zero, scalar);
|
addUniformValueFieldFunction1s(zero, scalar);
|
||||||
addUniformValueFieldFunction1s(zero, vector);
|
addUniformValueFieldFunction1s(zero, vector);
|
||||||
addUniformValueFieldFunction1s(zero, sphericalTensor);
|
addUniformValueFieldFunction1s(zero, sphericalTensor);
|
||||||
|
|||||||
@ -29,7 +29,6 @@ License
|
|||||||
#include "externalForce.H"
|
#include "externalForce.H"
|
||||||
#include "rigidBodyModel.H"
|
#include "rigidBodyModel.H"
|
||||||
#include "rigidBodyModelState.H"
|
#include "rigidBodyModelState.H"
|
||||||
#include "OneConstant.H"
|
|
||||||
#include "addToRunTimeSelectionTable.H"
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|||||||
@ -68,7 +68,10 @@ boundaryField
|
|||||||
|
|
||||||
if (!baseVel)
|
if (!baseVel)
|
||||||
{
|
{
|
||||||
baseVel = Function1<scalar>::New("timeFunction", dict);
|
baseVel = Function1<scalar>::New
|
||||||
|
(
|
||||||
|
"timeFunction", dict, &db()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool verbose = dict.getOrDefault<bool>("verbose", false);
|
const bool verbose = dict.getOrDefault<bool>("verbose", false);
|
||||||
@ -76,7 +79,10 @@ boundaryField
|
|||||||
if (!baseDir && dict.found("directionFunction"))
|
if (!baseDir && dict.found("directionFunction"))
|
||||||
{
|
{
|
||||||
// ie, NewIfPresent
|
// ie, NewIfPresent
|
||||||
baseDir = Function1<vector>::New("directionFunction", dict);
|
baseDir = Function1<vector>::New
|
||||||
|
(
|
||||||
|
"directionFunction", dict, &db()
|
||||||
|
);
|
||||||
|
|
||||||
InfoErr
|
InfoErr
|
||||||
<< "Function1 for direction" << nl;
|
<< "Function1 for direction" << nl;
|
||||||
|
|||||||
Reference in New Issue
Block a user