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();
311 autoPtr<mapDistribute> srcToTgtMap1;
312 autoPtr<mapDistribute> tgtToSrcMap1;
314 if (AMIPtr_->singlePatchProc() == -1)
319 globalIndex globalSrcFaces0(srcToTgtAddr0.size());
320 globalIndex globalTgtFaces0(tgtToSrcAddr0.size());
323 globalIndex globalSrcFaces1(size());
324 globalIndex globalTgtFaces1(nbr.size());
333 forAll(newTgtGlobalFaces, tgtFacei)
335 globalTgtFaces1.inplaceToGlobal(newTgtGlobalFaces[tgtFacei]);
337 AMIPtr_->tgtMap().distribute(newTgtGlobalFaces);
342 globalSrcFaces0.inplaceToGlobal(globalSrcFaceIDs);
343 AMIPtr_->srcMap().distribute(globalSrcFaceIDs);
347 List<List<point>> globalSrcCtrs0(srcCtr0);
348 AMIPtr_->srcMap().distribute(globalSrcCtrs0);
351 globalTgtFaces0.inplaceToGlobal(globalTgtFaceIDs);
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)
446 globalSrcFaces1.inplaceToGlobal(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" 501 List<Map<label>> cMap;
504 new mapDistribute(globalSrcFaces1, tgtToSrcAddr1, cMap)
508 List<Map<label>> cMap;
511 new mapDistribute(globalTgtFaces1, srcToTgtAddr1, cMap)
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);
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 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)
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.