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