Function1, Function2: Rationalising, simplifying and standardising writing

This commit is contained in:
Henry Weller
2020-11-28 19:50:39 +00:00
parent 156734571f
commit 21bb6c549d
45 changed files with 323 additions and 277 deletions

View File

@ -62,6 +62,17 @@ extern "C"
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::Function1s::${typeName}Function1${TemplateType}::writeData
(
Ostream& os
) const
{
NotImplemented;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::Function1s::${typeName}Function1${TemplateType}::
@ -127,13 +138,4 @@ Foam::Function1s::${typeName}Function1${TemplateType}::integrate
}
void Foam::Function1s::${typeName}Function1${TemplateType}::writeData
(
Ostream& os
) const
{
NotImplemented;
}
// ************************************************************************* i/

View File

@ -55,6 +55,11 @@ class ${typeName}Function1${TemplateType}
:
public FieldFunction1<${TemplateType}, ${typeName}Function1${TemplateType}>
{
// Private Member Functions
//- Write data to dictionary stream
virtual void writeData(Ostream& os) const;
public:
@ -108,9 +113,6 @@ public:
const scalar x2
) const;
//- Write in dictionary format
virtual void writeData(Ostream& os) const;
// Member Operators

View File

@ -88,6 +88,13 @@ Foam::Function1s::Coded<Type>::compileNew()
}
template<class Type>
void Foam::Function1s::Coded<Type>::writeData(Ostream& os) const
{
writeCode(os);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
@ -165,13 +172,4 @@ Foam::tmp<Foam::Field<Type>> Foam::Function1s::Coded<Type>::integrate
}
template<class Type>
void Foam::Function1s::Coded<Type>::writeData(Ostream& os) const
{
Function1<Type>::writeData(os);
os << token::END_STATEMENT << nl;
writeCode(os);
}
// ************************************************************************* //

View File

@ -116,6 +116,9 @@ class Coded
//- Compile, link and return the now coded Function1
autoPtr<Function1<Type>> compileNew();
//- Write data to dictionary stream
virtual void writeData(Ostream& os) const;
public:
@ -161,9 +164,6 @@ public:
const scalarField& x2
) const;
//- Write in dictionary format
virtual void writeData(Ostream& os) const;
// Member Operators

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -99,11 +99,10 @@ Foam::Function1s::Constant<Type>::~Constant()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::Function1s::Constant<Type>::writeData(Ostream& os) const
void Foam::Function1s::Constant<Type>::write(Ostream& os) const
{
Function1<Type>::writeData(os);
os << token::SPACE << value_ << token::END_STATEMENT << nl;
this->writeType(os)
<< token::SPACE << value_ << token::END_STATEMENT << nl;
}

View File

@ -106,7 +106,7 @@ public:
virtual inline Type integrate(const scalar x1, const scalar x2) const;
//- Write in dictionary format
virtual void writeData(Ostream& os) const;
virtual void write(Ostream& os) const;
// Member Operators

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -25,6 +25,16 @@ License
#include "Function1.H"
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
template<class Type>
Foam::Ostream& Foam::Function1<Type>::writeType(Ostream& os) const
{
return writeKeyword(os, name_) << type();
}
// * * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * //
template<class Type>
@ -95,9 +105,16 @@ const Foam::word& Foam::Function1<Type>::name() const
template<class Type>
void Foam::Function1<Type>::writeData(Ostream& os) const
void Foam::Function1<Type>::write(Ostream& os) const
{
writeKeyword(os, name_) << type();
writeKeyword(os, name_)
<< nl << indent << token::BEGIN_BLOCK << nl << incrIndent;
writeEntry(os, "type", type());
writeData(os);
os << decrIndent << indent << token::END_BLOCK << endl;
}
@ -144,7 +161,7 @@ Foam::FieldFunction1<Type, Function1Type>::integrate
template<class Type>
void Foam::writeEntry(Ostream& os, const Function1<Type>& f1)
{
f1.writeData(os);
f1.write(os);
}
@ -163,7 +180,7 @@ Foam::Ostream& Foam::operator<<
"Ostream& operator<<(Ostream&, const Function1<Type>&)"
);
f1.writeData(os);
f1.write(os);
return os;
}

View File

