Commit 36adf970 authored by Henry Weller's avatar Henry Weller
Browse files

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.
parent 20f9d827
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -33,6 +33,8 @@ Description
#include "argList.H"
#include "chemkinReader.H"
#include "OFstream.H"
#include "OStringStream.H"
#include "IStringStream.H"
using namespace Foam;
......@@ -60,15 +62,42 @@ int main(int argc, char *argv[])
chemkinReader cr(species, args[1], args[3], args[2], newFormat);
OFstream reactionsFile(args[4]);
reactionsFile
<< "elements" << cr.elementNames() << token::END_STATEMENT << nl << nl;
reactionsFile
<< "species" << cr.species() << token::END_STATEMENT << nl << nl;
cr.reactions().write(reactionsFile);
OFstream thermoFile(args[5]);
cr.speciesThermo().write(thermoFile);
// Temporary hack to splice the specie composition data into the thermo file
// 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;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment