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"}
296 transformType_ == NONE
298 transformType_ == ROTATIONAL
302 transformType_ == TRANSLATIONAL
308 if (transformComplete_)
322 const scalar matchTolerance,
332 const scalar lengthScale =
sqrt(
mag(area));
335 if (!transformComplete_ && nbrTransform.transformType_ !=
UNSPECIFIED)
337 if (!set(
inv(nbrTransform), lengthScale, matchTolerance))
341 <<
" and neighbour patch " << nbrName
379 const scalar matchTolerance,
395 if (
sum(areas.
size(), global) == 0 ||
sum(nbrAreas.
size(), global) == 0)
402 const vector nbrArea =
sum(nbrAreas, global);
407 const scalar sumMagAreas =
sum(magAreas, global);
408 const scalar sumMagNbrAreas =
sum(magNbrAreas, global);
409 const point ctr =
sum(ctrs*magAreas, global)/sumMagAreas;
410 const point nbrCtr =
sum(nbrCtrs*magNbrAreas, global)/sumMagNbrAreas;
413 const scalar lengthScale =
sqrt(sumMagAreas);
416 if (!transformComplete_)
426 const scalar
dot = normal & negNbrNormal;
435 :
mag(
delta) > lengthScale*rootSmall
447 if (transformType_ != oldTransformType)
453 normal*(negNbrNormal & midNormal)
454 - negNbrNormal*(normal & midNormal)
458 ^ (normal - negNbrNormal);
463 mag(axis) > lengthScale*rootSmall
473 acos(
min(
max(normalPerpA & negNbrNormalPerpA, -1), 1));
475 -
sign((normalPerpA ^ negNbrNormalPerpA) & rotationAxis_)*theta;
479 if (transformType_ != oldTransformType)
490 rotationCentre_ =
inv(
A) &
b;
502 transformComplete_ =
true;
508 Info<<
"Transformation calculated between patches " <<
name
519 const point nbrCtrT =
522 const scalar ctrNbrCtrTDistance =
mag(ctr - nbrCtrT);
524 if (ctrNbrCtrTDistance > lengthScale*matchTolerance)
527 str <<
"Patches " <<
name <<
" and " << nbrName <<
" are potentially "
528 <<
"not geometrically similar enough to be coupled." <<
nl <<
nl
529 <<
"The distance between the transformed centres of these patches "
530 <<
"is " << ctrNbrCtrTDistance <<
", which is greater than the "
531 <<
"patch length scale (" << lengthScale <<
") multiplied by the "
532 <<
"match tolerance (" << matchTolerance <<
")." <<
nl <<
nl
533 <<
"Check that the patches are geometrically similar and that any "
534 <<
"transformations defined between them are correct." <<
nl <<
nl
535 <<
"If the patches and their transformations are defined correctly "
536 <<
"but small irregularities in the mesh mean this geometric test "
537 <<
"is failing, then it might be appropriate to relax the failure "
538 <<
"criteria by increasing the \"matchTolerance\" setting for "
539 <<
"these patches in the \"polyMesh/boundary\" file.";
561 if (transformType_ != UNSPECIFIED)
563 writeEntry(os,
"transformType", transformTypeNames[transformType_]);
566 if (transformType_ == ROTATIONAL)
568 writeEntry(os,
"rotationAxis", rotationAxis_);
569 writeEntry(os,
"rotationCentre", rotationCentre_);
571 if (transformComplete_)
577 if (transformType_ == TRANSLATIONAL)
579 if (transformComplete_)
593 switch (transformType_)
603 oss <<
"axis=" << rotationAxis_
604 <<
", centre=" << rotationCentre_
607 if (transformComplete_)
621 oss <<
"separation=";
623 if (transformComplete_)
653 c1.rotationCentre_ = t.transformPosition(
c1.rotationCentre_);
658 if (
c1.transformComplete_)
660 c1.separation_ = t.transform(
c1.separation_);
664 if (
c1.transformComplete_)
679 if (
c1.transformComplete_)
681 c1.rotationAngle_ = -
c1.rotationAngle_;
687 if (
c1.transformComplete_)
689 c1.separation_ = -
c1.separation_;
693 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.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
T lookupOrDefault(const word &, const T &, const bool writeDefault=writeOptionalEntries > 0) const
Find and return a T, if not found return the given default.
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)
void dot(LagrangianPatchField< typename innerProduct< Type1, Type2 >::type > &f, const LagrangianPatchField< Type1 > &f1, const LagrangianPatchField< Type2 > &f2)
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.
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.
Ostream & incrIndent(Ostream &os)
Increment the indent level.
void mag(LagrangianPatchField< scalar > &f, const LagrangianPatchField< Type > &f1)
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
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 &)
defineTypeNameAndDebug(combustionModel, 0)
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
static scalar R(const scalar a, const scalar x)
void sqr(LagrangianPatchField< typename outerProduct< Type, Type >::type > &f, const LagrangianPatchField< Type > &f1)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
void inv(LagrangianPatchField< tensor > &f, const LagrangianPatchField< tensor > &f1)
void sqrt(LagrangianPatchField< scalar > &f, const LagrangianPatchField< scalar > &f1)
Ostream & indent(Ostream &os)
Indent stream.
void cmptMag(LagrangianPatchField< Type > &f, const LagrangianPatchField< Type > &f1)
const unitConversion unitDegrees
dimensionedScalar acos(const dimensionedScalar &ds)