coordinateSystems/coordinateRotation/cylindrical: Simplified use of R
This commit is contained in:
@ -161,17 +161,20 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
//- Transform vector using transformation tensor
|
||||
virtual vector transform(const vector& st) const = 0;
|
||||
|
||||
//- Transform vectorField using transformation tensor field
|
||||
virtual tmp<vectorField> transform(const vectorField& st) const = 0;
|
||||
|
||||
//- Transform vector using transformation tensor
|
||||
virtual vector transform(const vector& st) const = 0;
|
||||
//- Inverse transform vector using transformation tensor
|
||||
virtual vector invTransform(const vector& st) const = 0;
|
||||
|
||||
//- Inverse transform vectorField using transformation tensor field
|
||||
virtual tmp<vectorField> invTransform(const vectorField& st) const = 0;
|
||||
|
||||
//- Inverse transform vector using transformation tensor
|
||||
virtual vector invTransform(const vector& st) const = 0;
|
||||
//- Transform tensor using transformation tensorField
|
||||
virtual tensor transformTensor(const tensor& st) const = 0;
|
||||
|
||||
//- Transform tensor field using transformation tensorField
|
||||
virtual tmp<tensorField> transformTensor
|
||||
@ -179,26 +182,22 @@ public:
|
||||
const tensorField& st
|
||||
) const = 0;
|
||||
|
||||
//- Transform tensor using transformation tensorField
|
||||
virtual tensor transformTensor(const tensor& st) const = 0;
|
||||
//- Transform vector using transformation tensor and return
|
||||
// symmetrical tensor
|
||||
virtual symmTensor transformVector(const vector& st) const = 0;
|
||||
|
||||
//- Transform vectorField using transformation tensorField and return
|
||||
// symmetrical tensorField
|
||||
// symmetrical tensorField
|
||||
virtual tmp<symmTensorField> transformVector
|
||||
(
|
||||
const vectorField& st
|
||||
) const = 0;
|
||||
|
||||
//- Transform vector using transformation tensor and return
|
||||
// symmetrical tensor
|
||||
virtual symmTensor transformVector(const vector& st) const = 0;
|
||||
|
||||
|
||||
// Write
|
||||
|
||||
//- Write
|
||||
virtual void write(Ostream&) const = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -40,20 +40,25 @@ namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||
|
||||
Foam::tensor Foam::cylindrical::R(const vector& dir) const
|
||||
Foam::tensor Foam::cylindrical::R(const vector& p) const
|
||||
{
|
||||
const vector e3 = e3_/mag(e3_);
|
||||
const vector r = dir - (dir & e3)*e3;
|
||||
vector dir = p - origin_;
|
||||
dir /= mag(dir) + vSmall;
|
||||
|
||||
const vector axis = axis_/mag(axis_);
|
||||
const vector r = dir - (dir & axis)*axis;
|
||||
|
||||
if (mag(r) < small)
|
||||
{
|
||||
// If the point is on the axis choose any radial direction
|
||||
return axesRotation(e3, perpendicular(e3)).R();
|
||||
return axesRotation(axis, perpendicular(axis)).R();
|
||||
}
|
||||
else
|
||||
{
|
||||
return axesRotation(e3, dir).R();
|
||||
return axesRotation(axis, dir).R();
|
||||
}
|
||||
|
||||
return tensor(r, axis^r, axis);
|
||||
}
|
||||
|
||||
|
||||
@ -64,10 +69,7 @@ void Foam::cylindrical::init(const UList<vector>& points)
|
||||
|
||||
forAll(points, i)
|
||||
{
|
||||
vector dir = points[i] - origin_;
|
||||
dir /= mag(dir) + vSmall;
|
||||
|
||||
R[i] = this->R(dir);
|
||||
R[i] = this->R(points[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -83,7 +85,7 @@ Foam::cylindrical::cylindrical
|
||||
:
|
||||
Rptr_(),
|
||||
origin_(origin),
|
||||
e3_(axis)
|
||||
axis_(axis)
|
||||
{
|
||||
init(points);
|
||||
}
|
||||
@ -92,17 +94,19 @@ Foam::cylindrical::cylindrical
|
||||
Foam::cylindrical::cylindrical(const dictionary& dict)
|
||||
:
|
||||
Rptr_(),
|
||||
origin_(),
|
||||
e3_()
|
||||
origin_
|
||||
(
|
||||
dict.parent().found("origin")
|
||||
? dict.parent().lookup("origin")
|
||||
: dict.lookup("origin")
|
||||
),
|
||||
axis_
|
||||
(
|
||||
dict.found("e3")
|
||||
? dict.lookup("e3")
|
||||
: dict.lookup("axis")
|
||||
)
|
||||
{
|
||||
// If origin is specified in the coordinateSystem
|
||||
if (dict.parent().found("origin"))
|
||||
{
|
||||
dict.parent().lookup("origin") >> origin_;
|
||||
}
|
||||
|
||||
// Rotation axis
|
||||
dict.lookup("e3") >> e3_;
|
||||
}
|
||||
|
||||
|
||||
@ -135,10 +139,7 @@ void Foam::cylindrical::updatePoints(const UList<vector>& points)
|
||||
|
||||
forAll(points, i)
|
||||
{
|
||||
vector dir = points[i] - origin_;
|
||||
dir /= mag(dir) + vSmall;
|
||||
|
||||
R[i] = this->R(dir);
|
||||
R[i] = this->R(points[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -270,7 +271,7 @@ Foam::symmTensor Foam::cylindrical::transformVector
|
||||
|
||||
void Foam::cylindrical::write(Ostream& os) const
|
||||
{
|
||||
writeEntry(os, "e3", e3());
|
||||
writeEntry(os, "axis", axis());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -28,15 +28,15 @@ Description
|
||||
A local coordinate rotation.
|
||||
|
||||
The rotational field can be created in two ways:
|
||||
-# Each rotational tensor is defined with two vectors (\c dir and \c e3)
|
||||
where <tt>dir = point - origin</tt> and \c e3 is the rotation axis.
|
||||
-# Each rotational tensor is defined with two vectors (\c dir and \c axis)
|
||||
where <tt>dir = point - origin</tt> and \c axis is the rotation axis.
|
||||
Per each point an axesRotation type of rotation is created
|
||||
(cylindrical coordinates). For example:
|
||||
\verbatim
|
||||
cylindrical
|
||||
{
|
||||
type localAxes;
|
||||
e3 (0 0 1);
|
||||
axis (0 0 1);
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
@ -76,14 +76,14 @@ class cylindrical
|
||||
point origin_;
|
||||
|
||||
//- Rotation axis
|
||||
vector e3_;
|
||||
vector axis_;
|
||||
|
||||
|
||||
// Private members
|
||||
|
||||
//- Return the local transformation tensor
|
||||
// corresponding to the given vector
|
||||
tensor R(const vector& dir) const;
|
||||
// corresponding to the given point
|
||||
tensor R(const vector& p) const;
|
||||
|
||||
//- Initialise transformation tensor field for given points
|
||||
void init(const UList<vector>& points);
|
||||
@ -151,26 +151,14 @@ public:
|
||||
//- Return local Cartesian z-axis in global coordinates
|
||||
virtual const vector e3() const
|
||||
{
|
||||
return e3_;
|
||||
return axis_;
|
||||
}
|
||||
|
||||
//- Transform vectorField using transformation tensor field
|
||||
virtual tmp<vectorField> transform(const vectorField& tf) const;
|
||||
|
||||
//- Transform vector using transformation tensor
|
||||
virtual vector transform(const vector& v) const;
|
||||
|
||||
//- Transform vector using transformation tensor for component
|
||||
virtual vector transform(const vector& v, const label cmptI) const;
|
||||
|
||||
//- Inverse transform vectorField using transformation tensor field
|
||||
virtual tmp<vectorField> invTransform(const vectorField& vf) const;
|
||||
|
||||
//- Inverse transform vector using transformation tensor
|
||||
virtual vector invTransform(const vector& v) const;
|
||||
|
||||
//- Inverse transform vector using transformation tensor for component
|
||||
virtual vector invTransform(const vector& v, const label cmptI) const;
|
||||
//- Return local Cartesian z-axis in global coordinates
|
||||
virtual const vector axis() const
|
||||
{
|
||||
return axis_;
|
||||
}
|
||||
|
||||
//- Return if the rotation is uniform
|
||||
virtual bool uniform() const
|
||||
@ -178,23 +166,41 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
//- Transform tensor field using transformation tensorField
|
||||
virtual tmp<tensorField> transformTensor(const tensorField& tf) const;
|
||||
//- Transform vector using transformation tensor
|
||||
virtual vector transform(const vector& v) const;
|
||||
|
||||
//- Transform vectorField using transformation tensor field
|
||||
virtual tmp<vectorField> transform(const vectorField& tf) const;
|
||||
|
||||
//- Transform vector using transformation tensor for component
|
||||
virtual vector transform(const vector& v, const label cmptI) const;
|
||||
|
||||
//- Inverse transform vector using transformation tensor
|
||||
virtual vector invTransform(const vector& v) const;
|
||||
|
||||
//- Inverse transform vectorField using transformation tensor field
|
||||
virtual tmp<vectorField> invTransform(const vectorField& vf) const;
|
||||
|
||||
//- Inverse transform vector using transformation tensor for component
|
||||
virtual vector invTransform(const vector& v, const label cmptI) const;
|
||||
|
||||
//- Transform tensor using transformation tensorField
|
||||
virtual tensor transformTensor(const tensor& t) const;
|
||||
|
||||
//- Transform tensor field using transformation tensorField
|
||||
virtual tmp<tensorField> transformTensor(const tensorField& tf) const;
|
||||
|
||||
//- Transform vector using transformation tensor and return
|
||||
// symmetrical tensor
|
||||
virtual symmTensor transformVector(const vector& v) const;
|
||||
|
||||
//- Transform vectorField using transformation tensorField and return
|
||||
// symmetrical tensorField
|
||||
// symmetrical tensorField
|
||||
virtual tmp<symmTensorField> transformVector
|
||||
(
|
||||
const vectorField& vf
|
||||
) const;
|
||||
|
||||
//- Transform vector using transformation tensor and return
|
||||
// symmetrical tensor (R & st & R.T())
|
||||
virtual symmTensor transformVector(const vector& v) const;
|
||||
|
||||
|
||||
// Write
|
||||
|
||||
|
||||
Reference in New Issue
Block a user