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-2025 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 
33 {"wall", "external", "cellZone", "rotatingZone", "baffle"};
34 
35 
36 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
37 
38 Foam::label Foam::meshingSurface::nSurfaceParts
39 (
40  const searchableSurfaces::triSurface& surf
41 )
42 {
43  labelList faceZone;
44  return surf.markZones(boolList(surf.nEdges(), false), faceZone);
45 }
46 
47 
48 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
49 
51 :
52  path_(),
53  file_(),
54  name_(),
55  type_(surfaceType::wall),
56  boundBox_(),
57  closed_(),
58  inletRegions_(),
59  outletRegions_()
60 {}
61 
62 
63 Foam::meshingSurface::meshingSurface(const fileName& file, const Time& time)
64 :
65  path_(file.path()),
66  file_(file.name()),
67  name_(word(file_.lessExt())),
68  type_(surfaceType::wall),
69  boundBox_(),
70  closed_(),
71  nParts_(),
72  regions_(),
73  inletRegions_(),
74  outletRegions_()
75 {
76  searchableSurfaces::triSurface surf
77  (
78  IOobject
79  (
80  file_,
81  path_,
82  time
83  ),
84  triSurface(path_/file_)
85  );
86 
87  surf.cleanup(false);
88 
89  boundBox_ = Foam::boundBox(surf.points(), false);
90  closed_ = surf.hasVolumeType();
91  nParts_ = nSurfaceParts(surf);
92 
93  forAll(surf.patches(), i)
94  {
95  regions_.append(surf.patches()[i].name());
96  }
97 
98  // Add any region with name beginning "inlet" to inletRegions_
99  forAll(regions_, r)
100  {
101  if (!strncmp(regions_[r].c_str(), "inlet", 5))
102  {
103  inletRegions_.append(regions_[r]);
104  }
105  }
106 
107  // Add any region with name beginning "outlet" to outletRegions_
108  forAll(regions_, r)
109  {
110  if (!strncmp(regions_[r].c_str(), "outlet", 6))
111  {
112  outletRegions_.append(regions_[r]);
113  }
114  }
115 }
116 
117 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
118 
120 {}
121 
122 
123 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
124 
126 {
127  const word ext(file.ext());
128 
129  if (ext == "stl" || ext == "stlb" || ext == "obj" || ext == "vtk")
130  {
131  return true;
132  }
133 
134  return false;
135 }
136 
137 
138 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:433
Initialise the NamedEnum HashTable from the static list of names.
Definition: NamedEnum.H:55
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.
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
List< bool > boolList
Bool container classes.
Definition: boolList.H:50
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.