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-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::autoDensity
29
30Description
31 Choose random points inside the domain and place them with a probability
32 proportional to the target density of points.
33
34SourceFiles
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
47namespace Foam
48{
49
50/*---------------------------------------------------------------------------*\
51 Class autoDensity Declaration
52\*---------------------------------------------------------------------------*/
54class autoDensity
55:
57{
58
59private:
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,
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
139public:
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// ************************************************************************* //
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition: DynamicList.H:72
Generic templated field type.
Definition: Field.H:82
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:77
Random number generator.
Definition: Random.H:60
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:80
Choose random points inside the domain and place them with a probability proportional to the target d...
Definition: autoDensity.H:56
virtual ~autoDensity()=default
Destructor.
TypeName("autoDensity")
Runtime type information.
autoDensity(const dictionary &initialPointsDict, const Time &runTime, Random &rndGen, const conformationSurfaces &geometryToConformTo, const cellShapeControl &cellShapeControls, const autoPtr< backgroundMeshDecomposition > &decomposition)
Construct from components.
virtual List< Vb::Point > initialPoints() const
Return the initial points for the conformalVoronoiMesh.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
const fileName & name() const noexcept
The dictionary name.
Definition: dictionaryI.H:48
A class for handling file names.
Definition: fileName.H:76
Abstract base class for generating initial points for a conformalVoronoiMesh.
const conformationSurfaces & geometryToConformTo() const
const cellShapeControl & cellShapeControls() const
const backgroundMeshDecomposition & decomposition() const
Standard boundBox with extra functionality for use in octree.
Definition: treeBoundBox.H:89
A class for handling words, derived from Foam::string.
Definition: word.H:68
volScalarField & p
engineTime & runTime
Namespace for OpenFOAM.
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73