FeResPost Web Site                     FeResPost Online User Manual

IV.2.4.6 Manipulation of Complex Results

In this example, Complex Results will be read from a Nastran xdb file. One first examines the information stored in the result file, in order to extract only the Results on needs to illustrate the manipulation of Complex Results.

IV.2.4.6.1 Extracting xdb lists of load cases and Results

The part of interest looks as follows:

   xdbFileName="../../MODEL/EXEC_XDB/sol111_ri_xyz.xdb"  
   tab=NastranDb.getXdbLcScResNames(xdbFileName)  
   lcNames=tab[0]  
   scNames=tab[1]  
   resNames=tab[2]

The lists of load cases, sub-cases and result types stored in the xdb file are saved into three Arrays of Strings that can be printed or used for other purposes.

IV.2.4.6.2 Extracting xdb Results information

The part of interest looks as follows:

   xdbFileName="../../MODEL/EXEC_XDB/sol111_ri_xyz.xdb"  
   infos=NastranDb.getXdbLcInfos(xdbFileName)  
 
   infos.each do |tab|  
      STDOUT.printf("%-20s %-25s %-6d %-6d %-15g %-15g' n",  
                    tab[0],tab[1],tab[3],tab[4],tab[5],tab[6])  
   end

One extracts the information about the load cases and sub-cases to which Results are associated in the xdb file. Then, the name of load cases, sub-cases and associated integer and real data are printed. (Note, that the third String ID, which is always void, is not printed.) The example is provided in file "RUBY/EX17/printXdbLcInfos.rb".

IV.2.4.6.3 Manipulation of Complex Results

The results of "printXdbLcInfos.rb" are used to select load cases and sub-cases for which Results are imported into the DataBase. One also selects some of the Results:

   lcNames=[]  
   lcNames << "SINUS_X"  
 
   scNames=[]  
   scNames << "Output 70 (f = 119.0000)"  
   scNames << "Output 30 (f = 79.0000)"  
   scNames << "Output 1 (f = 50.0000)"  
 
   resNames=[]  
   resNames << "Accelerations, translational (MP)"  
   resNames << "MPC Forces, Forces (MP)"  
   resNames << "MPC Forces, Moments (MP)"  
   resNames << "Accelerations, translational (RI)"  
   resNames << "MPC Forces, Forces (RI)"  
   resNames << "MPC Forces, Moments (RI)"

Note that the selection of sub-cases to be imported into the DataBase is useful even when all the load cases are to be post-processed. Indeed the post-processing of a limited number of load cases at the same time reduces the amount of memory required to store all the Results. However, this means that several Result importations might be necessary, and this increases the time needed for disk IO operations.

Then the results are imported from xdb files corresponding to SOL111 Nastran calculations. One reads two files: one in which the Results are saved in rectangular format, and one in which they are saved in polar format:

   xdbFileName="../../MODEL/EXEC_XDB/sol111_ri_xyz.xdb"  
   db.readXdb(xdbFileName,lcNames,scNames,resNames)  
 
   xdbFileName="../../MODEL/EXEC_XDB/sol111_mp_xyz.xdb"  
   db.readXdb(xdbFileName,lcNames,scNames,resNames)

To illustrate the manipulation of Results, the extraction is done for one particular load case, one particular sub-case, and on a small Group of 11 nodes only:

   tmpGroup=Group.new  
   tmpGroup.setEntities("Node 60100:60110")  
 
   lcName="SINUS_X"  
   scName="Output 30 (f = 79.0000)"

Only the “Accelerations” Result is studied:

   resRI=db.getResultCopy(lcName,scName,"Accelerations, translational (RI)",  
                          "Nodes",tmpGroup,[])  
   Util::printRes(STDOUT,"Accelerations resRI",resRI)  
 
   resMP=db.getResultCopy(lcName,scName,"Accelerations, translational (MP)",  
                          "Nodes",tmpGroup,[])  
   Util::printRes(STDOUT,"Accelerations resMP",resMP)

The following statements illustrate the polar-rectangular formats conversions:

   calcMP=Result.new  
   calcMP.set2MP(resRI)  
   Util::printRes(STDOUT,"Accelerations calcMP",calcMP)  
 
   calcRI=Result.new  
   calcRI.set2RI(resMP)  
   Util::printRes(STDOUT,"Accelerations calcRI",calcRI)

And here, one shows how Real Results can be extracted from complex ones:

   resR=calcMP.getR  
   resM=calcMP.getM  
   resI=calcMP.getI  
   resP=calcMP.getP  
   Util::printRes(STDOUT,"Accelerations resR",resR)  
   Util::printRes(STDOUT,"Accelerations resM",resM)  
   Util::printRes(STDOUT,"Accelerations resI",resI)  
   Util::printRes(STDOUT,"Accelerations resP",resP)

Of course, the reverse operation can be done too. Here is how Complex Results can be assembled from one pair of Real Results:

   assyRI=Result.new  
   assyMP=Result.new  
   assyRI.assembleComplex(2,resR,resI);  
   assyMP.assembleComplex(3,resM,resP);  
 
   Util::printRes(STDOUT,"Accelerations assyRI",assyRI)  
   Util::printRes(STDOUT,"Accelerations assyMP",assyMP)

Finally, FeResPost allow to perform operations on Results that have Complex number arguments. For example, a Result object may be multiplied by a Complex number:

   require "complex"  
 
   Z=Complex.new(3.0,2.0)  
 
   multRI=resRI.clone  
   multRI*=Z  
   Util::printRes(STDOUT,"Accelerations multRI",multRI)  
 
   multMP=resMP.clone  
   multMP*=Z  
   Util::printRes(STDOUT,"Accelerations multMP",multMP)

IV.2.4.6.4 Working with XDB attachments

The example “printXdbLcScResSizes.rb” illustrates the extraction of Results from an XDB attachment. The advantage of this method for accessing Results, is that they must no be a priori loaded into a NastranDb object. The attachment is done as follows:

   xdbFileName="../../MODEL/EXEC_XDB/sol111_ri_xyz.xdb"  
   db.attachXdb(xdbFileName)

One then selects the load case, the list of sub-cases, and the Result types for the extraction:

   lcName="SINUS_X"  
 
    scNames=[]  
    scNames << "Output 13 (f = 62.0000)"  
    scNames << "Output 14 (f = 63.0000)"  
    scNames << "Output 15 (f = 64.0000)"  
    scNames << "Output 16 (f = 65.0000)"  
    scNames << "Output 17 (f = 66.0000)"  
    scNames << "Output 18 (f = 67.0000)"  
 
    resNames=[]  
    resNames << "Accelerations, Rotational (RI)"  
    resNames << "Accelerations, Translational (RI)"  
    resNames << "Displacements, Rotational (RI)"  
    resNames << "Displacements, Translational (RI)"

The extraction is then done with a call like this one:

    h=db.getAttachmentResults(xdbFileName,lcName,scNames,resNames,"Nodes",grp)

Finally, the Results that have been returned in h (a Hash object) can be retrieved as follows:

   h.each do |id,res|  
        lcName=id[0]  
        scName=id[1]  
        resName=id[2]  
        size=res.Size  
        STDOUT.printf("%s - %s - %s : %d' n",lcName,scName,resName,size)  
    end