37 Type
sum(
const Type&
x,
const bool global)
51 const Type
s =
sum(
x(), global);
81 void Foam::cyclicTransform::update()
83 if (!transformComplete_)
88 switch (transformType_)
94 transform_ = transformer();
98 if (rotationAngle_ == 0)
100 transform_ = transformer();
105 quaternion(rotationAxis_, rotationAngle_).R();
107 if (
mag(rotationCentre_) == 0)
122 if (
mag(separation_) == 0)
124 transform_ = transformer();
135 bool Foam::cyclicTransform::set
137 const cyclicTransform& t,
138 const scalar lengthScale,
139 const scalar matchTolerance
143 if (t.transformType_ == UNSPECIFIED)
150 if (transformType_ != UNSPECIFIED)
153 if (transformType_ != t.transformType_)
159 const scalar lengthTolerance = lengthScale*matchTolerance;
164 if (transformType_ == ROTATIONAL)
166 const scalar
dot = rotationAxis_ & t.rotationAxis_;
168 if (
mag(
dot) < 1 - matchTolerance)
175 (rotationAxis_ & (rotationCentre_ - t.rotationCentre_))
182 if (transformComplete_ && t.transformComplete_)
186 mag(rotationAngle_ -
sign(
dot)*t.rotationAngle_)
197 if (transformType_ == TRANSLATIONAL)
199 if (transformComplete_ && t.transformComplete_)
201 if (
mag(separation_ - t.separation_) > lengthTolerance)
210 if (!transformComplete_ && t.transformComplete_)
229 const bool defaultIsNone
232 transformType_(defaultIsNone ? NONE : UNSPECIFIED),
233 rotationAxis_(
vector::uniform(NaN)),
234 rotationCentre_(
vector::uniform(NaN)),
236 separation_(
vector::uniform(NaN)),
237 transformComplete_(transformType_ == NONE),
245 const bool defaultIsNone
252 dict.lookupOrDefaultBackwardsCompatible<
word>
254 {
"transformType",
"transform"},
255 transformTypeNames[defaultIsNone ? NONE : UNSPECIFIED]
261 transformType_ == ROTATIONAL
267 transformType_ == ROTATIONAL
277 transformType_ == TRANSLATIONAL
281 {
"separation",
"separationVector"}
288 transformType_ == NONE
290 transformType_ == ROTATIONAL
294 transformType_ == TRANSLATIONAL
300 if (transformComplete_)
314 const scalar matchTolerance,
324 const scalar lengthScale =
sqrt(
mag(area));
327 if (!transformComplete_ && nbrTransform.transformType_ !=
UNSPECIFIED)
329 if (!set(
inv(nbrTransform), lengthScale, matchTolerance))
333 <<
" and neighbour patch " << nbrName
371 const scalar matchTolerance,
387 if (
sum(areas.
size(), global) == 0 ||
sum(nbrAreas.
size(), global) == 0)
394 const vector nbrArea =
sum(nbrAreas, global);
399 const scalar sumMagAreas =
sum(magAreas, global);
400 const scalar sumMagNbrAreas =
sum(magNbrAreas, global);
401 const point ctr =
sum(ctrs*magAreas, global)/sumMagAreas;
402 const point nbrCtr =
sum(nbrCtrs*magNbrAreas, global)/sumMagNbrAreas;
405 const scalar lengthScale =
sqrt(sumMagAreas);
408 if (!transformComplete_)
418 const scalar
dot = normal & negNbrNormal;
427 :
mag(
delta) > lengthScale*rootSmall
439 if (transformType_ != oldTransformType)
445 normal*(negNbrNormal & midNormal)
446 - negNbrNormal*(normal & midNormal)
450 ^ (normal - negNbrNormal);
455 mag(axis) > lengthScale*rootSmall
465 acos(
min(
max(normalPerpA & negNbrNormalPerpA, -1), 1));
467 -
sign((normalPerpA ^ negNbrNormalPerpA) & rotationAxis_)*theta;
471 if (transformType_ != oldTransformType)
482 rotationCentre_ =
inv(
A) &
b;
494 transformComplete_ =
true;
500 Info<<
"Transformation calculated between patches " <<
name
511 const point nbrCtrT =
514 const scalar ctrNbrCtrTDistance =
mag(ctr - nbrCtrT);
516 if (ctrNbrCtrTDistance > lengthScale*matchTolerance)
519 str <<
"Patches " <<
name <<
" and " << nbrName <<
" are potentially "
520 <<
"not geometrically similar enough to be coupled." <<
nl <<
nl
521 <<
"The distance between the transformed centres of these patches "
522 <<
"is " << ctrNbrCtrTDistance <<
", which is greater than the "
523 <<
"patch length scale (" << lengthScale <<
") multiplied by the "
524 <<
"match tolerance (" << matchTolerance <<
")." <<
nl <<
nl
525 <<
"Check that the patches are geometrically similar and that any "
526 <<
"transformations defined between them are correct." <<
nl <<
nl
527 <<
"If the patches and their transformations are defined correctly "
528 <<
"but small irregularities in the mesh mean this geometric test "
529 <<
"is failing, then it might be appropriate to relax the failure "
530 <<
"criteria by increasing the \"matchTolerance\" setting for "
531 <<
"these patches in the \"polyMesh/boundary\" file.";
553 if (transformType_ != UNSPECIFIED)
555 writeEntry(os,
"transformType", transformTypeNames[transformType_]);
558 if (transformType_ == ROTATIONAL)
560 writeEntry(os,
"rotationAxis", rotationAxis_);
561 writeEntry(os,
"rotationCentre", rotationCentre_);
563 if (transformComplete_)
569 if (transformType_ == TRANSLATIONAL)
571 if (transformComplete_)
594 c1.rotationCentre_ = t.transformPosition(
c1.rotationCentre_);
599 if (
c1.transformComplete_)
601 c1.separation_ = t.transform(
c1.separation_);
605 if (
c1.transformComplete_)
620 if (
c1.transformComplete_)
622 c1.rotationAngle_ = -
c1.rotationAngle_;
628 if (
c1.transformComplete_)
630 c1.separation_ = -
c1.separation_;
634 if (
c1.transformComplete_)
static const Foam::dimensionedScalar A("A", Foam::dimPressure, 611.21)
Istream and Ostream manipulators taking arguments.
#define forAll(list, i)
Loop across all elements in list.
Pre-declare SubField and related Field type.
void size(const label)
Override size to be inconsistent with allocated storage.
Initialise the NamedEnum HashTable from the static list of names.
Output to memory buffer stream.
string str() const
Return the string.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
virtual int precision() const =0
Get precision of output field.
static Form uniform(const Cmpt &s)
Return a VectorSpace with all elements = s.
A list of keyword definitions, which are a keyword followed by any number of values (e....
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T, if not found return the given default.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
ITstream & lookupBackwardsCompatible(const wordList &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream, trying a list of keywords.
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Quaternion class used to perform rotations in 3D space.
tensor R() const
The rotation tensor corresponding the quaternion.
A class for managing temporary objects.
A class for handling words, derived from string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.name(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
const dimensionedScalar c1
First radiation constant: default SI units: [W/m^2].
string breakIntoIndentedLines(const string &str, const string::size_type nLength=80, const string::size_type nIndent=0)
Break a string up into indented lines.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Type gSum(const FieldField< Field, Type > &f)
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
dimensionedScalar sign(const dimensionedScalar &ds)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Tensor< scalar > tensor
Tensor of scalars.
label findMax(const ListType &, const label start=0)
Find index of max element (and larger than given element).
Ostream & endl(Ostream &os)
Add newline and flush stream.
word name(const bool)
Return a word representation of a bool.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
Ostream & incrIndent(Ostream &os)
Increment the indent level.
void dot(FieldField< Field1, typename innerProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
dimensionedScalar sqrt(const dimensionedScalar &ds)
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
dimensionSet transform(const dimensionSet &)
dimensionSet normalised(const dimensionSet &)
dimensioned< scalar > mag(const dimensioned< Type > &)
defineTypeNameAndDebug(combustionModel, 0)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
static scalar R(const scalar a, const scalar x)
dimensionSet cmptMag(const dimensionSet &)
dimensionedSphericalTensor inv(const dimensionedSphericalTensor &dt)
Ostream & indent(Ostream &os)
Indent stream.
const unitConversion unitDegrees
dimensionedScalar acos(const dimensionedScalar &ds)