Loading...
Searching...
No Matches
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-2024 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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
27Application
28 mirrorMesh
29
30Group
31 grpMeshManipulationUtilities
32
33Description
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
44using namespace Foam;
45
46// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47
48int 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 (
75 (
77 runTime.constant(),
79 ),
80 mirrorDict
81 );
82
83 hexRef8Data refData
84 (
86 (
87 "dummy",
88 mesh.facesInstance(),
90 mesh,
94 )
95 );
96
97 if (!overwrite)
98 {
99 ++runTime;
100 mesh.setInstance(runTime.timeName());
101 }
102
103
104 // More precision (for points data)
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// ************************************************************************* //
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
@ NO_REGISTER
Do not request registration (bool: false).
@ READ_IF_PRESENT
Reading is optional [identical to LAZY_READ].
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition IOobject.H:191
static unsigned int minPrecision(unsigned int prec) noexcept
Set the minimum default precision.
Definition IOstream.H:459
static void setAdvanced(const word &optName, bool advanced=true)
Set an existing option as being 'advanced' or normal.
Definition argList.C:419
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:400
static void addNote(const string &note)
Add extra notes for the usage information.
Definition argList.C:477
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
Mesh data needed to do the Finite Volume discretisation.
Definition fvMesh.H:85
virtual bool write(const bool writeOnProc=true) const
Write mesh using IO settings from time.
Definition fvMesh.C:1068
Various for reading/decomposing/reconstructing/distributing refinement data.
Definition hexRef8Data.H:57
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
static word defaultRegion
Return the default region name.
Definition polyMesh.H:406
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh").
Definition polyMesh.H:411
A class for handling words, derived from Foam::string.
Definition word.H:66
dynamicFvMesh & mesh
engineTime & runTime
const word dictName("faMeshDefinition")
Namespace for OpenFOAM.
List< labelList > labelListList
List of labelList.
Definition labelList.H:38
List< label > labelList
A List of labels.
Definition List.H:62
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
Definition HashSet.H:85
messageStream Info
Information stream (stdout output on master, null elsewhere).
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
vectorField pointField
pointField is a vectorField.
constexpr char nl
The newline '\n' character (0x0a).
Definition Ostream.H:50
IOobject dictIO
Foam::argList args(argc, argv)