@ -71,6 +71,15 @@ protected:
const word name_;
// Protected member functions
Ostream& writeType(Ostream& os) const;
//- Write data to dictionary stream
virtual void writeData(Ostream& os) const
{}
public:
typedef Type returnType;
@ -137,8 +146,8 @@ public:
const scalarField& x2
) const = 0;
//- Write in dictionary format
virtual void writeData(Ostream& os) const;
//- Write dictionary to stream
virtual void write(Ostream& os) const;
// Member Operators

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -90,13 +90,27 @@ Foam::autoPtr<Foam::Function1<Type>> Foam::Function1<Type>::New
<< exit(FatalError);
}
return cstrIter()
autoPtr<Function1<Type>> funcPtr
(
cstrIter()
(
entryName,
dict.found(entryName + "Coeffs")
? dict.subDict(entryName + "Coeffs")
: dict
)
);
if (dict.found(entryName + "Coeffs"))
{
IOWarningInFunction(dict)
<< "Using deprecated "
<< (entryName + "Coeffs") << " sub-dictionary."<< nl
<< " Please use the simpler form" << endl;
funcPtr->write(Info);
}
return funcPtr;
}
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2017-2019 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2017-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -55,11 +55,9 @@ Foam::Function1s::OneConstant<Type>::~OneConstant()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::Function1s::OneConstant<Type>::writeData(Ostream& os) const
void Foam::Function1s::OneConstant<Type>::write(Ostream& os) const
{
Function1<Type>::writeData(os);
os << token::END_STATEMENT << nl;
this->writeType(os) << token::END_STATEMENT << nl;
}

View File

@ -87,7 +87,7 @@ public:
virtual inline Type integrate(const scalar x1, const scalar x2) const;
//- Write in dictionary format
virtual void writeData(Ostream& os) const;
virtual void write(Ostream& os) const;
// Member Operators

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -184,11 +184,10 @@ Type Foam::Function1s::Polynomial<Type>::integrate
template<class Type>
void Foam::Function1s::Polynomial<Type>::writeData(Ostream& os) const
void Foam::Function1s::Polynomial<Type>::write(Ostream& os) const
{
Function1<Type>::writeData(os);
os << nl << indent << coeffs_ << token::END_STATEMENT << nl;
this->writeType(os)
<< nl << indent << coeffs_ << token::END_STATEMENT << nl;
}

View File

@ -111,7 +111,7 @@ public:
//- Write in dictionary format
virtual void writeData(Ostream& os) const;
virtual void write(Ostream& os) const;
// Member Operators

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2017-2019 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2017-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -25,6 +25,16 @@ License
#include "Ramp.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template <class Function1Type>
void Foam::Function1s::Ramp<Function1Type>::writeData(Ostream& os) const
{
writeEntry(os, "start", start_);
writeEntry(os, "duration", duration_);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template <class Function1Type>
@ -55,19 +65,4 @@ Foam::Function1s::Ramp<Function1Type>::~Ramp()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template <class Function1Type>
void Foam::Function1s::Ramp<Function1Type>::writeData(Ostream& os) const
{
Function1<scalar>::writeData(os);
os << token::END_STATEMENT << nl;
os << indent << word(this->name() + "Coeffs") << nl;
os << indent << token::BEGIN_BLOCK << incrIndent << nl;
writeEntry(os, "start", start_);
writeEntry(os, "duration", duration_);
os << decrIndent << indent << token::END_BLOCK << endl;
}
// ************************************************************************* //

View File

@ -114,6 +114,9 @@ protected:
return 1/duration_;
}
//- Write data to dictionary stream
virtual void writeData(Ostream& os) const;
private:
@ -144,9 +147,6 @@ public:
//- Return value for time t
virtual scalar value(const scalar t) const = 0;
//- Write in dictionary format
virtual void writeData(Ostream& os) const;
// Member Operators

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2017-2019 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2017-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -47,6 +47,15 @@ void Foam::Function1s::Scale<Type>::read(const dictionary& coeffs)
}
template<class Type>
void Foam::Function1s::Scale<Type>::writeData(Ostream& os) const
{
scale_->write(os);
xScale_->write(os);
value_->write(os);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
@ -81,20 +90,4 @@ Foam::Function1s::Scale<Type>::~Scale()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::Function1s::Scale<Type>::writeData(Ostream& os) const
{
Function1<Type>::writeData(os);
os << token::END_STATEMENT << nl;
os << indent << word(this->name() + "Coeffs") << nl;
os << indent << token::BEGIN_BLOCK << incrIndent << nl;
scale_->writeData(os);
xScale_->writeData(os);
value_->writeData(os);
os << decrIndent << indent << token::END_BLOCK << endl;
}
// ************************************************************************* //

View File

@ -160,6 +160,9 @@ class Scale
//- Read the coefficients from the given dictionary
void read(const dictionary& coeffs);
//- Write data to dictionary stream
virtual void writeData(Ostream& os) const;
public:
@ -186,9 +189,6 @@ public:
// Member Functions
//- Write in dictionary format
virtual void writeData(Ostream& os) const;
//- Return value
virtual inline Type value(const scalar x) const;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2016-2019 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -41,6 +41,16 @@ void Foam::Function1s::Sine<Type>::read(const dictionary& coeffs)
}
template<class Type>
void Foam::Function1s::Sine<Type>::writeData(Ostream& os) const
{
amplitude_->write(os);
writeEntry(os, "frequency", frequency_);
writeEntry(os, "start", start_);
level_->write(os);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
@ -75,21 +85,4 @@ Foam::Function1s::Sine<Type>::~Sine()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::Function1s::Sine<Type>::writeData(Ostream& os) const
{
Function1<Type>::writeData(os);
os << token::END_STATEMENT << nl;
os << indent << word(this->name() + "Coeffs") << nl;
os << indent << token::BEGIN_BLOCK << incrIndent << nl;
amplitude_->writeData(os);
writeEntry(os, "frequency", frequency_);
writeEntry(os, "start", start_);
level_->writeData(os);
os << decrIndent << indent << token::END_BLOCK << endl;
}
// ************************************************************************* //

View File

@ -114,6 +114,9 @@ class Sine
//- Read the coefficients from the given dictionary
void read(const dictionary& coeffs);
//- Write data to dictionary stream
virtual void writeData(Ostream& os) const;
public:
@ -146,9 +149,6 @@ public:
//- Integrate between two values
virtual inline Type integrate(const scalar x1, const scalar x2) const;
//- Write in dictionary format
virtual void writeData(Ostream& os) const;
// Member Operators

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2016-2019 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -42,6 +42,17 @@ void Foam::Function1s::Square<Type>::read(const dictionary& coeffs)
}
template<class Type>
void Foam::Function1s::Square<Type>::writeData(Ostream& os) const
{
amplitude_->write(os);
writeEntry(os, "frequency", frequency_);
writeEntry(os, "start", start_);
level_->write(os);
writeEntry(os, "markSpace", markSpace_);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
@ -77,22 +88,4 @@ Foam::Function1s::Square<Type>::~Square()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::Function1s::Square<Type>::writeData(Ostream& os) const
{
Function1<Type>::writeData(os);
os << token::END_STATEMENT << nl;
os << indent << word(this->name() + "Coeffs") << nl;
os << indent << token::BEGIN_BLOCK << incrIndent << nl;
amplitude_->writeData(os);
writeEntry(os, "frequency", frequency_);
writeEntry(os, "start", start_);
level_->writeData(os);
writeEntry(os, "markSpace", markSpace_);
os << decrIndent << indent << token::END_BLOCK << endl;
}
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2016-2019 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -125,6 +125,9 @@ class Square
//- Read the coefficients from the given dictionary
void read(const dictionary& coeffs);
//- Write data to dictionary stream
virtual void writeData(Ostream& os) const;
public:
@ -157,9 +160,6 @@ public:
//- Integrate between two values
virtual inline Type integrate(const scalar x1, const scalar x2) const;
//- Write in dictionary format
virtual void writeData(Ostream& os) const;
// Member Operators

View File

@ -130,6 +130,29 @@ Foam::scalar Foam::Function1s::Table<Type>::bound
}
template<class Type>
void Foam::Function1s::Table<Type>::writeData(Ostream& os) const
{
writeEntryIfDifferent
(
os,
"outOfBounds",
tableBase::boundsHandlingNames_[tableBase::boundsHandling::clamp],
tableBase::boundsHandlingNames_[boundsHandling_]
);
writeEntryIfDifferent
(
os,
"interpolationScheme",
linearInterpolationWeights::typeName,
interpolationScheme_
);
reader_->write(os, table_);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
@ -293,38 +316,4 @@ Foam::Function1s::Table<Type>::y() const
}
template<class Type>
void Foam::Function1s::Table<Type>::writeData
(
Ostream& os
) const
{
Function1<Type>::writeData(os);
os << token::END_STATEMENT << nl;
os << indent << word(this->name() + "Coeffs") << nl;
os << indent << token::BEGIN_BLOCK << incrIndent << nl;
writeEntryIfDifferent
(
os,
"outOfBounds",
tableBase::boundsHandlingNames_[tableBase::boundsHandling::clamp],
tableBase::boundsHandlingNames_[boundsHandling_]
);
writeEntryIfDifferent
(
os,
"interpolationScheme",
linearInterpolationWeights::typeName,
interpolationScheme_
);
reader_->write(os, table_);
os << decrIndent << indent << token::END_BLOCK << endl;
}
// ************************************************************************* //

