50 cyclicPeriodicAMIPolyPatch,
58 void Foam::cyclicPeriodicAMIPolyPatch::syncTransforms()
const
82 refCast<const coupledPolyPatch>
89 if (
returnReduce((size() && !periodicPatch.size()), orOp<bool>()))
91 if (periodicPatch.separation().size() > 1)
95 <<
" has non-uniform separation vector "
96 << periodicPatch.separation()
97 <<
"This is not allowed inside " <<
type()
98 <<
" patch " <<
name()
102 if (periodicPatch.forwardT().size() > 1)
106 <<
" has non-uniform transformation tensor "
107 << periodicPatch.forwardT()
108 <<
"This is not allowed inside " <<
type()
109 <<
" patch " <<
name()
125 && periodicPatch.parallel()
127 reduce(isParallel, orOp<bool>());
144 if (!periodicPatch.size())
148 if (sep[procI].size())
152 periodicPatch.separation()
156 periodicPatch.collocated()
179 if (!periodicPatch.size())
187 periodicPatch.forwardT()
191 periodicPatch.reverseT()
204 void Foam::cyclicPeriodicAMIPolyPatch::writeOBJ
231 void Foam::cyclicPeriodicAMIPolyPatch::resetAMI()
const
236 const coupledPolyPatch& periodicPatch
238 refCast<const coupledPolyPatch>
240 boundaryMesh()[periodicPatchID()]
249 pointField nbrPoints0(neighbPatch().localPoints());
250 transformPosition(nbrPoints0);
256 if (nTransforms_ > nSectors_/2)
258 nTransforms_ -= nSectors_;
260 else if (nTransforms_ < - nSectors_/2)
262 nTransforms_ += nSectors_;
267 for (label i = 0; i < nTransforms_; ++ i)
269 periodicPatch.transformPosition(thisPoints0);
271 for (label i = 0; i > nTransforms_; -- i)
273 periodicPatch.transformPosition(nbrPoints0);
276 autoPtr<OBJstream> ownStr;
277 autoPtr<OBJstream> neiStr;
280 const Time&
runTime = boundaryMesh().mesh().
time();
285 ownStr.reset(
new OBJstream(dir/
name() + postfix));
286 neiStr.reset(
new OBJstream(dir/neighbPatch().
name() + postfix));
289 <<
"patch:" <<
name()
290 <<
" writing accumulated AMI to " << ownStr().name()
291 <<
" and " << neiStr().name() <<
endl;
303 SubList<face>(localFaces(), size()),
309 SubList<face>(localFaces(), size()),
315 SubList<face>(neighbPatch().localFaces(), neighbPatch().size()),
321 SubList<face>(neighbPatch().localFaces(), neighbPatch().size()),
326 AMIPtr_->setRequireMatch(
false);
327 AMIPtr_->calculate(thisPatch0, nbrPatch0, surfPtr());
331 label nTransformsOld(nTransforms_);
344 scalar srcSum(
gAverage(AMIPtr_->srcWeightsSum()));
345 scalar tgtSum(
gAverage(AMIPtr_->tgtWeightsSum()));
356 scalar srcSumDiff = 0;
359 <<
"patch:" <<
name()
360 <<
" srcSum:" << srcSum
361 <<
" tgtSum:" << tgtSum
370 (1 - srcSum > matchTolerance())
371 || (1 - tgtSum > matchTolerance())
377 periodicPatch.transformPosition(thisPoints);
380 <<
"patch:" <<
name()
381 <<
" moving this side from:"
385 thisPatch.movePoints(thisPoints);
388 <<
"patch:" <<
name()
389 <<
" appending weights with untransformed slave side"
392 AMIPtr_->append(thisPatch, nbrPatch0);
401 periodicPatch.transformPosition(nbrPoints);
404 <<
"patch:" <<
name()
405 <<
" moving neighbour side from:"
409 nbrPatch.movePoints(nbrPoints);
411 AMIPtr_->append(thisPatch0, nbrPatch);
419 const scalar srcSumNew =
gAverage(AMIPtr_->srcWeightsSum());
420 const scalar srcSumDiffNew = srcSumNew - srcSum;
422 if (srcSumDiffNew < srcSumDiff || srcSumDiffNew < SMALL)
426 srcSumDiff = srcSumDiffNew;
430 tgtSum =
gAverage(AMIPtr_->tgtWeightsSum());
437 <<
"patch:" <<
name()
438 <<
" iteration:" << iter
439 <<
" srcSum:" << srcSum
440 <<
" tgtSum:" << tgtSum
447 ownStr.reset(
nullptr);
448 neiStr.reset(
nullptr);
452 nTransforms_ = (nTransforms_ + nTransformsOld)/2;
455 if (iter == maxIter_)
466 <<
"Patches " <<
name() <<
" and " << neighbPatch().name()
467 <<
" do not couple to within a tolerance of "
469 <<
" when transformed according to the periodic patch "
470 << periodicPatch.name() <<
"." <<
nl
471 <<
"The current sum of weights are for owner " <<
name()
472 <<
" : " << srcSum <<
" and for neighbour "
473 << neighbPatch().name() <<
" : " << tgtSum <<
nl
474 <<
"This is only acceptable during post-processing"
475 <<
"; not during running. Improve your mesh or increase"
476 <<
" the 'matchTolerance' setting in the patch specification."
483 mag(srcSum - floor(srcSum + 0.5)) > srcSum*matchTolerance()
484 ||
mag(tgtSum - floor(tgtSum + 0.5)) > tgtSum*matchTolerance()
493 <<
"Patches " <<
name() <<
" and " << neighbPatch().name()
494 <<
" do not overlap an integer number of times when transformed"
495 <<
" according to the periodic patch "
496 << periodicPatch.name() <<
"." <<
nl
497 <<
"The current matchTolerance : " << matchTolerance()
498 <<
", sum of owner weights : " << srcSum
499 <<
", sum of neighbour weights : " << tgtSum
501 <<
"This is only acceptable during post-processing"
502 <<
"; not during running. Improve your mesh or increase"
503 <<
" the 'matchTolerance' setting in the patch specification."
508 const label nFace =
returnReduce(size(), sumOp<label>());
515 srcWghtSum[faceI] =
sum(AMIPtr_->srcWeights()[faceI]);
520 tgtWghtSum[faceI] =
sum(AMIPtr_->tgtWeights()[faceI]);
524 <<
"AMI: Patch " <<
name()
526 <<
" min:" <<
gMin(srcWghtSum)
527 <<
" max:" <<
gMax(srcWghtSum)
530 <<
"AMI: Patch " << neighbPatch().
name()
532 <<
" min:" <<
gMin(tgtWghtSum)
533 <<
" max:" <<
gMax(tgtWghtSum)
548 const polyBoundaryMesh& bm,
549 const word& patchType,
562 faceAreaWeightAMI::typeName
568 AMIPtr_->setRequireMatch(
false);
578 const word& patchType
590 nTransforms_(
dict.getOrDefault<label>(
"nTransforms", 0)),
591 nSectors_(
dict.getOrDefault<label>(
"nSectors", 0)),
592 maxIter_(
dict.getOrDefault<label>(
"maxIter", 36))
594 AMIPtr_->setRequireMatch(
false);
605 nTransforms_(pp.nTransforms_),
606 nSectors_(pp.nSectors_),
607 maxIter_(pp.maxIter_)
609 AMIPtr_->setRequireMatch(
false);
619 const label newStart,
620 const word& nbrPatchName
624 nTransforms_(pp.nTransforms_),
625 nSectors_(pp.nSectors_),
626 maxIter_(pp.maxIter_)
628 AMIPtr_->setRequireMatch(
false);
642 nTransforms_(pp.nTransforms_),
643 nSectors_(pp.nSectors_),
644 maxIter_(pp.maxIter_)
646 AMIPtr_->setRequireMatch(
false);