57 Info<<
"NO MATCH for source face " << srcFacei <<
endl;
70 const face& srcF = src[srcFacei];
72 for (
const label pointi : srcF)
74 const point&
p = srcPoints[pointi];
75 os <<
"v " <<
p.x() <<
" " <<
p.y() <<
" " <<
p.z() <<
nl;
79 os << faceStr.c_str() <<
" " << (np - srcF.size() + 1) <<
nl;
82 for (
const label tgtFacei : tgtFaceCandidates)
84 const face& tgtF = tgt[tgtFacei];
87 const point&
p = tgtPoints[tgtF[pointi]];
88 os <<
"v " <<
p.x() <<
" " <<
p.y() <<
" " <<
p.z() <<
nl;
92 os <<
"l " << np-1 <<
" " << np <<
nl;
95 os <<
"l " << (np - tgtF.size() + 1) <<
" " << np <<
nl;
100 OFstream
os(
"no_match_" +
Foam::name(srcFacei) +
"_bb.obj");
105 os <<
"v " <<
p.x() <<
" " <<
p.y() <<
" " <<
p.z() <<
endl;
125 const label srcFacei,
126 const label tgtFacei,
127 DynamicList<label>& srcAddr,
128 DynamicList<scalar>& srcWght,
129 DynamicList<vector>& srcCtr,
130 DynamicList<label>& tgtAddr,
131 DynamicList<scalar>& tgtWght
134 addProfiling(ami,
"faceAreaWeightAMI2D::calcInterArea");
139 (srcMagSf_[srcFacei] < ROOTVSMALL)
140 || (tgtMagSf_[tgtFacei] < ROOTVSMALL)
146 const auto& srcPatch = this->srcPatch();
147 const auto& tgtPatch = this->tgtPatch();
152 const auto& srcTris = srcTris_[srcFacei];
153 const auto& tgtTris = tgtTris_[tgtFacei];
155 const auto& srcFaceNormals = srcPatch.
faceNormals();
162 for (
const auto& tris : srcTris)
164 const vector& origin = srcPoints[tris[0]];
165 const vector p10(srcPoints[tris[1]] - origin);
166 const vector p20(srcPoints[tris[2]] - origin);
167 const vector axis1(p10/(
mag(p10) + ROOTVSMALL));
168 const vector axis2(srcFaceNormals[srcFacei]^axis1);
177 for (
const auto& trit : tgtTris)
182 tgtPoints[trit[0]] - origin,
183 tgtPoints[trit[2]] - origin,
184 tgtPoints[trit[1]] - origin,
192 if (t.snapClosePoints(
s) == 3)
199 s.interArea(t,
c, da);
203 centroid += da*(origin +
c.x()*axis1 +
c.y()*axis2);
211 centroid /=
area + ROOTVSMALL;
214 srcWght.append(
area);
215 srcCtr.append(centroid);
217 tgtAddr.append(srcFacei);
218 tgtWght.append(
area);
225 const AABBTree<face>& tree,
226 const List<boundBox>& tgtFaceBbs,
227 const boundBox& srcFaceBb
232 const auto& treeBb = tree.boundBoxes();
233 const auto& treeAddr = tree.addressing();
237 const auto& tbb = treeBb[boxi];
239 if (srcFaceBb.overlaps(tbb))
241 const auto& boxAddr = treeAddr[boxi];
243 for (
const auto& tgtFacei : boxAddr)
245 if (srcFaceBb.overlaps(tgtFaceBbs[tgtFacei]))
247 faceIds.insert(tgtFacei);
253 return faceIds.toc();
262 const bool reverseTarget
272 const bool requireMatch,
273 const bool reverseTarget,
274 const scalar lowWeightCorrection,
276 const bool restartUncoveredSourceFace
318 const auto& src = this->srcPatch();
319 const auto& tgt = this->tgtPatch();
321 bool validSize =
true;
328 else if (!tgt.size())
331 << src.size() <<
" source faces but no target faces" <<
endl;
336 srcCentroids_.setSize(srcAddress_.size());
339 List<DynamicList<label>> tgtAddr(tgt.size());
340 List<DynamicList<scalar>> tgtWght(tgt.size());
351 const bool equalBinSize =
true;
352 const label maxLevel = 10;
353 const label minBinSize = 4;
363 const auto& tgtPoints = tgt.points();
364 List<boundBox> tgtFaceBbs(tgt.size());
367 tgtFaceBbs[facei] = boundBox(tgtPoints, tgt[facei],
false);
370 DynamicList<label> nonOverlapFaces;
372 const auto& srcPoints = src.points();
376 const face& srcFace = src[srcFacei];
378 treeBoundBox srcFaceBb(srcPoints, srcFace);
379 srcFaceBb.min() -= d;
380 srcFaceBb.max() += d;
384 overlappingTgtFaces(tree, tgtFaceBbs, srcFaceBb)
387 DynamicList<label> srcAddr(tgtFaces.size());
388 DynamicList<scalar> srcWght(tgtFaces.size());
389 DynamicList<point> srcCtr(tgtFaces.size());
391 for (
const label tgtFacei : tgtFaces)
405 if (mustMatchFaces() && srcAddr.empty())
407 if (
debug) writeNoMatch(srcFacei, tgtFaces, srcFaceBb);
414 srcAddress_[srcFacei].transfer(srcAddr);
415 srcWeights_[srcFacei].transfer(srcWght);
416 srcCentroids_[srcFacei].transfer(srcCtr);
419 srcNonOverlap_.transfer(nonOverlapFaces);
421 if (
debug && !srcNonOverlap_.empty())
423 Pout<<
" AMI: " << srcNonOverlap_.size()
424 <<
" non-overlap faces identified"
433 tgtAddress_[i].transfer(tgtAddr[i]);
434 tgtWeights_[i].transfer(tgtWght[i]);
443 globalIndex globalSrcFaces(srcPatch0.size());
444 globalIndex globalTgtFaces(tgtPatch0.size());
446 for (
labelList& addressing : srcAddress_)
448 for (label& addr : addressing)
450 addr = extendedTgtFaceIDs_[addr];
454 for (
labelList& addressing : tgtAddress_)
456 globalSrcFaces.inplaceToGlobal(addressing);
467 extendedTgtMapPtr_->constructMap(),
469 extendedTgtMapPtr_->subMap(),
473 ListOps::appendEqOp<label>(),
482 extendedTgtMapPtr_->constructMap(),
484 extendedTgtMapPtr_->subMap(),
488 ListOps::appendEqOp<scalar>(),
493 extendedTgtMapPtr_->reverseDistribute(tgtPatch0.size(), tgtMagSf_);
496 List<Map<label>> cMapSrc;
499 new mapDistribute(globalSrcFaces, tgtAddress_, cMapSrc)
502 List<Map<label>> cMapTgt;
505 new mapDistribute(globalTgtFaces, srcAddress_, cMapTgt)
510 normaliseWeights(requireMatch_,
true);
512 nonConformalCorrection();