ENH: Added option to read new chemkin format

This commit is contained in:
andy
2013-02-01 16:38:52 +00:00
parent eedaa820e2
commit 17e2039920
4 changed files with 44 additions and 17 deletions

View File

@ -439,20 +439,25 @@ bool finishReaction = false;
<readThermoSpecieName>{thermoSpecieName} {
string specieString(foamSpecieString(YYText()));
// Old format
size_t spacePos = specieString.find(' ');
if (spacePos != string::npos)
if (newFormat_)
{
currentSpecieName = specieString(0, spacePos);
specieString.replaceAll(" ", "_");
size_t strEnd = specieString.find_last_not_of('_');
currentSpecieName = specieString.substr(0, strEnd + 1);
}
else
{
currentSpecieName = specieString;
size_t spacePos = specieString.find(' ');
if (spacePos != string::npos)
{
currentSpecieName = specieString(0, spacePos);
}
else
{
currentSpecieName = specieString;
}
}
// New format
// specieString.replaceAll(" ", "_");
// size_t strEnd = specieString.find_last_not_of('_');
// currentSpecieName = specieString.substr(0, strEnd + 1);
BEGIN(readThermoDate);
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013-2013 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -862,13 +862,15 @@ Foam::chemkinReader::chemkinReader
(
const fileName& CHEMKINFileName,
speciesTable& species,
const fileName& thermoFileName
const fileName& thermoFileName,
const bool newFormat
)
:
lineNo_(1),
specieNames_(10),
speciesTable_(species),
reactions_(speciesTable_, speciesThermo_)
reactions_(speciesTable_, speciesThermo_),
newFormat_(newFormat)
{
read(CHEMKINFileName, thermoFileName);
}
@ -883,8 +885,14 @@ Foam::chemkinReader::chemkinReader
lineNo_(1),
specieNames_(10),
speciesTable_(species),
reactions_(speciesTable_, speciesThermo_)
reactions_(speciesTable_, speciesThermo_),
newFormat_(thermoDict.lookupOrDefault("newFormat", false))
{
if (newFormat_)
{
Info<< "Reading CHEMKIN thermo data in new file format" << endl;
}
fileName chemkinFile(fileName(thermoDict.lookup("CHEMKINFile")).expand());
fileName thermoFile = fileName::null;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013-2013 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -39,6 +39,7 @@ SourceFiles
#include "chemistryReader.H"
#include "fileName.H"
#include "typeInfo.H"
#include "Switch.H"
#include "HashPtrTable.H"
#include "ReactionList.H"
#include "DynamicList.H"
@ -207,6 +208,9 @@ private:
//- List of the reactions
ReactionList<gasHThermoPhysics> reactions_;
//- Flag to indicate that file is in new format
Switch newFormat_;
// Private Member Functions
@ -319,7 +323,8 @@ public:
(
const fileName& chemkinFile,
speciesTable& species,
const fileName& thermoFileName = fileName::null
const fileName& thermoFileName = fileName::null,
const bool newFormat = false
);
//- Construct by getting the CHEMKIN III file name from dictionary