View File

@ -39,15 +39,51 @@ Description
);
\endverbatim
or in dictionary form which supports the setting of options, e.g.
\verbatim
<entryName> table;
values
(
(0.0 (1 2 3))
(1.0 (4 5 6))
);
outOfBounds clamp; // optional out-of-bounds handling
interpolationScheme linear; // optional interpolation method
\endverbatim
or in sub-dictionary form which avoids clashes between table entries and
other entries in the dictionary:
\verbatim
<entryName>
{
type table;
values
(
(0.0 (1 2 3))
(1.0 (4 5 6))
);
outOfBounds clamp; // optional out-of-bounds handling
interpolationScheme linear; // optional interpolation method
}
\endverbatim
The data may be read from a separate file in either native or CSV format:
Usage:
\verbatim
<entryName> table;
<entryName>
{
type table;
file "<file path>"; // Name/path of thedata file
format foam; // data format (optional)
outOfBounds clamp; // optional out-of-bounds handling
interpolationScheme linear; // optional interpolation method
}
\endverbatim
SourceFiles
@ -113,7 +149,7 @@ class Table
const autoPtr<TableReader<Type>> reader_;
// Protected Member Functions
// Private Member Functions
//- Return (demand driven) interpolator
const interpolationWeights& interpolator() const;
@ -126,6 +162,9 @@ class Table
// as the interpolator already performs that function.
scalar bound(const scalar x) const;
//- Write data to dictionary stream
virtual void writeData(Ostream& os) const;
public:
@ -169,9 +208,6 @@ public:
//- Return the dependent values
virtual tmp<Field<Type>> y() const;
//- Write all table data in dictionary format
virtual void writeData(Ostream& os) const;
// Member Operators

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2017-2019 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2017-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -48,11 +48,9 @@ Foam::Function1s::ZeroConstant<Type>::~ZeroConstant()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::Function1s::ZeroConstant<Type>::writeData(Ostream& os) const
void Foam::Function1s::ZeroConstant<Type>::write(Ostream& os) const
{
Function1<Type>::writeData(os);
os << token::END_STATEMENT << nl;
this->writeType(os) << token::END_STATEMENT << nl;
}

View File

