raysPatchToPatch.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2021-2022 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::patchToPatches::intersection
26 
27 Description
28  Class to generate patchToPatch coupling geometry. Coupling is determined by
29  means of comparing the bound boxes generated by the intersection method.
30  This generates an outer "envelope" of possible intersections that can be
31  used for ray shooting and Lagrangian transfer.
32 
33 SourceFiles
34  rays.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef raysPatchToPatch_H
39 #define raysPatchToPatch_H
40 
41 #include "patchToPatch.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 namespace patchToPatches
48 {
49 
50 /*---------------------------------------------------------------------------*\
51  Class rays Declaration
52 \*---------------------------------------------------------------------------*/
53 
54 class rays
55 :
56  public patchToPatch
57 {
58  // Private Data
59 
60  // Parallel
61 
62  //- Cache of the part of the source patch local to the target
64  localSrcPatchPtr_;
65 
66  //- Cache of the part of the target patch local to the source
68  localTgtPatchPtr_;
69 
70 
71  // Private Member Functions
72 
73  //- Get the bound box for a source face
74  virtual treeBoundBox srcBox
75  (
76  const face& srcFace,
77  const pointField& srcPoints,
78  const vectorField& srcPointNormals
79  ) const;
80 
81  //- Intersect two faces
82  virtual bool intersectFaces
83  (
84  const primitiveOldTimePatch& srcPatch,
85  const vectorField& srcPointNormals,
86  const vectorField& srcPointNormals0,
87  const primitiveOldTimePatch& tgtPatch,
88  const label srcFacei,
89  const label tgtFacei
90  );
91 
92  //- Distribute the target patch so that enough is locally available
93  // for its intersection with the source patch can be computed
94  virtual
96  distributeTgt
97  (
98  const primitiveOldTimePatch& srcPatch,
99  const vectorField& srcPointNormals,
100  const vectorField& srcPointNormals0,
101  const primitiveOldTimePatch& tgtPatch,
102  distributionMap& tgtMap
103  );
104 
105  //- Distribute the source patch so that everything the target
106  // intersects is locally available. Happens after intersection.
107  virtual
109  distributeSrc
110  (
111  const primitiveOldTimePatch& srcPatch,
112  distributionMap& srcMap
113  );
114 
115  //- Finalising
116  virtual label finalise
117  (
118  const primitiveOldTimePatch& srcPatch,
119  const vectorField& srcPointNormals,
120  const vectorField& srcPointNormals0,
121  const primitiveOldTimePatch& tgtPatch,
122  const transformer& tgtToSrc
123  );
124 
125  //- Compute a ray intersection
126  procFace ray
127  (
128  const primitiveOldTimePatch& outPatch,
130  localOutPatchPtr,
131  const autoPtr<List<procFace>>& localOutProcFacesPtr,
132  const List<DynamicList<label>>& inLocalOutFacesPtr,
133  const scalar fraction,
134  const label inFacei,
135  const point& inP,
136  const vector& inN,
137  point& outP
138  ) const;
139 
140 
141 public:
142 
143  //- Runtime type information
144  TypeName("rays");
145 
146 
147  // Constructors
148 
149  //- Construct from components
150  rays(const bool reverse);
151 
152 
153  //- Destructor
154  ~rays();
155 
156 
157  // Member Functions
158 
159  //- For each source face, the coupled target weights
161  (
162  const primitivePatch& srcPatch
163  ) const;
164 
165  //- For each target face, the coupled source weights
167  (
168  const primitivePatch& tgtPatch
169  ) const;
170 
171  //- Compute a ray intersection from the source side to the target
173  (
174  const primitiveOldTimePatch& tgtPatch,
175  const scalar fraction,
176  const label srcFacei,
177  const vector& srcP,
178  const vector& srcN,
179  point& tgtP
180  ) const;
181 
182  //- Compute a ray intersection from the target side to the source
184  (
185  const primitiveOldTimePatch& srcPatch,
186  const scalar fraction,
187  const label tgtFacei,
188  const vector& tgtP,
189  const vector& tgtN,
190  point& srcP
191  ) const;
192 };
193 
194 
195 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
196 
197 } // End namespace patchToPatches
198 } // End namespace Foam
199 
200 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
201 
202 #endif
203 
204 // ************************************************************************* //
Vector-tensor class used to perform translations, rotations and scaling operations in 3D space...
Definition: transformer.H:83
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:75
Structure to conveniently store processor and face indices.
Definition: patchToPatch.H:60
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
bool reverse() const
Flag to indicate that the two patches are co-directional and.
Definition: patchToPatchI.H:87
virtual tmpNrc< List< DynamicList< scalar > > > tgtWeights(const primitivePatch &tgtPatch) const
For each target face, the coupled source weights.
A list of faces which address into the list of points.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
Definition: DynamicList.H:56
procFace tgtToSrcRay(const primitiveOldTimePatch &srcPatch, const scalar fraction, const label tgtFacei, const vector &tgtP, const vector &tgtN, point &srcP) const
Compute a ray intersection from the target side to the source.
A class for managing temporary objects without reference counting.
Definition: tmpNrc.H:52
Class containing processor-to-processor mapping information.
virtual tmpNrc< List< DynamicList< scalar > > > srcWeights(const primitivePatch &srcPatch) const
For each source face, the coupled target weights.
Standard boundBox + extra functionality for use in octree.
Definition: treeBoundBox.H:87
procFace srcToTgtRay(const primitiveOldTimePatch &tgtPatch, const scalar fraction, const label srcFacei, const vector &srcP, const vector &srcN, point &tgtP) const
Compute a ray intersection from the source side to the target.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
Class to generate coupling geometry between two primitive patches.
Definition: patchToPatch.H:53
rays(const bool reverse)
Construct from components.
TypeName("rays")
Runtime type information.
Namespace for OpenFOAM.