View Issue Details

IDProjectCategoryView StatusLast Update
0000708OpenFOAMBugpublic2014-05-09 15:29
Reporterolle Assigned Touser21 
PrioritynormalSeverityminorReproducibilityhave not tried
Status resolvedResolutionfixed 
Summary0000708: Cylindrical coordinate transformation
DescriptionI belive there is an error in the file src/meshTools/coordinateSystems/cylindricalCS.C . The functions for transforming vector fields does not make sense to me. It seems as if the coordinate transformation for a single vector:
    x=r*cos(theta), y=r*sin(theta), z=z
    r=sqrt(sq(x)+sq(y)), theta=atan2(y,x), z=z
are used also for the transformation of vector fields. The correct basis vector relationships to be used when transforming vector fields are:
e_x=e_r*cos(theta)-e_theta*sin(theta)
e_y=e_r*sin(theta)+e_theta*cos(theta)
e_z=e_z
e_r=e_x*cos(theta)+e_y*sin(theta)
e_theta=-e_x*sin(theta)+e_y*cos(theta)
e_z=e_z

I have not checked, but I think this bug could be present also in CS-transformations e.g. the one for spherical coords.
TagsNo tags attached.

Activities

user676

2013-06-12 10:25

  ~0002272

I think that transformation only make sense when dealing with points, but it is not correct for vector or vector fields. For vector and vector fields I think that the transformation is the same.

user21

2013-06-12 12:23

  ~0002274

The transformation is defined by the rotation tensor (R), which is build
at the constructor of the coordinate system using the axes provided to the
constructor. cylindricalCS only changes from cartesian (x,y,z) to cylindrical (theta, phi, z) or the inverse. R is applied to the cartesian vector.

olle

2013-06-12 13:38

reporter   ~0002275

I don't think I understand what you mean. But from what I can see in the code cylindricalCS cannot be used to convert e.g. a cartesian velocity field (U V W) to a cylindrical velocity field (U_theta U_r U_z). What the code can is converting one or many position vectors (x y z) to (theta r z).

This is perhaps intentional but it is a bit confusing for me. And functionality in OF for transforming vector fields (to e.g. cyl-coords) would be quite useful.

user676

2013-06-12 16:14

  ~0002277

For example: New functionality rotorDiskSource uses cylindricalCS with the intention to transform a vector field U from cartesian coordinate system to cylindrical coordinates system.
I am playing with this new functionality known in Fluent as Virtual Blade Model and if using the original code the forces perpendicular to the rotor plane are not axisymmetric because tangential component of the vector ( velocity vector or localForce vector) is taken as if it is an angle (phi).

user676

2014-05-09 09:20

  ~0003049

Any news about this "bug"?
Sergio, referring to the rotorDiskSource, the code says:
            // velocity in local cylindrical reference frame
            vector Uc = coordSys_.localVector(U[cellI]);

            // transform from rotor cylindrical into local coning system
            Uc = R_[i] & Uc;

            // set radial component of velocity to zero
            Uc.x() = 0.0;

            // set blade normal component of velocity
            Uc.y() = radius*omega_ - Uc.y();

rotation tensor R_[i] is not applied to the cartesian vector but it is applied to the cylindrical vector. The way in which R_[i] is constructed, it changes from planar( cylindrical) to local coning system.

Inside cylindricalCS.C:
Foam::tmp<Foam::vectorField> Foam::cylindricalCS::globalToLocal
(
    const vectorField& global,
    bool translate
) const
{
    const vectorField lc
    (
        coordinateSystem::globalToLocal(global, translate)
    );

    tmp<vectorField> tresult(new vectorField(lc.size()));
    vectorField& result = tresult();

    result.replace
    (
        vector::X,
        sqrt(sqr(lc.component(vector::X)) + sqr(lc.component(vector::Y)))
    );

    result.replace
    (
        vector::Y,
        atan2
        (
            lc.component(vector::Y),
            lc.component(vector::X)
        )*(inDegrees_ ? 180.0/constant::mathematical::pi : 1.0)
    );

Excuse me but I think that this is valid for points, not for vector fields

user21

2014-05-09 15:29

  ~0003050

This is fixed on commit fe8de9c92bc929e515c17baaea55c95fc6300297

Thanks for the report

Issue History

Date Modified Username Field Change
2012-12-21 08:33 olle New Issue
2013-06-12 10:25 user676 Note Added: 0002272
2013-06-12 12:23 user21 Note Added: 0002274
2013-06-12 13:38 olle Note Added: 0002275
2013-06-12 16:14 user676 Note Added: 0002277
2014-05-09 09:20 user676 Note Added: 0003049
2014-05-09 15:29 user21 Note Added: 0003050
2014-05-09 15:29 user21 Status new => resolved
2014-05-09 15:29 user21 Resolution open => fixed
2014-05-09 15:29 user21 Assigned To => user21