Bug fixing in vector transformation using localAxesRotation
Adding constructor for localAxesRotation class.
This commit is contained in:
sergio
2014-05-09 14:59:07 +01:00
committed by Andrew Heather
parent 007c694815
commit 7c28d5fb5d
7 changed files with 87 additions and 27 deletions

View File

@ -311,6 +311,16 @@ void Foam::fv::rotorDiskSource::createCoordinateSystem()
coeffs_.lookup("refDirection") >> refDir; coeffs_.lookup("refDirection") >> refDir;
localAxesRotation_.reset
(
new localAxesRotation
(
mesh_,
axis,
origin
)
);
// set the face areas and apply correction to calculated axis // set the face areas and apply correction to calculated axis
// e.g. if cellZone is more than a single layer in thickness // e.g. if cellZone is more than a single layer in thickness
setFaceArea(axis, true); setFaceArea(axis, true);
@ -323,6 +333,16 @@ void Foam::fv::rotorDiskSource::createCoordinateSystem()
coeffs_.lookup("axis") >> axis; coeffs_.lookup("axis") >> axis;
coeffs_.lookup("refDirection") >> refDir; coeffs_.lookup("refDirection") >> refDir;
localAxesRotation_.reset
(
new localAxesRotation
(
mesh_,
axis,
origin
)
);
setFaceArea(axis, false); setFaceArea(axis, false);
break; break;
@ -446,6 +466,7 @@ Foam::fv::rotorDiskSource::rotorDiskSource
invR_(cells_.size(), I), invR_(cells_.size(), I),
area_(cells_.size(), 0.0), area_(cells_.size(), 0.0),
coordSys_(false), coordSys_(false),
localAxesRotation_(),
rMax_(0.0), rMax_(0.0),
trim_(trimModel::New(*this, coeffs_)), trim_(trimModel::New(*this, coeffs_)),
blade_(coeffs_.subDict("blade")), blade_(coeffs_.subDict("blade")),
@ -482,6 +503,10 @@ void Foam::fv::rotorDiskSource::calculate
scalar AOAmin = GREAT; scalar AOAmin = GREAT;
scalar AOAmax = -GREAT; scalar AOAmax = -GREAT;
tmp<vectorField> tUcf(localAxesRotation_->transform(U));
vectorField& Ucf = tUcf();
forAll(cells_, i) forAll(cells_, i)
{ {
if (area_[i] > ROOTVSMALL) if (area_[i] > ROOTVSMALL)
@ -491,7 +516,7 @@ void Foam::fv::rotorDiskSource::calculate
const scalar radius = x_[i].x(); const scalar radius = x_[i].x();
// velocity in local cylindrical reference frame // velocity in local cylindrical reference frame
vector Uc = coordSys_.localVector(U[cellI]); vector Uc = Ucf[i];
// transform from rotor cylindrical into local coning system // transform from rotor cylindrical into local coning system
Uc = R_[i] & Uc; Uc = R_[i] & Uc;

View File

@ -90,6 +90,7 @@ SourceFiles
#include "fvOption.H" #include "fvOption.H"
#include "cylindricalCS.H" #include "cylindricalCS.H"
#include "localAxesRotation.H"
#include "NamedEnum.H" #include "NamedEnum.H"
#include "bladeModel.H" #include "bladeModel.H"
#include "profileModelList.H" #include "profileModelList.H"
@ -183,9 +184,12 @@ protected:
//- Area [m2] //- Area [m2]
List<scalar> area_; List<scalar> area_;
//- Rotor co-ordinate system (r, theta, z) //- Rotor local cylindrical co-ordinate system (r, theta, z)
cylindricalCS coordSys_; cylindricalCS coordSys_;
//- Rotor transformation co-ordinate system
autoPtr<localAxesRotation> localAxesRotation_;
//- Maximum radius //- Maximum radius
scalar rMax_; scalar rMax_;

View File

@ -113,6 +113,33 @@ 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)
:
Rptr_(),
origin_(vector::zero),
e3_(vector::zero)
{
Rptr_() = R;
}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
void Foam::localAxesRotation::clear() void Foam::localAxesRotation::clear()

View File

@ -26,17 +26,22 @@ Class
Description Description
A local coordinate rotation. A local coordinate rotation.
Each rotational tensor is defined with two vectors (dir and e3) The cell based rotational field can be created in two ways:
where dir = cellC - origin and e3 is the rotation axis.
Per each cell an axesRotation type of rotation is created
\verbatim 1) Each rotational tensor is defined with two vectors (dir and e3)
localAxesRotation where dir = cellC - origin and e3 is the rotation axis.
{ Per each cell an axesRotation type of rotation is created
type localAxes; (cylindrical coordinates)
e3 (0 0 1);
} \verbatim
\endverbatim localAxesRotation
{
type localAxes;
e3 (0 0 1);
}
\endverbatim
2) The rotational tensor field is provided at construction
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -88,9 +93,20 @@ 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
localAxesRotation
(
const objectRegistry&,
const vector& axis,
const point& origin
);
//- Construct from dictionary //- Construct from dictionary
localAxesRotation(const dictionary&); localAxesRotation(const dictionary&);
//- Construct from tensor Field
localAxesRotation(const tensorField&);
//- Return clone //- Return clone
autoPtr<localAxesRotation> clone() const autoPtr<localAxesRotation> clone() const
{ {

View File

@ -50,7 +50,7 @@ Description
Type of co-ordinates: Type of co-ordinates:
1) cartesian 1) cartesian
2) cylindrical
See Also See Also
coordinateSystem and coordinateSystem::New coordinateSystem and coordinateSystem::New

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -29,14 +29,6 @@ License
#include "mathematicalConstants.H" #include "mathematicalConstants.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(cylindricalCS, 0);
addToRunTimeSelectionTable(coordinateSystem, cylindricalCS, dictionary);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -36,7 +36,6 @@ SourceFiles
#define cylindricalCS_H #define cylindricalCS_H
#include "coordinateSystem.H" #include "coordinateSystem.H"
#include "typeInfo.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -89,9 +88,6 @@ protected:
public: public:
//- Runtime type information
TypeName("cylindrical");
// Constructors // Constructors