mirrorMesh.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-2017 OpenFOAM Foundation
9 Copyright (C) 2018-2020 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 mirrorMesh
29
30Group
31 grpMeshManipulationUtilities
32
33Description
34 Mirrors a mesh around a given plane.
35
36\*---------------------------------------------------------------------------*/
37
38#include "argList.H"
39#include "Time.H"
40#include "mirrorFvMesh.H"
41#include "mapPolyMesh.H"
42#include "hexRef8Data.H"
43
44using namespace Foam;
45
46// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47
48int main(int argc, char *argv[])
49{
50 argList::addNote
51 (
52 "Mirrors a mesh around a given plane."
53 );
54
55 argList::addOption("dict", "file", "Alternative mirrorMeshDict");
56 argList::setAdvanced("decomposeParDict");
57
58 #include "addOverwriteOption.H"
59 #include "setRootCase.H"
60 #include "createTime.H"
61
62 const bool overwrite = args.found("overwrite");
63
64 const word dictName("mirrorMeshDict");
65
67
68 Info<< "Reading " << dictIO.name() << nl << endl;
69
70 const IOdictionary mirrorDict(dictIO);
71
73 (
75 (
76 polyMesh::defaultRegion,
77 runTime.constant(),
79 ),
80 mirrorDict
81 );
82
83 hexRef8Data refData
84 (
86 (
87 "dummy",
88 mesh.facesInstance(),
89 polyMesh::meshSubDir,
90 mesh,
91 IOobject::READ_IF_PRESENT,
92 IOobject::NO_WRITE,
93 false
94 )
95 );
96
97 if (!overwrite)
98 {
99 ++runTime;
100 mesh.setInstance(runTime.timeName());
101 }
102
103
104 // Set the precision of the points data to 10
105 IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision()));
106
107 // Generate the mirrorred mesh
108 const fvMesh& mMesh = mesh.mirrorMesh();
109
110 const_cast<fvMesh&>(mMesh).setInstance(mesh.facesInstance());
111 Info<< "Writing mirrored mesh" << endl;
112 mMesh.write();
113
114 // Map the hexRef8 data
115 mapPolyMesh map
116 (
117 mesh,
118 mesh.nPoints(), //nOldPoints,
119 mesh.nFaces(), //nOldFaces,
120 mesh.nCells(), //nOldCells,
121 mesh.pointMap(), //pointMap,
122 List<objectMap>(0), // pointsFromPoints,
123 labelList(0), //faceMap,
124 List<objectMap>(0), //facesFromPoints,
125 List<objectMap>(0), //facesFromEdges,
126 List<objectMap>(0), //facesFromFaces,
127 mesh.cellMap(), //cellMap,
128 List<objectMap>(0), //cellsFromPoints,
129 List<objectMap>(0), //cellsFromEdges,
130 List<objectMap>(0), //cellsFromFaces,
131 List<objectMap>(0), //cellsFromCells,
132 labelList(0), //reversePointMap,
133 labelList(0), //reverseFaceMap,
134 labelList(0), //reverseCellMap,
135 labelHashSet(0), //flipFaceFlux,
136 labelListList(0), //patchPointMap,
137 labelListList(0), //pointZoneMap,
138 labelListList(0), //faceZonePointMap,
139 labelListList(0), //faceZoneFaceMap,
140 labelListList(0), //cellZoneMap,
141 pointField(0), //preMotionPoints,
142 labelList(0), //oldPatchStarts,
143 labelList(0), //oldPatchNMeshPoints,
144 autoPtr<scalarField>() //oldCellVolumesPtr
145 );
146 refData.updateMesh(map);
147 refData.write();
148
149 Info<< "End\n" << endl;
150
151 return 0;
152}
153
154
155// ************************************************************************* //
Y[inertIndex] max(0.0)
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
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
virtual bool write(const bool valid=true) const
Write mesh using IO settings from time.
Definition: fvMesh.C:1079
Various for reading/decomposing/reconstructing/distributing refinement data.
Definition: hexRef8Data.H:61
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:162
A class for handling words, derived from Foam::string.
Definition: word.H:68
dynamicFvMesh & mesh
engineTime & runTime
const word dictName("faMeshDefinition")
Namespace for OpenFOAM.
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
IOobject dictIO
Foam::argList args(argc, argv)