@ -84,7 +84,7 @@ public:
virtual inline Type integrate(const scalar x1, const scalar x2) const;
//- Write in dictionary format
virtual void writeData(Ostream& os) const;
virtual void write(Ostream& os) const;
// Member Operators

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2019 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2019-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -36,6 +36,15 @@ namespace Function1s
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::Function1s::reverseRamp::writeData(Ostream& os) const
{
Ramp<reverseRamp>::writeData(os);
ramp_->write(os);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::Function1s::reverseRamp::reverseRamp
@ -65,17 +74,4 @@ Foam::Function1s::reverseRamp::~reverseRamp()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::Function1s::reverseRamp::writeData(Ostream& os) const
{
Ramp<reverseRamp>::writeData(os);
os << token::END_STATEMENT << nl;
os << indent << word(this->name() + "Coeffs") << nl;
os << indent << token::BEGIN_BLOCK << incrIndent << nl;
ramp_->writeData(os);
os << decrIndent << indent << token::END_BLOCK << endl;
}
// ************************************************************************* //

View File

@ -83,10 +83,18 @@ class reverseRamp
:
public Ramp<reverseRamp>
{
// Private Data
//- Standard ramp function to reverse
autoPtr<Function1<scalar>> ramp_;
// Private Member Functions
//- Write data to dictionary stream
virtual void writeData(Ostream& os) const;
public:
// Runtime type information
@ -122,9 +130,6 @@ public:
const scalar t2
) const;
//- Write in dictionary format
virtual void writeData(Ostream& os) const;
// Member Operators

View File

@ -88,6 +88,13 @@ Foam::Function2s::Coded<Type>::compileNew()
}
template<class Type>
void Foam::Function2s::Coded<Type>::writeData(Ostream& os) const
{
writeCode(os);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
@ -142,13 +149,4 @@ Foam::tmp<Foam::Field<Type>> Foam::Function2s::Coded<Type>::value
}
template<class Type>
void Foam::Function2s::Coded<Type>::writeData(Ostream& os) const
{
Function2<Type>::writeData(os);
os << token::END_STATEMENT << nl;
writeCode(os);
}
// ************************************************************************* //

View File

@ -89,6 +89,9 @@ class Coded
//- Compile, link and return the now coded Function2
autoPtr<Function2<Type>> compileNew();
//- Write data to dictionary stream
virtual void writeData(Ostream& os) const;
public:
@ -128,9 +131,6 @@ public:
const scalarField& y
) const;
//- Write in dictionary format
virtual void writeData(Ostream& os) const;
// Member Operators

View File

@ -99,11 +99,10 @@ Foam::Function2s::Constant<Type>::~Constant()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::Function2s::Constant<Type>::writeData(Ostream& os) const
void Foam::Function2s::Constant<Type>::write(Ostream& os) const
{
Function2<Type>::writeData(os);
os << token::SPACE << value_ << token::END_STATEMENT << nl;
this->writeType(os)
<< token::SPACE << value_ << token::END_STATEMENT << nl;
}

View File

@ -116,7 +116,7 @@ public:
) const;
//- Write in dictionary format
virtual void writeData(Ostream& os) const;
virtual void write(Ostream& os) const;
// Member Operators

View File

@ -25,6 +25,15 @@ License
#include "Function2.H"
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
template<class Type>
Foam::Ostream& Foam::Function2<Type>::writeType(Ostream& os) const
{
return writeKeyword(os, name_) << type();
}
// * * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * //
template<class Type>
@ -95,9 +104,16 @@ const Foam::word& Foam::Function2<Type>::name() const
template<class Type>
void Foam::Function2<Type>::writeData(Ostream& os) const
void Foam::Function2<Type>::write(Ostream& os) const
{
writeKeyword(os, name_) << type();
writeKeyword(os, name_)
<< nl << indent << token::BEGIN_BLOCK << nl << incrIndent;
writeEntry(os, "type", type());
writeData(os);
os << decrIndent << indent << token::END_BLOCK << endl;
}
@ -125,7 +141,7 @@ Foam::tmp<Foam::Field<Type>> Foam::FieldFunction2<Type, Function2Type>::value
template<class Type>
void Foam::writeEntry(Ostream& os, const Function2<Type>& f1)
{
f1.writeData(os);
f1.write(os);
}
@ -144,7 +160,7 @@ Foam::Ostream& Foam::operator<<
"Ostream& operator<<(Ostream&, const Function2<Type>&)"
);
f1.writeData(os);
f1.write(os);
return os;
}

View File

@ -71,6 +71,15 @@ protected:
const word name_;
// Protected member functions
Ostream& writeType(Ostream& os) const;
//- Write data to dictionary stream
virtual void writeData(Ostream& os) const
{}
public:
typedef Type returnType;
@ -132,7 +141,7 @@ public:
) const = 0;
//- Write in dictionary format
virtual void writeData(Ostream& os) const;
virtual void write(Ostream& os) const;
// Member Operators

View File

