constantThermophysicalFunction: New constant liquid property function

Usage
    \constant
        Property    | Description
        value       | Constant property value
    \endconstant

    Example for the density of water between 280 and 350K
    \verbatim
    rho
    {
        type    constant;
        value   999.87;
    }
    \endverbatim
This commit is contained in:
Henry Weller
2019-11-26 14:50:03 +00:00
parent 7055e0400e
commit bce61e943e
3 changed files with 195 additions and 0 deletions

View File

@ -1,6 +1,7 @@
thermophysicalFunctions/thermophysicalFunction/thermophysicalFunction.C
thermophysicalFunctions/none/noneThermophysicalFunction.C
thermophysicalFunctions/constant/constantThermophysicalFunction.C
thermophysicalFunctions/table/tableThermophysicalFunction.C
thermophysicalFunctions/APIfunctions/APIdiffCoef/APIdiffCoefThermophysicalFunction.C

View File

@ -0,0 +1,80 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2019 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 "constantThermophysicalFunction.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace thermophysicalFunctions
{
defineTypeNameAndDebug(constant, 0);
addToRunTimeSelectionTable(thermophysicalFunction, constant, dictionary);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::thermophysicalFunctions::constant::constant(const dictionary& dict)
:
value_(dict.lookupType<scalar>("value"))
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::scalar Foam::thermophysicalFunctions::constant::f
(
scalar p,
scalar T
) const
{
return value_;
}
void Foam::thermophysicalFunctions::constant::writeData(Ostream& os) const
{
os << value_ << token::SPACE;
}
// * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * * * //
Foam::Ostream& Foam::thermophysicalFunctions::operator<<
(
Ostream& os,
const constant& f
)
{
f.writeData(os);
return os;
}
// ************************************************************************* //

View File

@ -0,0 +1,114 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2019 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::thermophysicalFunctions::constant
Description
Constant property function.
Usage
\constant
Property | Description
value | Constant property value
\endconstant
Example for the density of water between 280 and 350K
\verbatim
rho
{
type constant;
value 999.87;
}
\endverbatim
\*---------------------------------------------------------------------------*/
#ifndef constantThermophysicalFunction_H
#define constantThermophysicalFunction_H
#include "thermophysicalFunction.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace thermophysicalFunctions
{
// Forward declaration of friend functions and operators
class constant;
Ostream& operator<<(Ostream& os, const constant& f);
/*---------------------------------------------------------------------------*\
Class constant Declaration
\*---------------------------------------------------------------------------*/
class constant
:
public thermophysicalFunction
{
// Private member data
//- Constant value
scalar value_;
public:
//- Runtime type information
TypeName("constant");
// Constructors
//- Construct from dictionary
constant(const dictionary& dict);
// Member Functions
//- Evaluate the function and return the result
scalar f(scalar p, scalar T) const;
//- Write the function coefficients
void writeData(Ostream& os) const;
// Ostream Operator
friend Ostream& operator<<(Ostream& os, const constant& f);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace thermophysicalFunctions
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //