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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2012-2015 OpenFOAM Foundation
9  Copyright (C) 2019 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::autoDensity
29 
30 Description
31  Choose random points inside the domain and place them with a probability
32  proportional to the target density of points.
33 
34 SourceFiles
35  autoDensity.C
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef autoDensity_H
40 #define autoDensity_H
41 
42 #include "initialPointsMethod.H"
43 #include "treeBoundBox.H"
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 /*---------------------------------------------------------------------------*\
51  Class autoDensity Declaration
52 \*---------------------------------------------------------------------------*/
53 
54 class autoDensity
55 :
56  public initialPointsMethod
57 {
58 
59 private:
60 
61  // Private data
62 
63  //- Trial points attempted to be placed in all boxes
64  mutable label globalTrialPoints_;
65 
66  //- Smallest minimum cell size allowed, i.e. to avoid high initial
67  // population of areas of small size
68  scalar minCellSizeLimit_;
69 
70  //- Minimum normal level of recursion, can be more if a high density
71  // ratio is detected
72  label minLevels_;
73 
74  //- Maximum allowed ratio of cell size in a box
75  scalar maxSizeRatio_;
76 
77  //- How fine should the initial sample of the volume a box be to
78  // investigate its cell sizes and volume fraction
79  label volRes_;
80 
81  //- How fine should the initial sample of the surface of a box be to
82  // investigate if it is near to a the geometry.
83  label surfRes_;
84 
85 
86  // Private Member Functions
87 
88  //- Check if the given box overlaps the geometry or, in parallel, the
89  // backgroundMeshDecomposition
90  bool combinedOverlaps(const treeBoundBox& box) const;
91 
92  //- Check if the given point is inside the geometry and, in parallel,
93  // the backgroundMeshDecomposition
94  bool combinedInside(const point& p) const;
95 
96  //- Check if the given points are wellInside the geometry and, in
97  // parallel, inside the backgroundMeshDecomposition
98  Field<bool> combinedWellInside
99  (
100  const pointField& pts,
101  const scalarField& sizes
102  ) const;
103 
104  //- Check if the given points are wellInside the geometry and, in
105  // parallel, inside the backgroundMeshDecomposition
106  bool combinedWellInside
107  (
108  const point& p,
109  scalar size
110  ) const;
111 
112  //- Write boundBox as obj
113  void writeOBJ
114  (
115  const treeBoundBox& bb,
116  fileName name
117  ) const;
118 
119  //- Descend into octants of the supplied bound box
120  label recurseAndFill
121  (
123  const treeBoundBox& bb,
124  label levelLimit,
125  word recursionName
126  ) const;
127 
128  //- Fill the given box, optionally filling surface overlapping boxes.
129  // Returns true if the fill is successful, false if it is to be aborted
130  // in favour of further recursion.
131  bool fillBox
132  (
134  const treeBoundBox& bb,
135  bool overlapping
136  ) const;
137 
138 
139 public:
140 
141  //- Runtime type information
142  TypeName("autoDensity");
143 
144  // Constructors
145 
146  //- Construct from components
148  (
149  const dictionary& initialPointsDict,
150  const Time& runTime,
151  Random& rndGen,
155  );
156 
157 
158  //- Destructor
159  virtual ~autoDensity() = default;
160 
161 
162  // Member Functions
163 
164  //- Return the initial points for the conformalVoronoiMesh
165  virtual List<Vb::Point> initialPoints() const;
166 };
167 
168 
169 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
170 
171 } // End namespace Foam
172 
173 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
174 
175 #endif
176 
177 // ************************************************************************* //
runTime
engineTime & runTime
Definition: createEngineTime.H:13
Foam::Random
Random number generator.
Definition: Random.H:59
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::initialPointsMethod::cellShapeControls
const cellShapeControl & cellShapeControls() const
Definition: initialPointsMethod.H:181
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::initialPointsMethod::decomposition
const backgroundMeshDecomposition & decomposition() const
Definition: initialPointsMethod.H:186
Foam::fileName
A class for handling file names.
Definition: fileName.H:73
Foam::DynamicList
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition: DynamicList.H:55
Foam::treeBoundBox
Standard boundBox with extra functionality for use in octree.
Definition: treeBoundBox.H:86
Foam::autoDensity::initialPoints
virtual List< Vb::Point > initialPoints() const
Return the initial points for the conformalVoronoiMesh.
Foam::autoDensity::~autoDensity
virtual ~autoDensity()=default
Destructor.
Foam::dictionary::name
const fileName & name() const noexcept
The dictionary name.
Definition: dictionaryI.H:48
Foam::conformationSurfaces
Definition: conformationSurfaces.H:55
Foam::initialPointsMethod::geometryToConformTo
const conformationSurfaces & geometryToConformTo() const
Definition: initialPointsMethod.H:176
Foam::Field< bool >
treeBoundBox.H
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::cellShapeControl
Definition: cellShapeControl.H:64
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::initialPointsMethod
Abstract base class for generating initial points for a conformalVoronoiMesh.
Definition: initialPointsMethod.H:56
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
initialPointsMethod.H
Foam::Vector< scalar >
Foam::initialPointsMethod::rndGen
Random & rndGen() const
Definition: initialPointsMethod.H:171
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:63
Foam::autoDensity::autoDensity
autoDensity(const dictionary &initialPointsDict, const Time &runTime, Random &rndGen, const conformationSurfaces &geometryToConformTo, const cellShapeControl &cellShapeControls, const autoPtr< backgroundMeshDecomposition > &decomposition)
Construct from components.
Foam::autoDensity::TypeName
TypeName("autoDensity")
Runtime type information.
Foam::autoDensity
Choose random points inside the domain and place them with a probability proportional to the target d...
Definition: autoDensity.H:53