refinementFeatures.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) 2011-2014 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::refinementFeatures
28 
29 Description
30  Encapsulates queries for features.
31 
32 SourceFiles
33  refinementFeatures.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef refinementFeatures_H
38 #define refinementFeatures_H
39 
41 #include "indexedOctree.H"
42 #include "treeDataEdge.H"
43 #include "treeDataPoint.H"
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 /*---------------------------------------------------------------------------*\
51  Class refinementFeatures Declaration
52 \*---------------------------------------------------------------------------*/
53 
55 :
56  public PtrList<extendedFeatureEdgeMesh>
57 {
58  // Private data
59 
60  //- Per shell the list of ranges
61  List<scalarField> distances_;
62 
63  //- Per shell per distance the refinement level
64  labelListList levels_;
65 
66  //- Edge
68 
69  //- Features points
71 
72  //- Dry-run mode?
73  const bool dryRun_;
74 
75  //- Region edge trees (demand driven)
77  regionEdgeTreesPtr_;
78 
79 
80  // Private Member Functions
81 
82  //- Read set of feature edge meshes
83  void read(const objectRegistry&, const PtrList<dictionary>&);
84 
85  //- Build edge tree and feature point tree
86  void buildTrees(const label);
87 
88  //- Find shell level higher than ptLevel
89  void findHigherLevel
90  (
91  const pointField& pt,
92  const label featI,
93  labelList& maxLevel
94  ) const;
95 
96 
97 protected:
98 
100  {
101  return edgeTrees_;
102  }
103 
105  {
106  return pointTrees_;
107  }
108 
109 
111 
112 public:
113 
114  // Constructors
115 
116  //- Construct from description
118  (
119  const objectRegistry& io,
120  const PtrList<dictionary>& featDicts,
121  const bool dryRun = false
122  );
123 
124 
125  // Member Functions
126 
127  // Access
128 
129  //- Per featureEdgeMesh the list of level
130  const labelListList& levels() const
131  {
132  return levels_;
133  }
134 
135  //- Per featureEdgeMesh the list of ranges
136  const List<scalarField>& distances() const
137  {
138  return distances_;
139  }
140 
141 
142  // Query
143 
144  //- Highest distance of all features
145  scalar maxDistance() const;
146 
147  //- Find nearest point on nearest feature edge. Sets
148  // - nearFeature: index of feature mesh
149  // - nearInfo : location on feature edge and edge index
150  // (note: not feature edge index but index into
151  // edges() directly)
152  // - nearNormal : local feature edge normal
153  void findNearestEdge
154  (
155  const pointField& samples,
156  const scalarField& nearestDistSqr,
157  labelList& nearFeature,
159  vectorField& nearNormal
160  ) const;
161 
162  //- Find nearest point on nearest region edge. Sets
163  // - nearFeature: index of feature mesh
164  // - nearInfo : location on feature edge and edge index
165  // (note: not feature edge index but index into
166  // edges() directly)
167  // - nearNormal : local feature edge normal
169  (
170  const pointField& samples,
171  const scalarField& nearestDistSqr,
172  labelList& nearFeature,
174  vectorField& nearNormal
175  ) const;
176 
177  //- Find nearest feature point. Sets
178  // - nearFeature: index of feature mesh
179  // - nearInfo : location on feature point and point index.
180  // (note: not index into shapes().pointLabels() but
181  // index into points() directly)
182  void findNearestPoint
183  (
184  const pointField& samples,
185  const scalarField& nearestDistSqr,
186  labelList& nearFeature,
188  ) const;
189 
190  //- Find shell level higher than ptLevel
191  void findHigherLevel
192  (
193  const pointField& pt,
194  const labelList& ptLevel,
195  labelList& maxLevel
196  ) const;
197 
198  // Other
199 
200  //- Check sizes - return true if error and stream to os
201  bool checkSizes
202  (
203  const scalar maxRatio,
204  const boundBox& meshBb,
205  const bool report,
206  Ostream& os
207  ) const;
208 };
209 
210 
211 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
212 
213 } // End namespace Foam
214 
215 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
216 
217 #endif
218 
219 // ************************************************************************* //
Foam::refinementFeatures::findNearestPoint
void findNearestPoint(const pointField &samples, const scalarField &nearestDistSqr, labelList &nearFeature, List< pointIndexHit > &nearInfo) const
Find nearest feature point. Sets.
Definition: refinementFeatures.C:814
indexedOctree.H
Foam::refinementFeatures::maxDistance
scalar maxDistance() const
Highest distance of all features.
Definition: refinementFeatures.C:881
meshBb
List< treeBoundBox > meshBb(1, treeBoundBox(boundBox(coarseMesh.points(), false)).extend(rndGen, 1e-3))
extendedFeatureEdgeMesh.H
Foam::refinementFeatures::checkSizes
bool checkSizes(const scalar maxRatio, const boundBox &meshBb, const bool report, Ostream &os) const
Check sizes - return true if error and stream to os.
Definition: refinementFeatures.C:570
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:60
Foam::Field< vector >
treeDataPoint.H
Foam::refinementFeatures::edgeTrees
const PtrList< indexedOctree< treeDataEdge > > & edgeTrees() const
Definition: refinementFeatures.H:98
samples
scalarField samples(nIntervals, Zero)
Foam::refinementFeatures::distances
const List< scalarField > & distances() const
Per featureEdgeMesh the list of ranges.
Definition: refinementFeatures.H:135
Foam::PtrList
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: List.H:62
treeDataEdge.H
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::refinementFeatures::regionEdgeTrees
const PtrList< indexedOctree< treeDataEdge > > & regionEdgeTrees() const
Definition: refinementFeatures.C:417
Foam::refinementFeatures::findNearestRegionEdge
void findNearestRegionEdge(const pointField &samples, const scalarField &nearestDistSqr, labelList &nearFeature, List< pointIndexHit > &nearInfo, vectorField &nearNormal) const
Find nearest point on nearest region edge. Sets.
Definition: refinementFeatures.C:699
Foam::refinementFeatures
Encapsulates queries for features.
Definition: refinementFeatures.H:53
Foam::List< scalarField >
Foam::boundBox
A bounding box defined in terms of min/max extrema points.
Definition: boundBox.H:63
Foam::refinementFeatures::levels
const labelListList & levels() const
Per featureEdgeMesh the list of level.
Definition: refinementFeatures.H:129
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::refinementFeatures::refinementFeatures
refinementFeatures(const objectRegistry &io, const PtrList< dictionary > &featDicts, const bool dryRun=false)
Construct from description.
Definition: refinementFeatures.C:473
Foam::Tuple2
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
Definition: Tuple2.H:57
Foam::refinementFeatures::findNearestEdge
void findNearestEdge(const pointField &samples, const scalarField &nearestDistSqr, labelList &nearFeature, List< pointIndexHit > &nearInfo, vectorField &nearNormal) const
Find nearest point on nearest feature edge. Sets.
Definition: refinementFeatures.C:640
Foam::refinementFeatures::pointTrees
const PtrList< indexedOctree< treeDataPoint > > & pointTrees() const
Definition: refinementFeatures.H:103