From bc4a6ce8dd6c6899643c5639f5f176b64c090d87 Mon Sep 17 00:00:00 2001 From: Yeongdo Park Date: Sun, 4 Nov 2018 13:58:52 -0500 Subject: [PATCH] introduce class GasState --- diffusivityModel/GasState/GasState.C | 130 +++++++++++++ diffusivityModel/GasState/GasState.H | 177 ++++++++++++++++++ diffusivityModel/GasState/GasStateI.H | 100 ++++++++++ diffusivityModel/Make/files | 2 + diffusivityModel/Make/options | 1 + .../diffusivityModel/diffusivityModel.C | 12 +- .../diffusivityModel/diffusivityModel.H | 5 + 7 files changed, 425 insertions(+), 2 deletions(-) create mode 100644 diffusivityModel/GasState/GasState.C create mode 100644 diffusivityModel/GasState/GasState.H create mode 100644 diffusivityModel/GasState/GasStateI.H diff --git a/diffusivityModel/GasState/GasState.C b/diffusivityModel/GasState/GasState.C new file mode 100644 index 0000000..684c232 --- /dev/null +++ b/diffusivityModel/GasState/GasState.C @@ -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 . + +\*---------------------------------------------------------------------------*/ + +#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::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 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 * * * * * * * * * * * * * * // + + +// ************************************************************************* // diff --git a/diffusivityModel/GasState/GasState.H b/diffusivityModel/GasState/GasState.H new file mode 100644 index 0000000..f1b7d39 --- /dev/null +++ b/diffusivityModel/GasState/GasState.H @@ -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 . + +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 &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 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 + +// ************************************************************************* // diff --git a/diffusivityModel/GasState/GasStateI.H b/diffusivityModel/GasState/GasStateI.H new file mode 100644 index 0000000..7b7a7f7 --- /dev/null +++ b/diffusivityModel/GasState/GasStateI.H @@ -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 . + +\*---------------------------------------------------------------------------*/ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// * * * * * * * * * * * * * 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 * * * * * * * * * * * * * // + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + +// ************************************************************************* // diff --git a/diffusivityModel/Make/files b/diffusivityModel/Make/files index 8297da0..2c49ca8 100644 --- a/diffusivityModel/Make/files +++ b/diffusivityModel/Make/files @@ -9,6 +9,8 @@ Coulomb/Coulomb.C N64/N64.C CrossSection/CrossSection.C +GasState/GasState.C + diffusivityModel/diffusivityModel.C LIB = $(FOAM_USER_LIBBIN)/libdiffusivityModel diff --git a/diffusivityModel/Make/options b/diffusivityModel/Make/options index aef5940..6006f0a 100644 --- a/diffusivityModel/Make/options +++ b/diffusivityModel/Make/options @@ -8,6 +8,7 @@ EXE_INC = \ -ICoulomb \ -IN64 \ -ICrossSection \ + -IGasState \ -IdiffusivityModel \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \ diff --git a/diffusivityModel/diffusivityModel/diffusivityModel.C b/diffusivityModel/diffusivityModel/diffusivityModel.C index f5c08f7..16d7594 100644 --- a/diffusivityModel/diffusivityModel/diffusivityModel.C +++ b/diffusivityModel/diffusivityModel/diffusivityModel.C @@ -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::diffusivityModel::thermoData_ = NULL; // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // +const Foam::PtrList &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 diff --git a/diffusivityModel/diffusivityModel/diffusivityModel.H b/diffusivityModel/diffusivityModel/diffusivityModel.H index d310380..e841a3f 100644 --- a/diffusivityModel/diffusivityModel/diffusivityModel.H +++ b/diffusivityModel/diffusivityModel/diffusivityModel.H @@ -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 *thermoData_; + //- Reference to thermo object const psiReactionThermo& thermo_; @@ -151,6 +155,7 @@ public: //- Static data staticData // static const dataType staticData; + static const PtrList &thermoData(); // Constructors