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  Note that this method is not added to the run-time selection table, as it
34  is not a method which facilitates patch coupling or mapping.
35 
36 SourceFiles
37  rays.C
38 
39 \*---------------------------------------------------------------------------*/
40 
41 #ifndef raysPatchToPatch_H
42 #define raysPatchToPatch_H
43 
44 #include "patchToPatch.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 namespace patchToPatches
51 {
52 
53 /*---------------------------------------------------------------------------*\
54  Class rays Declaration
55 \*---------------------------------------------------------------------------*/
56 
57 class rays
58 :
59  public patchToPatch
60 {
61  // Private Data
62 
63  // Parallel
64 
65  //- Cache of the part of the source patch local to the target
67  localSrcPatchPtr_;
68 
69  //- Cache of the part of the target patch local to the source
71  localTgtPatchPtr_;
72 
73 
74  // Private Member Functions
75 
76  //- Get the bound box for a source face
77  virtual treeBoundBox srcBox
78  (
79  const face& srcFace,
80  const pointField& srcPoints,
81  const vectorField& srcPointNormals
82  ) const;
83 
84  //- Intersect two faces
85  virtual bool intersectFaces
86  (
87  const primitiveOldTimePatch& srcPatch,
88  const vectorField& srcPointNormals,
89  const vectorField& srcPointNormals0,
90  const primitiveOldTimePatch& tgtPatch,
91  const label srcFacei,
92  const label tgtFacei
93  );
94 
95  //- Finalise the intersection locally. Trims the local target patch
96  // so that only parts that actually intersect the source remain.
97  // Returns new-to-old map for trimming target-associated data.
98  virtual labelList finaliseLocal
99  (
100  const primitiveOldTimePatch& srcPatch,
101  const vectorField& srcPointNormals,
102  const vectorField& srcPointNormals0,
103  const primitiveOldTimePatch& tgtPatch
104  );
105 
106  //- Distribute the source patch so that any information needed by
107  // the target is locally available
108  virtual void distributeSrc(const primitiveOldTimePatch& srcPatch);
109 
110  //- Finalising
111  virtual label finalise
112  (
113  const primitiveOldTimePatch& srcPatch,
114  const vectorField& srcPointNormals,
115  const vectorField& srcPointNormals0,
116  const primitiveOldTimePatch& tgtPatch,
117  const transformer& tgtToSrc
118  );
119 
120  //- Compute a ray intersection
121  remote ray
122  (
123  const primitiveOldTimePatch& outPatch,
125  localOutPatchPtr,
126  const autoPtr<List<remote>>& localOutProcFacesPtr,
127  const List<DynamicList<label>>& inLocalOutFacesPtr,
128  const scalar fraction,
129  const label inFacei,
130  const point& inP,
131  const vector& inN,
132  point& outP
133  ) const;
134 
135  //- For each source face, the coupled target weights
136  virtual tmpNrc<List<DynamicList<scalar>>> srcWeights() const;
137 
138  //- For each target face, the coupled source weights
139  virtual tmpNrc<List<DynamicList<scalar>>> tgtWeights() const;
140 
141 
142 public:
143 
144  //- Runtime type information
145  TypeName("rays");
146 
147 
148  // Constructors
149 
150  //- Construct from components
151  rays(const bool reverse);
152 
153 
154  //- Destructor
155  ~rays();
156 
157 
158  // Member Functions
159 
160  //- Compute a ray intersection from the source side to the target
162  (
163  const primitiveOldTimePatch& tgtPatch,
164  const scalar fraction,
165  const label srcFacei,
166  const vector& srcP,
167  const vector& srcN,
168  point& tgtP
169  ) const;
170 
171  //- Compute a ray intersection from the target side to the source
173  (
174  const primitiveOldTimePatch& srcPatch,
175  const scalar fraction,
176  const label tgtFacei,
177  const vector& tgtP,
178  const vector& tgtN,
179  point& srcP
180  ) const;
181 };
182 
183 
184 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
185 
186 } // End namespace patchToPatches
187 } // End namespace Foam
188 
189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
190 
191 #endif
192 
193 // ************************************************************************* //
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:76
Class to generate coupling geometry between two primitive patches.
Definition: patchToPatch.H:56
tmp< Field< Type > > tgtToSrc(const Field< Type > &tgtFld) const
Interpolate a target patch field to the source with no left.
bool reverse() const
Flag to indicate that the two patches are co-directional and.
Definition: patchToPatchI.H:31
rays(const bool reverse)
Construct from components.
TypeName("rays")
Runtime type information.
remote 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.
remote 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.
Struct for keeping processor, element (cell, face, point) index.
Definition: remote.H:57
A class for managing temporary objects without reference counting.
Definition: tmpNrc.H:53
Vector-tensor class used to perform translations, rotations and scaling operations in 3D space.
Definition: transformer.H:84
Standard boundBox + extra functionality for use in octree.
Definition: treeBoundBox.H:90
Namespace for OpenFOAM.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59