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" },
75void Foam::meshToMesh::mapInternalSrcToTgt
80 const bool secondOrder
88void Foam::meshToMesh::mapInternalSrcToTgt
93 const bool secondOrder
101void Foam::meshToMesh::mapInternalSrcToTgt
106 const bool secondOrder
114void Foam::meshToMesh::mapInternalSrcToTgt
119 const bool secondOrder
127void Foam::meshToMesh::mapInternalSrcToTgt
132 const bool secondOrder
140void Foam::meshToMesh::mapInternalSrcToTgt
145 const bool secondOrder
153void Foam::meshToMesh::mapInternalTgtToSrc
158 const bool secondOrder
166void Foam::meshToMesh::mapInternalTgtToSrc
171 const bool secondOrder
179void Foam::meshToMesh::mapInternalTgtToSrc
184 const bool secondOrder
192void Foam::meshToMesh::mapInternalTgtToSrc
197 const bool secondOrder
205void Foam::meshToMesh::mapInternalTgtToSrc
210 const bool secondOrder
218void Foam::meshToMesh::mapInternalTgtToSrc
223 const bool secondOrder
231void Foam::meshToMesh::mapAndOpSrcToTgt
242void Foam::meshToMesh::mapAndOpSrcToTgt
253void Foam::meshToMesh::mapAndOpSrcToTgt
264void Foam::meshToMesh::mapAndOpSrcToTgt
275void Foam::meshToMesh::mapAndOpSrcToTgt
286void Foam::meshToMesh::mapAndOpTgtToSrc
297void Foam::meshToMesh::mapAndOpTgtToSrc
308void Foam::meshToMesh::mapAndOpTgtToSrc
319void Foam::meshToMesh::mapAndOpTgtToSrc
330void Foam::meshToMesh::mapAndOpTgtToSrc
352 intersectBb.inflate(0.01);
362 if (intersectBb.overlaps(cellBb))
377void Foam::meshToMesh::normaliseWeights
379 const word& descriptor,
384 const label nCell =
returnReduce(wght.size(), sumOp<label>());
404void Foam::meshToMesh::calcAddressing
406 const word& methodName,
411 autoPtr<meshToMeshMethod> methodPtr
435 methodPtr->writeConnectivity(src, tgt, srcToTgtCellAddr_);
440void Foam::meshToMesh::calculate(
const word& methodName,
const bool normalise)
442 Info<<
"Creating mesh-to-mesh addressing for " << srcRegion_.name()
443 <<
" and " << tgtRegion_.name() <<
" regions using "
444 << methodName <<
endl;
446 singleMeshProc_ = calcDistribution(srcRegion_, tgtRegion_);
448 if (singleMeshProc_ == -1)
451 globalIndex globalSrcCells(srcRegion_.nCells());
452 globalIndex globalTgtCells(tgtRegion_.nCells());
457 autoPtr<mapDistribute> mapPtr = calcProcMap(srcRegion_, tgtRegion_);
458 const mapDistribute& map = mapPtr();
466 distributeAndMergeCells
474 newTgtFaceNeighbours,
485 tgtRegion_.time().timeName(),
490 std::move(newTgtPoints),
491 std::move(newTgtFaces),
492 std::move(newTgtFaceOwners),
493 std::move(newTgtFaceNeighbours),
502 newTgt.nBoundaryFaces(),
503 newTgt.nInternalFaces(),
505 newTgt.boundaryMesh(),
512 (void)newTgt.tetBasePtIs();
519 Pout<<
"Created newTgt mesh:" <<
nl
520 <<
" old cells = " << tgtRegion_.nCells()
521 <<
", new cells = " << newTgt.nCells() <<
nl
522 <<
" old faces = " << tgtRegion_.nFaces()
523 <<
", new faces = " << newTgt.nFaces() <<
endl;
527 Pout<<
"Writing newTgt mesh: " << newTgt.
name() <<
endl;
532 calcAddressing(methodName, srcRegion_, newTgt);
535 for (
labelList& addressing : srcToTgtCellAddr_)
537 for (label& addr : addressing)
539 addr = newTgtCellIDs[addr];
544 for (
labelList& addressing : tgtToSrcCellAddr_)
546 globalSrcCells.inplaceToGlobal(addressing);
550 mapDistributeBase::distribute
561 ListOps::appendEqOp<label>(),
568 mapDistributeBase::distribute
579 ListOps::appendEqOp<scalar>(),
604 List<Map<label>> cMap;
607 new mapDistribute(globalSrcCells, tgtToSrcCellAddr_, cMap)
611 new mapDistribute(globalTgtCells, srcToTgtCellAddr_, cMap)
615 reduce(V_, sumOp<scalar>());
619 calcAddressing(methodName, srcRegion_, tgtRegion_);
639 Info<<
" Overlap volume: " << V_ <<
endl;
650 case interpolationMethod::imDirect:
655 case interpolationMethod::imMapNearest:
660 case interpolationMethod::imCellVolumeWeight:
661 case interpolationMethod::imCorrectedCellVolumeWeight:
669 <<
"Unhandled enumeration " << interpolationMethodNames_[method]
678void Foam::meshToMesh::calculatePatchAMIs(
const word& AMIMethodName)
680 if (!patchAMIs_.empty())
683 <<
"patch AMI already calculated"
687 patchAMIs_.setSize(srcPatchID_.size());
691 label srcPatchi = srcPatchID_[i];
692 label tgtPatchi = tgtPatchID_[i];
694 const polyPatch& srcPP = srcRegion_.boundaryMesh()[srcPatchi];
695 const polyPatch& tgtPP = tgtRegion_.boundaryMesh()[tgtPatchi];
697 Info<<
"Creating AMI between source patch " << srcPP.name()
698 <<
" and target patch " << tgtPP.name()
699 <<
" using " << AMIMethodName
716 patchAMIs_[i].calculate(srcPP, tgtPP);
723void Foam::meshToMesh::constructNoCuttingPatches
725 const word& methodName,
726 const word& AMIMethodName,
727 const bool interpAllPatches
730 if (interpAllPatches)
732 const polyBoundaryMesh& srcBM = srcRegion_.boundaryMesh();
733 const polyBoundaryMesh& tgtBM = tgtRegion_.boundaryMesh();
735 DynamicList<label> srcPatchID(srcBM.size());
736 DynamicList<label> tgtPatchID(tgtBM.size());
739 const polyPatch& pp = srcBM[patchi];
744 if (!isA<processorPolyPatch>(pp))
746 srcPatchID.append(pp.index());
748 label tgtPatchi = tgtBM.findPatchID(pp.name());
752 tgtPatchID.append(tgtPatchi);
757 <<
"Source patch " << pp.name()
758 <<
" not found in target mesh. "
759 <<
"Available target patches are " << tgtBM.names()
765 srcPatchID_.transfer(srcPatchID);
766 tgtPatchID_.transfer(tgtPatchID);
770 calculate(methodName,
true);
773 calculatePatchAMIs(AMIMethodName);
777void Foam::meshToMesh::constructFromCuttingPatches
779 const word& methodName,
780 const word& AMIMethodName,
781 const HashTable<word>& patchMap,
786 const polyBoundaryMesh& srcBm = srcRegion_.boundaryMesh();
787 const polyBoundaryMesh& tgtBm = tgtRegion_.boundaryMesh();
790 cuttingPatches_.setSize(cuttingPatches.size());
791 forAll(cuttingPatches_, i)
793 const word& patchName = cuttingPatches[i];
794 label cuttingPatchi = srcBm.findPatchID(patchName);
796 if (cuttingPatchi == -1)
799 <<
"Unable to find patch '" << patchName
800 <<
"' in mesh '" << srcRegion_.name() <<
"'. "
801 <<
" Available patches include:" << srcBm.names()
805 cuttingPatches_[i] = cuttingPatchi;
808 DynamicList<label> srcIDs(patchMap.size());
809 DynamicList<label> tgtIDs(patchMap.size());
813 const word& tgtPatchName = iter.key();
814 const word& srcPatchName = iter.val();
816 const polyPatch& srcPatch = srcBm[srcPatchName];
821 if (!isA<processorPolyPatch>(srcPatch))
823 const polyPatch& tgtPatch = tgtBm[tgtPatchName];
825 srcIDs.append(srcPatch.index());
826 tgtIDs.append(tgtPatch.index());
830 srcPatchID_.transfer(srcIDs);
831 tgtPatchID_.transfer(tgtIDs);
834 calculate(methodName, normalise);
837 calculatePatchAMIs(AMIMethodName);
849 bool interpAllPatches
854 procMapMethod_(mapMethod),
870 constructNoCuttingPatches
883 const word& methodName,
884 const word& AMIMethodName,
886 bool interpAllPatches
891 procMapMethod_(mapMethod),
907 constructNoCuttingPatches(methodName, AMIMethodName, interpAllPatches);
924 procMapMethod_(mapMethod),
938 constructFromCuttingPatches
953 const word& methodName,
954 const word& AMIMethodName,
963 procMapMethod_(mapMethod),
977 constructFromCuttingPatches
Interpolation class dealing with transfer of data between two primitive patches with an arbitrary mes...
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Generic templated field type.
Generic GeometricField class.
Internal::FieldType & primitiveFieldRef(const bool updateAccessTime=true)
Return a reference to the internal field.
A HashTable similar to std::unordered_map.
label size() const noexcept
The number of elements in table.
void append(const T &val)
Append an element at the end of the list.
static const List< T > & null()
Return a null List.
virtual const fileName & name() const
Get the name of the stream.
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
void size(const label n)
Older name for setAddressableSize.
@ nonBlocking
"nonBlocking"
static int & msgType() noexcept
Message tag of standard messages.
A bounding box defined in terms of min/max extrema points.
const point & min() const
Minimum describing the bounding box.
const point & max() const
Maximum describing the bounding box.
labelList maskCells() const
Return src cell IDs for the overlap region.
Class to calculate the cell-addressing between two overlapping meshes.
virtual ~meshToMesh()
Destructor.
interpolationMethod
Enumeration specifying interpolation method.
procMapMethod
Enumeration specifying processor parallel map construction method.
static word interpolationMethodAMI(const interpolationMethod method)
Conversion between mesh and patch interpolation methods.
void mapSrcToTgt(const UList< Type > &srcFld, const CombineOp &cop, List< Type > &result) const
Map field from src to tgt mesh with defined operation.
static const Enum< procMapMethod > procMapMethodNames_
static const Enum< interpolationMethod > interpolationMethodNames_
Mesh consisting of general polyhedral cells.
virtual const faceList & faces() const
Return raw faces.
const boundBox & bounds() const
Return mesh bounding box.
virtual const pointField & points() const
Return raw points.
const cellList & cells() const
int myProcNo() const noexcept
Return processor number.
A class for handling words, derived from Foam::string.
static const word null
An empty word.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
const polyBoundaryMesh & patches
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
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))
List< word > wordList
A List of words.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
List< label > labelList
A List of labels.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
messageStream Info
Information stream (stdout output on master, null elsewhere)
vectorField pointField
pointField is a vectorField.
List< scalar > scalarList
A List of scalars.
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Ostream & endl(Ostream &os)
Add newline and flush stream.
List< labelList > labelListList
A List of labelList.
void reduce(const List< UPstream::commsStruct > &comms, T &value, const BinaryOp &bop, const int tag, const label comm)
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
errorManip< error > abort(error &err)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce (copy) and return value.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
List< face > faceList
A List of faces.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
List< scalarList > scalarListList
A List of scalarList.
constexpr char nl
The newline '\n' character (0x0a)
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIters(container, iter)
Iterate across all elements of the container object with const access.
static const char *const typeName
The type name used in ensight case files.