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-2023 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"
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
74  IOobjectList objects(mesh, runTime.name());
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  hexRef8Data refData
95  (
96  IOobject
97  (
98  "dummy",
99  mesh.facesInstance(),
101  mesh,
104  false
105  )
106  );
107 
108  if (!overwrite)
109  {
110  runTime++;
111  }
112 
113  // Change the mesh. No inflation.
114  autoPtr<polyTopoChangeMap> map = meshMod.changeMesh(mesh, false);
115 
116  // Update fields
117  mesh.topoChange(map);
118 
119  // Move mesh (since morphing does not do this)
120  if (map().hasMotionPoints())
121  {
122  mesh.setPoints(map().preMotionPoints());
123  }
124 
125  if (overwrite)
126  {
127  mesh.setInstance(oldInstance);
128  }
129 
130  Info<< "Writing mesh to time " << runTime.name() << endl;
131  mesh.write();
132 
133  refData.topoChange(map);
134  refData.write();
135 
136  Info<< "End\n" << endl;
137 
138  return 0;
139 }
140 
141 
142 // ************************************************************************* //
Field reading functions for post-processing utilities.
List of IOobjects with searching and retrieving facilities.
Definition: IOobjectList.H:53
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
virtual Ostream & write(const char)=0
Write character.
static void addNote(const string &)
Add extra notes for the usage information.
Definition: argList.C:159
static void addBoolOption(const word &opt, const string &usage="")
Add to a bool option to validOptions with usage information.
Definition: argList.C:118
bool optionFound(const word &opt) const
Return true if the named option is found.
Definition: argListI.H:114
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
Duplicate points.
Various for reading/decomposing/reconstructing/distributing refinement data.
Definition: hexRef8Data.H:58
Takes mesh with 'baffles' (= boundary faces sharing points). Determines for selected points on bounda...
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
Definition: polyMesh.H:271
Direct mesh changes based on v1.3 polyTopoChange syntax.
Determines the 'side' for every face and connected to a singly-connected (through edges) region of fa...
Definition: regionSide.H:62
A class for handling words, derived from string.
Definition: word.H:62
int main(int argc, char *argv[])
Definition: financialFoam.C:44
Info<< "Calculating turbulent flame speed field St\n"<< endl;volScalarField St(IOobject("St", runTime.name(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE), flameWrinkling->Xi() *Su);multivariateSurfaceInterpolationScheme< scalar >::fieldTable fields
Definition: createFields.H:230
Namespace for OpenFOAM.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
messageStream Info
static const char nl
Definition: Ostream.H:260
objects
Foam::argList args(argc, argv)
Foam::surfaceFields.