Welcome to the forums. Please post in English or French.

You are not logged in.

#1 2010-09-25 09:56:30

Bracchesimo
Member
From: Italy
Registered: 2010-08-17
Posts: 100
Website

[SOLVED] Accessing Mesh Data Structure

Hello,

I have one month experience with code_aster, I am pretty good programming in c++, Matlab and VB, I am new to python.

I would like to access the mesh data structure during the execution of code_aster. I found the following thread:
http://www.code-aster.org/forum2/viewtopic.php?id=14260
that suggests:

# TITLE Example N 2 "Accessing Aster Data using python methods" 
#
#    It is necessary to select "command by command" execution 
#    deactivating PAR_LOT option
#    Document u1.03.02
DEBUT( PAR_LOT = 'NON' );
#
#    Reference is made to the comment in:
#
#    /aster/STA10.2/bibpyt/Utilitai/partition.py
#
#    Importing Class MAIL_PY from Module partition.py from path
#    see above
#
from Utilitai.partition import *
import numpy as N
#
#   Reading the mesh file in Aster Format 
#
line1=LIRE_MAILLAGE();
#
#   Creating empty new MAIL_PY "class istantiation"
#
mesh1 = MAIL_PY()
#
#    Reading mesh Data From Aster using object referencing to the
#    class function FromAster
#
mesh1.FromAster(line1)
#
#    Get Number of Nodes and Number of Element
#
nonu=mesh1.dime_maillage[0]
elnu=mesh1.dime_maillage[2]
#
#    Get node, element, group and connectivity lists
#      Data are elements/nodes LABEL
#
NodeList = list(mesh1.correspondance_noeuds)
ElemList = list(mesh1.correspondance_mailles)
ElemType = list(mesh1.tm)
#
#   Get Node coordinates referenced from node sequence position
#
ncoor = mesh1.cn
#
#      Data are elements/nodes sequence positions
#
NodeGroup = mesh1.gno
ElemGroup = mesh1.gma
#
#   Get element connection as class CONNEC a two  numpy arrays
#       referring to an element of it as follow:
#       Connex[k]  array (sequence) of the node of the k-th element
#       Connex[k][j]  reference the j-th node of the k-th element connectivity
#
Connex   = mesh1.co
#
#  this will print the node LABEL and Coordinates
#   from their sequence posistion
#
for i in range(nonu):
    print NodeList[i],'X..',ncoor[i][0],'Y..',ncoor[i][1],'Z..',ncoor[i][2]
#
#  this will print the Element  LABEL, Type and connectivity
#   from their seequence posistion
#   Element Type is from class variable  .nom
#
for i in range(elnu):
    print ' element .....', ElemList[i],'Type....',mesh1.nom[ElemType[i]]
    for j in Connex[i]:
        print '         node.....',NodeList[j]
FIN();

I got the following problem when I try to import python module

 from Utilitai.partition import *
import numpy as N

I have just like the impression that it can not be located form the python interpreter, anyway the mess file reports:

!-------------------------------------------------------!
   ! <EXCEPTION> <DVP_2>                                   !
   !                                                       !
   !                                                       !
   !    Erreur numérique (floating point exception).       !
   !                                                       !
   !                                                       !
   !                                                       !
   !                                                       !
   ! Il y a probablement une erreur dans la programmation. !
   ! Veuillez contacter votre assistance technique.        !
   !-------------------------------------------------------!

Any solution to this?
how to show code_aster the location of such modules?
is there any other problem?
in the end, which python interpreter is used by code_aster, I am running v9.4 ?

Thanks in advance!

Last edited by Bracchesimo (2010-10-02 12:03:28)

Offline

#2 2010-09-25 11:08:27

Bracchesimo
Member
From: Italy
Registered: 2010-08-17
Posts: 100
Website

Re: [SOLVED] Accessing Mesh Data Structure

I got it

I solved it changing the code this way (old code is commented):

import sys 
sys.path.append( 'home/partitionpath.......' ) #adding the location of the partition module

#from Utilitai.partition import *

#from Utilitai.Partition import * #this module couldn'be located
from partition import *
#import numpy as N #that caused floating point error
import Numeric as N

I can access the data structure now. I would be happy now to know what was that numerical error that was caused by the usage of "numpy" instead of Numeric

Thanks

Offline

#3 2010-09-28 12:40:04

robber
Member
From: Italy
Registered: 2010-05-24
Posts: 78
Website

Re: [SOLVED] Accessing Mesh Data Structure

It would be nice if you could add relevant comment to the original post

--
RB


RB

Offline

#4 2010-09-28 12:47:37

Bracchesimo
Member
From: Italy
Registered: 2010-08-17
Posts: 100
Website

Re: [SOLVED] Accessing Mesh Data Structure

robber wrote:

It would be nice if you could add relevant comment to the original post

--
RB

????????????????????????????????????

What's the unrelevant part?

Offline

#5 2010-09-28 13:33:33

robber
Member
From: Italy
Registered: 2010-05-24
Posts: 78
Website

Re: [SOLVED] Accessing Mesh Data Structure

...on the post where you got the first example, .....


RB

Offline

#6 2010-09-28 15:25:50

Bracchesimo
Member
From: Italy
Registered: 2010-08-17
Posts: 100
Website

Re: [SOLVED] Accessing Mesh Data Structure

Oh sorry I misunderstood, I am just adding the solution that worked for me.

Offline