50 { interpolationMethod::imDirect,
"direct" },
51 { interpolationMethod::imMapNearest,
"mapNearest" },
52 { interpolationMethod::imCellVolumeWeight,
"cellVolumeWeight" },
54 interpolationMethod::imCorrectedCellVolumeWeight,
55 "correctedCellVolumeWeight"
66 { procMapMethod::pmAABB,
"AABB" },
67 { procMapMethod::pmLOD,
"LOD" },
74 void Foam::meshToMesh::mapInternalSrcToTgt
79 const bool secondOrder
87 void Foam::meshToMesh::mapInternalSrcToTgt
92 const bool secondOrder
100 void Foam::meshToMesh::mapInternalSrcToTgt
105 const bool secondOrder
113 void Foam::meshToMesh::mapInternalSrcToTgt
118 const bool secondOrder
126 void Foam::meshToMesh::mapInternalSrcToTgt
131 const bool secondOrder
139 void Foam::meshToMesh::mapInternalSrcToTgt
144 const bool secondOrder
152 void Foam::meshToMesh::mapInternalTgtToSrc
157 const bool secondOrder
165 void Foam::meshToMesh::mapInternalTgtToSrc
170 const bool secondOrder
178 void Foam::meshToMesh::mapInternalTgtToSrc
183 const bool secondOrder
191 void Foam::meshToMesh::mapInternalTgtToSrc
196 const bool secondOrder
204 void Foam::meshToMesh::mapInternalTgtToSrc
209 const bool secondOrder
217 void Foam::meshToMesh::mapInternalTgtToSrc
222 const bool secondOrder
230 void Foam::meshToMesh::mapAndOpSrcToTgt
241 void Foam::meshToMesh::mapAndOpSrcToTgt
252 void Foam::meshToMesh::mapAndOpSrcToTgt
263 void Foam::meshToMesh::mapAndOpSrcToTgt
274 void Foam::meshToMesh::mapAndOpSrcToTgt
285 void Foam::meshToMesh::mapAndOpTgtToSrc
296 void Foam::meshToMesh::mapAndOpTgtToSrc
307 void Foam::meshToMesh::mapAndOpTgtToSrc
318 void Foam::meshToMesh::mapAndOpTgtToSrc
329 void Foam::meshToMesh::mapAndOpTgtToSrc
351 intersectBb.inflate(0.01);
361 if (intersectBb.overlaps(cellBb))
369 Pout<<
"participating source mesh cells: " <<
cells.size() <<
endl;
376 void Foam::meshToMesh::normaliseWeights
378 const word& descriptor,
383 const label nCell =
returnReduce(wght.size(), sumOp<label>());
403 void Foam::meshToMesh::calcAddressing
405 const word& methodName,
410 autoPtr<meshToMeshMethod> methodPtr
434 methodPtr->writeConnectivity(src, tgt, srcToTgtCellAddr_);
439 void Foam::meshToMesh::calculate(
const word& methodName,
const bool normalise)
441 Info<<
"Creating mesh-to-mesh addressing for " << srcRegion_.name()
442 <<
" and " << tgtRegion_.name() <<
" regions using "
443 << methodName <<
endl;
445 singleMeshProc_ = calcDistribution(srcRegion_, tgtRegion_);
447 if (singleMeshProc_ == -1)
450 globalIndex globalSrcCells(srcRegion_.nCells());
451 globalIndex globalTgtCells(tgtRegion_.nCells());
456 autoPtr<mapDistribute> mapPtr = calcProcMap(srcRegion_, tgtRegion_);
457 const mapDistribute& map = mapPtr();
465 distributeAndMergeCells
473 newTgtFaceNeighbours,
484 tgtRegion_.time().timeName(),
489 std::move(newTgtPoints),
490 std::move(newTgtFaces),
491 std::move(newTgtFaceOwners),
492 std::move(newTgtFaceNeighbours),
501 newTgt.nBoundaryFaces(),
502 newTgt.nInternalFaces(),
504 newTgt.boundaryMesh(),
511 (void)newTgt.tetBasePtIs();
518 Pout<<
"Created newTgt mesh:" <<
nl
519 <<
" old cells = " << tgtRegion_.nCells()
520 <<
", new cells = " << newTgt.nCells() <<
nl
521 <<
" old faces = " << tgtRegion_.nFaces()
522 <<
", new faces = " << newTgt.nFaces() <<
endl;
526 Pout<<
"Writing newTgt mesh: " << newTgt.
name() <<
endl;
531 calcAddressing(methodName, srcRegion_, newTgt);
534 for (
labelList& addressing : srcToTgtCellAddr_)
536 for (label& addr : addressing)
538 addr = newTgtCellIDs[addr];
543 for (
labelList& addressing : tgtToSrcCellAddr_)
545 globalSrcCells.inplaceToGlobal(addressing);
560 ListOps::appendEqOp<label>(),
578 ListOps::appendEqOp<scalar>(),
603 List<Map<label>> cMap;
606 new mapDistribute(globalSrcCells, tgtToSrcCellAddr_, cMap)
610 new mapDistribute(globalTgtCells, srcToTgtCellAddr_, cMap)
614 reduce(V_, sumOp<scalar>());
618 calcAddressing(methodName, srcRegion_, tgtRegion_);
638 Info<<
" Overlap volume: " << V_ <<
endl;
649 case interpolationMethod::imDirect:
651 return nearestFaceAMI::typeName;
654 case interpolationMethod::imMapNearest:
656 return nearestFaceAMI::typeName;
659 case interpolationMethod::imCellVolumeWeight:
660 case interpolationMethod::imCorrectedCellVolumeWeight:
662 return faceAreaWeightAMI::typeName;
668 <<
"Unhandled enumeration " << interpolationMethodNames_[method]
673 return nearestFaceAMI::typeName;
677 void Foam::meshToMesh::calculatePatchAMIs(
const word& AMIMethodName)
679 if (!patchAMIs_.empty())
682 <<
"patch AMI already calculated"
686 patchAMIs_.setSize(srcPatchID_.size());
690 label srcPatchi = srcPatchID_[i];
691 label tgtPatchi = tgtPatchID_[i];
693 const polyPatch& srcPP = srcRegion_.boundaryMesh()[srcPatchi];
694 const polyPatch& tgtPP = tgtRegion_.boundaryMesh()[tgtPatchi];
696 Info<<
"Creating AMI between source patch " << srcPP.name()
697 <<
" and target patch " << tgtPP.name()
698 <<
" using " << AMIMethodName
715 patchAMIs_[i].calculate(srcPP, tgtPP);
722 void Foam::meshToMesh::constructNoCuttingPatches
724 const word& methodName,
725 const word& AMIMethodName,
726 const bool interpAllPatches
729 if (interpAllPatches)
731 const polyBoundaryMesh& srcBM = srcRegion_.boundaryMesh();
732 const polyBoundaryMesh& tgtBM = tgtRegion_.boundaryMesh();
734 DynamicList<label> srcPatchID(srcBM.size());
735 DynamicList<label> tgtPatchID(tgtBM.size());
738 const polyPatch& pp = srcBM[patchi];
743 if (!isA<processorPolyPatch>(pp))
745 srcPatchID.append(pp.index());
747 label tgtPatchi = tgtBM.findPatchID(pp.name());
751 tgtPatchID.append(tgtPatchi);
756 <<
"Source patch " << pp.name()
757 <<
" not found in target mesh. "
758 <<
"Available target patches are " << tgtBM.names()
764 srcPatchID_.transfer(srcPatchID);
765 tgtPatchID_.transfer(tgtPatchID);
769 calculate(methodName,
true);
772 calculatePatchAMIs(AMIMethodName);
776 void Foam::meshToMesh::constructFromCuttingPatches
778 const word& methodName,
779 const word& AMIMethodName,
780 const HashTable<word>& patchMap,
785 const polyBoundaryMesh& srcBm = srcRegion_.boundaryMesh();
786 const polyBoundaryMesh& tgtBm = tgtRegion_.boundaryMesh();
789 cuttingPatches_.setSize(cuttingPatches.size());
790 forAll(cuttingPatches_, i)
792 const word& patchName = cuttingPatches[i];
793 label cuttingPatchi = srcBm.findPatchID(patchName);
795 if (cuttingPatchi == -1)
798 <<
"Unable to find patch '" << patchName
799 <<
"' in mesh '" << srcRegion_.name() <<
"'. "
800 <<
" Available patches include:" << srcBm.names()
804 cuttingPatches_[i] = cuttingPatchi;
807 DynamicList<label> srcIDs(patchMap.size());
808 DynamicList<label> tgtIDs(patchMap.size());
812 const word& tgtPatchName = iter.key();
813 const word& srcPatchName = iter.val();
815 const polyPatch& srcPatch = srcBm[srcPatchName];
820 if (!isA<processorPolyPatch>(srcPatch))
822 const polyPatch& tgtPatch = tgtBm[tgtPatchName];
824 srcIDs.append(srcPatch.index());
825 tgtIDs.append(tgtPatch.index());
829 srcPatchID_.transfer(srcIDs);
830 tgtPatchID_.transfer(tgtIDs);
833 calculate(methodName, normalise);
836 calculatePatchAMIs(AMIMethodName);
842 Foam::meshToMesh::meshToMesh
848 bool interpAllPatches
853 procMapMethod_(mapMethod),
869 constructNoCuttingPatches
871 interpolationMethodNames_[method],
872 interpolationMethodAMI(method),
878 Foam::meshToMesh::meshToMesh
882 const word& methodName,
883 const word& AMIMethodName,
885 bool interpAllPatches
890 procMapMethod_(mapMethod),
906 constructNoCuttingPatches(methodName, AMIMethodName, interpAllPatches);
910 Foam::meshToMesh::meshToMesh
923 procMapMethod_(mapMethod),
937 constructFromCuttingPatches
939 interpolationMethodNames_[method],
940 interpolationMethodAMI(method),
948 Foam::meshToMesh::meshToMesh
952 const word& methodName,
953 const word& AMIMethodName,
962 procMapMethod_(mapMethod),
976 constructFromCuttingPatches