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-2021 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 "ReadFields.H"
39 #include "volFields.H"
40 #include "surfaceFields.H"
41 #include "pointFields.H"
42 
43 using namespace Foam;
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 int main(int argc, char *argv[])
48 {
50  (
51  "Detect faces that share points (baffles)\n"
52  "and duplicate the points to separate them."
53  );
54 
55  #include "addOverwriteOption.H"
56  #include "addRegionOption.H"
58  (
59  "fields",
60  "update fields"
61  );
62 
63  #include "setRootCase.H"
64  #include "createTime.H"
66  #include "createNamedMesh.H"
67 
68  const bool overwrite = args.optionFound("overwrite");
69  const bool fields = args.optionFound("fields");
70 
71  const word oldInstance = mesh.pointsInstance();
72 
73  // Read objects in time directory
75 
76  if (fields) Info<< "Reading geometric fields" << nl << endl;
77 
78  #include "readVolFields.H"
79  #include "readSurfaceFields.H"
80  #include "readPointFields.H"
81 
82  // Mesh change engine
83  polyTopoChange meshMod(mesh);
84 
85  // Analyse which points need to be duplicated
87 
88  // Point duplication engine
89  duplicatePoints pointDuplicator(mesh);
90 
91  // Insert topo changes
92  pointDuplicator.setRefinement(regionSide, meshMod);
93 
94  if (!overwrite)
95  {
96  runTime++;
97  }
98 
99  // Change the mesh. No inflation.
100  autoPtr<mapPolyMesh> map = meshMod.changeMesh(mesh, false);
101 
102  // Update fields
103  mesh.updateMesh(map);
104 
105  // Move mesh (since morphing does not do this)
106  if (map().hasMotionPoints())
107  {
108  mesh.movePoints(map().preMotionPoints());
109  }
110 
111  if (overwrite)
112  {
113  mesh.setInstance(oldInstance);
114  }
115 
116  Info<< "Writing mesh to time " << runTime.timeName() << endl;
117  mesh.write();
118 
119  Info<< "End\n" << endl;
120 
121  return 0;
122 }
123 
124 
125 // ************************************************************************* //
Foam::surfaceFields.
List of IOobjects with searching and retrieving facilities.
Definition: IOobjectList.H:50
void off()
Switch the function objects off.
engineTime & runTime
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.
static word timeName(const scalar, const int precision=precision_)
Return time name of given scalar time.
Definition: Time.C:636
virtual bool write(const bool write=true) const
Write mesh using IO settings from time.
Definition: fvMesh.C:1093
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:802
Duplicate points.
virtual void updateMesh(const mapPolyMesh &mpm)
Update mesh corresponding to the given map.
Definition: fvMesh.C:795
dynamicFvMesh & mesh
A class for handling words, derived from string.
Definition: word.H:59
static const char nl
Definition: Ostream.H:260
objects
void setInstance(const fileName &)
Set the instance for mesh files.
Definition: polyMeshIO.C:32
virtual tmp< scalarField > movePoints(const pointField &)
Move points, returns volumes swept by faces in motion.
Definition: fvMesh.C:716
const functionObjectList & functionObjects() const
Return the list of function objects.
Definition: Time.H:410
Direct mesh changes based on v1.3 polyTopoChange syntax.
messageStream Info
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)
Namespace for OpenFOAM.