Loading...
Searching...
No Matches
ensightToFoam.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 | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2022-2024 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26Application
27 ensightToFoam
28
29Group
30 grpMeshConversionUtilities
31
32Description
33 Convert an Ensight Gold mesh into OpenFOAM format.
34
35Usage
36 \b ensightToFoam [OPTION] <ensightGeometryFile>
37
38 Options:
39 - \par -mergeTol <factor>
40 Specify an alternative merging tolerance as a fraction of
41 the bounding box of the points.
42
43 - \par -scale <factor>
44 Specify an optional geometry scaling factor.
45
46 - \par -keepHandedness
47 Do not automatically flip negative volume cells
48
49See also
50 Foam::meshReader and Foam::fileFormats::STARCDMeshReader
51
52\*---------------------------------------------------------------------------*/
53
54#include "argList.H"
55#include "Time.H"
56#include "ensightMeshReader.H"
57
58using namespace Foam;
59
60// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
61
62int main(int argc, char *argv[])
63{
65 (
66 "Convert Ensight mesh to OpenFOAM"
67 );
68
70 argList::addArgument(".geo file", "The file containing the geometry");
72 (
73 "mergeTol",
74 "factor",
75 "Merge tolerance as a fraction of bounding box - 0 to disable merging"
76 );
78 (
79 "scale",
80 "factor",
81 "Geometry scaling factor - default is 1"
82 );
84 (
85 "keepHandedness",
86 "Do not automatically flip inverted cells"
87 " (default is to do a geometric test)"
88 );
89
90 argList args(argc, argv);
91 Time runTime(args.rootPath(), args.caseName());
92
93 // More precision (for points data)
95
96 const fileName geomFile(args.get<fileName>(1));
97
98 {
100 (
101 geomFile,
102 runTime,
103 args.getOrDefault<scalar>("mergeTol", 1e-10),
104 args.getOrDefault<scalar>("scale", 1.0),
105 args.found("keepHandedness")
106 );
107
108 autoPtr<polyMesh> mesh = reader.mesh(runTime);
109 mesh().setInstance(runTime.constant());
110 mesh().write();
111 }
112
113 Info<< "\nEnd\n" << endl;
114
115 return 0;
116}
117
118// ************************************************************************* //
static unsigned int minPrecision(unsigned int prec) noexcept
Set the minimum default precision.
Definition IOstream.H:459
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition Time.H:75
Extract command arguments and options from the supplied argc and argv parameters.
Definition argList.H:119
static void addArgument(const string &argName, const string &usage="")
Append a (mandatory) argument to validArgs.
Definition argList.C:366
static void addBoolOption(const word &optName, const string &usage="", bool advanced=false)
Add a bool option to validOptions with usage information.
Definition argList.C:389
static void noParallel()
Remove the parallel options.
Definition argList.C:599
static void addOption(const word &optName, const string &param="", const string &usage="", bool advanced=false)
Add an option to validOptions with usage information.
Definition argList.C:400
static void addNote(const string &note)
Add extra notes for the usage information.
Definition argList.C:477
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
A class for handling file names.
Definition fileName.H:75
dynamicFvMesh & mesh
engineTime & runTime
Namespace for OpenFOAM.
messageStream Info
Information stream (stdout output on master, null elsewhere).
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
Foam::argList args(argc, argv)
volScalarField & e