/src/mesh/autoMesh/autoHexMesh/refinementSurfaces/refinementSurfaces.H

https://gitlab.com/johnvarv/OpenFOAM-3.0.x · C Header · 368 lines · 202 code · 72 blank · 94 comment · 0 complexity · 908b883c4aa6a0f6a7e888d932f87957 MD5 · raw file

  1. /*---------------------------------------------------------------------------*\
  2. ========= |
  3. \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
  4. \\ / O peration |
  5. \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
  6. \\/ M anipulation |
  7. -------------------------------------------------------------------------------
  8. License
  9. This file is part of OpenFOAM.
  10. OpenFOAM is free software: you can redistribute it and/or modify it
  11. under the terms of the GNU General Public License as published by
  12. the Free Software Foundation, either version 3 of the License, or
  13. (at your option) any later version.
  14. OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
  15. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  16. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  17. for more details.
  18. You should have received a copy of the GNU General Public License
  19. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
  20. Class
  21. Foam::refinementSurfaces
  22. Description
  23. Container for data on surfaces used for surface-driven refinement.
  24. Contains all the data about the level of refinement needed per
  25. surface.
  26. SourceFiles
  27. refinementSurfaces.C
  28. \*---------------------------------------------------------------------------*/
  29. #ifndef refinementSurfaces_H
  30. #define refinementSurfaces_H
  31. #include "triSurfaceGeoMesh.H"
  32. #include "triSurfaceFields.H"
  33. #include "vectorList.H"
  34. #include "pointIndexHit.H"
  35. #include "surfaceZonesInfo.H"
  36. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
  37. namespace Foam
  38. {
  39. class searchableSurfaces;
  40. class shellSurfaces;
  41. class triSurfaceMesh;
  42. typedef List<point> pointList;
  43. /*---------------------------------------------------------------------------*\
  44. Class refinementSurfaces Declaration
  45. \*---------------------------------------------------------------------------*/
  46. class refinementSurfaces
  47. {
  48. // Private data
  49. //- Reference to all geometry.
  50. const searchableSurfaces& allGeometry_;
  51. //- Indices of surfaces that are refinement ones
  52. labelList surfaces_;
  53. //- Surface name (word)
  54. wordList names_;
  55. //- List of surface zone (face and cell zone) information
  56. PtrList<surfaceZonesInfo> surfZones_;
  57. //- From local region number to global region number
  58. labelList regionOffset_;
  59. //- From global region number to refinement level
  60. labelList minLevel_;
  61. //- From global region number to refinement level
  62. labelList maxLevel_;
  63. //- From global region number to small-gap level
  64. labelList gapLevel_;
  65. //- From global region number to perpendicular angle
  66. scalarField perpendicularAngle_;
  67. //- From global region number to patchType
  68. PtrList<dictionary> patchInfo_;
  69. // Private Member Functions
  70. //- Disallow default bitwise copy construct
  71. refinementSurfaces(const refinementSurfaces&);
  72. //- Disallow default bitwise assignment
  73. void operator=(const refinementSurfaces&);
  74. public:
  75. // Constructors
  76. //- Construct from surfaces and dictionary
  77. refinementSurfaces
  78. (
  79. const searchableSurfaces& allGeometry,
  80. const dictionary&,
  81. const label gapLevelIncrement
  82. );
  83. //- Construct from components
  84. refinementSurfaces
  85. (
  86. const searchableSurfaces& allGeometry,
  87. const labelList& surfaces,
  88. const wordList& names,
  89. const PtrList<surfaceZonesInfo>& surfZones,
  90. const labelList& regionOffset,
  91. const labelList& minLevel,
  92. const labelList& maxLevel,
  93. const labelList& gapLevel,
  94. const scalarField& perpendicularAngle,
  95. PtrList<dictionary>& patchInfo
  96. );
  97. // Member Functions
  98. // Access
  99. const searchableSurfaces& geometry() const
  100. {
  101. return allGeometry_;
  102. }
  103. const labelList& surfaces() const
  104. {
  105. return surfaces_;
  106. }
  107. //- Names of surfaces
  108. const wordList& names() const
  109. {
  110. return names_;
  111. }
  112. const PtrList<surfaceZonesInfo>& surfZones() const
  113. {
  114. return surfZones_;
  115. }
  116. //- From local region number to global region number
  117. const labelList& regionOffset() const
  118. {
  119. return regionOffset_;
  120. }
  121. //- From global region number to refinement level
  122. const labelList& minLevel() const
  123. {
  124. return minLevel_;
  125. }
  126. //- From global region number to refinement level
  127. const labelList& maxLevel() const
  128. {
  129. return maxLevel_;
  130. }
  131. //- From global region number to small gap refinement level
  132. const labelList& gapLevel() const
  133. {
  134. return gapLevel_;
  135. }
  136. //- From global region number to perpendicular angle
  137. const scalarField& perpendicularAngle() const
  138. {
  139. return perpendicularAngle_;
  140. }
  141. //- From global region number to patch type
  142. const PtrList<dictionary>& patchInfo() const
  143. {
  144. return patchInfo_;
  145. }
  146. // Helper
  147. //- From surface and region on surface to global region
  148. label globalRegion(const label surfI, const label regionI) const
  149. {
  150. return regionOffset_[surfI]+regionI;
  151. }
  152. //- Min level for surface and region on surface
  153. label minLevel(const label surfI, const label regionI) const
  154. {
  155. return minLevel_[globalRegion(surfI, regionI)];
  156. }
  157. //- Max level for surface and region on surface
  158. label maxLevel(const label surfI, const label regionI) const
  159. {
  160. return maxLevel_[globalRegion(surfI, regionI)];
  161. }
  162. label nRegions() const
  163. {
  164. return minLevel_.size();
  165. }
  166. //- Calculate minLevelFields
  167. void setMinLevelFields
  168. (
  169. const shellSurfaces& shells
  170. );
  171. ////- Helper: count number of triangles per region
  172. //static labelList countRegions(const triSurface&);
  173. // Searching
  174. //- Find intersection of edge. Return -1 or first surface
  175. // with higher (than currentLevel) minlevel.
  176. // Return surface number and level.
  177. void findHigherIntersection
  178. (
  179. const pointField& start,
  180. const pointField& end,
  181. const labelList& currentLevel, // current cell refinement level
  182. labelList& surfaces,
  183. labelList& surfaceLevel
  184. ) const;
  185. //- Find all intersections of edge. Unsorted order.
  186. void findAllHigherIntersections
  187. (
  188. const pointField& start,
  189. const pointField& end,
  190. const labelList& currentLevel, // current cell refinement level
  191. const labelList& globalRegionLevel, // level per surfregion
  192. List<vectorList>& surfaceNormal,
  193. labelListList& surfaceLevel
  194. ) const;
  195. //- Find all intersections of edge. Unsorted order.
  196. void findAllHigherIntersections
  197. (
  198. const pointField& start,
  199. const pointField& end,
  200. const labelList& currentLevel, // current cell refinement level
  201. const labelList& globalRegionLevel, // level per surfregion
  202. List<pointList>& surfaceLocation,
  203. List<vectorList>& surfaceNormal,
  204. labelListList& surfaceLevel
  205. ) const;
  206. //- Find intersection nearest to the endpoints. surface1,2 are
  207. // not indices into surfacesToTest but refinement surface indices.
  208. // Returns surface, region on surface (so not global surface)
  209. // and position on surface.
  210. void findNearestIntersection
  211. (
  212. const labelList& surfacesToTest,
  213. const pointField& start,
  214. const pointField& end,
  215. labelList& surface1,
  216. List<pointIndexHit>& hit1,
  217. labelList& region1,
  218. labelList& surface2,
  219. List<pointIndexHit>& hit2,
  220. labelList& region2
  221. ) const;
  222. //- findNearestIntersection but also get normals
  223. void findNearestIntersection
  224. (
  225. const labelList& surfacesToTest,
  226. const pointField& start,
  227. const pointField& end,
  228. labelList& surface1,
  229. List<pointIndexHit>& hit1,
  230. labelList& region1,
  231. vectorField& normal1,
  232. labelList& surface2,
  233. List<pointIndexHit>& hit2,
  234. labelList& region2,
  235. vectorField& normal2
  236. ) const;
  237. //- Used for debugging only: find intersection of edge.
  238. void findAnyIntersection
  239. (
  240. const pointField& start,
  241. const pointField& end,
  242. labelList& surfaces,
  243. List<pointIndexHit>&
  244. ) const;
  245. //- Find nearest point on surfaces.
  246. void findNearest
  247. (
  248. const labelList& surfacesToTest,
  249. const pointField& samples,
  250. const scalarField& nearestDistSqr,
  251. labelList& surfaces,
  252. List<pointIndexHit>&
  253. ) const;
  254. //- Find nearest point on surfaces. Return surface and region on
  255. // surface (so not global surface)
  256. void findNearestRegion
  257. (
  258. const labelList& surfacesToTest,
  259. const pointField& samples,
  260. const scalarField& nearestDistSqr,
  261. labelList& hitSurface,
  262. labelList& hitRegion
  263. ) const;
  264. //- Find nearest point on surfaces. Return surface, region and
  265. // normal on surface (so not global surface)
  266. void findNearestRegion
  267. (
  268. const labelList& surfacesToTest,
  269. const pointField& samples,
  270. const scalarField& nearestDistSqr,
  271. labelList& hitSurface,
  272. List<pointIndexHit>& hitInfo,
  273. labelList& hitRegion,
  274. vectorField& hitNormal
  275. ) const;
  276. //- Detect if a point is 'inside' (closed) surfaces.
  277. // Returns -1 if not, returns first surface it is.
  278. void findInside
  279. (
  280. const labelList& surfacesToTest,
  281. const pointField& pt,
  282. labelList& insideSurfaces
  283. ) const;
  284. };
  285. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
  286. } // End namespace Foam
  287. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
  288. #endif
  289. // ************************************************************************* //