kivaToFoam.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  kivaToFoam
26 
27 Description
28  Converts a KIVA3v grid to OpenFOAM format.
29 
30 \*---------------------------------------------------------------------------*/
31 
32 #include "argList.H"
33 #include "Time.H"
34 #include "polyMesh.H"
35 #include "IFstream.H"
36 #include "OFstream.H"
37 #include "cellShape.H"
38 #include "cellModeller.H"
39 #include "preservePatchTypes.H"
40 #include "emptyPolyPatch.H"
41 #include "wallPolyPatch.H"
42 #include "symmetryPolyPatch.H"
43 #include "wedgePolyPatch.H"
44 #include "oldCyclicPolyPatch.H"
45 #include "unitConversion.H"
46 
47 using namespace Foam;
48 
49 //- Supported KIVA versions
50 enum kivaVersions
51 {
52  kiva3,
53  kiva3v
54 };
55 
56 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
57 
58 int main(int argc, char *argv[])
59 {
62  (
63  "file",
64  "name",
65  "specify alternative input file name - default is otape17"
66  );
68  (
69  "version",
70  "version",
71  "specify kiva version [kiva3|kiva3v] - default is '3v'"
72  );
74  (
75  "zHeadMin",
76  "scalar",
77  "minimum z-height for transferring liner faces to cylinder-head"
78  );
79 
80  #include "setRootCase.H"
81  #include "createTime.H"
82 
83  const fileName kivaFileName =
84  args.optionLookupOrDefault<fileName>("file", "otape17");
85 
86  kivaVersions kivaVersion = kiva3v;
87  if (args.optionFound("version"))
88  {
89  const word versionName = args["version"];
90 
91  if (versionName == "kiva3")
92  {
93  kivaVersion = kiva3;
94  }
95  else if (versionName == "kiva3v")
96  {
97  kivaVersion = kiva3v;
98  }
99  else
100  {
102  << "KIVA file version " << versionName << " not supported"
103  << exit(FatalError);
104 
105  args.printUsage();
106  FatalError.exit(1);
107  }
108  }
109 
110  scalar zHeadMin = -GREAT;
111  args.optionReadIfPresent("zHeadMin", zHeadMin);
112 
113  #include "readKivaGrid.H"
114 
115  Info<< "End\n" << endl;
116 
117  return 0;
118 }
119 
120 
121 // ************************************************************************* //
A class for handling file names.
Definition: fileName.H:69
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
error FatalError
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
Unit conversion functions.
bool optionReadIfPresent(const word &opt, T &) const
Read a value from the named option if present.
Definition: argListI.H:198
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:253
static void noParallel()
Remove the parallel options.
Definition: argList.C:146
void exit(const int errNo=1)
Exit : can be called for any error to exit program.
Definition: error.C:168
T optionLookupOrDefault(const word &opt, const T &deflt) const
Read a value from the named option if present.
Definition: argListI.H:237
bool optionFound(const word &opt) const
Return true if the named option is found.
Definition: argListI.H:108
A class for handling words, derived from string.
Definition: word.H:59
static void addOption(const word &opt, const string &param="", const string &usage="")
Add to an option to validOptions with usage information.
Definition: argList.C:93
preservePatchTypes
messageStream Info
void printUsage() const
Print usage.
Definition: argList.C:1033
Foam::argList args(argc, argv)
Namespace for OpenFOAM.