autoDensity.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2012-2015 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::autoDensity
26 
27 Description
28  Choose random points inside the domain and place them with a probability
29  proportional to the target density of points.
30 
31 SourceFiles
32  autoDensity.C
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef autoDensity_H
37 #define autoDensity_H
38 
39 #include "initialPointsMethod.H"
40 #include "treeBoundBox.H"
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 namespace Foam
45 {
46 
47 /*---------------------------------------------------------------------------*\
48  Class autoDensity Declaration
49 \*---------------------------------------------------------------------------*/
50 
51 class autoDensity
52 :
53  public initialPointsMethod
54 {
55 
56 private:
57 
58  // Private data
59 
60  //- Trial points attempted to be placed in all boxes
61  mutable label globalTrialPoints_;
62 
63  //- Smallest minimum cell size allowed, i.e. to avoid high initial
64  // population of areas of small size
65  scalar minCellSizeLimit_;
66 
67  //- Minimum normal level of recursion, can be more if a high density
68  // ratio is detected
69  label minLevels_;
70 
71  //- Maximum allowed ratio of cell size in a box
72  scalar maxSizeRatio_;
73 
74  //- How fine should the initial sample of the volume a box be to
75  // investigate its cell sizes and volume fraction
76  label volRes_;
77 
78  //- How fine should the initial sample of the surface of a box be to
79  // investigate if it is near to a the geometry.
80  label surfRes_;
81 
82 
83  // Private Member Functions
84 
85  //- Check if the given box overlaps the geometry or, in parallel, the
86  // backgroundMeshDecomposition
87  bool combinedOverlaps(const treeBoundBox& box) const;
88 
89  //- Check if the given point is inside the geometry and, in parallel,
90  // the backgroundMeshDecomposition
91  bool combinedInside(const point& p) const;
92 
93  //- Check if the given points are wellInside the geometry and, in
94  // parallel, inside the backgroundMeshDecomposition
95  Field<bool> combinedWellInside
96  (
97  const pointField& pts,
98  const scalarField& sizes
99  ) const;
100 
101  //- Check if the given points are wellInside the geometry and, in
102  // parallel, inside the backgroundMeshDecomposition
103  bool combinedWellInside
104  (
105  const point& p,
106  scalar size
107  ) const;
108 
109  //- Write boundBox as obj
110  void writeOBJ
111  (
112  const treeBoundBox& bb,
113  fileName name
114  ) const;
115 
116  //- Descend into octants of the supplied bound box
117  label recurseAndFill
118  (
120  const treeBoundBox& bb,
121  label levelLimit,
122  word recursionName
123  ) const;
124 
125  //- Fill the given box, optionally filling surface overlapping boxes.
126  // Returns true if the fill is successful, false if it is to be aborted
127  // in favour of further recursion.
128  bool fillBox
129  (
130  DynamicList<Vb::Point>& initialPoints,
131  const treeBoundBox& bb,
132  bool overlapping
133  ) const;
134 
135 
136 public:
137 
138  //- Runtime type information
139  TypeName("autoDensity");
140 
141  // Constructors
142 
143  //- Construct from components
145  (
146  const dictionary& initialPointsDict,
147  const Time& runTime,
148  Random& rndGen,
152  );
153 
154 
155  //- Destructor
156  virtual ~autoDensity()
157  {}
158 
159 
160  // Member Functions
161 
162  //- Return the initial points for the conformalVoronoiMesh
163  virtual List<Vb::Point> initialPoints() const;
164 };
165 
166 
167 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
168 
169 } // End namespace Foam
170 
171 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
172 
173 #endif
174 
175 // ************************************************************************* //
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
A class for handling file names.
Definition: fileName.H:69
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:60
virtual ~autoDensity()
Destructor.
Definition: autoDensity.H:155
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
const cellShapeControl & cellShapeControls() const
const fileName & name() const
Return the dictionary name.
Definition: dictionary.H:103
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
Definition: DynamicList.H:56
autoDensity(const dictionary &initialPointsDict, const Time &runTime, Random &rndGen, const conformationSurfaces &geometryToConformTo, const cellShapeControl &cellShapeControls, const autoPtr< backgroundMeshDecomposition > &decomposition)
Construct from components.
A class for handling words, derived from string.
Definition: word.H:59
Abstract base class for generating initial points for a conformalVoronoiMesh.
virtual List< Vb::Point > initialPoints() const
Return the initial points for the conformalVoronoiMesh.
const backgroundMeshDecomposition & decomposition() const
Simple random number generator.
Definition: Random.H:49
TypeName("autoDensity")
Runtime type information.
const conformationSurfaces & geometryToConformTo() const
Choose random points inside the domain and place them with a probability proportional to the target d...
Definition: autoDensity.H:50
Standard boundBox + extra functionality for use in octree.
Definition: treeBoundBox.H:87
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
volScalarField & p
Namespace for OpenFOAM.