mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: localAxesRotation - added new consructor to operate on a list of cells
This commit is contained in:
@ -51,20 +51,41 @@ namespace Foam
|
|||||||
|
|
||||||
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::localAxesRotation::init(const objectRegistry& obr)
|
void Foam::localAxesRotation::init
|
||||||
|
(
|
||||||
|
const objectRegistry& obr,
|
||||||
|
const List<label>& cells
|
||||||
|
)
|
||||||
{
|
{
|
||||||
const polyMesh& mesh = refCast<const polyMesh>(obr);
|
const polyMesh& mesh = refCast<const polyMesh>(obr);
|
||||||
const vectorField& cc = mesh.cellCentres();
|
const vectorField& cc = mesh.cellCentres();
|
||||||
|
|
||||||
|
if (cells.size())
|
||||||
|
{
|
||||||
|
Rptr_.reset(new tensorField(cells.size()));
|
||||||
|
|
||||||
|
tensorField& R = Rptr_();
|
||||||
|
forAll(cells, i)
|
||||||
|
{
|
||||||
|
label cellI = cells[i];
|
||||||
|
vector dir = cc[cellI] - origin_;
|
||||||
|
dir /= mag(dir) + VSMALL;
|
||||||
|
|
||||||
|
R[i] = axesRotation(e3_, dir).R();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Rptr_.reset(new tensorField(mesh.nCells()));
|
||||||
|
|
||||||
tensorField& R = Rptr_();
|
tensorField& R = Rptr_();
|
||||||
forAll(cc, cellI)
|
forAll(cc, cellI)
|
||||||
{
|
{
|
||||||
vector dir = cc[cellI] - origin_;
|
vector dir = cc[cellI] - origin_;
|
||||||
dir /= mag(dir) + VSMALL;
|
dir /= mag(dir) + VSMALL;
|
||||||
|
|
||||||
const axesRotation ar(e3_, dir);
|
R[cellI] = axesRotation(e3_, dir).R();
|
||||||
|
}
|
||||||
R[cellI] = ar.R();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,13 +111,41 @@ Foam::localAxesRotation::localAxesRotation
|
|||||||
// rotation axis
|
// rotation axis
|
||||||
dict.lookup("e3") >> e3_;
|
dict.lookup("e3") >> e3_;
|
||||||
|
|
||||||
const polyMesh& mesh = refCast<const polyMesh>(obr);
|
|
||||||
|
|
||||||
Rptr_.reset(new tensorField(mesh.nCells()));
|
|
||||||
init(obr);
|
init(obr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::localAxesRotation::localAxesRotation
|
||||||
|
(
|
||||||
|
const objectRegistry& obr,
|
||||||
|
const vector& axis,
|
||||||
|
const point& origin
|
||||||
|
)
|
||||||
|
:
|
||||||
|
Rptr_(),
|
||||||
|
origin_(origin),
|
||||||
|
e3_(axis)
|
||||||
|
{
|
||||||
|
init(obr);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::localAxesRotation::localAxesRotation
|
||||||
|
(
|
||||||
|
const objectRegistry& obr,
|
||||||
|
const vector& axis,
|
||||||
|
const point& origin,
|
||||||
|
const List<label>& cells
|
||||||
|
)
|
||||||
|
:
|
||||||
|
Rptr_(),
|
||||||
|
origin_(origin),
|
||||||
|
e3_(axis)
|
||||||
|
{
|
||||||
|
init(obr, cells);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::localAxesRotation::localAxesRotation(const dictionary& dict)
|
Foam::localAxesRotation::localAxesRotation(const dictionary& dict)
|
||||||
:
|
:
|
||||||
Rptr_(),
|
Rptr_(),
|
||||||
@ -113,23 +162,6 @@ Foam::localAxesRotation::localAxesRotation(const dictionary& dict)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::localAxesRotation::localAxesRotation
|
|
||||||
(
|
|
||||||
const objectRegistry& obr,
|
|
||||||
const vector& axis,
|
|
||||||
const point& origin
|
|
||||||
)
|
|
||||||
:
|
|
||||||
Rptr_(),
|
|
||||||
origin_(origin),
|
|
||||||
e3_(axis)
|
|
||||||
{
|
|
||||||
const polyMesh& mesh = refCast<const polyMesh>(obr);
|
|
||||||
|
|
||||||
Rptr_.reset(new tensorField(mesh.nCells()));
|
|
||||||
init(obr);
|
|
||||||
}
|
|
||||||
|
|
||||||
Foam::localAxesRotation::localAxesRotation(const tensorField& R)
|
Foam::localAxesRotation::localAxesRotation(const tensorField& R)
|
||||||
:
|
:
|
||||||
Rptr_(),
|
Rptr_(),
|
||||||
@ -157,43 +189,26 @@ void Foam::localAxesRotation::updateCells
|
|||||||
const labelList& cells
|
const labelList& cells
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
const vectorField& cc = mesh.cellCentres();
|
||||||
|
tensorField& R = Rptr_();
|
||||||
|
|
||||||
forAll(cells, i)
|
forAll(cells, i)
|
||||||
{
|
{
|
||||||
label cellI = cells[i];
|
label cellI = cells[i];
|
||||||
vector dir = mesh.cellCentres()[cellI] - origin_;
|
vector dir = cc[cellI] - origin_;
|
||||||
dir /= mag(dir) + VSMALL;
|
dir /= mag(dir) + VSMALL;
|
||||||
|
|
||||||
Rptr_()[cellI] = axesRotation(e3_, dir).R();
|
R[cellI] = axesRotation(e3_, dir).R();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::vector Foam::localAxesRotation::transform(const vector& st) const
|
|
||||||
{
|
|
||||||
notImplemented
|
|
||||||
(
|
|
||||||
"vector localAxesRotation::transform(const vector&) const"
|
|
||||||
);
|
|
||||||
return vector::zero;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Foam::vector Foam::localAxesRotation::invTransform(const vector& st) const
|
|
||||||
{
|
|
||||||
notImplemented
|
|
||||||
(
|
|
||||||
"vector localAxesRotation::invTransform(const vector&) const"
|
|
||||||
);
|
|
||||||
return vector::zero;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Foam::tmp<Foam::vectorField> Foam::localAxesRotation::transform
|
Foam::tmp<Foam::vectorField> Foam::localAxesRotation::transform
|
||||||
(
|
(
|
||||||
const vectorField& st
|
const vectorField& vf
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
if (Rptr_->size() != st.size())
|
if (Rptr_->size() != vf.size())
|
||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
@ -203,25 +218,65 @@ Foam::tmp<Foam::vectorField> Foam::localAxesRotation::transform
|
|||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (Rptr_() & st);
|
return (Rptr_() & vf);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::vector Foam::localAxesRotation::transform(const vector& v) const
|
||||||
|
{
|
||||||
|
notImplemented
|
||||||
|
(
|
||||||
|
"vector localAxesRotation::transform(const vector&) const"
|
||||||
|
);
|
||||||
|
return vector::zero;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::vector Foam::localAxesRotation::transform
|
||||||
|
(
|
||||||
|
const vector& v,
|
||||||
|
const label cmptI
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
return (Rptr_()[cmptI] & v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::tmp<Foam::vectorField> Foam::localAxesRotation::invTransform
|
Foam::tmp<Foam::vectorField> Foam::localAxesRotation::invTransform
|
||||||
(
|
(
|
||||||
const vectorField& st
|
const vectorField& vf
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
return (Rptr_().T() & st);
|
return (Rptr_().T() & vf);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::vector Foam::localAxesRotation::invTransform(const vector& v) const
|
||||||
|
{
|
||||||
|
notImplemented
|
||||||
|
(
|
||||||
|
"vector localAxesRotation::invTransform(const vector&) const"
|
||||||
|
);
|
||||||
|
return vector::zero;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::vector Foam::localAxesRotation::invTransform
|
||||||
|
(
|
||||||
|
const vector& v,
|
||||||
|
const label cmptI
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
return (Rptr_()[cmptI].T() & v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::tmp<Foam::tensorField> Foam::localAxesRotation::transformTensor
|
Foam::tmp<Foam::tensorField> Foam::localAxesRotation::transformTensor
|
||||||
(
|
(
|
||||||
const tensorField& st
|
const tensorField& tf
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
if (Rptr_->size() != st.size())
|
if (Rptr_->size() != tf.size())
|
||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
@ -233,13 +288,13 @@ Foam::tmp<Foam::tensorField> Foam::localAxesRotation::transformTensor
|
|||||||
<< "tensorField st has different size to tensorField Tr"
|
<< "tensorField st has different size to tensorField Tr"
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
return (Rptr_() & st & Rptr_().T());
|
return (Rptr_() & tf & Rptr_().T());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::tensor Foam::localAxesRotation::transformTensor
|
Foam::tensor Foam::localAxesRotation::transformTensor
|
||||||
(
|
(
|
||||||
const tensor& st
|
const tensor& t
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
notImplemented
|
notImplemented
|
||||||
@ -253,21 +308,21 @@ Foam::tensor Foam::localAxesRotation::transformTensor
|
|||||||
|
|
||||||
Foam::tmp<Foam::tensorField> Foam::localAxesRotation::transformTensor
|
Foam::tmp<Foam::tensorField> Foam::localAxesRotation::transformTensor
|
||||||
(
|
(
|
||||||
const tensorField& st,
|
const tensorField& tf,
|
||||||
const labelList& cellMap
|
const labelList& cellMap
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
if (cellMap.size() != st.size())
|
if (cellMap.size() != tf.size())
|
||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
"tmp<tensorField> localAxesRotation::transformTensor"
|
"tmp<tensorField> localAxesRotation::transformTensor"
|
||||||
"("
|
"("
|
||||||
"const tensorField&"
|
"const tensorField&, "
|
||||||
"const labelList&"
|
"const labelList&"
|
||||||
")"
|
")"
|
||||||
)
|
)
|
||||||
<< "tensorField st has different size to tensorField Tr"
|
<< "tensorField tf has different size to tensorField Tr"
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,7 +333,7 @@ Foam::tmp<Foam::tensorField> Foam::localAxesRotation::transformTensor
|
|||||||
forAll(cellMap, i)
|
forAll(cellMap, i)
|
||||||
{
|
{
|
||||||
const label cellI = cellMap[i];
|
const label cellI = cellMap[i];
|
||||||
t[i] = R[cellI] & st[i] & Rtr[cellI];
|
t[i] = R[cellI] & tf[i] & Rtr[cellI];
|
||||||
}
|
}
|
||||||
|
|
||||||
return tt;
|
return tt;
|
||||||
@ -287,13 +342,13 @@ Foam::tmp<Foam::tensorField> Foam::localAxesRotation::transformTensor
|
|||||||
|
|
||||||
Foam::tmp<Foam::symmTensorField> Foam::localAxesRotation::transformVector
|
Foam::tmp<Foam::symmTensorField> Foam::localAxesRotation::transformVector
|
||||||
(
|
(
|
||||||
const vectorField& st
|
const vectorField& vf
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
if (Rptr_->size() != st.size())
|
if (Rptr_->size() != vf.size())
|
||||||
{
|
{
|
||||||
FatalErrorIn("localAxesRotation::transformVector(const vectorField&)")
|
FatalErrorIn("localAxesRotation::transformVector(const vectorField&)")
|
||||||
<< "tensorField st has different size to tensorField Tr"
|
<< "tensorField vf has different size to tensorField Tr"
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -303,7 +358,7 @@ Foam::tmp<Foam::symmTensorField> Foam::localAxesRotation::transformVector
|
|||||||
const tensorField& R = Rptr_();
|
const tensorField& R = Rptr_();
|
||||||
forAll(fld, i)
|
forAll(fld, i)
|
||||||
{
|
{
|
||||||
fld[i] = transformPrincipal(R[i], st[i]);
|
fld[i] = transformPrincipal(R[i], vf[i]);
|
||||||
}
|
}
|
||||||
return tfld;
|
return tfld;
|
||||||
}
|
}
|
||||||
@ -311,7 +366,7 @@ Foam::tmp<Foam::symmTensorField> Foam::localAxesRotation::transformVector
|
|||||||
|
|
||||||
Foam::symmTensor Foam::localAxesRotation::transformVector
|
Foam::symmTensor Foam::localAxesRotation::transformVector
|
||||||
(
|
(
|
||||||
const vector& st
|
const vector& v
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
notImplemented
|
notImplemented
|
||||||
|
|||||||
@ -80,7 +80,11 @@ class localAxesRotation
|
|||||||
// Private members
|
// Private members
|
||||||
|
|
||||||
//- Init transformation tensor field
|
//- Init transformation tensor field
|
||||||
void init(const objectRegistry& obr);
|
void init
|
||||||
|
(
|
||||||
|
const objectRegistry& obr,
|
||||||
|
const List<label>& cells = List<label>()
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -93,7 +97,7 @@ public:
|
|||||||
//- Construct from dictionary and objectRegistry
|
//- Construct from dictionary and objectRegistry
|
||||||
localAxesRotation(const dictionary&, const objectRegistry&);
|
localAxesRotation(const dictionary&, const objectRegistry&);
|
||||||
|
|
||||||
//- Construct from dictionary and objectRegistry
|
//- Construct from components for all cells
|
||||||
localAxesRotation
|
localAxesRotation
|
||||||
(
|
(
|
||||||
const objectRegistry&,
|
const objectRegistry&,
|
||||||
@ -101,6 +105,15 @@ public:
|
|||||||
const point& origin
|
const point& origin
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//- Construct from components for list of cells
|
||||||
|
localAxesRotation
|
||||||
|
(
|
||||||
|
const objectRegistry&,
|
||||||
|
const vector& axis,
|
||||||
|
const point& origin,
|
||||||
|
const List<label>& cells
|
||||||
|
);
|
||||||
|
|
||||||
//- Construct from dictionary
|
//- Construct from dictionary
|
||||||
localAxesRotation(const dictionary&);
|
localAxesRotation(const dictionary&);
|
||||||
|
|
||||||
@ -167,16 +180,22 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
//- Transform vectorField using transformation tensor field
|
//- Transform vectorField using transformation tensor field
|
||||||
virtual tmp<vectorField> transform(const vectorField& st) const;
|
virtual tmp<vectorField> transform(const vectorField& tf) const;
|
||||||
|
|
||||||
//- Transform vector using transformation tensor
|
//- Transform vector using transformation tensor
|
||||||
virtual vector transform(const vector& st) const;
|
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
|
//- Inverse transform vectorField using transformation tensor field
|
||||||
virtual tmp<vectorField> invTransform(const vectorField& st) const;
|
virtual tmp<vectorField> invTransform(const vectorField& vf) const;
|
||||||
|
|
||||||
//- Inverse transform vector using transformation tensor
|
//- Inverse transform vector using transformation tensor
|
||||||
virtual vector invTransform(const vector& st) const;
|
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 if the rotation is uniform
|
//- Return if the rotation is uniform
|
||||||
virtual bool uniform() const
|
virtual bool uniform() const
|
||||||
@ -185,15 +204,15 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
//- Transform tensor field using transformation tensorField
|
//- Transform tensor field using transformation tensorField
|
||||||
virtual tmp<tensorField> transformTensor(const tensorField& st) const;
|
virtual tmp<tensorField> transformTensor(const tensorField& tf) const;
|
||||||
|
|
||||||
//- Transform tensor using transformation tensorField
|
//- Transform tensor using transformation tensorField
|
||||||
virtual tensor transformTensor(const tensor& st) const;
|
virtual tensor transformTensor(const tensor& t) const;
|
||||||
|
|
||||||
//- Transform tensor sub-field using transformation tensorField
|
//- Transform tensor sub-field using transformation tensorField
|
||||||
virtual tmp<tensorField> transformTensor
|
virtual tmp<tensorField> transformTensor
|
||||||
(
|
(
|
||||||
const tensorField& st,
|
const tensorField& tf,
|
||||||
const labelList& cellMap
|
const labelList& cellMap
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
@ -201,19 +220,18 @@ public:
|
|||||||
// symmetrical tensorField
|
// symmetrical tensorField
|
||||||
virtual tmp<symmTensorField> transformVector
|
virtual tmp<symmTensorField> transformVector
|
||||||
(
|
(
|
||||||
const vectorField& st
|
const vectorField& vf
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Transform vector using transformation tensor and return
|
//- Transform vector using transformation tensor and return
|
||||||
// symmetrical tensor (R & st & R.T())
|
// symmetrical tensor (R & st & R.T())
|
||||||
virtual symmTensor transformVector(const vector& st) const;
|
virtual symmTensor transformVector(const vector& v) const;
|
||||||
|
|
||||||
|
|
||||||
// Write
|
// Write
|
||||||
|
|
||||||
//- Write
|
//- Write
|
||||||
virtual void write(Ostream&) const;
|
virtual void write(Ostream&) const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user