FeResPost Web Site                     FeResPost Online User Manual

IV.2.11.2 Superelements and OP2 files

The first test with OP2 files involves the reading of Results only. Test is provided in file “RUBY/EX27/readOp2.rb”.

The NastranDb object is initialized by reading model from BDF file as explained in section IV.2.11.1. One builds a list of superelement IDs as follows:

   nbr=db.NbrSuperElements  
   seIds=[0]  
   (0...nbr).each do |pos|  
       seIds << db.getSuperElementIdFromPos(pos)  
   end

Note that the master database with SEID=0 is considered in the seIds Array.

Results are read from an OP2 file:

   printf("' n' n   0) Reading all the results in the DataBase : ' n' n")  
   db.readOp2(op2FileName,"Results")

The following instructions produce only the title line. No Results are associated to the master database. (This is normal as all GRIDs and elements are defined in superelements and not in the residual model):

   printf("' n' n   A) Getting results from the main database : ' n' n")  
   db.each_resultKey do |lcName,scName,tpName|  
      tmpRes=db.getResultCopy(lcName,scName,tpName)  
      printf("%-20s%-25s%-60s%-10d' n",lcName,scName,tpName,tmpRes.Size)  
   end

With the following instructions we print the characteristics of Results stored in the master database and all its superelements:

   printf("' n' n   B) Getting all the results from all databases : ' n' n")  
   seIds.each do |seId|  
       currentDb=nil  
       if seId>0 then  
           currentDb=db.getSuperElementFromId(seId)  
       else  
           currentDb=db  
       end  
       printf("currentDb.SEID = %d' n",currentDb.SEID)  
       currentDb.each_resultKey do |lcName,scName,tpName|  
           res=currentDb.getResultCopy(lcName,scName,tpName)  
           $stdout.printf("A) %s - %s - %s : %d' n",lcName,scName,tpName,res.Size)  
       end  
   end

This produces an output that looks as follows:

   B) Getting all the results from all databases :  
 
   currentDb.SEID = 0  
   currentDb.SEID = 1  
   B) Load Case 1 - Statics - Applied Loads, Forces : 8  
   B) Load Case 1 - Statics - Displacements, Rotational : 88  
   B) Load Case 1 - Statics - Displacements, Translational : 88  
   B) Load Case 1 - Statics - Reaction Forces, Forces : 5  
   B) Load Case 1 - Statics - Reaction Forces, Moments : 5  
   B) Load Case 1 - Statics - SPC Forces, Forces : 5  
   B) Load Case 1 - Statics - SPC Forces, Moments : 5  
   B) Load Case 1 - Statics - Stress Tensor : 256  
   currentDb.SEID = 2  
   B) Load Case 1 - Statics - Applied Loads, Forces : 20  
   B) Load Case 1 - Statics - Displacements, Rotational : 24  
   B) Load Case 1 - Statics - Displacements, Translational : 24  
   B) Load Case 1 - Statics - Stress Tensor : 32  
   currentDb.SEID = 3  
   B) Load Case 1 - Statics - Applied Loads, Forces : 18  
   ...

Again, no Result is produced for master DB. On the other hand, superelements contain Results that are retrieved from database using “getResultCopy” method.

We end the example by cleaning the results and erasing the NastranDb object:

   db.removeAllResultsAllSE()  
   db=nil  
   GC.start()

A model can also be read from an OP2 file, even though it is not recommended practice. The “readOp2” can also be used to read both the model and Results:

   db=NastranDb.new()  
   db.readOp2(op2FileName,"Model/Results")

We verify in the ruby script that the same Results are associated to the master database and its superelements, and that the superelements are correctly read from the OP2 file.