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);
559 ListOps::appendEqOp<label>(),
575 ListOps::appendEqOp<scalar>(),
599 List<Map<label>> cMap;
602 new mapDistribute(globalSrcCells, tgtToSrcCellAddr_, cMap)
606 new mapDistribute(globalTgtCells, srcToTgtCellAddr_, cMap)
610 reduce(V_, sumOp<scalar>());
614 calcAddressing(methodName, srcRegion_, tgtRegion_);
634 Info<<
" Overlap volume: " << V_ <<
endl;
645 case interpolationMethod::imDirect:
647 return nearestFaceAMI::typeName;
650 case interpolationMethod::imMapNearest:
652 return nearestFaceAMI::typeName;
655 case interpolationMethod::imCellVolumeWeight:
656 case interpolationMethod::imCorrectedCellVolumeWeight:
658 return faceAreaWeightAMI::typeName;
664 <<
"Unhandled enumeration " << interpolationMethodNames_[method]
669 return nearestFaceAMI::typeName;
673 void Foam::meshToMesh::calculatePatchAMIs(
const word& AMIMethodName)
675 if (!patchAMIs_.empty())
678 <<
"patch AMI already calculated"
682 patchAMIs_.setSize(srcPatchID_.size());
686 label srcPatchi = srcPatchID_[i];
687 label tgtPatchi = tgtPatchID_[i];
689 const polyPatch& srcPP = srcRegion_.boundaryMesh()[srcPatchi];
690 const polyPatch& tgtPP = tgtRegion_.boundaryMesh()[tgtPatchi];
692 Info<<
"Creating AMI between source patch " << srcPP.name()
693 <<
" and target patch " << tgtPP.name()
694 <<
" using " << AMIMethodName
711 patchAMIs_[i].calculate(srcPP, tgtPP);
718 void Foam::meshToMesh::constructNoCuttingPatches
720 const word& methodName,
721 const word& AMIMethodName,
722 const bool interpAllPatches
725 if (interpAllPatches)
727 const polyBoundaryMesh& srcBM = srcRegion_.boundaryMesh();
728 const polyBoundaryMesh& tgtBM = tgtRegion_.boundaryMesh();
730 DynamicList<label> srcPatchID(srcBM.size());
731 DynamicList<label> tgtPatchID(tgtBM.size());
734 const polyPatch& pp = srcBM[patchi];
739 if (!isA<processorPolyPatch>(pp))
741 srcPatchID.append(pp.index());
743 label tgtPatchi = tgtBM.findPatchID(pp.name());
747 tgtPatchID.append(tgtPatchi);
752 <<
"Source patch " << pp.name()
753 <<
" not found in target mesh. "
754 <<
"Available target patches are " << tgtBM.names()
760 srcPatchID_.transfer(srcPatchID);
761 tgtPatchID_.transfer(tgtPatchID);
765 calculate(methodName,
true);
768 calculatePatchAMIs(AMIMethodName);
772 void Foam::meshToMesh::constructFromCuttingPatches
774 const word& methodName,
775 const word& AMIMethodName,
776 const HashTable<word>& patchMap,
781 const polyBoundaryMesh& srcBm = srcRegion_.boundaryMesh();
782 const polyBoundaryMesh& tgtBm = tgtRegion_.boundaryMesh();
785 cuttingPatches_.setSize(cuttingPatches.size());
786 forAll(cuttingPatches_, i)
788 const word& patchName = cuttingPatches[i];
789 label cuttingPatchi = srcBm.findPatchID(patchName);
791 if (cuttingPatchi == -1)
794 <<
"Unable to find patch '" << patchName
795 <<
"' in mesh '" << srcRegion_.name() <<
"'. "
796 <<
" Available patches include:" << srcBm.names()
800 cuttingPatches_[i] = cuttingPatchi;
803 DynamicList<label> srcIDs(patchMap.size());
804 DynamicList<label> tgtIDs(patchMap.size());
808 const word& tgtPatchName = iter.key();
809 const word& srcPatchName = iter.val();
811 const polyPatch& srcPatch = srcBm[srcPatchName];
816 if (!isA<processorPolyPatch>(srcPatch))
818 const polyPatch& tgtPatch = tgtBm[tgtPatchName];
820 srcIDs.append(srcPatch.index());
821 tgtIDs.append(tgtPatch.index());
825 srcPatchID_.transfer(srcIDs);
826 tgtPatchID_.transfer(tgtIDs);
829 calculate(methodName, normalise);
832 calculatePatchAMIs(AMIMethodName);
838 Foam::meshToMesh::meshToMesh
844 bool interpAllPatches
849 procMapMethod_(mapMethod),
865 constructNoCuttingPatches
867 interpolationMethodNames_[method],
868 interpolationMethodAMI(method),
874 Foam::meshToMesh::meshToMesh
878 const word& methodName,
879 const word& AMIMethodName,
881 bool interpAllPatches
886 procMapMethod_(mapMethod),
902 constructNoCuttingPatches(methodName, AMIMethodName, interpAllPatches);
906 Foam::meshToMesh::meshToMesh
919 procMapMethod_(mapMethod),
933 constructFromCuttingPatches
935 interpolationMethodNames_[method],
936 interpolationMethodAMI(method),
944 Foam::meshToMesh::meshToMesh
948 const word& methodName,
949 const word& AMIMethodName,
958 procMapMethod_(mapMethod),
972 constructFromCuttingPatches