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);
74 const label faceEdgei = direction ? facePointi : facePointi1;
77 const label edgei = pp.faceEdges()[facei][faceEdgei];
78 const labelList edgeFaces = pp.edgeFaces()[edgei];
81 if (edgeFaces.size() == 2)
87 const label facej = edgeFaces[edgeFaces[0] == facei];
88 const label facePointj = pp[facej].which(pp[facei][facePointi]);
91 if (faceMap[facej] == -1)
96 facePointi = facePointj;
97 faceMap[facei] = mapFacei;
98 facePointMap[facei] = facePointi;
99 changed = changed || facei != mapFacei || facePointi != 0;
102 else if (facePointMap[facei] != facePointi1 || facei == seedFacei)
107 facePointi = facePointi1;
115 facePointi = facePointj;
119 if (walks.valid() && walks->last().last() != facei)
121 walks->last().append(facei);
129 facePointi = facePointi1;
132 while (facei != seedFacei || facePointi != seedFacePointi);
151 os <<
"v " << p.
x() <<
' ' << p.
y() <<
' ' << p.
z() <<
endl;
160 os <<
' ' << f[fi] + 1;
177 const point& p0 = points0[pointi];
178 const point& p1 = points1[pointi];
179 os <<
"v " << p0.
x() <<
' ' << p0.
y() <<
' ' << p0.
z() <<
endl 180 <<
"v " << p1.
x() <<
' ' << p1.
y() <<
' ' << p1.
z() <<
endl 181 <<
"l " << 2*pointi <<
' ' << 2*pointi + 1 <<
endl;
197 const point&
c = points[pointi];
198 os <<
"v " << c.
x() <<
' '<< c.
y() <<
' ' << c.
z() <<
endl;
203 for (
label pathj = 0; pathj < paths[pathi].
size() - 1; ++ pathj)
205 os <<
"l " << paths[pathi][pathj] + 1 <<
' ' 206 << paths[pathi][pathj + 1] + 1 <<
endl;
232 while (mapFacei < pp.size())
248 if (faceRegionis[facei] == -1 && faceMap[facei] != -1)
250 faceRegionis[facei] = nRegions;
258 if (faceMap[facei] == -1)
277 ownToOwnOrderDataPtr_->seedFaceis =
labelList(nRegions, -1);
281 const label regioni = faceRegionis[facei];
283 if (tols[facei] > maxTols[regioni])
285 ownToOwnOrderDataPtr_->seedFaceis[regioni] = facei;
286 maxTols[regioni] = tols[facei];
293 forAll(ownToOwnOrderDataPtr_->seedFaceis, regioni)
295 const face&
f = pp[ownToOwnOrderDataPtr_->seedFaceis[regioni]];
300 if (ownToNbrDebugPtr.
valid())
303 ownToNbrDebugPtr->nFaces = pp.size();
304 ownToNbrDebugPtr->nPoints = pp.
nPoints();
305 ownToNbrDebugPtr->nEdges = pp.
nEdges();
325 seedFaceis = ownToOwnOrderDataPtr_->seedFaceis;
326 ownToOwnOrderDataPtr_.
clear();
334 seedFaceis.
resize(ownerSeedFacePoints.
size());
335 seedFacePointis.
resize(ownerSeedFacePoints.
size());
338 if (ownToNbrDebugPtr.
valid())
340 const label ownerNFaces = ownToNbrDebugPtr->nFaces;
341 const label ownerNPoints = ownToNbrDebugPtr->nPoints;
342 const label ownerNEdges = ownToNbrDebugPtr->nEdges;
343 const label ownerNInternalEdges = ownToNbrDebugPtr->nInternalEdges;
344 if (pp.size() != ownerNFaces)
347 << pp.size() <<
" faces whilst it's neighbour has " 348 << ownerNFaces <<
endl;
350 if (pp.
nPoints() != ownerNPoints)
353 << pp.
nPoints() <<
" points whilst it's neighbour has " 354 << ownerNPoints <<
endl;
356 if (pp.
nEdges() != ownerNEdges)
359 << pp.
nEdges() <<
" edges whilst it's neighbour has " 360 << ownerNEdges <<
endl;
366 <<
"neighbour has " << ownerNInternalEdges <<
endl;
372 forAll(ownerSeedFacePoints, regioni)
374 const pointField& ownerFacePts = ownerSeedFacePoints[regioni];
379 scalar minSumSqrDisplacement = vGreat;
384 if (facePts.
size() != ownerFacePts.
size())
continue;
386 forAll(facePts, facePointi)
388 const scalar sumSqrDisplacement =
397 if (sumSqrDisplacement < minSumSqrDisplacement)
399 seedFaceis[regioni] = facei;
400 seedFacePointis[regioni] = facePointi;
401 minSumSqrDisplacement = sumSqrDisplacement;
407 const scalar seedFaceTol =
410 faceList(1, pp[seedFaceis[regioni]]),
414 if (minSumSqrDisplacement > seedFaceTol)
417 <<
"The root-sum-square displacement between the points of " 418 <<
"the seed face and the best matching face (#" 419 << seedFaceis[regioni] <<
") on patch " <<
name()
420 <<
" is " <<
sqrt(minSumSqrDisplacement) <<
"." 422 <<
"This is greater than the match tolerance of " 423 << seedFaceTol <<
" for this face." 425 <<
"Check that the patches are conformal and that any " 426 <<
"transformations defined between them are correct" 428 <<
"It might be possible to fix this problem by increasing " 429 <<
"the \"matchTolerance\" setting for this patch in the " 432 <<
"Re-run with the \"coupled\" debug flag set for more " 440 bool changed =
false;
445 forAll(seedFaceis, regioni)
453 seedFacePointis[regioni],
472 Pout<<
"Writing patch " <<
name() <<
" walks to " 478 bool badWalk = mapFacei != pp.size();
481 badWalk = badWalk || facePointMap[facei] == -1;
486 <<
"The ordering walk did not hit every face exactly once" 494 (pp[facei].size() - facePointMap[facei]) % pp[facei].size();
519 const word& patchType
522 polyPatch(name, size, start, index, bm, patchType),
523 matchTolerance_(defaultMatchTol_),
524 ownToOwnOrderDataPtr_(
nullptr)
534 const word& patchType
537 polyPatch(name, dict, index, bm, patchType),
538 matchTolerance_(dict.
lookupOrDefault(
"matchTolerance", defaultMatchTol_)),
539 ownToOwnOrderDataPtr_(
nullptr)
551 ownToOwnOrderDataPtr_(
nullptr)
564 polyPatch(pp, bm, index, newSize, newStart),
566 ownToOwnOrderDataPtr_(
nullptr)
579 polyPatch(pp, bm, index, mapAddressing, newStart),
581 ownToOwnOrderDataPtr_(
nullptr)
605 const point& cc = faceCentres[facei];
607 const face&
f = faces[facei];
611 scalar maxLenSqr = -great;
614 scalar maxCmpt = -great;
618 const point& pt = points[f[fp]];
619 maxLenSqr =
max(maxLenSqr,
magSqr(pt - cc));
636 writeEntry(os,
"matchTolerance", matchTolerance_);
670 is >> ownToNbrDebug.nFaces
671 >> ownToNbrDebug.nPoints
672 >> ownToNbrDebug.nEdges
673 >> ownToNbrDebug.nInternalEdges;
684 os << ownToNbrDebug.nFaces
685 << ownToNbrDebug.nPoints
686 << ownToNbrDebug.nEdges
687 << 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.
const dimensionedScalar & c
Speed of light in a vacuum.
void resize(const label)
Alias for setSize(const label)
T & first()
Return the first element of the list.
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.