From dfc868000cfcf1e873eb0f4415de0c6dc8e8b33a Mon Sep 17 00:00:00 2001 From: ignis Date: Thu, 26 Apr 2018 16:59:21 +0900 Subject: [PATCH] skeletal molecule property input processing --- Make/files | 1 + Make/options | 1 + createFields.H | 2 + diffusivityModel/Particle/Particle.C | 121 +++++++++++++ diffusivityModel/Particle/Particle.H | 167 ++++++++++++++++++ diffusivityModel/Particle/ParticleI.H | 74 ++++++++ .../diffusivityModel/diffusivityModel.C | 66 ++++++- 7 files changed, 425 insertions(+), 7 deletions(-) create mode 100644 diffusivityModel/Particle/Particle.C create mode 100644 diffusivityModel/Particle/Particle.H create mode 100644 diffusivityModel/Particle/ParticleI.H diff --git a/Make/files b/Make/files index 89ea15f..68423ef 100644 --- a/Make/files +++ b/Make/files @@ -1,3 +1,4 @@ +diffusivityModel/Particle/Particle.C diffusivityModel/diffusivityModel/diffusivityModel.C eReactingFoam.C diff --git a/Make/options b/Make/options index 4e4ea18..37cb8d9 100644 --- a/Make/options +++ b/Make/options @@ -1,4 +1,5 @@ EXE_INC = \ + -IdiffusivityModel/Particle \ -IdiffusivityModel/diffusivityModel \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \ diff --git a/createFields.H b/createFields.H index 17da979..da1cfdb 100644 --- a/createFields.H +++ b/createFields.H @@ -125,3 +125,5 @@ volScalarField dQ ); #include "createMRF.H" + +diff.correct(); diff --git a/diffusivityModel/Particle/Particle.C b/diffusivityModel/Particle/Particle.C new file mode 100644 index 0000000..695fb45 --- /dev/null +++ b/diffusivityModel/Particle/Particle.C @@ -0,0 +1,121 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "Particle.H" + +#include "dictionary.H" +#include "scalarList.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +// const dataType Foam::Particle::staticData(); + + +// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + + +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::Particle::Particle(const dictionary& dict) +: + name_(dict["name"]), + W_(readScalar(dict["W"])), + z_(readScalar(dict["z"])) +{ + label geometry (dict.lookupOrDefault("geometry", 0)); + + const entry* entryPtr = dict.lookupEntryPtr("tranlib", false, true); + + if (entryPtr) + { + scalarList tranlib(entryPtr->stream()); + geometry = tranlib[0]; + } + + switch(geometry) + { + case 0: + geometry_ = Geometry::ATOM; + break; + case 1: + geometry_ = Geometry::LINEAR; + break; + case 2: + geometry_ = Geometry::NONLINEAR; + break; + default: + FatalErrorInFunction + << "Illegal molecule geometry type. 0, 1 and 2 are allowed." + << abort(FatalError); + } + +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::Particle::~Particle() +{} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + + +// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * // + +void Foam::Particle::operator=(const Particle& rhs) +{ + // Check for assignment to self + if (this == &rhs) + { + FatalErrorInFunction + << "Attempted assignment to self" + << abort(FatalError); + } +} + +// * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * * // + + +// * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * * // + +Foam::Ostream& Foam::operator<<(Ostream& os, const Particle& st) +{ + os << st.name_ << tab + << st.W_ << tab + << st.z_ << tab + << st.geometry_; + + os.check("Ostream& operator<<(Ostream& os, const specie& st)"); + return os; +} + +// ************************************************************************* // diff --git a/diffusivityModel/Particle/Particle.H b/diffusivityModel/Particle/Particle.H new file mode 100644 index 0000000..6a13ea2 --- /dev/null +++ b/diffusivityModel/Particle/Particle.H @@ -0,0 +1,167 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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::Particle + +Description + +SourceFiles + ParticleI.H + Particle.C + ParticleIO.C + +\*---------------------------------------------------------------------------*/ + +#ifndef Particle_H +#define Particle_H + +#include "word.H" +#include "scalar.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of classes +class Istream; +class Ostream; +class dictionary; + +// Forward declaration of friend functions and operators +class Particle; +Istream& operator>>(Istream&, Particle&); +Ostream& operator<<(Ostream&, const Particle&); + + +/*---------------------------------------------------------------------------*\ + Class Particle Declaration +\*---------------------------------------------------------------------------*/ + +class Particle +{ + +public: + + //- Enumeration defining the particle geometry + enum Geometry + { + ATOM = 0, + LINEAR = 1, + NONLINEAR = 2 + }; + + +protected: + + // Private data + + //- Species name + word name_; + + //- Molecular weight [kg / kmol] + scalar W_; + + //- Number of elementary charges + scalar z_; + + //- Geometry + Geometry geometry_; + + + // Private Member Functions + + //- Disallow default bitwise copy construct + Particle(const Particle&); + + //- Disallow default bitwise assignment + void operator=(const Particle&); + + +public: + + // Static data members + + + // Constructors + + //- Construct from components + Particle(const dictionary& dict); + + //- Construct from Istream + Particle(Istream&); + + //- Construct as copy + // Particle(const Particle&); + + + //- Destructor + ~Particle(); + + + // Member Functions + + // Access + inline const word& name(); + + inline scalar W(); + + inline scalar z(); + + // Check + + // Edit + + // Write + + + // Member Operators + + // void operator=(const Particle&); + + + // Friend Functions + + // Friend Operators + + // IOstream Operators + + friend Istream& operator>>(Istream&, Particle&); + friend Ostream& operator<<(Ostream&, const Particle&); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "ParticleI.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/diffusivityModel/Particle/ParticleI.H b/diffusivityModel/Particle/ParticleI.H new file mode 100644 index 0000000..e3efb32 --- /dev/null +++ b/diffusivityModel/Particle/ParticleI.H @@ -0,0 +1,74 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 const Foam::word& Foam::Particle::name() +{ + return name_; +} + + +inline Foam::scalar Foam::Particle::W() +{ + return W_; +} + + +inline Foam::scalar Foam::Particle::z() +{ + return z_; +} + +// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // + + +// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * // + + +// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // + + +// * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * * // + + +// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * // + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + +// ************************************************************************* // diff --git a/diffusivityModel/diffusivityModel/diffusivityModel.C b/diffusivityModel/diffusivityModel/diffusivityModel.C index 7a10f3b..a808785 100644 --- a/diffusivityModel/diffusivityModel/diffusivityModel.C +++ b/diffusivityModel/diffusivityModel/diffusivityModel.C @@ -29,6 +29,7 @@ License #include "speciesTable.H" #include "volFieldsFwd.H" #include "scalarMatrices.H" +#include "Particle.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -64,15 +65,58 @@ Foam::diffusivityModel::diffusivityModel(const psiReactionThermo& thermo) )() ); + Switch readIons = false; + Switch readNeutrals = false; forAll(species_, i) { - // transports[species_[i]]; - Info << species_[i] << endl; - Info << thermo_.composition().W(i) << endl; - Info << thermo_.composition().Qc(i) << endl; - Info << thermo_.composition().z(i) << endl; - Info << readScalar(transports.subDict(species_[i]).subDict("transport")["As"]) << endl; + const word namei(species_[i]); + const label Wi = thermo_.composition().W(i); + const label zi = thermo_.composition().z(i); + + dictionary tranDict(transports.subDict(species_[i]).subDict("transport")); + tranDict.add("name", namei); + tranDict.add("W", Wi); + tranDict.add("z", zi); + + Particle p(tranDict); + + Info << tranDict << endl; + Info << p << endl; + Info << scalarList(tranDict["tranlib"]) << endl; + + // Electron + if (species_[i] == "E-") + { + if (readIons || readNeutrals) + { + FatalErrorInFunction + << "Electron should be the first species in the list" + << abort(FatalError); + } + // new Electron (tranDict); + } + // Ions + else if (zi != 0) + { + if (readNeutrals) + { + FatalErrorInFunction + << "Ions should be listed before any neutrals" + << abort(FatalError); + } + + readIons = true; + + // new Ion (tranDict); + } + // Neutrals + else + { + readNeutrals = true; + + // new Neutral (tranDict); + } } /* */ @@ -132,10 +176,16 @@ void Foam::diffusivityModel::correct() scalarSymmetricSquareMatrix Dij(species_.size()); - forAll (species_, celli) + forAll (p, celli) { const scalar pi = p[celli]; const scalar Ti = T[celli]; + scalarField Yi(species_.size()); + + forAll (species_, i) + { + Yi[i] = thermo_.composition().Y(i)[celli]; + } label idx = 0; @@ -153,6 +203,8 @@ void Foam::diffusivityModel::correct() // DMat = 0; } + + Info << Yi << endl; } return;