34 namespace patchToPatches
51 const treeBoundBox bb(srcPoints, srcFace);
53 const point c = bb.midpoint();
54 const scalar l = bb.maxDim();
56 return treeBoundBox(c - l*
vector::one, c + l*vector::one);
60 bool Foam::patchToPatches::inverseDistance::inside
68 using namespace constant::mathematical;
76 const vector& a = T & (ps[f[i]] -
p);
77 const vector& b = T & (ps[f[f.fcIndex(i)]] -
p);
79 angle -=
sign(r & (a ^ b))*
acos((a & b)/magAB);
82 return pi < angle && angle < 3*
pi;
86 bool Foam::patchToPatches::inverseDistance::intersectFaces
91 const label otherFacei,
92 DynamicList<label>& faceOtherFaces,
93 DynamicList<scalar>& faceWeights
96 const face& f = otherPatch[otherFacei];
99 const point& p = patch.faceCentres()[facei];
100 const vector& r = patch.faceNormals()[facei];
102 bool intersectsOther = inside(f, ps, p, r);
104 if (!intersectsOther)
106 forAll(otherPatch.faceFaces()[otherFacei], otherFaceFacei)
108 const label otherFacej =
109 otherPatch.faceFaces()[otherFacei][otherFaceFacei];
111 const face& g = otherPatch[otherFacej];
113 if (inside(g, ps, p, r))
115 intersectsOther =
true;
123 faceOtherFaces.append(otherFacei);
126 1/
max(
mag(p - otherPatch.faceCentres()[otherFacei]), vSmall)
130 return intersectsOther;
134 bool Foam::patchToPatches::inverseDistance::intersectFaces
140 const label srcFacei,
144 const bool srcCouples =
151 srcLocalTgtFaces_[srcFacei],
152 srcWeights_[srcFacei]
155 const bool tgtCouples =
162 tgtLocalSrcFaces_[tgtFacei],
163 tgtWeights_[tgtFacei]
166 return srcCouples || tgtCouples;
170 void Foam::patchToPatches::inverseDistance::initialise
186 srcWeights_.resize(srcPatch.size());
187 tgtWeights_.resize(tgtPatch.size());
191 void Foam::patchToPatches::inverseDistance::rDistributeTgt
194 const distributionMap& tgtMap
199 rDistributeListList(tgtPatch.size(), tgtMap, tgtWeights_);
203 Foam::label Foam::patchToPatches::inverseDistance::finalise
209 const transformer& tgtToSrc
212 const label nCouples =
222 forAll(srcWeights_, srcFacei)
224 const scalar w =
sum(srcWeights_[srcFacei]);
226 forAll(srcWeights_[srcFacei], i)
228 srcWeights_[srcFacei][i] /=
max(w, vSmall);
232 forAll(tgtWeights_, tgtFacei)
234 const scalar w =
sum(tgtWeights_[tgtFacei]);
236 forAll(tgtWeights_[tgtFacei], i)
238 tgtWeights_[tgtFacei][i] /=
max(w, vSmall);
addToRunTimeSelectionTable(patchToPatch, intersection, bool)
~inverseDistance()
Destructor.
dimensionedScalar sign(const dimensionedScalar &ds)
inverseDistance(const bool reverse)
Construct from components.
dimensionedScalar acos(const dimensionedScalar &ds)
#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.
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
FvWallInfoData< WallInfo, label > label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
dimensionedScalar sqrt(const dimensionedScalar &ds)
Vector< scalar > vector
A scalar version of the templated Vector.
Macros for easy insertion into run-time selection tables.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
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.
virtual tmpNrc< List< DynamicList< scalar > > > srcWeights(const primitivePatch &srcPatch) const
For each source face, the coupled target weights.
dimensioned< scalar > magSqr(const dimensioned< Type > &)
void reverse(UList< T > &, const label n)
virtual tmpNrc< List< DynamicList< scalar > > > tgtWeights(const primitivePatch &tgtPatch) const
For each target face, the coupled source weights.
PrimitivePatch< SubList< face >, const pointField & > primitivePatch
Addressing for a faceList slice.
A class for managing temporary objects without reference counting.
virtual label finalise(const primitiveOldTimePatch &srcPatch, const vectorField &srcPointNormals, const vectorField &srcPointNormals0, const primitiveOldTimePatch &tgtPatch, const transformer &tgtToSrc)
Finalising.
vector point
Point is a vector.
Standard boundBox + extra functionality for use in octree.
static const Vector< scalar > one
dimensioned< scalar > mag(const dimensioned< Type > &)
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.
Tensor< scalar > tensor
Tensor of scalars.