cellSizeFunction.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) 2012-2020 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::cellSizeFunction
26 
27 Description
28  Abstract base class for specifying target cell sizes
29 
30 SourceFiles
31  cellSizeFunction.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef cellSizeFunction_H
36 #define cellSizeFunction_H
37 
38 #include "point.H"
39 #include "conformalVoronoiMesh.H"
40 #include "searchableSurface.H"
41 #include "dictionary.H"
42 #include "autoPtr.H"
43 #include "runTimeSelectionTables.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 
51 /*---------------------------------------------------------------------------*\
52  Class cellSizeFunction Declaration
53 \*---------------------------------------------------------------------------*/
54 
55 class cellSizeFunction
56 :
57  public dictionary
58 {
59 
60 public:
61 
62  //- Surface side mode
63  enum sideMode
64  {
65  smInside, // Control inside the surface
66  smOutside, // Control outside the surface
67  rmBothsides // Control on both sides of a surface
68  };
69 
70  //- Runtime type information
71  TypeName("cellSizeFunction");
72 
73 
74 protected:
75 
76  // Static data
77 
78  //- Point closeness tolerance to a surface where the function "snaps" to
79  // including the surface
80  static scalar snapToSurfaceTol_;
81 
82 
83  // Protected data
84 
85  //- Reference to the searchableSurface that cellSizeFunction
86  // relates to
88 
89  //- Cell size at the surface
91 
93 
94  //- Method details dictionary
96 
97  const scalar& defaultCellSize_;
98 
99  //- Index of the region of the surface that this cell size function
100  // applies to
102 
103  //- Mode of size specification, i.e. inside, outside or bothSides
107 
108 
109 public:
110 
111  // Declare run-time constructor selection table
112 
114  (
115  autoPtr,
117  dictionary,
118  (
119  const dictionary& cellSizeFunctionDict,
120  const searchableSurface& surface,
121  const scalar& defaultCellSize,
122  const labelList regionIndices
123  ),
124  (cellSizeFunctionDict, surface, defaultCellSize, regionIndices)
125  );
126 
127 
128  // Constructors
129 
130  //- Construct from components
132  (
133  const word& type,
134  const dictionary& cellSizeFunctionDict,
135  const searchableSurface& surface,
136  const scalar& defaultCellSize,
137  const labelList regionIndices
138  );
139 
140  //- Disallow default bitwise copy construction
141  cellSizeFunction(const cellSizeFunction&) = delete;
142 
143 
144  // Selectors
145 
146  //- Return a reference to the selected cellSizeFunction
148  (
149  const dictionary& cellSizeFunctionDict,
150  const searchableSurface& surface,
151  const scalar& defaultCellSize,
152  const labelList regionIndices
153  );
154 
155 
156  //- Destructor
157  virtual ~cellSizeFunction();
158 
159 
160  // Member Functions
161 
162  //- Const access to the details dictionary
163  inline const dictionary& coeffsDict() const
164  {
165  return coeffsDict_;
166  }
167 
168  virtual bool sizeLocations
169  (
170  const pointIndexHit& hitPt,
171  const vector& n,
172  pointField& shapePts,
173  scalarField& shapeSizes
174  ) const = 0;
175 
176  //- Modify scalar argument to the cell size specified by function.
177  // Return a boolean specifying if the function was used, i.e. false if
178  // the point was not in range of the surface for a spatially varying
179  // size.
180  virtual bool cellSize
181  (
182  const point& pt,
183  scalar& size
184  ) const = 0;
185 
186 
187  virtual bool setCellSize
188  (
189  const pointField& pts
190  )
191  {
193  << "Not overloaded."
194  << endl;
195  return false;
196  }
198  label priority() const
199  {
200  return priority_;
201  }
202 
203 
204  // Member Operators
205 
206  //- Disallow default bitwise assignment
207  void operator=(const cellSizeFunction&) = delete;
208 };
209 
210 
211 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
212 
213 } // End namespace Foam
214 
215 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
216 
217 #endif
218 
219 // ************************************************************************* //
scalarField surfaceCellSize_
Cell size at the surface.
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
autoPtr< surfaceCellSizeFunction > surfaceCellSizeFunction_
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
Abstract base class for specifying target cell sizes.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
Definition: PointIndexHit.H:53
sideMode
Surface side mode.
Base class of (analytical or triangulated) surface. Encapsulates all the search routines. WIP.
declareRunTimeSelectionTable(autoPtr, cellSizeFunction, dictionary,(const dictionary &cellSizeFunctionDict, const searchableSurface &surface, const scalar &defaultCellSize, const labelList regionIndices),(cellSizeFunctionDict, surface, defaultCellSize, regionIndices))
TypeName("cellSizeFunction")
Runtime type information.
const labelList regionIndices_
Index of the region of the surface that this cell size function.
cellSizeFunction(const word &type, const dictionary &cellSizeFunctionDict, const searchableSurface &surface, const scalar &defaultCellSize, const labelList regionIndices)
Construct from components.
virtual bool setCellSize(const pointField &pts)
A class for handling words, derived from string.
Definition: word.H:59
const dictionary & coeffsDict() const
Const access to the details dictionary.
virtual bool cellSize(const point &pt, scalar &size) const =0
Modify scalar argument to the cell size specified by function.
virtual bool sizeLocations(const pointIndexHit &hitPt, const vector &n, pointField &shapePts, scalarField &shapeSizes) const =0
virtual ~cellSizeFunction()
Destructor.
dictionary coeffsDict_
Method details dictionary.
#define WarningInFunction
Report a warning using Foam::Warning.
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488
static scalar snapToSurfaceTol_
Point closeness tolerance to a surface where the function "snaps" to.
label n
const scalar & defaultCellSize_
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
static autoPtr< cellSizeFunction > New(const dictionary &cellSizeFunctionDict, const searchableSurface &surface, const scalar &defaultCellSize, const labelList regionIndices)
Return a reference to the selected cellSizeFunction.
Macros to ease declaration of run-time selection tables.
void operator=(const cellSizeFunction &)=delete
Disallow default bitwise assignment.
const searchableSurface & surface_
Reference to the searchableSurface that cellSizeFunction.
sideMode sideMode_
Mode of size specification, i.e. inside, outside or bothSides.
Namespace for OpenFOAM.