mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: adjustments for Function1/PatchFunction1
- additional debug information - improve support for dictionary specification of constant, polynomial and table entries. These previously only worked properly for primitiveEntry, which causes confusion. - extend table Function1 to include TableFile functionality. Simplifies switching and modifying content.
This commit is contained in:
@ -1,15 +1,6 @@
|
|||||||
EXE_INC = \
|
EXE_INC = \
|
||||||
-DFULLDEBUG -g -O0 \
|
-DFULLDEBUG -g \
|
||||||
-I$(LIB_SRC)/lagrangian/intermediate/lnInclude \
|
|
||||||
-I$(LIB_SRC)/thermophysicalModels/radiation/lnInclude \
|
|
||||||
-I$(LIB_SRC)/thermophysicalModels/thermophysicalFunctions/lnInclude \
|
|
||||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
|
||||||
-I$(LIB_SRC)/meshTools/lnInclude
|
-I$(LIB_SRC)/meshTools/lnInclude
|
||||||
|
|
||||||
EXE_LIBS = \
|
EXE_LIBS = \
|
||||||
-llagrangianIntermediate \
|
-lmeshTools
|
||||||
-lradiationModels \
|
|
||||||
-lregionModels \
|
|
||||||
-lfiniteVolume \
|
|
||||||
-lmeshTools \
|
|
||||||
-lsampling
|
|
||||||
|
|||||||
@ -32,7 +32,8 @@ Description
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "fvCFD.H"
|
#include "argList.H"
|
||||||
|
#include "IOstreams.H"
|
||||||
#include "Function1.H"
|
#include "Function1.H"
|
||||||
#include "scalarIndList.H"
|
#include "scalarIndList.H"
|
||||||
#include "scalarField.H"
|
#include "scalarField.H"
|
||||||
@ -40,6 +41,8 @@ Description
|
|||||||
#include "linearInterpolationWeights.H"
|
#include "linearInterpolationWeights.H"
|
||||||
#include "splineInterpolationWeights.H"
|
#include "splineInterpolationWeights.H"
|
||||||
|
|
||||||
|
using namespace Foam;
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
|
|||||||
@ -26,11 +26,44 @@ x
|
|||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
function1 table
|
constant1 constant 100;
|
||||||
|
|
||||||
|
table1 table
|
||||||
(
|
(
|
||||||
(0 0)(10 1)
|
(0 0)(10 1)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
table2
|
||||||
|
{
|
||||||
|
type table;
|
||||||
|
values
|
||||||
|
(
|
||||||
|
(0 0)(10 1)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
table3
|
||||||
|
{
|
||||||
|
type table;
|
||||||
|
file "<constant>/table-values";
|
||||||
|
}
|
||||||
|
|
||||||
|
poly1 polynomial
|
||||||
|
(
|
||||||
|
(0 1)
|
||||||
|
(1 1)
|
||||||
|
);
|
||||||
|
|
||||||
|
poly2
|
||||||
|
{
|
||||||
|
type polynomial;
|
||||||
|
coeffs
|
||||||
|
(
|
||||||
|
(0 1)
|
||||||
|
(1 1)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function2
|
function2
|
||||||
{
|
{
|
||||||
type expression;
|
type expression;
|
||||||
|
|||||||
9
applications/test/Function1/case1/constant/table-values
Normal file
9
applications/test/Function1/case1/constant/table-values
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
// -*- C++ -*-
|
||||||
|
// Some table values
|
||||||
|
|
||||||
|
(
|
||||||
|
(0 0)
|
||||||
|
(20 1)
|
||||||
|
);
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -53,8 +53,8 @@ SourceFiles
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef CSV_H
|
#ifndef Function1Types_CSV_H
|
||||||
#define CSV_H
|
#define Function1Types_CSV_H
|
||||||
|
|
||||||
#include "Function1.H"
|
#include "Function1.H"
|
||||||
#include "TableBase.H"
|
#include "TableBase.H"
|
||||||
|
|||||||
@ -52,9 +52,29 @@ Foam::Function1Types::Constant<Type>::Constant
|
|||||||
Function1<Type>(entryName, dict),
|
Function1<Type>(entryName, dict),
|
||||||
value_(Zero)
|
value_(Zero)
|
||||||
{
|
{
|
||||||
ITstream& is = dict.lookup(entryName);
|
const entry* eptr = dict.findEntry(entryName, keyType::LITERAL);
|
||||||
word entryType(is);
|
|
||||||
|
if (eptr && eptr->isStream())
|
||||||
|
{
|
||||||
|
// Primitive (inline) format. Eg,
|
||||||
|
// - key constant 1.2;
|
||||||
|
// - key 1.2;
|
||||||
|
|
||||||
|
ITstream& is = eptr->stream();
|
||||||
|
if (is.peek().isWord())
|
||||||
|
{
|
||||||
|
is.skip(); // Discard leading 'constant'
|
||||||
|
}
|
||||||
is >> value_;
|
is >> value_;
|
||||||
|
dict.checkITstream(is, entryName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Dictionary format. Eg,
|
||||||
|
// key { type constant; value 1.2; }
|
||||||
|
|
||||||
|
dict.readEntry("value", value_);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -71,10 +91,10 @@ Foam::Function1Types::Constant<Type>::Constant
|
|||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
Foam::Function1Types::Constant<Type>::Constant(const Constant<Type>& cnst)
|
Foam::Function1Types::Constant<Type>::Constant(const Constant<Type>& rhs)
|
||||||
:
|
:
|
||||||
Function1<Type>(cnst),
|
Function1<Type>(rhs),
|
||||||
value_(cnst.value_)
|
value_(rhs.value_)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -30,18 +30,31 @@ Class
|
|||||||
Description
|
Description
|
||||||
Templated function that returns a constant value.
|
Templated function that returns a constant value.
|
||||||
|
|
||||||
Usage - for entry \<entryName\> returning the value <value>:
|
Usage - for entry \<entryName\> returning the value \<value\>,
|
||||||
|
can be specified is different formats.
|
||||||
|
|
||||||
|
Inline specification:
|
||||||
\verbatim
|
\verbatim
|
||||||
<entryName> constant <value>
|
<entryName> constant <value>
|
||||||
\endverbatim
|
\endverbatim
|
||||||
|
|
||||||
|
Dictionary format:
|
||||||
|
\verbatim
|
||||||
|
<entryName>
|
||||||
|
{
|
||||||
|
type constant;
|
||||||
|
value <value>;
|
||||||
|
}
|
||||||
|
\endverbatim
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
Constant.C
|
Constant.C
|
||||||
|
ConstantI.H
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef Constant_H
|
#ifndef Function1Types_Constant_H
|
||||||
#define Constant_H
|
#define Function1Types_Constant_H
|
||||||
|
|
||||||
#include "Function1.H"
|
#include "Function1.H"
|
||||||
|
|
||||||
@ -93,7 +106,7 @@ public:
|
|||||||
Constant(const word& entryName, Istream& is);
|
Constant(const word& entryName, Istream& is);
|
||||||
|
|
||||||
//- Copy constructor
|
//- Copy constructor
|
||||||
explicit Constant(const Constant<Type>& cnst);
|
explicit Constant(const Constant<Type>& rhs);
|
||||||
|
|
||||||
//- Construct and return a clone
|
//- Construct and return a clone
|
||||||
virtual tmp<Function1<Type>> clone() const
|
virtual tmp<Function1<Type>> clone() const
|
||||||
@ -117,7 +130,7 @@ public:
|
|||||||
//- Return value as a function of (scalar) independent variable
|
//- Return value as a function of (scalar) independent variable
|
||||||
virtual tmp<Field<Type>> value(const scalarField& x) const;
|
virtual tmp<Field<Type>> value(const scalarField& x) const;
|
||||||
|
|
||||||
//- Write in dictionary format
|
//- Write as primitive (inline) format
|
||||||
virtual void writeData(Ostream& os) const;
|
virtual void writeData(Ostream& os) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -96,8 +96,8 @@ SourceFiles
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef function1Types_Cosine_H
|
#ifndef Function1Types_Cosine_H
|
||||||
#define function1Types_Cosine_H
|
#define Function1Types_Cosine_H
|
||||||
|
|
||||||
#include "Sine.H"
|
#include "Sine.H"
|
||||||
|
|
||||||
|
|||||||
@ -143,7 +143,7 @@ public:
|
|||||||
//- Construct from entry name
|
//- Construct from entry name
|
||||||
explicit Function1(const word& entryName);
|
explicit Function1(const word& entryName);
|
||||||
|
|
||||||
//- Construct from entry name and dictionary
|
//- Construct from entry name and dictionary (unused)
|
||||||
Function1(const word& entryName, const dictionary& dict);
|
Function1(const word& entryName, const dictionary& dict);
|
||||||
|
|
||||||
//- Copy construct
|
//- Copy construct
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||||
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.
|
||||||
@ -49,6 +49,10 @@ Foam::Function1<Type>::New
|
|||||||
{
|
{
|
||||||
// Dictionary entry
|
// Dictionary entry
|
||||||
|
|
||||||
|
DebugInFunction
|
||||||
|
<< "For " << entryName << " with dictionary entries: "
|
||||||
|
<< flatOutput(coeffs->toc()) << nl;
|
||||||
|
|
||||||
coeffs->readEntry
|
coeffs->readEntry
|
||||||
(
|
(
|
||||||
"type",
|
"type",
|
||||||
@ -62,17 +66,21 @@ Foam::Function1<Type>::New
|
|||||||
else if (eptr)
|
else if (eptr)
|
||||||
{
|
{
|
||||||
// Primitive entry
|
// Primitive entry
|
||||||
// - non-word : value for constant function
|
|
||||||
// - word : the modelType
|
// - word : the modelType
|
||||||
|
// - non-word : value for constant function
|
||||||
|
|
||||||
|
DebugInFunction
|
||||||
|
<< "For " << entryName << " with primitive entry" << nl;
|
||||||
|
|
||||||
ITstream& is = eptr->stream();
|
ITstream& is = eptr->stream();
|
||||||
|
|
||||||
token firstToken(is);
|
if (is.peek().isWord())
|
||||||
|
|
||||||
if (!firstToken.isWord())
|
|
||||||
{
|
{
|
||||||
// A value
|
modelType = is.peek().wordToken();
|
||||||
is.putBack(firstToken);
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// A value - compatibility for reading constant
|
||||||
|
|
||||||
const Type constValue = pTraits<Type>(is);
|
const Type constValue = pTraits<Type>(is);
|
||||||
|
|
||||||
@ -81,10 +89,6 @@ Foam::Function1<Type>::New
|
|||||||
new Function1Types::Constant<Type>(entryName, constValue)
|
new Function1Types::Constant<Type>(entryName, constValue)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
modelType = firstToken.wordToken();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fallthrough
|
// Fallthrough
|
||||||
}
|
}
|
||||||
|
|||||||
@ -81,7 +81,7 @@ public:
|
|||||||
//- Construct from entry name
|
//- Construct from entry name
|
||||||
explicit function1Base(const word& entryName);
|
explicit function1Base(const word& entryName);
|
||||||
|
|
||||||
//- Construct from entry name and dictionary
|
//- Construct from entry name and dictionary (unused)
|
||||||
function1Base(const word& entryName, const dictionary& dict);
|
function1Base(const word& entryName, const dictionary& dict);
|
||||||
|
|
||||||
//- Copy construct
|
//- Copy construct
|
||||||
|
|||||||
@ -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.
|
||||||
@ -31,9 +31,9 @@ Description
|
|||||||
|
|
||||||
Example usage for limiting a polynomial:
|
Example usage for limiting a polynomial:
|
||||||
\verbatim
|
\verbatim
|
||||||
limitedPolyTest limitRange;
|
<entryName>
|
||||||
limitedPolyTestCoeffs
|
|
||||||
{
|
{
|
||||||
|
type limitRange;
|
||||||
min 0.4;
|
min 0.4;
|
||||||
max 1.4;
|
max 1.4;
|
||||||
|
|
||||||
@ -53,17 +53,20 @@ Description
|
|||||||
- poly(x) for 0.4 < x < 1.4.
|
- poly(x) for 0.4 < x < 1.4.
|
||||||
|
|
||||||
|
|
||||||
Example usage for limiting a table
|
Example usage for limiting a file-based table:
|
||||||
\verbatim
|
\verbatim
|
||||||
limitedTableFileTest limitRange;
|
<entryName>
|
||||||
limitedTableFileTestCoeffs
|
|
||||||
{
|
{
|
||||||
|
type limitRange;
|
||||||
min 0.4;
|
min 0.4;
|
||||||
max 1.4;
|
max 1.4;
|
||||||
|
|
||||||
value tableFile;
|
value
|
||||||
|
{
|
||||||
|
type table;
|
||||||
file "<system>/fanCurve.txt";
|
file "<system>/fanCurve.txt";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
\endverbatim
|
\endverbatim
|
||||||
|
|
||||||
Where:
|
Where:
|
||||||
@ -79,8 +82,8 @@ SourceFiles
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef LimitRange_H
|
#ifndef Function1Types_LimitRange_H
|
||||||
#define LimitRange_H
|
#define Function1Types_LimitRange_H
|
||||||
|
|
||||||
#include "Function1.H"
|
#include "Function1.H"
|
||||||
|
|
||||||
|
|||||||
@ -40,8 +40,8 @@ SourceFiles
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef OneConstant_H
|
#ifndef Function1Types_OneConstant_H
|
||||||
#define OneConstant_H
|
#define Function1Types_OneConstant_H
|
||||||
|
|
||||||
#include "Function1.H"
|
#include "Function1.H"
|
||||||
|
|
||||||
@ -110,7 +110,7 @@ public:
|
|||||||
const scalarField& x2
|
const scalarField& x2
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Write in dictionary format
|
//- Write as primitive (inline) format
|
||||||
virtual void writeData(Ostream& os) const;
|
virtual void writeData(Ostream& os) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
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.
|
||||||
@ -28,6 +28,37 @@ License
|
|||||||
|
|
||||||
#include "PolynomialEntry.H"
|
#include "PolynomialEntry.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void Foam::Function1Types::Polynomial<Type>::checkCoefficients()
|
||||||
|
{
|
||||||
|
if (coeffs_.empty())
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "Invalid (empty) polynomial coefficients for "
|
||||||
|
<< this->name() << nl
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const auto& coeff : coeffs_)
|
||||||
|
{
|
||||||
|
if (mag(coeff.second() + pTraits<Type>::one) < ROOTVSMALL)
|
||||||
|
{
|
||||||
|
canIntegrate_ = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (debug && !canIntegrate_)
|
||||||
|
{
|
||||||
|
WarningInFunction
|
||||||
|
<< "Polynomial " << this->name() << " cannot be integrated"
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
@ -41,37 +72,31 @@ Foam::Function1Types::Polynomial<Type>::Polynomial
|
|||||||
coeffs_(),
|
coeffs_(),
|
||||||
canIntegrate_(true)
|
canIntegrate_(true)
|
||||||
{
|
{
|
||||||
ITstream& is = dict.lookup(entryName);
|
const entry* eptr = dict.findEntry(entryName, keyType::LITERAL);
|
||||||
const word entryType(is);
|
|
||||||
|
|
||||||
is >> coeffs_;
|
if (eptr && eptr->isStream())
|
||||||
|
|
||||||
if (!coeffs_.size())
|
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
// Primitive (inline) format. Eg,
|
||||||
<< "Invalid (empty) polynomial coefficients for "
|
// key polynomial ((0 0) (10 1));
|
||||||
<< this->name() << nl
|
|
||||||
<< exit(FatalError);
|
ITstream& is = eptr->stream();
|
||||||
|
if (is.peek().isWord())
|
||||||
|
{
|
||||||
|
is.skip(); // Discard leading 'polynomial'
|
||||||
|
}
|
||||||
|
is >> this->coeffs_;
|
||||||
|
dict.checkITstream(is, entryName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Dictionary format - "values" lookup. Eg,
|
||||||
|
//
|
||||||
|
// key { type polynomial; coeffs ((0 0) (10 1)); }
|
||||||
|
|
||||||
|
dict.readEntry("coeffs", this->coeffs_);
|
||||||
}
|
}
|
||||||
|
|
||||||
forAll(coeffs_, i)
|
this->checkCoefficients();
|
||||||
{
|
|
||||||
if (mag(coeffs_[i].second() + pTraits<Type>::one) < ROOTVSMALL)
|
|
||||||
{
|
|
||||||
canIntegrate_ = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (debug)
|
|
||||||
{
|
|
||||||
if (!canIntegrate_)
|
|
||||||
{
|
|
||||||
WarningInFunction
|
|
||||||
<< "Polynomial " << this->name() << " cannot be integrated"
|
|
||||||
<< endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -86,32 +111,7 @@ Foam::Function1Types::Polynomial<Type>::Polynomial
|
|||||||
coeffs_(coeffs),
|
coeffs_(coeffs),
|
||||||
canIntegrate_(true)
|
canIntegrate_(true)
|
||||||
{
|
{
|
||||||
if (!coeffs_.size())
|
this->checkCoefficients();
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "Invalid (empty) polynomial coefficients for "
|
|
||||||
<< this->name() << nl
|
|
||||||
<< exit(FatalError);
|
|
||||||
}
|
|
||||||
|
|
||||||
forAll(coeffs_, i)
|
|
||||||
{
|
|
||||||
if (mag(coeffs_[i].second() + 1) < ROOTVSMALL)
|
|
||||||
{
|
|
||||||
canIntegrate_ = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (debug)
|
|
||||||
{
|
|
||||||
if (!canIntegrate_)
|
|
||||||
{
|
|
||||||
WarningInFunction
|
|
||||||
<< "Polynomial " << this->name() << " cannot be integrated"
|
|
||||||
<< endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -6,6 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||||
|
Copyright (C) 2021 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -31,6 +32,7 @@ Description
|
|||||||
list of Tuple2's. Data is input in the form,
|
list of Tuple2's. Data is input in the form,
|
||||||
e.g. for an entry \<entryName\> that describes y = x^2 + 2x^3
|
e.g. for an entry \<entryName\> that describes y = x^2 + 2x^3
|
||||||
|
|
||||||
|
Inline specification:
|
||||||
\verbatim
|
\verbatim
|
||||||
<entryName> polynomial
|
<entryName> polynomial
|
||||||
(
|
(
|
||||||
@ -39,13 +41,26 @@ Description
|
|||||||
);
|
);
|
||||||
\endverbatim
|
\endverbatim
|
||||||
|
|
||||||
|
Dictionary format:
|
||||||
|
\verbatim
|
||||||
|
<entryName>
|
||||||
|
{
|
||||||
|
type polynomial;
|
||||||
|
coeffs
|
||||||
|
(
|
||||||
|
(1 2)
|
||||||
|
(2 3)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
\endverbatim
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
PolynomialEntry.C
|
PolynomialEntry.C
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef PolynomialEntry_H
|
#ifndef Function1Types_Polynomial_H
|
||||||
#define PolynomialEntry_H
|
#define Function1Types_Polynomial_H
|
||||||
|
|
||||||
#include "Function1.H"
|
#include "Function1.H"
|
||||||
#include "Tuple2.H"
|
#include "Tuple2.H"
|
||||||
@ -72,12 +87,15 @@ class Polynomial
|
|||||||
//- Polynomial coefficients - list of prefactor, exponent
|
//- Polynomial coefficients - list of prefactor, exponent
|
||||||
List<Tuple2<Type, Type>> coeffs_;
|
List<Tuple2<Type, Type>> coeffs_;
|
||||||
|
|
||||||
//- Flag to indicate whether poly can be integrated
|
//- Flag to indicate whether polynomial can be integrated
|
||||||
bool canIntegrate_;
|
bool canIntegrate_;
|
||||||
|
|
||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Check coefficients and if polynomial can be integrated
|
||||||
|
void checkCoefficients();
|
||||||
|
|
||||||
//- No copy assignment
|
//- No copy assignment
|
||||||
void operator=(const Polynomial<Type>&) = delete;
|
void operator=(const Polynomial<Type>&) = delete;
|
||||||
|
|
||||||
@ -125,8 +143,7 @@ public:
|
|||||||
//- Integrate between two (scalar) values
|
//- Integrate between two (scalar) values
|
||||||
virtual Type integrate(const scalar x1, const scalar x2) const;
|
virtual Type integrate(const scalar x1, const scalar x2) const;
|
||||||
|
|
||||||
|
//- Write as primitive (inline) format
|
||||||
//- Write in dictionary format
|
|
||||||
virtual void writeData(Ostream& os) const;
|
virtual void writeData(Ostream& os) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -63,8 +63,8 @@ Description
|
|||||||
Where:
|
Where:
|
||||||
\table
|
\table
|
||||||
Property | Description | Required
|
Property | Description | Required
|
||||||
value | Function of type Function1<Type> | yes
|
|
||||||
scale | Scaling function of type Function1<scalar> | yes
|
scale | Scaling function of type Function1<scalar> | yes
|
||||||
|
value | Function of type Function1<Type> | yes
|
||||||
\endtable
|
\endtable
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
@ -72,8 +72,8 @@ SourceFiles
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef Scale_H
|
#ifndef Function1Types_Scale_H
|
||||||
#define Scale_H
|
#define Function1Types_Scale_H
|
||||||
|
|
||||||
#include "Function1.H"
|
#include "Function1.H"
|
||||||
|
|
||||||
|
|||||||
@ -98,8 +98,8 @@ SourceFiles
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef function1Types_Sine_H
|
#ifndef Function1Types_Sine_H
|
||||||
#define function1Types_Sine_H
|
#define Function1Types_Sine_H
|
||||||
|
|
||||||
#include "Function1.H"
|
#include "Function1.H"
|
||||||
|
|
||||||
|
|||||||
@ -101,8 +101,8 @@ Note
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef function1Types_Square_H
|
#ifndef Function1Types_Square_H
|
||||||
#define function1Types_Square_H
|
#define Function1Types_Square_H
|
||||||
|
|
||||||
#include "Sine.H"
|
#include "Sine.H"
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -37,11 +37,53 @@ Foam::Function1Types::Table<Type>::Table
|
|||||||
const dictionary& dict
|
const dictionary& dict
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
TableBase<Type>(entryName, dict)
|
TableBase<Type>(entryName, dict),
|
||||||
|
fName_()
|
||||||
{
|
{
|
||||||
ITstream& is = dict.lookup(entryName);
|
const entry* eptr = dict.findEntry(entryName, keyType::LITERAL);
|
||||||
const word entryType(is);
|
|
||||||
|
if (eptr && eptr->isStream())
|
||||||
|
{
|
||||||
|
// Primitive (inline) format. Eg,
|
||||||
|
// key table ((0 0) (10 1));
|
||||||
|
|
||||||
|
ITstream& is = eptr->stream();
|
||||||
|
if (is.peek().isWord())
|
||||||
|
{
|
||||||
|
is.skip(); // Discard leading 'table'
|
||||||
|
}
|
||||||
is >> this->table_;
|
is >> this->table_;
|
||||||
|
dict.checkITstream(is, entryName);
|
||||||
|
}
|
||||||
|
else if (dict.readIfPresent("file", fName_))
|
||||||
|
{
|
||||||
|
// Dictionary format - "file" lookup. Eg,
|
||||||
|
// key { type table; file "name"; }
|
||||||
|
|
||||||
|
fileName expandedFile(fName_);
|
||||||
|
expandedFile.expand();
|
||||||
|
|
||||||
|
autoPtr<ISstream> isPtr(fileHandler().NewIFstream(expandedFile));
|
||||||
|
if (isPtr && isPtr->good())
|
||||||
|
{
|
||||||
|
*isPtr >> this->table_;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FatalIOErrorInFunction(dict)
|
||||||
|
<< "Cannot open file: " << expandedFile << nl
|
||||||
|
<< exit(FatalIOError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Dictionary format - "values" lookup. Eg,
|
||||||
|
//
|
||||||
|
// key { type table; values ((0 0) (10 1)); }
|
||||||
|
|
||||||
|
dict.readEntry("values", this->table_);
|
||||||
|
}
|
||||||
|
|
||||||
TableBase<Type>::check();
|
TableBase<Type>::check();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,8 +91,36 @@ Foam::Function1Types::Table<Type>::Table
|
|||||||
template<class Type>
|
template<class Type>
|
||||||
Foam::Function1Types::Table<Type>::Table(const Table<Type>& tbl)
|
Foam::Function1Types::Table<Type>::Table(const Table<Type>& tbl)
|
||||||
:
|
:
|
||||||
TableBase<Type>(tbl)
|
TableBase<Type>(tbl),
|
||||||
|
fName_(tbl.fName_)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void Foam::Function1Types::Table<Type>::writeData(Ostream& os) const
|
||||||
|
{
|
||||||
|
Function1<Type>::writeData(os);
|
||||||
|
os.endEntry();
|
||||||
|
|
||||||
|
os.beginBlock(word(this->name() + "Coeffs"));
|
||||||
|
|
||||||
|
// Note: for TableBase write the dictionary entries it needs but not
|
||||||
|
// the values themselves
|
||||||
|
TableBase<Type>::writeEntries(os);
|
||||||
|
|
||||||
|
if (fName_.empty())
|
||||||
|
{
|
||||||
|
os.writeEntry("values", this->table_);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
os.writeEntry("file", fName_);
|
||||||
|
}
|
||||||
|
|
||||||
|
os.endBlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||||
Copyright (C) 2019 OpenCFD Ltd.
|
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -30,10 +30,12 @@ Class
|
|||||||
Description
|
Description
|
||||||
Templated table container function.
|
Templated table container function.
|
||||||
|
|
||||||
Items are stored in a list of Tuple2's. First column is always stored as
|
Items are stored in a list of Tuple2, with the first column always
|
||||||
scalar entries. Data is read in Tuple2 form.
|
being a scalar and the second column (the lookup value) in
|
||||||
|
required data type.
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
|
Inline specification.
|
||||||
\verbatim
|
\verbatim
|
||||||
<entryName> table
|
<entryName> table
|
||||||
(
|
(
|
||||||
@ -42,13 +44,43 @@ Description
|
|||||||
);
|
);
|
||||||
\endverbatim
|
\endverbatim
|
||||||
|
|
||||||
|
Dictionary specification, external data reference.
|
||||||
|
\verbatim
|
||||||
|
<entryName>
|
||||||
|
{
|
||||||
|
type table;
|
||||||
|
file "<case>/path/tableValues";
|
||||||
|
}
|
||||||
|
\endverbatim
|
||||||
|
|
||||||
|
Dictionary specification, embedded content
|
||||||
|
Dictionary form.
|
||||||
|
\verbatim
|
||||||
|
<entryName>
|
||||||
|
{
|
||||||
|
type table;
|
||||||
|
values
|
||||||
|
(
|
||||||
|
(0.0 (1 2 3))
|
||||||
|
(1.0 (4 5 6))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
\endverbatim
|
||||||
|
|
||||||
|
Note
|
||||||
|
The external data reference (using the \c file keyword) is
|
||||||
|
used in preference to the \c values specification.
|
||||||
|
|
||||||
|
See Also
|
||||||
|
Foam::Function1Types::TableFile
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
Table.C
|
Table.C
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef Table_H
|
#ifndef Function1Types_Table_H
|
||||||
#define Table_H
|
#define Function1Types_Table_H
|
||||||
|
|
||||||
#include "TableBase.H"
|
#include "TableBase.H"
|
||||||
|
|
||||||
@ -68,6 +100,12 @@ class Table
|
|||||||
:
|
:
|
||||||
public TableBase<Type>
|
public TableBase<Type>
|
||||||
{
|
{
|
||||||
|
// Private Data
|
||||||
|
|
||||||
|
//- Input name for file-based input (optional)
|
||||||
|
fileName fName_;
|
||||||
|
|
||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
//- No copy assignment
|
//- No copy assignment
|
||||||
@ -81,10 +119,10 @@ public:
|
|||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct from entry name and dictionary
|
//- Construct from entry name and dictionary.
|
||||||
Table(const word& entryName, const dictionary& dict);
|
Table(const word& entryName, const dictionary& dict);
|
||||||
|
|
||||||
//- Copy constructor
|
//- Copy construct
|
||||||
explicit Table(const Table<Type>& tbl);
|
explicit Table(const Table<Type>& tbl);
|
||||||
|
|
||||||
//- Construct and return a clone
|
//- Construct and return a clone
|
||||||
@ -96,6 +134,12 @@ public:
|
|||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
virtual ~Table() = default;
|
virtual ~Table() = default;
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
//- Write coefficients in dictionary format
|
||||||
|
virtual void writeData(Ostream& os) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -35,8 +35,8 @@ SourceFiles
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef TableBase_H
|
#ifndef Function1Types_TableBase_H
|
||||||
#define TableBase_H
|
#define Function1Types_TableBase_H
|
||||||
|
|
||||||
#include "tableBounds.H"
|
#include "tableBounds.H"
|
||||||
#include "Function1.H"
|
#include "Function1.H"
|
||||||
|
|||||||
@ -51,13 +51,16 @@ Description
|
|||||||
);
|
);
|
||||||
\endverbatim
|
\endverbatim
|
||||||
|
|
||||||
|
See Also
|
||||||
|
Foam::Function1Types::Table
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
TableFile.C
|
TableFile.C
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef TableFile_H
|
#ifndef Function1Types_TableFile_H
|
||||||
#define TableFile_H
|
#define Function1Types_TableFile_H
|
||||||
|
|
||||||
#include "TableBase.H"
|
#include "TableBase.H"
|
||||||
|
|
||||||
|
|||||||
@ -43,8 +43,8 @@ SourceFiles
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef Uniform_H
|
#ifndef Function1Types_Uniform_H
|
||||||
#define Uniform_H
|
#define Function1Types_Uniform_H
|
||||||
|
|
||||||
#include "Function1.H"
|
#include "Function1.H"
|
||||||
|
|
||||||
|
|||||||
@ -31,17 +31,26 @@ Description
|
|||||||
Templated function that returns the corresponding 0 (zero).
|
Templated function that returns the corresponding 0 (zero).
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
|
Inline specification:
|
||||||
\verbatim
|
\verbatim
|
||||||
<entryName> zero;
|
<entryName> zero;
|
||||||
\endverbatim
|
\endverbatim
|
||||||
|
|
||||||
|
In dictionary format:
|
||||||
|
\verbatim
|
||||||
|
<entryName>
|
||||||
|
{
|
||||||
|
type zero;
|
||||||
|
}
|
||||||
|
\endverbatim
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
ZeroConstant.C
|
ZeroConstant.C
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef ZeroConstant_H
|
#ifndef Function1Types_ZeroConstant_H
|
||||||
#define ZeroConstant_H
|
#define Function1Types_ZeroConstant_H
|
||||||
|
|
||||||
#include "Function1.H"
|
#include "Function1.H"
|
||||||
|
|
||||||
@ -94,7 +103,7 @@ public:
|
|||||||
//- Integrate between two values
|
//- Integrate between two values
|
||||||
virtual inline Type integrate(const scalar x1, const scalar x2) const;
|
virtual inline Type integrate(const scalar x1, const scalar x2) const;
|
||||||
|
|
||||||
//- Write in dictionary format
|
//- Write as primitive (inline) format
|
||||||
virtual void writeData(Ostream& os) const;
|
virtual void writeData(Ostream& os) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -39,8 +39,8 @@ SourceFiles
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef halfCosineRamp_H
|
#ifndef Function1Types_halfCosineRamp_H
|
||||||
#define halfCosineRamp_H
|
#define Function1Types_halfCosineRamp_H
|
||||||
|
|
||||||
#include "ramp.H"
|
#include "ramp.H"
|
||||||
|
|
||||||
|
|||||||
@ -39,8 +39,8 @@ SourceFiles
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef linearRamp_H
|
#ifndef Function1Types_linearRamp_H
|
||||||
#define linearRamp_H
|
#define Function1Types_linearRamp_H
|
||||||
|
|
||||||
#include "ramp.H"
|
#include "ramp.H"
|
||||||
|
|
||||||
|
|||||||
@ -39,8 +39,8 @@ SourceFiles
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef quadraticRamp_H
|
#ifndef Function1Types_quadraticRamp_H
|
||||||
#define quadraticRamp_H
|
#define Function1Types_quadraticRamp_H
|
||||||
|
|
||||||
#include "ramp.H"
|
#include "ramp.H"
|
||||||
|
|
||||||
|
|||||||
@ -39,8 +39,8 @@ SourceFiles
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef quarterCosineRamp_H
|
#ifndef Function1Types_quarterCosineRamp_H
|
||||||
#define quarterCosineRamp_H
|
#define Function1Types_quarterCosineRamp_H
|
||||||
|
|
||||||
#include "ramp.H"
|
#include "ramp.H"
|
||||||
|
|
||||||
|
|||||||
@ -38,8 +38,8 @@ SourceFiles
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef quarterSineRamp_H
|
#ifndef Function1Types_quarterSineRamp_H
|
||||||
#define quarterSineRamp_H
|
#define Function1Types_quarterSineRamp_H
|
||||||
|
|
||||||
#include "ramp.H"
|
#include "ramp.H"
|
||||||
|
|
||||||
|
|||||||
@ -66,8 +66,8 @@ SourceFiles
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef ramp_H
|
#ifndef Function1Types_ramp_H
|
||||||
#define ramp_H
|
#define Function1Types_ramp_H
|
||||||
|
|
||||||
#include "Function1.H"
|
#include "Function1.H"
|
||||||
|
|
||||||
|
|||||||
@ -38,8 +38,8 @@ SourceFiles
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef stepFunction_H
|
#ifndef Function1Types_stepFunction_H
|
||||||
#define stepFunction_H
|
#define Function1Types_stepFunction_H
|
||||||
|
|
||||||
#include "ramp.H"
|
#include "ramp.H"
|
||||||
|
|
||||||
|
|||||||
@ -36,15 +36,14 @@ Description
|
|||||||
|
|
||||||
For example,
|
For example,
|
||||||
\verbatim
|
\verbatim
|
||||||
pistonPositionTime table ( (0 0.13) (0.020 0.03) );
|
pistonPositionTime table ((0 0.13) (0.020 0.03));
|
||||||
\endverbatim
|
\endverbatim
|
||||||
|
or
|
||||||
or with a tableFile
|
|
||||||
\verbatim
|
\verbatim
|
||||||
pistonPositionTime tableFile;
|
pistonPositionTime
|
||||||
pistonPositionTimeCoeffs
|
|
||||||
{
|
{
|
||||||
fileName "data";
|
type table;
|
||||||
|
file "<constant>/pistonPosition.dat";
|
||||||
outOfBounds clamp;
|
outOfBounds clamp;
|
||||||
interpolationScheme linear;
|
interpolationScheme linear;
|
||||||
}
|
}
|
||||||
@ -76,7 +75,7 @@ class freePiston
|
|||||||
:
|
:
|
||||||
public engineTime
|
public engineTime
|
||||||
{
|
{
|
||||||
// Private data
|
// Private Data
|
||||||
|
|
||||||
autoPtr<Function1<scalar>> pistonPositionTime_;
|
autoPtr<Function1<scalar>> pistonPositionTime_;
|
||||||
|
|
||||||
|
|||||||
@ -30,8 +30,6 @@ License
|
|||||||
#include "addToRunTimeSelectionTable.H"
|
#include "addToRunTimeSelectionTable.H"
|
||||||
#include "volFields.H"
|
#include "volFields.H"
|
||||||
#include "surfaceFields.H"
|
#include "surfaceFields.H"
|
||||||
#include "Tuple2.H"
|
|
||||||
#include "PolynomialEntry.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
Copyright (C) 2017-2020 OpenCFD Ltd
|
Copyright (C) 2017-2021 OpenCFD Ltd
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -71,11 +71,11 @@ Usage
|
|||||||
{
|
{
|
||||||
type fanPressure;
|
type fanPressure;
|
||||||
direction in;
|
direction in;
|
||||||
fanCurve tableFile;
|
fanCurve
|
||||||
fanCurveCoeffs
|
|
||||||
{
|
{
|
||||||
|
type table;
|
||||||
file "<constant>/fanCurve";
|
file "<constant>/fanCurve";
|
||||||
outOfBounds clamp;
|
outOfBounds clamp; // Optional out-of-bounds handling
|
||||||
}
|
}
|
||||||
p0 uniform 0;
|
p0 uniform 0;
|
||||||
value uniform 0;
|
value uniform 0;
|
||||||
|
|||||||
@ -101,52 +101,43 @@ Foam::PatchFunction1Types::ConstantField<Type>::getValue
|
|||||||
}
|
}
|
||||||
ITstream& is = eptr->stream();
|
ITstream& is = eptr->stream();
|
||||||
|
|
||||||
// Read first token
|
if (is.peek().isWord())
|
||||||
token firstToken(is);
|
|
||||||
|
|
||||||
if (firstToken.isWord())
|
|
||||||
{
|
{
|
||||||
if
|
const word contentType(is);
|
||||||
(
|
|
||||||
firstToken.wordToken() == "uniform"
|
if (contentType == "uniform" || contentType == "constant")
|
||||||
|| firstToken.wordToken() == "constant"
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
is >> uniformValue;
|
is >> uniformValue;
|
||||||
fld.setSize(len);
|
fld.resize(len);
|
||||||
fld = uniformValue;
|
fld = uniformValue;
|
||||||
}
|
}
|
||||||
else if (firstToken.wordToken() == "nonuniform")
|
else if (contentType == "nonuniform")
|
||||||
{
|
{
|
||||||
List<Type>& list = fld;
|
|
||||||
is >> list;
|
|
||||||
isUniform = false;
|
isUniform = false;
|
||||||
|
is >> static_cast<List<Type>&>(fld);
|
||||||
const label currentSize = fld.size();
|
const label lenRead = fld.size();
|
||||||
if (currentSize != len)
|
if (len != lenRead)
|
||||||
{
|
{
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
len < currentSize
|
len < lenRead
|
||||||
&& FieldBase::allowConstructFromLargerSize
|
&& FieldBase::allowConstructFromLargerSize
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
#ifdef FULLDEBUG
|
#ifdef FULLDEBUG
|
||||||
IOWarningInFunction(dict)
|
IOWarningInFunction(dict)
|
||||||
<< "Sizes do not match. "
|
<< "Sizes do not match. Truncating " << lenRead
|
||||||
<< "Re-sizing " << currentSize
|
<< " entries to " << len << endl;
|
||||||
<< " entries to " << len
|
|
||||||
<< endl;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Resize (shrink) the data
|
// Truncate the data
|
||||||
fld.setSize(len);
|
fld.resize(len);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FatalIOErrorInFunction(dict)
|
FatalIOErrorInFunction(dict)
|
||||||
<< "size " << fld.size()
|
<< "size " << lenRead
|
||||||
<< " is not equal to the given value of " << len
|
<< " is not equal to the expected length " << len
|
||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -156,15 +147,15 @@ Foam::PatchFunction1Types::ConstantField<Type>::getValue
|
|||||||
isUniform = false;
|
isUniform = false;
|
||||||
FatalIOErrorInFunction(dict)
|
FatalIOErrorInFunction(dict)
|
||||||
<< "Expected keyword 'uniform', 'nonuniform' or 'constant'"
|
<< "Expected keyword 'uniform', 'nonuniform' or 'constant'"
|
||||||
<< ", found " << firstToken.wordToken()
|
<< ", found " << contentType
|
||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
is.putBack(firstToken);
|
// Uniform (constant) field
|
||||||
is >> uniformValue;
|
is >> uniformValue;
|
||||||
fld.setSize(len);
|
fld.resize(len);
|
||||||
fld = uniformValue;
|
fld = uniformValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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.
|
||||||
@ -49,6 +49,10 @@ Foam::PatchFunction1<Type>::New
|
|||||||
{
|
{
|
||||||
// Dictionary entry
|
// Dictionary entry
|
||||||
|
|
||||||
|
DebugInFunction
|
||||||
|
<< "For " << entryName << " with dictionary entries: "
|
||||||
|
<< flatOutput(coeffs->toc()) << nl;
|
||||||
|
|
||||||
coeffs->readEntry
|
coeffs->readEntry
|
||||||
(
|
(
|
||||||
"type",
|
"type",
|
||||||
@ -60,18 +64,21 @@ Foam::PatchFunction1<Type>::New
|
|||||||
else if (eptr)
|
else if (eptr)
|
||||||
{
|
{
|
||||||
// Primitive entry
|
// Primitive entry
|
||||||
// - non-word : value for constant (uniform) function
|
|
||||||
// - word : the modelType, or uniform/nonuniform
|
// - word : the modelType, or uniform/nonuniform
|
||||||
|
// - non-word : value for constant (uniform) function
|
||||||
|
|
||||||
|
DebugInFunction
|
||||||
|
<< "For " << entryName << " with primitive entry" << nl;
|
||||||
|
|
||||||
ITstream& is = eptr->stream();
|
ITstream& is = eptr->stream();
|
||||||
|
|
||||||
token firstToken(is);
|
if (is.peek().isWord())
|
||||||
|
|
||||||
// Compatibility for reading straight fields
|
|
||||||
if (!firstToken.isWord())
|
|
||||||
{
|
{
|
||||||
// A value
|
modelType = is.peek().wordToken();
|
||||||
is.putBack(firstToken);
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// A value - compatibility for reading uniform (constant) field
|
||||||
|
|
||||||
const Type constValue = pTraits<Type>(is);
|
const Type constValue = pTraits<Type>(is);
|
||||||
|
|
||||||
@ -88,8 +95,6 @@ Foam::PatchFunction1<Type>::New
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
modelType = firstToken.wordToken();
|
|
||||||
|
|
||||||
// Looks like a normal field entry?
|
// Looks like a normal field entry?
|
||||||
if (modelType == "uniform" || modelType == "nonuniform")
|
if (modelType == "uniform" || modelType == "nonuniform")
|
||||||
{
|
{
|
||||||
|
|||||||
@ -24,9 +24,9 @@ boundaryField
|
|||||||
inlet
|
inlet
|
||||||
{
|
{
|
||||||
type flowRateInletVelocity;
|
type flowRateInletVelocity;
|
||||||
massFlowRate tableFile;
|
massFlowRate
|
||||||
massFlowRateCoeffs
|
|
||||||
{
|
{
|
||||||
|
type table;
|
||||||
file "<constant>/massLossRate";
|
file "<constant>/massLossRate";
|
||||||
}
|
}
|
||||||
value uniform (0 0 0);
|
value uniform (0 0 0);
|
||||||
|
|||||||
@ -25,11 +25,10 @@ boundaryField
|
|||||||
{
|
{
|
||||||
type fanPressure;
|
type fanPressure;
|
||||||
direction in;
|
direction in;
|
||||||
fanCurve tableFile;
|
fanCurve
|
||||||
fanCurveCoeffs
|
|
||||||
{
|
{
|
||||||
|
type table;
|
||||||
file "<constant>/FluxVsdP.dat";
|
file "<constant>/FluxVsdP.dat";
|
||||||
// readerType openFoam; // Default
|
|
||||||
// outOfBounds clamp; // Default
|
// outOfBounds clamp; // Default
|
||||||
}
|
}
|
||||||
//nonDimensional true;
|
//nonDimensional true;
|
||||||
|
|||||||
@ -59,9 +59,12 @@ functions
|
|||||||
type setTimeStep;
|
type setTimeStep;
|
||||||
libs (utilityFunctionObjects);
|
libs (utilityFunctionObjects);
|
||||||
enabled yes;
|
enabled yes;
|
||||||
deltaT tableFile;
|
deltaT
|
||||||
|
{
|
||||||
|
type table;
|
||||||
file "<system>/deltaTvalues";
|
file "<system>/deltaTvalues";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
minMaxp
|
minMaxp
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user