Go to the documentation of this file.
58 const int neighbProcNo,
65 neighbProcNo_(neighbProcNo),
68 neighbFaceCellCentres_()
86 neighbFaceCellCentres_()
101 neighbFaceCellCentres_()
117 neighbFaceCentres_(),
119 neighbFaceCellCentres_()
135 neighbFaceCentres_(),
137 neighbFaceCellCentres_()
156 UOPstream toNeighbProc(neighbProcNo(), pBufs);
161 << faceCellCentres();
171 UIPstream fromNeighbProc(neighbProcNo(), pBufs);
174 >> neighbFaceCentres_
176 >> neighbFaceCellCentres_;
183 vectorField nbrFaceNormals(neighbFaceAreas_.size());
189 forAll(faceNormals, facei)
191 scalar magSf =
mag(faceAreas()[facei]);
192 scalar nbrMagSf =
mag(neighbFaceAreas_[facei]);
193 scalar avSf = (magSf + nbrMagSf)/2.0;
197 if (magSf < SMALL || nbrMagSf < SMALL)
201 faceNormals[facei] =
point(1, 0, 0);
202 nbrFaceNormals[facei] = -faceNormals[facei];
205 else if (
mag(magSf - nbrMagSf) > matchTolerance()*
sqr(tols[facei]))
213 Pout<<
"processorPolyPatch::calcGeometry : Writing my "
215 <<
" faces to OBJ file " << nm <<
endl;
222 /
name() +
"_faceCentresConnections.obj"
225 Pout<<
"processorPolyPatch::calcGeometry :"
226 <<
" Dumping cell centre lines between"
227 <<
" corresponding face centres to OBJ file" << ccStr.
name()
232 forAll(faceCentres(), faceI)
234 const point& c0 = neighbFaceCentres_[faceI];
235 const point&
c1 = faceCentres()[faceI];
241 <<
"face " << facei <<
" area does not match neighbour by "
242 << 100*
mag(magSf - nbrMagSf)/avSf
243 <<
"% -- possible face ordering problem." <<
endl
244 <<
"patch:" <<
name()
245 <<
" my area:" << magSf
246 <<
" neighbour area:" << nbrMagSf
247 <<
" matching tolerance:"
248 << matchTolerance()*
sqr(tols[facei])
250 <<
"Mesh face:" << start()+facei
254 <<
"If you are certain your matching is correct"
255 <<
" you can increase the 'matchTolerance' setting"
256 <<
" in the patch dictionary in the boundary file."
258 <<
"Rerun with processor debug flag set for"
263 faceNormals[facei] = faceAreas()[facei]/magSf;
264 nbrFaceNormals[facei] = neighbFaceAreas_[facei]/nbrMagSf;
274 matchTolerance()*tols,
313 for (
label patchPointI = 0; patchPointI <
nPoints(); patchPointI++)
315 label faceI = pointFaces()[patchPointI][0];
317 pointFace[patchPointI] = faceI;
319 const face&
f = localFaces()[faceI];
321 pointIndex[patchPointI] =
findIndex(
f, patchPointI);
328 for (
label patchEdgeI = 0; patchEdgeI < nEdges(); patchEdgeI++)
330 label faceI = edgeFaces()[patchEdgeI][0];
332 edgeFace[patchEdgeI] = faceI;
334 const labelList& fEdges = faceEdges()[faceI];
336 edgeIndex[patchEdgeI] =
findIndex(fEdges, patchEdgeI);
339 UOPstream toNeighbProc(neighbProcNo(), pBufs);
355 neighbPointsPtr_.clear();
356 neighbEdgesPtr_.clear();
374 UIPstream fromNeighbProc(neighbProcNo(), pBufs);
390 labelList& neighbPoints = neighbPointsPtr_();
392 forAll(nbrPointFace, nbrPointI)
395 const face&
f = localFaces()[nbrPointFace[nbrPointI]];
398 label patchPointI =
f[index];
400 if (neighbPoints[patchPointI] == -1)
403 neighbPoints[patchPointI] = nbrPointI;
405 else if (neighbPoints[patchPointI] >= 0)
408 neighbPoints[patchPointI] = -2;
413 forAll(neighbPoints, patchPointI)
415 if (neighbPoints[patchPointI] == -2)
417 neighbPoints[patchPointI] = -1;
424 neighbEdgesPtr_.reset(
new labelList(nEdges(), -1));
425 labelList& neighbEdges = neighbEdgesPtr_();
427 forAll(nbrEdgeFace, nbrEdgeI)
430 const labelList&
f = faceEdges()[nbrEdgeFace[nbrEdgeI]];
432 label patchEdgeI =
f[index];
434 if (neighbEdges[patchEdgeI] == -1)
437 neighbEdges[patchEdgeI] = nbrEdgeI;
439 else if (neighbEdges[patchEdgeI] >= 0)
442 neighbEdges[patchEdgeI] = -2;
447 forAll(neighbEdges, patchEdgeI)
449 if (neighbEdges[patchEdgeI] == -2)
451 neighbEdges[patchEdgeI] = -1;
464 if (!neighbPointsPtr_.valid())
467 <<
"No extended addressing calculated for patch " <<
name()
470 return neighbPointsPtr_();
476 if (!neighbEdgesPtr_.valid())
479 <<
"No extended addressing calculated for patch " <<
name()
482 return neighbEdgesPtr_();
508 Pout<<
"processorPolyPatch::order : Writing my " << pp.size()
509 <<
" faces to OBJ file " << nm <<
endl;
518 /
name() +
"_localFaceCentres.obj"
520 Pout<<
"processorPolyPatch::order : "
521 <<
"Dumping " << fc.size()
522 <<
" local faceCentres to " << localStr.
name() <<
endl;
535 UOPstream toNeighbour(neighbProcNo(), pBufs);
555 facePointAverages[fI] += ppPoints[facePoints[pI]];
558 facePointAverages[fI] /= facePoints.
size();
562 UOPstream toNeighbour(neighbProcNo(), pBufs);
564 << anchors << facePointAverages;
580 const bool sameOrientation,
581 const scalar absTolSqr,
585 if (a.
size() !=
b.size())
593 if (!sameOrientation)
600 scalar closestMatchDistSqr =
sqr(GREAT);
607 const scalar diffSqr =
magSqr(aPts[aCirc()] - bPts[bCirc()]);
609 if (diffSqr < absTolSqr)
617 if (!sameOrientation)
626 matchDistSqr = diffSqr;
630 const scalar diffSqr2 =
magSqr(aPts[aCirc()] - bPts[bCirc2()]);
632 if (diffSqr2 > absTolSqr)
638 matchDistSqr += diffSqr2;
648 if (matchDistSqr < closestMatchDistSqr)
650 closestMatchDistSqr = matchDistSqr;
652 if (!sameOrientation)
661 if (closestMatchDistSqr == 0)
672 }
while (bCirc.
circulate(circulateDirection));
674 matchDistSqr = closestMatchDistSqr;
717 faceMap[patchFaceI] = patchFaceI;
734 const point& wantedAnchor = anchors[patchFaceI];
736 rotation[patchFaceI] = getRotation
744 if (rotation[patchFaceI] > 0)
761 UIPstream fromNeighbour(neighbProcNo(), pBufs);
762 fromNeighbour >> masterPts >> masterFaces;
772 const face& localFace = localFaces[lFaceI];
773 label faceRotation = -1;
775 const scalar absTolSqr =
sqr(SMALL);
777 scalar closestMatchDistSqr =
sqr(GREAT);
778 scalar matchDistSqr =
sqr(GREAT);
779 label closestFaceMatch = -1;
780 label closestFaceRotation = -1;
782 forAll(masterFaces, mFaceI)
784 const face& masterFace = masterFaces[mFaceI];
786 faceRotation = matchFace
800 && matchDistSqr < closestMatchDistSqr
803 closestMatchDistSqr = matchDistSqr;
804 closestFaceMatch = mFaceI;
805 closestFaceRotation = faceRotation;
808 if (closestMatchDistSqr == 0)
814 if (closestFaceRotation != -1 && closestMatchDistSqr == 0)
816 faceMap[lFaceI] = closestFaceMatch;
818 rotation[lFaceI] = closestFaceRotation;
820 if (lFaceI != closestFaceMatch || closestFaceRotation > 0)
829 Pout<<
"Number of matches = " << nMatches <<
" / "
830 << pp.size() <<
endl;
835 const label localPtI = localFace[pI];
836 pts[pI] = localPts[localPtI];
840 <<
"No match for face " << localFace <<
nl << pts
856 UIPstream fromNeighbour(neighbProcNo(), pBufs);
857 fromNeighbour >> masterCtrs >> masterNormals
858 >> masterAnchors >> masterFacePointAverages;
867 if (debug || masterCtrs.size() != pp.size())
873 /
name() +
"_nbrFaceCentres.obj"
875 Pout<<
"processorPolyPatch::order : "
876 <<
"Dumping neighbour faceCentres to " << nbrStr.
name()
880 writeOBJ(nbrStr, masterCtrs[faceI]);
884 if (masterCtrs.size() != pp.size())
887 <<
"in patch:" <<
name() <<
" : "
888 <<
"Local size of patch is " << pp.size() <<
" (faces)."
890 <<
"Received from neighbour " << masterCtrs.size()
923 facePointAverages[fI] += ppPoints[facePoints[pI]];
926 facePointAverages[fI] /= facePoints.
size();
932 *calcFaceTol(pp, pp.
points(), facePointAverages)
944 masterFacePointAverages,
954 faceMap[oldFaceI] = faceMap2[oldFaceI];
969 if (!matchedAll || debug)
975 /
name() +
"_faces.obj"
977 Pout<<
"processorPolyPatch::order :"
978 <<
" Writing faces to OBJ file " << str.
name() <<
endl;
984 /
name() +
"_faceCentresConnections.obj"
987 Pout<<
"processorPolyPatch::order :"
988 <<
" Dumping newly found match as lines between"
989 <<
" corresponding face centres to OBJ file "
999 if (masterFaceI != -1)
1001 const point& c0 = masterCtrs[masterFaceI];
1011 <<
"in patch:" <<
name() <<
" : "
1012 <<
"Cannot match vectors to faces on both sides of patch"
1014 <<
" masterCtrs[0]:" << masterCtrs[0] <<
endl
1016 <<
" Check your topology changes or maybe you have"
1017 <<
" multiple separated (from cyclics) processor patches"
1019 <<
" Continuing with incorrect face ordering from now on"
1034 const point& wantedAnchor = masterAnchors[newFaceI];
1036 rotation[newFaceI] = getRotation
1044 if (rotation[newFaceI] == -1)
1047 <<
"in patch " <<
name()
1049 <<
"Cannot find point on face " << pp[oldFaceI]
1050 <<
" with vertices "
1052 <<
" that matches point " << wantedAnchor
1053 <<
" when matching the halves of processor patch "
1055 <<
"Continuing with incorrect face ordering from now on"
1064 if (
faceMap[faceI] != faceI || rotation[faceI] != 0)
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
const Field< PointType > & points() const
Return reference to global points.
A class for handling words, derived from string.
Output inter-processor communications stream operating on external buffer.
A class for handling file names.
List< label > labelList
A List of labels.
virtual void movePoints(PstreamBuffers &, const pointField &p)
Correct patches after moving points.
#define forAll(list, i)
Loop across all elements in list.
void writeOBJ(Ostream &os, label &vertI, const tetPoints &tet)
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurence of given element and return index,.
Walks over a container as if it were circular. The container must have the following members defined:
void initMovePoints(PstreamBuffers &, const pointField &)
Initialise the patches for moving points.
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
Template functions to aid in the implementation of demand driven data.
const Field< PointType > & localPoints() const
Return pointField of points in patch.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
static bool & parRun()
Is this a parallel run?
void setIteratorToFulcrum()
Set the iterator to the current position of the fulcrum.
const labelList & neighbEdges() const
Return neighbour edge labels. WIP.
Ostream & endl(Ostream &os)
Add newline and flush stream.
The coupledPolyPatch is an abstract base class for patches that couple regions of the computational d...
dimensioned< scalar > mag(const dimensioned< Type > &)
virtual void updateMesh(PstreamBuffers &)
Update of the patch topology.
void calcGeometry(PstreamBuffers &)
Calculate the patch geometry.
dimensionSet transform(const dimensionSet &)
word name() const
Return file name (part beyond last /)
autoPtr< labelList > neighbPointsPtr_
Corresponding neighbouring local point label for every local point.
static label matchFace(const face &localFace, const pointField &localPts, const face &masterFace, const pointField &masterPts, const bool sameOrientation, const scalar absTolSqr, scalar &matchDistSqr)
Determine correspondence between points. See below.
virtual void initUpdateMesh(PstreamBuffers &)
Initialise the update of the patch topology.
const dimensionedScalar c1
First radiation constant: default SI units: [W/m2].
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Pre-declare SubField and related Field type.
void initGeometry(PstreamBuffers &)
Initialise the calculation of the patch geometry.
#define SeriousErrorInFunction
Report an error message using Foam::SeriousError.
Neighbour processor patch.
virtual void write(Ostream &) const
Write the polyPatch data as a dictionary.
A list of keyword definitions, which are a keyword followed by any number of values (e....
Macros for easy insertion into run-time selection tables.
errorManip< error > abort(error &err)
difference_type nRotations() const
Return the distance between the iterator and the fulcrum. This is.
void movePoints(PstreamBuffers &, const pointField &)
Correct patches after moving points.
errorManipArg< error, int > exit(error &err, const int errNo=1)
virtual void initUpdateMesh(PstreamBuffers &)
Initialise the update of the patch topology.
void setSize(const label)
Reset size of List.
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.
direction
Direction type enumeration.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const labelList & neighbPoints() const
Return neighbour point labels. WIP.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
virtual void write(Ostream &) const
Write the polyPatch data as a dictionary.
prefixOSstream Pout(cout, "Pout")
const Field< PointType > & faceNormals() const
Return face normals for patch.
virtual void initOrder(PstreamBuffers &, const primitivePatch &) const
Initialize ordering for primitivePatch. Does not.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
const Field< PointType > & faceCentres() const
Return face centres for patch.
Ostream & writeKeyword(const keyType &)
Write the keyword followed by an appropriate indentation.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
label readLabel(Istream &is)
const List< Face > & localFaces() const
Return patch faces addressing into local point list.
A List with indirect addressing.
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface....
A face is a list of labels corresponding to mesh vertices.
void setFulcrumToIterator()
Set the fulcrum to the current position of the iterator.
virtual void updateMesh(PstreamBuffers &)
Update of the patch topology.
const fileName & name() const
Return the name of the stream.
void size(const label)
Override size to be inconsistent with allocated storage.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Input inter-processor communications stream operating on external buffer.
virtual ~processorPolyPatch()
Destructor.
vector point
Point is a vector.
autoPtr< labelList > neighbEdgesPtr_
Corresponding neighbouring local edge label for every local edge.
defineTypeNameAndDebug(combustionModel, 0)
bool circulate(const CirculatorBase::direction dir=NONE)
Circulate around the list in the given direction.
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.
dimensioned< scalar > magSqr(const dimensioned< Type > &)
word name(const complex &)
Return a string representation of a complex.
virtual bool order(PstreamBuffers &, const primitivePatch &, labelList &faceMap, labelList &rotation) const
Return new ordering for primitivePatch.
A list of faces which address into the list of points.