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-2020 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 "vtkSetWriter.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 
109  // Write some stats
110  allGeometry.writeStats(List<wordList>(0), Info);
111  // Check topology
112  allGeometry.checkTopology(true);
113  // Check geometry
114  allGeometry.checkGeometry
115  (
116  100.0, // max size ratio
117  1e-9, // intersection tolerance
119  0.01, // min triangle quality
120  true
121  );
122 
123  return 0;
124  }
125 
126 
128 
129  Info<< "Create mesh for time = " << runTime.timeName() << nl << endl;
130 
131  conformalVoronoiMesh mesh(runTime, foamyHexMeshDict, decompDictFile);
132 
133 
134  if (conformationOnly)
135  {
136  mesh.initialiseForConformation();
137 
138  ++runTime;
139 
140  mesh.writeMesh(runTime.timeName());
141  }
142  else
143  {
144  mesh.initialiseForMotion();
145 
146  while (runTime.run())
147  {
148  ++runTime;
149 
150  Info<< nl << "Time = " << runTime.timeName() << endl;
151 
152  mesh.move();
153 
154  Info<< nl;
156  }
157  }
158 
159  Info<< "\nEnd\n" << endl;
160 
161  return 0;
162 }
163 
164 
165 // ************************************************************************* //
Foam::expressions::patchExpr::debug
int debug
Static debugging option.
Foam::IOobject::NO_WRITE
Definition: IOobject.H:195
Foam::IOdictionary
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:54
runTime
engineTime & runTime
Definition: createEngineTime.H:13
Foam::conformalVoronoiMesh
Definition: conformalVoronoiMesh.H:96
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
Foam::fileName
A class for handling file names.
Definition: fileName.H:73
Foam::argList::getOrDefault
T getOrDefault(const word &optName, const T &deflt) const
Get a value from the named option if present, or return default.
Definition: argListI.H:307
Foam::Time::timeName
static word timeName(const scalar t, const int precision=precision_)
Definition: Time.C:780
Foam::argList::addNote
static void addNote(const string &note)
Add extra notes for the usage information.
Definition: argList.C:412
Foam::vtkSetWriter
Definition: vtkSetWriter.H:54
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::searchableSurfaces::writeStats
void writeStats(const List< wordList > &, Ostream &) const
Write some stats.
Definition: searchableSurfaces.C:870
Foam::Time::printExecutionTime
Ostream & printExecutionTime(OSstream &os) const
Print the elapsed ExecutionTime (cpu-time), ClockTime.
Definition: TimeIO.C:618
searchableSurfaces.H
Foam::argList::noFunctionObjects
static void noFunctionObjects(bool addWithOption=false)
Remove '-noFunctionObjects' option and ignore any occurrences.
Definition: argList.C:473
Foam::Info
messageStream Info
Information stream (stdout output on master, null elsewhere)
argList.H
Foam::checkGeometry
label checkGeometry(const polyMesh &mesh, const bool allGeometry, autoPtr< surfaceWriter > &surfWriter, const autoPtr< writer< scalar >> &setWriter)
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::writer< scalar >
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
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
IOdictionary.H
Time.H
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
setRootCase.H
vtkSetWriter.H
Foam::TimePaths::system
const word & system() const
Return system name.
Definition: TimePathsI.H:102
Foam::nl
constexpr char nl
Definition: Ostream.H:404
Foam::argList::executable
const word & executable() const noexcept
Name of executable without the path.
Definition: argListI.H:51
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:63
Foam::searchableSurfaces
Container for searchableSurfaces. The collection is specified as a dictionary. For example,...
Definition: searchableSurfaces.H:92
Foam::constant::electromagnetic::e
const dimensionedScalar e
Elementary charge.
Definition: createFields.H:11
createTime.H
Foam::IOobject::MUST_READ_IF_MODIFIED
Definition: IOobject.H:186
Foam::TimePaths::constant
const word & constant() const
Return constant name.
Definition: TimePathsI.H:96
args
Foam::argList args(argc, argv)
Foam::Time::run
virtual bool run() const
Return true if run should continue,.
Definition: Time.C:885
conformalVoronoiMesh.H
Foam::argList::found
bool found(const word &optName) const
Return true if the named option is found.
Definition: argListI.H:178
Foam::IOobject::MUST_READ
Definition: IOobject.H:185