View Issue Details
ID  Project  Category  View Status  Date Submitted  Last Update 

0000708  OpenFOAM  Bug  public  20121221 08:33  20140509 15:29 
Reporter  olle  Assigned To  
Priority  normal  Severity  minor  Reproducibility  have not tried 
Status  resolved  Resolution  fixed  
Summary  0000708: Cylindrical coordinate transformation  
Description  I 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 CStransformations e.g. the one for spherical coords.  
Tags  No tags attached.  

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. 

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. 

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. cylcoords) would be quite useful. 

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). 

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 

This is fixed on commit fe8de9c92bc929e515c17baaea55c95fc6300297 Thanks for the report 
Date Modified  Username  Field  Change 

20121221 08:33  olle  New Issue  
20130612 10:25 

Note Added: 0002272  
20130612 12:23 

Note Added: 0002274  
20130612 13:38  olle  Note Added: 0002275  
20130612 16:14 

Note Added: 0002277  
20140509 09:20 

Note Added: 0003049  
20140509 15:29 

Note Added: 0003050  
20140509 15:29 

Status  new => resolved 
20140509 15:29 

Resolution  open => fixed 
20140509 15:29 

Assigned To  => user21 