refinementRegions.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-2026 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::refinementRegions
26 
27 Description
28  Encapsulates queries for volume refinement ('refine all cells within
29  shell').
30 
31 SourceFiles
32  refinementRegions.C
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef refinementRegions_H
37 #define refinementRegions_H
38 
39 #include "Tuple2.H"
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 namespace Foam
45 {
46 
47 class searchableSurfaceList;
48 
49 /*---------------------------------------------------------------------------*\
50  Class refinementRegions Declaration
51 \*---------------------------------------------------------------------------*/
52 
54 {
55 public:
56 
57  // Public data types
58 
59  //- Volume refinement controls
60  enum class refineMode
61  {
62  inside, // Refine all inside shell
63  outside, // ,, outside
64  distance, // Refine based on distance to shell
65  insideSpan, // Refine based on distance internal span
66  outsideSpan // Refine based on distance external span
67  };
68 
69 
70 private:
71 
72  // Private Data
73 
74  //- Reference to all geometry.
75  const searchableSurfaceList& allGeometry_;
76 
77  //- Indices of surfaces that are shells
78  labelList shells_;
79 
80  //- Per shell whether to refine inside or outside
81  List<refineMode> modes_;
82 
83  //- Per shell the list of ranges
84  List<scalarField> distances_;
85 
86  //- Per shell per distance the refinement level
87  labelListList levels_;
88 
89  //- Number of cells across span for refinement mode span
90  labelList cellsAcrossSpan_;
91 
92  //- Surface closness field for refinement mode span
93  PtrList<scalarIOField> closeness_;
94 
95 
96  // Private Data
97 
98  //- refineMode names
99  static const NamedEnum<refineMode, 5> refineModeNames_;
100 
101 
102  // Private Member Functions
103 
104  //- Helper function for initialisation.
105  void setAndCheckLevels(const label shelli, const dictionary& dict);
106 
107  //- Specifically orient triSurfaces using a calculated point outside.
108  // Done since quite often triSurfaces not of consistent orientation
109  // which is (currently) necessary for sideness calculation
110  void orient();
111 
112  //- Interpolate the surface closeness field to the given point
113  scalar interpolate
114  (
115  const searchableSurfaces::triSurface& tris,
116  const scalarIOField& closeness,
117  const point& pt,
118  const label index
119  ) const;
120 
121  //- Find maximum level of a shell
122  void findHigherLevel
123  (
124  const pointField& pt,
125  const label shelli,
126  const scalar level0EdgeLength,
128  ) const;
129 
130 
131 public:
132 
133  // Constructors
134 
135  //- Construct from geometry and dictionary
137  (
138  const searchableSurfaceList& allGeometry,
139  const dictionary& shellsDict
140  );
141 
142 
143  // Member Functions
144 
145  // Query
146 
147  //- Highest shell level
148  label maxLevel() const;
149 
150  //- Find shell level higher than ptLevel
151  void findHigherLevel
152  (
153  const pointField& pt,
154  const labelList& ptLevel,
155  const scalar level0EdgeLength,
157  ) const;
158 };
159 
160 
161 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
162 
163 } // End namespace Foam
164 
165 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
166 
167 #endif
168 
169 // ************************************************************************* //
A primitive field of type <Type> with automated input and output.
Definition: IOField.H:53
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 keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Encapsulates queries for volume refinement ('refine all cells within shell').
refinementRegions(const searchableSurfaceList &allGeometry, const dictionary &shellsDict)
Construct from geometry and dictionary.
label maxLevel() const
Highest shell level.
refineMode
Volume refinement controls.
Container for searchableSurfaces.
A surface geometry formed of discrete facets, e.g. triangles and/or quadrilaterals,...
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
dictionary dict