@ -90,13 +90,7 @@ Foam::autoPtr<Foam::Function2<Type>> Foam::Function2<Type>::New
<< exit(FatalError);
}
return cstrIter()
(
entryName,
dict.found(entryName + "Coeffs")
? dict.subDict(entryName + "Coeffs")
: dict
);
return cstrIter()(entryName, dict);
}
}

View File

@ -55,11 +55,9 @@ Foam::Function2s::OneConstant<Type>::~OneConstant()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::Function2s::OneConstant<Type>::writeData(Ostream& os) const
void Foam::Function2s::OneConstant<Type>::write(Ostream& os) const
{
Function2<Type>::writeData(os);
os << token::END_STATEMENT << nl;
this->writeType(os) << token::END_STATEMENT << nl;
}

View File

@ -91,7 +91,7 @@ public:
) const;
//- Write in dictionary format
virtual void writeData(Ostream& os) const;
virtual void write(Ostream& os) const;
// Member Operators

View File

@ -49,6 +49,16 @@ void Foam::Function2s::Scale<Type>::read(const dictionary& coeffs)
}
template<class Type>
void Foam::Function2s::Scale<Type>::writeData(Ostream& os) const
{
scale_->write(os);
xScale_->write(os);
yScale_->write(os);
value_->write(os);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
@ -82,21 +92,4 @@ Foam::Function2s::Scale<Type>::~Scale()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::Function2s::Scale<Type>::writeData(Ostream& os) const
{
Function2<Type>::writeData(os);
os << token::END_STATEMENT << nl;
os << indent << word(this->name() + "Coeffs") << nl;
os << indent << token::BEGIN_BLOCK << incrIndent << nl;
scale_->writeData(os);
xScale_->writeData(os);
yScale_->writeData(os);
value_->writeData(os);
os << decrIndent << indent << token::END_BLOCK << endl;
}
// ************************************************************************* //

View File

@ -80,6 +80,9 @@ class Scale
//- Read the coefficients from the given dictionary
void read(const dictionary& coeffs);
//- Write data to dictionary stream
virtual void writeData(Ostream& os) const;
public:
@ -106,9 +109,6 @@ public:
// Member Functions
//- Write in dictionary format
virtual void writeData(Ostream& os) const;
//- Return value
virtual inline Type value(const scalar x, const scalar y) const;

View File

@ -48,11 +48,9 @@ Foam::Function2s::ZeroConstant<Type>::~ZeroConstant()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::Function2s::ZeroConstant<Type>::writeData(Ostream& os) const
void Foam::Function2s::ZeroConstant<Type>::write(Ostream& os) const
{
Function2<Type>::writeData(os);
os << token::END_STATEMENT << nl;
this->writeType(os) << token::END_STATEMENT << nl;
}

View File

@ -88,7 +88,7 @@ public:
) const;
//- Write in dictionary format
virtual void writeData(Ostream& os) const;
virtual void write(Ostream& os) const;
// Member Operators

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2012-2019 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -120,9 +120,9 @@ Foam::Ostream& Foam::operator<<
template<class Type>
void Foam::TimeFunction1<Type>::writeData(Ostream& os) const
void Foam::TimeFunction1<Type>::write(Ostream& os) const
{
function_->writeData(os);
function_->write(os);
}

View File

@ -128,7 +128,7 @@ public:
);
//- Write in dictionary format
virtual void writeData(Ostream& os) const;
virtual void write(Ostream& os) const;
};

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -577,7 +577,7 @@ void Foam::MRFZone::writeData(Ostream& os) const
writeEntry(os, "cellZone", cellZoneName_);
writeEntry(os, "origin", origin_);
writeEntry(os, "axis", axis_);
omega_->writeData(os);
omega_->write(os);
if (excludedPatchNames_.size())
{

View File

@ -209,7 +209,7 @@ void Foam::sixDoFRigidBodyMotionRestraints::axialAngularSpring::write
writeEntry(os, "axis", axis_);
moment_->writeData(os);
moment_->write(os);
writeKeyword(os, "angleFormat");

View File

@ -23,12 +23,17 @@ boundaryField
inlet
{
type uniformTotalPressure;
p0 table
p0
{
type table;
values
(
(0 10)
(1 40)
);
}
}
outlet1
{