43 bool Foam::coupledPolyPatch::walk
47 const label seedFacei,
48 const label seedFacePointi,
52 autoPtr<labelListList>& walks
56 label facei = seedFacei, facePointi = seedFacePointi;
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;
118 facePointi = facePointj;
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;
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;
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 its neighbour has "
362 << ownerNFaces <<
endl;
364 if (pp.
nPoints() != ownerNPoints)
367 << pp.
nPoints() <<
" points whilst its neighbour has "
368 << ownerNPoints <<
endl;
370 if (pp.
nEdges() != ownerNEdges)
373 << pp.
nEdges() <<
" edges whilst its 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();
536 matchTolerance_(defaultMatchTol_),
537 ownToOwnOrderDataPtr_(nullptr)
550 matchTolerance_(
dict.lookupOrDefault(
"matchTolerance", defaultMatchTol_)),
551 ownToOwnOrderDataPtr_(nullptr)
562 matchTolerance_(pp.matchTolerance_),
563 ownToOwnOrderDataPtr_(nullptr)
576 polyPatch(pp, bm, index, newSize, newStart),
577 matchTolerance_(pp.matchTolerance_),
578 ownToOwnOrderDataPtr_(nullptr)
602 const point& cc = faceCentres[facei];
604 const face&
f = faces[facei];
608 scalar maxLenSqr = -great;
611 scalar maxCmpt = -great;
616 maxLenSqr =
max(maxLenSqr,
magSqr(pt - cc));
633 writeEntry(os,
"matchTolerance", matchTolerance_);
645 is >> ownToNbr.seedFacePoints;
656 os << ownToNbr.seedFacePoints;
667 is >> ownToNbrDebug.nFaces
668 >> ownToNbrDebug.nPoints
669 >> ownToNbrDebug.nEdges
670 >> ownToNbrDebug.nInternalEdges;
681 os << ownToNbrDebug.nFaces
682 << ownToNbrDebug.nPoints
683 << ownToNbrDebug.nEdges
684 << ownToNbrDebug.nInternalEdges;
Various functions to operate on Lists.
#define forAll(list, i)
Loop across all elements in list.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
void resize(const label)
Alias for setSize(const label)
void size(const label)
Override size to be inconsistent with allocated storage.
void clear()
Clear the list, i.e. set size to zero.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
label nEdges() const
Return number of edges in patch.
label nPoints() const
Return number of points supporting patch faces.
label nInternalEdges() const
Number of internal edges.
const Field< PointType > & points() const
Return reference to global points.
const List< FaceType > & localFaces() const
Return patch faces addressing into local point list.
const Field< PointType > & localPoints() const
Return pointField of points in patch.
const Field< PointType > & faceCentres() const
Return face centres for patch.
A List with indirect addressing.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
T & first()
Return the first element of the list.
label size() const
Return the number of elements in the UList.
bool valid() const
Return true if the autoPtr valid (ie, the pointer is set)
The coupledPolyPatch is an abstract base class for patches that couple regions of the computational d...
virtual void write(Ostream &) const
Write the polyPatch data as a dictionary.
coupledPolyPatch(const word &name, const label size, const label start, const label index, const polyBoundaryMesh &bm)
Construct from components.
static const scalar defaultMatchTol_
Default matching tolerance.
virtual bool order(const ownToNbrOrderData &ownToNbr, const autoPtr< ownToNbrDebugOrderData > &ownToNbrDebugPtr, const primitivePatch &, labelList &faceMap, labelList &rotation) const
Return new ordering for the given primitivePatch.
static void writeOBJ(const fileName &, const primitivePatch &)
Write a patch in OBJ format.
static scalarField calcFaceTol(const UList< face > &faces, const pointField &points, const pointField &faceCentres)
Calculate typical tolerance per face. Is currently max distance.
virtual void initOrder(ownToNbrOrderData &ownToNbr, autoPtr< ownToNbrDebugOrderData > &ownToNbrDebugPtr, const primitivePatch &) const
Initialise ordering for the given primitivePatch. Fills the.
virtual ~coupledPolyPatch()
Destructor.
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
A face is a list of labels corresponding to mesh vertices.
A class for handling file names.
A patch is a list of labels that address the faces in the global face list.
virtual void write(Ostream &) const
Write the polyPatch data as a dictionary.
A class for handling words, derived from string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define SeriousErrorInFunction
Report an error message using Foam::SeriousError.
const dimensionedScalar c
Speed of light in a vacuum.
errorManipArg< error, int > exit(error &err, const int errNo=1)
List< label > labelList
A List of labels.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
ListType reverseList(const ListType &list)
Reverse a list. First element becomes last element etc.
ListType rotateList(const ListType &list, const label n)
Rotate a list by n places. If n is positive rotate clockwise/right/down.
vectorField pointField
pointField is a vectorField.
void cmptMax(Field< typename Field< Type >::cmptType > &res, const UList< Type > &f)
PrimitivePatch< SubList< face >, const pointField & > primitivePatch
Addressing for a faceList slice.
List< labelList > labelListList
A List of labelList.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
prefixOSstream Pout(cout, "Pout")
tmp< DimensionedField< Type, GeoMesh, Field > > cmptMag(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
void sqrt(LagrangianPatchField< scalar > &f, const LagrangianPatchField< scalar > &f1)
tmp< DimensionedField< scalar, GeoMesh, Field > > magSqr(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
defineTypeNameAndDebug(atmosphericBoundaryLayer, 0)
void writeEntry(Ostream &os, const word &key, const DimensionedFieldFunction< DimensionedFieldType > &f)
dimensioned< Type > max(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
Data to pass from owner.initOrder to nbr.order if debugging.
Data to pass from owner.initOrder to nbr.order.
List< pointField > seedFacePoints
Data to pass from owner.initOrder to owner.order.