meshingSurface.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) 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 \*---------------------------------------------------------------------------*/
25 
26 #include "meshingSurface.H"
27 #include "triSurface.H"
28 
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33  template<>
35  {"wall", "external", "cellZone", "rotatingZone", "baffle"};
36 }
37 
38 
41 
42 
43 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
44 
45 Foam::label Foam::meshingSurface::nSurfaceParts(const triSurfaceMesh& surf)
46 {
47  labelList faceZone;
48  return surf.markZones(boolList(surf.nEdges(), false), faceZone);
49 }
50 
51 
52 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
53 
55 :
56  path_(),
57  file_(),
58  name_(),
59  type_(surfaceType::wall),
60  boundBox_(),
61  closed_(),
62  inletRegions_(),
63  outletRegions_()
64 {}
65 
66 
67 Foam::meshingSurface::meshingSurface(const fileName& file, const Time& time)
68 :
69  path_(file.path()),
70  file_(file.name()),
71  name_(word(file_.lessExt())),
72  type_(surfaceType::wall),
73  boundBox_(),
74  closed_(),
75  nParts_(),
76  regions_(),
77  inletRegions_(),
78  outletRegions_()
79 {
80  triSurfaceMesh surf
81  (
82  IOobject
83  (
84  file_,
85  path_,
86  time
87  ),
88  triSurface(path_/file_)
89  );
90 
91  surf.cleanup(false);
92 
93  boundBox_ = Foam::boundBox(surf.points(), false);
94  closed_ = surf.hasVolumeType();
95  nParts_ = nSurfaceParts(surf);
96 
97  forAll(surf.patches(), i)
98  {
99  regions_.append(surf.patches()[i].name());
100  }
101 
102  // Add any region with name beginning "inlet" to inletRegions_
103  forAll(regions_, r)
104  {
105  if (!strncmp(regions_[r].c_str(), "inlet", 5))
106  {
107  inletRegions_.append(regions_[r]);
108  }
109  }
110 
111  // Add any region with name beginning "outlet" to outletRegions_
112  forAll(regions_, r)
113  {
114  if (!strncmp(regions_[r].c_str(), "outlet", 6))
115  {
116  outletRegions_.append(regions_[r]);
117  }
118  }
119 }
120 
121 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
122 
124 {}
125 
126 
127 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
128 
130 {
131  const word ext(file.ext());
132 
133  if (ext == "stl" || ext == "stlb" || ext == "obj" || ext == "vtk")
134  {
135  return true;
136  }
137 
138  return false;
139 }
140 
141 
142 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
Initialise the NamedEnum HashTable from the static list of names.
Definition: NamedEnum.H:54
static const char * names[nEnum]
The set of names corresponding to the enumeration Enum.
Definition: NamedEnum.H:69
A bounding box defined in terms of the points at its extremities.
Definition: boundBox.H:59
A class for handling file names.
Definition: fileName.H:82
meshingSurface()
Construct null.
static const NamedEnum< surfaceType, 5 > surfaceTypeNames
Enumeration names for surfaceTypes.
static bool isSurfaceExt(const fileName &file)
~meshingSurface()
Destructor.
Namespace for OpenFOAM.
List< label > labelList
A List of labels.
Definition: labelList.H:56
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
word name(const bool)
Return a word representation of a bool.
Definition: boolIO.C:39
List< bool > boolList
Bool container classes.
Definition: boolList.H:50