All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
splitBaffles.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-2022 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  splitBaffles
26 
27 Description
28  Detects faces that share points (baffles) and duplicates the points to
29  separate them
30 
31 \*---------------------------------------------------------------------------*/
32 
33 #include "argList.H"
34 #include "Time.H"
35 #include "polyTopoChange.H"
36 #include "localPointRegion.H"
37 #include "duplicatePoints.H"
38 #include "hexRef8Data.H"
39 #include "ReadFields.H"
40 #include "volFields.H"
41 #include "surfaceFields.H"
42 #include "pointFields.H"
43 
44 using namespace Foam;
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 int main(int argc, char *argv[])
49 {
51  (
52  "Detect faces that share points (baffles)\n"
53  "and duplicate the points to separate them."
54  );
55 
56  #include "addOverwriteOption.H"
57  #include "addRegionOption.H"
59  (
60  "fields",
61  "update fields"
62  );
63 
64  #include "setRootCase.H"
65  #include "createTime.H"
66  runTime.functionObjects().off();
67  #include "createNamedMesh.H"
68 
69  const bool overwrite = args.optionFound("overwrite");
70  const bool fields = args.optionFound("fields");
71 
72  const word oldInstance = mesh.pointsInstance();
73 
74  // Read objects in time directory
75  IOobjectList objects(mesh, runTime.timeName());
76 
77  if (fields) Info<< "Reading geometric fields" << nl << endl;
78 
79  #include "readVolFields.H"
80  #include "readSurfaceFields.H"
81  #include "readPointFields.H"
82 
83  // Mesh change engine
84  polyTopoChange meshMod(mesh);
85 
86  // Analyse which points need to be duplicated
88 
89  // Point duplication engine
90  duplicatePoints pointDuplicator(mesh);
91 
92  // Insert topo changes
93  pointDuplicator.setRefinement(regionSide, meshMod);
94 
95  hexRef8Data refData
96  (
97  IOobject
98  (
99  "dummy",
102  mesh,
105  false
106  )
107  );
108 
109  if (!overwrite)
110  {
111  runTime++;
112  }
113 
114  // Change the mesh. No inflation.
115  autoPtr<polyTopoChangeMap> map = meshMod.changeMesh(mesh, false);
116 
117  // Update fields
118  mesh.topoChange(map);
119 
120  // Move mesh (since morphing does not do this)
121  if (map().hasMotionPoints())
122  {
123  mesh.setPoints(map().preMotionPoints());
124  }
125 
126  if (overwrite)
127  {
128  mesh.setInstance(oldInstance);
129  }
130 
131  Info<< "Writing mesh to time " << runTime.timeName() << endl;
132  mesh.write();
133 
134  refData.topoChange(map);
135  refData.write();
136 
137  Info<< "End\n" << endl;
138 
139  return 0;
140 }
141 
142 
143 // ************************************************************************* //
Foam::surfaceFields.
List of IOobjects with searching and retrieving facilities.
Definition: IOobjectList.H:50
const fileName & facesInstance() const
Return the current instance directory for faces.
Definition: polyMesh.C:888
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
Definition: polyMesh.H:328
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
Field reading functions for post-processing utilities.
virtual bool write(const bool write=true) const
Write mesh using IO settings from time.
Definition: fvMesh.C:1658
fvMesh & mesh
virtual void topoChange(const polyTopoChangeMap &map)
Update mesh corresponding to the given map.
Definition: fvMesh.C:1151
Takes mesh with &#39;baffles&#39; (= boundary faces sharing points). Determines for selected points on bounda...
Determines the &#39;side&#39; for every face and connected to a singly-connected (through edges) region of fa...
Definition: regionSide.H:61
const fileName & pointsInstance() const
Return the current instance directory for points.
Definition: polyMesh.C:882
Duplicate points.
A class for handling words, derived from string.
Definition: word.H:59
virtual void setPoints(const pointField &)
Reset the points.
Definition: fvMesh.C:1048
static const char nl
Definition: Ostream.H:260
objects
void setInstance(const fileName &)
Set the instance for mesh files.
Definition: polyMeshIO.C:77
Direct mesh changes based on v1.3 polyTopoChange syntax.
messageStream Info
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
static void addBoolOption(const word &opt, const string &usage="")
Add to a bool option to validOptions with usage information.
Definition: argList.C:118
static void addNote(const string &)
Add extra notes for the usage information.
Definition: argList.C:159
Foam::argList args(argc, argv)
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:98
Namespace for OpenFOAM.