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