43 <<
"Attempted to perform topology update when createAMIFaces_ "
44 <<
"flag is set to false"
51 <<
"Mesh already has volumes set!"
59 <<
"Patch:" <<
name() <<
" before: sum(mag(faceAreas)):"
61 <<
"Patch:" <<
name() <<
" before: sum(mag(faceAreas0)):"
75 <<
"Patch:" <<
name() <<
" after: sum(mag(faceAreas)):"
77 <<
"Patch:" <<
name() <<
" after: sum(mag(faceAreas0)):"
90 <<
"Attempted to perform topology update when createAMIFaces_ "
91 <<
"flag is set to false"
100 bool changeRequired =
false;
106 const label newSrcFaceStart = srcFaceIDs_.size();
108 if (newSrcFaceStart != 0)
110 for (label facei = newSrcFaceStart; facei < size(); ++facei)
112 changeRequired =
true;
113 label meshFacei = start() + facei;
118 const label newTgtFaceStart = tgtFaceIDs_.size();
120 if (newTgtFaceStart != 0)
122 for (label facei = newTgtFaceStart; facei < nbr.size(); ++facei)
124 changeRequired =
true;
125 label meshFacei = nbr.
start() + facei;
133 return changeRequired;
142 if (!createAMIFaces_)
145 <<
"Attempted to perform topology update when createAMIFaces_ "
146 <<
"flag is set to false"
150 bool changedFaces =
false;
162 const label nSrcFace = srcToTgtAddr.
size();
163 const label nTgtFace = tgtToSrcAddr.
size();
165 srcFaceIDs_.setSize(nSrcFace);
166 tgtFaceIDs_.setSize(nTgtFace);
168 label nNewSrcFaces = 0;
169 forAll(srcToTgtAddr, srcFacei)
171 const labelList& tgtAddr = srcToTgtAddr[srcFacei];
174 if (tgtAddr.
empty())
continue;
177 srcFaceIDs_[srcFacei][0] = srcFacei;
179 const label meshFacei = start() + srcFacei;
180 for (label addri = 1; addri < tgtAddr.
size(); ++addri)
188 srcFaceIDs_[srcFacei][addri] = nNewSrcFaces + nSrcFace;
206 label nNewTgtFaces = 0;
207 forAll(tgtToSrcAddr, tgtFacei)
209 const labelList& srcAddr = tgtToSrcAddr[tgtFacei];
212 if (srcAddr.
empty())
continue;
215 tgtFaceIDs_[tgtFacei][0] = tgtFacei;
217 const label meshFacei = nbr.
start() + tgtFacei;
218 for (label addri = 1; addri < srcAddr.
size(); ++addri)
226 tgtFaceIDs_[tgtFacei][addri] = nNewTgtFaces + nTgtFace;
245 Info<<
"AMI: Patch " <<
name() <<
" additional faces: "
247 <<
"AMI: Patch " << nbr.
name() <<
" additional faces: "
253 Pout<<
"New faces - " <<
name() <<
": " << nNewSrcFaces
254 <<
" " << nbr.
name() <<
": " << nNewTgtFaces <<
endl;
267 if (!createAMIFaces_)
270 <<
"Attempted to perform topology update when createAMIFaces_ "
271 <<
"flag is set to false"
295 faceAreas0_ = faceAreas();
296 faceCentres0_ = faceCentres();
314 if (AMIPtr_->singlePatchProc() == -1)
333 forAll(newTgtGlobalFaces, tgtFacei)
337 AMIPtr_->tgtMap().distribute(newTgtGlobalFaces);
343 AMIPtr_->srcMap().distribute(globalSrcFaceIDs);
348 AMIPtr_->srcMap().distribute(globalSrcCtrs0);
352 AMIPtr_->tgtMap().distribute(globalTgtFaceIDs);
362 forAll(tgtToSrcAddr0, tgtFacei0)
364 forAll(tgtToSrcAddr0[tgtFacei0], addri)
366 const label globalSrcFacei =
367 globalSrcFaceIDs[tgtToSrcAddr0[tgtFacei0][addri]];
368 globalTgtToSrcAddr[tgtFacei0][addri] = globalSrcFacei;
371 AMIPtr_->tgtMap().distribute(globalTgtToSrcAddr);
374 forAll(srcToTgtAddr0, srcFacei0)
376 forAll(srcToTgtAddr0[srcFacei0], addri)
378 const label globalTgtFacei =
379 globalTgtFaceIDs[srcToTgtAddr0[srcFacei0][addri]];
380 globalSrcToTgtAddr[srcFacei0][addri] = globalTgtFacei;
383 AMIPtr_->srcMap().distribute(globalSrcToTgtAddr);
386 forAll(srcToTgtAddr0, srcFacei0)
388 const labelList& newSrcFaces = srcFaceIDs_[srcFacei0];
392 const label srcFacei1 = newSrcFaces[i];
397 const label tgtFacei0 = srcToTgtAddr0[srcFacei0][i];
399 globalTgtToSrcAddr[tgtFacei0].
find
401 globalSrcFaceIDs[srcFacei0]
411 Pout<<
"Unable to find global source face "
412 << globalSrcFaceIDs[srcFacei0]
413 <<
" in globalTgtToSrcAddr[" << tgtFacei0 <<
"]: "
414 << globalTgtToSrcAddr[tgtFacei0]
419 const label tgtFacei1 = newTgtGlobalFaces[tgtFacei0][addri];
426 srcToTgtAddr1[srcFacei1] =
labelList(1, tgtFacei1);
427 faceAreas0_[srcFacei1] *= srcToTgtWght0[srcFacei0][i];
428 faceCentres0_[srcFacei1] = srcCtr0[srcFacei0][i];
435 <<
"Unable to find " << nError <<
" global source faces"
444 forAll(newSrcGlobalFaces, srcFacei)
449 AMIPtr_->srcMap().distribute(newSrcGlobalFaces);
452 forAll(tgtToSrcAddr0, tgtFacei0)
454 const labelList& newTgtFaces = tgtFaceIDs_[tgtFacei0];
457 const label srcFacei0 = tgtToSrcAddr0[tgtFacei0][i];
460 globalSrcToTgtAddr[srcFacei0].
find
462 globalTgtFaceIDs[tgtFacei0]
472 Pout<<
"Unable to find global target face "
473 << globalTgtFaceIDs[tgtFacei0]
474 <<
" in globalSrcToTgtAddr[" << srcFacei0 <<
"]: "
475 << globalSrcToTgtAddr[srcFacei0]
480 const label srcFacei1 = newSrcGlobalFaces[srcFacei0][addri];
483 point srcCtr0(globalSrcCtrs0[srcFacei0][addri]);
484 reverseTransformPosition(srcCtr0, srcFacei0);
486 const label tgtFacei1 = newTgtFaces[i];
487 tgtToSrcAddr1[tgtFacei1] =
labelList(1, srcFacei1);
488 nbrFaceCentres0[tgtFacei1] = srcCtr0;
495 <<
"Unable to find " << nError <<
" global target faces"
516 vectorList newSrcGlobalFaceAreas(faceAreas0_);
518 srcToTgtMap1->distribute(newSrcGlobalFaceAreas);
519 forAll(nbrFaceAreas0, tgtFacei)
521 if (!tgtToSrcAddr1[tgtFacei].empty())
523 const label srcFacei = tgtToSrcAddr1[tgtFacei][0];
524 nbrFaceAreas0[tgtFacei] = -newSrcGlobalFaceAreas[srcFacei];
531 forAll(srcToTgtAddr0, srcFacei0)
533 const labelList& srcFaceTgtAddr0 = srcToTgtAddr0[srcFacei0];
534 const scalarList& srcFaceTgtWght0 = srcToTgtWght0[srcFacei0];
535 const pointList& srcFaceTgtCtr0 = srcCtr0[srcFacei0];
536 forAll(srcFaceTgtAddr0, addri)
538 const label srcFacei1 = srcFaceIDs_[srcFacei0][addri];
541 const label tgtFacei0 = srcFaceTgtAddr0[addri];
542 const label tgtAddri0 =
543 tgtToSrcAddr0[tgtFacei0].
find(srcFacei0);
552 Pout<<
"Unable to find source face " << srcFacei0
553 <<
" in tgtToSrcAddr0[" << tgtFacei0 <<
"]: "
554 << tgtToSrcAddr0[tgtFacei0]
559 const label tgtFacei1 = tgtFaceIDs_[tgtFacei0][tgtAddri0];
561 faceAreas0_[srcFacei1] *= srcFaceTgtWght0[addri];
562 nbrFaceAreas0[tgtFacei1] = -faceAreas0_[srcFacei1];
564 point pt(srcFaceTgtCtr0[addri]);
565 faceCentres0_[srcFacei1] = pt;
566 reverseTransformPosition(pt, srcFacei0);
567 nbrFaceCentres0[tgtFacei1] = pt;
573 srcToTgtAddr1[srcFacei1] =
labelList(1, tgtFacei1);
574 tgtToSrcAddr1[tgtFacei1] =
labelList(1, srcFacei1);
581 <<
"Unable to find " << nError
582 <<
" source faces in tgtToSrcAddr0"
588 forAll(srcToTgtAddr1, facei)
590 if (srcToTgtAddr1[facei].size())
592 newSrcToTgtWeights[facei] =
scalarList(1, scalar(1));
598 faceAreas0_[facei] *= tolerance_;
603 forAll(tgtToSrcAddr1, facei)
605 if (tgtToSrcAddr1[facei].size())
607 newTgtToSrcWeights[facei] =
scalarList(1, scalar(1));
613 nbrFaceAreas0[facei] *= tolerance_;
621 std::move(srcToTgtMap1),
622 std::move(tgtToSrcMap1),
623 std::move(srcToTgtAddr1),
624 std::move(newSrcToTgtWeights),
625 std::move(tgtToSrcAddr1),
626 std::move(newTgtToSrcWeights)
630 AMIPtr_->srcMagSf() =
mag(faceAreas0_);
631 AMIPtr_->tgtMagSf() =
mag(nbrFaceAreas0);
635 Pout<<
"cyclicAMIPolyPatch : " <<
name()
636 <<
" constructed AMI with " <<
nl
637 <<
" " <<
"srcAddress:" << AMIPtr_().srcAddress().size()
639 <<
" " <<
"tgAddress :" << AMIPtr_().tgtAddress().size()
651 createAMIFaces_ =
true;
661 if (createAMIFaces_ && owner())
665 resetAMI(topoChange.
points());
667 removeAMIFaces(topoChange);
669 addAMIFaces(topoChange);
void setSize(const label n)
Alias for resize()
void clear()
Clear the list, i.e. set size to zero.
SubField is a Field obtained as a section of another Field, without its own allocation....
bool empty() const noexcept
True if the UList is empty (ie, size() is zero)
label find(const T &val, label pos=0) const
Find index of the first occurrence of the value.
void size(const label n)
Older name for setAddressableSize.
label whichZone(const label objectIndex) const
Given a global object index, return the zone it is in.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
void reset(autoPtr< T > &&other) noexcept
Delete managed object and set to new given pointer.
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface....
const bMesh & mesh() const
Cyclic patch for Arbitrary Mesh Interface (AMI)
vectorField & faceAreas0() const
Return access to the initial face areas.
bool createAMIFaces_
Flag to indicate that new AMI faces will created.
virtual bool addAMIFaces(polyTopoChange &topoChange)
Collect faces to add in the topoChange container.
vectorField faceCentres0_
Temporary storage for AMI face centres.
virtual void restoreScaledGeometry()
virtual bool removeAMIFaces(polyTopoChange &topoChange)
Collect faces to remove in the topoChange container.
virtual bool setTopology(polyTopoChange &topoChange)
Set topology changes in the polyTopoChange object.
vectorField faceAreas0_
Temporary storage for AMI face areas.
virtual bool changeTopology() const
Return true if this patch changes the mesh topology.
virtual void setAMIFaces()
Set properties of newly inserted faces after topological changes.
vectorField & faceCentres0() const
Return access to the initial face centres.
bool moveFaceCentres_
Move face centres (default = no)
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
void inplaceToGlobal(labelUList &labels) const
From local to global index (inplace)
Class containing processor-to-processor mapping information.
label index() const noexcept
The index of this patch in the boundaryMesh.
const word & name() const noexcept
The patch name.
Mesh consisting of general polyhedral cells.
const faceZoneMesh & faceZones() const noexcept
Return face zone mesh.
virtual const faceList & faces() const
Return raw faces.
virtual const labelList & faceOwner() const
Return face owner.
const vectorField::subField faceAreas() const
Return face normals.
label start() const
Return start label of this patch in the polyMesh face list.
const vectorField::subField faceCentres() const
Return face centres.
Direct mesh changes based on v1.3 polyTopoChange syntax.
void removeFace(const label facei, const label mergeFacei)
Remove/merge face.
label addFace(const face &f, const label own, const label nei, const label masterPointID, const label masterEdgeID, const label masterFaceID, const bool flipFaceFlux, const label patchID, const label zoneID, const bool zoneFlip)
Add face to cells. Return new face label.
const DynamicList< point > & points() const
Points. Shrunk after constructing mesh (or calling of compact())
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define DebugInfo
Report an information message using Foam::Info.
#define WarningInFunction
Report a warning using Foam::Warning.
#define DebugInFunction
Report an information message using Foam::Info.
Type gSum(const FieldField< Field, Type > &f)
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i)
List< label > labelList
A List of labels.
messageStream Info
Information stream (stdout output on master, null elsewhere)
List< scalar > scalarList
A List of scalars.
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
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.
constexpr char nl
The newline '\n' character (0x0a)
#define forAll(list, i)
Loop across all elements in list.