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
219 {
"transformType",
"transform"},
220 transformTypeNames[defaultIsNone ? NONE : UNSPECIFIED]
226 transformType_ == ROTATIONAL
232 transformType_ == ROTATIONAL
239 transformType_ == TRANSLATIONAL
243 {
"separation",
"separationVector"}
250 transformType_ == NONE
252 transformType_ == ROTATIONAL
253 && dict.
found(
"rotationAngle")
256 transformType_ == TRANSLATIONAL
257 && (dict.
found(
"separation") || dict.
found(
"separationVector"))
262 if (transformComplete_)
276 const scalar matchTolerance
285 const scalar lengthScale =
sqrt(
mag(area));
288 if (!transformComplete_ && nbrTransform.transformType_ != UNSPECIFIED)
290 if (!
set(
inv(nbrTransform), lengthScale, matchTolerance))
294 <<
" and neighbour patch " << nbrName
332 const scalar matchTolerance
347 if (areas.
size() == 0 || nbrAreas.
size() == 0)
return;
356 const point ctr =
sum(ctrs*magAreas)/
sum(magAreas);
357 const point nbrCtr =
sum(nbrCtrs*magNbrAreas)/
sum(magNbrAreas);
360 const scalar lengthScale =
sqrt(
sum(magAreas));
363 if (!transformComplete_)
373 const scalar
dot = normal & negNbrNormal;
377 if (transformType_ == UNSPECIFIED)
382 :
mag(delta) > lengthScale*rootSmall
391 if (transformType_ == ROTATIONAL)
394 if (transformType_ != oldTransformType)
400 normal*(negNbrNormal & midNormal)
401 - negNbrNormal*(normal & midNormal)
405 ^ (normal - negNbrNormal);
410 mag(axis) > lengthScale*rootSmall
421 acos(
min(
max(normalPerpA & negNbrNormalPerpA, -1), 1));
423 -
sign((normalPerpA ^ negNbrNormalPerpA) & rotationAxis_)
427 if (transformType_ != oldTransformType)
438 rotationCentre_ =
inv(A) &
b;
444 if (transformType_ == TRANSLATIONAL)
450 transformComplete_ =
true;
456 Info<<
"Transformation calculated between patches " << name
467 const point nbrCtrT =
468 transform_.transformPosition(nbrCtr);
470 const scalar ctrNbrCtrTDistance =
mag(ctr - nbrCtrT);
472 if (ctrNbrCtrTDistance > lengthScale*matchTolerance)
475 <<
"The distance between the centre of patch " << name
476 <<
" and the transformed centre of patch " << nbrName <<
" is " 477 << ctrNbrCtrTDistance <<
"." 479 <<
"This is greater than the match tolerance of " 480 << lengthScale*matchTolerance <<
" for the patch." 482 <<
"Check that the patches are geometrically similar and that any " 483 <<
"transformations defined between them are correct" 485 <<
"It might be possible to fix this problem by increasing the " 486 <<
"\"matchTolerance\" setting for this patch in the boundary " 506 if (transformType_ != UNSPECIFIED)
508 writeEntry(os,
"transformType", transformTypeNames[transformType_]);
511 if (transformType_ == ROTATIONAL)
513 writeEntry(os,
"rotationAxis", rotationAxis_);
514 writeEntry(os,
"rotationCentre", rotationCentre_);
516 if (transformComplete_)
518 writeEntry(os,
"rotationAngle", rotationAngle_);
522 if (transformType_ == TRANSLATIONAL)
524 if (transformComplete_)
546 c1.rotationAxis_ =
normalised(t.transform(c1.rotationAxis_));
547 c1.rotationCentre_ = t.transformPosition(c1.rotationCentre_);
552 if (c1.transformComplete_)
554 c1.separation_ = t.transform(c1.separation_);
558 if (c1.transformComplete_)
573 if (c1.transformComplete_)
575 c1.rotationAngle_ = - c1.rotationAngle_;
581 if (c1.transformComplete_)
583 c1.separation_ = - c1.separation_;
587 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.
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.
const dimensionedScalar b
Wien displacement law constant: default SI units: [m K].
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)
const dimensionedScalar c1
First radiation constant: default SI units: [W/m^2].
T lookupOrDefaultBackwardsCompatible(const wordList &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T, trying a list of keywords in sequence.
Form normalised(const VectorSpace< Form, Cmpt, Ncmpts > &vs)
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.
ITstream & lookupBackwardsCompatible(const wordList &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream, trying a list of keywords.
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.