3. Access methods on concepts#

3.1. Access to the contents of an SD list#

lst = listr8.Values ()

lst is a Python list that contains values from the Aster list: lst = [:ref:` 0., 1.1, 2.3, … < 0., 1.1, 2.3, …>`]

3.2. Access to the content of a functional SD or a soft SD#

lst1, lst2, (lst3) = [function/table] .Values ()

lst1 and lst2 are two Python lists that contain x-numbers and ordinates. If the function is complex, we get a third list and lst2 and lst3 will contain the lists of the real and imaginary parts.

lst1 = [function] .absc ()

lst1 is the list of abscissa, which is also the first list returned by Values ().

lst2 = [function] .Ordo ()

lst2 is the list of ordinates, which is also the second list returned by Values ().

dico1 = [function] .Parameters ()

returns a dictionary containing the parameters of the function; the type jeveux (FONCTION, FONC_C, NAPPE) is not returned, so the dictionary can be provided to CALC_FONC_INTERP as it is (see efica02a).

3.3. Evaluation of an SD function or formula#

Functions and formulas can simply be evaluated in the python namespace, so the command file, like this:

FONC1 = FORMULE (VALE =' (Y**2) + X',

NOM_PARA =( “X”, “Y”,)), );

> >> print FONC1 (1.,2.)

or with a function:

FONC2 = DEFI_FONCTION (NOM_PARA ='X', VALE =( 0., 0., 1., 4.,))

> >> print FONC2 (0.5)

2.

In the case of functions, it should be noted that a tolerance of 1.e-6 in relative terms is applied when the value of the parameter is very close to the limits in order to avoid an error due to an extension that is forbidden to the nearest rounding.

3.4. Access to the content of a mesh SD#

Two methods allow you to retrieve the list of groups of meshes and nodes of a mesh-type data structure:

[(tuple),...] = [mesh]. LIST_GROUP_MA ()

returns a list of tuples, each containing the name of each group of elements, the number of cells it contains, and the highest dimension (0, 1, 2, or 3) of its cells:

tuple = (“GMA”, number of meshes, mesh size)

[(tuple),...] = [mesh]. LIST_GROUP_NO ()

returns the list of node groups in the form:

tuple = (group_no name, number of group_no nodes)

3.5. Access to the content of a SDmatr_asse_ *#

Let matr be a matr_asse_depl_r data structure.

We get a numpy array of the full matrix by doing:

array = matr. EXTR_MATR ()

To recover the matrix with a hollow storage, we do:

data, lines, cols, dim = matr. EXTR_MATR (sparse=True)

We have:

array is of dimension (dim, dim)

number of non-zero terms: len (data) = len (lines) = len (cols)

data [k] = array [lines [k], cols [k]]

Likewise for matrgene a matr_asse_gene_r data structure, for example, produced by the operator PROJ_MATR_BASE.

We get a numpy array of the full matrix by doing:

array = matrix. EXTR_MATR_GENE ()

3.6. Access to the keys of an SD result#

If EVOL is a result data structure, then:

dictionary = EVOL. LIST_CHAMPS ()

is a dictionary whose keys are the names of the fields that index the list of calculated order numbers.

Table 3.6-1

Example:

>>> print dictionary ['DEPL']
[:ref:`0,1,2 <0,1,2>`]

(field DEPLest calculated at serial numbers 0, 1 and 2)

>>> print dictionary ['SIEF_ELNO']
[]

(field is not calculated)

Table 3.6-2

dictionary = EVOL. LIST_VARI_ACCES ()

is a dictionary whose keys are access variables that index their own values.

Table 3.6-3

Example:

>>> print dictionary ['NUME_ORDRE']
[:ref:`0,1,2 <0,1,2>`]

(the order numbers of the EVOLsont result: 0.1 and 2)

>>> print dictionary ['INST']
[:ref:`0., 2., 4. <0., 2., 4.>`]

(the calculated times of the EVOLsont result: 0.s,2.s and 4.s)

Table 3.6-4

dictionary = EVOL. LIST_PARA ()

is a dictionary whose keys are the calculation parameters that index the lists (with a cardinal equal to the number of order numbers calculated) of their values.

Table 3.6-5

Example:

>>> print dictionary ['MODELE']
['MO', 'MO', 'MO']

(name of the reference model concept for each order number)

>>> print dictionary ['ITER_GLOB']
[:ref:`4,2,3 <4,2,3>`]

(number of convergence iterations for each order number)

Table at 3.6-6

3.7. Access to the content of a tran_gene SD#

If trangene is a tran_gene data structure, for example, produced by the DYNA_VIBRA operator, then:

Table 3.7-1

3.8. Access to the content of a melasflu SD#

This Python method makes it possible to extract the list of fluid velocities for which the calculation of fluid-elastic coupling parameters has been performed.

>>> base = CALC_FLUI_STRU ( ... )
>>> print base. VITE_FLUI ()
[:ref:`1., 1.5, 2.5, 3. <1., 1.5, 2.5, 3.>`]

List of fluid velocities for which coupling coefficients have been calculated.

3.9. Retrieving fields by elements and fields at nodes in Python (EXTR_COMP)#

The EXTR_COMP method, applied to a field, allows the field content to be retrieved in Python.

3.9.1. Command arguments EXTR_COMP#

The command has 3 arguments:

ch1 = CHAMP. EXTR_COMP (comp=” “, lgma= [], topo=0), for the fields at the nodes,

ch1 = CHAMP. EXTR_COMP (comp, lgma, topo=0), for fields per element,

comp

component of the field on the lgma list.. For node fields, if comp is left by default, all components are returned. The result of the command is changed (see below).

lgma

list of mesh groups, if empty then we take all group_ma (equivalent to TOUT =” OUI “in the Aster commands.

topo

topology information is returned if >0 (optional, default = 0).

Table 3.9.1-1

Note: for node fields, you can run the command in the following way: ch1= CHAMP. EXTR_COMP (topo=1). In this case, we return all the components for all the topological entities in field CHAMP.

3.9.2. Example of use#

From the U result:

  1. A field (node or ELxx) corresponding to a moment is created by CREA_CHAMP.

  2. The component is extracted using the EXTR_COMP method (declared for cham_elem and cham_no) which creates a new type of python object: post_comp_cham_el and post_comp_cham_no whose attributes are described below. You can extract all the components at once by not specifying this one (for node fields only).

U = STAT_NON_LINE (…)

U104 = CREA_CHAMP (

TYPE_CHAM = “NOEU_DEPL_R”,

OPERATION = “EXTR”,

RESULTAT = U,

NOM_CHAM = “DEPL”,

NUME_ORDRE = 104,

)

U104NP = U104. EXTR_COMP (“X”, [”S_ SUP “,])

print u104np.Values

V104 = CREA_CHAMP (

TYPE_CHAM = “ELGA_VARI_R”,

OPERATION = “EXTR”,

RESULTAT = U,

NOM_CHAM = “VARI_ELGA”,

NUME_ORDRE = 104,

)

V104NP=V104. EXTR_COMP (“V22”, [] ,1)

print v104np.Values

Print V104NP.mesh

Print V104NP.Point

Print V104NP.sub_point

3.9.3. Results of order EXTR_COMP#

ch1.values: Numeric.array containing the values

  • For fields by elements, if the topology was requested (topo>0):

  • ch1.mesh: mesh number

  • ch1.point: number of the point in the mesh

  • ch1.sub_point: number of the sub-point in the mesh

  • For the fields at the nodes, if the topology was requested (topo>0):

  • ch1.node: node number

  • ch1.comp: if we requested all the components of the field (comp = “”, value by default), component associated with the value.