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-2024 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 "addRegionOption.H"
47  #include "addDictOption.H"
48 
49  #include "setRootCase.H"
50  #include "createTime.H"
51 
52  const word regionName =
54 
55  const bool overwrite = args.optionFound("overwrite");
56 
57  mirrorFvMesh mesh
58  (
59  IOobject
60  (
61  regionName,
62  runTime.constant(),
63  runTime
64  ),
65  systemDictIO("mirrorMeshDict", args, runTime)
66  );
67 
68  hexRef8Data refData
69  (
70  IOobject
71  (
72  "dummy",
73  mesh.facesInstance(),
75  mesh,
78  false
79  )
80  );
81 
82  if (!overwrite)
83  {
84  runTime++;
85  mesh.setInstance(runTime.name());
86  }
87 
88 
89  // Set the precision of the points data to 10
91 
92  // Generate the mirrored mesh
93  const fvMesh& mMesh = mesh.mirrorMesh();
94 
95  const_cast<fvMesh&>(mMesh).setInstance(mesh.facesInstance());
96  Info<< "Writing mirrored mesh" << endl;
97  mMesh.write();
98 
99  // Map the hexRef8 data
101  (
102  mesh,
103  mesh.nPoints(), // nOldPoints,
104  mesh.nFaces(), // nOldFaces,
105  mesh.nCells(), // nOldCells,
106  move(mesh.pointMap()), // pointMap,
107  List<objectMap>(0), // pointsFromPoints,
108  labelList(0), // faceMap,
109  List<objectMap>(0), // facesFromFaces,
110  move(mesh.cellMap()), // cellMap,
111  List<objectMap>(0), // cellsFromCells,
112  labelList(0), // reversePointMap,
113  labelList(0), // reverseFaceMap,
114  labelList(0), // reverseCellMap,
115  labelHashSet(0), // flipFaceFlux,
116  labelListList(0), // patchPointMap,
117  labelList(0), // oldPatchSizes,
118  labelList(0), // oldPatchStarts,
119  labelList(0), // oldPatchNMeshPoints,
120  autoPtr<scalarField>() // oldCellVolumesPtr
121  );
122  refData.topoChange(map);
123  refData.write();
124 
125  Info<< "End" << endl;
126 
127  return 0;
128 }
129 
130 
131 // ************************************************************************* //
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
T optionLookupOrDefault(const word &opt, const T &deflt) const
Read a value from the named option if present.
Definition: argListI.H:243
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:99
virtual bool write(const bool write=true) const
Write mesh using IO settings from time.
Definition: fvMesh.C:1737
Various for reading/decomposing/reconstructing/distributing refinement data.
Definition: hexRef8Data.H:58
static word defaultRegion
Return the default region name.
Definition: polyMesh.H:267
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
Definition: polyMesh.H:270
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
A class for handling words, derived from string.
Definition: word.H:62
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:257
const word & regionName(const solver &region)
Definition: solver.H:209
IOobject systemDictIO(const word &dictName, const argList &args, const objectRegistry &ob, const word &regionName=polyMesh::defaultRegion)
Definition: systemDict.C:33
messageStream Info
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:213
Foam::argList args(argc, argv)