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-2018 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 private:
110 
111  // Private Member Functions
112 
113  //- Disallow default bitwise copy construct
115 
116  //- Disallow default bitwise assignment
117  void operator=(const cellSizeFunction&);
118 
119 
120 public:
121 
122  // Declare run-time constructor selection table
123 
125  (
126  autoPtr,
128  dictionary,
129  (
130  const dictionary& cellSizeFunctionDict,
131  const searchableSurface& surface,
132  const scalar& defaultCellSize,
133  const labelList regionIndices
134  ),
135  (cellSizeFunctionDict, surface, defaultCellSize, regionIndices)
136  );
137 
138 
139  // Constructors
140 
141  //- Construct from components
143  (
144  const word& type,
145  const dictionary& cellSizeFunctionDict,
146  const searchableSurface& surface,
147  const scalar& defaultCellSize,
148  const labelList regionIndices
149  );
150 
151 
152  // Selectors
153 
154  //- Return a reference to the selected cellSizeFunction
156  (
157  const dictionary& cellSizeFunctionDict,
158  const searchableSurface& surface,
159  const scalar& defaultCellSize,
160  const labelList regionIndices
161  );
162 
163 
164  //- Destructor
165  virtual ~cellSizeFunction();
166 
167 
168  // Member Functions
169 
170  //- Const access to the details dictionary
171  inline const dictionary& coeffsDict() const
172  {
173  return coeffsDict_;
174  }
175 
176  virtual bool sizeLocations
177  (
178  const pointIndexHit& hitPt,
179  const vector& n,
180  pointField& shapePts,
181  scalarField& shapeSizes
182  ) const = 0;
183 
184  //- Modify scalar argument to the cell size specified by function.
185  // Return a boolean specifying if the function was used, i.e. false if
186  // the point was not in range of the surface for a spatially varying
187  // size.
188  virtual bool cellSize
189  (
190  const point& pt,
191  scalar& size
192  ) const = 0;
193 
194 
195  virtual bool setCellSize
196  (
197  const pointField& pts
198  )
199  {
201  << "Not overloaded."
202  << endl;
203  return false;
204  }
206  label priority() const
207  {
208  return priority_;
209  }
210 };
211 
212 
213 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
214 
215 } // End namespace Foam
216 
217 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
218 
219 #endif
220 
221 // ************************************************************************* //
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:137
Abstract base class for specifying target cell sizes.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:256
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.
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
fileName::Type type(const fileName &, const bool followLink=true)
Return the file type: DIRECTORY or FILE.
Definition: POSIX.C:481
virtual ~cellSizeFunction()
Destructor.
dictionary coeffsDict_
Method details dictionary.
#define WarningInFunction
Report a warning using Foam::Warning.
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.
const searchableSurface & surface_
Reference to the searchableSurface that cellSizeFunction.
sideMode sideMode_
Mode of size specification, i.e. inside, outside or bothSides.
Namespace for OpenFOAM.