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;
104 const cyclicAMIPolyPatch& nbr = neighbPatch();
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;
151 const cyclicAMIPolyPatch& nbr = neighbPatch();
153 polyMesh&
mesh =
const_cast<polyMesh&
>(boundaryMesh().mesh());
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;
176 srcFaceIDs_[srcFacei].
setSize(tgtAddr.size());
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;
200 faceZones.whichZone(meshFacei),
206 label nNewTgtFaces = 0;
207 forAll(tgtToSrcAddr, tgtFacei)
209 const labelList& srcAddr = tgtToSrcAddr[tgtFacei];
212 if (srcAddr.empty())
continue;
214 tgtFaceIDs_[tgtFacei].
setSize(srcAddr.size());
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;
239 faceZones.whichZone(meshFacei),
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" 283 const cyclicAMIPolyPatch& nbr = neighbPatch();
295 faceAreas0_ = faceAreas();
296 faceCentres0_ = faceCentres();
297 nbrFaceAreas0 = nbr.faceAreas();
298 nbrFaceCentres0 = nbr.faceCentres();
305 const label singlePatchProc = AMIPtr_->singlePatchProc();
312 autoPtr<mapDistribute> srcToTgtMap1;
313 autoPtr<mapDistribute> tgtToSrcMap1;
315 if (AMIPtr_->distributed())
320 globalIndex globalSrcFaces0(srcToTgtAddr0.size(), AMIPtr_().comm());
321 globalIndex globalTgtFaces0(tgtToSrcAddr0.size(), AMIPtr_().comm());
324 globalIndex globalSrcFaces1(size(), AMIPtr_().comm());
325 globalIndex globalTgtFaces1(nbr.size(), AMIPtr_().comm());
334 forAll(newTgtGlobalFaces, tgtFacei)
336 globalTgtFaces1.inplaceToGlobal(newTgtGlobalFaces[tgtFacei]);
338 AMIPtr_->tgtMap().distribute(newTgtGlobalFaces);
343 globalSrcFaces0.inplaceToGlobal(globalSrcFaceIDs);
344 AMIPtr_->srcMap().distribute(globalSrcFaceIDs);
348 List<List<point>> globalSrcCtrs0(srcCtr0);
349 AMIPtr_->srcMap().distribute(globalSrcCtrs0);
352 globalTgtFaces0.inplaceToGlobal(globalTgtFaceIDs);
353 AMIPtr_->tgtMap().distribute(globalTgtFaceIDs);
363 forAll(tgtToSrcAddr0, tgtFacei0)
365 forAll(tgtToSrcAddr0[tgtFacei0], addri)
367 const label globalSrcFacei =
368 globalSrcFaceIDs[tgtToSrcAddr0[tgtFacei0][addri]];
369 globalTgtToSrcAddr[tgtFacei0][addri] = globalSrcFacei;
372 AMIPtr_->tgtMap().distribute(globalTgtToSrcAddr);
375 forAll(srcToTgtAddr0, srcFacei0)
377 forAll(srcToTgtAddr0[srcFacei0], addri)
379 const label globalTgtFacei =
380 globalTgtFaceIDs[srcToTgtAddr0[srcFacei0][addri]];
381 globalSrcToTgtAddr[srcFacei0][addri] = globalTgtFacei;
384 AMIPtr_->srcMap().distribute(globalSrcToTgtAddr);
387 forAll(srcToTgtAddr0, srcFacei0)
389 const labelList& newSrcFaces = srcFaceIDs_[srcFacei0];
393 const label srcFacei1 = newSrcFaces[i];
398 const label tgtFacei0 = srcToTgtAddr0[srcFacei0][i];
400 globalTgtToSrcAddr[tgtFacei0].find
402 globalSrcFaceIDs[srcFacei0]
412 Pout<<
"Unable to find global source face " 413 << globalSrcFaceIDs[srcFacei0]
414 <<
" in globalTgtToSrcAddr[" << tgtFacei0 <<
"]: " 415 << globalTgtToSrcAddr[tgtFacei0]
420 const label tgtFacei1 = newTgtGlobalFaces[tgtFacei0][addri];
427 srcToTgtAddr1[srcFacei1] =
labelList(1, tgtFacei1);
428 faceAreas0_[srcFacei1] *= srcToTgtWght0[srcFacei0][i];
429 faceCentres0_[srcFacei1] = srcCtr0[srcFacei0][i];
436 <<
"Unable to find " << nError <<
" global source faces" 445 forAll(newSrcGlobalFaces, srcFacei)
447 globalSrcFaces1.inplaceToGlobal(newSrcGlobalFaces[srcFacei]);
450 AMIPtr_->srcMap().distribute(newSrcGlobalFaces);
453 forAll(tgtToSrcAddr0, tgtFacei0)
455 const labelList& newTgtFaces = tgtFaceIDs_[tgtFacei0];
458 const label srcFacei0 = tgtToSrcAddr0[tgtFacei0][i];
461 globalSrcToTgtAddr[srcFacei0].find
463 globalTgtFaceIDs[tgtFacei0]
473 Pout<<
"Unable to find global target face " 474 << globalTgtFaceIDs[tgtFacei0]
475 <<
" in globalSrcToTgtAddr[" << srcFacei0 <<
"]: " 476 << globalSrcToTgtAddr[srcFacei0]
481 const label srcFacei1 = newSrcGlobalFaces[srcFacei0][addri];
484 point srcCtr0(globalSrcCtrs0[srcFacei0][addri]);
485 reverseTransformPosition(srcCtr0, srcFacei0);
487 const label tgtFacei1 = newTgtFaces[i];
488 tgtToSrcAddr1[tgtFacei1] =
labelList(1, srcFacei1);
489 nbrFaceCentres0[tgtFacei1] = srcCtr0;
496 <<
"Unable to find " << nError <<
" global target faces" 502 List<Map<label>> cMap;
505 new mapDistribute(globalSrcFaces1, tgtToSrcAddr1, cMap)
509 List<Map<label>> cMap;
512 new mapDistribute(globalTgtFaces1, srcToTgtAddr1, cMap)
517 vectorList newSrcGlobalFaceAreas(faceAreas0_);
519 srcToTgtMap1->distribute(newSrcGlobalFaceAreas);
520 forAll(nbrFaceAreas0, tgtFacei)
522 if (!tgtToSrcAddr1[tgtFacei].empty())
524 const label srcFacei = tgtToSrcAddr1[tgtFacei][0];
525 nbrFaceAreas0[tgtFacei] = -newSrcGlobalFaceAreas[srcFacei];
532 forAll(srcToTgtAddr0, srcFacei0)
534 const labelList& srcFaceTgtAddr0 = srcToTgtAddr0[srcFacei0];
535 const scalarList& srcFaceTgtWght0 = srcToTgtWght0[srcFacei0];
536 const pointList& srcFaceTgtCtr0 = srcCtr0[srcFacei0];
537 forAll(srcFaceTgtAddr0, addri)
539 const label srcFacei1 = srcFaceIDs_[srcFacei0][addri];
542 const label tgtFacei0 = srcFaceTgtAddr0[addri];
543 const label tgtAddri0 =
544 tgtToSrcAddr0[tgtFacei0].find(srcFacei0);
553 Pout<<
"Unable to find source face " << srcFacei0
554 <<
" in tgtToSrcAddr0[" << tgtFacei0 <<
"]: " 555 << tgtToSrcAddr0[tgtFacei0]
560 const label tgtFacei1 = tgtFaceIDs_[tgtFacei0][tgtAddri0];
562 faceAreas0_[srcFacei1] *= srcFaceTgtWght0[addri];
563 nbrFaceAreas0[tgtFacei1] = -faceAreas0_[srcFacei1];
565 point pt(srcFaceTgtCtr0[addri]);
566 faceCentres0_[srcFacei1] = pt;
567 reverseTransformPosition(pt, srcFacei0);
568 nbrFaceCentres0[tgtFacei1] = pt;
574 srcToTgtAddr1[srcFacei1] =
labelList(1, tgtFacei1);
575 tgtToSrcAddr1[tgtFacei1] =
labelList(1, srcFacei1);
582 <<
"Unable to find " << nError
583 <<
" source faces in tgtToSrcAddr0" 589 forAll(srcToTgtAddr1, facei)
591 if (srcToTgtAddr1[facei].size())
593 newSrcToTgtWeights[facei] =
scalarList(1, scalar(1));
599 faceAreas0_[facei] *= tolerance_;
604 forAll(tgtToSrcAddr1, facei)
606 if (tgtToSrcAddr1[facei].size())
608 newTgtToSrcWeights[facei] =
scalarList(1, scalar(1));
614 nbrFaceAreas0[facei] *= tolerance_;
622 std::move(srcToTgtMap1),
623 std::move(tgtToSrcMap1),
624 std::move(srcToTgtAddr1),
625 std::move(newSrcToTgtWeights),
626 std::move(tgtToSrcAddr1),
627 std::move(newTgtToSrcWeights),
632 AMIPtr_->srcMagSf() =
mag(faceAreas0_);
633 AMIPtr_->tgtMagSf() =
mag(nbrFaceAreas0);
637 Pout<<
"cyclicAMIPolyPatch : " <<
name()
638 <<
" constructed AMI with " <<
nl 639 <<
" " <<
"srcAddress:" << AMIPtr_().srcAddress().size()
641 <<
" " <<
"tgAddress :" << AMIPtr_().tgtAddress().size()
653 createAMIFaces_ =
true;
663 if (createAMIFaces_ && owner())
667 resetAMI(topoChange.
points());
669 removeAMIFaces(topoChange);
671 addAMIFaces(topoChange);
List< scalar > scalarList
List of scalar.
void size(const label n)
Older name for setAddressableSize.
ZoneMesh< faceZone, polyMesh > faceZoneMesh
A ZoneMesh with the type faceZone.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
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.
bool moveFaceCentres_
Move face centres (default = no)
virtual bool addAMIFaces(polyTopoChange &topoChange)
Collect faces to add in the topoChange container.
constexpr char nl
The newline '\n' character (0x0a)
Ostream & endl(Ostream &os)
Add newline and flush stream.
List< vector > vectorList
List of vector.
SubField is a Field obtained as a section of another Field, without its own allocation. SubField is derived from a SubList rather than a List.
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
List< labelList > labelListList
List of labelList.
virtual bool setTopology(polyTopoChange &topoChange)
Set topology changes in the polyTopoChange object.
bool createAMIFaces_
Flag to indicate that new AMI faces will created.
#define forAll(list, i)
Loop across all elements in list.
virtual void setAMIFaces()
Set properties of newly inserted faces after topological changes.
vectorField faceAreas0_
Temporary storage for AMI face areas.
void setSize(const label n)
Alias for resize()
Type gSum(const FieldField< Field, Type > &f)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
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 polyBoundaryMesh & boundaryMesh() const noexcept
Return boundaryMesh reference.
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i), works like std::iota() but returning a...
void clear()
Clear the list, i.e. set size to zero.
List< scalarList > scalarListList
List of scalarList.
#define DebugInFunction
Report an information message using Foam::Info.
const DynamicList< point > & points() const
Points. Shrunk after constructing mesh (or calling of compact())
virtual const labelList & faceOwner() const
Return face owner.
virtual const faceList & faces() const
Return raw faces.
errorManip< error > abort(error &err)
#define DebugInfo
Report an information message using Foam::Info.
vectorField faceCentres0_
Temporary storage for AMI face centres.
const word & name() const noexcept
The patch name.
const vectorField::subField faceAreas() const
Return face normals.
int debug
Static debugging option.
const faceZoneMesh & faceZones() const noexcept
Return face zone mesh.
virtual void restoreScaledGeometry()
Helper to re-apply the geometric scaling lost during mesh updates.
virtual bool removeAMIFaces(polyTopoChange &topoChange)
Collect faces to remove in the topoChange container.
vector point
Point is a vector.
#define WarningInFunction
Report a warning using Foam::Warning.
Direct mesh changes based on v1.3 polyTopoChange syntax.
virtual bool changeTopology() const
Return true if this patch changes the mesh topology.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Field< vector > vectorField
Specialisation of Field<T> for vector.
List< point > pointList
List of point.
List< label > labelList
A List of labels.
List< pointList > pointListList
List of pointList.
bool returnReduceOr(const bool value, const label comm=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
void removeFace(const label facei, const label mergeFacei)
Remove/merge face.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
const vectorField::subField faceCentres() const
Return face centres.