chemkinToFoam.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Application
25  chemkinToFoam
26 
27 Description
28  Converts CHEMKINIII thermodynamics and reaction data files into
29  OpenFOAM format.
30 
31 \*---------------------------------------------------------------------------*/
32 
33 #include "argList.H"
34 #include "chemkinReader.H"
35 #include "OFstream.H"
36 
37 using namespace Foam;
38 
39 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40 
41 int main(int argc, char *argv[])
42 {
43  argList::validArgs.append("CHEMKINFile");
44  argList::validArgs.append("CHEMKINThermodynamicsFile");
45  argList::validArgs.append("CHEMKINTransport");
46  argList::validArgs.append("FOAMChemistryFile");
47  argList::validArgs.append("FOAMThermodynamicsFile");
48 
50  (
51  "newFormat",
52  "read Chemkin thermo file in new format"
53  );
54 
55  argList args(argc, argv);
56 
57  bool newFormat = args.optionFound("newFormat");
58 
59  speciesTable species;
60 
61  chemkinReader cr(species, args[1], args[3], args[2], newFormat);
62 
63  OFstream reactionsFile(args[4]);
64  reactionsFile
65  << "species" << cr.species() << token::END_STATEMENT << nl << nl;
66 
67  cr.reactions().write(reactionsFile);
68 
69 
70  OFstream thermoFile(args[5]);
71  cr.speciesThermo().write(thermoFile);
72 
73  Info<< "End\n" << endl;
74 
75  return 0;
76 }
77 
78 
79 // ************************************************************************* //
Output to file stream.
Definition: OFstream.H:81
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:253
static SLList< string > validArgs
A list of valid (mandatory) arguments.
Definition: argList.H:154
Foam::chemkinReader.
Definition: chemkinReader.H:62
bool optionFound(const word &opt) const
Return true if the named option is found.
Definition: argListI.H:108
Extract command arguments and options from the supplied argc and argv parameters. ...
Definition: argList.H:102
static const char nl
Definition: Ostream.H:262
A wordList with hashed indices for faster lookup by name.
messageStream Info
static void addBoolOption(const word &opt, const string &usage="")
Add to a bool option to validOptions with usage information.
Definition: argList.C:83
Foam::argList args(argc, argv)
Namespace for OpenFOAM.