33 namespace patchToPatches
50 const treeBoundBox bb(srcPoints, srcFace);
52 const point c = bb.midpoint();
53 const scalar l = bb.maxDim();
55 return treeBoundBox(c - l*
vector::one, c + l*vector::one);
59 bool Foam::patchToPatches::nearest::intersectFaces
64 const label otherFacei,
65 DynamicList<label>& faceOtherFaces,
69 auto closest = [&patch,&otherPatch]
72 const label otherFacei
75 const point& c = patch.faceCentres()[facei];
76 const point& otherC = otherPatch.faceCentres()[otherFacei];
77 const scalar distSqr =
magSqr(c - otherC);
79 forAll(otherPatch.faceEdges()[otherFacei], otherFaceEdgei)
81 const label otherEdgei =
82 otherPatch.faceEdges()[otherFacei][otherFaceEdgei];
86 if (otherPatch.edgeFaces()[otherEdgei].size() == 2)
89 otherPatch.edgeFaces()[otherEdgei]
90 [otherPatch.edgeFaces()[otherEdgei][0] == otherFacei];
92 otherNbrC = otherPatch.faceCentres()[facej];
96 const edge& e = otherPatch.edges()[otherEdgei];
97 const point& p = otherPatch.localPoints()[e[0]];
98 const vector dp = e.vec(otherPatch.localPoints());
99 const vector n = otherPatch.faceNormals()[otherFacei] ^ dp;
101 otherNbrC = p + ((
tensor::I - 2*
sqr(n)) & (otherC - p));
104 if (
magSqr(c - otherNbrC) < distSqr)
113 if (closest(facei, otherFacei))
115 const point& c = patch.faceCentres()[facei];
116 const point& otherC = otherPatch.faceCentres()[otherFacei];
117 const scalar distSqr =
magSqr(c - otherC);
119 if (faceOtherFaces.empty() || faceDistance > distSqr)
121 faceOtherFaces.clear();
122 faceOtherFaces.append(otherFacei);
123 faceDistance = distSqr;
129 const labelList& otherFaceFaces = otherPatch.faceFaces()[otherFacei];
130 forAll(otherFaceFaces, otherFaceFacei)
132 if (closest(facei, otherFaceFaces[otherFaceFacei]))
142 bool Foam::patchToPatches::nearest::intersectFaces
148 const label srcFacei,
152 const bool srcCouples =
159 srcLocalTgtFaces_[srcFacei],
160 srcDistances_[srcFacei]
163 const bool tgtCouples =
170 tgtLocalSrcFaces_[tgtFacei],
171 tgtDistances_[tgtFacei]
174 return srcCouples || tgtCouples;
179 void Foam::patchToPatches::nearest::initialise
195 srcDistances_.resize(srcPatch.size());
196 srcDistances_ = vGreat;
198 tgtDistances_.resize(tgtPatch.size());
199 tgtDistances_ = vGreat;
203 void Foam::patchToPatches::nearest::rDistributeTgt
206 const distributionMap& tgtMap
210 List<List<scalar>> tgtDistances(tgtLocalSrcFaces_.size());
211 forAll(tgtLocalSrcFaces_, tgtFacei)
213 if (!tgtLocalSrcFaces_[tgtFacei].empty())
215 tgtDistances[tgtFacei].resize(1, tgtDistances_[tgtFacei]);
223 rDistributeListList(tgtPatch.size(), tgtMap, tgtDistances);
226 forAll(tgtLocalSrcFaces_, tgtFacei)
228 if (tgtLocalSrcFaces_[tgtFacei].size() > 1)
232 const label srcFacei = tgtLocalSrcFaces_[tgtFacei][i];
234 tgtLocalSrcFaces_[tgtFacei].resize(1);
235 tgtLocalSrcFaces_[tgtFacei][0] = srcFacei;
237 tgtDistances_[tgtFacei] = tgtDistances[tgtFacei][i];
273 result[srcFacei].
resize(1, scalar(1));
295 result[tgtFacei].
resize(1, scalar(1));
addToRunTimeSelectionTable(patchToPatch, intersection, bool)
#define forAll(list, i)
Loop across all elements in list.
virtual void rDistributeTgt(const primitiveOldTimePatch &tgtPatch, const distributionMap &tgtMap)
Send data that resulted from an intersection between the source.
FvWallInfoData< WallInfo, label > label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
dimensionedSymmTensor sqr(const dimensionedVector &dv)
label findMin(const ListType &, const label start=0)
Find index of min element (and less than given element).
List< DynamicList< label > > srcLocalTgtFaces_
For each source face, the coupled local target faces.
T & ref()
Return non-const reference or generate a fatal error.
Vector< scalar > vector
A scalar version of the templated Vector.
void resize(const label)
Alias for setSize(const label)
Macros for easy insertion into run-time selection tables.
virtual tmpNrc< List< DynamicList< scalar > > > srcWeights(const primitivePatch &srcPatch) const
For each source face, the coupled target weights.
A list of faces which address into the list of points.
vectorField pointField
pointField is a vectorField.
defineTypeNameAndDebug(intersection, 0)
PrimitiveOldTimePatch< SubList< face >, const pointField & > primitiveOldTimePatch
Addressing for a faceList slice.
List< label > labelList
A List of labels.
nearest(const bool reverse)
Construct from components.
dimensioned< scalar > magSqr(const dimensioned< Type > &)
void reverse(UList< T > &, const label n)
PrimitivePatch< SubList< face >, const pointField & > primitivePatch
Addressing for a faceList slice.
A class for managing temporary objects without reference counting.
vector point
Point is a vector.
List< DynamicList< label > > tgtLocalSrcFaces_
For each target face, the coupled local source faces.
Standard boundBox + extra functionality for use in octree.
static const Vector< scalar > one
Field< vector > vectorField
Specialisation of Field<T> for vector.
virtual void initialise(const primitiveOldTimePatch &srcPatch, const vectorField &srcPointNormals, const vectorField &srcPointNormals0, const primitiveOldTimePatch &tgtPatch)
Initialisation.
Class to generate coupling geometry between two primitive patches.
virtual tmpNrc< List< DynamicList< scalar > > > tgtWeights(const primitivePatch &tgtPatch) const
For each target face, the coupled source weights.