55 const label neighbProcNo
77 const int neighbProcNo,
84 neighbProcNo_(neighbProcNo),
87 neighbFaceCellCentres_()
98 const int neighbProcNo,
100 const word& patchType
105 newName(myProcNo, neighbProcNo),
114 neighbProcNo_(neighbProcNo),
115 neighbFaceCentres_(),
117 neighbFaceCellCentres_()
127 const word& patchType
131 myProcNo_(
dict.
get<label>(
"myProcNo")),
132 neighbProcNo_(
dict.
get<label>(
"neighbProcNo")),
133 neighbFaceCentres_(),
135 neighbFaceCellCentres_()
146 myProcNo_(
pp.myProcNo_),
147 neighbProcNo_(
pp.neighbProcNo_),
148 neighbFaceCentres_(),
150 neighbFaceCellCentres_()
164 myProcNo_(
pp.myProcNo_),
165 neighbProcNo_(
pp.neighbProcNo_),
166 neighbFaceCentres_(),
168 neighbFaceCellCentres_()
182 myProcNo_(
pp.myProcNo_),
183 neighbProcNo_(
pp.neighbProcNo_),
184 neighbFaceCentres_(),
186 neighbFaceCellCentres_()
194 neighbPointsPtr_.clear();
195 neighbEdgesPtr_.clear();
205 if (neighbProcNo() >= pBufs.
nProcs())
208 <<
"On patch " <<
name()
209 <<
" trying to access out of range neighbour processor " 210 << neighbProcNo() <<
". This can happen if" <<
nl 211 <<
" trying to run on an incorrect number of processors" 215 UOPstream toNeighbProc(neighbProcNo(), pBufs);
220 << faceCellCentres();
230 UIPstream fromNeighbProc(neighbProcNo(), pBufs);
233 >> neighbFaceCentres_
235 >> neighbFaceCellCentres_;
242 vectorField nbrFaceNormals(neighbFaceAreas_.size());
248 forAll(faceNormals, facei)
250 const scalar magSf =
mag(faceAreas()[facei]);
251 const scalar nbrMagSf =
mag(neighbFaceAreas_[facei]);
255 if (magSf < SMALL || nbrMagSf < SMALL)
259 faceNormals[facei] =
point(1, 0, 0);
260 nbrFaceNormals[facei] = -faceNormals[facei];
263 else if (
mag(magSf - nbrMagSf) > matchTolerance()*
sqr(tols[facei]))
265 const scalar avgMagSf = 0.5*(magSf + nbrMagSf);
273 Pout<<
"processorPolyPatch::calcGeometry : Writing my " 275 <<
" faces to OBJ file " << nm <<
endl;
282 /
name() +
"_faceCentresConnections.obj" 285 Pout<<
"processorPolyPatch::calcGeometry :" 286 <<
" Dumping cell centre lines between" 287 <<
" corresponding face centres to OBJ file" << ccStr.
name()
292 forAll(faceCentres(), facej)
294 const point& c0 = neighbFaceCentres_[facej];
295 const point&
c1 = faceCentres()[facej];
301 <<
"face " << facei <<
" area does not match neighbour by " 302 << 100*
mag(magSf - nbrMagSf)/avgMagSf
303 <<
"% -- possible face ordering problem." <<
endl 304 <<
"patch:" <<
name()
305 <<
" my area:" << magSf
306 <<
" neighbour area:" << nbrMagSf
307 <<
" matching tolerance:" 308 << matchTolerance()*
sqr(tols[facei])
310 <<
"Mesh face:" << start()+facei
312 << UIndirectList<point>(
points(), operator[](facei))
314 <<
"If you are certain your matching is correct" 315 <<
" you can increase the 'matchTolerance' setting" 316 <<
" in the patch dictionary in the boundary file." 318 <<
"Rerun with processor debug flag set for" 323 faceNormals[facei] = faceAreas()[facei]/magSf;
324 nbrFaceNormals[facei] = neighbFaceAreas_[facei]/nbrMagSf;
334 matchTolerance()*tols,
344 PstreamBuffers& pBufs,
369 if (neighbProcNo() >= pBufs.
nProcs())
372 <<
"On patch " <<
name()
373 <<
" trying to access out of range neighbour processor " 374 << neighbProcNo() <<
". This can happen if" <<
nl 375 <<
" trying to run on an incorrect number of processors" 383 for (label patchPointi = 0; patchPointi <
nPoints(); patchPointi++)
385 label facei = pointFaces()[patchPointi][0];
387 pointFace[patchPointi] = facei;
389 const face&
f = localFaces()[facei];
391 pointIndex[patchPointi] =
f.
find(patchPointi);
398 for (label patchEdgeI = 0; patchEdgeI < nEdges(); patchEdgeI++)
400 label facei = edgeFaces()[patchEdgeI][0];
402 edgeFace[patchEdgeI] = facei;
404 const labelList& fEdges = faceEdges()[facei];
406 edgeIndex[patchEdgeI] = fEdges.
find(patchEdgeI);
409 UOPstream toNeighbProc(neighbProcNo(), pBufs);
425 neighbPointsPtr_.clear();
426 neighbEdgesPtr_.clear();
444 UIPstream fromNeighbProc(neighbProcNo(), pBufs);
460 labelList& neighbPoints = neighbPointsPtr_();
462 forAll(nbrPointFace, nbrPointi)
465 const face&
f = localFaces()[nbrPointFace[nbrPointi]];
467 label index = (
f.
size() - nbrPointIndex[nbrPointi]) %
f.
size();
468 label patchPointi =
f[index];
470 if (neighbPoints[patchPointi] == -1)
473 neighbPoints[patchPointi] = nbrPointi;
475 else if (neighbPoints[patchPointi] >= 0)
478 neighbPoints[patchPointi] = -2;
483 forAll(neighbPoints, patchPointi)
485 if (neighbPoints[patchPointi] == -2)
487 neighbPoints[patchPointi] = -1;
494 neighbEdgesPtr_.reset(
new labelList(nEdges(), -1));
495 labelList& neighbEdges = neighbEdgesPtr_();
497 forAll(nbrEdgeFace, nbrEdgeI)
500 const labelList&
f = faceEdges()[nbrEdgeFace[nbrEdgeI]];
501 label index = (
f.
size() - nbrEdgeIndex[nbrEdgeI] - 1) %
f.
size();
502 label patchEdgeI =
f[index];
504 if (neighbEdges[patchEdgeI] == -1)
507 neighbEdges[patchEdgeI] = nbrEdgeI;
509 else if (neighbEdges[patchEdgeI] >= 0)
512 neighbEdges[patchEdgeI] = -2;
517 forAll(neighbEdges, patchEdgeI)
519 if (neighbEdges[patchEdgeI] == -2)
521 neighbEdges[patchEdgeI] = -1;
534 if (!neighbPointsPtr_)
537 <<
"No extended addressing calculated for patch " <<
name()
540 return *neighbPointsPtr_;
546 if (!neighbEdgesPtr_)
549 <<
"No extended addressing calculated for patch " <<
name()
552 return *neighbEdgesPtr_;
558 PstreamBuffers& pBufs,
578 Pout<<
"processorPolyPatch::order : Writing my " <<
pp.size()
579 <<
" faces to OBJ file " << nm <<
endl;
588 /
name() +
"_localFaceCentres.obj" 590 Pout<<
"processorPolyPatch::order : " 591 <<
"Dumping " << fc.size()
592 <<
" local faceCentres to " << localStr.
name() <<
endl;
605 UOPstream toNeighbour(neighbProcNo(), pBufs);
625 facePointAverages[fI] += ppPoints[facePoints[pI]];
628 facePointAverages[fI] /= facePoints.size();
632 UOPstream toNeighbour(neighbProcNo(), pBufs);
634 << anchors << facePointAverages;
646 const bool sameOrientation,
647 const scalar absTolSqr,
651 if (a.size() !=
b.size())
659 if (!sameOrientation)
666 scalar closestMatchDistSqr =
sqr(GREAT);
668 ConstCirculator<face> aCirc(a);
669 ConstCirculator<face> bCirc(
b);
673 const scalar diffSqr =
magSqr(aPts[*aCirc] - bPts[*bCirc]);
675 if (diffSqr < absTolSqr)
678 ConstCirculator<face> bCirc2(bCirc);
681 bCirc2.setFulcrumToIterator();
683 if (!sameOrientation)
692 matchDistSqr = diffSqr;
696 const scalar diffSqr2 =
magSqr(aPts[*aCirc] - bPts[*bCirc2]);
698 if (diffSqr2 > absTolSqr)
704 matchDistSqr += diffSqr2;
709 bCirc2.circulate(circulateDirection)
712 if (!aCirc.circulate())
714 if (matchDistSqr < closestMatchDistSqr)
716 closestMatchDistSqr = matchDistSqr;
718 if (!sameOrientation)
720 matchFp = a.size() - bCirc.nRotations();
724 matchFp = bCirc.nRotations();
727 if (closestMatchDistSqr == 0)
735 aCirc.setIteratorToFulcrum();
738 }
while (bCirc.circulate(circulateDirection));
740 matchDistSqr = closestMatchDistSqr;
779 faceMap[patchFacei] = patchFacei;
796 const point& wantedAnchor = anchors[patchFacei];
798 rotation[patchFacei] = getRotation
806 if (rotation[patchFacei] > 0)
829 UIPstream fromNeighbour(neighbProcNo(), pBufs);
830 fromNeighbour >> masterPts >> masterFaces;
840 const face& localFace = localFaces[lFacei];
841 label faceRotation = -1;
843 const scalar absTolSqr =
sqr(tols[lFacei]);
845 scalar closestMatchDistSqr =
sqr(GREAT);
846 scalar matchDistSqr =
sqr(GREAT);
847 label closestFaceMatch = -1;
848 label closestFaceRotation = -1;
850 forAll(masterFaces, mFacei)
852 const face& masterFace = masterFaces[mFacei];
854 faceRotation = matchFace
868 && matchDistSqr < closestMatchDistSqr
871 closestMatchDistSqr = matchDistSqr;
872 closestFaceMatch = mFacei;
873 closestFaceRotation = faceRotation;
876 if (closestMatchDistSqr == 0)
884 closestFaceRotation != -1
885 && closestMatchDistSqr < absTolSqr
888 faceMap[lFacei] = closestFaceMatch;
890 rotation[lFacei] = closestFaceRotation;
892 if (lFacei != closestFaceMatch || closestFaceRotation > 0)
901 Pout<<
"Number of matches = " << nMatches <<
" / " 907 const label localPtI = localFace[pI];
908 pts[pI] = localPts[localPtI];
912 <<
"No match for face " << localFace <<
nl <<
pts 928 UIPstream fromNeighbour(neighbProcNo(), pBufs);
929 fromNeighbour >> masterCtrs >> masterNormals
930 >> masterAnchors >> masterFacePointAverages;
933 if (
debug || masterCtrs.size() !=
pp.size())
939 /
name() +
"_nbrFaceCentres.obj" 941 Pout<<
"processorPolyPatch::order : " 942 <<
"Dumping neighbour faceCentres to " << nbrStr.
name()
946 writeOBJ(nbrStr, masterCtrs[facei]);
950 if (masterCtrs.size() !=
pp.size())
953 <<
"in patch:" <<
name() <<
" : " 954 <<
"Local size of patch is " <<
pp.size() <<
" (faces)." 956 <<
"Received from neighbour " << masterCtrs.size()
989 facePointAverages[fI] += ppPoints[facePoints[pI]];
992 facePointAverages[fI] /= facePoints.size();
998 *calcFaceTol(
pp,
pp.
points(), facePointAverages)
1010 masterFacePointAverages,
1022 faceMap[oldFacei] = faceMap2[oldFacei];
1032 if (!matchedAll ||
debug)
1037 boundaryMesh().
mesh().time().
path()
1038 /
name() +
"_faces.obj" 1040 Pout<<
"processorPolyPatch::order :" 1041 <<
" Writing faces to OBJ file " << str.
name() <<
endl;
1046 boundaryMesh().
mesh().time().
path()
1047 /
name() +
"_faceCentresConnections.obj" 1050 Pout<<
"processorPolyPatch::order :" 1051 <<
" Dumping newly found match as lines between" 1052 <<
" corresponding face centres to OBJ file " 1060 label masterFacei =
faceMap[facei];
1062 if (masterFacei != -1)
1064 const point& c0 = masterCtrs[masterFacei];
1074 <<
"in patch:" <<
name() <<
" : " 1075 <<
"Cannot match vectors to faces on both sides of patch" 1077 <<
" masterCtrs[0]:" << masterCtrs[0] <<
endl 1079 <<
" Check your topology changes or maybe you have" 1080 <<
" multiple separated (from cyclics) processor patches" 1082 <<
" Continuing with incorrect face ordering from now on" 1095 label newFacei =
faceMap[oldFacei];
1097 const point& wantedAnchor = masterAnchors[newFacei];
1099 rotation[newFacei] = getRotation
1107 if (rotation[newFacei] == -1)
1110 <<
"in patch " <<
name()
1112 <<
"Cannot find point on face " <<
pp[oldFacei]
1113 <<
" with vertices " 1114 << UIndirectList<point>(
pp.
points(),
pp[oldFacei])
1115 <<
" that matches point " << wantedAnchor
1116 <<
" when matching the halves of processor patch " 1118 <<
"Continuing with incorrect face ordering from now on" 1127 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.
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.
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 ("procBoundary..") constructed from the pair of processor IDs...
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.
virtual const fileName & name() const override
Get the name of the output serial stream. (eg, the name of the Fstream file name) ...
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 expressions::valueTypeCode::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)
label find(const T &val) const
Find index of the first occurrence of the value.
void initGeometry(PstreamBuffers &)
Initialise the calculation of the patch geometry.
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO...
Output inter-processor communications stream using MPI send/recv etc. - operating on external buffer...
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...
int neighbProcNo() const noexcept
Return neighbour processor number.
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.
int myProcNo() const noexcept
Return processor number.
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())
addToRunTimeSelectionTable(functionObject, pointHistory, dictionary)
static constexpr const zero Zero
Global zero (0)