class FlameStructure for read initial CMC flame structure

This commit is contained in:
ignis 2017-08-31 18:59:15 +09:00
parent b1a36355a3
commit 7b6c05c25c
7 changed files with 649 additions and 2 deletions

View file

@ -0,0 +1,265 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "FlameStructure.H"
#include "IFstream.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
// const Foam::CMC::dataType Foam::CMC::FlameStructure::staticData();
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::CMC::FlameStructure::FlameStructure(word fileName)
:
names_(),
Y_(),
W_(),
T_(),
Q_(),
h_(),
rho_(),
Rgas_()
{
IFstream slfmFile (fileName);
word garbage;
word yname;
// number of eta grids and species
label nEta(0);
label nY(0);
slfmFile.getLine(garbage); //INPUT FILE FOR THE SR-CMC ROUTINES
slfmFile.getLine(garbage); //No.GRID POINTS No. SPECIES
slfmFile >> nEta >> nY;
Y_.setSize(nY);
W_.setSize(nY);
eta_.setSize(nEta);
T_.setSize(nEta);
Q_.setSize(nEta);
h_.setSize(nEta);
rho_.setSize(nEta);
Rgas_.setSize(nEta);
slfmFile.getLine(garbage); //blank line (trailing white spaces)
slfmFile.getLine(garbage); //PRESSURE(ATM)
slfmFile.getLine(garbage); //1.0
slfmFile.getLine(garbage); //MIXTURE FRACTION GRID
scalarField YTemp(nEta,0);
scalarField WTemp(nEta,0);
for(label j=0 ; j<nEta ; j++)
{
slfmFile >> eta_[j];
}
slfmFile.getLine(garbage); //blank line (trailing white spaces)
slfmFile.getLine(garbage); //INITIAL CONDITIONS
for(label i=0; i<nY ; i++)
{
//species name
slfmFile >> yname;
names_.append(yname);
//species mass fractions
for(label j=0 ; j<nEta ; j++)
{
slfmFile >> YTemp[j];
}
Y_.set(i, new scalarField(YTemp));
//species production rates
for(label j=0 ; j<nEta ; j++)
{
slfmFile >> WTemp[j];
}
W_.set(i, new scalarField(WTemp));
slfmFile.getLine(garbage); //blank line (trailing white spaces)
}
//read temperature
slfmFile >> yname;
for(label j=0 ; j<nEta ; j++)
{
slfmFile >> T_[j];
T_[j] = max(0.0, T_[j]);
}
for(label j=0 ; j<nEta ; j++)
{
slfmFile >> Q_[j];
}
/*
// calcuate rather than read
//read density
slfmFile >> yname;
for(label j=0 ; j<nEta ; j++)
{
slfmFile >> rho_[j];
}
//read enthalpy
slfmFile >> yname;
for(label j=0 ; j<nEta ; j++)
{
slfmFile >> Rgas_[j];
}
*/
/*
Interpolation(etaValue, eta, 1, nY+1, yi_temp, yi);
for(label j = 0 ; j<=etamax ; j++)
{
for(label i = 0 ; i<Ysize ; i++)
{
QiCMC[j*Ysize+i] = yi[j*(nY+1)+i];
}
TCMC[j] = yi[j*(nY+1)+nY];
}
for(label k=1 ; k<nf ; k++)
{
for(label j = 0 ; j<=etamax ; j++)
{
for(label i = 0 ; i<Ysize ; i++)
{
QiCMC[(k*(etamax+1)+j)*Ysize+i] = QiCMC[j*Ysize+i];
}
TCMC[j+k*(etamax+1)] = TCMC[j];
}
}
for(label j=0 ; j <= etamax ; j++) //get conditional enthalpy
{
for(label k = 0 ; k<nf ; k++)
{
scalar Tin = TCMC[ j+k*(etamax+1) ];
scalarField QiCMCin(Ysize, 0);
for(label i=0 ; i<Ysize ; i++)
{
QiCMCin[i] = QiCMC[(k*(etamax+1)+j)*Ysize + i];
}
rhoCMC[j+k*(etamax+1)] = chemistry->calculateRHOCMC(QiCMCin , Tin, Pin);
QhCMC[j+k*(etamax+1)] = chemistry->calculateHCMC(QiCMCin , Tin, rhoCMC[ j+k*(etamax+1)], Pin);
}
}
*/
}
Foam::CMC::FlameStructure::FlameStructure(const FlameStructure&)
// :
// baseClassName(),
// data_()
{}
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
/*
Foam::autoPtr<Foam::CMC::FlameStructure>
Foam::CMC::FlameStructure::New()
{
return autoPtr<FlameStructure>(new FlameStructure);
}
*/
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::CMC::FlameStructure::~FlameStructure()
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
void Foam::CMC::FlameStructure::operator=(const FlameStructure& 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,242 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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::CMC::FlameStructure
Description
SourceFiles
FlameStructureI.H
FlameStructure.C
FlameStructureIO.C
\*---------------------------------------------------------------------------*/
#ifndef FlameStructure_H
#define FlameStructure_H
#include "scalarField.H"
#include "hashedWordList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class Istream;
class Ostream;
namespace CMC
{
class FlameStructure;
}
// Forward declaration of friend functions and operators
Istream& operator>>(Istream&, CMC::FlameStructure&);
Ostream& operator<<(Ostream&, const CMC::FlameStructure&);
namespace CMC
{
/*---------------------------------------------------------------------------*\
Class FlameStructure Declaration
\*---------------------------------------------------------------------------*/
class FlameStructure
{
// Private data
//- Mixture fraction grid
scalarField eta_;
//- Species name table
hashedWordList names_;
//- Species mass fraction
PtrList<scalarField> Y_;
// scalarFieldArray2d Y_;
//- Species production rate
PtrList<scalarField> W_;
//scalarFieldArray2d W_;
//- Temperature
scalarField T_;
//- Heat source
scalarField Q_;
//- Enthalpy
scalarField h_;
//- Density
scalarField rho_;
//- Specific gas constant for mean W
scalarField Rgas_;
// Private Member Functions
//- Disallow Construct null
FlameStructure();
//- Disallow default bitwise copy construct
FlameStructure(const FlameStructure&);
//- Disallow default bitwise assignment
void operator=(const FlameStructure&);
//- limit value of alpha and beta
void limitAB();
public:
// Static data members
//- Static data staticData
// static const dataType staticData;
// Constructors
//- Construct from components
FlameStructure(word fileName);
//- Construct from Istream
FlameStructure(Istream&);
//- Construct as copy
// FlameStructure(const FlameStructure&);
// Selectors
//- Select null constructed
// static autoPtr<FlameStructure> New();
//- Destructor
~FlameStructure();
// Member Functions
// Access
//- Select null constructed
scalarField& eta() {return eta_;}
//- Select null constructed
hashedWordList& names() {return names_;}
//- Select null constructed
PtrList<scalarField>& Y() {return Y_;}
//- Select null constructed
PtrList<scalarField>& W() {return W_;}
//- Select null constructed
scalarField& T() {return T_;}
//- Select null constructed
scalarField& Q() {return Q_;}
//- Select null constructed
scalarField& rho() {return rho_;}
//- Select null constructed
scalarField& h() {return h_;}
//- Select null constructed
scalarField& Rgas() {return Rgas_;}
//- Select null constructed
const scalarField& eta() const {return eta_;}
//- Select null constructed
const hashedWordList& names() const {return names_;}
//- Select null constructed
const PtrList<scalarField>& Y() const {return Y_;}
//- Select null constructed
const PtrList<scalarField>& W() const {return W_;}
//- Select null constructed
const scalarField& T() const {return T_;}
//- Select null constructed
const scalarField& Q() const {return Q_;}
//- Select null constructed
const scalarField& rho() const {return rho_;}
//- Select null constructed
const scalarField& h() const {return h_;}
//- Select null constructed
const scalarField& Rgas() const {return Rgas_;}
/*
*/
// Check
// Edit
// Write
// Member Operators
// void operator=(const FlameStructure&);
// Friend Functions
// Friend Operators
// IOstream Operators
friend Istream& ::Foam::operator>>(Istream&, FlameStructure&);
friend Ostream& ::Foam::operator<<(Ostream&, const FlameStructure&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace CMC
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "FlameStructureI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,58 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// ************************************************************************* //

View file

@ -0,0 +1,79 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "FlameStructure.H"
#include "IOstreams.H"
#include "error.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::CMC::FlameStructure::FlameStructure(Istream& is)
/*
:
base1(is),
base2(is),
member1(is),
member2(is)
*/
{
// Check state of Istream
is.check("Foam::CMC::FlameStructure::FlameStructure(Foam::Istream&)");
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
Foam::Istream& Foam::operator>>(Istream& is, CMC::FlameStructure&)
{
// Check state of Istream
is.check
(
"Foam::Istream& Foam::operator>>(Foam::Istream&, Foam::CMC::FlameStructure&)"
);
return is;
}
Foam::Ostream& Foam::operator<<(Ostream& os, const CMC::FlameStructure& fs)
{
// Check state of Ostream
os.check
(
"Foam::Ostream& Foam::operator<<(Foam::Ostream&, "
"const Foam::CMC::FlameStructure&)"
);
os << fs.names()
<< fs.eta()
<< fs.Y()
<< fs.T()
<< endl;
return os;
}
// ************************************************************************* //

View file

@ -51,6 +51,8 @@ Contact
#include "LinearMesh.H"
#include "../FlameStructure/FlameStructure.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])

View file

@ -1,3 +1,5 @@
../FlameStructure/FlameStructure.C
../FlameStructure/FlameStructureIO.C
LagrangianCMCFoam.C
EXE = $(FOAM_USER_APPBIN)/LagrangianCMCFoam

View file

@ -1,4 +1,5 @@
IFstream slfmFile (SLFMinit);
CMC::FlameStructure test (SLFMinit);
word garbage, yname;
scalar neta(0), ny(0);
@ -26,7 +27,6 @@ slfmFile.getLine(garbage); //INITIAL
for(label i=0; i<ny ; i++) //species
{
slfmFile>>yname;
Info<<yname<<endl;
for(label j=0 ; j<neta ; j++)
{
slfmFile>>yi_temp[j*(ny+1)+i];
@ -41,7 +41,6 @@ for(label i=0; i<ny ; i++) //species
//Temperature
slfmFile>>yname;
Info<<yname<<endl;
for(label j=0 ; j<neta ; j++)
{
slfmFile>>yi_temp[j*(ny+1)+ny];