Loading...
Searching...
No Matches
triangulatedPatch.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) 2023-2024 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
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
26Class
27 Foam::triangulatedPatch
28
29Description
30 Performs a triangulation of a patch to return randomised point locations.
31
32\*---------------------------------------------------------------------------*/
33
34#ifndef Foam_triangulatedPatch_H
35#define Foam_triangulatedPatch_H
36
37#include "polyMesh.H"
38#include "labelledTri.H"
39#include "Random.H"
40
41// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43namespace Foam
44{
45/*---------------------------------------------------------------------------*\
46 Class triangulatedPatch Declaration
47\*---------------------------------------------------------------------------*/
48
50{
51 // Private Data
52
53 //- Reference to the polyPatch
54 const polyPatch& patch_;
55
56 //- Perturbation tolerance to move the point towards the cell centre
57 bool perturbTol_;
58
59 //- The polyPatch faces as triangles, the index of each corresponds
60 //- to the undecomposed patch face index.
61 List<labelledTri> triFace_;
62
63 //- The cumulative triangle area per triangle face,
64 //- globally normalised as a 0-1 interval.
65 scalarList triWght_;
66
67
68 // Private Member Functions
69
70 //- Update triangulation
71 void update();
72
73 //- Return a random point on the patch based on random number, 0 < c < 1
74 bool randomPoint
75 (
76 Random& rnd,
77 const scalar c,
78 point& result,
79 label& facei,
80 label& celli
81 ) const;
82
83
84 // Static Member Functions
85
86 //- Triangulate the patch faces and create addressing
87 static void triangulate(const polyPatch& pp, List<labelledTri>& tris);
88
89public:
90
91 //- Constructors
92
93 //- Construct from components
95 (
96 const polyPatch& patch,
97 const scalar perturbTol
98 );
99
100 //- Construct from mesh and patch name
102 (
103 const polyMesh& mesh,
104 const word& patchName,
105 const scalar perturbTol
106 );
107
108
109 //- Destructor
110 ~triangulatedPatch() = default;
111
112
113 // Member Functions
114
115 //- Set a random point on the local patch
116 //
117 // \param rnd random number generator
118 // \param result the random point
119 // \param facei index associated with the random point
120 // \param celli index associated with the random point
121 //
122 // \return true if point has been set
124 (
125 Random& rnd,
126 point& result,
127 label& facei,
128 label& celli
129 ) const;
130
131 //- Set a global random point on the patch
132 //
133 // \param rnd random number generator
134 // \param result the random point
135 // \param facei index associated with the random point
136 // \param celli index associated with the random point
137 //
138 // \return true if point has been set
140 (
141 Random& rnd,
142 point& result,
143 label& facei,
144 label& celli
145 ) const;
146};
147
148
149// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
150
151} // End namespace Foam
152
153// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
154
155#endif
156
157// ************************************************************************* //
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition List.H:72
Random number generator.
Definition Random.H:56
Mesh consisting of general polyhedral cells.
Definition polyMesh.H:79
A patch is a list of labels that address the faces in the global face list.
Definition polyPatch.H:73
bool randomGlobalPoint(Random &rnd, point &result, label &facei, label &celli) const
Set a global random point on the patch.
triangulatedPatch(const polyPatch &patch, const scalar perturbTol)
Constructors.
bool randomLocalPoint(Random &rnd, point &result, label &facei, label &celli) const
Set a random point on the local patch.
~triangulatedPatch()=default
Destructor.
A class for handling words, derived from Foam::string.
Definition word.H:66
mesh update()
dynamicFvMesh & mesh
Namespace for OpenFOAM.
vector point
Point is a vector.
Definition point.H:37
List< scalar > scalarList
List of scalar.
Definition scalarList.H:32