FeResPost Web Site                     FeResPost Online User Manual

IV.2.4.5 Coordinate system transformations

One first presents an example, in which one modifies the coordinates of a point, and the components of a vector and of a tensor attached to this point. One first extracts the coordinate systems that are used in this example are defined, and entities that shall be transformed:

    cs5=db.getCoordSysCopy(5)
    cs6=db.getCoordSysCopy(6)

    x=[5.0,0.0,0.0]
    v=[1.5,3.2,-4.0]
    m=[[2.0,3.0,-7.0],[1.0,0.0,0.0],[0.0,0.0,1.0]]

One assumes that the coordinates and components of the vector and tensor defined above are given in coordinate system 5. Coordinates and components can be expressed in basic coordinate system as follows:

    x0=cs5.changeCoordsA20(x)
    v0=cs5.changeCompsA20(x,v)
    m0=cs5.changeCompsA20(x,m)

Then, the coordinates and components can be re-expressed with respect to the coordinate system 5 using the following transformations:

    x5=cs5.changeCoords02B(x0)
    v5=cs5.changeComps02B(x0,v0)
    m5=cs5.changeComps02B(x0,m0)

Coordinates and components can also be transformed directly from coordinate system 5 to 6:

    x6=cs5.changeCoordsA2B(x5,cs6)
    v6=cs5.changeCompsA2B(x5,v5,cs6)
    m6=cs5.changeCompsA2B(x5,m5,cs6)

and then back to coordinate system 5:

    x5=cs6.changeCoordsA2B(x6,cs5)
    v5=cs6.changeCompsA2B(x6,v6,cs5)
    m5=cs6.changeCompsA2B(x6,m6,cs5)

The entire example is given in file "RUBY/EX09/modifCS.rb".

One presents below an example that illustrates the transformations of coordinate system in which Result components are expressed. One loads results on elements with PCOMP properties. Then the components are printed after several transformations:

The transformations are performed with the following instructions:

   ...
   stress.modifyRefCoordSys(db,0)
   ...
   stress.modifyRefCoordSys(db,"elemIJK")
   ...
   stress.modifyRefCoordSys(db,7)
   ...
   stress.modifyRefCoordSys(db,"matCS")
   ...
   stress.modifyRefCoordSys(db,0,[1.0, 0.0, 0.0])
   ...
   stress.modifyRefCoordSys(db,0,[0.0, 1.0, 0.0])
   ...
   stress.modifyRefCoordSys(db,"elemCS")
   ...

Two versions of the sequence of transformations are proposed:

1.

In the first version, the transformations are done from the native Results. This means that the Result object to be transformed is reloaded from the DataBase prior to each transformation. One also presents an example of use of the “each” iterator of Result class.

2.

In the second version, the transformation is done successively on the same Result object which has been loaded only once. One also presents examples of the use of “each”, “each_key” and “each_values” of the Result class. For example, two versions of the use of “each_key” iterator are presented:

            ...
            stress.each_key do |stressKey|
               for j in 0..3
                  printf("%10s",stressKey[j].to_s)
               end
               printf("\n")
            end
      
            stress.each_key("int","int","int","int") do |elemId,nodeId,layerId,subLayerId|
               printf("%10s",elemId.to_s)
               printf("%10s",nodeId.to_s)
               printf("%10s",layerId.to_s)
               printf("%10s",subLayerId.to_s)
               printf("\n")
            end
            ...

The example ends with an error message for the second version because it is not possible to transform a Result object if stored values are already expressed in a projected coordinate system.

This example is provided in file "RUBY/EX09/modifCS2D.rb". A second version of the example with transformation of results on 3D elements is given in file "RUBY/EX09/modifCS3D.rb".

A third version involving the use of user defined coordinate systems is provided in file "RUBY/EX09/modifCS2Db.rb". This version illustrate the manipulation of CoordSys objects.

Finally, a fourth version of the 2D example is obtained by addition new arguments to the “modifyRefCoordSys” method in such a way that Results expressed in user or projected coordinate systems can further be modified without resulting in error messages. The successive transformation of coordinate systems become:

   ...
   stress.modifyRefCoordSys(db,0)
   ...
   stress.modifyRefCoordSys(db,"elemIJK")
   ...
   stress.modifyRefCoordSys(db,7)
   ...
   stress.modifyRefCoordSys(db,"matCS")
   ...
   stress.modifyRefCoordSys(db,0,[1.0, 0.0, 0.0])
   ...
   stress.modifyRefCoordSys(db,0,[0.0, 1.0, 0.0],0,[1.0, 0.0, 0.0])
   ...
   stress.modifyRefCoordSys(db,"elemCS",nil,0,[0.0, 1.0, 0.0])
   ...

This last version is given in file "RUBY/EX09/modifCS2Dc.rb".