mirrorMesh.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-2022 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  mirrorMesh
26 
27 Description
28  Mirrors a mesh around a given plane.
29 
30 \*---------------------------------------------------------------------------*/
31 
32 #include "argList.H"
33 #include "Time.H"
34 #include "mirrorFvMesh.H"
35 #include "polyTopoChangeMap.H"
36 #include "hexRef8Data.H"
37 #include "systemDict.H"
38 
39 using namespace Foam;
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 int main(int argc, char *argv[])
44 {
45  #include "addOverwriteOption.H"
46  #include "addDictOption.H"
47 
48  #include "setRootCase.H"
49  #include "createTime.H"
50 
51  const bool overwrite = args.optionFound("overwrite");
52 
53  mirrorFvMesh mesh
54  (
55  IOobject
56  (
58  runTime.constant(),
59  runTime
60  ),
61  systemDictIO("mirrorMeshDict", args, runTime)
62  );
63 
64  hexRef8Data refData
65  (
66  IOobject
67  (
68  "dummy",
69  mesh.facesInstance(),
71  mesh,
74  false
75  )
76  );
77 
78  if (!overwrite)
79  {
80  runTime++;
81  mesh.setInstance(runTime.name());
82  }
83 
84 
85  // Set the precision of the points data to 10
87 
88  // Generate the mirrored mesh
89  const fvMesh& mMesh = mesh.mirrorMesh();
90 
91  const_cast<fvMesh&>(mMesh).setInstance(mesh.facesInstance());
92  Info<< "Writing mirrored mesh" << endl;
93  mMesh.write();
94 
95  // Map the hexRef8 data
97  (
98  mesh,
99  mesh.nPoints(), // nOldPoints,
100  mesh.nFaces(), // nOldFaces,
101  mesh.nCells(), // nOldCells,
102  mesh.pointMap(), // pointMap,
103  List<objectMap>(0), // pointsFromPoints,
104  labelList(0), // faceMap,
105  List<objectMap>(0), // facesFromPoints,
106  List<objectMap>(0), // facesFromEdges,
107  List<objectMap>(0), // facesFromFaces,
108  mesh.cellMap(), // cellMap,
109  List<objectMap>(0), // cellsFromPoints,
110  List<objectMap>(0), // cellsFromEdges,
111  List<objectMap>(0), // cellsFromFaces,
112  List<objectMap>(0), // cellsFromCells,
113  labelList(0), // reversePointMap,
114  labelList(0), // reverseFaceMap,
115  labelList(0), // reverseCellMap,
116  labelHashSet(0), // flipFaceFlux,
117  labelListList(0), // patchPointMap,
118  labelListList(0), // pointZoneMap,
119  labelListList(0), // faceZonePointMap,
120  labelListList(0), // faceZoneFaceMap,
121  labelListList(0), // cellZoneMap,
122  pointField(0), // preMotionPoints,
123  labelList(0), // oldPatchStarts,
124  labelList(0), // oldPatchNMeshPoints,
125  autoPtr<scalarField>() // oldCellVolumesPtr
126  );
127  refData.topoChange(map);
128  refData.write();
129 
130  Info<< "End" << endl;
131 
132  return 0;
133 }
134 
135 
136 // ************************************************************************* //
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
static unsigned int defaultPrecision()
Return the default precision.
Definition: IOstream.H:458
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:91
bool optionFound(const word &opt) const
Return true if the named option is found.
Definition: argListI.H:114
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:101
virtual bool write(const bool write=true) const
Write mesh using IO settings from time.
Definition: fvMesh.C:1736
Various for reading/decomposing/reconstructing/distributing refinement data.
Definition: hexRef8Data.H:58
static word defaultRegion
Return the default region name.
Definition: polyMesh.H:268
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
Definition: polyMesh.H:271
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
int main(int argc, char *argv[])
Definition: financialFoam.C:44
Namespace for OpenFOAM.
List< label > labelList
A List of labels.
Definition: labelList.H:56
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
IOobject systemDictIO(const word &dictName, const argList &args, const objectRegistry &ob, const word &regionName=polyMesh::defaultRegion)
Definition: systemDict.C:33
messageStream Info
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:42
List< labelList > labelListList
A List of labelList.
Definition: labelList.H:57
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
HashSet< label, Hash< label > > labelHashSet
A HashSet with label keys.
Definition: HashSet.H:211
Foam::argList args(argc, argv)