52 void Foam::cyclicTransform::update()
54 if (!transformComplete_)
59 switch (transformType_)
69 if (rotationAngle_ == 0)
78 if (
mag(rotationCentre_) == 0)
93 if (
mag(separation_) == 0)
106 bool Foam::cyclicTransform::set
109 const scalar lengthScale,
110 const scalar matchTolerance
114 if (t.transformType_ == UNSPECIFIED)
121 if (transformType_ != UNSPECIFIED)
124 if (transformType_ != t.transformType_)
130 const scalar lengthTolerance = lengthScale*matchTolerance;
135 if (transformType_ == ROTATIONAL)
137 const scalar
dot = rotationAxis_ & t.rotationAxis_;
139 if (
mag(dot) < 1 - matchTolerance)
146 (rotationAxis_ & (rotationCentre_ - t.rotationCentre_))
153 if (transformComplete_ && t.transformComplete_)
168 if (transformType_ == TRANSLATIONAL)
170 if (transformComplete_ && t.transformComplete_)
172 if (
mag(separation_ - t.separation_) > lengthTolerance)
181 if (!transformComplete_ && t.transformComplete_)
194 const bool defaultIsNone
197 transformType_(defaultIsNone ? NONE : UNSPECIFIED),
202 transformComplete_(transformType_ == NONE),
210 const bool defaultIsNone
218 dict.
found(
"transformType")
219 ? transformTypeNames.read(dict.
lookup(
"transformType"))
220 : dict.
found(
"transform")
221 ? transformTypeNames.read(dict.
lookup(
"transform"))
222 : (defaultIsNone ? NONE : UNSPECIFIED)
226 transformType_ == ROTATIONAL
232 transformType_ == ROTATIONAL
239 transformType_ == TRANSLATIONAL
244 dict.
found(
"separation")
246 : dict.
found(
"separationVector")
254 transformType_ == NONE
256 transformType_ == ROTATIONAL
257 && dict.
found(
"rotationAngle")
260 transformType_ == TRANSLATIONAL
261 && (dict.
found(
"separation") || dict.
found(
"separationVector"))
266 if (transformComplete_)
280 const scalar matchTolerance
289 const scalar lengthScale =
sqrt(
mag(area));
292 if (!transformComplete_ && nbrTransform.transformType_ != UNSPECIFIED)
294 if (!
set(
inv(nbrTransform), lengthScale, matchTolerance))
298 <<
" and neighbour patch " << nbrName
336 const scalar matchTolerance
351 if (areas.
size() == 0 || nbrAreas.
size() == 0)
return;
360 const point ctr =
sum(ctrs*magAreas)/
sum(magAreas);
361 const point nbrCtr =
sum(nbrCtrs*magNbrAreas)/
sum(magNbrAreas);
364 const scalar lengthScale =
sqrt(
sum(magAreas));
367 if (!transformComplete_)
377 const scalar
dot = normal & negNbrNormal;
381 if (transformType_ == UNSPECIFIED)
386 :
mag(delta) > lengthScale*rootSmall
395 if (transformType_ == ROTATIONAL)
398 if (transformType_ != oldTransformType)
404 normal*(negNbrNormal & midNormal)
405 - negNbrNormal*(normal & midNormal)
409 ^ (normal - negNbrNormal);
414 mag(axis) > lengthScale*rootSmall
425 acos(
min(
max(normalPerpA & negNbrNormalPerpA, -1), 1));
427 -
sign((normalPerpA ^ negNbrNormalPerpA) & rotationAxis_)
431 if (transformType_ != oldTransformType)
442 rotationCentre_ =
inv(A) &
b;
448 if (transformType_ == TRANSLATIONAL)
454 transformComplete_ =
true;
460 Info<<
"Transformation calculated between patches " << name
471 const point nbrCtrT =
472 transform_.transformPosition(nbrCtr);
474 const scalar ctrNbrCtrTDistance =
mag(ctr - nbrCtrT);
476 if (ctrNbrCtrTDistance > lengthScale*matchTolerance)
479 <<
"The distance between the centre of patch " << name
480 <<
" and the transformed centre of patch " << nbrName <<
" is " 481 << ctrNbrCtrTDistance <<
"." 483 <<
"This is greater than the match tolerance of " 484 << lengthScale*matchTolerance <<
" for the patch." 486 <<
"Check that the patches are geometrically similar and that any " 487 <<
"transformations defined between them are correct" 489 <<
"It might be possible to fix this problem by increasing the " 490 <<
"\"matchTolerance\" setting for this patch in the boundary " 510 if (transformType_ != UNSPECIFIED)
512 writeEntry(os,
"transformType", transformTypeNames[transformType_]);
515 if (transformType_ == ROTATIONAL)
517 writeEntry(os,
"rotationAxis", rotationAxis_);
518 writeEntry(os,
"rotationCentre", rotationCentre_);
520 if (transformComplete_)
522 writeEntry(os,
"rotationAngle", rotationAngle_);
526 if (transformType_ == TRANSLATIONAL)
528 if (transformComplete_)
550 c1.rotationAxis_ =
normalised(t.transform(c1.rotationAxis_));
551 c1.rotationCentre_ = t.transformPosition(c1.rotationCentre_);
556 if (c1.transformComplete_)
558 c1.separation_ = t.transform(c1.separation_);
562 if (c1.transformComplete_)
577 if (c1.transformComplete_)
579 c1.rotationAngle_ = - c1.rotationAngle_;
585 if (c1.transformComplete_)
587 c1.separation_ = - c1.separation_;
591 if (c1.transformComplete_)
dimensionedScalar sign(const dimensionedScalar &ds)
dimensionedScalar acos(const dimensionedScalar &ds)
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.
tensor R() const
The rotation tensor corresponding the quaternion.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
scalar radToDeg(const scalar rad)
Conversion from radians to degrees.
Ostream & indent(Ostream &os)
Indent stream.
errorManipArg< error, int > exit(error &err, const int errNo=1)
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 dimensionedScalar & c1
First radiation constant: default SI units: [W/m^2].
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Unit conversion functions.
dimensionedSphericalTensor inv(const dimensionedSphericalTensor &dt)
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.
Initialise the NamedEnum HashTable from the static list of names.
scalar degToRad(const scalar deg)
Conversion from degrees to radians.
void dot(FieldField< Field1, typename innerProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
Form normalised(const VectorSpace< Form, Cmpt, Ncmpts > &vs)
const dimensionedScalar & b
Wien displacement law constant: default SI units: [m K].
A class for handling words, derived from string.
Quaternion class used to perform rotations in 3D space.
label findMax(const ListType &, const label start=0)
Find index of max element (and larger than given element).
void cmptMag(FieldField< Field, Type > &cf, const FieldField< Field, Type > &f)
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Istream and Ostream manipulators taking arguments.
defineTypeNameAndDebug(combustionModel, 0)
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
#define R(A, B, C, D, E, F, K, M)
static Vector< scalar > uniform(const scalar &s)
Return a VectorSpace with all elements = s.
dimensioned< scalar > mag(const dimensioned< Type > &)
Ostream & incrIndent(Ostream &os)
Increment the indent level.
virtual int precision() const =0
Get precision of output field.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.