43 bool Foam::coupledPolyPatch::walk
47 const label seedFacei,
48 const label seedFacePointi,
52 autoPtr<labelListList>& walks
56 label facei = seedFacei, facePointi = seedFacePointi;
57 faceMap[facei] = mapFacei;
58 facePointMap[facei] = facePointi;
59 bool changed = facei != mapFacei || facePointi != 0;
70 const label facePointi1 =
72 ? pp[facei].fcIndex(facePointi)
73 : pp[facei].rcIndex(facePointi);
76 const label faceEdgei =
77 direction ? facePointi : pp[facei].rcIndex(facePointi);
78 const label edgei = pp.faceEdges()[facei][faceEdgei];
83 if (pp.edgeFaces()[edgei].size() != 2)
85 facePointi = facePointi1;
91 pp.edgeFaces()[edgei][pp.edgeFaces()[edgei][0] == facei];
92 const label facePointj = pp[facej].which(pp[facei][facePointi]);
95 const label facePointj1 =
97 ? pp[facej].rcIndex(facePointj)
98 : pp[facej].fcIndex(facePointj);
105 if (pp[facei][facePointi1] != pp[facej][facePointj1])
107 facePointi = facePointi1;
113 if (faceMap[facej] == -1)
118 facePointi = facePointj;
119 faceMap[facei] = mapFacei;
120 facePointMap[facei] = facePointi;
121 changed = changed || facei != mapFacei || facePointi != 0;
124 else if (facePointMap[facei] != facePointi1 || facei == seedFacei)
129 facePointi = facePointi1;
137 facePointi = facePointj;
141 if (walks.valid() && walks->last().last() != facei)
143 walks->last().append(facei);
146 while (facei != seedFacei || facePointi != seedFacePointi);
165 os <<
"v " << p.
x() <<
' ' << p.
y() <<
' ' << p.
z() <<
endl;
174 os <<
' ' << f[fi] + 1;
191 const point& p0 = points0[pointi];
192 const point& p1 = points1[pointi];
193 os <<
"v " << p0.
x() <<
' ' << p0.
y() <<
' ' << p0.
z() <<
endl 194 <<
"v " << p1.
x() <<
' ' << p1.
y() <<
' ' << p1.
z() <<
endl 195 <<
"l " << 2*pointi <<
' ' << 2*pointi + 1 <<
endl;
211 const point&
c = points[pointi];
212 os <<
"v " << c.
x() <<
' '<< c.
y() <<
' ' << c.
z() <<
endl;
217 for (
label pathj = 0; pathj < paths[pathi].
size() - 1; ++ pathj)
219 os <<
"l " << paths[pathi][pathj] + 1 <<
' ' 220 << paths[pathi][pathj + 1] + 1 <<
endl;
246 while (mapFacei < pp.size())
262 if (faceRegionis[facei] == -1 && faceMap[facei] != -1)
264 faceRegionis[facei] = nRegions;
272 if (faceMap[facei] == -1)
291 ownToOwnOrderDataPtr_->seedFaceis =
labelList(nRegions, -1);
295 const label regioni = faceRegionis[facei];
297 if (tols[facei] > maxTols[regioni])
299 ownToOwnOrderDataPtr_->seedFaceis[regioni] = facei;
300 maxTols[regioni] = tols[facei];
307 forAll(ownToOwnOrderDataPtr_->seedFaceis, regioni)
309 const face&
f = pp[ownToOwnOrderDataPtr_->seedFaceis[regioni]];
314 if (ownToNbrDebugPtr.
valid())
317 ownToNbrDebugPtr->nFaces = pp.size();
318 ownToNbrDebugPtr->nPoints = pp.
nPoints();
319 ownToNbrDebugPtr->nEdges = pp.
nEdges();
339 seedFaceis = ownToOwnOrderDataPtr_->seedFaceis;
340 ownToOwnOrderDataPtr_.
clear();
348 seedFaceis.
resize(ownerSeedFacePoints.
size());
349 seedFacePointis.
resize(ownerSeedFacePoints.
size());
352 if (ownToNbrDebugPtr.
valid())
354 const label ownerNFaces = ownToNbrDebugPtr->nFaces;
355 const label ownerNPoints = ownToNbrDebugPtr->nPoints;
356 const label ownerNEdges = ownToNbrDebugPtr->nEdges;
357 const label ownerNInternalEdges = ownToNbrDebugPtr->nInternalEdges;
358 if (pp.size() != ownerNFaces)
361 << pp.size() <<
" faces whilst it's neighbour has " 362 << ownerNFaces <<
endl;
364 if (pp.
nPoints() != ownerNPoints)
367 << pp.
nPoints() <<
" points whilst it's neighbour has " 368 << ownerNPoints <<
endl;
370 if (pp.
nEdges() != ownerNEdges)
373 << pp.
nEdges() <<
" edges whilst it's neighbour has " 374 << ownerNEdges <<
endl;
380 <<
"neighbour has " << ownerNInternalEdges <<
endl;
386 forAll(ownerSeedFacePoints, regioni)
388 const pointField& ownerFacePts = ownerSeedFacePoints[regioni];
393 scalar minSumSqrDisplacement = vGreat;
398 if (facePts.
size() != ownerFacePts.
size())
continue;
400 forAll(facePts, facePointi)
402 const scalar sumSqrDisplacement =
411 if (sumSqrDisplacement < minSumSqrDisplacement)
413 seedFaceis[regioni] = facei;
414 seedFacePointis[regioni] = facePointi;
415 minSumSqrDisplacement = sumSqrDisplacement;
421 const scalar seedFaceTol =
424 faceList(1, pp[seedFaceis[regioni]]),
428 if (minSumSqrDisplacement > seedFaceTol)
431 <<
"The root-sum-square displacement between the points of " 432 <<
"the seed face and the best matching face (#" 433 << seedFaceis[regioni] <<
") on patch " <<
name()
434 <<
" is " <<
sqrt(minSumSqrDisplacement) <<
"." 436 <<
"This is greater than the match tolerance of " 437 << seedFaceTol <<
" for this face." 439 <<
"Check that the patches are conformal and that any " 440 <<
"transformations defined between them are correct" 442 <<
"It might be possible to fix this problem by increasing " 443 <<
"the \"matchTolerance\" setting for this patch in the " 446 <<
"Re-run with the \"coupled\" debug flag set for more " 454 bool changed =
false;
459 forAll(seedFaceis, regioni)
467 seedFacePointis[regioni],
486 Pout<<
"Writing patch " <<
name() <<
" walks to " 492 bool badWalk = mapFacei != pp.size();
495 badWalk = badWalk || facePointMap[facei] == -1;
500 <<
"The ordering walk did not hit every face exactly once" 508 (pp[facei].size() - facePointMap[facei]) % pp[facei].size();
533 const word& patchType
536 polyPatch(name, size, start, index, bm, patchType),
537 matchTolerance_(defaultMatchTol_),
538 ownToOwnOrderDataPtr_(
nullptr)
548 const word& patchType
551 polyPatch(name, dict, index, bm, patchType),
552 matchTolerance_(dict.
lookupOrDefault(
"matchTolerance", defaultMatchTol_)),
553 ownToOwnOrderDataPtr_(
nullptr)
565 ownToOwnOrderDataPtr_(
nullptr)
578 polyPatch(pp, bm, index, newSize, newStart),
580 ownToOwnOrderDataPtr_(
nullptr)
593 polyPatch(pp, bm, index, mapAddressing, newStart),
595 ownToOwnOrderDataPtr_(
nullptr)
619 const point& cc = faceCentres[facei];
621 const face&
f = faces[facei];
625 scalar maxLenSqr = -great;
628 scalar maxCmpt = -great;
632 const point& pt = points[f[fp]];
633 maxLenSqr =
max(maxLenSqr,
magSqr(pt - cc));
650 writeEntry(os,
"matchTolerance", matchTolerance_);
684 is >> ownToNbrDebug.nFaces
685 >> ownToNbrDebug.nPoints
686 >> ownToNbrDebug.nEdges
687 >> ownToNbrDebug.nInternalEdges;
698 os << ownToNbrDebug.nFaces
699 << ownToNbrDebug.nPoints
700 << ownToNbrDebug.nEdges
701 << ownToNbrDebug.nInternalEdges;
List< labelList > labelListList
A List of labelList.
label nPoints() const
Return number of points supporting patch faces.
virtual bool order(const ownToNbrOrderData &ownToNbr, const autoPtr< ownToNbrDebugOrderData > &ownToNbrDebugPtr, const primitivePatch &, labelList &faceMap, labelList &rotation) const
Return new ordering for the given primitivePatch.
void cmptMax(FieldField< Field, typename FieldField< Field, Type >::cmptType > &cf, const FieldField< Field, Type > &f)
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
A class for handling file names.
errorManipArg< error, int > exit(error &err, const int errNo=1)
A face is a list of labels corresponding to mesh vertices.
A list of keyword definitions, which are a keyword followed by any number of values (e...
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const Field< PointType > & faceCentres() const
Return face centres for patch.
coupledPolyPatch(const word &name, const label size, const label start, const label index, const polyBoundaryMesh &bm, const word &patchType)
Construct from components.
ListType rotateList(const ListType &list, const label n)
Rotate a list by n places. If n is positive rotate clockwise/right/down.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
void size(const label)
Override size to be inconsistent with allocated storage.
dimensionedScalar sqrt(const dimensionedScalar &ds)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Data to pass from owner.initOrder to owner.order.
label nInternalEdges() const
Number of internal edges.
The coupledPolyPatch is an abstract base class for patches that couple regions of the computational d...
const Field< PointType > & localPoints() const
Return pointField of points in patch.
void resize(const label)
Alias for setSize(const label)
T & first()
Return the first element of the list.
const dimensionedScalar c
Speed of light in a vacuum.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
virtual void write(Ostream &) const
Write the polyPatch data as a dictionary.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
Various functions to operate on Lists.
#define SeriousErrorInFunction
Report an error message using Foam::SeriousError.
virtual void initOrder(ownToNbrOrderData &ownToNbr, autoPtr< ownToNbrDebugOrderData > &ownToNbrDebugPtr, const primitivePatch &) const
Initialise ordering for the given primitivePatch. Fills the.
Data to pass from owner.initOrder to nbr.order if debugging.
A list of faces which address into the list of points.
vectorField pointField
pointField is a vectorField.
const scalar matchTolerance_
Local matching tolerance.
void clear()
Clear the list, i.e. set size to zero.
A class for handling words, derived from string.
Data to pass from owner.initOrder to nbr.order.
const Field< PointType > & points() const
Return reference to global points.
List< label > labelList
A List of labels.
pointField points(const pointField &) const
Return the points corresponding to this face.
bool valid() const
Return true if the autoPtr valid (ie, the pointer is set)
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
ListType reverseList(const ListType &list)
Reverse a list. First element becomes last element etc.
void cmptMag(FieldField< Field, Type > &cf, const FieldField< Field, Type > &f)
dimensioned< scalar > magSqr(const dimensioned< Type > &)
An Ostream is an abstract base class for all output systems (streams, files, token lists...
label nEdges() const
Return number of edges in patch.
defineTypeNameAndDebug(combustionModel, 0)
virtual void write(Ostream &) const
Write the polyPatch data as a dictionary.
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
PrimitivePatch< SubList< face >, const pointField & > primitivePatch
Addressing for a faceList slice.
word name(const complex &)
Return a string representation of a complex.
static scalarField calcFaceTol(const UList< face > &faces, const pointField &points, const pointField &faceCentres)
Calculate typical tolerance per face. Is currently max distance.
virtual ~coupledPolyPatch()
Destructor.
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
prefixOSstream Pout(cout, "Pout")
const List< FaceType > & localFaces() const
Return patch faces addressing into local point list.
A List with indirect addressing.
const doubleScalar e
Elementary charge.
static const scalar defaultMatchTol_
Default matching tolerance.
A patch is a list of labels that address the faces in the global face list.
label size() const
Return the number of elements in the UList.
List< pointField > seedFacePoints
static void writeOBJ(const fileName &, const primitivePatch &)
Write a patch in OBJ format.