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,
93  false
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 // ************************************************************************* //
Foam::IOobject::NO_WRITE
@ NO_WRITE
Definition: IOobject.H:191
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:63
Foam::pointField
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:38
Foam::IOdictionary
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:50
runTime
engineTime & runTime
Definition: createEngineTime.H:13
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:165
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:63
Foam::fvMesh::write
virtual bool write(const bool valid=true) const
Definition: fvMesh.C:1034
setSystemRunTimeDictionaryIO.H
Foam::polyMesh::defaultRegion
static word defaultRegion
Definition: polyMesh.H:314
Foam::mirrorFvMesh
Definition: mirrorFvMesh.H:45
addOverwriteOption.H
mapPolyMesh.H
dictName
const word dictName("faMeshDefinition")
Foam::polyMesh::meshSubDir
static word meshSubDir
Definition: polyMesh.H:317
Foam::Time::timeName
static word timeName(const scalar t, const int precision=precision_)
Definition: Time.C:773
Foam::argList::addNote
static void addNote(const string &note)
Definition: argList.C:405
Foam::polyMesh::facesInstance
const fileName & facesInstance() const
Definition: polyMesh.C:845
Foam::endl
Ostream & endl(Ostream &os)
Definition: Ostream.H:381
Foam::primitiveMesh::nPoints
label nPoints() const noexcept
Definition: primitiveMeshI.H:30
Foam::primitiveMesh::nCells
label nCells() const noexcept
Definition: primitiveMeshI.H:89
Foam::Info
messageStream Info
argList.H
Foam::IOobject::READ_IF_PRESENT
@ READ_IF_PRESENT
Definition: IOobject.H:183
Foam::argList::setAdvanced
static void setAdvanced(const word &optName, bool advanced=true)
Definition: argList.C:347
Foam::max
label max(const labelHashSet &set, label maxValue=labelMin)
Definition: hashSets.C:40
Foam::hexRef8Data
Various for reading/decomposing/reconstructing/distributing refinement data.
Definition: hexRef8Data.H:56
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
dictIO
IOobject dictIO
Definition: setConstantMeshDictionaryIO.H:1
hexRef8Data.H
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:81
Foam
Definition: atmBoundaryLayer.C:26
Foam::IOobject::name
const word & name() const noexcept
Definition: IOobjectI.H:58
Foam::IOstream::defaultPrecision
static unsigned int defaultPrecision() noexcept
Definition: IOstream.H:338
Time.H
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:49
Foam::labelListList
List< labelList > labelListList
A List of labelList.
Definition: labelList.H:51
setRootCase.H
Foam::nl
constexpr char nl
Definition: Ostream.H:424
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:58
createTime.H
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:157
Foam::primitiveMesh::nFaces
label nFaces() const noexcept
Definition: primitiveMeshI.H:83
Foam::labelHashSet
HashSet< label, Hash< label > > labelHashSet
A HashSet with label keys and label hasher.
Definition: HashSet.H:85
Foam::TimePaths::constant
const word & constant() const
Definition: TimePathsI.H:89
Foam::argList::addOption
static void addOption(const word &optName, const string &param="", const string &usage="", bool advanced=false)
Definition: argList.C:328
args
Foam::argList args(argc, argv)
Foam::polyMesh::setInstance
void setInstance(const fileName &instance, const IOobject::writeOption wOpt=IOobject::AUTO_WRITE)
Definition: polyMeshIO.C:29
mirrorFvMesh.H
Foam::argList::found
bool found(const word &optName) const
Definition: argListI.H:171