All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
foamyHexMesh.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Application
25  foamyHexMesh
26 
27 Description
28  Conformal Voronoi automatic mesh generator
29 
30 \*---------------------------------------------------------------------------*/
31 
32 #include "argList.H"
33 #include "Time.H"
34 #include "IOdictionary.H"
35 #include "searchableSurfaces.H"
36 #include "conformalVoronoiMesh.H"
37 #include "vtkSetWriter.H"
38 
39 using namespace Foam;
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 int main(int argc, char *argv[])
44 {
46  (
47  "checkGeometry",
48  "check all surface geometry for quality"
49  );
50 
52  (
53  "conformationOnly",
54  "conform to the initial points without any point motion"
55  );
56 
57  #include "setRootCase.H"
58  #include "createTime.H"
59 
61 
62  const bool checkGeometry = args.optionFound("checkGeometry");
63  const bool conformationOnly = args.optionFound("conformationOnly");
64 
65  IOdictionary foamyHexMeshDict
66  (
67  IOobject
68  (
69  args.executable() + "Dict",
70  runTime.system(),
71  runTime,
74  )
75  );
76 
77 
78  if (checkGeometry)
79  {
80  const searchableSurfaces allGeometry
81  (
82  IOobject
83  (
84  "cvSearchableSurfaces",
85  runTime.constant(),
87  runTime,
90  ),
91  foamyHexMeshDict.subDict("geometry"),
92  foamyHexMeshDict.lookupOrDefault("singleRegionName", true)
93  );
94 
95  // Write some stats
96  allGeometry.writeStats(List<wordList>(0), Info);
97  // Check topology
98  allGeometry.checkTopology(true);
99  // Check geometry
100  allGeometry.checkGeometry
101  (
102  100.0, // max size ratio
103  1e-9, // intersection tolerance
104  0.01, // min triangle quality
105  true
106  );
107 
108  return 0;
109  }
110 
111 
112  conformalVoronoiMesh::debug = true;
113 
114  Info<< "Create mesh for time = " << runTime.timeName() << nl << endl;
115 
116  conformalVoronoiMesh mesh(runTime, foamyHexMeshDict);
117 
118 
119  if (conformationOnly)
120  {
121  mesh.initialiseForConformation();
122 
123  runTime++;
124 
125  mesh.writeMesh(runTime.timeName());
126  }
127  else
128  {
129  mesh.initialiseForMotion();
130 
131  while (runTime.run())
132  {
133  runTime++;
134 
135  Info<< nl << "Time = " << runTime.timeName() << endl;
136 
137  mesh.move();
138 
139  Info<< nl
140  << "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
141  << " ClockTime = " << runTime.elapsedClockTime() << " s"
142  << nl << endl;
143  }
144  }
145 
146 
147  Info<< nl << "End" << nl << endl;
148 
149  return 0;
150 }
151 
152 
153 // ************************************************************************* //
const word & executable() const
Name of executable without the path.
Definition: argListI.H:36
void off()
Switch the function objects off.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
engineTime & runTime
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
bool optionFound(const word &opt) const
Return true if the named option is found.
Definition: argListI.H:114
static word timeName(const scalar, const int precision=precision_)
Return time name of given scalar time.
Definition: Time.C:636
virtual bool run() const
Return true if run should continue,.
Definition: Time.C:815
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:53
dynamicFvMesh & mesh
static const word & geometryDir()
Return the geometry directory name.
const word & constant() const
Return constant name.
Definition: TimePaths.H:123
Container for searchableSurfaces.
const word & system() const
Return system name.
Definition: TimePaths.H:113
static const char nl
Definition: Ostream.H:260
time_t elapsedClockTime() const
Returns wall-clock time from clock instantiation.
Definition: clock.C:122
double elapsedCpuTime() const
Return CPU time (in seconds) from the start.
Definition: cpuTime.C:67
const functionObjectList & functionObjects() const
Return the list of function objects.
Definition: Time.H:410
messageStream Info
const doubleScalar e
Elementary charge.
Definition: doubleScalar.H:105
static void addBoolOption(const word &opt, const string &usage="")
Add to a bool option to validOptions with usage information.
Definition: argList.C:118
Foam::argList args(argc, argv)
void writeStats(const List< wordList > &, Ostream &) const
Write some stats.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:92
Namespace for OpenFOAM.