mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Rename DataEntry -> Function1
Function1 is an abstract base-class of run-time selectable unary functions which may be composed of other Function1's allowing the user to specify complex functions of a single scalar variable, e.g. time. The implementations need not be a simple or continuous functions; interpolated tables and polynomials are also supported. In fact form of mapping between a single scalar input and a single primitive type output is supportable. The primary application of Function1 is in time-varying boundary conditions, it also used for other functions of time, e.g. injected mass is spray simulations but is not limited to functions of time.
This commit is contained in:
267
src/OpenFOAM/primitives/functions/Function1/CSV/CSV.C
Normal file
267
src/OpenFOAM/primitives/functions/Function1/CSV/CSV.C
Normal file
@ -0,0 +1,267 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
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 "CSV.H"
|
||||
#include "DynamicList.H"
|
||||
#include "IFstream.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<>
|
||||
Foam::label Foam::Function1Types::CSV<Foam::label>::readValue
|
||||
(
|
||||
const List<string>& splitted
|
||||
)
|
||||
{
|
||||
if (componentColumns_[0] >= splitted.size())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "No column " << componentColumns_[0] << " in "
|
||||
<< splitted << endl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
return readLabel(IStringStream(splitted[componentColumns_[0]])());
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
Foam::scalar Foam::Function1Types::CSV<Foam::scalar>::readValue
|
||||
(
|
||||
const List<string>& splitted
|
||||
)
|
||||
{
|
||||
if (componentColumns_[0] >= splitted.size())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "No column " << componentColumns_[0] << " in "
|
||||
<< splitted << endl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
return readScalar(IStringStream(splitted[componentColumns_[0]])());
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Type Foam::Function1Types::CSV<Type>::readValue(const List<string>& splitted)
|
||||
{
|
||||
Type result;
|
||||
|
||||
for (label i = 0; i < pTraits<Type>::nComponents; i++)
|
||||
{
|
||||
if (componentColumns_[i] >= splitted.size())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "No column " << componentColumns_[i] << " in "
|
||||
<< splitted << endl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
result[i] =
|
||||
readScalar(IStringStream(splitted[componentColumns_[i]])());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::Function1Types::CSV<Type>::read()
|
||||
{
|
||||
fileName expandedFile(fName_);
|
||||
IFstream is(expandedFile.expand());
|
||||
|
||||
if (!is.good())
|
||||
{
|
||||
FatalIOErrorInFunction(is)
|
||||
<< "Cannot open CSV file for reading."
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
DynamicList<Tuple2<scalar, Type>> values;
|
||||
|
||||
// skip header
|
||||
for (label i = 0; i < nHeaderLine_; i++)
|
||||
{
|
||||
string line;
|
||||
is.getLine(line);
|
||||
}
|
||||
|
||||
label nEntries = max(componentColumns_);
|
||||
|
||||
// read data
|
||||
while (is.good())
|
||||
{
|
||||
string line;
|
||||
is.getLine(line);
|
||||
|
||||
|
||||
label n = 0;
|
||||
std::size_t pos = 0;
|
||||
DynamicList<string> splitted;
|
||||
|
||||
if (mergeSeparators_)
|
||||
{
|
||||
std::size_t nPos = 0;
|
||||
|
||||
while ((pos != std::string::npos) && (n <= nEntries))
|
||||
{
|
||||
bool found = false;
|
||||
while (!found)
|
||||
{
|
||||
nPos = line.find(separator_, pos);
|
||||
|
||||
if ((nPos != std::string::npos) && (nPos - pos == 0))
|
||||
{
|
||||
pos = nPos + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
nPos = line.find(separator_, pos);
|
||||
|
||||
if (nPos == std::string::npos)
|
||||
{
|
||||
splitted.append(line.substr(pos));
|
||||
pos = nPos;
|
||||
n++;
|
||||
}
|
||||
else
|
||||
{
|
||||
splitted.append(line.substr(pos, nPos - pos));
|
||||
pos = nPos + 1;
|
||||
n++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while ((pos != std::string::npos) && (n <= nEntries))
|
||||
{
|
||||
std::size_t nPos = line.find(separator_, pos);
|
||||
|
||||
if (nPos == std::string::npos)
|
||||
{
|
||||
splitted.append(line.substr(pos));
|
||||
pos = nPos;
|
||||
n++;
|
||||
}
|
||||
else
|
||||
{
|
||||
splitted.append(line.substr(pos, nPos - pos));
|
||||
pos = nPos + 1;
|
||||
n++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (splitted.size() <= 1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
scalar x = readScalar(IStringStream(splitted[refColumn_])());
|
||||
Type value = readValue(splitted);
|
||||
|
||||
values.append(Tuple2<scalar,Type>(x, value));
|
||||
}
|
||||
|
||||
this->table_.transfer(values);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::CSV<Type>::CSV
|
||||
(
|
||||
const word& entryName,
|
||||
const dictionary& dict,
|
||||
const word& ext
|
||||
)
|
||||
:
|
||||
TableBase<Type>(entryName, dict.subDict(entryName + ext)),
|
||||
coeffs_(dict.subDict(entryName + ext)),
|
||||
nHeaderLine_(readLabel(coeffs_.lookup("nHeaderLine"))),
|
||||
refColumn_(readLabel(coeffs_.lookup("refColumn"))),
|
||||
componentColumns_(coeffs_.lookup("componentColumns")),
|
||||
separator_(coeffs_.lookupOrDefault<string>("separator", string(","))[0]),
|
||||
mergeSeparators_(readBool(coeffs_.lookup("mergeSeparators"))),
|
||||
fName_(coeffs_.lookup("fileName"))
|
||||
{
|
||||
if (componentColumns_.size() != pTraits<Type>::nComponents)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< componentColumns_ << " does not have the expected length of "
|
||||
<< pTraits<Type>::nComponents << endl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
read();
|
||||
|
||||
TableBase<Type>::check();
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::CSV<Type>::CSV(const CSV<Type>& tbl)
|
||||
:
|
||||
TableBase<Type>(tbl),
|
||||
nHeaderLine_(tbl.nHeaderLine_),
|
||||
refColumn_(tbl.refColumn_),
|
||||
componentColumns_(tbl.componentColumns_),
|
||||
separator_(tbl.separator_),
|
||||
mergeSeparators_(tbl.mergeSeparators_),
|
||||
fName_(tbl.fName_)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::CSV<Type>::~CSV()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
const Foam::fileName& Foam::Function1Types::CSV<Type>::fName() const
|
||||
{
|
||||
return fName_;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * * * //
|
||||
|
||||
#include "CSVIO.C"
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
196
src/OpenFOAM/primitives/functions/Function1/CSV/CSV.H
Normal file
196
src/OpenFOAM/primitives/functions/Function1/CSV/CSV.H
Normal file
@ -0,0 +1,196 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
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::CSV
|
||||
|
||||
Description
|
||||
Templated CSV container data entry. Reference column is always a scalar,
|
||||
e.g. time
|
||||
|
||||
\verbatim
|
||||
<entryName> csvFile;
|
||||
<entryName>Coeffs
|
||||
{
|
||||
nHeaderLine 4; // number of header lines
|
||||
refColumn 0; // reference column index
|
||||
componentColumns (1 2 3); // component column indices
|
||||
separator ","; // optional (defaults to ",")
|
||||
mergeSeparators no; // merge multiple separators
|
||||
fileName "fileXYZ"; // name of csv data file
|
||||
outOfBounds clamp; // optional out-of-bounds handling
|
||||
interpolationScheme linear; // optional interpolation scheme
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
SourceFiles
|
||||
CSV.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef CSV_H
|
||||
#define CSV_H
|
||||
|
||||
#include "Function1.H"
|
||||
#include "TableBase.H"
|
||||
#include "Tuple2.H"
|
||||
#include "labelList.H"
|
||||
#include "ISstream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of friend functions and operators
|
||||
namespace Function1Types
|
||||
{
|
||||
template<class Type> class CSV;
|
||||
};
|
||||
|
||||
template<class Type>
|
||||
Ostream& operator<<(Ostream&, const Function1Types::CSV<Type>&);
|
||||
|
||||
namespace Function1Types
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class CSV Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class CSV
|
||||
:
|
||||
public TableBase<Type>
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Coefficients dictionary (for convenience on reading)
|
||||
dictionary coeffs_;
|
||||
|
||||
//- Number header lines
|
||||
label nHeaderLine_;
|
||||
|
||||
//- Column of the time
|
||||
label refColumn_;
|
||||
|
||||
//- Labels of the components
|
||||
labelList componentColumns_;
|
||||
|
||||
//- Separator character
|
||||
char separator_;
|
||||
|
||||
//- Merge separators flag, e.g. ',,,' becomes ','
|
||||
bool mergeSeparators_;
|
||||
|
||||
//- File name for csv table
|
||||
fileName fName_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Read csv data table
|
||||
void read();
|
||||
|
||||
//- Read the next value from the splitted string
|
||||
Type readValue(const List<string>&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const CSV<Type>&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("csvFile");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from entry name and dictionary
|
||||
CSV
|
||||
(
|
||||
const word& entryName,
|
||||
const dictionary& dict,
|
||||
const word& ext = "Coeffs"
|
||||
);
|
||||
|
||||
//- Copy constructor
|
||||
CSV(const CSV<Type>& tbl);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual tmp<Function1<Type>> clone() const
|
||||
{
|
||||
return tmp<Function1<Type>>(new CSV<Type>(*this));
|
||||
}
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~CSV();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
//- Return const access to the file name
|
||||
virtual const fileName& fName() const;
|
||||
|
||||
|
||||
// I/O
|
||||
|
||||
//- Ostream Operator
|
||||
friend Ostream& operator<< <Type>
|
||||
(
|
||||
Ostream& os,
|
||||
const CSV<Type>& cnst
|
||||
);
|
||||
|
||||
//- Write in dictionary format
|
||||
virtual void writeData(Ostream& os) const;
|
||||
};
|
||||
|
||||
|
||||
template<>
|
||||
label CSV<label>::readValue(const List<string>& splitted);
|
||||
|
||||
template<>
|
||||
Foam::scalar CSV<scalar>::readValue(const List<string>& splitted);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Function1Types
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "CSV.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
91
src/OpenFOAM/primitives/functions/Function1/CSV/CSVIO.C
Normal file
91
src/OpenFOAM/primitives/functions/Function1/CSV/CSVIO.C
Normal file
@ -0,0 +1,91 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
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 "Function1.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::Ostream& Foam::operator<<
|
||||
(
|
||||
Ostream& os,
|
||||
const Function1Types::CSV<Type>& tbl
|
||||
)
|
||||
{
|
||||
os << static_cast<const Function1<Type>& >(tbl)
|
||||
<< token::SPACE << tbl.nHeaderLine_
|
||||
<< token::SPACE << tbl.timeColumn_
|
||||
<< token::SPACE << tbl.componentColumns_
|
||||
<< token::SPACE << tbl.separator_
|
||||
<< token::SPACE << tbl.mergeSeparators_
|
||||
<< token::SPACE << tbl.fileName_;
|
||||
|
||||
// Check state of Ostream
|
||||
os.check("Ostream& operator<<(Ostream&, const CSV<Type>&)");
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::Function1Types::CSV<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;
|
||||
|
||||
// Note: for TableBase write the dictionary entries it needs but not
|
||||
// the values themselves
|
||||
TableBase<Type>::writeEntries(os);
|
||||
|
||||
os.writeKeyword("nHeaderLine") << nHeaderLine_ << token::END_STATEMENT
|
||||
<< nl;
|
||||
os.writeKeyword("refColumn") << refColumn_ << token::END_STATEMENT << nl;
|
||||
|
||||
// Force writing labelList in ascii
|
||||
os.writeKeyword("componentColumns");
|
||||
if (os.format() == IOstream::BINARY)
|
||||
{
|
||||
os.format(IOstream::ASCII);
|
||||
os << componentColumns_;
|
||||
os.format(IOstream::BINARY);
|
||||
}
|
||||
else
|
||||
{
|
||||
os << componentColumns_;
|
||||
}
|
||||
os << token::END_STATEMENT << nl;
|
||||
|
||||
os.writeKeyword("separator") << string(separator_)
|
||||
<< token::END_STATEMENT << nl;
|
||||
os.writeKeyword("mergeSeparators") << mergeSeparators_
|
||||
<< token::END_STATEMENT << nl;
|
||||
os.writeKeyword("fileName") << fName_ << token::END_STATEMENT << nl;
|
||||
os << decrIndent << indent << token::END_BLOCK << endl;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,97 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
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 "Constant.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::Constant<Type>::Constant
|
||||
(
|
||||
const word& entryName,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
Function1<Type>(entryName),
|
||||
value_(pTraits<Type>::zero)
|
||||
{
|
||||
Istream& is(dict.lookup(entryName));
|
||||
word entryType(is);
|
||||
is >> value_;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::Constant<Type>::Constant
|
||||
(
|
||||
const word& entryName,
|
||||
Istream& is
|
||||
)
|
||||
:
|
||||
Function1<Type>(entryName),
|
||||
value_(pTraits<Type>(is))
|
||||
{}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::Constant<Type>::Constant(const Constant<Type>& cnst)
|
||||
:
|
||||
Function1<Type>(cnst),
|
||||
value_(cnst.value_)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::Constant<Type>::~Constant()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Type Foam::Function1Types::Constant<Type>::value(const scalar x) const
|
||||
{
|
||||
return value_;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Type Foam::Function1Types::Constant<Type>::integrate
|
||||
(
|
||||
const scalar x1,
|
||||
const scalar x2
|
||||
) const
|
||||
{
|
||||
return (x2 - x1)*value_;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * * * //
|
||||
|
||||
#include "ConstantIO.C"
|
||||
|
||||
// ************************************************************************* //
|
||||
152
src/OpenFOAM/primitives/functions/Function1/Constant/Constant.H
Normal file
152
src/OpenFOAM/primitives/functions/Function1/Constant/Constant.H
Normal file
@ -0,0 +1,152 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
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::Constant
|
||||
|
||||
Description
|
||||
Templated basic entry that holds a constant value.
|
||||
|
||||
Usage - for entry \<entryName\> having the value <value>:
|
||||
\verbatim
|
||||
<entryName> constant <value>
|
||||
\endverbatim
|
||||
|
||||
SourceFiles
|
||||
Constant.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef Constant_H
|
||||
#define Constant_H
|
||||
|
||||
#include "Function1.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of friend functions and operators
|
||||
namespace Function1Types
|
||||
{
|
||||
template<class Type> class Constant;
|
||||
};
|
||||
|
||||
template<class Type>
|
||||
Ostream& operator<<(Ostream&, const Function1Types::Constant<Type>&);
|
||||
|
||||
namespace Function1Types
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class Constant Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class Constant
|
||||
:
|
||||
public Function1<Type>
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Constant value
|
||||
Type value_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const Constant<Type>&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Runtime type information
|
||||
TypeName("constant");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from entry name and dictionary
|
||||
Constant(const word& entryName, const dictionary& dict);
|
||||
|
||||
//- Construct from entry name and Istream
|
||||
// Reads the constant value without the Function1 type
|
||||
// for backward compatibility
|
||||
Constant(const word& entryName, Istream& is);
|
||||
|
||||
//- Copy constructor
|
||||
Constant(const Constant<Type>& cnst);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual tmp<Function1<Type>> clone() const
|
||||
{
|
||||
return tmp<Function1<Type>>(new Constant<Type>(*this));
|
||||
}
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~Constant();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return constant value
|
||||
Type value(const scalar) const;
|
||||
|
||||
//- Integrate between two values
|
||||
Type integrate(const scalar x1, const scalar x2) const;
|
||||
|
||||
|
||||
// I/O
|
||||
|
||||
//- Ostream Operator
|
||||
friend Ostream& operator<< <Type>
|
||||
(
|
||||
Ostream& os,
|
||||
const Constant<Type>& cnst
|
||||
);
|
||||
|
||||
//- Write in dictionary format
|
||||
virtual void writeData(Ostream& os) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Function1Types
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "Constant.C"
|
||||
# include "Function1New.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,59 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
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 "Constant.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::Ostream& Foam::operator<<
|
||||
(
|
||||
Ostream& os,
|
||||
const Function1Types::Constant<Type>& cnst
|
||||
)
|
||||
{
|
||||
os << static_cast<const Function1<Type>& >(cnst)
|
||||
<< token::SPACE << cnst.value_;
|
||||
|
||||
// Check state of Ostream
|
||||
os.check
|
||||
(
|
||||
"Ostream& operator<<(Ostream&, const Constant<Type>&)"
|
||||
);
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::Function1Types::Constant<Type>::writeData(Ostream& os) const
|
||||
{
|
||||
Function1<Type>::writeData(os);
|
||||
|
||||
os << token::SPACE << value_ << token::END_STATEMENT << nl;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,127 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
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 "Function1.H"
|
||||
#include "Time.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1<Type>::Function1(const word& entryName)
|
||||
:
|
||||
refCount(),
|
||||
name_(entryName)
|
||||
{}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1<Type>::Function1(const Function1<Type>& de)
|
||||
:
|
||||
refCount(),
|
||||
name_(de.name_)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1<Type>::~Function1()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
const Foam::word& Foam::Function1<Type>::name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::Function1<Type>::convertTimeBase(const Time&)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Type Foam::Function1<Type>::value(const scalar x) const
|
||||
{
|
||||
NotImplemented;
|
||||
|
||||
return pTraits<Type>::zero;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Type Foam::Function1<Type>::integrate(const scalar x1, const scalar x2) const
|
||||
{
|
||||
NotImplemented;
|
||||
|
||||
return pTraits<Type>::zero;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>> Foam::Function1<Type>::value
|
||||
(
|
||||
const scalarField& x
|
||||
) const
|
||||
{
|
||||
tmp<Field<Type>> tfld(new Field<Type>(x.size()));
|
||||
Field<Type>& fld = tfld();
|
||||
|
||||
forAll(x, i)
|
||||
{
|
||||
fld[i] = this->value(x[i]);
|
||||
}
|
||||
return tfld;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>> Foam::Function1<Type>::integrate
|
||||
(
|
||||
const scalarField& x1,
|
||||
const scalarField& x2
|
||||
) const
|
||||
{
|
||||
tmp<Field<Type>> tfld(new Field<Type>(x1.size()));
|
||||
Field<Type>& fld = tfld();
|
||||
|
||||
forAll(x1, i)
|
||||
{
|
||||
fld[i] = this->integrate(x1[i], x2[i]);
|
||||
}
|
||||
return tfld;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * * * //
|
||||
|
||||
#include "Function1IO.C"
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,209 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
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::Function1
|
||||
|
||||
Description
|
||||
Top level data entry class for use in dictionaries. Provides a mechanism
|
||||
to specify a variable as a certain type, e.g. constant or table, and
|
||||
provide functions to return the (interpolated) value, and integral between
|
||||
limits.
|
||||
|
||||
SourceFiles
|
||||
Function1.C
|
||||
Function1New.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef Function1_H
|
||||
#define Function1_H
|
||||
|
||||
#include "dictionary.H"
|
||||
#include "Field.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declarations
|
||||
class Time;
|
||||
|
||||
// Forward declaration of friend functions and operators
|
||||
template<class Type> class Function1;
|
||||
template<class Type> Ostream& operator<<(Ostream&, const Function1<Type>&);
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class Function1 Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class Function1
|
||||
:
|
||||
public refCount
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const Function1<Type>&);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Name of entry
|
||||
const word name_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("Function1")
|
||||
|
||||
//- Declare runtime constructor selection table
|
||||
declareRunTimeSelectionTable
|
||||
(
|
||||
autoPtr,
|
||||
Function1,
|
||||
dictionary,
|
||||
(
|
||||
const word& entryName,
|
||||
const dictionary& dict
|
||||
),
|
||||
(entryName, dict)
|
||||
);
|
||||
|
||||
|
||||
// Constructor
|
||||
|
||||
//- Construct from entry name
|
||||
Function1(const word& entryName);
|
||||
|
||||
//- Copy constructor
|
||||
Function1(const Function1<Type>& de);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual tmp<Function1<Type>> clone() const
|
||||
{
|
||||
return tmp<Function1<Type>>(new Function1<Type>(*this));
|
||||
}
|
||||
|
||||
|
||||
//- Selector
|
||||
static autoPtr<Function1<Type>> New
|
||||
(
|
||||
const word& entryName,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~Function1();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
//- Return the name of the entry
|
||||
const word& name() const;
|
||||
|
||||
|
||||
// Manipulation
|
||||
|
||||
//- Convert time
|
||||
virtual void convertTimeBase(const Time& t);
|
||||
|
||||
|
||||
// Evaluation
|
||||
|
||||
//- Return value as a function of (scalar) independent variable
|
||||
virtual Type value(const scalar x) const;
|
||||
|
||||
//- Return value as a function of (scalar) independent variable
|
||||
virtual tmp<Field<Type>> value(const scalarField& x) const;
|
||||
|
||||
//- Integrate between two (scalar) values
|
||||
virtual Type integrate(const scalar x1, const scalar x2) const;
|
||||
|
||||
//- Integrate between two (scalar) values
|
||||
virtual tmp<Field<Type>> integrate
|
||||
(
|
||||
const scalarField& x1,
|
||||
const scalarField& x2
|
||||
) const;
|
||||
|
||||
|
||||
// I/O
|
||||
|
||||
//- Ostream Operator
|
||||
friend Ostream& operator<< <Type>
|
||||
(
|
||||
Ostream& os,
|
||||
const Function1<Type>& de
|
||||
);
|
||||
|
||||
//- Write in dictionary format
|
||||
virtual void writeData(Ostream& os) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#define makeFunction1(Type) \
|
||||
\
|
||||
defineNamedTemplateTypeNameAndDebug(Function1<Type>, 0); \
|
||||
\
|
||||
defineTemplateRunTimeSelectionTable \
|
||||
( \
|
||||
Function1<Type>, \
|
||||
dictionary \
|
||||
);
|
||||
|
||||
|
||||
#define makeFunction1Type(SS, Type) \
|
||||
\
|
||||
defineNamedTemplateTypeNameAndDebug(Function1Types::SS<Type>, 0); \
|
||||
\
|
||||
Function1<Type>::adddictionaryConstructorToTable<Function1Types::SS<Type>> \
|
||||
add##SS##Type##ConstructorToTable_;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "Function1.C"
|
||||
# include "Constant.H"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,52 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
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/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef Function1Fws_H
|
||||
#define Function1Fws_H
|
||||
|
||||
#include "Function1.H"
|
||||
#include "vector.H"
|
||||
#include "symmTensor.H"
|
||||
#include "sphericalTensor.H"
|
||||
#include "tensor.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef Function1<label> labelFunction1;
|
||||
typedef Function1<scalar> scalarFunction1;
|
||||
typedef Function1<vector> vectorFunction1;
|
||||
typedef Function1<symmTensor> symmTensorFunction1;
|
||||
typedef Function1<sphericalTensor> sphericalTensorFunction1;
|
||||
typedef Function1<tensor> tensorFunction1;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,56 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
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 "Function1.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::Ostream& Foam::operator<<
|
||||
(
|
||||
Ostream& os,
|
||||
const Function1<Type>& de
|
||||
)
|
||||
{
|
||||
// Check state of Ostream
|
||||
os.check
|
||||
(
|
||||
"Ostream& operator<<(Ostream&, const Function1<Type>&)"
|
||||
);
|
||||
|
||||
os << de.name_;
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::Function1<Type>::writeData(Ostream& os) const
|
||||
{
|
||||
os.writeKeyword(name_) << type();
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,73 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
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 "Constant.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::autoPtr<Foam::Function1<Type>> Foam::Function1<Type>::New
|
||||
(
|
||||
const word& entryName,
|
||||
const dictionary& dict
|
||||
)
|
||||
{
|
||||
Istream& is(dict.lookup(entryName, false));
|
||||
|
||||
token firstToken(is);
|
||||
word Function1Type;
|
||||
|
||||
if (!firstToken.isWord())
|
||||
{
|
||||
is.putBack(firstToken);
|
||||
return autoPtr<Function1<Type>>
|
||||
(
|
||||
new Function1Types::Constant<Type>(entryName, is)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
Function1Type = firstToken.wordToken();
|
||||
}
|
||||
|
||||
typename dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(Function1Type);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown Function1 type "
|
||||
<< Function1Type << " for Function1 "
|
||||
<< entryName << nl << nl
|
||||
<< "Valid Function1 types are:" << nl
|
||||
<< dictionaryConstructorTablePtr_->sortedToc() << nl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
return cstrIter()(entryName, dict);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,205 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
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 "PolynomialEntry.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::Polynomial<Type>::Polynomial
|
||||
(
|
||||
const word& entryName,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
Function1<Type>(entryName),
|
||||
coeffs_(),
|
||||
canIntegrate_(true)
|
||||
{
|
||||
Istream& is(dict.lookup(entryName));
|
||||
word entryType(is);
|
||||
|
||||
is >> coeffs_;
|
||||
|
||||
if (!coeffs_.size())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Polynomial coefficients for entry " << this->name_
|
||||
<< " are invalid (empty)" << nl << exit(FatalError);
|
||||
}
|
||||
|
||||
forAll(coeffs_, i)
|
||||
{
|
||||
if (mag(coeffs_[i].second() + pTraits<Type>::one) < ROOTVSMALL)
|
||||
{
|
||||
canIntegrate_ = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
if (!canIntegrate_)
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Polynomial " << this->name_ << " cannot be integrated"
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::Polynomial<Type>::Polynomial
|
||||
(
|
||||
const word& entryName,
|
||||
const List<Tuple2<Type, Type>>& coeffs
|
||||
)
|
||||
:
|
||||
Function1<Type>(entryName),
|
||||
coeffs_(coeffs),
|
||||
canIntegrate_(true)
|
||||
{
|
||||
if (!coeffs_.size())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Polynomial coefficients for entry " << this->name_
|
||||
<< " are invalid (empty)" << 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::Polynomial<Type>::Polynomial(const Polynomial& poly)
|
||||
:
|
||||
Function1<Type>(poly),
|
||||
coeffs_(poly.coeffs_),
|
||||
canIntegrate_(poly.canIntegrate_)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::Polynomial<Type>::~Polynomial()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::Function1Types::Polynomial<Type>::convertTimeBase(const Time& t)
|
||||
{
|
||||
forAll(coeffs_, i)
|
||||
{
|
||||
Type value = coeffs_[i].first();
|
||||
for (direction cmpt = 0; cmpt < pTraits<Type>::nComponents; cmpt++)
|
||||
{
|
||||
setComponent(coeffs_[i].first(), cmpt) =
|
||||
t.userTimeToTime(component(value, cmpt));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Type Foam::Function1Types::Polynomial<Type>::value(const scalar x) const
|
||||
{
|
||||
Type y(pTraits<Type>::zero);
|
||||
forAll(coeffs_, i)
|
||||
{
|
||||
y += cmptMultiply
|
||||
(
|
||||
coeffs_[i].first(),
|
||||
cmptPow(pTraits<Type>::one*x, coeffs_[i].second())
|
||||
);
|
||||
}
|
||||
|
||||
return y;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Type Foam::Function1Types::Polynomial<Type>::integrate
|
||||
(
|
||||
const scalar x1,
|
||||
const scalar x2
|
||||
) const
|
||||
{
|
||||
Type intx(pTraits<Type>::zero);
|
||||
|
||||
if (canIntegrate_)
|
||||
{
|
||||
forAll(coeffs_, i)
|
||||
{
|
||||
intx += cmptMultiply
|
||||
(
|
||||
cmptDivide
|
||||
(
|
||||
coeffs_[i].first(),
|
||||
coeffs_[i].second() + pTraits<Type>::one
|
||||
),
|
||||
cmptPow
|
||||
(
|
||||
pTraits<Type>::one*x2,
|
||||
coeffs_[i].second() + pTraits<Type>::one
|
||||
)
|
||||
- cmptPow
|
||||
(
|
||||
pTraits<Type>::one*x1,
|
||||
coeffs_[i].second() + pTraits<Type>::one
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return intx;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * * * //
|
||||
|
||||
#include "PolynomialEntryIO.C"
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,170 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
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::PolynomialEntry
|
||||
|
||||
Description
|
||||
PolynomialEntry container data entry for scalars. Items are stored in a
|
||||
list of Tuple2's. Data is input in the form,
|
||||
e.g. for an entry \<entryName\> that describes y = x^2 + 2x^3
|
||||
|
||||
\verbatim
|
||||
<entryName> polynomial
|
||||
(
|
||||
(1 2)
|
||||
(2 3)
|
||||
);
|
||||
\endverbatim
|
||||
|
||||
SourceFiles
|
||||
PolynomialEntry.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef PolynomialEntry_H
|
||||
#define PolynomialEntry_H
|
||||
|
||||
#include "Function1.H"
|
||||
#include "Tuple2.H"
|
||||
#include "Function1Fwd.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of friend functions and operators
|
||||
namespace Function1Types
|
||||
{
|
||||
template<class Type> class Polynomial;
|
||||
};
|
||||
|
||||
template<class Type>
|
||||
Ostream& operator<<(Ostream&, const Function1Types::Polynomial<Type>&);
|
||||
|
||||
namespace Function1Types
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class Polynomial Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class Polynomial
|
||||
:
|
||||
public Function1<Type>
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Polynomial coefficients - list of prefactor, exponent
|
||||
List<Tuple2<Type, Type>> coeffs_;
|
||||
|
||||
//- Flag to indicate whether poly can be integrated
|
||||
bool canIntegrate_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const Polynomial<Type>&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("polynomial");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
Polynomial(const word& entryName, const dictionary& dict);
|
||||
|
||||
//- Construct from components
|
||||
Polynomial
|
||||
(
|
||||
const word& entryName,
|
||||
const List<Tuple2<Type, Type>>&
|
||||
);
|
||||
|
||||
//- Copy constructor
|
||||
Polynomial(const Polynomial& poly);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual tmp<Function1<Type>> clone() const
|
||||
{
|
||||
return tmp<Function1<Type>>(new Polynomial(*this));
|
||||
}
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~Polynomial();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Manipulation
|
||||
|
||||
//- Convert time
|
||||
virtual void convertTimeBase(const Time& t);
|
||||
|
||||
|
||||
// Evaluation
|
||||
|
||||
//- Return Polynomial value
|
||||
Type value(const scalar x) const;
|
||||
|
||||
//- Integrate between two (scalar) values
|
||||
Type integrate(const scalar x1, const scalar x2) const;
|
||||
|
||||
|
||||
// I/O
|
||||
|
||||
//- Ostream Operator
|
||||
friend Ostream& operator<< <Type>
|
||||
(
|
||||
Ostream& os,
|
||||
const Polynomial<Type>& cnst
|
||||
);
|
||||
|
||||
//- Write in dictionary format
|
||||
virtual void writeData(Ostream& os) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Function1Types
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "PolynomialEntry.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,59 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
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 "PolynomialEntry.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::Ostream& Foam::operator<<
|
||||
(
|
||||
Ostream& os,
|
||||
const Function1Types::Polynomial<Type>& poly
|
||||
)
|
||||
{
|
||||
os << static_cast<const Function1<Type>& >(poly)
|
||||
<< token::SPACE << poly.coeffs_;
|
||||
|
||||
// Check state of Ostream
|
||||
os.check
|
||||
(
|
||||
"Ostream& operator<<(Ostream&, const Polynomial&)"
|
||||
);
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::Function1Types::Polynomial<Type>::writeData(Ostream& os) const
|
||||
{
|
||||
Function1<Type>::writeData(os);
|
||||
|
||||
os << nl << indent << coeffs_ << token::END_STATEMENT << nl;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
102
src/OpenFOAM/primitives/functions/Function1/Sine/Sine.C
Normal file
102
src/OpenFOAM/primitives/functions/Function1/Sine/Sine.C
Normal file
@ -0,0 +1,102 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
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 "Sine.H"
|
||||
#include "mathematicalConstants.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::Function1Types::Sine<Type>::read(const dictionary& coeffs)
|
||||
{
|
||||
t0_ = coeffs.lookupOrDefault<scalar>("t0", 0);
|
||||
amplitude_ = coeffs.lookupOrDefault<scalar>("amplitude", 1);
|
||||
frequency_ = readScalar(coeffs.lookup("frequency"));
|
||||
scale_ = pTraits<Type>(coeffs.lookup("scale"));
|
||||
level_ = pTraits<Type>(coeffs.lookup("level"));
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::Sine<Type>::Sine
|
||||
(
|
||||
const word& entryName,
|
||||
const dictionary& dict,
|
||||
const word& ext
|
||||
)
|
||||
:
|
||||
Function1<Type>(entryName)
|
||||
{
|
||||
read(dict.subDict(entryName + ext));
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::Sine<Type>::Sine(const Sine<Type>& se)
|
||||
:
|
||||
Function1<Type>(se),
|
||||
t0_(se.t0_),
|
||||
amplitude_(se.amplitude_),
|
||||
frequency_(se.frequency_),
|
||||
level_(se.level_)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::Sine<Type>::~Sine()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Type Foam::Function1Types::Sine<Type>::value(const scalar t) const
|
||||
{
|
||||
return
|
||||
amplitude_*sin(constant::mathematical::twoPi*frequency_*(t - t0_))
|
||||
*scale_
|
||||
+ level_;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Type Foam::Function1Types::Sine<Type>::integrate
|
||||
(
|
||||
const scalar t1,
|
||||
const scalar t2
|
||||
) const
|
||||
{
|
||||
NotImplemented;
|
||||
return level_;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * * * //
|
||||
|
||||
#include "SineIO.C"
|
||||
|
||||
// ************************************************************************* //
|
||||
200
src/OpenFOAM/primitives/functions/Function1/Sine/Sine.H
Normal file
200
src/OpenFOAM/primitives/functions/Function1/Sine/Sine.H
Normal file
@ -0,0 +1,200 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
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::Sine
|
||||
|
||||
Description
|
||||
Templated sine function with support for an offset level.
|
||||
|
||||
\f[
|
||||
a sin(2 \pi f (t - t_0)) s + l
|
||||
\f]
|
||||
|
||||
where
|
||||
|
||||
\vartable
|
||||
a | Amplitude
|
||||
f | Frequency [1/s]
|
||||
s | Type scale factor
|
||||
l | Type offset level
|
||||
t_0 | Start time [s]
|
||||
t | Time [s]
|
||||
\endvartable
|
||||
|
||||
Example for a scalar:
|
||||
\verbatim
|
||||
<entryName> sine;
|
||||
<entryName>Coeffs
|
||||
{
|
||||
frequency 10;
|
||||
amplitude 0.1;
|
||||
scale 2e-6;
|
||||
level 2e-6;
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
Example for a vector:
|
||||
\verbatim
|
||||
<entryName> sine;
|
||||
<entryName>Coeffs
|
||||
{
|
||||
frequency 10;
|
||||
amplitude 1;
|
||||
scale (1 0.1 0);
|
||||
level (10 1 0);
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
SourceFiles
|
||||
Sine.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef Sine_H
|
||||
#define Sine_H
|
||||
|
||||
#include "Function1.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of friend functions and operators
|
||||
namespace Function1Types
|
||||
{
|
||||
template<class Type> class Sine;
|
||||
};
|
||||
|
||||
template<class Type>
|
||||
Ostream& operator<<(Ostream&, const Function1Types::Sine<Type>&);
|
||||
|
||||
namespace Function1Types
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class Sine Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class Sine
|
||||
:
|
||||
public Function1<Type>
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Start-time for the sin function
|
||||
scalar t0_;
|
||||
|
||||
//- Scalar amplitude of the sin function
|
||||
scalar amplitude_;
|
||||
|
||||
//- Frequency of the sin function
|
||||
scalar frequency_;
|
||||
|
||||
//- Scaling factor of the sin function
|
||||
Type scale_;
|
||||
|
||||
//- Level to which the sin function is added
|
||||
Type level_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Read the coefficients from the given dictionary
|
||||
void read(const dictionary& coeffs);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const Sine<Type>&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Runtime type information
|
||||
TypeName("sine");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from entry name and dictionary
|
||||
Sine
|
||||
(
|
||||
const word& entryName,
|
||||
const dictionary& dict,
|
||||
const word& ext = "Coeffs"
|
||||
);
|
||||
|
||||
//- Copy constructor
|
||||
Sine(const Sine<Type>& se);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual tmp<Function1<Type>> clone() const
|
||||
{
|
||||
return tmp<Function1<Type>>(new Sine<Type>(*this));
|
||||
}
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~Sine();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return value for time t
|
||||
Type value(const scalar t) const;
|
||||
|
||||
//- Integrate between the two time values t1 and t2
|
||||
Type integrate(const scalar t1, const scalar t2) const;
|
||||
|
||||
|
||||
// I/O
|
||||
|
||||
//- Ostream Operator
|
||||
friend Ostream& operator<< <Type>
|
||||
(
|
||||
Ostream& os,
|
||||
const Sine<Type>& cnst
|
||||
);
|
||||
|
||||
//- Write in dictionary format
|
||||
virtual void writeData(Ostream& os) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Function1Types
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "Sine.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
70
src/OpenFOAM/primitives/functions/Function1/Sine/SineIO.C
Normal file
70
src/OpenFOAM/primitives/functions/Function1/Sine/SineIO.C
Normal file
@ -0,0 +1,70 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
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 "Sine.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::Ostream& Foam::operator<<
|
||||
(
|
||||
Ostream& os,
|
||||
const Function1Types::Sine<Type>& se
|
||||
)
|
||||
{
|
||||
os << static_cast<const Function1<Type>& >(se)
|
||||
<< token::SPACE << se.t0_
|
||||
<< token::SPACE << se.amplitude_
|
||||
<< token::SPACE << se.frequency_
|
||||
<< token::SPACE << se.scale_
|
||||
<< token::SPACE << se.level_;
|
||||
|
||||
// Check state of Ostream
|
||||
os.check
|
||||
(
|
||||
"Ostream& operator<<(Ostream&, const Sine<Type>&)"
|
||||
);
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::Function1Types::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;
|
||||
os.writeKeyword("t0") << t0_ << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("amplitude") << amplitude_ << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("frequency") << frequency_ << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("scale") << scale_ << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("level") << level_ << token::END_STATEMENT << nl;
|
||||
os << decrIndent << indent << token::END_BLOCK << endl;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
60
src/OpenFOAM/primitives/functions/Function1/Table/Table.C
Normal file
60
src/OpenFOAM/primitives/functions/Function1/Table/Table.C
Normal file
@ -0,0 +1,60 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
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 "Table.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::Table<Type>::Table
|
||||
(
|
||||
const word& entryName,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
TableBase<Type>(entryName, dict)
|
||||
{
|
||||
Istream& is(dict.lookup(entryName));
|
||||
word entryType(is);
|
||||
is >> this->table_;
|
||||
TableBase<Type>::check();
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::Table<Type>::Table(const Table<Type>& tbl)
|
||||
:
|
||||
TableBase<Type>(tbl)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::Table<Type>::~Table()
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
124
src/OpenFOAM/primitives/functions/Function1/Table/Table.H
Normal file
124
src/OpenFOAM/primitives/functions/Function1/Table/Table.H
Normal file
@ -0,0 +1,124 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
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::Table
|
||||
|
||||
Description
|
||||
Templated table container data entry. Items are stored in a list of
|
||||
Tuple2's. First column is always stored as scalar entries. Data is read
|
||||
in Tuple2 form, e.g. for an entry \<entryName\> that is (scalar, vector):
|
||||
|
||||
\verbatim
|
||||
<entryName> table
|
||||
(
|
||||
(0.0 (1 2 3))
|
||||
(1.0 (4 5 6))
|
||||
);
|
||||
\endverbatim
|
||||
|
||||
SourceFiles
|
||||
Table.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef Table_H
|
||||
#define Table_H
|
||||
|
||||
#include "Function1.H"
|
||||
#include "Tuple2.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of friend functions and operators
|
||||
namespace Function1Types
|
||||
{
|
||||
template<class Type> class Table;
|
||||
};
|
||||
|
||||
template<class Type>
|
||||
Ostream& operator<<(Ostream&, const Function1Types::Table<Type>&);
|
||||
|
||||
namespace Function1Types
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class Table Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class Table
|
||||
:
|
||||
public TableBase<Type>
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const Table<Type>&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("table");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from entry name and Istream
|
||||
Table(const word& entryName, const dictionary& dict);
|
||||
|
||||
//- Copy constructor
|
||||
Table(const Table<Type>& tbl);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual tmp<Function1<Type>> clone() const
|
||||
{
|
||||
return tmp<Function1<Type>>(new Table<Type>(*this));
|
||||
}
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~Table();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Function1Types
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "Table.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
413
src/OpenFOAM/primitives/functions/Function1/Table/TableBase.C
Normal file
413
src/OpenFOAM/primitives/functions/Function1/Table/TableBase.C
Normal file
@ -0,0 +1,413 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
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 "TableBase.H"
|
||||
#include "Time.H"
|
||||
#include "interpolationWeights.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
const Foam::interpolationWeights&
|
||||
Foam::Function1Types::TableBase<Type>::interpolator() const
|
||||
{
|
||||
if (interpolatorPtr_.empty())
|
||||
{
|
||||
// Re-work table into linear list
|
||||
tableSamplesPtr_.reset(new scalarField(table_.size()));
|
||||
scalarField& tableSamples = tableSamplesPtr_();
|
||||
forAll(table_, i)
|
||||
{
|
||||
tableSamples[i] = table_[i].first();
|
||||
}
|
||||
interpolatorPtr_ = interpolationWeights::New
|
||||
(
|
||||
interpolationScheme_,
|
||||
tableSamples
|
||||
);
|
||||
}
|
||||
|
||||
return interpolatorPtr_();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::TableBase<Type>::TableBase
|
||||
(
|
||||
const word& name,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
Function1<Type>(name),
|
||||
name_(name),
|
||||
boundsHandling_
|
||||
(
|
||||
wordToBoundsHandling
|
||||
(
|
||||
dict.lookupOrDefault<word>("outOfBounds", "clamp")
|
||||
)
|
||||
),
|
||||
interpolationScheme_
|
||||
(
|
||||
dict.lookupOrDefault<word>("interpolationScheme", "linear")
|
||||
),
|
||||
table_()
|
||||
{}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::TableBase<Type>::TableBase(const TableBase<Type>& tbl)
|
||||
:
|
||||
Function1<Type>(tbl),
|
||||
name_(tbl.name_),
|
||||
boundsHandling_(tbl.boundsHandling_),
|
||||
interpolationScheme_(tbl.interpolationScheme_),
|
||||
table_(tbl.table_),
|
||||
tableSamplesPtr_(tbl.tableSamplesPtr_),
|
||||
interpolatorPtr_(tbl.interpolatorPtr_)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::TableBase<Type>::~TableBase()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::word Foam::Function1Types::TableBase<Type>::boundsHandlingToWord
|
||||
(
|
||||
const boundsHandling& bound
|
||||
) const
|
||||
{
|
||||
word enumName("warn");
|
||||
|
||||
switch (bound)
|
||||
{
|
||||
case ERROR:
|
||||
{
|
||||
enumName = "error";
|
||||
break;
|
||||
}
|
||||
case WARN:
|
||||
{
|
||||
enumName = "warn";
|
||||
break;
|
||||
}
|
||||
case CLAMP:
|
||||
{
|
||||
enumName = "clamp";
|
||||
break;
|
||||
}
|
||||
case REPEAT:
|
||||
{
|
||||
enumName = "repeat";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return enumName;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
typename Foam::Function1Types::TableBase<Type>::boundsHandling
|
||||
Foam::Function1Types::TableBase<Type>::wordToBoundsHandling
|
||||
(
|
||||
const word& bound
|
||||
) const
|
||||
{
|
||||
if (bound == "error")
|
||||
{
|
||||
return ERROR;
|
||||
}
|
||||
else if (bound == "warn")
|
||||
{
|
||||
return WARN;
|
||||
}
|
||||
else if (bound == "clamp")
|
||||
{
|
||||
return CLAMP;
|
||||
}
|
||||
else if (bound == "repeat")
|
||||
{
|
||||
return REPEAT;
|
||||
}
|
||||
else
|
||||
{
|
||||
WarningInFunction
|
||||
<< "bad outOfBounds specifier " << bound << " using 'warn'"
|
||||
<< endl;
|
||||
|
||||
return WARN;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
typename Foam::Function1Types::TableBase<Type>::boundsHandling
|
||||
Foam::Function1Types::TableBase<Type>::outOfBounds
|
||||
(
|
||||
const boundsHandling& bound
|
||||
)
|
||||
{
|
||||
boundsHandling prev = boundsHandling_;
|
||||
boundsHandling_ = bound;
|
||||
|
||||
return prev;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::Function1Types::TableBase<Type>::check() const
|
||||
{
|
||||
if (!table_.size())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Table for entry " << this->name_ << " is invalid (empty)"
|
||||
<< nl << exit(FatalError);
|
||||
}
|
||||
|
||||
label n = table_.size();
|
||||
scalar prevValue = table_[0].first();
|
||||
|
||||
for (label i = 1; i < n; ++i)
|
||||
{
|
||||
const scalar currValue = table_[i].first();
|
||||
|
||||
// avoid duplicate values (divide-by-zero error)
|
||||
if (currValue <= prevValue)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "out-of-order value: " << currValue << " at index " << i
|
||||
<< exit(FatalError);
|
||||
}
|
||||
prevValue = currValue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
bool Foam::Function1Types::TableBase<Type>::checkMinBounds
|
||||
(
|
||||
const scalar x,
|
||||
scalar& xDash
|
||||
) const
|
||||
{
|
||||
if (x < table_[0].first())
|
||||
{
|
||||
switch (boundsHandling_)
|
||||
{
|
||||
case ERROR:
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "value (" << x << ") underflow"
|
||||
<< exit(FatalError);
|
||||
break;
|
||||
}
|
||||
case WARN:
|
||||
{
|
||||
WarningInFunction
|
||||
<< "value (" << x << ") underflow" << nl
|
||||
<< endl;
|
||||
|
||||
// fall-through to 'CLAMP'
|
||||
}
|
||||
case CLAMP:
|
||||
{
|
||||
xDash = table_[0].first();
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
case REPEAT:
|
||||
{
|
||||
// adjust x to >= minX
|
||||
scalar span = table_.last().first() - table_[0].first();
|
||||
xDash = fmod(x - table_[0].first(), span) + table_[0].first();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
xDash = x;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
bool Foam::Function1Types::TableBase<Type>::checkMaxBounds
|
||||
(
|
||||
const scalar x,
|
||||
scalar& xDash
|
||||
) const
|
||||
{
|
||||
if (x > table_.last().first())
|
||||
{
|
||||
switch (boundsHandling_)
|
||||
{
|
||||
case ERROR:
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "value (" << x << ") overflow"
|
||||
<< exit(FatalError);
|
||||
break;
|
||||
}
|
||||
case WARN:
|
||||
{
|
||||
WarningInFunction
|
||||
<< "value (" << x << ") overflow" << nl
|
||||
<< endl;
|
||||
|
||||
// fall-through to 'CLAMP'
|
||||
}
|
||||
case CLAMP:
|
||||
{
|
||||
xDash = table_.last().first();
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
case REPEAT:
|
||||
{
|
||||
// adjust x to >= minX
|
||||
scalar span = table_.last().first() - table_[0].first();
|
||||
xDash = fmod(x - table_[0].first(), span) + table_[0].first();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
xDash = x;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::Function1Types::TableBase<Type>::convertTimeBase(const Time& t)
|
||||
{
|
||||
forAll(table_, i)
|
||||
{
|
||||
scalar value = table_[i].first();
|
||||
table_[i].first() = t.userTimeToTime(value);
|
||||
}
|
||||
|
||||
tableSamplesPtr_.clear();
|
||||
interpolatorPtr_.clear();
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Type Foam::Function1Types::TableBase<Type>::value(const scalar x) const
|
||||
{
|
||||
scalar xDash = x;
|
||||
|
||||
if (checkMinBounds(x, xDash))
|
||||
{
|
||||
return table_[0].second();
|
||||
}
|
||||
|
||||
if (checkMaxBounds(xDash, xDash))
|
||||
{
|
||||
return table_.last().second();
|
||||
}
|
||||
|
||||
// Use interpolator
|
||||
interpolator().valueWeights(xDash, currentIndices_, currentWeights_);
|
||||
|
||||
Type t = currentWeights_[0]*table_[currentIndices_[0]].second();
|
||||
for (label i = 1; i < currentIndices_.size(); i++)
|
||||
{
|
||||
t += currentWeights_[i]*table_[currentIndices_[i]].second();
|
||||
}
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Type Foam::Function1Types::TableBase<Type>::integrate
|
||||
(
|
||||
const scalar x1,
|
||||
const scalar x2
|
||||
) const
|
||||
{
|
||||
// Use interpolator
|
||||
interpolator().integrationWeights(x1, x2, currentIndices_, currentWeights_);
|
||||
|
||||
Type sum = currentWeights_[0]*table_[currentIndices_[0]].second();
|
||||
for (label i = 1; i < currentIndices_.size(); i++)
|
||||
{
|
||||
sum += currentWeights_[i]*table_[currentIndices_[i]].second();
|
||||
}
|
||||
|
||||
return sum;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::scalarField> Foam::Function1Types::TableBase<Type>::x() const
|
||||
{
|
||||
tmp<scalarField> tfld(new scalarField(table_.size(), 0.0));
|
||||
scalarField& fld = tfld();
|
||||
|
||||
forAll(table_, i)
|
||||
{
|
||||
fld[i] = table_[i].first();
|
||||
}
|
||||
|
||||
return tfld;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>> Foam::Function1Types::TableBase<Type>::y() const
|
||||
{
|
||||
tmp<Field<Type>> tfld(new Field<Type>(table_.size(), pTraits<Type>::zero));
|
||||
Field<Type>& fld = tfld();
|
||||
|
||||
forAll(table_, i)
|
||||
{
|
||||
fld[i] = table_[i].second();
|
||||
}
|
||||
|
||||
return tfld;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * * * //
|
||||
|
||||
#include "TableBaseIO.C"
|
||||
|
||||
// ************************************************************************* //
|
||||
204
src/OpenFOAM/primitives/functions/Function1/Table/TableBase.H
Normal file
204
src/OpenFOAM/primitives/functions/Function1/Table/TableBase.H
Normal file
@ -0,0 +1,204 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
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::TableBase
|
||||
|
||||
Description
|
||||
Base class for table with bounds handling, interpolation and integration
|
||||
|
||||
SourceFiles
|
||||
TableBase.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef TableBase_H
|
||||
#define TableBase_H
|
||||
|
||||
#include "Function1.H"
|
||||
#include "Tuple2.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class interpolationWeights;
|
||||
|
||||
// Forward declaration of friend functions and operators
|
||||
namespace Function1Types
|
||||
{
|
||||
template<class Type> class TableBase;
|
||||
};
|
||||
|
||||
template<class Type>
|
||||
Ostream& operator<<(Ostream&, const Function1Types::TableBase<Type>&);
|
||||
|
||||
namespace Function1Types
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class TableBase Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class TableBase
|
||||
:
|
||||
public Function1<Type>
|
||||
{
|
||||
public:
|
||||
|
||||
// Public data types
|
||||
|
||||
//- Enumeration for handling out-of-bound values
|
||||
enum boundsHandling
|
||||
{
|
||||
ERROR, /*!< Exit with a FatalError */
|
||||
WARN, /*!< Issue warning and clamp value (default) */
|
||||
CLAMP, /*!< Clamp value to the start/end value */
|
||||
REPEAT /*!< Treat as a repeating list */
|
||||
};
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Table name
|
||||
const word name_;
|
||||
|
||||
//- Enumeration for handling out-of-bound values
|
||||
const boundsHandling boundsHandling_;
|
||||
|
||||
//- Interpolation type
|
||||
const word interpolationScheme_;
|
||||
|
||||
//- Table data
|
||||
List<Tuple2<scalar, Type>> table_;
|
||||
|
||||
//- Extracted values
|
||||
mutable autoPtr<scalarField> tableSamplesPtr_;
|
||||
|
||||
//- Interpolator method
|
||||
mutable autoPtr<interpolationWeights> interpolatorPtr_;
|
||||
|
||||
//- Cached indices and weights
|
||||
mutable labelList currentIndices_;
|
||||
|
||||
mutable scalarField currentWeights_;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Return (demand driven) interpolator
|
||||
const interpolationWeights& interpolator() const;
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const TableBase<Type>&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from dictionary - note table is not populated
|
||||
TableBase(const word& name, const dictionary& dict);
|
||||
|
||||
//- Copy constructor. Note: steals interpolator, tableSamples
|
||||
TableBase(const TableBase<Type>& tbl);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~TableBase();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return the out-of-bounds handling as a word
|
||||
word boundsHandlingToWord(const boundsHandling& bound) const;
|
||||
|
||||
//- Return the out-of-bounds handling as an enumeration
|
||||
boundsHandling wordToBoundsHandling(const word& bound) const;
|
||||
|
||||
//- Set the out-of-bounds handling from enum, return previous setting
|
||||
boundsHandling outOfBounds(const boundsHandling& bound);
|
||||
|
||||
//- Check the table for size and consistency
|
||||
void check() const;
|
||||
|
||||
//- Check minimum table bounds
|
||||
bool checkMinBounds(const scalar x, scalar& xDash) const;
|
||||
|
||||
//- Check maximum table bounds
|
||||
bool checkMaxBounds(const scalar x, scalar& xDash) const;
|
||||
|
||||
//- Convert time
|
||||
virtual void convertTimeBase(const Time& t);
|
||||
|
||||
//- Return Table value
|
||||
virtual Type value(const scalar x) const;
|
||||
|
||||
//- Integrate between two (scalar) values
|
||||
virtual Type integrate(const scalar x1, const scalar x2) const;
|
||||
|
||||
//- Return the reference values
|
||||
virtual tmp<scalarField> x() const;
|
||||
|
||||
//- Return the dependent values
|
||||
virtual tmp<Field<Type>> y() const;
|
||||
|
||||
|
||||
// I/O
|
||||
|
||||
//- Ostream Operator
|
||||
friend Ostream& operator<< <Type>
|
||||
(
|
||||
Ostream& os,
|
||||
const TableBase<Type>& tbl
|
||||
);
|
||||
|
||||
//- Write all table data in dictionary format
|
||||
virtual void writeData(Ostream& os) const;
|
||||
|
||||
//- Write keywords only in dictionary format. Used for non-inline
|
||||
// table types
|
||||
virtual void writeEntries(Ostream& os) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Function1Types
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "TableBase.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,75 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
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 "Function1.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::Ostream& Foam::operator<<
|
||||
(
|
||||
Ostream& os,
|
||||
const Function1Types::TableBase<Type>& tbl
|
||||
)
|
||||
{
|
||||
os << static_cast<const Function1<Type>&>(tbl);
|
||||
os << token::SPACE << tbl.table_;
|
||||
|
||||
// Check state of Ostream
|
||||
os.check
|
||||
(
|
||||
"Ostream& operator<<(Ostream&, const TableBase<Type>&, const bool)"
|
||||
);
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::Function1Types::TableBase<Type>::writeData(Ostream& os) const
|
||||
{
|
||||
Function1<Type>::writeData(os);
|
||||
os << nl << indent << table_ << token::END_STATEMENT << nl;
|
||||
writeEntries(os);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::Function1Types::TableBase<Type>::writeEntries(Ostream& os) const
|
||||
{
|
||||
if (boundsHandling_ != CLAMP)
|
||||
{
|
||||
os.writeKeyword("outOfBounds") << boundsHandlingToWord(boundsHandling_)
|
||||
<< token::END_STATEMENT << nl;
|
||||
}
|
||||
if (interpolationScheme_ != "linear")
|
||||
{
|
||||
os.writeKeyword("interpolationScheme") << interpolationScheme_
|
||||
<< token::END_STATEMENT << nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,79 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
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 "TableFile.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::TableFile<Type>::TableFile
|
||||
(
|
||||
const word& entryName,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
TableBase<Type>(entryName, dict.subDict(entryName + "Coeffs")),
|
||||
fName_("none")
|
||||
{
|
||||
const dictionary coeffs(dict.subDict(entryName + "Coeffs"));
|
||||
coeffs.lookup("fileName") >> fName_;
|
||||
|
||||
fileName expandedFile(fName_);
|
||||
IFstream is(expandedFile.expand());
|
||||
|
||||
if (!is.good())
|
||||
{
|
||||
FatalIOErrorInFunction
|
||||
(
|
||||
is
|
||||
) << "Cannot open file." << exit(FatalIOError);
|
||||
}
|
||||
|
||||
is >> this->table_;
|
||||
|
||||
TableBase<Type>::check();
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::TableFile<Type>::TableFile(const TableFile<Type>& tbl)
|
||||
:
|
||||
TableBase<Type>(tbl),
|
||||
fName_(tbl.fName_)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::TableFile<Type>::~TableFile()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * * * //
|
||||
|
||||
#include "TableFileIO.C"
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,147 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
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::TableFile
|
||||
|
||||
Description
|
||||
Templated table container data entry where data is read from file.
|
||||
|
||||
\verbatim
|
||||
<entryName> tableFile;
|
||||
<entryName>Coeffs
|
||||
{
|
||||
fileName dataFile; // name of data file
|
||||
outOfBounds clamp; // optional out-of-bounds handling
|
||||
interpolationScheme linear; // optional interpolation method
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
Items are stored in a list of Tuple2's. First column is always stored as
|
||||
scalar entries. Data is read in the form, e.g. for an entry \<entryName\>
|
||||
that is (scalar, vector):
|
||||
\verbatim
|
||||
(
|
||||
(0.0 (1 2 3))
|
||||
(1.0 (4 5 6))
|
||||
);
|
||||
\endverbatim
|
||||
|
||||
|
||||
SourceFiles
|
||||
TableFile.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef TableFile_H
|
||||
#define TableFile_H
|
||||
|
||||
#include "Function1.H"
|
||||
#include "Tuple2.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of friend functions and operators
|
||||
namespace Function1Types
|
||||
{
|
||||
template<class Type> class TableFile;
|
||||
};
|
||||
|
||||
template<class Type>
|
||||
Ostream& operator<<(Ostream&, const Function1Types::TableFile<Type>&);
|
||||
|
||||
namespace Function1Types
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class TableFile Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class TableFile
|
||||
:
|
||||
public TableBase<Type>
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- File name for csv table (optional)
|
||||
fileName fName_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const TableFile<Type>&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("tableFile");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from entry name and Istream
|
||||
TableFile(const word& entryName, const dictionary& dict);
|
||||
|
||||
//- Copy constructor
|
||||
TableFile(const TableFile<Type>& tbl);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual tmp<Function1<Type>> clone() const
|
||||
{
|
||||
return tmp<Function1<Type>>(new TableFile<Type>(*this));
|
||||
}
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~TableFile();
|
||||
|
||||
|
||||
// I/O
|
||||
|
||||
//- Write in dictionary format
|
||||
virtual void writeData(Ostream& os) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Function1Types
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "TableFile.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,48 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
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 "Function1.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::Function1Types::TableFile<Type>::writeData(Ostream& os) const
|
||||
{
|
||||
Function1<Type>::writeData(os);
|
||||
|
||||
os << token::END_STATEMENT << nl
|
||||
<< indent << word(this->name() + "Coeffs") << nl
|
||||
<< indent << token::BEGIN_BLOCK << nl << incrIndent;
|
||||
|
||||
// Note: for TableBase write the dictionary entries it needs but not
|
||||
// the values themselves
|
||||
TableBase<Type>::writeEntries(os);
|
||||
|
||||
os.writeKeyword("fileName")<< fName_ << token::END_STATEMENT << nl;
|
||||
os << decrIndent << indent << token::END_BLOCK << endl;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,89 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
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 "Constant.H"
|
||||
#include "PolynomialEntry.H"
|
||||
#include "Sine.H"
|
||||
#include "CSV.H"
|
||||
#include "Table.H"
|
||||
#include "TableFile.H"
|
||||
|
||||
#include "label.H"
|
||||
#include "scalar.H"
|
||||
#include "vector.H"
|
||||
#include "sphericalTensor.H"
|
||||
#include "symmTensor.H"
|
||||
#include "tensor.H"
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
makeFunction1(label);
|
||||
makeFunction1Type(Constant, label);
|
||||
// Polynomial functions and interpolation do evaluate to label
|
||||
// Instead evaluate a scalar and convert to label as appropriate
|
||||
|
||||
makeFunction1(scalar);
|
||||
makeFunction1Type(Constant, scalar);
|
||||
makeFunction1Type(Polynomial, scalar);
|
||||
makeFunction1Type(Sine, scalar);
|
||||
makeFunction1Type(CSV, scalar);
|
||||
makeFunction1Type(Table, scalar);
|
||||
makeFunction1Type(TableFile, scalar);
|
||||
|
||||
makeFunction1(vector);
|
||||
makeFunction1Type(Constant, vector);
|
||||
makeFunction1Type(Polynomial, vector);
|
||||
makeFunction1Type(Sine, vector);
|
||||
makeFunction1Type(CSV, vector);
|
||||
makeFunction1Type(Table, vector);
|
||||
makeFunction1Type(TableFile, vector);
|
||||
|
||||
makeFunction1(sphericalTensor);
|
||||
makeFunction1Type(Constant, sphericalTensor);
|
||||
makeFunction1Type(Polynomial, sphericalTensor);
|
||||
makeFunction1Type(Sine, sphericalTensor);
|
||||
makeFunction1Type(CSV, sphericalTensor);
|
||||
makeFunction1Type(Table, sphericalTensor);
|
||||
makeFunction1Type(TableFile, sphericalTensor);
|
||||
|
||||
makeFunction1(symmTensor);
|
||||
makeFunction1Type(Constant, symmTensor);
|
||||
makeFunction1Type(Polynomial, symmTensor);
|
||||
makeFunction1Type(Sine, symmTensor);
|
||||
makeFunction1Type(CSV, symmTensor);
|
||||
makeFunction1Type(Table, symmTensor);
|
||||
makeFunction1Type(TableFile, symmTensor);
|
||||
|
||||
makeFunction1(tensor);
|
||||
makeFunction1Type(Constant, tensor);
|
||||
makeFunction1Type(Polynomial, tensor);
|
||||
makeFunction1Type(Sine, tensor);
|
||||
makeFunction1Type(CSV, tensor);
|
||||
makeFunction1Type(Table, tensor);
|
||||
makeFunction1Type(TableFile, tensor);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user