refinementSurfaces.H
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-2024 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 Class
25  Foam::refinementSurfaces
26 
27 Description
28  Container for data on surfaces used for surface-driven refinement.
29  Contains all the data about the level of refinement needed per
30  surface.
31 
32 SourceFiles
33  refinementSurfaces.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef refinementSurfaces_H
38 #define refinementSurfaces_H
39 
40 #include "primitiveFields.H"
41 #include "pointFields.H"
42 #include "vectorList.H"
43 #include "pointIndexHit.H"
44 #include "surfaceZonesInfo.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 
51 class searchableSurfaces;
52 class refinementRegions;
53 
54 typedef List<point> pointList;
55 
56 /*---------------------------------------------------------------------------*\
57  Class refinementSurfaces Declaration
58 \*---------------------------------------------------------------------------*/
59 
61 {
62  // Private Data
63 
64  //- Reference to all geometry.
65  const searchableSurfaces& allGeometry_;
66 
67  //- Indices of surfaces that are refinement ones
68  labelList surfaces_;
69 
70  //- Surface name (word)
71  wordList names_;
72 
73  //- List of surface zone (face and cell zone) information
74  PtrList<surfaceZonesInfo> surfZones_;
75 
76  //- From local region number to global region number
77  labelList regionOffset_;
78 
79  //- From global region number to refinement level
80  labelList minLevel_;
81 
82  //- From global region number to refinement level
83  labelList maxLevel_;
84 
85  //- From global region number to small-gap level
86  labelList gapLevel_;
87 
88  //- From global region number to perpendicular angle
89  scalarField perpendicularAngle_;
90 
91  //- From global region number to patchType
92  PtrList<dictionary> patchInfo_;
93 
94 
95 public:
96 
97  // Constructors
98 
99  //- Construct from surfaces and dictionary
101  (
102  const searchableSurfaces& allGeometry,
103  const dictionary&,
104  const label gapLevelIncrement
105  );
106 
107  //- Construct from components
109  (
110  const searchableSurfaces& allGeometry,
111  const labelList& surfaces,
112  const wordList& names,
114  const labelList& regionOffset,
115  const labelList& minLevel,
116  const labelList& maxLevel,
117  const labelList& gapLevel,
120  );
121 
122  //- Disallow default bitwise copy construction
123  refinementSurfaces(const refinementSurfaces&) = delete;
124 
125 
126  // Member Functions
127 
128  // Access
129 
130  const searchableSurfaces& geometry() const
131  {
132  return allGeometry_;
133  }
134 
135  const labelList& surfaces() const
136  {
137  return surfaces_;
138  }
139 
140  //- Names of surfaces
141  const wordList& names() const
142  {
143  return names_;
144  }
145 
146  const PtrList<surfaceZonesInfo>& surfZones() const
147  {
148  return surfZones_;
149  }
150 
151  //- From local region number to global region number
152  const labelList& regionOffset() const
153  {
154  return regionOffset_;
155  }
156 
157  //- From global region number to refinement level
158  const labelList& minLevel() const
159  {
160  return minLevel_;
161  }
162 
163  //- From global region number to refinement level
164  const labelList& maxLevel() const
165  {
166  return maxLevel_;
167  }
168 
169  //- From global region number to small gap refinement level
170  const labelList& gapLevel() const
171  {
172  return gapLevel_;
173  }
174 
175  //- From global region number to perpendicular angle
176  const scalarField& perpendicularAngle() const
177  {
178  return perpendicularAngle_;
179  }
180 
181  //- From global region number to patch type
182  const PtrList<dictionary>& patchInfo() const
183  {
184  return patchInfo_;
185  }
186 
187 
188  // Helper
189 
190  //- From surface and region on surface to global region
191  label globalRegion(const label surfi, const label regioni) const
192  {
193  return regionOffset_[surfi]+regioni;
194  }
195 
196  //- Min level for surface and region on surface
197  label minLevel(const label surfi, const label regioni) const
198  {
199  return minLevel_[globalRegion(surfi, regioni)];
200  }
201 
202  //- Max level for surface and region on surface
203  label maxLevel(const label surfi, const label regioni) const
204  {
205  return maxLevel_[globalRegion(surfi, regioni)];
206  }
207 
208  label nRegions() const
209  {
210  return minLevel_.size();
211  }
212 
213  //- Calculate the refinement level for every element
214  // of the searchablesurface
215  void setMinLevelFields
216  (
217  const refinementRegions& shells,
218  const scalar level0EdgeLength,
219  const bool extendedRefinementSpan
220  );
221 
222 
223  // Searching
224 
225  //- Find intersection of edge. Return -1 or first surface
226  // with higher (than currentLevel) minlevel.
227  // Return surface number and level.
229  (
230  const pointField& start,
231  const pointField& end,
232  const labelList& currentLevel, // current cell refinement level
233 
235  labelList& surfaceLevel
236  ) const;
237 
238  //- Find all intersections of edge. Unsorted order.
240  (
241  const pointField& start,
242  const pointField& end,
243  const labelList& currentLevel, // current cell refinement level
244  const labelList& globalRegionLevel, // level per surfregion
245 
246  List<vectorList>& surfaceNormal,
247  labelListList& surfaceLevel
248  ) const;
249 
250  //- Find all intersections of edge. Unsorted order.
252  (
253  const pointField& start,
254  const pointField& end,
255  const labelList& currentLevel, // current cell refinement level
256  const labelList& globalRegionLevel, // level per surfregion
257 
259  List<vectorList>& surfaceNormal,
260  labelListList& surfaceLevel
261  ) const;
262 
263  //- Find intersection nearest to the endpoints. surface1,2 are
264  // not indices into surfacesToTest but refinement surface indices.
265  // Returns surface, region on surface (so not global surface)
266  // and position on surface.
268  (
269  const labelList& surfacesToTest,
270  const pointField& start,
271  const pointField& end,
272 
273  labelList& surface1,
274  List<pointIndexHit>& hit1,
275  labelList& region1,
276  labelList& surface2,
277  List<pointIndexHit>& hit2,
278  labelList& region2
279  ) const;
280 
281  //- findNearestIntersection but also get normals
283  (
284  const labelList& surfacesToTest,
285  const pointField& start,
286  const pointField& end,
287 
288  labelList& surface1,
289  List<pointIndexHit>& hit1,
290  labelList& region1,
291  vectorField& normal1,
292 
293  labelList& surface2,
294  List<pointIndexHit>& hit2,
295  labelList& region2,
296  vectorField& normal2
297  ) const;
298 
299  //- Used for debugging only: find intersection of edge.
301  (
302  const pointField& start,
303  const pointField& end,
306  ) const;
307 
308  //- Find nearest point on surfaces.
309  void findNearest
310  (
311  const labelList& surfacesToTest,
312  const pointField& samples,
313  const scalarField& nearestDistSqr,
316  ) const;
317 
318  //- Find nearest point on surfaces. Return surface and region on
319  // surface (so not global surface)
320  void findNearestRegion
321  (
322  const labelList& surfacesToTest,
323  const pointField& samples,
324  const scalarField& nearestDistSqr,
325  labelList& hitSurface,
326  labelList& hitRegion
327  ) const;
328 
329  //- Find nearest point on surfaces. Return surface, region and
330  // normal on surface (so not global surface)
331  void findNearestRegion
332  (
333  const labelList& surfacesToTest,
334  const pointField& samples,
335  const scalarField& nearestDistSqr,
336  labelList& hitSurface,
337  List<pointIndexHit>& hitinfo,
338  labelList& hitRegion,
339  vectorField& hitNormal
340  ) const;
341 
342  //- Detect if a point is 'inside' (closed) surfaces.
343  // Returns -1 if not, returns first surface it is.
344  void findInside
345  (
346  const labelList& surfacesToTest,
347  const pointField& pt,
348  labelList& insideSurfaces
349  ) const;
350 
351 
352  // Member Operators
353 
354  //- Disallow default bitwise assignment
355  void operator=(const refinementSurfaces&) = delete;
356 };
357 
358 
359 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
360 
361 } // End namespace Foam
362 
363 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
364 
365 #endif
366 
367 // ************************************************************************* //
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:91
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: PtrList.H:75
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
Encapsulates queries for volume refinement ('refine all cells within shell').
Container for data on surfaces used for surface-driven refinement. Contains all the data about the le...
const wordList & names() const
Names of surfaces.
const scalarField & perpendicularAngle() const
From global region number to perpendicular angle.
void findAllHigherIntersections(const pointField &start, const pointField &end, const labelList &currentLevel, const labelList &globalRegionLevel, List< vectorList > &surfaceNormal, labelListList &surfaceLevel) const
Find all intersections of edge. Unsorted order.
void findNearest(const labelList &surfacesToTest, const pointField &samples, const scalarField &nearestDistSqr, labelList &surfaces, List< pointIndexHit > &) const
Find nearest point on surfaces.
refinementSurfaces(const searchableSurfaces &allGeometry, const dictionary &, const label gapLevelIncrement)
Construct from surfaces and dictionary.
const labelList & regionOffset() const
From local region number to global region number.
const PtrList< dictionary > & patchInfo() const
From global region number to patch type.
const labelList & minLevel() const
From global region number to refinement level.
const labelList & maxLevel() const
From global region number to refinement level.
void findInside(const labelList &surfacesToTest, const pointField &pt, labelList &insideSurfaces) const
Detect if a point is 'inside' (closed) surfaces.
void findNearestRegion(const labelList &surfacesToTest, const pointField &samples, const scalarField &nearestDistSqr, labelList &hitSurface, labelList &hitRegion) const
Find nearest point on surfaces. Return surface and region on.
void findAnyIntersection(const pointField &start, const pointField &end, labelList &surfaces, List< pointIndexHit > &) const
Used for debugging only: find intersection of edge.
void operator=(const refinementSurfaces &)=delete
Disallow default bitwise assignment.
const PtrList< surfaceZonesInfo > & surfZones() const
void findHigherIntersection(const pointField &start, const pointField &end, const labelList &currentLevel, labelList &surfaces, labelList &surfaceLevel) const
Find intersection of edge. Return -1 or first surface.
const searchableSurfaces & geometry() const
void setMinLevelFields(const refinementRegions &shells, const scalar level0EdgeLength, const bool extendedRefinementSpan)
Calculate the refinement level for every element.
void findNearestIntersection(const labelList &surfacesToTest, const pointField &start, const pointField &end, labelList &surface1, List< pointIndexHit > &hit1, labelList &region1, labelList &surface2, List< pointIndexHit > &hit2, labelList &region2) const
Find intersection nearest to the endpoints. surface1,2 are.
const labelList & surfaces() const
label globalRegion(const label surfi, const label regioni) const
From surface and region on surface to global region.
const labelList & gapLevel() const
From global region number to small gap refinement level.
Container for searchableSurfaces.
Contains information about location on a triSurface.
Namespace for OpenFOAM.
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< point > pointList
Specialisations of Field<T> for scalar, vector and tensor.
scalarField samples(nIntervals, 0)