40 const scalar coupledPolyPatch::defaultMatchTol_ = 1
e-4;
50 { transformType::UNKNOWN,
"unknown" },
51 { transformType::ROTATIONAL,
"rotational" },
52 { transformType::TRANSLATIONAL,
"translational" },
54 { transformType::NOORDERING,
"noOrdering" },
62 os <<
"v " << pt.
x() <<
' ' << pt.
y() <<
' ' << pt.
z() <<
endl;
94 os <<
"l " << vertI-1 <<
' ' << vertI <<
nl;
111 for (
const face&
f : faces)
115 if (foamToObj.insert(
f[fp], vertI))
125 os <<
' ' << foamToObj[
f[fp]]+1;
127 os <<
' ' << foamToObj[
f[0]]+1 <<
nl;
146 anchors[facei] =
points[faces[facei][0]];
154 const face&
f = faces[facei];
164 for (label fp2 = 0; fp2 <
f.
size(); ++fp2)
166 if (
f[fp1] ==
f[fp2])
191 anchors[facei] =
points[faces[facei][0]];
212 const point& cc = faceCentres[facei];
214 const face&
f = faces[facei];
218 scalar maxLenSqr = -GREAT;
221 scalar maxCmpt = -GREAT;
226 maxLenSqr =
max(maxLenSqr,
magSqr(pt - cc));
249 scalar minDistSqr = GREAT;
255 if (distSqr < minDistSqr)
257 minDistSqr = distSqr;
262 if (anchorFp == -1 ||
Foam::sqrt(minDistSqr) > tol)
273 if (distSqr == minDistSqr && fp != anchorFp)
276 <<
"Cannot determine unique anchor point on face "
279 <<
"Both at index " << anchorFp <<
" and " << fp
280 <<
" the vertices have the same distance "
282 <<
" to the anchor " << anchor
283 <<
". Continuing but results might be wrong."
289 return (
f.size() - anchorFp) %
f.size();
307 Pout<<
"coupledPolyPatch::calcTransformTensors : " <<
name() <<
endl
308 <<
" transform:" << transformTypeNames[
transform] <<
nl
309 <<
" (half)size:" << Cf.size() <<
nl
310 <<
" absTol:" << absTol <<
nl
311 <<
" smallDist min:" <<
min(smallDist) <<
nl
312 <<
" smallDist max:" <<
max(smallDist) <<
nl
313 <<
" sum(mag(nf & nr)):" <<
sum(
mag(nf & nr)) <<
endl;
357 forwardT_.setSize(Cf.size());
358 reverseT_.setSize(Cf.size());
359 collocated_.setSize(Cf.size());
370 Pout<<
" sum(mag(forwardT_ - forwardT_[0])):"
371 <<
sum(
mag(forwardT_ - forwardT_[0]))
377 forwardT_.setSize(1);
378 reverseT_.setSize(1);
379 collocated_.setSize(1);
383 Pout<<
" difference in rotation less than"
384 <<
" local tolerance "
385 <<
error <<
". Assuming uniform rotation." <<
endl;
396 separation_ = Cr - Cf;
398 collocated_.setSize(separation_.size());
406 bool sameSeparation =
true;
407 bool doneWarning =
false;
409 forAll(separation_, facei)
411 scalar smallSqr =
sqr(smallDist[facei]);
413 collocated_[facei] = (
magSqr(separation_[facei]) < smallSqr);
416 if (
magSqr(separation_[facei] - separation_[0]) > smallSqr)
418 sameSeparation =
false;
420 if (!doneWarning &&
debug)
424 Pout<<
" separation " << separation_[facei]
426 <<
" differs from separation[0] " << separation_[0]
427 <<
" by more than local tolerance "
429 <<
". Assuming non-uniform separation." <<
endl;
441 Pout<<
" separation " <<
mag(separation_[0])
442 <<
" less than local tolerance " << smallDist[0]
443 <<
". Assuming zero separation." <<
endl;
453 Pout<<
" separation " <<
mag(separation_[0])
454 <<
" more than local tolerance " << smallDist[0]
455 <<
". Assuming uniform separation." <<
endl;
458 separation_.setSize(1);
467 Pout<<
" separation_:" << separation_.size() <<
nl
468 <<
" forwardT size:" << forwardT_.size() <<
endl;
481 const polyBoundaryMesh& bm,
482 const word& patchType,
487 matchTolerance_(defaultMatchTol_),
498 const word& patchType
502 matchTolerance_(
dict.getOrDefault(
"matchTolerance", defaultMatchTol_)),
505 transformTypeNames.getOrDefault
522 matchTolerance_(
pp.matchTolerance_),
523 transform_(
pp.transform_)
534 matchTolerance_(
pp.matchTolerance_),
535 transform_(
pp.transform_)
549 matchTolerance_(
pp.matchTolerance_),
550 transform_(
pp.transform_)
564 matchTolerance_(
pp.matchTolerance_),
565 transform_(
pp.transform_)
582 os.writeEntry(
"matchTolerance", matchTolerance_);
583 os.writeEntry(
"transform", transformTypeNames[transform_]);
Various functions to operate on Lists.
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
bool insert(const Key &key, const T &obj)
Copy insert a new entry, not overwriting existing entries.
void setSize(label n)
Alias for resize().
A HashTable to objects of type <T> with a label key.
Output to file stream as an OSstream, normally using std::ofstream for the actual output.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
const Field< point_type > & points() const noexcept
A List with indirect addressing. Like IndirectList but does not store addressing.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
void size(const label n)
Older name for setAddressableSize.
const Cmpt & x() const noexcept
Access to the vector x component.
const Cmpt & z() const noexcept
Access to the vector z component.
const Cmpt & y() const noexcept
Access to the vector y component.
The coupledPolyPatch is an abstract base class for patches that couple regions of the computational d...
virtual transformType transform() const
Type of transform.
virtual void write(Ostream &os) const
Write the polyPatch data as a dictionary.
static const Enum< transformType > transformTypeNames
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.
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.
static scalarField calcFaceTol(const UList< face > &faces, const pointField &points, const pointField &faceCentres)
Calculate typical tolerance per face. Is currently max distance.
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.
static pointField getAnchorPoints(const UList< face > &, const pointField &, const transformType)
Get a unique anchor point for all faces.
virtual ~coupledPolyPatch()
Destructor.
static void writeOBJ(Ostream &os, const point &pt)
Write point in OBJ format.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Class to handle errors and exceptions in a simple, consistent stream-based manner.
Smooth ATC in cells next to a set of patches supplied by type.
A face is a list of labels corresponding to mesh vertices.
A class for handling file names.
label index() const noexcept
The index of this patch in the boundaryMesh.
A polyBoundaryMesh is a polyPatch list with registered IO, a reference to the associated polyMesh,...
A patch is a list of labels that address the faces in the global face list.
friend class polyBoundaryMesh
const faceList::subList faces() const
Return mesh faces for the patch.
virtual void write(Ostream &os) const
Write the polyPatch data as a dictionary.
const vectorField::subField faceCentres() const
Return face centres.
polyPatch(const word &name, const label size, const label start, const label index, const polyBoundaryMesh &bm, const word &patchType)
Construct from components.
label start() const noexcept
Return start label of this patch in the polyMesh face list.
const labelUList & faceCells() const
Return face-cell addressing.
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
const volScalarField & p0
OBJstream os(runTime.globalPath()/outputName)
#define WarningInFunction
Report a warning using Foam::Warning.
Namespace for handling debugging switches.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
List< label > labelList
A List of labels.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
tensor rotationTensor(const vector &n1, const vector &n2)
Rotational transformation tensor from vector n1 to n2.
refinementData transform(const tensor &, const refinementData val)
No-op rotational transform for base types.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensionedScalar sqrt(const dimensionedScalar &ds)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Field< vector > vectorField
Specialisation of Field<T> for vector.
vector point
Point is a vector.
List< bool > boolList
A List of bools.
void cmptMax(FieldField< Field, typename FieldField< Field, Type >::cmptType > &cf, const FieldField< Field, Type > &f)
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &f1, const label comm)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
void cmptMag(FieldField< Field, Type > &cf, const FieldField< Field, Type > &f)
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
vectorField pointField
pointField is a vectorField.
UList< label > labelUList
A UList of labels.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
constexpr char nl
The newline '\n' character (0x0a).
labelList pointLabels(nPoints, -1)
#define forAll(list, i)
Loop across all elements in list.