nearbyPatchToPatch.C
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-2026 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 \*---------------------------------------------------------------------------*/
25 
26 #include "nearbyPatchToPatch.H"
27 #include "boundSphere.H"
28 
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33 namespace patchToPatches
34 {
36 }
37 }
38 
39 
40 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
41 
43 (
44  const face& srcFace,
45  const pointField& srcPoints,
46  const vectorField& srcPointNormals
47 ) const
48 {
49  const treeBoundBox bb(srcPoints, srcFace);
50 
51  const point c = bb.midpoint();
52  const scalar l = bb.maxDim();
53 
54  return treeBoundBox(c - l*vector::one, c + l*vector::one);
55 }
56 
57 
59 (
60  const primitiveOldTimePatch& srcPatch,
61  const vectorField& srcPointNormals,
62  const vectorField& srcPointNormals0,
63  const primitiveOldTimePatch& tgtPatch,
64  const label srcFacei,
65  const label tgtFacei
66 )
67 {
68  if (boundSphere::overlap(srcSpheres_[srcFacei], tgtSpheres_[tgtFacei]))
69  {
70  srcLocalTgtFaces_[srcFacei].append(tgtFacei);
71  tgtLocalSrcFaces_[tgtFacei].append(srcFacei);
72 
73  return true;
74  }
75  else
76  {
77  return false;
78  }
79 }
80 
81 
83 (
84  const primitiveOldTimePatch& srcPatch,
85  const vectorField& srcPointNormals,
86  const vectorField& srcPointNormals0,
87  const primitiveOldTimePatch& tgtPatch
88 )
89 {
91  (
92  srcPatch,
93  srcPointNormals,
94  srcPointNormals0,
95  tgtPatch
96  );
97 
98  srcSpheres_.resize(srcPatch.size());
99  forAll(srcPatch, srcFacei)
100  {
101  srcSpheres_[srcFacei] =
102  boundSphere::local
103  (
104  UIndirectList<point>(srcPatch.points(), srcPatch[srcFacei])
105  );
106  }
107 
108  tgtSpheres_.resize(tgtPatch.size());
109  forAll(tgtPatch, tgtFacei)
110  {
111  tgtSpheres_[tgtFacei] =
112  boundSphere::local
113  (
114  UIndirectList<point>(tgtPatch.points(), tgtPatch[tgtFacei])
115  );
116  }
117 }
118 
119 
120 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
121 
123 :
125  srcSpheres_(),
126  tgtSpheres_()
127 {}
128 
129 
130 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
131 
133 {}
134 
135 
136 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:449
const Field< PointType > & points() const
Return reference to global points.
A List with indirect addressing.
Definition: UIndirectList.H:61
static const Form one
Definition: VectorSpace.H:119
point midpoint() const
The midpoint of the bounding box.
Definition: boundBoxI.H:112
scalar maxDim() const
Largest length/height/width dimension.
Definition: boundBoxI.H:142
static bool overlap(const boundSphere &a, const boundSphere &b)
Return whether two spheres overlap.
Definition: boundSphereI.H:183
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
virtual void initialise(const primitiveOldTimePatch &srcPatch, const vectorField &srcPointNormals, const vectorField &srcPointNormals0, const primitiveOldTimePatch &tgtPatch)
Initialisation.
Definition: patchToPatch.C:640
Class to generate patchToPatch coupling geometry. Couples a face to the single nearby opposite face o...
nearby(const bool reverse)
Construct from components.
virtual bool intersectFaces(const primitiveOldTimePatch &srcPatch, const vectorField &srcPointNormals, const vectorField &srcPointNormals0, const primitiveOldTimePatch &tgtPatch, const label srcFacei, const label tgtFacei)
Intersect two faces.
virtual treeBoundBox srcBox(const face &srcFace, const pointField &srcPoints, const vectorField &srcPointNormals) const
Get the bound box for a source face.
virtual void initialise(const primitiveOldTimePatch &srcPatch, const vectorField &srcPointNormals, const vectorField &srcPointNormals0, const primitiveOldTimePatch &tgtPatch)
Initialisation.
Standard boundBox + extra functionality for use in octree.
Definition: treeBoundBox.H:90
const dimensionedScalar c
Speed of light in a vacuum.
defineTypeNameAndDebug(intersection, 0)
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
void reverse(UList< T > &, const label n)
Definition: UListI.H:334