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-2022 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
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 
27 Application
28  makeFaMesh
29 
30 Description
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 
35 Original 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 "faMeshTools.H"
46 #include "IOdictionary.H"
47 #include "IOobjectList.H"
48 #include "areaFields.H"
49 #include "edgeFields.H"
50 #include "faFieldDecomposer.H"
51 #include "faMeshReconstructor.H"
52 #include "faMeshSubset.H"
53 #include "PtrListOps.H"
54 #include "foamVtkIndPatchWriter.H"
55 #include "OBJstream.H"
56 
57 using namespace Foam;
58 
59 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
60 
61 int main(int argc, char *argv[])
62 {
64  (
65  "A mesh generator for finiteArea mesh"
66  );
68  (
69  "empty-patch",
70  "name",
71  "Specify name for a default empty patch",
72  false // An advanced option, but not enough to worry about that
73  );
74  argList::addOption("dict", "file", "Alternative faMeshDefinition");
75 
77  (
78  "Create but do not write"
79  );
81  (
82  "no-decompose",
83  "Suppress procAddressing creation and field decomposition"
84  " (parallel)"
85  );
87  (
88  "no-fields",
89  "Suppress field decomposition"
90  " (parallel)"
91  );
93  (
94  "write-vtk",
95  "Write mesh as a vtp (vtk) file for display or debugging"
96  );
98  (
99  "write-edges-obj",
100  "Write mesh edges as obj files (one per processor)",
101  true // advanced option (debugging only)
102  );
103 
104  #include "addRegionOption.H"
105  #include "setRootCase.H"
106  #include "createTime.H"
107  #include "createNamedPolyMesh.H"
108 
109  const bool doDecompose = !args.found("no-decompose");
110  const bool doDecompFields = !args.found("no-fields");
111 
112  if (!doDecompose)
113  {
114  Info<< "Skip decompose of finiteArea mesh/fields" << nl;
115  }
116  else if (!doDecompFields)
117  {
118  Info<< "Skip decompose of finiteArea fields" << nl;
119  }
120 
121  // Reading faMeshDefinition dictionary
122  #include "findMeshDefinitionDict.H"
123 
124  // Inject/overwrite name for optional 'empty' patch
125  word patchName;
126  if (args.readIfPresent("empty-patch", patchName))
127  {
128  meshDefDict.add("emptyPatch", patchName, true);
129  }
130 
131 
132  // Create
134 
135  // Mesh information (less verbose)
137 
138  if (args.found("write-edges-obj"))
139  {
140  #include "faMeshWriteEdgesOBJ.H"
141  }
142 
143  if (args.found("write-vtk"))
144  {
145  #include "faMeshWriteVTK.H"
146  }
147 
148  if (args.dryRun())
149  {
150  Info<< "\ndry-run: not writing mesh or decomposing fields\n" << nl;
151  }
152  else
153  {
154  // Set the precision of the points data to 10
156 
157  Info<< nl << "Write finite area mesh." << nl;
158  aMesh.write();
159 
160  Info<< endl;
161  #include "decomposeFaFields.H"
162  }
163 
164  Info<< "\nEnd\n" << endl;
165 
166  return 0;
167 }
168 
169 // ************************************************************************* //
Finite area mesh (used for 2-D non-Euclidian finite area method) defined using a patch of faces on a ...
Definition: faMesh.H:88
static void addNote(const string &note)
Add extra notes for the usage information.
Definition: argList.C:453
IOdictionary & meshDefDict
virtual bool write(const bool valid=true) const
Write mesh.
Definition: faMesh.C:1029
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:49
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:487
static unsigned int defaultPrecision() noexcept
Return the default precision.
Definition: IOstream.H:416
static void addBoolOption(const word &optName, const string &usage="", bool advanced=false)
Add a bool option to validOptions with usage information.
Definition: argList.C:365
Functions to operate on Pointer Lists.
entry * add(entry *entryPtr, bool mergeEntry=false)
Add a new entry.
Definition: dictionary.C:637
Required Variables.
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
dynamicFvMesh & mesh
A class for handling words, derived from Foam::string.
Definition: word.H:63
static void addDryRunOption(const string &usage, bool advanced=false)
Enable a &#39;dry-run&#39; bool option, with usage information.
Definition: argList.C:495
int dryRun() const noexcept
Return the dry-run flag.
Definition: argListI.H:109
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:376
static void printMeshChecks(const faMesh &mesh, const int verbose=1)
Report mesh information.
messageStream Info
Information stream (stdout output on master, null elsewhere)
bool readIfPresent(const word &optName, T &val) const
Read a value from the named option if present.
Definition: argListI.H:316
faMesh aMesh(mesh)
Foam::argList args(argc, argv)
bool found(const word &optName) const
Return true if the named option is found.
Definition: argListI.H:171
Namespace for OpenFOAM.