View Issue Details

IDProjectCategoryView StatusLast Update
0001982OpenFOAM(No Category)public2016-01-29 13:01
ReporterchbAssigned Tohenry 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformGNU/LinuxOSOtherOS Version(please specify)
Product Version 
Fixed in Version 
Summary0001982: vectors e1,e2,e3 reported are different to the definition of the coordinate system.
DescriptionFor a
coordinateSystem
        {
            type cartesian;
            origin (1 2 3);
            coordinateRotation
            {
                 type axesRotation;
                 e1 (0 1 0 );
                 e2 (0 0 1 );
            // e3 (1 0 0 );

        }

the vectors e1,e2,e3 reported are different to the definition of the coordinate system.

Steps To Reproduce  sample code
  {
               const coordinateSystem& csys = pZ.coordSys();

               const vector& e3_ok = csys.R().R().T().z();
               
               Info << endl;
               Info << "csys:" << csys <<endl;
               Info << "csys.R().R() ;" << csys.R().R() << endl;
               Info << "csys.R().R().T():" << csys.R().R().T()<< endl;
 
               Info << endl<< "e3_wrong:" << csys.R().e3() << endl;
               Info << endl<< "e3_ok :" << csys.R().R().T().z() << endl;
            }
            
The sample code gives following output:
 
      coordinateSystem origin: (1 2 3)
      e1 (0 0 1);
      e2 (1 0 0);
      e3 (0 1 0);
      
      csys.R().R() : (0 0 1 1 0 0 0 1 0)
      
      csys.R().R().T(): (0 1 0 0 0 1 1 0 0)

      e3_wrong:(0 1 0)

      e3_ok :(1 0 0)



Additional InformationI think following changes will lead to a coorect output of e1((),e2(),e3()

axesRotation.H: line 153 ff

        //- Return local Cartesian x-axis
        virtual const vector e1() const
        {
            return R_.x();
        }

        //- Return local Cartesian y-axis
        virtual const vector e2() const
        {
            return R_.y();
        }

        //- Return local Cartesian z-axis
        virtual const vector e3() const
        {
            return R_.z();
        }
        
should eventully be changed to somtehing like:

        //- Return local Cartesian x-axis in global coordinates
        virtual const vector e1() const
        {
            return R_.T().x();
        }

        //- Return local Cartesian y-axis in global coordinates
        virtual const vector e2() const
        {
            return R_.T().y();
        }

        //- Return local Cartesian z-axis in global coordinates
        virtual const vector e3() const
        {
            return R_.T().z();
        }
       
similar changes are eventually required for EulerCoordinateRotation.H and STARCDCoordinateRotation.
TagsNo tags attached.

Activities

henry

2016-01-28 20:02

manager   ~0005868

Wouldn't it be more efficient and sensible to use

        //- Return local Cartesian x-axis
        virtual const vector e1() const
        {
            return Rtr_.x();
        }

        //- Return local Cartesian y-axis
        virtual const vector e2() const
        {
            return Rtr_.y();
        }

        //- Return local Cartesian z-axis
        virtual const vector e3() const
        {
            return Rtr_.z();
        }

chb

2016-01-29 07:15

reporter   ~0005869

Last edited: 2016-01-29 07:25

View 6 revisions

Henry,
Using of Rtr_ instead of R_.T() is really more elegant.

But I think also the comments are a little bit confusing at the moment:
    e.g. //- Return local Cartesian x-axis
In my interpretation the LOCAL x-axis is just (1 0 0) and so on..

So I think something like
       //- Return local Cartesian x-axis in global coordinates
expresses more what e1(),e2(),e3() returns (at least in my understanding of the topic)
Regards,
Christof

henry

2016-01-29 07:21

manager   ~0005870

I would say that all of the coordinate transformation handling in OpenFOAM is more than just a little bit confusing and happy to include any suggestions you have to make it better. At some point I think it will need a re-write.

I will push the changes to e? shortly.

henry

2016-01-29 09:59

manager   ~0005871

Resolved in OpenFOAM-dev by commit d84325d5afbcb49e94c0354c14507e0705a0a86f

Could you test these changes and let me know before I close this report?

chb

2016-01-29 12:55

reporter   ~0005872

I tested your patch with OF 3.0.0 and the output is now correct:

csys:coordinateSystem origin: (1 2 3)
e1 (0 1 0);
e2 (0 0 1);
e3 (1 0 0);

csys.R().R() :
(0 0 1 1 0 0 0 1 0)
csys.R().R().T():
(0 1 0 0 0 1 1 0 0)

e3_wrong:(1 0 0)

e3_ok :(1 0 0)

Issue History

Date Modified Username Field Change
2016-01-28 13:38 chb New Issue
2016-01-28 20:02 henry Note Added: 0005868
2016-01-29 07:15 chb Note Added: 0005869
2016-01-29 07:17 chb Note Edited: 0005869 View Revisions
2016-01-29 07:18 chb Note Edited: 0005869 View Revisions
2016-01-29 07:19 chb Note Edited: 0005869 View Revisions
2016-01-29 07:20 chb Note Edited: 0005869 View Revisions
2016-01-29 07:21 henry Note Added: 0005870
2016-01-29 07:25 chb Note Edited: 0005869 View Revisions
2016-01-29 09:59 henry Note Added: 0005871
2016-01-29 12:55 chb Note Added: 0005872
2016-01-29 13:01 henry Status new => resolved
2016-01-29 13:01 henry Resolution open => fixed
2016-01-29 13:01 henry Assigned To => henry
2016-03-11 11:44 administrator Category 3.0.1 => (No Category)