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-------------------------------------------------------------------------------
11License
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
27Application
28 foamyHexMesh
29
30Group
31 grpMeshGenerationUtilities
32
33Description
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"
43#include "vtkCoordSetWriter.H"
44
45using namespace Foam;
46
47// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48
49int main(int argc, char *argv[])
50{
51 argList::addNote
52 (
53 "Conformal Voronoi automatic mesh generator"
54 );
55 argList::addBoolOption
56 (
57 "checkGeometry",
58 "Check all surface geometry for quality"
59 );
60
61 argList::addBoolOption
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 (
82 (
83 args.executable() + "Dict",
84 runTime.system(),
85 runTime,
86 IOobject::MUST_READ_IF_MODIFIED,
87 IOobject::NO_WRITE
88 )
89 );
90
91
92 if (checkGeometry)
93 {
94 const searchableSurfaces allGeometry
95 (
97 (
98 "cvSearchableSurfaces",
99 runTime.constant(),
100 "triSurface",
101 runTime,
102 IOobject::MUST_READ,
103 IOobject::NO_WRITE
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
129 conformalVoronoiMesh::debug = true;
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;
157 runTime.printExecutionTime(Info);
158 }
159 }
160
161 Info<< "\nEnd\n" << endl;
162
163 return 0;
164}
165
166
167// ************************************************************************* //
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:57
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:77
bool found(const word &optName) const
Return true if the named option is found.
Definition: argListI.H:178
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
const word & executable() const noexcept
Name of executable without the path.
Definition: argListI.H:51
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
A class for handling file names.
Definition: fileName.H:76
Container for searchableSurfaces. The collection is specified as a dictionary. For example,...
dynamicFvMesh & mesh
engineTime & runTime
Namespace for OpenFOAM.
label checkGeometry(const polyMesh &mesh, const bool allGeometry, autoPtr< surfaceWriter > &surfWriter, autoPtr< coordSetWriter > &setWriter)
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
Foam::argList args(argc, argv)
volScalarField & e
Definition: createFields.H:11