inverseDistancePatchToPatch.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::inverseDistance
26 
27 Description
28  Class to generate patchToPatch coupling geometry. Couples a face to the
29  opposite face onto which its centre-normal ray projects, plus the immediate
30  neighbours to that opposite face. The proportion of contribution from the
31  different faces is calculated using inverse distance weighting.
32 
33 SourceFiles
34  inverseDistance.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef inverseDistancePatchToPatch_H
39 #define inverseDistancePatchToPatch_H
40 
41 #include "nearbyPatchToPatch.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 namespace patchToPatches
48 {
49 
50 /*---------------------------------------------------------------------------*\
51  Class inverseDistance Declaration
52 \*---------------------------------------------------------------------------*/
53 
54 class inverseDistance
55 :
56  public nearby
57 {
58  // Private Member Data
59 
60  //- For each source face, the coupled target weights
61  List<DynamicList<scalar>> srcWeights_;
62 
63  //- For each target face, the coupled source weights
64  List<DynamicList<scalar>> tgtWeights_;
65 
66 
67  // Private Static Member Functions
68 
69  //- Return whether a ray starting at point `p` with direction `r` hits
70  // a face `f` with points `ps`
71  static bool rayHitsFace
72  (
73  const point& p,
74  const vector& r,
75  const face& f,
76  const pointField& ps
77  );
78 
79 
80  // Private Member Functions
81 
82  //- Initialisation
83  virtual void initialise
84  (
85  const primitiveOldTimePatch& srcPatch,
86  const vectorField& srcPointNormals,
87  const vectorField& srcPointNormals0,
88  const primitiveOldTimePatch& tgtPatch
89  );
90 
91  //- Convert the addressing generated by the base class into weights
92  // (and addressing) appropriate for inverse distance interpolation
93  void generateWeights
94  (
95  const primitiveOldTimePatch& srcPatch,
96  const primitiveOldTimePatch& tgtPatch
97  );
98 
99  //- Finalise the intersection locally. Trims the local target patch
100  // so that only parts that actually intersect the source remain.
101  // Returns new-to-old map for trimming target-associated data.
102  virtual labelList finaliseLocal
103  (
104  const primitiveOldTimePatch& srcPatch,
105  const vectorField& srcPointNormals,
106  const vectorField& srcPointNormals0,
107  const primitiveOldTimePatch& tgtPatch
108  );
109 
110  //- Send data that resulted from an intersection between the source
111  // patch and a distributed source-local-target patch back to the
112  // original target processes
113  virtual void rDistributeTgt(const primitiveOldTimePatch& tgtPatch);
114 
115  //- Finalise the intersection
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  //- For each source face, the coupled target weights
126  virtual tmpNrc<List<DynamicList<scalar>>> srcWeights() const;
127 
128  //- For each target face, the coupled source weights
129  virtual tmpNrc<List<DynamicList<scalar>>> tgtWeights() const;
130 
131 
132 public:
133 
134  //- Runtime type information
135  TypeName("inverseDistance");
136 
137 
138  // Constructors
139 
140  //- Construct from components
141  inverseDistance(const bool reverse);
142 
143 
144  //- Destructor
146 };
147 
148 
149 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
150 
151 } // End namespace patchToPatches
152 } // End namespace Foam
153 
154 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
155 
156 #endif
157 
158 // ************************************************************************* //
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:91
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:76
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
Class to generate patchToPatch coupling geometry. Couples a face to the opposite face onto which its ...
TypeName("inverseDistance")
Runtime type information.
inverseDistance(const bool reverse)
Construct from components.
Class to generate patchToPatch coupling geometry. Couples a face to the single nearby opposite face o...
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
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
labelList f(nPoints)
volScalarField & p