diff --git a/src/lagrangian/intermediate/Make/files b/src/lagrangian/intermediate/Make/files index 8ba5b4e0a086f108a2493c5b08b847a4bd64551c..bc6b095488a15c7e12415736a91846a22ba1ff8e 100644 --- a/src/lagrangian/intermediate/Make/files +++ b/src/lagrangian/intermediate/Make/files @@ -79,6 +79,6 @@ evaporationProperties/evaporationProperties/evaporationPropertiesIO.C /* data entries */ submodels/IO/DataEntry/makeDataEntries.C - +submodels/IO/DataEntry/polynomial/polynomial.C LIB = $(FOAM_LIBBIN)/liblagrangianIntermediate diff --git a/src/lagrangian/intermediate/submodels/IO/DataEntry/Constant/ConstantIO.C b/src/lagrangian/intermediate/submodels/IO/DataEntry/Constant/ConstantIO.C index 51212f9dbc3d58322a5a870f2ae318a62f26aecd..93e92a25880691cff4e488623c170a8374786270 100644 --- a/src/lagrangian/intermediate/submodels/IO/DataEntry/Constant/ConstantIO.C +++ b/src/lagrangian/intermediate/submodels/IO/DataEntry/Constant/ConstantIO.C @@ -32,21 +32,21 @@ template<class Type> Foam::Ostream& Foam::operator<< ( Ostream& os, - const Constant<Type>& de + const Constant<Type>& cnst ) { if (os.format() == IOstream::ASCII) { - os << static_cast<const DataEntry<Type>& >(de) - << token::SPACE << de.value_; + os << static_cast<const DataEntry<Type>& >(cnst) + << token::SPACE << cnst.value_; } else { - os << static_cast<const DataEntry<Type>& >(de); + os << static_cast<const DataEntry<Type>& >(cnst); os.write ( - reinterpret_cast<const char*>(&de.value_), - sizeof(de.value_) + reinterpret_cast<const char*>(&cnst.value_), + sizeof(cnst.value_) ); } diff --git a/src/lagrangian/intermediate/submodels/IO/DataEntry/Table/Table.H b/src/lagrangian/intermediate/submodels/IO/DataEntry/Table/Table.H index f96c79a816fd0b74a28b403ced51e60fed08572a..2bd1152bf4ce27ff37630c54c4083d4bb3a38953 100644 --- a/src/lagrangian/intermediate/submodels/IO/DataEntry/Table/Table.H +++ b/src/lagrangian/intermediate/submodels/IO/DataEntry/Table/Table.H @@ -75,8 +75,8 @@ class Table { // Private data - //- Table data - List<Tuple2<scalar, Type> > table_; + //- Table data + List<Tuple2<scalar, Type> > table_; // Private Member Functions diff --git a/src/lagrangian/intermediate/submodels/IO/DataEntry/Table/TableIO.C b/src/lagrangian/intermediate/submodels/IO/DataEntry/Table/TableIO.C index 8ee842c4c3fcb9d055dff0f75729677a143d3a44..dda24c362aa97abe5f4bb38ec0f72747711a6758 100644 --- a/src/lagrangian/intermediate/submodels/IO/DataEntry/Table/TableIO.C +++ b/src/lagrangian/intermediate/submodels/IO/DataEntry/Table/TableIO.C @@ -32,21 +32,21 @@ template<class Type> Foam::Ostream& Foam::operator<< ( Ostream& os, - const Table<Type>& de + const Table<Type>& tbl ) { if (os.format() == IOstream::ASCII) { - os << static_cast<const DataEntry<Type>& >(de) - << token::SPACE << de.table_; + os << static_cast<const DataEntry<Type>& >(tbl) + << token::SPACE << tbl.table_; } else { - os << static_cast<const DataEntry<Type>& >(de); + os << static_cast<const DataEntry<Type>& >(tbl); os.write ( - reinterpret_cast<const char*>(&de.table_), - sizeof(de.table_) + reinterpret_cast<const char*>(&tbl.table_), + sizeof(tbl.table_) ); } diff --git a/src/lagrangian/intermediate/submodels/IO/DataEntry/polynomial/polynomial.C b/src/lagrangian/intermediate/submodels/IO/DataEntry/polynomial/polynomial.C new file mode 100644 index 0000000000000000000000000000000000000000..56101256e0a374c04b0c5999067e23684740ba7c --- /dev/null +++ b/src/lagrangian/intermediate/submodels/IO/DataEntry/polynomial/polynomial.C @@ -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; +} + + +// ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/IO/DataEntry/polynomial/polynomial.H b/src/lagrangian/intermediate/submodels/IO/DataEntry/polynomial/polynomial.H new file mode 100644 index 0000000000000000000000000000000000000000..3787cf69ace2cab17f1805475c09ebb1992e63b4 --- /dev/null +++ b/src/lagrangian/intermediate/submodels/IO/DataEntry/polynomial/polynomial.H @@ -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 + +// ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/IO/DataEntry/polynomial/polynomialIO.C b/src/lagrangian/intermediate/submodels/IO/DataEntry/polynomial/polynomialIO.C new file mode 100644 index 0000000000000000000000000000000000000000..05c34b645fc696abd1a6ed7c82e27683a9175508 --- /dev/null +++ b/src/lagrangian/intermediate/submodels/IO/DataEntry/polynomial/polynomialIO.C @@ -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; +} + + +// ************************************************************************* //