foamyHexMesh.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) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2016-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  foamyHexMesh
29 
30 Group
31  grpMeshGenerationUtilities
32 
33 Description
34  Conformal Voronoi automatic mesh generator
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #include "argList.H"
39 #include "Time.H"
40 #include "IOdictionary.H"
41 #include "searchableSurfaces.H"
42 #include "conformalVoronoiMesh.H"
43 #include "vtkCoordSetWriter.H"
44 
45 using namespace Foam;
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
49 int main(int argc, char *argv[])
50 {
52  (
53  "Conformal Voronoi automatic mesh generator"
54  );
56  (
57  "checkGeometry",
58  "Check all surface geometry for quality"
59  );
60 
62  (
63  "conformationOnly",
64  "Conform to the initial points without any point motion"
65  );
66 
67  argList::noFunctionObjects(); // Never use function objects
68 
69  #include "setRootCase.H"
70  #include "createTime.H"
71 
72  const bool checkGeometry = args.found("checkGeometry");
73  const bool conformationOnly = args.found("conformationOnly");
74 
75  // Allow override of decomposeParDict location
76  const fileName decompDictFile =
77  args.getOrDefault<fileName>("decomposeParDict", "");
78 
79  IOdictionary foamyHexMeshDict
80  (
81  IOobject
82  (
83  args.executable() + "Dict",
84  runTime.system(),
85  runTime,
88  )
89  );
90 
91 
92  if (checkGeometry)
93  {
94  const searchableSurfaces allGeometry
95  (
96  IOobject
97  (
98  "cvSearchableSurfaces",
99  runTime.constant(),
100  "triSurface",
101  runTime,
104  ),
105  foamyHexMeshDict.subDict("geometry"),
106  foamyHexMeshDict.getOrDefault("singleRegionName", true)
107  );
108 
110 
111  // Write some stats
112  allGeometry.writeStats(List<wordList>(), Info);
113  // Check topology
114  allGeometry.checkTopology(true);
115  // Check geometry
116  allGeometry.checkGeometry
117  (
118  100.0, // max size ratio
119  1e-9, // intersection tolerance
120  setWriterPtr,
121  0.01, // min triangle quality
122  true
123  );
124 
125  return 0;
126  }
127 
128 
130 
131  Info<< "Create mesh for time = " << runTime.timeName() << nl << endl;
132 
133  conformalVoronoiMesh mesh(runTime, foamyHexMeshDict, decompDictFile);
134 
135 
136  if (conformationOnly)
137  {
138  mesh.initialiseForConformation();
139 
140  ++runTime;
141 
142  mesh.writeMesh(runTime.timeName());
143  }
144  else
145  {
146  mesh.initialiseForMotion();
147 
148  while (runTime.run())
149  {
150  ++runTime;
151 
152  Info<< nl << "Time = " << runTime.timeName() << endl;
153 
154  mesh.move();
155 
156  Info<< nl;
158  }
159  }
160 
161  Info<< "\nEnd\n" << endl;
162 
163  return 0;
164 }
165 
166 
167 // ************************************************************************* //
static void noFunctionObjects(bool addWithOption=false)
Remove &#39;-noFunctionObjects&#39; option and ignore any occurrences.
Definition: argList.C:514
static void addNote(const string &note)
Add extra notes for the usage information.
Definition: argList.C:453
A class for handling file names.
Definition: fileName.H:71
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:56
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:49
engineTime & runTime
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:487
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
Ignore writing from objectRegistry::writeObject()
T getOrDefault(const word &optName, const T &deflt) const
Get a value from the named option if present, or return default.
Definition: argListI.H:300
virtual bool run() const
Return true if run should continue,.
Definition: Time.C:859
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:50
const dimensionedScalar e
Elementary charge.
Definition: createFields.H:11
dynamicFvMesh & mesh
const word & executable() const noexcept
Name of executable without the path.
Definition: argListI.H:44
Reading required, file watched for runTime modification.
const word & system() const noexcept
Return system name.
Definition: TimePathsI.H:95
Container for searchableSurfaces. The collection is specified as a dictionary. For example...
static word timeName(const scalar t, const int precision=precision_)
Return time name of given scalar time formatted with the given precision.
Definition: Time.C:760
const word & constant() const noexcept
Return constant name.
Definition: TimePathsI.H:89
int debug
Static debugging option.
Ostream & printExecutionTime(OSstream &os) const
Print the elapsed ExecutionTime (cpu-time), ClockTime.
Definition: TimeIO.C:612
messageStream Info
Information stream (stdout output on master, null elsewhere)
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
Foam::argList args(argc, argv)
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:166
bool found(const word &optName) const
Return true if the named option is found.
Definition: argListI.H:171
Namespace for OpenFOAM.
label checkGeometry(const polyMesh &mesh, const bool allGeometry, autoPtr< surfaceWriter > &surfWriter, autoPtr< coordSetWriter > &setWriter)