37 const scalar coupledPolyPatch::defaultMatchTol_ = 1
e-4;
45 "coincidentFullMatch",
58 os <<
"v " << pt.
x() <<
' ' << pt.
y() <<
' ' << pt.
z() <<
endl;
71 writeOBJ(os, points[pointLabels[i]]);
90 os <<
"l " << vertI-1 <<
' ' << vertI <<
nl;
109 const face& f = faces[i];
113 if (foamToObj.insert(f[fp], vertI))
123 os <<
' ' << foamToObj[f[fp]]+1;
125 os <<
' ' << foamToObj[f[0]]+1 <<
nl;
139 if (transform != COINCIDENTFULLMATCH)
144 anchors[facei] = points[faces[facei][0]];
152 const face& f = faces[facei];
158 const point& p1 = points[f[fp1]];
162 for (
label fp2 = 0; fp2 < f.size(); ++fp2)
164 if (f[fp1] == f[fp2])
169 const point& p2 = points[f[fp2]];
189 anchors[facei] = points[faces[facei][0]];
210 const point& cc = faceCentres[facei];
212 const face& f = faces[facei];
216 scalar maxLenSqr = -great;
219 scalar maxCmpt = -great;
223 const point& pt = points[f[fp]];
224 maxLenSqr =
max(maxLenSqr,
magSqr(pt - cc));
247 scalar minDistSqr = great;
251 scalar distSqr =
magSqr(anchor - points[f[fp]]);
253 if (distSqr < minDistSqr)
255 minDistSqr = distSqr;
260 if (anchorFp == -1 ||
Foam::sqrt(minDistSqr) > tol)
269 scalar distSqr =
magSqr(anchor - points[f[fp]]);
271 if (distSqr == minDistSqr && fp != anchorFp)
274 <<
"Cannot determine unique anchor point on face " 277 <<
"Both at index " << anchorFp <<
" and " << fp
278 <<
" the vertices have the same distance " 280 <<
" to the anchor " << anchor
281 <<
". Continuing but results might be wrong." 287 return (f.
size() - anchorFp) % f.
size();
305 Pout<<
"coupledPolyPatch::calcTransformTensors : " <<
name() <<
endl 306 <<
" transform:" << transformTypeNames[
transform] <<
nl 307 <<
" (half)size:" << Cf.
size() <<
nl 308 <<
" absTol:" << absTol <<
nl 309 <<
" smallDist min:" <<
min(smallDist) <<
nl 310 <<
" smallDist max:" <<
max(smallDist) <<
nl 311 <<
" sum(mag(nf & nr)):" <<
sum(
mag(nf & nr)) <<
endl;
325 separation_.setSize(0);
328 collocated_.setSize(0);
341 transform == ROTATIONAL
343 transform != TRANSLATIONAL
344 && transform != COINCIDENTFULLMATCH
353 separation_.setSize(0);
355 forwardT_.setSize(Cf.
size());
356 reverseT_.setSize(Cf.
size());
357 collocated_.setSize(Cf.
size());
368 Pout<<
" sum(mag(forwardT_ - forwardT_[0])):" 369 <<
sum(
mag(forwardT_ - forwardT_[0]))
373 if (
sum(
mag(forwardT_ - forwardT_[0])) < error)
375 forwardT_.setSize(1);
376 reverseT_.setSize(1);
377 collocated_.setSize(1);
381 Pout<<
" difference in rotation less than" 382 <<
" local tolerance " 383 << error <<
". Assuming uniform rotation." <<
endl;
391 forwardT_.setSize(0);
392 reverseT_.setSize(0);
394 separation_ = Cr - Cf;
396 collocated_.
setSize(separation_.size());
404 bool sameSeparation =
true;
405 bool doneWarning =
false;
407 forAll(separation_, facei)
409 scalar smallSqr =
sqr(smallDist[facei]);
411 collocated_[facei] = (
magSqr(separation_[facei]) < smallSqr);
414 if (
magSqr(separation_[facei] - separation_[0]) > smallSqr)
416 sameSeparation =
false;
418 if (!doneWarning && debug)
422 Pout<<
" separation " << separation_[facei]
424 <<
" differs from separation[0] " << separation_[0]
425 <<
" by more than local tolerance " 427 <<
". Assuming non-uniform separation." <<
endl;
439 Pout<<
" separation " <<
mag(separation_[0])
440 <<
" less than local tolerance " << smallDist[0]
441 <<
". Assuming zero separation." <<
endl;
444 separation_.setSize(0);
451 Pout<<
" separation " <<
mag(separation_[0])
452 <<
" more than local tolerance " << smallDist[0]
453 <<
". Assuming uniform separation." <<
endl;
456 separation_.setSize(1);
465 Pout<<
" separation_:" << separation_.size() <<
nl 466 <<
" forwardT size:" << forwardT_.size() <<
endl;
480 const word& patchType,
484 polyPatch(name, size, start, index, bm, patchType),
485 matchTolerance_(defaultMatchTol_),
486 transform_(transform)
496 const word& patchType
499 polyPatch(name, dict, index, bm, patchType),
500 matchTolerance_(dict.
lookupOrDefault(
"matchTolerance", defaultMatchTol_)),
503 dict.
found(
"transform")
504 ? transformTypeNames.read(dict.
lookup(
"transform"))
517 matchTolerance_(pp.matchTolerance_),
518 transform_(pp.transform_)
531 polyPatch(pp, bm, index, newSize, newStart),
532 matchTolerance_(pp.matchTolerance_),
533 transform_(pp.transform_)
546 polyPatch(pp, bm, index, mapAddressing, newStart),
547 matchTolerance_(pp.matchTolerance_),
548 transform_(pp.transform_)
567 os.
writeKeyword(
"transform") << transformTypeNames[transform_]
void cmptMax(FieldField< Field, typename FieldField< Field, Type >::cmptType > &cf, const FieldField< Field, Type > &f)
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
#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.
A face is a list of labels corresponding to mesh vertices.
coupledPolyPatch(const word &name, const label size, const label start, const label index, const polyBoundaryMesh &bm, const word &patchType, const transformType transform)
Construct from components.
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 > &)
dimensionedSymmTensor sqr(const dimensionedVector &dv)
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.
The coupledPolyPatch is an abstract base class for patches that couple regions of the computational d...
tensor rotationTensor(const vector &n1, const vector &n2)
Rotational transformation tensor from vector n1 to n2.
Initialise the NamedEnum HashTable from the static list of names.
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.
List< bool > boolList
Bool container classes.
Class to handle errors and exceptions in a simple, consistent stream-based manner.
static pointField getAnchorPoints(const UList< face > &, const pointField &, const transformType)
Get a unique anchor point for all faces.
static const NamedEnum< transformType, 5 > transformTypeNames
A class for handling words, derived from string.
static void writeOBJ(Ostream &os, const point &pt)
Write point in OBJ format.
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...
defineTypeNameAndDebug(combustionModel, 0)
virtual void write(Ostream &) const
Write the polyPatch data as a dictionary.
Ostream & writeKeyword(const keyType &)
Write the keyword followed by an appropriate indentation.
static label getRotation(const pointField &points, const face &f, const point &anchor, const scalar tol)
Get the number of vertices face f needs to be rotated such that.
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
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.
void calcTransformTensors(const vectorField &Cf, const vectorField &Cr, const vectorField &nf, const vectorField &nr, const scalarField &smallDist, const scalar absTol, const transformType=UNKNOWN) const
Calculate the transformation tensors.
void setSize(const label)
Reset size of List.
virtual ~coupledPolyPatch()
Destructor.
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
#define WarningInFunction
Report a warning using Foam::Warning.
prefixOSstream Pout(cout, "Pout")
A List with indirect addressing.
dimensioned< scalar > mag(const dimensioned< Type > &)
const doubleScalar e
Elementary charge.
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.
dimensionSet transform(const dimensionSet &)
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.