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 OpenCFD Ltd.
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::triangulatedPatch
28 
29 Description
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 "Random.H"
39 
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 
42 namespace Foam
43 {
44 /*---------------------------------------------------------------------------*\
45  Class triangulatedPatch Declaration
46 \*---------------------------------------------------------------------------*/
47 
49 {
50  // Private Data
51 
52  //- Reference to the polyPatch
53  const polyPatch& patch_;
54 
55  //- Perturbation tolerance to move the point towards the cell centre
56  bool perturbTol_;
57 
58  //- Face triangles
59  faceList triFace_;
60 
61  //- Triangle to patch face addressing
62  labelList triToFace_;
63 
64  //- Triangle weights
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 public:
85 
86  //- Constructors
87 
88  //- Construct from components
90  (
91  const polyPatch& patch,
92  const scalar perturbTol
93  );
94 
95  //- Construct from mesh and patch name
97  (
98  const polyMesh& mesh,
99  const word& patchName,
100  const scalar perturbTol
101  );
102 
103 
104  //- Destructor
105  ~triangulatedPatch() = default;
106 
107 
108  // Member Functions
109 
110  //- Set a random point on the local patch
111  //
112  // \param rnd random number generator
113  // \param result the random point
114  // \param facei index associated with the random point
115  // \param celli index associated with the random point
116  //
117  // \return true if point has been set
118  bool randomLocalPoint
119  (
120  Random& rnd,
121  point& result,
122  label& facei,
123  label& celli
124  ) const;
125 
126  //- Set a global random point on the patch
127  //
128  // \param rnd random number generator
129  // \param result the random point
130  // \param facei index associated with the random point
131  // \param celli index associated with the random point
132  //
133  // \return true if point has been set
134  bool randomGlobalPoint
135  (
136  Random& rnd,
137  point& result,
138  label& facei,
139  label& celli
140  ) const;
141 };
142 
143 
144 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
145 
146 } // End namespace Foam
147 
148 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
149 
150 #endif
151 
152 // ************************************************************************* //
triangulatedPatch(const polyPatch &patch, const scalar perturbTol)
Constructors.
dynamicFvMesh & mesh
A class for handling words, derived from Foam::string.
Definition: word.H:63
bool randomLocalPoint(Random &rnd, point &result, label &facei, label &celli) const
Set a random point on the local patch.
bool randomGlobalPoint(Random &rnd, point &result, label &facei, label &celli) const
Set a global random point on the patch.
Random number generator.
Definition: Random.H:55
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
~triangulatedPatch()=default
Destructor.
Performs a triangulation of a patch to return randomised point locations.
const dimensionedScalar c
Speed of light in a vacuum.
const std::string patch
OpenFOAM patch number as a std::string.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:69
Namespace for OpenFOAM.