51 { interpolationMethod::imDirect,
"direct" },
52 { interpolationMethod::imMapNearest,
"mapNearest" },
53 { interpolationMethod::imCellVolumeWeight,
"cellVolumeWeight" },
55 interpolationMethod::imCorrectedCellVolumeWeight,
56 "correctedCellVolumeWeight" 67 { procMapMethod::pmAABB,
"AABB" },
68 { procMapMethod::pmLOD,
"LOD" },
75 void Foam::meshToMesh::mapInternalSrcToTgt
80 const bool secondOrder
88 void Foam::meshToMesh::mapInternalSrcToTgt
93 const bool secondOrder
101 void Foam::meshToMesh::mapInternalSrcToTgt
106 const bool secondOrder
114 void Foam::meshToMesh::mapInternalSrcToTgt
119 const bool secondOrder
127 void Foam::meshToMesh::mapInternalSrcToTgt
132 const bool secondOrder
140 void Foam::meshToMesh::mapInternalSrcToTgt
145 const bool secondOrder
153 void Foam::meshToMesh::mapInternalTgtToSrc
158 const bool secondOrder
166 void Foam::meshToMesh::mapInternalTgtToSrc
171 const bool secondOrder
179 void Foam::meshToMesh::mapInternalTgtToSrc
184 const bool secondOrder
192 void Foam::meshToMesh::mapInternalTgtToSrc
197 const bool secondOrder
205 void Foam::meshToMesh::mapInternalTgtToSrc
210 const bool secondOrder
218 void Foam::meshToMesh::mapInternalTgtToSrc
223 const bool secondOrder
231 void Foam::meshToMesh::mapAndOpSrcToTgt
242 void Foam::meshToMesh::mapAndOpSrcToTgt
253 void Foam::meshToMesh::mapAndOpSrcToTgt
264 void Foam::meshToMesh::mapAndOpSrcToTgt
275 void Foam::meshToMesh::mapAndOpSrcToTgt
286 void Foam::meshToMesh::mapAndOpTgtToSrc
297 void Foam::meshToMesh::mapAndOpTgtToSrc
308 void Foam::meshToMesh::mapAndOpTgtToSrc
319 void Foam::meshToMesh::mapAndOpTgtToSrc
330 void Foam::meshToMesh::mapAndOpTgtToSrc
348 max(src.bounds().min(), tgt.bounds().min()),
349 min(src.bounds().max(), tgt.bounds().max())
352 intersectBb.inflate(0.01);
354 const cellList& srcCells = src.cells();
355 const faceList& srcFaces = src.faces();
358 DynamicList<label>
cells(src.size());
361 boundBox cellBb(srcCells[srcI].
points(srcFaces, srcPts),
false);
362 if (intersectBb.overlaps(cellBb))
377 void Foam::meshToMesh::normaliseWeights
379 const word& descriptor,
402 void Foam::meshToMesh::calcAddressing
404 const word& methodName,
409 autoPtr<meshToMeshMethod> methodPtr
433 methodPtr->writeConnectivity(src, tgt, srcToTgtCellAddr_);
438 void Foam::meshToMesh::calculate(
const word& methodName,
const bool normalise)
440 Info<<
"Creating mesh-to-mesh addressing for " << srcRegion_.name()
441 <<
" and " << tgtRegion_.name() <<
" regions using " 442 << methodName <<
endl;
444 singleMeshProc_ = calcDistribution(srcRegion_, tgtRegion_);
446 if (singleMeshProc_ == -1)
449 globalIndex globalSrcCells(srcRegion_.nCells());
450 globalIndex globalTgtCells(tgtRegion_.nCells());
455 autoPtr<mapDistribute> mapPtr = calcProcMap(srcRegion_, tgtRegion_);
456 const mapDistribute& map = mapPtr();
464 distributeAndMergeCells
472 newTgtFaceNeighbours,
483 tgtRegion_.time().timeName(),
488 std::move(newTgtPoints),
489 std::move(newTgtFaces),
490 std::move(newTgtFaceOwners),
491 std::move(newTgtFaceNeighbours),
503 newTgt.nBoundaryFaces(),
504 newTgt.nInternalFaces(),
506 newTgt.boundaryMesh(),
514 (void)newTgt.tetBasePtIs();
521 Pout<<
"Created newTgt mesh:" <<
nl 522 <<
" old cells = " << tgtRegion_.nCells()
523 <<
", new cells = " << newTgt.nCells() <<
nl 524 <<
" old faces = " << tgtRegion_.nFaces()
525 <<
", new faces = " << newTgt.nFaces() <<
endl;
529 Pout<<
"Writing newTgt mesh: " << newTgt.
name() <<
endl;
534 calcAddressing(methodName, srcRegion_, newTgt);
537 for (
labelList& addressing : srcToTgtCellAddr_)
539 for (label& addr : addressing)
541 addr = newTgtCellIDs[addr];
546 for (
labelList& addressing : tgtToSrcCellAddr_)
548 globalSrcCells.inplaceToGlobal(addressing);
563 ListOps::appendEqOp<label>(),
581 ListOps::appendEqOp<scalar>(),
606 List<Map<label>> cMap;
609 new mapDistribute(globalSrcCells, tgtToSrcCellAddr_, cMap)
613 new mapDistribute(globalTgtCells, srcToTgtCellAddr_, cMap)
617 reduce(V_, sumOp<scalar>());
621 calcAddressing(methodName, srcRegion_, tgtRegion_);
641 Info<<
" Overlap volume: " << V_ <<
endl;
647 const interpolationMethod method
652 case interpolationMethod::imDirect:
654 return nearestFaceAMI::typeName;
657 case interpolationMethod::imMapNearest:
659 return nearestFaceAMI::typeName;
662 case interpolationMethod::imCellVolumeWeight:
663 case interpolationMethod::imCorrectedCellVolumeWeight:
665 return faceAreaWeightAMI::typeName;
671 <<
"Unhandled enumeration " << interpolationMethodNames_[method]
676 return nearestFaceAMI::typeName;
680 void Foam::meshToMesh::calculatePatchAMIs(
const word& AMIMethodName)
682 if (!patchAMIs_.empty())
685 <<
"patch AMI already calculated" 689 patchAMIs_.setSize(srcPatchID_.size());
693 label srcPatchi = srcPatchID_[i];
694 label tgtPatchi = tgtPatchID_[i];
696 const polyPatch& srcPP = srcRegion_.boundaryMesh()[srcPatchi];
697 const polyPatch& tgtPP = tgtRegion_.boundaryMesh()[tgtPatchi];
699 Info<<
"Creating AMI between source patch " << srcPP.name()
700 <<
" and target patch " << tgtPP.name()
701 <<
" using " << AMIMethodName
718 patchAMIs_[i].calculate(srcPP, tgtPP);
725 void Foam::meshToMesh::constructNoCuttingPatches
727 const word& methodName,
728 const word& AMIMethodName,
729 const bool interpAllPatches
732 if (interpAllPatches)
734 const polyBoundaryMesh& srcBM = srcRegion_.boundaryMesh();
735 const polyBoundaryMesh& tgtBM = tgtRegion_.boundaryMesh();
737 DynamicList<label> srcPatchID(srcBM.size());
738 DynamicList<label> tgtPatchID(tgtBM.size());
741 const polyPatch&
pp = srcBM[patchi];
746 if (!isA<processorPolyPatch>(
pp))
748 srcPatchID.append(
pp.index());
750 label tgtPatchi = tgtBM.findPatchID(
pp.name());
754 tgtPatchID.append(tgtPatchi);
759 <<
"Source patch " <<
pp.name()
760 <<
" not found in target mesh. " 761 <<
"Available target patches are " << tgtBM.names()
767 srcPatchID_.transfer(srcPatchID);
768 tgtPatchID_.transfer(tgtPatchID);
772 calculate(methodName,
true);
775 calculatePatchAMIs(AMIMethodName);
779 void Foam::meshToMesh::constructFromCuttingPatches
781 const word& methodName,
782 const word& AMIMethodName,
783 const HashTable<word>& patchMap,
788 const polyBoundaryMesh& srcBm = srcRegion_.boundaryMesh();
789 const polyBoundaryMesh& tgtBm = tgtRegion_.boundaryMesh();
792 cuttingPatches_.setSize(cuttingPatches.size());
793 forAll(cuttingPatches_, i)
795 const word& patchName = cuttingPatches[i];
796 label cuttingPatchi = srcBm.findPatchID(patchName);
798 if (cuttingPatchi == -1)
801 <<
"Unable to find patch '" << patchName
802 <<
"' in mesh '" << srcRegion_.name() <<
"'. " 803 <<
" Available patches include:" << srcBm.names()
807 cuttingPatches_[i] = cuttingPatchi;
810 DynamicList<label> srcIDs(patchMap.size());
811 DynamicList<label> tgtIDs(patchMap.size());
815 const word& tgtPatchName = iter.key();
816 const word& srcPatchName = iter.val();
818 const polyPatch& srcPatch = srcBm[srcPatchName];
823 if (!isA<processorPolyPatch>(srcPatch))
825 const polyPatch& tgtPatch = tgtBm[tgtPatchName];
827 srcIDs.append(srcPatch.index());
828 tgtIDs.append(tgtPatch.index());
832 srcPatchID_.transfer(srcIDs);
833 tgtPatchID_.transfer(tgtIDs);
836 calculate(methodName, normalise);
839 calculatePatchAMIs(AMIMethodName);
845 Foam::meshToMesh::meshToMesh
849 const interpolationMethod& method,
850 const procMapMethod& mapMethod,
851 bool interpAllPatches
856 procMapMethod_(mapMethod),
872 constructNoCuttingPatches
881 Foam::meshToMesh::meshToMesh
885 const word& methodName,
886 const word& AMIMethodName,
887 const procMapMethod& mapMethod,
888 bool interpAllPatches
893 procMapMethod_(mapMethod),
909 constructNoCuttingPatches(methodName, AMIMethodName, interpAllPatches);
913 Foam::meshToMesh::meshToMesh
917 const interpolationMethod& method,
920 const procMapMethod& mapMethod,
926 procMapMethod_(mapMethod),
940 constructFromCuttingPatches
951 Foam::meshToMesh::meshToMesh
955 const word& methodName,
956 const word& AMIMethodName,
959 const procMapMethod& mapMethod,
965 procMapMethod_(mapMethod),
979 constructFromCuttingPatches
List< scalar > scalarList
List of scalar.
virtual const fileName & name() const
Get the name of the output serial stream. (eg, the name of the Fstream file name) ...
void size(const label n)
Older name for setAddressableSize.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &f1)
List< cell > cellList
List of cell.
errorManipArg< error, int > exit(error &err, const int errNo=1)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
void append(const T &val)
Append an element at the end of the list.
static const Enum< interpolationMethod > interpolationMethodNames_
static const Enum< procMapMethod > procMapMethodNames_
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
constexpr char nl
The newline '\n' character (0x0a)
Ostream & endl(Ostream &os)
Add newline and flush stream.
static int & msgType() noexcept
Message tag of standard messages.
Generic GeometricField class.
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Can be negative if the process i...
static const List< T > & null()
Return a null List.
List< labelList > labelListList
List of labelList.
#define forAll(list, i)
Loop across all elements in list.
procMapMethod
Enumeration specifying processor parallel map construction method.
List< face > faceList
List of faces.
PtrList< polyPatch > polyPatchList
Store lists of polyPatch as a PtrList.
vectorField pointField
pointField is a vectorField.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
List< scalarList > scalarListList
List of scalarList.
A class for handling words, derived from Foam::string.
static const word null
An empty word.
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
A HashTable similar to std::unordered_map.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
errorManip< error > abort(error &err)
const T * set(const label i) const
Return const pointer to element (can be nullptr), or nullptr for out-of-range access (ie...
static word interpolationMethodAMI(const interpolationMethod method)
Conversion between mesh and patch interpolation methods.
int debug
Static debugging option.
defineTypeNameAndDebug(combustionModel, 0)
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
List< word > wordList
List of word.
Internal::FieldType & primitiveFieldRef(const bool updateAccessTime=true)
Return a reference to the internal field values.
virtual ~meshToMesh()
Destructor.
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
static void distribute(const Pstream::commsTypes commsType, const List< labelPair > &schedule, const label constructSize, const labelListList &subMap, const bool subHasFlip, const labelListList &constructMap, const bool constructHasFlip, List< T > &field, const NegateOp &negOp, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Distribute data with specified negate operator (for flips).
const polyBoundaryMesh & patches
Automatically write from objectRegistry::writeObject()
Interpolation class dealing with transfer of data between two primitive patches with an arbitrary mes...
void reduce(const List< UPstream::commsStruct > &comms, T &value, const BinaryOp &bop, const int tag, const label comm)
Reduce inplace (cf. MPI Allreduce) using specified communication schedule.
"nonBlocking" : (MPI_Isend, MPI_Irecv)
messageStream Info
Information stream (stdout output on master, null elsewhere)
Mesh consisting of general polyhedral cells.
static autoPtr< AMIInterpolation > New(const word &modelName, const dictionary &dict, const bool reverseTarget=false)
Selector for dictionary.
interpolationMethod
Enumeration specifying interpolation method.
List< label > labelList
A List of labels.
void mapSrcToTgt(const UList< Type > &srcFld, const CombineOp &cop, List< Type > &result) const
Map field from src to tgt mesh with defined operation.
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
bool returnReduceOr(const bool value, const label comm=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
Ostream & incrIndent(Ostream &os)
Increment the indent level.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
static autoPtr< meshToMeshMethod > New(const word &methodName, const polyMesh &src, const polyMesh &tgt)
Selector.
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
forAllConstIters(mixture.phases(), phase)