introduce class GasState

This commit is contained in:
Yeongdo Park 2018-11-04 13:58:52 -05:00
parent 1f98596435
commit bc4a6ce8dd
7 changed files with 425 additions and 2 deletions

View file

@ -0,0 +1,130 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "GasState.H"
#include "diffusivityModel.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
// const dataType Foam::GasState::staticData();
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
inline const Foam::PtrList<Foam::GasState::thermoType> &Foam::GasState::thermos()
{
return diffusivityModel::thermoData();
}
inline const Foam::GasState::thermoType &Foam::GasState::thermos(label i)
{
return thermos()[i];
}
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::GasState::GasState(const scalar p, const scalar T, const label n)
:
p_(p),
T_(T),
Y_(n, 0.0)
{
Y_[0] = 1.0;
}
Foam::GasState::GasState(const scalar p, const scalar T, const scalarField &Y)
:
p_(p),
T_(T),
Y_(Y)
{
scalar sumY = Foam::sum(Y_);
Y_ /= sumY;
}
Foam::GasState::GasState(const scalar p, const scalar T, tmp<scalarField> Y)
:
p_(p),
T_(T),
Y_(Y)
{
scalar sumY = Foam::sum(Y_);
Y_ /= sumY;
}
Foam::GasState::GasState(const GasState& state)
:
p_(state.p_),
T_(state.T_),
Y_(state.Y_)
{}
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::GasState::~GasState()
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
void Foam::GasState::operator=(const GasState& rhs)
{
// Check for assignment to self
if (this == &rhs)
{
FatalErrorInFunction
<< "Attempted assignment to self"
<< abort(FatalError);
}
}
// * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * * //
// ************************************************************************* //

View file

@ -0,0 +1,177 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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::GasState
Description
SourceFiles
GasStateI.H
GasState.C
GasStateIO.C
\*---------------------------------------------------------------------------*/
#ifndef GasState_H
#define GasState_H
#include "thermoPhysicsTypes.H"
#include "scalarField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class Istream;
class Ostream;
// Forward declaration of friend functions and operators
class GasState;
Istream& operator>>(Istream&, GasState&);
Ostream& operator<<(Ostream&, const GasState&);
/*---------------------------------------------------------------------------*\
Class GasState Declaration
\*---------------------------------------------------------------------------*/
class GasState
{
public:
// Data type
typedef gasHThermoPhysics thermoType;
private:
// Private data
//- Description of data_
scalar p_;
//- Description of data_
scalar T_;
//- Description of data_
scalarField Y_;
// Private Member Functions
//- Disallow default bitwise copy construct
GasState(const GasState&);
//- Disallow default bitwise assignment
void operator=(const GasState&);
//- Static data staticData
inline const PtrList<thermoType> &thermos();
inline const thermoType &thermos(label i);
public:
// Static data members
//- Static data staticData
// static const dataType staticData;
// Constructors
//- Construct null
GasState();
//- Construct from components
GasState(const scalar p, const scalar T, const label n);
GasState(const scalar p, const scalar T, const scalarField &Y);
GasState(const scalar p, const scalar T, tmp<scalarField> Y);
//- Construct from Istream
GasState(Istream&);
//- Construct as copy
//- Destructor
~GasState();
// Member Functions
// Access
inline scalar T() const;
inline scalar &T();
inline scalar p() const;
inline scalar &p();
inline scalar Y(label i) const;
inline const scalarField &Y() const;
inline scalarField &Y();
// Check
// Edit
// Write
// Member Operators
// Friend Functions
// Friend Operators
// IOstream Operators
friend Istream& operator>>(Istream&, GasState&);
friend Ostream& operator<<(Ostream&, const GasState&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "GasStateI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,100 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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/>.
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline Foam::scalar Foam::GasState::T() const
{
return T_;
}
inline Foam::scalar &Foam::GasState::T()
{
return T_;
}
inline Foam::scalar Foam::GasState::p() const
{
return p_;
}
inline Foam::scalar &Foam::GasState::p()
{
return p_;
}
inline Foam::scalar Foam::GasState::Y(label i) const
{
return Y_[i];
}
inline const Foam::scalarField &Foam::GasState::Y() const
{
return Y_;
}
inline Foam::scalarField &Foam::GasState::Y()
{
return Y_;
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// ************************************************************************* //

View file

@ -9,6 +9,8 @@ Coulomb/Coulomb.C
N64/N64.C
CrossSection/CrossSection.C
GasState/GasState.C
diffusivityModel/diffusivityModel.C
LIB = $(FOAM_USER_LIBBIN)/libdiffusivityModel

View file

@ -8,6 +8,7 @@ EXE_INC = \
-ICoulomb \
-IN64 \
-ICrossSection \
-IGasState \
-IdiffusivityModel \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \

View file

@ -30,7 +30,6 @@ License
#include "volFieldsFwd.H"
#include "scalarMatrices.H"
#include "multiComponentMixture.H"
#include "thermoPhysicsTypes.H"
#include "Particle.H"
#include "Electron.H"
@ -43,11 +42,15 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
// const dataType Foam::diffusivityModel::staticData();
const Foam::PtrList<Foam::gasHThermoPhysics> *Foam::diffusivityModel::thermoData_ = NULL;
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
const Foam::PtrList<Foam::gasHThermoPhysics> &Foam::diffusivityModel::thermoData()
{
return *thermoData_;
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -410,6 +413,11 @@ Foam::diffusivityModel::diffusivityModel(const psiReactionThermo& thermo)
const volScalarField::Mesh &mesh = thermo_.composition().Y(0).mesh();
if (thermoData_ == NULL)
{
thermoData_ = &(mcm.speciesData());
}
dictionary transports
(
IFstream

View file

@ -39,6 +39,7 @@ SourceFiles
#include "scalar.H"
#include "autoPtr.H"
#include "psiReactionThermo.H"
#include "thermoPhysicsTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -66,6 +67,9 @@ class diffusivityModel
{
// Private data
//- Static data staticData
static const PtrList<gasHThermoPhysics> *thermoData_;
//- Reference to thermo object
const psiReactionThermo& thermo_;
@ -151,6 +155,7 @@ public:
//- Static data staticData
// static const dataType staticData;
static const PtrList<gasHThermoPhysics> &thermoData();
// Constructors