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