60 const int neighbProcNo,
67 neighbProcNo_(neighbProcNo),
70 neighbFaceCellCentres_()
81 const int neighbProcNo,
88 newName(myProcNo, neighbProcNo),
97 neighbProcNo_(neighbProcNo),
100 neighbFaceCellCentres_()
110 const word& patchType
114 myProcNo_(
dict.
get<label>(
"myProcNo")),
115 neighbProcNo_(
dict.
get<label>(
"neighbProcNo")),
116 neighbFaceCentres_(),
118 neighbFaceCellCentres_()
129 myProcNo_(
pp.myProcNo_),
130 neighbProcNo_(
pp.neighbProcNo_),
131 neighbFaceCentres_(),
133 neighbFaceCellCentres_()
147 myProcNo_(
pp.myProcNo_),
148 neighbProcNo_(
pp.neighbProcNo_),
149 neighbFaceCentres_(),
151 neighbFaceCellCentres_()
165 myProcNo_(
pp.myProcNo_),
166 neighbProcNo_(
pp.neighbProcNo_),
167 neighbFaceCentres_(),
169 neighbFaceCellCentres_()
177 neighbPointsPtr_.clear();
178 neighbEdgesPtr_.clear();
186 const label myProcNo,
187 const label neighbProcNo
202 if (neighbProcNo() >= pBufs.
nProcs())
205 <<
"On patch " <<
name()
206 <<
" trying to access out of range neighbour processor " 207 << neighbProcNo() <<
". This can happen if" <<
nl 208 <<
" trying to run on an incorrect number of processors" 212 UOPstream toNeighbProc(neighbProcNo(), pBufs);
217 << faceCellCentres();
227 UIPstream fromNeighbProc(neighbProcNo(), pBufs);
230 >> neighbFaceCentres_
232 >> neighbFaceCellCentres_;
239 vectorField nbrFaceNormals(neighbFaceAreas_.size());
245 forAll(faceNormals, facei)
247 const scalar magSf =
mag(faceAreas()[facei]);
248 const scalar nbrMagSf =
mag(neighbFaceAreas_[facei]);
252 if (magSf < SMALL || nbrMagSf < SMALL)
256 faceNormals[facei] =
point(1, 0, 0);
257 nbrFaceNormals[facei] = -faceNormals[facei];
260 else if (
mag(magSf - nbrMagSf) > matchTolerance()*
sqr(tols[facei]))
262 const scalar avgMagSf = 0.5*(magSf + nbrMagSf);
270 Pout<<
"processorPolyPatch::calcGeometry : Writing my " 272 <<
" faces to OBJ file " << nm <<
endl;
279 /
name() +
"_faceCentresConnections.obj" 282 Pout<<
"processorPolyPatch::calcGeometry :" 283 <<
" Dumping cell centre lines between" 284 <<
" corresponding face centres to OBJ file" << ccStr.
name()
289 forAll(faceCentres(), facej)
291 const point& c0 = neighbFaceCentres_[facej];
292 const point&
c1 = faceCentres()[facej];
298 <<
"face " << facei <<
" area does not match neighbour by " 299 << 100*
mag(magSf - nbrMagSf)/avgMagSf
300 <<
"% -- possible face ordering problem." <<
endl 301 <<
"patch:" <<
name()
302 <<
" my area:" << magSf
303 <<
" neighbour area:" << nbrMagSf
304 <<
" matching tolerance:" 305 << matchTolerance()*
sqr(tols[facei])
307 <<
"Mesh face:" << start()+facei
309 << UIndirectList<point>(
points(), operator[](facei))
311 <<
"If you are certain your matching is correct" 312 <<
" you can increase the 'matchTolerance' setting" 313 <<
" in the patch dictionary in the boundary file." 315 <<
"Rerun with processor debug flag set for" 320 faceNormals[facei] = faceAreas()[facei]/magSf;
321 nbrFaceNormals[facei] = neighbFaceAreas_[facei]/nbrMagSf;
331 matchTolerance()*tols,
341 PstreamBuffers& pBufs,
366 if (neighbProcNo() >= pBufs.
nProcs())
369 <<
"On patch " <<
name()
370 <<
" trying to access out of range neighbour processor " 371 << neighbProcNo() <<
". This can happen if" <<
nl 372 <<
" trying to run on an incorrect number of processors" 380 for (label patchPointi = 0; patchPointi <
nPoints(); patchPointi++)
382 label facei = pointFaces()[patchPointi][0];
384 pointFace[patchPointi] = facei;
386 const face&
f = localFaces()[facei];
388 pointIndex[patchPointi] =
f.
find(patchPointi);
395 for (label patchEdgeI = 0; patchEdgeI < nEdges(); patchEdgeI++)
397 label facei = edgeFaces()[patchEdgeI][0];
399 edgeFace[patchEdgeI] = facei;
401 const labelList& fEdges = faceEdges()[facei];
403 edgeIndex[patchEdgeI] = fEdges.
find(patchEdgeI);
406 UOPstream toNeighbProc(neighbProcNo(), pBufs);
422 neighbPointsPtr_.clear();
423 neighbEdgesPtr_.clear();
441 UIPstream fromNeighbProc(neighbProcNo(), pBufs);
457 labelList& neighbPoints = neighbPointsPtr_();
459 forAll(nbrPointFace, nbrPointi)
462 const face&
f = localFaces()[nbrPointFace[nbrPointi]];
464 label index = (
f.
size() - nbrPointIndex[nbrPointi]) %
f.
size();
465 label patchPointi =
f[index];
467 if (neighbPoints[patchPointi] == -1)
470 neighbPoints[patchPointi] = nbrPointi;
472 else if (neighbPoints[patchPointi] >= 0)
475 neighbPoints[patchPointi] = -2;
480 forAll(neighbPoints, patchPointi)
482 if (neighbPoints[patchPointi] == -2)
484 neighbPoints[patchPointi] = -1;
491 neighbEdgesPtr_.reset(
new labelList(nEdges(), -1));
492 labelList& neighbEdges = neighbEdgesPtr_();
494 forAll(nbrEdgeFace, nbrEdgeI)
497 const labelList&
f = faceEdges()[nbrEdgeFace[nbrEdgeI]];
498 label index = (
f.
size() - nbrEdgeIndex[nbrEdgeI] - 1) %
f.
size();
499 label patchEdgeI =
f[index];
501 if (neighbEdges[patchEdgeI] == -1)
504 neighbEdges[patchEdgeI] = nbrEdgeI;
506 else if (neighbEdges[patchEdgeI] >= 0)
509 neighbEdges[patchEdgeI] = -2;
514 forAll(neighbEdges, patchEdgeI)
516 if (neighbEdges[patchEdgeI] == -2)
518 neighbEdges[patchEdgeI] = -1;
531 if (!neighbPointsPtr_)
534 <<
"No extended addressing calculated for patch " <<
name()
537 return *neighbPointsPtr_;
543 if (!neighbEdgesPtr_)
546 <<
"No extended addressing calculated for patch " <<
name()
549 return *neighbEdgesPtr_;
555 PstreamBuffers& pBufs,
575 Pout<<
"processorPolyPatch::order : Writing my " <<
pp.size()
576 <<
" faces to OBJ file " << nm <<
endl;
585 /
name() +
"_localFaceCentres.obj" 587 Pout<<
"processorPolyPatch::order : " 588 <<
"Dumping " << fc.size()
589 <<
" local faceCentres to " << localStr.
name() <<
endl;
602 UOPstream toNeighbour(neighbProcNo(), pBufs);
622 facePointAverages[fI] += ppPoints[facePoints[pI]];
625 facePointAverages[fI] /= facePoints.size();
629 UOPstream toNeighbour(neighbProcNo(), pBufs);
631 << anchors << facePointAverages;
643 const bool sameOrientation,
644 const scalar absTolSqr,
648 if (a.size() !=
b.size())
656 if (!sameOrientation)
663 scalar closestMatchDistSqr =
sqr(GREAT);
665 ConstCirculator<face> aCirc(a);
666 ConstCirculator<face> bCirc(
b);
670 const scalar diffSqr =
magSqr(aPts[*aCirc] - bPts[*bCirc]);
672 if (diffSqr < absTolSqr)
675 ConstCirculator<face> bCirc2(bCirc);
678 bCirc2.setFulcrumToIterator();
680 if (!sameOrientation)
689 matchDistSqr = diffSqr;
693 const scalar diffSqr2 =
magSqr(aPts[*aCirc] - bPts[*bCirc2]);
695 if (diffSqr2 > absTolSqr)
701 matchDistSqr += diffSqr2;
706 bCirc2.circulate(circulateDirection)
709 if (!aCirc.circulate())
711 if (matchDistSqr < closestMatchDistSqr)
713 closestMatchDistSqr = matchDistSqr;
715 if (!sameOrientation)
717 matchFp = a.size() - bCirc.nRotations();
721 matchFp = bCirc.nRotations();
724 if (closestMatchDistSqr == 0)
732 aCirc.setIteratorToFulcrum();
735 }
while (bCirc.circulate(circulateDirection));
737 matchDistSqr = closestMatchDistSqr;
776 faceMap[patchFacei] = patchFacei;
793 const point& wantedAnchor = anchors[patchFacei];
795 rotation[patchFacei] = getRotation
803 if (rotation[patchFacei] > 0)
826 UIPstream fromNeighbour(neighbProcNo(), pBufs);
827 fromNeighbour >> masterPts >> masterFaces;
837 const face& localFace = localFaces[lFacei];
838 label faceRotation = -1;
840 const scalar absTolSqr =
sqr(tols[lFacei]);
842 scalar closestMatchDistSqr =
sqr(GREAT);
843 scalar matchDistSqr =
sqr(GREAT);
844 label closestFaceMatch = -1;
845 label closestFaceRotation = -1;
847 forAll(masterFaces, mFacei)
849 const face& masterFace = masterFaces[mFacei];
851 faceRotation = matchFace
865 && matchDistSqr < closestMatchDistSqr
868 closestMatchDistSqr = matchDistSqr;
869 closestFaceMatch = mFacei;
870 closestFaceRotation = faceRotation;
873 if (closestMatchDistSqr == 0)
881 closestFaceRotation != -1
882 && closestMatchDistSqr < absTolSqr
885 faceMap[lFacei] = closestFaceMatch;
887 rotation[lFacei] = closestFaceRotation;
889 if (lFacei != closestFaceMatch || closestFaceRotation > 0)
898 Pout<<
"Number of matches = " << nMatches <<
" / " 904 const label localPtI = localFace[pI];
905 pts[pI] = localPts[localPtI];
909 <<
"No match for face " << localFace <<
nl <<
pts 925 UIPstream fromNeighbour(neighbProcNo(), pBufs);
926 fromNeighbour >> masterCtrs >> masterNormals
927 >> masterAnchors >> masterFacePointAverages;
930 if (
debug || masterCtrs.size() !=
pp.size())
936 /
name() +
"_nbrFaceCentres.obj" 938 Pout<<
"processorPolyPatch::order : " 939 <<
"Dumping neighbour faceCentres to " << nbrStr.
name()
943 writeOBJ(nbrStr, masterCtrs[facei]);
947 if (masterCtrs.size() !=
pp.size())
950 <<
"in patch:" <<
name() <<
" : " 951 <<
"Local size of patch is " <<
pp.size() <<
" (faces)." 953 <<
"Received from neighbour " << masterCtrs.size()
986 facePointAverages[fI] += ppPoints[facePoints[pI]];
989 facePointAverages[fI] /= facePoints.size();
995 *calcFaceTol(
pp,
pp.
points(), facePointAverages)
1007 masterFacePointAverages,
1019 faceMap[oldFacei] = faceMap2[oldFacei];
1029 if (!matchedAll ||
debug)
1034 boundaryMesh().
mesh().time().
path()
1035 /
name() +
"_faces.obj" 1037 Pout<<
"processorPolyPatch::order :" 1038 <<
" Writing faces to OBJ file " << str.
name() <<
endl;
1043 boundaryMesh().
mesh().time().
path()
1044 /
name() +
"_faceCentresConnections.obj" 1047 Pout<<
"processorPolyPatch::order :" 1048 <<
" Dumping newly found match as lines between" 1049 <<
" corresponding face centres to OBJ file " 1057 label masterFacei =
faceMap[facei];
1059 if (masterFacei != -1)
1061 const point& c0 = masterCtrs[masterFacei];
1071 <<
"in patch:" <<
name() <<
" : " 1072 <<
"Cannot match vectors to faces on both sides of patch" 1074 <<
" masterCtrs[0]:" << masterCtrs[0] <<
endl 1076 <<
" Check your topology changes or maybe you have" 1077 <<
" multiple separated (from cyclics) processor patches" 1079 <<
" Continuing with incorrect face ordering from now on" 1092 label newFacei =
faceMap[oldFacei];
1094 const point& wantedAnchor = masterAnchors[newFacei];
1096 rotation[newFacei] = getRotation
1104 if (rotation[newFacei] == -1)
1107 <<
"in patch " <<
name()
1109 <<
"Cannot find point on face " <<
pp[oldFacei]
1110 <<
" with vertices " 1111 << UIndirectList<point>(
pp.
points(),
pp[oldFacei])
1112 <<
" that matches point " << wantedAnchor
1113 <<
" when matching the halves of processor patch " 1115 <<
"Continuing with incorrect face ordering from now on" 1124 if (
faceMap[facei] != facei || rotation[facei] != 0)
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
virtual const fileName & name() const
Get the name of the output serial stream. (eg, the name of the Fstream file name) ...
const List< face_type > & localFaces() const
Return patch faces addressing into local point list.
void size(const label n)
Older name for setAddressableSize.
const labelList & neighbPoints() const
Return neighbour point labels. WIP.
virtual void write(Ostream &os) const
Write the polyPatch data as a dictionary.
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
const Field< point_type > & localPoints() const
Return pointField of points in patch.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
virtual void initUpdateMesh(PstreamBuffers &)
Initialise the update of the patch topology.
label find(const T &val, label pos=0) const
Find index of the first occurrence of the value.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
constexpr char nl
The newline '\n' character (0x0a)
virtual void initOrder(PstreamBuffers &, const primitivePatch &) const
Initialize ordering for primitivePatch. Does not.
static word newName(const label myProcNo, const label neighbProcNo)
Return the name of a processorPolyPatch.
Ostream & endl(Ostream &os)
Add newline and flush stream.
void calcGeometry(PstreamBuffers &)
Calculate the patch geometry.
static bool & parRun() noexcept
Test if this a parallel run.
The coupledPolyPatch is an abstract base class for patches that couple regions of the computational d...
direction
Direction type enumeration.
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
void movePoints(PstreamBuffers &, const pointField &)
Correct patches after moving points.
Determine correspondence between points. See below.
Macros for easy insertion into run-time selection tables.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
virtual void movePoints(PstreamBuffers &, const pointField &p)
Correct patches after moving points.
#define SeriousErrorInFunction
Report an error message using Foam::SeriousError.
Neighbour processor patch.
#define forAll(list, i)
Loop across all elements in list.
void initMovePoints(PstreamBuffers &, const pointField &)
Initialise the patches for moving points.
const Field< point_type > & faceNormals() const
Return face unit normals for patch.
List< face > faceList
List of faces.
A list of faces which address into the list of points.
bool matchPoints(const UList< point > &pts0, const UList< point > &pts1, const UList< scalar > &matchDistance, const bool verbose, labelList &from0To1, const point &origin=point::zero)
Determine correspondence between pointFields. Gets passed.
vectorField pointField
pointField is a vectorField.
void setSize(const label n)
Alias for resize()
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
virtual void initUpdateMesh(PstreamBuffers &)
Initialise the update of the patch topology.
A class for handling words, derived from Foam::string.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
const Field< point_type > & faceCentres() const
Return face centres for patch.
virtual ~processorPolyPatch()
Destructor.
virtual void updateMesh(PstreamBuffers &)
Update of the patch topology.
const Field< point_type > & points() const noexcept
Return reference to global points.
errorManip< error > abort(error &err)
void initGeometry(PstreamBuffers &)
Initialise the calculation of the patch geometry.
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO...
int debug
Static debugging option.
OBJstream os(runTime.globalPath()/outputName)
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
defineTypeNameAndDebug(combustionModel, 0)
virtual void updateMesh(PstreamBuffers &)
Update of the patch topology.
static label matchFace(const face &localFace, const pointField &localPts, const face &masterFace, const pointField &masterPts, const bool sameOrientation, const scalar absTolSqr, scalar &matchDistSqr)
Returns rotation.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
PrimitivePatch< SubList< face >, const pointField & > primitivePatch
A PrimitivePatch with a SubList addressing for the faces, const reference for the point field...
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
vector point
Point is a vector.
const dimensionedScalar c1
First radiation constant: default SI units: [W/m2].
virtual void write(Ostream &) const
Write the polyPatch data as a dictionary.
Field< vector > vectorField
Specialisation of Field<T> for vector.
virtual bool order(PstreamBuffers &, const primitivePatch &, labelList &faceMap, labelList &rotation) const
Return new ordering for primitivePatch.
label nProcs() const noexcept
Number of ranks associated with PstreamBuffers.
List< label > labelList
A List of labels.
A patch is a list of labels that address the faces in the global face list.
const labelList & neighbEdges() const
Return neighbour edge labels. WIP.
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
processorPolyPatch(const word &name, const label size, const label start, const label index, const polyBoundaryMesh &bm, const int myProcNo, const int neighbProcNo, const transformType transform=UNKNOWN, const word &patchType=typeName)
Construct from components with specified name.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
static constexpr const zero Zero
Global zero (0)