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" << nl << endl;
150 
151  return 0;
152 }
153 
154 
155 // ************************************************************************* //
Foam::IOobject::NO_WRITE
Definition: IOobject.H:130
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:71
Foam::pointField
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:44
Foam::IOdictionary
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:54
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:104
Foam::IOobject::name
const word & name() const
Return name.
Definition: IOobjectI.H:70
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::fvMesh::write
virtual bool write(const bool valid=true) const
Write mesh using IO settings from time.
Definition: fvMesh.C:895
setSystemRunTimeDictionaryIO.H
Foam::polyMesh::defaultRegion
static word defaultRegion
Return the default region name.
Definition: polyMesh.H:312
Foam::mirrorFvMesh
Definition: mirrorFvMesh.H:49
addOverwriteOption.H
Foam::primitiveMesh::nFaces
label nFaces() const
Number of mesh faces.
Definition: primitiveMeshI.H:90
mapPolyMesh.H
Foam::polyMesh::meshSubDir
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
Definition: polyMesh.H:315
Foam::Time::timeName
static word timeName(const scalar t, const int precision=precision_)
Definition: Time.C:785
Foam::argList::addNote
static void addNote(const string &note)
Add extra notes for the usage information.
Definition: argList.C:413
dictName
const word dictName("blockMeshDict")
Foam::polyMesh::facesInstance
const fileName & facesInstance() const
Return the current instance directory for faces.
Definition: polyMesh.C:821
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:350
Foam::primitiveMesh::nCells
label nCells() const
Number of mesh cells.
Definition: primitiveMeshI.H:96
Foam::Info
messageStream Info
Information stream (uses stdout - output is on the master only)
argList.H
Foam::IOobject::READ_IF_PRESENT
Definition: IOobject.H:122
Foam::argList::setAdvanced
static void setAdvanced(const word &optName, bool advanced=true)
Set an existing option as being 'advanced' or normal.
Definition: argList.C:355
Foam::max
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
Foam::hexRef8Data
Various for reading/decomposing/reconstructing/distributing refinement data.
Definition: hexRef8Data.H:60
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:84
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Time.H
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::labelListList
List< labelList > labelListList
A List of labelList.
Definition: labelList.H:56
setRootCase.H
Foam::nl
constexpr char nl
Definition: Ostream.H:385
Foam::IOstream::defaultPrecision
static unsigned int defaultPrecision()
Return the default precision.
Definition: IOstream.H:333
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:102
Foam::primitiveMesh::nPoints
label nPoints() const
Number of mesh points.
Definition: primitiveMeshI.H:37
createTime.H
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:160
Foam::labelHashSet
HashSet< label, Hash< label > > labelHashSet
A HashSet with label keys and label hasher.
Definition: HashSet.H:410
Foam::TimePaths::constant
const word & constant() const
Return constant name.
Definition: TimePathsI.H:88
Foam::argList::addOption
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:336
args
Foam::argList args(argc, argv)
Foam::polyMesh::setInstance
void setInstance(const fileName &instance, const IOobject::writeOption wOpt=IOobject::AUTO_WRITE)
Set the instance for mesh files.
Definition: polyMeshIO.C:36
mirrorFvMesh.H
Foam::argList::found
bool found(const word &optName) const
Return true if the named option is found.
Definition: argListI.H:157