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 | Copyright (C) 2011-2015 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 
60  runTime.functionObjects().off();
61 
62  const bool checkGeometry = args.optionFound("checkGeometry");
63  const bool conformationOnly = args.optionFound("conformationOnly");
64 
65  // Allow override of decomposeParDict location
66  fileName decompDictFile;
67  if (args.optionReadIfPresent("decomposeParDict", decompDictFile))
68  {
69  if (isDir(decompDictFile))
70  {
71  decompDictFile = decompDictFile / "decomposeParDict";
72  }
73  }
74 
75 
76  IOdictionary foamyHexMeshDict
77  (
78  IOobject
79  (
80  args.executable() + "Dict",
81  runTime.system(),
82  runTime,
85  )
86  );
87 
88 
89  if (checkGeometry)
90  {
91  const searchableSurfaces allGeometry
92  (
93  IOobject
94  (
95  "cvSearchableSurfaces",
96  runTime.constant(),
97  "triSurface",
98  runTime,
101  ),
102  foamyHexMeshDict.subDict("geometry"),
103  foamyHexMeshDict.lookupOrDefault("singleRegionName", true)
104  );
105 
106  // Write some stats
107  allGeometry.writeStats(List<wordList>(0), Info);
108  // Check topology
109  allGeometry.checkTopology(true);
110  // Check geometry
111  allGeometry.checkGeometry
112  (
113  100.0, // max size ratio
114  1e-9, // intersection tolerance
116  0.01, // min triangle quality
117  true
118  );
119 
120  return 0;
121  }
122 
123 
124  conformalVoronoiMesh::debug = true;
125 
126  Info<< "Create mesh for time = " << runTime.timeName() << nl << endl;
127 
128  conformalVoronoiMesh mesh(runTime, foamyHexMeshDict, decompDictFile);
129 
130 
131  if (conformationOnly)
132  {
133  mesh.initialiseForConformation();
134 
135  runTime++;
136 
137  mesh.writeMesh(runTime.timeName());
138  }
139  else
140  {
141  mesh.initialiseForMotion();
142 
143  while (runTime.run())
144  {
145  runTime++;
146 
147  Info<< nl << "Time = " << runTime.timeName() << endl;
148 
149  mesh.move();
150 
151  Info<< nl
152  << "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
153  << " ClockTime = " << runTime.elapsedClockTime() << " s"
154  << nl << endl;
155  }
156  }
157 
158 
159  Info<< "\nEnd\n" << endl;
160 
161  return 0;
162 }
163 
164 
165 // ************************************************************************* //
Foam::IOdictionary
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:53
Foam::conformalVoronoiMesh
Definition: conformalVoronoiMesh.H:97
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
Foam::argList::addBoolOption
static void addBoolOption(const word &opt, const string &usage="")
Add to a bool option to validOptions with usage information.
Definition: argList.C:98
Foam::checkGeometry
label checkGeometry(const polyMesh &mesh, const bool allGeometry, const autoPtr< surfaceWriter > &)
Definition: checkGeometry.C:478
Foam::vtkSetWriter
Definition: vtkSetWriter.H:48
Foam::IOobject::MUST_READ
@ MUST_READ
Definition: IOobject.H:108
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::IOobject::NO_WRITE
@ NO_WRITE
Definition: IOobject.H:118
Foam::IOobject::MUST_READ_IF_MODIFIED
@ MUST_READ_IF_MODIFIED
Definition: IOobject.H:109
searchableSurfaces.H
Foam::argList::executable
const word & executable() const
Name of executable without the path.
Definition: argListI.H:30
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::Info
messageStream Info
argList.H
main
int main(int argc, char *argv[])
Definition: postCalc.C:54
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam::writer
Base class for graphics format writing. Entry points are.
Definition: writer.H:78
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::isDir
bool isDir(const fileName &)
Does the name exist as a DIRECTORY in the file system?
Definition: POSIX.C:615
Foam::e
const double e
Elementary charge.
Definition: doubleFloat.H:94
IOdictionary.H
Foam::autoPtr
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
setRootCase.H
vtkSetWriter.H
Foam::List
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
Foam::searchableSurfaces
Container for searchableSurfaces.
Definition: searchableSurfaces.H:53
createTime.H
Foam::argList::optionFound
bool optionFound(const word &opt) const
Return true if the named option is found.
Definition: argListI.H:108
args
Foam::argList args(argc, argv)
Foam::argList::optionReadIfPresent
bool optionReadIfPresent(const word &opt, T &) const
Read a value from the named option if present.
Definition: argListI.H:198
conformalVoronoiMesh.H