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 -------------------------------------------------------------------------------
11 License
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 
27 Application
28  mirrorMesh
29 
30 Group
31  grpMeshManipulationUtilities
32 
33 Description
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 
44 using namespace Foam;
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 int main(int argc, char *argv[])
49 {
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  (
74  IOobject
75  (
77  runTime.constant(),
78  runTime
79  ),
80  mirrorDict
81  );
82 
83  hexRef8Data refData
84  (
85  IOobject
86  (
87  "dummy",
90  mesh,
94  )
95  );
96 
97  if (!overwrite)
98  {
99  ++runTime;
101  }
102 
103 
104  // Set the precision of the points data to 10
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 // ************************************************************************* //
static void addNote(const string &note)
Add extra notes for the usage information.
Definition: argList.C:462
static void setAdvanced(const word &optName, bool advanced=true)
Set an existing option as being &#39;advanced&#39; or normal.
Definition: argList.C:404
const fileName & facesInstance() const
Return the current instance directory for faces.
Definition: polyMesh.C:854
label nPoints() const noexcept
Number of mesh points.
const word & name() const noexcept
Return the object name.
Definition: IOobjectI.H:162
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:56
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:40
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:49
const word dictName("faMeshDefinition")
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
Definition: polyMesh.H:402
engineTime & runTime
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:487
static unsigned int defaultPrecision() noexcept
Return the default precision.
Definition: IOstream.H:423
Ignore writing from objectRegistry::writeObject()
label nFaces() const noexcept
Number of mesh faces.
List< labelList > labelListList
List of labelList.
Definition: labelList.H:38
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:157
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:50
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
Definition: HashSet.H:85
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:38
dynamicFvMesh & mesh
A class for handling words, derived from Foam::string.
Definition: word.H:63
static word defaultRegion
Return the default region name.
Definition: polyMesh.H:397
Reading is optional [identical to LAZY_READ].
static void addOption(const word &optName, const string &param="", const string &usage="", bool advanced=false)
Add an option to validOptions with usage information.
Definition: argList.C:385
virtual bool write(const bool writeOnProc=true) const
Write mesh using IO settings from time.
Definition: fvMesh.C:1069
static word timeName(const scalar t, const int precision=precision_)
Return time name of given scalar time formatted with the given precision.
Definition: Time.C:770
const word & constant() const noexcept
Return constant name.
Definition: TimePathsI.H:89
void setInstance(const fileName &instance, const IOobjectOption::writeOption wOpt=IOobject::AUTO_WRITE)
Set the instance for mesh files.
Definition: polyMeshIO.C:29
label nCells() const noexcept
Number of mesh cells.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:79
messageStream Info
Information stream (stdout output on master, null elsewhere)
IOobject dictIO
Various for reading/decomposing/reconstructing/distributing refinement data.
Definition: hexRef8Data.H:56
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
List< label > labelList
A List of labels.
Definition: List.H:62
Foam::argList args(argc, argv)
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:171
Do not request registration (bool: false)
bool found(const word &optName) const
Return true if the named option is found.
Definition: argListI.H:171
Namespace for OpenFOAM.