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-2018 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(),
86  "triSurface",
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
105  0.01, // min triangle quality
106  true
107  );
108 
109  return 0;
110  }
111 
112 
113  conformalVoronoiMesh::debug = true;
114 
115  Info<< "Create mesh for time = " << runTime.timeName() << nl << endl;
116 
117  conformalVoronoiMesh mesh(runTime, foamyHexMeshDict);
118 
119 
120  if (conformationOnly)
121  {
122  mesh.initialiseForConformation();
123 
124  runTime++;
125 
126  mesh.writeMesh(runTime.timeName());
127  }
128  else
129  {
130  mesh.initialiseForMotion();
131 
132  while (runTime.run())
133  {
134  runTime++;
135 
136  Info<< nl << "Time = " << runTime.timeName() << endl;
137 
138  mesh.move();
139 
140  Info<< nl
141  << "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
142  << " ClockTime = " << runTime.elapsedClockTime() << " s"
143  << nl << endl;
144  }
145  }
146 
147 
148  Info<< nl << "End" << nl << endl;
149 
150  return 0;
151 }
152 
153 
154 // ************************************************************************* //
const word & executable() const
Name of executable without the path.
Definition: argListI.H:30
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:60
engineTime & runTime
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:256
bool optionFound(const word &opt) const
Return true if the named option is found.
Definition: argListI.H:108
static word timeName(const scalar, const int precision=precision_)
Return time name of given scalar time.
Definition: Time.C:626
virtual bool run() const
Return true if run should continue,.
Definition: Time.C:799
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:52
dynamicFvMesh & mesh
const word & constant() const
Return constant name.
Definition: TimePaths.H:124
Container for searchableSurfaces.
const word & system() const
Return system name.
Definition: TimePaths.H:114
static const char nl
Definition: Ostream.H:265
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
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
const doubleScalar e
Elementary charge.
Definition: doubleScalar.H:98
static void addBoolOption(const word &opt, const string &usage="")
Add to a bool option to validOptions with usage information.
Definition: argList.C:110
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.