mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
chemkinToFoam: Added support for converting elements and species composition
Based of patch contributed by Francesco Contino, Tommaso Lucchini, Gianluca D’Errico, Hervé Jeanmart, Nicolas Bourgeois and Stéphane Backaert.
This commit is contained in:
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -33,6 +33,8 @@ Description
|
|||||||
#include "argList.H"
|
#include "argList.H"
|
||||||
#include "chemkinReader.H"
|
#include "chemkinReader.H"
|
||||||
#include "OFstream.H"
|
#include "OFstream.H"
|
||||||
|
#include "OStringStream.H"
|
||||||
|
#include "IStringStream.H"
|
||||||
|
|
||||||
using namespace Foam;
|
using namespace Foam;
|
||||||
|
|
||||||
@ -60,15 +62,42 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
chemkinReader cr(species, args[1], args[3], args[2], newFormat);
|
chemkinReader cr(species, args[1], args[3], args[2], newFormat);
|
||||||
|
|
||||||
|
|
||||||
OFstream reactionsFile(args[4]);
|
OFstream reactionsFile(args[4]);
|
||||||
|
reactionsFile
|
||||||
|
<< "elements" << cr.elementNames() << token::END_STATEMENT << nl << nl;
|
||||||
reactionsFile
|
reactionsFile
|
||||||
<< "species" << cr.species() << token::END_STATEMENT << nl << nl;
|
<< "species" << cr.species() << token::END_STATEMENT << nl << nl;
|
||||||
|
|
||||||
cr.reactions().write(reactionsFile);
|
cr.reactions().write(reactionsFile);
|
||||||
|
|
||||||
|
|
||||||
OFstream thermoFile(args[5]);
|
// Temporary hack to splice the specie composition data into the thermo file
|
||||||
cr.speciesThermo().write(thermoFile);
|
// pending complete integration into the thermodynamics structure
|
||||||
|
|
||||||
|
OStringStream os;
|
||||||
|
cr.speciesThermo().write(os);
|
||||||
|
dictionary thermoDict(IStringStream(os.str())());
|
||||||
|
|
||||||
|
wordList speciesList(thermoDict.toc());
|
||||||
|
|
||||||
|
// Add elements
|
||||||
|
forAll(speciesList, si)
|
||||||
|
{
|
||||||
|
dictionary elementsDict("elements");
|
||||||
|
forAll(cr.specieComposition()[speciesList[si]], ei)
|
||||||
|
{
|
||||||
|
elementsDict.add
|
||||||
|
(
|
||||||
|
cr.specieComposition()[speciesList[si]][ei].elementName,
|
||||||
|
cr.specieComposition()[speciesList[si]][ei].nAtoms
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
thermoDict.subDict(speciesList[si]).add("elements", elementsDict);
|
||||||
|
}
|
||||||
|
|
||||||
|
thermoDict.write(OFstream(args[5])(), false);
|
||||||
|
|
||||||
|
|
||||||
Info<< "End\n" << endl;
|
Info<< "End\n" << endl;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user