chemkinReader : handle relative filenames when reading from thermo Dict

This commit is contained in:
Mark Olesen
2008-05-27 09:00:20 +02:00
parent 8f0c802318
commit f4c462cac5

View File

@ -52,7 +52,7 @@ namespace Foam
/* * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * */
const char* Foam::chemkinReader::reactionTypeNames[4] =
const char* Foam::chemkinReader::reactionTypeNames[4] =
{
"irreversible",
"reversible",
@ -154,7 +154,7 @@ void Foam::chemkinReader::checkCoeffs
<< " rate expression on line "
<< lineNo_-1 << ", should be "
<< nCoeffs << " but " << reactionCoeffs.size() << " supplied." << nl
<< "Coefficients are "
<< "Coefficients are "
<< reactionCoeffs << nl
<< exit(FatalError);
}
@ -291,7 +291,7 @@ void Foam::chemkinReader::addPressureDependentReaction
<< "Wrong number of coefficients for Troe rate expression"
" on line " << lineNo_-1 << ", should be 3 or 4 but "
<< TroeCoeffs.size() << " supplied." << nl
<< "Coefficients are "
<< "Coefficients are "
<< TroeCoeffs << nl
<< exit(FatalError);
}
@ -347,7 +347,7 @@ void Foam::chemkinReader::addPressureDependentReaction
<< "Wrong number of coefficients for SRI rate expression"
" on line " << lineNo_-1 << ", should be 3 or 5 but "
<< SRICoeffs.size() << " supplied." << nl
<< "Coefficients are "
<< "Coefficients are "
<< SRICoeffs << nl
<< exit(FatalError);
}
@ -397,7 +397,7 @@ void Foam::chemkinReader::addPressureDependentReaction
if (fofType < 4)
{
FatalErrorIn("chemkinReader::addPressureDependentReaction")
<< "Fall-off function type "
<< "Fall-off function type "
<< fallOffFunctionNames[fofType]
<< " on line " << lineNo_-1
<< " not implemented"
@ -459,7 +459,7 @@ void Foam::chemkinReader::addReaction
// Calculate the unit conversion factor for the A coefficient
// for the change from mol/cm^3 to kmol/m^3 concentraction units
const scalar concFactor = 0.001;
const scalar concFactor = 0.001;
scalar sumExp = 0.0;
forAll (lhs, i)
{
@ -868,21 +868,34 @@ Foam::chemkinReader::chemkinReader(const dictionary& thermoDict)
specieNames_(10),
speciesTable_(static_cast<const wordList&>(wordList()))
{
fileName CHEMKINFileName
fileName chemkinFile
(
fileName(thermoDict.lookup("CHEMKINFile")).expand()
);
fileName thermoFileName = fileName::null;
fileName thermoFile = fileName::null;
if (thermoDict.found("CHEMKINThermoFile"))
{
thermoFileName =
fileName(thermoDict.lookup("CHEMKINThermoFile")).expand();
thermoFile = fileName(thermoDict.lookup("CHEMKINThermoFile")).expand();
}
read(CHEMKINFileName, thermoFileName);
// allow relative file names
fileName relPath = thermoDict.name().path();
if (relPath.size())
{
if (chemkinFile.size() && chemkinFile[0] != '/')
{
chemkinFile = relPath/chemkinFile;
}
if (thermoFile.size() && thermoFile[0] != '/')
{
thermoFile = relPath/thermoFile;
}
}
read(chemkinFile, thermoFile);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //