37 Type
sum(
const Type&
x,
const bool global)
51 const Type
s =
sum(
x(), global);
89 void Foam::cyclicTransform::update()
91 if (!transformComplete_)
96 switch (transformType_)
102 transform_ = transformer();
106 if (rotationAngle_ == 0)
108 transform_ = transformer();
113 quaternion(rotationAxis_, rotationAngle_).R();
115 if (
mag(rotationCentre_) == 0)
130 if (
mag(separation_) == 0)
132 transform_ = transformer();
143 bool Foam::cyclicTransform::set
145 const cyclicTransform& t,
146 const scalar lengthScale,
147 const scalar matchTolerance
151 if (t.transformType_ == UNSPECIFIED)
158 if (transformType_ != UNSPECIFIED)
161 if (transformType_ != t.transformType_)
167 const scalar lengthTolerance = lengthScale*matchTolerance;
172 if (transformType_ == ROTATIONAL)
174 const scalar
dot = rotationAxis_ & t.rotationAxis_;
176 if (
mag(
dot) < 1 - matchTolerance)
183 (rotationAxis_ & (rotationCentre_ - t.rotationCentre_))
190 if (transformComplete_ && t.transformComplete_)
194 mag(rotationAngle_ -
sign(
dot)*t.rotationAngle_)
205 if (transformType_ == TRANSLATIONAL)
207 if (transformComplete_ && t.transformComplete_)
209 if (
mag(separation_ - t.separation_) > lengthTolerance)
218 if (!transformComplete_ && t.transformComplete_)
237 const bool defaultIsNone
240 transformType_(defaultIsNone ? NONE : UNSPECIFIED),
241 rotationAxis_(
vector::uniform(NaN)),
242 rotationCentre_(
vector::uniform(NaN)),
244 separation_(
vector::uniform(NaN)),
245 transformComplete_(transformType_ == NONE),
253 const bool defaultIsNone
260 dict.lookupOrDefaultBackwardsCompatible<
word>
262 {
"transformType",
"transform"},
263 transformTypeNames[defaultIsNone ? NONE : UNSPECIFIED]
269 transformType_ == ROTATIONAL
275 transformType_ == ROTATIONAL
285 transformType_ == TRANSLATIONAL
289 {
"separation",
"separationVector"},
297 transformType_ == NONE
299 transformType_ == ROTATIONAL
303 transformType_ == TRANSLATIONAL
309 if (transformComplete_)
323 const scalar matchTolerance,
336 if (!transformComplete_ && nbrTransform.transformType_ !=
UNSPECIFIED)
338 if (!set(
inv(nbrTransform), lengthScale, matchTolerance))
342 <<
" and neighbour patch " << nbrName
380 const scalar matchTolerance,
396 if (
sum(areas.
size(), global) == 0 ||
sum(nbrAreas.
size(), global) == 0)
403 const vector nbrArea =
sum(nbrAreas, global);
408 const scalar sumMagAreas =
sum(magAreas, global);
409 const scalar sumMagNbrAreas =
sum(magNbrAreas, global);
410 const point ctr =
sum(ctrs*magAreas, global)/sumMagAreas;
411 const point nbrCtr =
sum(nbrCtrs*magNbrAreas, global)/sumMagNbrAreas;
414 const scalar lengthScale =
sqrt(sumMagAreas);
417 if (!transformComplete_)
427 const scalar
dot = normal & negNbrNormal;
436 :
mag(
delta) > lengthScale*rootSmall
448 if (transformType_ != oldTransformType)
454 normal*(negNbrNormal & midNormal)
455 - negNbrNormal*(normal & midNormal)
459 ^ (normal - negNbrNormal);
464 mag(axis) > lengthScale*rootSmall
474 acos(
min(
max(normalPerpA & negNbrNormalPerpA, -1), 1));
476 -
sign((normalPerpA ^ negNbrNormalPerpA) & rotationAxis_)*theta;
480 if (transformType_ != oldTransformType)
491 rotationCentre_ =
inv(
A) &
b;
503 transformComplete_ =
true;
509 Info<<
"Transformation calculated between patches " <<
name
520 const point nbrCtrT =
523 const scalar ctrNbrCtrTDistance =
mag(ctr - nbrCtrT);
525 if (ctrNbrCtrTDistance > lengthScale*matchTolerance)
528 str <<
"Patches " <<
name <<
" and " << nbrName <<
" are potentially "
529 <<
"not geometrically similar enough to be coupled." <<
nl <<
nl
530 <<
"The distance between the transformed centres of these patches "
531 <<
"is " << ctrNbrCtrTDistance <<
", which is greater than the "
532 <<
"patch length scale (" << lengthScale <<
") multiplied by the "
533 <<
"match tolerance (" << matchTolerance <<
")." <<
nl <<
nl
534 <<
"Check that the patches are geometrically similar and that any "
535 <<
"transformations defined between them are correct." <<
nl <<
nl
536 <<
"If the patches and their transformations are defined correctly "
537 <<
"but small irregularities in the mesh mean this geometric test "
538 <<
"is failing, then it might be appropriate to relax the failure "
539 <<
"criteria by increasing the \"matchTolerance\" setting for "
540 <<
"these patches in the \"polyMesh/boundary\" file.";
562 if (transformType_ != UNSPECIFIED)
564 writeEntry(os,
"transformType", transformTypeNames[transformType_]);
567 if (transformType_ == ROTATIONAL)
569 writeEntry(os,
"rotationAxis", rotationAxis_);
570 writeEntry(os,
"rotationCentre", rotationCentre_);
572 if (transformComplete_)
578 if (transformType_ == TRANSLATIONAL)
580 if (transformComplete_)
594 switch (transformType_)
604 oss <<
"axis=" << rotationAxis_
605 <<
", centre=" << rotationCentre_
608 if (transformComplete_)
622 oss <<
"separation=";
624 if (transformComplete_)
654 c1.rotationCentre_ = t.transformPosition(
c1.rotationCentre_);
659 if (
c1.transformComplete_)
661 c1.separation_ = t.transform(
c1.separation_);
665 if (
c1.transformComplete_)
680 if (
c1.transformComplete_)
682 c1.rotationAngle_ = -
c1.rotationAngle_;
688 if (
c1.transformComplete_)
690 c1.separation_ = -
c1.separation_;
694 if (
c1.transformComplete_)
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 keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
T lookupOrDefault(const word &, const T &) 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 handling character strings derived from std::string.
A class for managing temporary objects.
T toUser(const T &) const
Convert a value to user units.
A class for handling words, derived from string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.name(), lagrangian::cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
const dimensionedScalar c1
First radiation constant: default SI units: [W/m^2].
static const coefficient A("A", dimPressure, 611.21)
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)
const dimensionSet & dimless
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.
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.
void transform(GeometricField< Type, GeoMesh > &rtf, const GeometricField< tensor, GeoMesh > &trf, const GeometricField< Type, GeoMesh > &tf)
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Type gSum(const UList< Type > &f, const label comm)
tmp< DimensionedField< typename outerProduct< Type, Type >::type, GeoMesh, Field >> sqr(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
void inv(pointPatchField< tensor > &, const pointPatchField< tensor > &)
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
dimensionSet normalised(const dimensionSet &)
dimensioned< Type > min(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
static scalar R(const scalar a, const scalar x)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
tmp< DimensionedField< scalar, GeoMesh, Field > > mag(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
tmp< DimensionedField< Type, GeoMesh, Field > > cmptMag(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
void sqrt(LagrangianPatchField< scalar > &f, const LagrangianPatchField< scalar > &f1)
defineTypeNameAndDebug(atmosphericBoundaryLayer, 0)
Ostream & indent(Ostream &os)
Indent stream.
void writeEntry(Ostream &os, const word &key, const DimensionedFieldFunction< DimensionedFieldType > &f)
dimensionedScalar acos(const dimensionedScalar &ds)
dimensioned< Type > max(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
void dot(GeometricField< typename innerProduct< Type1, Type2 >::type, GeoMesh, PrimitiveField1 > &gf, const GeometricField< Type1, GeoMesh, PrimitiveField2 > &gf1, const GeometricField< Type2, GeoMesh, PrimitiveField3 > &gf2)