mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Data entry updates + new polynomial type
This commit is contained in:
@ -79,6 +79,6 @@ evaporationProperties/evaporationProperties/evaporationPropertiesIO.C
|
|||||||
|
|
||||||
/* data entries */
|
/* data entries */
|
||||||
submodels/IO/DataEntry/makeDataEntries.C
|
submodels/IO/DataEntry/makeDataEntries.C
|
||||||
|
submodels/IO/DataEntry/polynomial/polynomial.C
|
||||||
|
|
||||||
LIB = $(FOAM_LIBBIN)/liblagrangianIntermediate
|
LIB = $(FOAM_LIBBIN)/liblagrangianIntermediate
|
||||||
|
|||||||
@ -32,21 +32,21 @@ template<class Type>
|
|||||||
Foam::Ostream& Foam::operator<<
|
Foam::Ostream& Foam::operator<<
|
||||||
(
|
(
|
||||||
Ostream& os,
|
Ostream& os,
|
||||||
const Constant<Type>& de
|
const Constant<Type>& cnst
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (os.format() == IOstream::ASCII)
|
if (os.format() == IOstream::ASCII)
|
||||||
{
|
{
|
||||||
os << static_cast<const DataEntry<Type>& >(de)
|
os << static_cast<const DataEntry<Type>& >(cnst)
|
||||||
<< token::SPACE << de.value_;
|
<< token::SPACE << cnst.value_;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
os << static_cast<const DataEntry<Type>& >(de);
|
os << static_cast<const DataEntry<Type>& >(cnst);
|
||||||
os.write
|
os.write
|
||||||
(
|
(
|
||||||
reinterpret_cast<const char*>(&de.value_),
|
reinterpret_cast<const char*>(&cnst.value_),
|
||||||
sizeof(de.value_)
|
sizeof(cnst.value_)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -75,8 +75,8 @@ class Table
|
|||||||
{
|
{
|
||||||
// Private data
|
// Private data
|
||||||
|
|
||||||
//- Table data
|
//- Table data
|
||||||
List<Tuple2<scalar, Type> > table_;
|
List<Tuple2<scalar, Type> > table_;
|
||||||
|
|
||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|||||||
@ -32,21 +32,21 @@ template<class Type>
|
|||||||
Foam::Ostream& Foam::operator<<
|
Foam::Ostream& Foam::operator<<
|
||||||
(
|
(
|
||||||
Ostream& os,
|
Ostream& os,
|
||||||
const Table<Type>& de
|
const Table<Type>& tbl
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (os.format() == IOstream::ASCII)
|
if (os.format() == IOstream::ASCII)
|
||||||
{
|
{
|
||||||
os << static_cast<const DataEntry<Type>& >(de)
|
os << static_cast<const DataEntry<Type>& >(tbl)
|
||||||
<< token::SPACE << de.table_;
|
<< token::SPACE << tbl.table_;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
os << static_cast<const DataEntry<Type>& >(de);
|
os << static_cast<const DataEntry<Type>& >(tbl);
|
||||||
os.write
|
os.write
|
||||||
(
|
(
|
||||||
reinterpret_cast<const char*>(&de.table_),
|
reinterpret_cast<const char*>(&tbl.table_),
|
||||||
sizeof(de.table_)
|
sizeof(tbl.table_)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,90 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||||
|
\\/ 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 2 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, write to the Free Software Foundation,
|
||||||
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "polynomial.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::polynomial::polynomial(const word& entryName, Istream& is)
|
||||||
|
:
|
||||||
|
DataEntry<scalar>(entryName),
|
||||||
|
coeffs_(is)
|
||||||
|
{
|
||||||
|
if (!coeffs_.size())
|
||||||
|
{
|
||||||
|
FatalErrorIn("Foam::polynomial::polynomial(const word&, Istream&)")
|
||||||
|
<< "polynomial coefficients for entry " << this->name_
|
||||||
|
<< " is invalid (empty)" << nl << exit(FatalError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::polynomial::polynomial(const polynomial& poly)
|
||||||
|
:
|
||||||
|
DataEntry<scalar>(poly),
|
||||||
|
coeffs_(poly.coeffs_)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::polynomial::~polynomial()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::scalar Foam::polynomial::value(const scalar x) const
|
||||||
|
{
|
||||||
|
scalar y = 0.0;
|
||||||
|
forAll(coeffs_, i)
|
||||||
|
{
|
||||||
|
y += coeffs_[i].first()*pow(x, coeffs_[i].second());
|
||||||
|
}
|
||||||
|
|
||||||
|
return y;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::scalar Foam::polynomial::integrate(const scalar x1, const scalar x2) const
|
||||||
|
{
|
||||||
|
scalar intx = 0.0;
|
||||||
|
|
||||||
|
forAll(coeffs_, i)
|
||||||
|
{
|
||||||
|
intx +=
|
||||||
|
coeffs_[i].first()/(coeffs_[i].second() + 1)
|
||||||
|
*(
|
||||||
|
pow(x2, coeffs_[i].second() + 1)
|
||||||
|
- pow(x1, coeffs_[i].second() + 1)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return intx;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,130 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||||
|
\\/ 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 2 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, write to the Free Software Foundation,
|
||||||
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::polynomial
|
||||||
|
|
||||||
|
Description
|
||||||
|
Templated polynomial container data entry. 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
|
||||||
|
polynomial.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef polynomial_H
|
||||||
|
#define polynomial_H
|
||||||
|
|
||||||
|
#include "DataEntry.H"
|
||||||
|
#include "Tuple2.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
class polynomial;
|
||||||
|
|
||||||
|
Ostream& operator<<
|
||||||
|
(
|
||||||
|
Ostream&,
|
||||||
|
const polynomial&
|
||||||
|
);
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class polynomial Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class polynomial
|
||||||
|
:
|
||||||
|
public DataEntry<scalar>
|
||||||
|
{
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- Polynomial coefficients - list of prefactor, exponent
|
||||||
|
List<Tuple2<scalar, scalar> > coeffs_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Disallow default bitwise assignment
|
||||||
|
void operator=(const polynomial&);
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("polynomial");
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from entry name and Istream
|
||||||
|
polynomial(const word& entryName, Istream& is);
|
||||||
|
|
||||||
|
//- Copy constructor
|
||||||
|
polynomial(const polynomial& poly);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~polynomial();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
//- Return polynomial value
|
||||||
|
scalar value(const scalar x) const;
|
||||||
|
|
||||||
|
//- Integrate between two (scalar) values
|
||||||
|
scalar integrate(const scalar x1, const scalar x2) const;
|
||||||
|
|
||||||
|
|
||||||
|
//- Ostream Operator
|
||||||
|
friend Ostream& operator<<
|
||||||
|
(
|
||||||
|
Ostream&,
|
||||||
|
const polynomial&
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,62 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||||
|
\\/ 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 2 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, write to the Free Software Foundation,
|
||||||
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "polynomial.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::Ostream& Foam::operator<<
|
||||||
|
(
|
||||||
|
Ostream& os,
|
||||||
|
const polynomial& poly
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (os.format() == IOstream::ASCII)
|
||||||
|
{
|
||||||
|
os << static_cast<const DataEntry<scalar>& >(poly)
|
||||||
|
<< token::SPACE << poly.coeffs_;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
os << static_cast<const DataEntry<scalar>& >(poly);
|
||||||
|
os.write
|
||||||
|
(
|
||||||
|
reinterpret_cast<const char*>(&poly.coeffs_),
|
||||||
|
sizeof(poly.coeffs_)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check state of Ostream
|
||||||
|
os.check
|
||||||
|
(
|
||||||
|
"Ostream& operator<<(Ostream&, const polynomial&)"
|
||||||
|
);
|
||||||
|
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
Reference in New Issue
Block a user