makeFaMesh.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) 2016-2017 Wikki Ltd
9 Copyright (C) 2021 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Application
28 makeFaMesh
29
30Description
31 A mesh generator for finiteArea mesh.
32 When called in parallel, it will also try to act like decomposePar,
33 create procAddressing and decompose serial finite-area fields.
34
35Original Authors
36 Zeljko Tukovic, FAMENA
37 Hrvoje Jasak, Wikki Ltd.
38
39\*---------------------------------------------------------------------------*/
40
41#include "Time.H"
42#include "argList.H"
43#include "OSspecific.H"
44#include "faMesh.H"
45#include "IOdictionary.H"
46#include "IOobjectList.H"
47
48#include "areaFields.H"
49#include "edgeFields.H"
50#include "faFieldDecomposer.H"
51#include "faMeshReconstructor.H"
52#include "PtrListOps.H"
54#include "OBJstream.H"
55
56using namespace Foam;
57
58// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
59
60int main(int argc, char *argv[])
61{
62 argList::addNote
63 (
64 "A mesh generator for finiteArea mesh"
65 );
66 argList::addOption
67 (
68 "empty-patch",
69 "name",
70 "Specify name for a default empty patch",
71 false // An advanced option, but not enough to worry about that
72 );
73 argList::addOption("dict", "file", "Alternative faMeshDefinition");
74
75 argList::addDryRunOption
76 (
77 "Create but do not write"
78 );
79 argList::addBoolOption
80 (
81 "no-decompose",
82 "Suppress procAddressing creation and field decomposition"
83 " (parallel)"
84 );
85 argList::addBoolOption
86 (
87 "no-fields",
88 "Suppress field decomposition"
89 " (parallel)"
90 );
91 argList::addBoolOption
92 (
93 "write-vtk",
94 "Write mesh as a vtp (vtk) file for display or debugging"
95 );
96 argList::addBoolOption
97 (
98 "write-edges-obj",
99 "Write mesh edges as obj files (one per processor)",
100 true // advanced option (debugging only)
101 );
102
103 #include "addRegionOption.H"
104 #include "setRootCase.H"
105 #include "createTime.H"
106 #include "createNamedPolyMesh.H"
107
108 const bool doDecompose = !args.found("no-decompose");
109 const bool doDecompFields = !args.found("no-fields");
110
111 if (!doDecompose)
112 {
113 Info<< "Skip decompose of finiteArea mesh/fields" << nl;
114 }
115 else if (!doDecompFields)
116 {
117 Info<< "Skip decompose of finiteArea fields" << nl;
118 }
119
120 // Reading faMeshDefinition dictionary
121 #include "findMeshDefinitionDict.H"
122
123 // Inject/overwrite name for optional 'empty' patch
124 word patchName;
125 if (args.readIfPresent("empty-patch", patchName))
126 {
127 meshDefDict.add("emptyPatch", patchName, true);
128 }
129
130
131 // Create
133
134 // Mesh information
135 #include "printMeshSummary.H"
136
137 if (args.found("write-edges-obj"))
138 {
139 #include "faMeshWriteEdgesOBJ.H"
140 }
141
142 if (args.found("write-vtk"))
143 {
144 #include "faMeshWriteVTK.H"
145 }
146
147 if (args.dryRun())
148 {
149 Info<< "\ndry-run: not writing mesh or decomposing fields\n" << nl;
150 }
151 else
152 {
153 // Set the precision of the points data to 10
154 IOstream::defaultPrecision(10);
155
156 Info<< nl << "Write finite area mesh." << nl;
157 aMesh.write();
158
159 Info<< endl;
160 #include "decomposeFaFields.H"
161 }
162
163 Info<< "\nEnd\n" << endl;
164
165 return 0;
166}
167
168// ************************************************************************* //
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
Functions to operate on Pointer Lists.
int dryRun() const noexcept
Return the dry-run flag.
Definition: argListI.H:116
bool found(const word &optName) const
Return true if the named option is found.
Definition: argListI.H:178
bool readIfPresent(const word &optName, T &val) const
Read a value from the named option if present.
Definition: argListI.H:323
Finite area mesh (used for 2-D non-Euclidian finite area method) defined using a patch of faces on a ...
Definition: faMesh.H:100
A class for handling words, derived from Foam::string.
Definition: word.H:68
dynamicFvMesh & mesh
Required Variables.
IOdictionary & meshDefDict
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:372
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
Foam::argList args(argc, argv)
faMesh aMesh(mesh)