cellDistFuncs.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-2016 OpenFOAM Foundation
9  Copyright (C) 2020,2024 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::cellDistFuncs
29 
30 Description
31  Collection of functions used in wall distance calculation.
32 
33 SourceFiles
34  cellDistFuncs.C
35  cellDistFuncsTemplates.C
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef cellDistFuncs_H
40 #define cellDistFuncs_H
41 
42 #include "HashSet.H"
43 #include "Map.H"
44 #include "wordRe.H"
45 #include "scalarField.H"
46 #include "point.H"
47 #include "primitivePatch.H"
48 #include "className.H"
49 
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 
52 namespace Foam
53 {
54 
55 // Forward declaration of classes
56 class polyMesh;
57 class polyPatch;
58 class polyBoundaryMesh;
59 
60 /*---------------------------------------------------------------------------*\
61  Class cellDistFuncs Declaration
62 \*---------------------------------------------------------------------------*/
63 
64 class cellDistFuncs
65 {
66  // Private Member Data
67 
68  //- Reference to mesh
69  const polyMesh& mesh_;
70 
71 
72  // Private Member Functions
73 
74  //- No copy construct
75  cellDistFuncs(const cellDistFuncs&) = delete;
76 
77  //- No copy assignment
78  void operator=(const cellDistFuncs&) = delete;
79 
80 public:
81 
82  // Static Data Members
83 
84  ClassName("cellDistFuncs");
85 
86 
87  //- Use combined-wall-patches wall distance v.s. v2406 per-patch
88  //- distance. Default is true
89  static bool useCombinedWallPatch;
90 
91 
92  // Constructors
93 
94  //- Construct from mesh
95  cellDistFuncs(const polyMesh& mesh);
96 
97 
98  // Member Functions
99 
100  //- Access mesh
101  const polyMesh& mesh() const
102  {
103  return mesh_;
104  }
105 
106  //- Return the set of patch IDs corresponding to the given names
109  //- Get patchIDs of/derived off certain type (e.g. 'processorPolyPatch')
110  // Uses isA, not isType
111  template<class Type>
112  labelHashSet getPatchIDs() const;
113 
114  //- Calculate smallest true distance (and patch face index)
115  // from pt to faces wallFaces.
116  template<class PatchType>
117  scalar smallestDist
118  (
119  const point& p,
120  const PatchType& patch,
121  const labelUList& wallFaces,
122  label& patchFacei
123  ) const;
124 
125  //- Get faces sharing point with face on patch
126  template<class PatchType>
127  void getPointNeighbours
128  (
129  const PatchType&,
130  const label patchFacei,
132  ) const;
133 
134  //- Size of largest patch (out of supplied subset of patches)
135  label maxPatchSize(const labelHashSet& patchIDs) const;
136 
137  //- Sum of patch sizes (out of supplied subset of patches).
138  // Used in sizing arrays.
139  label sumPatchSize(const labelHashSet& patchIDs) const;
140 
141  //- Correct all cells connected to boundary (via face). Sets values in
142  // wallDistCorrected. Sets nearest wallface in nearestFace.
144  (
145  const labelHashSet& patchIDs,
146  scalarField& wallDistCorrected,
147  Map<label>& nearestFace
148  ) const;
149 
150  //- Correct all cells connected to wall (via point). Sets values in
151  // wallDistCorrected. Uses/sets nearest wallFace in nearestFace.
153  (
154  const labelHashSet& patchIDs,
155  scalarField& wallDistCorrected,
156  Map<label>& nearestFace
157  ) const;
158 
159  //- Correct all cells connected to any of the patches in patchIDs. Sets
160  // - cell values in wallDistCorrected
161  // - (mesh) face that contains the nearest point
163  (
164  const labelList& patchIDs,
165  const bool doPointCells,
166  scalarField& wallDistCorrected,
167  Map<label>& nearestFace
168  ) const;
169 };
170 
171 
172 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
173 
174 } // End namespace Foam
175 
176 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
177 
178 #ifdef NoRepository
179  #include "cellDistFuncsTemplates.C"
180 #endif
181 
182 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
183 
184 #endif
185 
186 // ************************************************************************* //
labelHashSet getPatchIDs() const
Get patchIDs of/derived off certain type (e.g. &#39;processorPolyPatch&#39;)
const labelList patchIDs(pbm.indices(polyPatchNames, true))
label sumPatchSize(const labelHashSet &patchIDs) const
Sum of patch sizes (out of supplied subset of patches).
Definition: cellDistFuncs.C:87
void correctBoundaryFaceCells(const labelHashSet &patchIDs, scalarField &wallDistCorrected, Map< label > &nearestFace) const
Correct all cells connected to boundary (via face). Sets values in.
Collection of functions used in wall distance calculation.
Definition: cellDistFuncs.H:59
static bool useCombinedWallPatch
Use combined-wall-patches wall distance v.s. v2406 per-patch distance. Default is true...
Definition: cellDistFuncs.H:92
void correctBoundaryCells(const labelList &patchIDs, const bool doPointCells, scalarField &wallDistCorrected, Map< label > &nearestFace) const
Correct all cells connected to any of the patches in patchIDs. Sets.
wordList patchNames(nPatches)
void correctBoundaryPointCells(const labelHashSet &patchIDs, scalarField &wallDistCorrected, Map< label > &nearestFace) const
Correct all cells connected to wall (via point). Sets values in.
label maxPatchSize(const labelHashSet &patchIDs) const
Size of largest patch (out of supplied subset of patches)
Definition: cellDistFuncs.C:66
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:105
scalar smallestDist(const point &p, const PatchType &patch, const labelUList &wallFaces, label &patchFacei) const
Calculate smallest true distance (and patch face index)
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
Macro definitions for declaring ClassName(), NamespaceName(), etc.
const std::string patch
OpenFOAM patch number as a std::string.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:75
volScalarField & p
void getPointNeighbours(const PatchType &, const label patchFacei, DynamicList< label > &) const
Get faces sharing point with face on patch.
const polyMesh & mesh() const
Access mesh.
Namespace for OpenFOAM.
ClassName("cellDistFuncs")