51 { interpolationMethod::imDirect,
"direct" },
52 { interpolationMethod::imMapNearest,
"mapNearest" },
53 { interpolationMethod::imCellVolumeWeight,
"cellVolumeWeight" },
55 interpolationMethod::imCorrectedCellVolumeWeight,
56 "correctedCellVolumeWeight"
67 { procMapMethod::pmAABB,
"AABB" },
75void Foam::meshToMesh::mapInternalSrcToTgt
77 const VolumeField<sphericalTensor>&
field,
78 const plusEqOp<sphericalTensor>& cop,
79 VolumeField<sphericalTensor>& result,
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
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))
377void Foam::meshToMesh::normaliseWeights
379 const word& descriptor,
402void Foam::meshToMesh::calcAddressing
404 const word& methodName,
433 methodPtr->writeConnectivity(src, tgt, srcToTgtCellAddr_);
438void 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)
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);
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;
680void 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];
699 Info<<
"Creating AMI between source patch " << srcPP.name()
700 <<
" and target patch " << tgtPP.name()
701 <<
" using " << AMIMethodName
718 patchAMIs_[i].calculate(srcPP, tgtPP);
725void Foam::meshToMesh::constructNoCuttingPatches
727 const word& methodName,
728 const word& AMIMethodName,
729 const bool interpAllPatches
732 if (interpAllPatches)
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);
779void Foam::meshToMesh::constructFromCuttingPatches
781 const word& methodName,
782 const word& AMIMethodName,
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;
815 const word& tgtPatchName = iter.key();
816 const word& srcPatchName = iter.val();
818 const polyPatch& srcPatch = srcBm[srcPatchName];
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);
845Foam::meshToMesh::meshToMesh
849 const interpolationMethod method,
850 const procMapMethod mapMethod,
851 bool interpAllPatches
856 procMapMethod_(mapMethod),
872 constructNoCuttingPatches
881Foam::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);
913Foam::meshToMesh::meshToMesh
917 const interpolationMethod method,
920 const procMapMethod mapMethod,
926 procMapMethod_(mapMethod),
940 constructFromCuttingPatches
951Foam::meshToMesh::meshToMesh
955 const word& methodName,
956 const word& AMIMethodName,
959 const procMapMethod mapMethod,
965 procMapMethod_(mapMethod),
979 constructFromCuttingPatches
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
static autoPtr< AMIInterpolation > New(const word &modelName, const dictionary &dict, const bool reverseTarget=false)
Selector for dictionary.
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 that is much like a Foam::List except that it is expected to hold numeri...
Internal::FieldType & primitiveFieldRef(const bool updateAccessTime=true)
Return a reference to the internal field values.
A HashTable similar to std::unordered_map.
label size() const noexcept
The number of elements in table.
@ NO_READ
Nothing to be read.
@ AUTO_WRITE
Automatically write from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
static const List< T > & null() noexcept
Return a null List (reference to a nullObject). Behaves like an empty List.
const T * set(const label i) const
Return const pointer to element (can be nullptr), or nullptr for out-of-range access (ie,...
void setSize(const label n)
Same as resize().
void size(const label n)
Older name for setAddressableSize.
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Negative if the process is not a...
@ nonBlocking
"nonBlocking" (immediate) : (MPI_Isend, MPI_Irecv)
static int & msgType() noexcept
Message tag of standard messages.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
A bounding box defined in terms of min/max extrema points.
const point & max() const noexcept
Maximum describing the bounding box.
const point & min() const noexcept
Minimum describing the bounding box.
Calculates a non-overlapping list of offsets based on an input size (eg, number of cells) from differ...
static void distribute(const UPstream::commsTypes commsType, const UList< labelPair > &schedule, const label constructSize, const labelListList &subMap, const bool subHasFlip, const labelListList &constructMap, const bool constructHasFlip, List< T > &field, const T &nullValue, const CombineOp &cop, const NegateOp &negOp, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Distribute combine data with specified combine operation and negate operator (for flips).
Class containing processor-to-processor mapping information.
static autoPtr< meshToMeshMethod > New(const word &methodName, const polyMesh &src, const polyMesh &tgt)
Selector.
Class to calculate the cell-addressing between two overlapping meshes.
virtual ~meshToMesh()
Destructor.
interpolationMethod
Enumeration specifying interpolation method.
@ imCorrectedCellVolumeWeight
procMapMethod
Enumeration specifying processor parallel map construction method.
void mapTgtToSrc(const UList< Type > &tgtFld, const CombineOp &cop, List< Type > &result) const
Map field from tgt to src mesh with defined operation.
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_
A polyBoundaryMesh is a polyPatch list with registered IO, a reference to the associated polyMesh,...
Mesh consisting of general polyhedral cells.
virtual const faceList & faces() const
Return raw faces.
const boundBox & bounds() const noexcept
Return mesh bounding box.
virtual const pointField & points() const
Return raw points.
A patch is a list of labels that address the faces in the global face list.
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundaryMesh reference.
const cellList & cells() const
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))
Namespace for handling debugging switches.
List< scalarList > scalarListList
List of scalarList.
PtrList< polyPatch > polyPatchList
Store lists of polyPatch as a PtrList.
List< word > wordList
List of word.
bool returnReduceOr(const bool value, const int communicator=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
GeometricField< Type, fvPatchField, volMesh > VolumeField
A volume field for a given type.
List< labelList > labelListList
List of labelList.
List< label > labelList
A List of labels.
messageStream Info
Information stream (stdout output on master, null elsewhere).
List< face > faceList
List of faces.
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Ostream & endl(Ostream &os)
Add newline and flush stream.
List< cell > cellList
List of cell.
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
void reduce(T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce).
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
AMIInterpolation AMIPatchToPatchInterpolation
Patch-to-patch interpolation == Foam::AMIInterpolation.
errorManip< error > abort(error &err)
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &f1, const label comm)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
vectorField pointField
pointField is a vectorField.
errorManipArg< error, int > exit(error &err, const int errNo=1)
List< scalar > scalarList
List of scalar.
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
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.
List helper to append y elements onto the end of x.
Functor to negate primitives. Dummy for most other types.