kivaToFoam.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2022 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 "mergedCyclicPolyPatch.H"
45 #include "polyMeshUnMergeCyclics.H"
46 #include "unitConversion.H"
47 
48 using namespace Foam;
49 
50 //- Supported KIVA versions
51 enum kivaVersions
52 {
53  kiva3,
54  kiva3v
55 };
56 
57 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
58 
59 int main(int argc, char *argv[])
60 {
63  (
64  "file",
65  "name",
66  "specify alternative input file name - default is otape17"
67  );
69  (
70  "version",
71  "version",
72  "specify kiva version [kiva3|kiva3v] - default is '3v'"
73  );
75  (
76  "zHeadMin",
77  "scalar",
78  "minimum z-height for transferring liner faces to cylinder-head"
79  );
80 
81  #include "setRootCase.H"
82  #include "createTime.H"
83 
84  const fileName kivaFileName =
85  args.optionLookupOrDefault<fileName>("file", "otape17");
86 
87  kivaVersions kivaVersion = kiva3v;
88  if (args.optionFound("version"))
89  {
90  const word versionName = args["version"];
91 
92  if (versionName == "kiva3")
93  {
94  kivaVersion = kiva3;
95  }
96  else if (versionName == "kiva3v")
97  {
98  kivaVersion = kiva3v;
99  }
100  else
101  {
102  args.printUsage();
103 
105  << "KIVA file version " << versionName << " not supported"
106  << exit(FatalError);
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 // ************************************************************************* //
static void addOption(const word &opt, const string &param="", const string &usage="")
Add to an option to validOptions with usage information.
Definition: argList.C:128
bool optionFound(const word &opt) const
Return true if the named option is found.
Definition: argListI.H:114
bool optionReadIfPresent(const word &opt, T &) const
Read a value from the named option if present.
Definition: argListI.H:204
static void noParallel()
Remove the parallel options.
Definition: argList.C:175
T optionLookupOrDefault(const word &opt, const T &deflt) const
Read a value from the named option if present.
Definition: argListI.H:243
void printUsage() const
Print usage.
Definition: argList.C:1238
A class for handling file names.
Definition: fileName.H:82
A class for handling words, derived from string.
Definition: word.H:62
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
int main(int argc, char *argv[])
Definition: financialFoam.C:44
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
messageStream Info
error FatalError
preservePatchTypes
Foam::argList args(argc, argv)
Unit conversion functions.