background image
Code_Aster
®
Version
6.4
Titrate:
Code_Aster: the maintenance of Eficas and the supervisor
Date:
02/04/04
Author (S):
C. CAREMOLI, A. YESSAYAN
Key
:
D9.02.01-A
Page
:
1/34
Data-processing manual of Description
D9.02 booklet: - HT-66/04/003/A
Organization (S):
EDF-R & D/SINETICS















Data-processing manual of Description
D9.02 booklet: -
Document: D9.02.01



Code_Aster: the maintenance of Eficas and of
supervisor


Summary:

This document is with the use of the developers of the supervisory core of Aster. It clarifies the interpretation of the file
data of the user (construction of the command set) and the sequence of the executions.
background image
Code_Aster
®
Version
6.4
Titrate:
Code_Aster: the maintenance of Eficas and the supervisor
Date:
02/04/04
Author (S):
C. CAREMOLI, A. YESSAYAN
Key
:
D9.02.01-A
Page
:
2/34
Data-processing manual of Description
D9.02 booklet: - HT-66/04/003/A
Contents
1
Introduction ............................................................................................................................................ 4
1.1
Definitions ........................................................................................................................................ 6
1.2
Assumption of responsibility of maintenance ............................................................................................... 10
2
The organization sources Python ............................................................................................................. 10
2.1
Conventions ................................................................................................................................... 10
2.2
Typology of the modules Python ...................................................................................................... 11
2.3
Hierarchy of the indices of the sources ......................................................................................... 12
2.3.1
The python sources of the supervisor ...................................................................................... 12
2.3.2
Sources of the interface-graph Eficas ......................................................................... 13
2.4
The environment ............................................................................................................................ 13
2.4.1
Installation of the interpreter Python ...................................................................................... 13
2.4.2
Shell parameters of configuration ........................................................................................ 13
2.4.3
Installation of the interface-graph Eficas ........................................................................... 13
2.4.4
Update of the supervisor ................................................................................................... 13
3
Use of the language Python in Eficas and the supervisor of Code_Aster ............................. 14
3.1
Call of a function with a variable number of arguments ......................................................... 14
3.2
Use of spaces of name ..................................................................................................... 14
3.2.1
Concept of space of names ..................................................................................................... 14
3.2.2
The module __builtin__ .................................................................................................... 15
3.2.3
Execution of a control Python in a space of names ........................................... 15
3.3
A second manner of importing a module ............................................................................... 16
3.4
Modulate Python written in language C ................................................................................................ 17
4
The general catalog of the controls of Code_Aster ....................................................................... 18
4.1
Example 1: a factory to build the key words simple .................................................... 18
4.1.1
Principle of the factory ............................................................................................................ 18
4.1.2
The organization of the factory in files ................................................................................. 20
4.2
Example 2: a factory to build a control .............................................................. 22
4.2.1
Addition of classes PROC and PROC_ETAPE with the factory ......................................................... 23
4.2.2
Concept of catalog of controls .................................................................................... 24
4.2.3
Concept of command file .......................................................................................... 24
4.2.4
Use of the catalog and the command file ............................................................. 25
4.3
The file catalogs ........................................................................................................................ 26
4.3.1
Catalog of a control ................................................................................................. 26
4.3.2
General structure of the file catalogs ................................................................................ 27
4.4
Installation of the catalog in the memory .................................................................................... 27
4.4.1
The structure of data in the package Core ................................................................ 28
4.4.2
The package Accas ................................................................................................................ 30
5
The macro-controls Python ........................................................................................................... 32
background image
Code_Aster
®
Version
6.4
Titrate:
Code_Aster: the maintenance of Eficas and the supervisor
Date:
02/04/04
Author (S):
C. CAREMOLI, A. YESSAYAN
Key
:
D9.02.01-A
Page
:
3/34
Data-processing manual of Description
D9.02 booklet: - HT-66/04/003/A
6
Some questions ............................................................................................................................. 32
6.1
How to know which file catalog is used by a calculation? ................................................ 32
6.2
How mode DEBUG is managed? ....................................................................................... 33
6.3
Where the catalog of control is it charged in the memory ..................................................... 33
6.3.1
Creation of the object JdC ......................................................................................................... 33
6.3.2
Loading of the entities of the catalog in the object JdC ...................................................... 33
6.4
Where the command set is carried out by the supervisor? ....................................................... 33
6.5
With what is used the key word _F used in the command file?................................................... 34
6.6
Where the interface getvxx of the command set find-such?...................................................... 34
7
Bibliography ........................................................................................................................................ 34
background image
Code_Aster
®
Version
6.4
Titrate:
Code_Aster: the maintenance of Eficas and the supervisor
Date:
02/04/04
Author (S):
C. CAREMOLI, A. YESSAYAN
Key
:
D9.02.01-A
Page
:
4/34
Data-processing manual of Description
D9.02 booklet: - HT-66/04/003/A
1 Introduction
Numerical study
To make a numerical study with Code_Aster, the end-user starts the functionalities of
code and provides information necessary to the execution of these functionalities.
A functionality is selected via a control. A control is initially
a name i.e. a character string or an external identifier (known of the user) of
functionality. It also incorporates attributes and initially the identifier interns
functionality (exploitable by code FORTRAN).
Information necessary to the launching and the execution of the control otherwise-known as them
parameters of the digital processing, are data introduced by means of key words them
identifier. For a given control, a certain number of parameters must be defined.
The description of the controls and the key words is carried out by the developers of Code_Aster.
in a file called “catalogs controls”.
The end-user uses the code via a file called “command file”. He provides to it
controls whose composition must be compatible with their description in the catalog of
controls. The controls are numerous but the number of associated data is much
more important with possible combinations themselves very many.
Finally the computer code stores information (controls and key words) in a structure of
data interns called “command set”.

The role of the supervisor
The supervisor is the part of Code_Aster which manages the command set. In particular:
· it imports the catalog of the controls in the Python memory,
· it charges the controls and their key words in the Python memory,
· it carries out the processing orders by control,
· it provides - at the request of FORTRAN ­ the value of the parameters to the functionalities of
Code_Aster. stored in the memory Python. For that the supervisor proposes API C.
The graphic interface Eficas
It is possible to define “manually” its command file, for example by means of one
text editor. However, the user nonfamiliar with syntax of the controls which it handles
but also the language python will be able to use Eficas.
The graphic interface Eficas is intended for the end-user of Code_Aster. It allows him
to build valid controls with statically such validated associated key words them, then
to generate a command file bound for the code. The user has the insurance that the file
product by Eficas has a correct syntax.
The core
The sources common to the Eficas interface-graph and the supervisor of Code_Aster are
organized (identified and gathered) in a specific space of called development
the “core”. The comprehension of these sources is obviously a condition necessary for
to undertake the maintenance of the two tools which use them.
background image
Code_Aster
®
Version
6.4
Titrate:
Code_Aster: the maintenance of Eficas and the supervisor
Date:
02/04/04
Author (S):
C. CAREMOLI, A. YESSAYAN
Key
:
D9.02.01-A
Page
:
5/34
Data-processing manual of Description
D9.02 booklet: - HT-66/04/003/A
Main actors
The main types of actors evolving/moving in the environment of Eficas and the supervisor are listed
below.
· The end-user: he rather knows the physical part of the problem to be solved and he has as a task
to introduce valid data into the code, of launching calculations and stripping them
results; it can use the graphic interface Eficas for that.
· The developer of functionalities in Code_Aster
: it practices primarily
programming FORTRAN of the numerical algorithms and, in the case of a macro-control,
the drafting of script corresponding Python; it enriches and/or modifies the catalog of
order and it uses API C of the supervisor to recover in his code FORTRAN, them
values provided by the end-user.
· The developer of the supervisor in Code_Aster: it writes scripts of reading and
of interpretation of the catalog of controls and command set; it is also occupied
module python aster written out of C (astermodule.c) which serves as API to the supervisor.
· The person in charge for the maintenance of the code, the environment of use and management of
configuration: he centralizes the sources. In addition to code FORTRAN, these sources include/understand
those of the catalog (Python) of the controls, scripts (Python) of the supervisor and those of
modulate aster.
· The developer of the graphic interface Eficas develops a man-machine interface. Its
role is to conceive and program dialog boxes as well as sequences
of event allowing the taking into account of the requests of the end-user and the checking ­
at every moment - validity of the command set in the course of construction.
In this document, one rather stresses the principles of the design of the core that on the detail
scripts which one cannot save the examination.
Covered subjects
The first chapter proposes a summary definition of the terms used abundantly in the continuation
document.
Chapter 2 presents few conventions and the organization of the source files in indices:
packages. It also describes the environment necessary to the development and operation
of the supervisor of Code_Aster and graphic interface Eficas.
In chapter 3, some recalls are carried out on the language of Python script. They must direct
the future person in charge for maintenance towards certain techniques that it will be necessary for him to control for
to carry out its task.
The important subject of the factory of control is evoked in chapter 4. It is a base necessary to
comprehension of all the structure of the command set.
Lastly, an answer is brought to chapter 5, some questions which one can provide that all
future person in charge for maintenance will be able to be posed.
background image
Code_Aster
®
Version
6.4
Titrate:
Code_Aster: the maintenance of Eficas and the supervisor
Date:
02/04/04
Author (S):
C. CAREMOLI, A. YESSAYAN
Key
:
D9.02.01-A
Page
:
6/34
Data-processing manual of Description
D9.02 booklet: - HT-66/04/003/A
1.1 Definitions
Mode “by batch”
The treatment of the controls user by Code_Aster can be carried out according to two
modes.
In the first mode, the file control is charged in memory to create the command set.
This creation of the jdc makes it possible to validate syntax python (brackets, commas), Aster syntax
(coherence with the catalog) and to validate the last concepts in argument. Finally after this
checking, the command set is traversed to carry out the digital processings
agents.
This first mode is called “mode by batch”. The end-user selects this mode while specifying
value “YES” for key word PAR_LOT under the control BEGINNING.
In the second mode, the command file is charged in memory to create the play of
controls. Then the stages (equivalent to the controls) are built and carried out
sequentially.
The end-user selects this mode by specifying the value “NOT” for key word PAR_LOT under
order BEGINNING.
By defect, the mode used is PAR_LOT=' OUI'.
Operator of Code_Aster
An operator is a unit of fascinating Code_Aster in load a functionality of the code.
Concretely it is a subroutine FORTRAN whose name is numbered, for example the subroutine
OP0001 which charges a mesh in the memory of the application. The classification of the operators
facilitate association between their internal representation (subroutine FORTRAN) and their representation
external for the end-user (control).
Order
A control is a character string identifying a numerical operator. It thus allows
the end-user to start the execution of this operator starting from a data file called
“command file”.
There are 4 types of controls: OPER, PROC, MACRO and FORMULATE.
The developer of the numerical operator defines - in the catalog of the control -
control characteristics and those of the key words corresponding to the parameters of the operator
numerical:
· its name (the character string usable by the end-user),
· its rules of composition in key words,
· an explanatory French and/or English comment,
· the key defining the manual and the chapter devoted to this key word in the documentation of
Code_Aster.
Order OPER
In addition to the attributes enumerated above, an ordering of type OPER has the following attribute:
· The type of the structure of data Aster produced by the operator and turned over by
order;
background image
Code_Aster
®
Version
6.4
Titrate:
Code_Aster: the maintenance of Eficas and the supervisor
Date:
02/04/04
Author (S):
C. CAREMOLI, A. YESSAYAN
Key
:
D9.02.01-A
Page
:
7/34
Data-processing manual of Description
D9.02 booklet: - HT-66/04/003/A
Order PROC
An ordering of type PROC to the characteristic not to turn over a value. This characteristic
put aside, it has the same attributes as an ordering of type OPER.
MACRO control
Macro is a function written in Python ­ by the Aster developer - which calls controls
­ i.e. operators - of Code_Aster. It stores results which could be recovered via
the supervisor.
The text the macro one can be public; in this case it is stored in a specific file of
macro sub-directory. If it is deprived, it is placed or imported in the command file.
An ordering of MACRO type makes it possible the end-user to use the macro one. For example
order MACRO_MATR_ASSE allows to launch the macro public macro_matr_asse_ops.

Catalog of a control
The catalog of a control is the whole of the Python instructions describing the definition of
order i.e. the values assigned to the attributes of the control.
The catalog of a control is written by the developer of the numerical operator associated
order.
Catalog general
The general catalog is a Python file containing the description of all the controls
otherwise-known as containing the catalogs of all the controls.
Command set
The command set is the structure of data - organized in an object Python ­ container
the whole of the information provided by the end-user, in the command file.
Command file
The command file makes it possible the end-user to start the numerical operators carrying
functionalities of Code_Aster via the controls.
Structure of data Aster
A structure of Aster data is an organization of data produced by an operator
numerical of Code_Aster. It is identified by a type itself declared at the beginning of the catalog
(cata.py); what makes it possible to use it symbolically ­ ­ in the command file although it
that is to say produced by FORTRAN.
background image
Code_Aster
®
Version
6.4
Titrate:
Code_Aster: the maintenance of Eficas and the supervisor
Date:
02/04/04
Author (S):
C. CAREMOLI, A. YESSAYAN
Key
:
D9.02.01-A
Page
:
8/34
Data-processing manual of Description
D9.02 booklet: - HT-66/04/003/A
Simple key word
A simple key word is a character string identifying a data used in input by one
operator (a numerical functionality of Code_Aster). A simple key word is thus defined inside
of an ordering of Code_Aster.
The end-user will be able to provide a value to the parameter of a control via the name
simple key word corresponding in the command file.
The developer of functionality of Code_Aster will define as for him, the characteristics of the key word
simple in the catalog of the control containing the simple key word:
· its name (the character string usable by the end-user and the numerical operator),
· the type of the parameter (whole, real, text, concept,…),
· the statute of the simple key word (optional or obligatory),
· the default value to be assigned to the parameter,
· the minimum number of data which the end-user will have to provide behind the simple key word,
· the maximum number of data which the end-user will have to provide behind the simple key word,
· an explanatory French and/or English comment.
The supervisor of Code_Aster charges in the memory of the application, the characteristics of the key word
simple, starting from the catalog of the controls. Then it charges (and checks) possibly the value of
parameter of the control starting from the command file provided to the application by the end-user.
The numerical operator of Code_Aster questions the supervisor via the API getvxx to recover
value of the parameter starting from the name of the key word. The supervisor turns over the value provided by
the user or the default value of the parameter.
Key word factor
A key word factor is a character string identifying a group of simple key words
semantically associated. A key word factor is defined inside a control. A control
can contain several key words possibly optional factors., each key word factor
containing itself of the simple key words of the same name.
The end-user will be able to define in his command file, a key word factor by specifying sound
name then its value i.e. the value of the definite numerical parameters behind the key words
simple of the key word factor.
The developer of the functionality of Code_Aster defines the characteristics of the key word factor
in the catalog of the control containing the key word factor:
· its name (the character string usable by the end-user and the numerical operator),
· its rules of composition in simple key words,
· the statute of the key word factor (optional or obligatory),
· the minimum number of repetition of the key word factor,
· the maximum number of repetition of the key word factor,
· an explanatory French and/or English comment,
· the key defining the manual and the chapter devoted to this key word in the documentation of
Code_Aster.
background image
Code_Aster
®
Version
6.4
Titrate:
Code_Aster: the maintenance of Eficas and the supervisor
Date:
02/04/04
Author (S):
C. CAREMOLI, A. YESSAYAN
Key
:
D9.02.01-A
Page
:
9/34
Data-processing manual of Description
D9.02 booklet: - HT-66/04/003/A
Conditional block
A conditional block (a block), associates:
· simple key words,
· key words factors,
· and of the conditional blocks.
The occurrence of the block in its control, depends on a condition expressed at the time of the definition of
order by the developer of the numerical functionality.
The developer of the operator corresponding to the control containing the block, specifies them
characteristics of the block:
· its name,
· its condition,
· its rules of composition in simple key words,
· an explanatory French and/or English comment.
The end-user will be able to give a value to the parameters of the processing by using the key words
factors and key words simple associates in the conditional block but without specifying the name of
block.
Regulate composition
The composite entities of the catalog of controls such as “command set”, orders,
key words factor and conditional block, structure of other entities while possibly following one or
several rules of composition among the following ones:
AU_MOINS_UN
Rule AU_MOINS_UN expresses that one at least entities whose names passed in
arguments must be present in the composite entity in which figure the rule.
UN_PARMI
Rule UN_PARMI expresses that one and only one of the entities of the entities whose names are
passed in arguments must be present in the composite entity in which figure the rule.
EXCLUDED
The rule EXCLUDED expresses which if one of the entities whose name passed in argument, is
present, the entities corresponding to the other arguments must miss in the entity
composed in which figure the rule. Otherwise-known as if several entities of the group are
present the rule is violated.
TOGETHER
The rule TOGETHER expresses that if one of the entities whose name passed in argument is
present in the composed entity, then all those corresponding to the other names will have to be it
too. The command of the occurrences does not have importance. And if none the entities represented in
the rule is not present in the composite entity, the composite entity is valid.
PRESENT_PRESENT
Rule PRESENT_PRESENT expresses that if the entity corresponding to the first name is present,
then all those corresponding to the other names will have to be it also in the composite entity
current. The command of occurrence of the other entities does not have importance. If none the entities
represented in the rule is not present, the composite entity is valid.
background image
Code_Aster
®
Version
6.4
Titrate:
Code_Aster: the maintenance of Eficas and the supervisor
Date:
02/04/04
Author (S):
C. CAREMOLI, A. YESSAYAN
Key
:
D9.02.01-A
Page
:
10/34
Data-processing manual of Description
D9.02 booklet: - HT-66/04/003/A
PRESENT_ABSENT
Rule PRESENT_ABSENT expresses that if the entity corresponding to the first name is present,
then all those corresponding to the other names will have to miss in the composite entity
current. The command of occurrence of the other entities does not have importance. If none the entities
represented in the rule is not present, the composite entity is valid.
Each rule of composition (called also simply “rule”) is a class (see the module
regle.py).
1.2
Assumption of responsibility of maintenance
The following step is proposed to the candidate with the maintenance of the graphic interface Eficas and/or
of the supervisor of Code_Aster.
· To study “Accas” i.e. what is common to the graphic interface Eficas and to
supervisor of Code_Aster;
· To study the structure of the general catalog of the controls: in the file catalogs and in
memory of the application. For that:
- to familiarize itself with the techniques of programming in Python, used in Accas;
- to develop a small model of factory (cf [§4.1]) for integrating the mechanism well of
base loading of the key words.
· To study the structure of the command set (in its file) and memory; in particular
the question of the loading of the command set (mechanism and areas of codes concerned)
must be considered;
· To examine scripts Python or the sources C brought into play at the time of requests of
amendment or of processing of the errors detected by the users.


2
The organization Python sources
2.1 Conventions
Following conventions the purpose of which are to facilitate the reading of scripts, are imperfectly
applied
· a name of class starts with a capital letter;
· the identifier of an object of the type Python list starts with the prefix l_ (this rule is
used in Eficas);
· in the packages used by the supervisor (Core, Execution, Validation, Build and
Accas) only one class is defined by module i.e. by file * .py;
· in the packages used by the supervisor (Core, Execution, Validation, Build and
Accas) the name of each module starts with a prefix indicating the name of the package.
- N_ for Core
- V_ for Validation
- E_ for Execution
- B_ for Build
- A_ for Accas
background image
Code_Aster
®
Version
6.4
Titrate:
Code_Aster: the maintenance of Eficas and the supervisor
Date:
02/04/04
Author (S):
C. CAREMOLI, A. YESSAYAN
Key
:
D9.02.01-A
Page
:
11/34
Data-processing manual of Description
D9.02 booklet: - HT-66/04/003/A
2.2
Typology of the modules Python
Each class is defined in a module: for example, class MCSIMP is defined in the module
N_MCSIMP.py where the N_ prefix indicates the name of the package (Core) containing the module.
The technique of the packages makes it possible to cut out the modules according to the sphere of activity in
which it acts. With each field corresponds a Python package
For example, class MCSIMP exists in each of the five packages,
· ·Core: N_MCIMP.SIMP;
· ·Validation: V_MCSIMP.SIMP;
· ·Ihm: I_MCIMP.SIMP;
· ·Accas: A_MCIMP.SIMP;
· ·Build: B_MCIMP.SIMP;
Core This package contains primarily the system of class of the factory of the command set.
Validation
This package contains the modules carrying out the checks of validity of the objects (controls,
conditional blocks, key words,…).
Build This package is present only in the supervisor contains the modules treating the controls
of macro type and methods of request to the command set since the API-C: interfaces
GETVxxx.
Accas
This package is most important. It contains ­ in particular - the classes more including
used as well by the interface ­ graphic Eficas as by the supervisor of Code_Aster.
It is in this package that it is necessary to seek the objects and the methods specialized in
­ processing not graph ­ of the controls:
· loading of the catalog;
· loading of a command set;
· execution of the command set.
The classes girls defined in this package are it by heritage of classes relationships having it
even name that the classes girls but being located in a different package.
Ihm
The classes of this package enrich the classes by the Core of methods ­ nonrelated to
the graphic aspect ­ used by the graphic interface Eficas.
Editor
This package contains the modules of graphic processing of the command set.
background image
Code_Aster
®
Version
6.4
Titrate:
Code_Aster: the maintenance of Eficas and the supervisor
Date:
02/04/04
Author (S):
C. CAREMOLI, A. YESSAYAN
Key
:
D9.02.01-A
Page
:
12/34
Data-processing manual of Description
D9.02 booklet: - HT-66/04/003/A
2.3
Hierarchy of the indices of the sources
2.3.1 The python sources of the supervisor
The supervisor of Code_Aster is composed of written modules python:
· out of C for the applicative interface of the supervisor: the module aster (astermodule.c);
· in Python for the management of the command set (loading, organization,…).
The diagram below presents the indices containing the Python sources of the supervisor.








Core
Eficas
Accas
Validation
Execution
Build
Macro
background image
Code_Aster
®
Version
6.4
Titrate:
Code_Aster: the maintenance of Eficas and the supervisor
Date:
02/04/04
Author (S):
C. CAREMOLI, A. YESSAYAN
Key
:
D9.02.01-A
Page
:
13/34
Data-processing manual of Description
D9.02 booklet: - HT-66/04/003/A
2.3.2 Sources of the Eficas interface-graph
The sources are organized in indices under the index of Eficas installation:
























2.4 Environment
This paragraph describes the pre-necessary conditions with the operation of the Supervisor and the interface
Eficas graph.
2.4.1 Installation of the interpreter Python
To inform
2.4.2 Shell parameters of configuration
To inform
2.4.3 Installation of the Eficas interface-graph
To inform
2.4.4 Update of the supervisor
To inform
Core
Eficas
Accas
Validation
Ihm
Editor
Extensio
Macro
Misc
Tools
background image
Code_Aster
®
Version
6.4
Titrate:
Code_Aster: the maintenance of Eficas and the supervisor
Date:
02/04/04
Author (S):
C. CAREMOLI, A. YESSAYAN
Key
:
D9.02.01-A
Page
:
14/34
Data-processing manual of Description
D9.02 booklet: - HT-66/04/003/A
3
Use of the language Python in Eficas and in
supervisor of Code_Aster
One presents here the techniques of programming in Python language, whose control is necessary to
any candidate with the maintenance of the graphic interface Eficas and the supervisor of Code_Aster.
3.1
Call of a function with a variable number of arguments
The end-user of Code_Aster uses a Python script to start the functionalities and to provide
values with the parameters of the functionality. Supply of these values being sometimes optional,
the Accas core uses the mechanism envisaged in the Python language to pass a variable number
arguments with a function.
To maintain Accas, it is, consequently, necessary to control this technique of which us
let us present a small example below.
# script main.py
def fonc (a number, * tup_args, ** d_args):
print a number
print repr (tup_args)
print repr (d_args)
fonc (11111, “arg 2”, “arg 3”, 4, n=5, j=6)
Under Unix, the interpretation of script main.py is done by:
$ python main.py
It gives the following result on the standard exit:
11111
(“arg 2”, “arg 3”, 4)
{“: 5, “I: 6}
Only the argument a number is obligatory. The possible positional arguments according to are stored
in a tuple (which can be empty) and the possible arguments passed by key word are stored in one
dictionary.
This technique is used in particular, by the objects which build the command set in
memory then which initialize it.
3.2
Use of spaces of name
3.2.1 Concept of space of names
A space of names (see [bib1], page 97) is a Python dictionary containing a whole of
couples name/value. The name is in general a character string and the value can be a value
numerical, a function or an object.
In a module Python, each instruction is carried out in a called specific space of names
space names room whose contents can be displayed by the function locals (). Instructions
also access to the total space of names has whose contents can be displayed with the function
globals ().
Accas uses in particular, a space of names to store the dictionary of the definitions which will be
used to interpret the key words and to charge their value in the memory.
background image
Code_Aster
®
Version
6.4
Titrate:
Code_Aster: the maintenance of Eficas and the supervisor
Date:
02/04/04
Author (S):
C. CAREMOLI, A. YESSAYAN
Key
:
D9.02.01-A
Page
:
15/34
Data-processing manual of Description
D9.02 booklet: - HT-66/04/003/A
3.2.2
modulate
__builtin__
A remarkable module is the standard module __builtin__ which is ­ except particular case ([bib2],
page 100) ­ referred in each module user by the attribute __builtins__ in mode
ReadOnly only.
The interpretation of the following sequence:
# script main.py
print globals ()
display
{“__doc__”:Nun, “__name__”:“__main__”, “__builtins__”:<module'__builtin__ '(built-in) >}
The module __builtin__ is imported by defect; all data and the functions which it contains
are thus accessible by defect, in all the modules of the application. Data and functions
defined in the module __builtin__ can thus be regarded as most total with
the application.
Inter alia, one finds in this module, the following tools:
· the functions locals (). and globals ();
· the variable __debug__ which conditions interpretation according to its value 1 (defect) or 0;
· the function “builtin” __import__.
# script main.py
# One installs the module context in the total space of the interpreter
# (__builtin__)
# under name CONTEXT in order to have access to the functions
# get_current_step, set_current_step and unset_current_step of anywhere
importation context
importation __builtin__
__builtin__.CONTEXT=context

It is possible to import and enrich the module __builtin__; this technique is used in
Eficas in script Core/__init__.py.

3.2.3 Execution of a control Python in a space of names
In the following example, variable GB defined at the beginning of script is accessible in all the units
module: it is defined in the total space of names.
# script main.py
gb=2
def fonc (A):
b=gb * has
print “locals () =”, locals ()
print “globals () =”, globals ()
return B
x=123
z=-1
u=fonc (X)
print z+u
background image
Code_Aster
®
Version
6.4
Titrate:
Code_Aster: the maintenance of Eficas and the supervisor
Date:
02/04/04
Author (S):
C. CAREMOLI, A. YESSAYAN
Key
:
D9.02.01-A
Page
:
16/34
Data-processing manual of Description
D9.02 booklet: - HT-66/04/003/A
The interpretation of script main.py displays:
locals () = {“B”: 246, “has”: 123}
globals () = {“__doc__”:Nun, “fonc”: <function fonc At 0x810aee4>, “Z”: - 1, “X”: 123,
“__builtins__”: <module “__builtin__” (built-in) >, “__name__”: “__main__”, “GB”: 2}
A specific space of names can be created and used to carry out instructions stored in
a character string.
# script main.py
d_contexte= {“has”: 1, “B”: 2}
print d_contexte
s_commande=' x=a+b'
exec s_commande in d_contexte
print d_contexte
When it interprets script main.py, the interpreter enriches space by names d_contexte with
“X”:3 the result of the instruction s_commande. But the local space of names does not contain the result
the instruction s_commande.
During the use of the instruction exec, one can specify that the data created must be it in
the local space of names as the example shows it below.
# script main.py
# script main.py
d_contexte= {“has”: 1, “B”: 2}
print d_contexte
s_commande=' x=a+b'
exec s_commande in d_contexte, locals ()
print “x=”, X
what displays:
{“B”: 2, “has”: 1}
x= 3
The instruction Python exec makes it possible to create a space of names by the interpretation of a Python script -
stored in a character string - by specifying a space of names behind the key word in, by
example: exec s_script in space

3.3
A second manner of importing a module
The function “builtin” __import__ ([bib2], p. 100), makes it possible to import a module starting from its name
stored in a character string. In fact, this function is called by the Python interpreter at the time
importation of a module by the instruction importation ([bib3], p629). This technique is used with several
recoveries in Eficas (packages Editor and Extensions).
nom_module=' string'
print to dir ()
module_string =__import__ (nom_module)
print to dir ()
print to dir (module_string)
print module_string.lower (“ABCD”)
One notices that the function __import__ turns over in module_string, a reference on
modulate string from which it is possible to reach the tools contained in the module.
background image
Code_Aster
®
Version
6.4
Titrate:
Code_Aster: the maintenance of Eficas and the supervisor
Date:
02/04/04
Author (S):
C. CAREMOLI, A. YESSAYAN
Key
:
D9.02.01-A
Page
:
17/34
Data-processing manual of Description
D9.02 booklet: - HT-66/04/003/A
The function “builtin” __import__ can also be used to import a module specific to leave
of a parcelling (package). The following example imports the general catalog of the controls of
Code_Aster then displays on the standard exit the name of each control.
importation sys
Local TOP='//yessayan/Eficas/EficasPourSalome' # index of installation
sys.path.append (SIGNAL)
sys.path.append (TOP+'/Aster')
from Cata importation cata
for control in cata.JdC.commandes:
print commande.nom
It can be written:
importation sys
Local TOP='//yessayan/Eficas/EficasPourSalome'
sys.path.append (SIGNAL)
sys.path.append (TOP+'/Aster')
package=__import__ (“Cata.cata”)
module_cata= getattr (package, “cata”)
for control in module_cata.JdC.commandes:
print commande.nom
As it is indicated in the documentation of python (http://www.python.org/doc/current/lib/built-in-
funcs.html), the instruction
__import__ (“Cata.cata”)
import the Cata package.
It thus remains to recover the module of the catalog starting from the package for example:
module=getattr (package, “cata”))
The control __import__ makes it possible to import a module or a package whose name is not known
that at the moment of the interpretation of current script.

3.4
Modulate Python written in language C
To inform
background image
Code_Aster
®
Version
6.4
Titrate:
Code_Aster: the maintenance of Eficas and the supervisor
Date:
02/04/04
Author (S):
C. CAREMOLI, A. YESSAYAN
Key
:
D9.02.01-A
Page
:
18/34
Data-processing manual of Description
D9.02 booklet: - HT-66/04/003/A
4
The general catalog of the controls of Code_Aster
4.1
Example 1: a factory to build the simple key words
4.1.1 Principle of the factory
The end-user of Code_Aster provides values to the functionalities via key words.
A key word makes it possible to introduce a value (key word simple) or another key word (key word factor).
The mechanism of loading and especially of use of the value of the key word is complicated by the fact
that the type of this value is not single. This type can be for example: float, int, string,… In
the following example:
MASSE_VOLUMIQUE=7800.0
FICHIER_MAILLAGE=' maillage.unv'
Key words simple MASSE_VOLUMIQUE and FICHIER_MAILLAGE receive the value respectively
7800.0 and “maillage.unv”
It is thus necessary to describe some share the characteristics of the key word simple (name, type, default value,
unit, optional or obligatory statute,…). The answer to this question is founded on separation
characteristics/following value:
· the main role of an object of the type MCSIMP is to wrap the value of a simple key word
otherwise-known as the main attribute of an object of the type MCSIMP is a value;
· an object of the type SIMP has two main roles:
- to wrap the definition of a simple key word: an object SIMP contains the whole of
characteristics of a simple key word: its name, the type of its value,…;
- but this object also has a function __call__ which makes it possible to generate a key word
simple starting from its characteristics; an object SIMP can be regarded as one
machine to manufacture an object of MCSIMP from where the factory term
Each object MCSIMP contains its value and a reference on the object SIMP which describes its
characteristics.
The technique of the factory is presented Ci below by reducing classes MCSIMP and SIMP to their
minimum.
· Class MCSIMP has two attributes:
- definition: its definition (a reference on object SIMP which created object MCSIMP) to leave
it is possible to recover the text part of the key word: definition.nom or sound
definition.type type;
- valley: its value
· class SIMP has two attributes:
- name: the part text (character string which can contain a white space) key word
MCSIMP which object SIMP will build;
- type: the type of the value introduced by the key word MCSIMP which object SIMP will build.
The function __call__ of class SIMP creates an object of the type MCSIMP. That implies that the class
MCSIMP is defined before the definition of this function.
In the model of design factory applied to the command set of Code_Aster, the class
manufactured (example MCSIMP) must be defined before the class fabricante (SIMP).
background image
Code_Aster
®
Version
6.4
Titrate:
Code_Aster: the maintenance of Eficas and the supervisor
Date:
02/04/04
Author (S):
C. CAREMOLI, A. YESSAYAN
Key
:
D9.02.01-A
Page
:
19/34
Data-processing manual of Description
D9.02 booklet: - HT-66/04/003/A
# script main.py
importation sys
# string in python 2.1 becomes str starting from python 2.2
s_version=str (sys.version_info [0]) + '.'+str (sys.version_info [1])
assert (float (s_version) <=2.1), 'the version “+s_version+” of python is
INVALIDE'
class MCSIMP:
def __init__ (coil, definition, valley, parent=None):
self.definition = definition
self.val = valley
self.parent = None
class SIMP:
def __init__ (coil, name, type):
self.nom = name
self.type =type
def __call__ (coil, valley, parent=None):
assert (str (standard (valley))== " <type '“+self.type+” '>”)
return MCSIMP (definition=self, val=val, parent=parent)
d_context= {
“MASSE_VOLUMIQUE”: SIMP (nom=' MASS VOLUMIQUE', type=' float'),
“FICHIER_MAILLAGE”: SIMP (nom=' FILE MAILLAGE', type=' string')
}
s_commande = “rho=MASSE_VOLUMIQUE (7800.0)”
exec s_commande in d_context, locals () # rho is added to the space of
names locals ()
print rho
print rho.definition.nom
print rho.val
s_commande = “mail=FICHIER_MAILLAGE (“maillage.d”)”
exec s_commande in d_context, locals () # mall is added to the space of
names locals ()
print mall
print mail.definition.nom
print mail.val
sys.stderr.write (“FINE NORMAL of main.py " + ' \)
The interpretation of script main.py above gives the following display:
<__main__.MCSIMP authority At 0x810c4ac>
DENSITY
7800.0
<__main__.MCSIMP authority At 0x810c4d4>
FILE MESH
maillage.d
Let us consider the lines
s_commande = “rho=MASSE_VOLUMIQUE (7800.0)”
exec s_commande in d_context, locals ()
background image
Code_Aster
®
Version
6.4
Titrate:
Code_Aster: the maintenance of Eficas and the supervisor
Date:
02/04/04
Author (S):
C. CAREMOLI, A. YESSAYAN
Key
:
D9.02.01-A
Page
:
20/34
Data-processing manual of Description
D9.02 booklet: - HT-66/04/003/A
The mechanism of construction of the rho object, in the local space of names, is a mechanism of
factory including/understanding the following stages:
· In the space of names d_context, the control becomes:
rho=SIMP (nom=' MASS VOLUMIQUE', type=' float') (7800.0)
then it is carried out;
· An object of the type SIMP is built with the name “DENSITY”;
· the method __call__ is called with val=7800.0 in argument;
· starting from the name (self.nom) and value (valley), the method __call__ creates and turns over
an object of the type MCSIMP;
· the turned over object is affected with the variable rho in the local space of names.
Important:
In the control s_commande, the key words should not contain of white space:
“rho=MASSE_VOLUMIQUE (7800.0) “is a valid Python instruction.
A white space in “rho=MASSE VOLUMINAL (7800.0)” would generate an error with
interpretation.
In the dictionary of the key words the character strings used for the keys, must obey
writing rules of an identifier Python: no white space.
4.1.2 The organization of the factory in files
The organization in files, presented below, described that which is used for the graphic interface
Eficas and for the supervisor. It also describes the procedure of loading of the command set
in the memory starting from provided information ­ in the command file - by the user
final.
The files all ­ of scripts Python - must be defined in the following order:
1) MCSIMP. py
2) SIMP.py
3) dictio.py: the dictionary of key words MASSE_VOLUMIQUE and FICHIER_MAILLAGE
4) valeurs.py: the file of the values provided by the end-user (for Aster, the file of
controls user)
5) main.py: the code charging the values provided by the end-user while reading and interpreting
the file valeurs.py (for Aster the executable one, also interpreter
python: aster.exe)
Let us recall that the definition of class MCSIMP must be carried out before that of class SIMP. It
who leads to an organization starting with the definition of class MCSIMP.
# MCSIMP.py script
class MCSIMP:
def __init__ (coil, definition, valley, parent=None):
assert (definition. __class__. __name__==' SIMP')
self.definition = definition
assert (standard (valley).__name__==definition.type)
self.val = valley
self.parent =None
return
background image
Code_Aster
®
Version
6.4
Titrate:
Code_Aster: the maintenance of Eficas and the supervisor
Date:
02/04/04
Author (S):
C. CAREMOLI, A. YESSAYAN
Key
:
D9.02.01-A
Page
:
21/34
Data-processing manual of Description
D9.02 booklet: - HT-66/04/003/A
The attribute self.parent useless here, will be used when the key word is defined inside one
order. It will then contain a reference on this control.
The developer of Accas can then define class SIMP.
# SIMP.py script
importation MCSIMP
importation standards
class SIMP:
def __init__ (coil, name, type):
self.nom = name
self.type =type
def __call__ (coil, valley, parent=None):
assert (str (standard (valley))== " <type '“+self.type+” '>”)
return MCSIMP.MCSIMP (definition=self, val=val, parent=parent)

Once two modules SIMP and MCSIMP placed at its disposal, the developer of functionalities
numerical of the code can now define a “applicatif catalog of key words 'in the file
dictio.py. This script defines in a dictionary python, description (standard, possible values,
field of definition,…) values associated with the key word with kind to allow the reading of these
values.
For example:
# script dictio.py
from SIMP importation SIMP
dict= {“MASSE_VOLUMIQUE”:SIMP (nom=' MASS VOLUMIQUE', type=' float',
“FICHIER_MAILLAGE”:SIMP (nom= `FILE MAILLAGE', type=' string')}

And the end-user can finally use the functionalities by providing a script, for example
valeurs.py.

# script valeurs.py
rho=MASSE_VOLUMIQUE (7800.0)
mail=FICHIER_MAILLAGE (“maillage.d')
background image
Code_Aster
®
Version
6.4
Titrate:
Code_Aster: the maintenance of Eficas and the supervisor
Date:
02/04/04
Author (S):
C. CAREMOLI, A. YESSAYAN
Key
:
D9.02.01-A
Page
:
22/34
Data-processing manual of Description
D9.02 booklet: - HT-66/04/003/A
To charge in memory the data provided by the user, the code will read the command file
as follows:

# script main.py
from SIMP importation *
d_context= {“MASSE_VOLUMIQUE”:SIMP (nom=' MASS VOLUMIQUE', type=' float'),
“FICHIER_MAILLAGE”:SIMP (nom=' FILE MAILLAGE', type=' string')}
nom_script_valeurs = “valeurs.py”
f=open (nom_script_valeurs, “R”)
string_parametres = f.read ()
f.close ()
exec string_parametres in d_context, locals ()
print rho, rho.definition.nom, rho.val

To charge in memory, the value associated with a simple key word, should be interpreted script python ­
text of the key words simple and value (S) associated (S) provided by the end-user - in space with names (it
dictionary d_context) of the key word.

4.2
Example 2: a factory to build a control
In practice, the key words are not separately but obligatorily defined inside one
order. What complicates the process of construction of the key words in the memory. Us
let us present a ­ example now always simplified ­ intended to facilitate the comprehension of it
process.
For that we will consider that a command set is a list of controls of the type
“procedure” and that each control is parameterized by simple key words and only by
simple key words (not of conditional block, not of put-key factor). This simplification increases
legibility while preserving all the categories of difficulties of facing to charge the play of
order in memory.
One thus starts by adding a factory controls of the type PROC_ETAPE.
background image
Code_Aster
®
Version
6.4
Titrate:
Code_Aster: the maintenance of Eficas and the supervisor
Date:
02/04/04
Author (S):
C. CAREMOLI, A. YESSAYAN
Key
:
D9.02.01-A
Page
:
23/34
Data-processing manual of Description
D9.02 booklet: - HT-66/04/003/A
4.2.1 Addition of classes PROC and PROC_ETAPE with the factory
The class PROC_ETAPE which modelizes an ordering of type “procedure”, is very close to
classify MCSIMP. So much so that both could inherit a class common mother (it is
moreover the case in Accas).
# PROC_ETAPE.py script
print “\ tImport of “+__name__
class PROC_ETAPE:
def __init__ (coil, definition, args= {}):
print 2 * '\ t'+ " PROC_ETAPE __init__: creation of an object “+ \
coil. __class__. __name__
print 3 * “\ t'+' PROC_ETAPE __init__: definition.nom=”, definition.nom
print 3 * “\ t'+' PROC_ETAPE __init__: args=”, args
assert (definition. __class__. __name__==' PROC')
self.definition = definition
self.valor = args
return
An object PROC_ETAPE is manufactured by an object of the type PROC. Its attribute self.definition is
a reference on the object PROC which created it.
# PROC.py script
print “\ tImport of “+__name__
importation PROC_ETAPE
from SIMP importation *
class PROC:
def __init__ (coil, name, COp, ** args):
print 1 * '\ t'+ " PROC __init__: creation of an object “+ \
coil. __class__. __name__
print 2 * “\ t'+' PROC __init__: nom=”, name
print 2 * “\ t'+' PROC __init__: args=”, args
self.nom = name # text of the control
self.entites = args # dictionary of the manufacturers
self.op = COp # number of operator FORTRAN
return
def __call__ (coil, ** args):
#
args
contains
definition
values
MCSIMP
(MASSE_VOLUMIQUE,
# FICHIER_MAILLAGE)
print 1 * “\ t'+' PROC __call__: args=”, args
print 1 * “\ t'+' PROC __call__: self.entites=”, self.entites
# construction of the simple key words of the control and addition in
# the dictionary of the key words of control PROC in the course of
# construction
dict = {}
for K, v in args.items ():
dict [K] = self.entites [K] (val=v, parent=self)
print 1 * “\ t'+' PROC __call__: dict=”, dict
return PROC_ETAPE.PROC_ETAPE (coil, dict)
background image
Code_Aster
®
Version
6.4
Titrate:
Code_Aster: the maintenance of Eficas and the supervisor
Date:
02/04/04
Author (S):
C. CAREMOLI, A. YESSAYAN
Key
:
D9.02.01-A
Page
:
24/34
Data-processing manual of Description
D9.02 booklet: - HT-66/04/003/A
During its creation carried out starting from the catalog, object PROC memorizes in the dictionary
self.entites, the composition of the control in simple key words; this information will be
used in the second time ­ to build the simple key words of the control ­ when
object PROC will be called upon via its method __call__.
It is also the method __call__ which will initialize the key words located inside the control with
the values provided in the command file (module SIMP is exactly that presented in
the first example).
4.2.2 Concept of catalog of controls
In the first example ([§4.1]), the description of the key words was made in the dictionary (space
names) d_context. But to facilitate the task of the developers of Code_Aster, it is preferable
to describe the controls and their contents via a script Python then to convert it
script in a dictionary which will be used as space of names for the loading of the controls.
For our second example, the catalog can be written thus;
# script cata.py
print 1 * '\ t'+ " Importation of “+__name__

from SIMP importation *
from PROC importation *

AFFE_MATERIAU=PROC (nom=' AFFE_MATERIAU',
op=10,
MASSE_VOLUMIQUE=SIMP (nom= " DENSITY ", type=' float'),
FICHIER_MAILLAGE=SIMP (nom= " FILE MESH ", type=' string'))
This catalog contains only one control: AFFE_MATERIAU of which the use will start the call to
routine FORTRAN op0010. This routine will use two parameters MASSE_VOLUMIQUE and
FICHIER_MAILLAGE
The conversion of the catalog into a dictionary is done into important simply the catalog in one
space names. What does the following sequence:
d_context= {}
string_cata= " from cata importation * “
exec string_cata in d_context
4.2.3 Concept of command file
The command file is him also a script Python, very simple intended to be interpreted in
the space of names of the catalog of controls. For example:
# script commandes.py
AFFE_MATERIAU (MASSE_VOLUMIQUE=7800.0, FICHIER_MAILLAGE= " maillage.unv ")
background image
Code_Aster
®
Version
6.4
Titrate:
Code_Aster: the maintenance of Eficas and the supervisor
Date:
02/04/04
Author (S):
C. CAREMOLI, A. YESSAYAN
Key
:
D9.02.01-A
Page
:
25/34
Data-processing manual of Description
D9.02 booklet: - HT-66/04/003/A
In script commandes.py above, the end-user asks for the execution of routine FORTRAN
op0010 with MASSE_VOLUMIQUE=7800.0 and FICHIER_MAILLAGE= " maillage.unv ". He is
interpreted by the following sequence:
f_commandes=open (“commandes.py”, “R”)
string_commandes = f_commandes.read ()
f_commandes.close ()
exec string_commandes in d_context
At the end of which the command set (here reduced to only control AFFE_MATERIAU) is defined
in the space of names d_context.
4.2.4 Use
catalog
and of the command file
Following Python script carries out the loading of the catalog, the loading of the command file
and the examination of the command set in the memory.
# script main.py
importation traceback
trace=traceback.extract_stack ()
script_file=trace [0] [0]
prefixe=script_file+': '
print prefixe+ " BEGINNING of “, script_file
d_context= {}
# 1. Loading of the catalog
# Creation - into important the catalog cata - of a space of being useful name
# for the interpretation of the command set
print 3 * '\ n'+prefixe+ " importation of the catalog "
string_cata= " from cata importation * “
exec string_cata in d_context
# 2. Loading of the text of the controls
# Reading of the command file (the text of the controls east stores in
one
# channels of caratères)
print 3 * '\ n'+prefixe+ " reading of the text of the controls "
f_commandes=open (“commandes.py”, “R”)
string_commandes = f_commandes.read ()
f_commandes.close ()
# 3. Creation of the command set
# Interpretation of the text of the control in the d_contexte of the catalog.
structure
# command set, produced, is stored in the space of name d_context
print 3 * '\ n'+prefixe+ \
“Conversion of the text of the controls (string) into a command set
(d_context) “
exec string_commandes in d_context
# 4. Course of the structure command set in the d_contexte
print 3 * '\ n'+prefixe+ " Display of the command set "
importation standards
for K, v in d_context.items ():
yew
type (v) ==types.InstanceType
and
v. __class__. __name__==
“PROC_ETAPE”:
background image
Code_Aster
®
Version
6.4
Titrate:
Code_Aster: the maintenance of Eficas and the supervisor
Date:
02/04/04
Author (S):
C. CAREMOLI, A. YESSAYAN
Key
:
D9.02.01-A
Page
:
26/34
Data-processing manual of Description
D9.02 booklet: - HT-66/04/003/A
# if the attribute is a control, one examines his value
# i.e. its key words
print 1 * “\ t'+v.definition.nom+” \ t'+str (v. __class__)
for kk, vv in v.valeur.items ():
print 2 * “\ t'+kk,”: “, vv,” \ you, vv.val
print 2 * “\
print prefixe+ " FINE NORMAL of ", script_file

4.3
The file catalogs
4.3.1 Catalog of a control
The catalog of a control contains the description of the control. Each control is one
authority of class OPER, PROC or MACRO
Attribute Description
name
name of the control (character string without white space)
COp
number of operator FORTRAN: entirety ranging between 1 and 199
sd_prod
type of the result, for the controls of the type OPER
regulate
list rules of composition of the control
Fr
French comment
Doc.
reference of documentation Aster
reentrant
repetable
entities
Composition of the control: arguments containing the description of the key words
used to provide values to the key words of the control
Example
ASSE_MAILLAGE=OPER (nom=' ASSE_MAILLAGE', op= 105, sd_prod=maillage,
fr=' To assemble two mesh under only one nom',
docu=' U4.23.03-e', reentrant=',
MESH =SIMP (statut=' o', typ=maillage, min=2, max=2),
);

In this example, drawn from the true catalog of controls of Code_Aster:
· the described control is called ASSE_MAILLAGE;
· it makes it possible to start operator FORTRAN op0105;
· it turns over a data of the mesh type; this type is defined in the beginning of catalog
cata.py;
· the use of operator FORTRAN op0105 requires obligatorily, the supply of 2 data
of mesh type
background image
Code_Aster
®
Version
6.4
Titrate:
Code_Aster: the maintenance of Eficas and the supervisor
Date:
02/04/04
Author (S):
C. CAREMOLI, A. YESSAYAN
Key
:
D9.02.01-A
Page
:
27/34
Data-processing manual of Description
D9.02 booklet: - HT-66/04/003/A
4.3.2 General structure of the file catalogs
The file catalogs controls of Code_Aster ­ the module $TOP/Aster/Cata/cata.py -
contains following information:
· importation of all information of the module Accas, in particular Accas.A_ASSD.ASSD
· statement of the types deriving from the generic type Accas.A_ASSD.ASSD, used to typify them
values of the key words or the values turned over by the controls; for example types:
- entirety, reality, complex, list, channels;
- the geometrical ones, No (node), groupno, my (mesh), groupma;
- mesh, model, MATER
- etc
· the list of the catalogs of the controls i.e. the description of all the controls,
with for each control
4.4
Installation of the catalog in the memory
It is important to remember that a reference on the catalog running is stored in the module
whose reference is stored in CONTEXT. Reference CONTEXT is itself defined in
the total space of names __builtin__
A reference on the catalog running is obtained by:
CONTEXT.get_current_cata ()
background image
Code_Aster
®
Version
6.4
Titrate:
Code_Aster: the maintenance of Eficas and the supervisor
Date:
02/04/04
Author (S):
C. CAREMOLI, A. YESSAYAN
Key
:
D9.02.01-A
Page
:
28/34
Data-processing manual of Description
D9.02 booklet: - HT-66/04/003/A
4.4.1 The structure of data in the package Core
The following classes have as a role to store the command set in the memory and to restore
value of the key words to the request.
OBJECT
get_val ():type_de_base
get_etape ():STAGE
MCSIMP
get_val ():type_de_base
JDC
get_etape ():STAGE
MCFACT
get_val ():OBJECT
MCBLOC
get_val ():OBJECT
MCCOMPO
get_mocle (key):OBJECT
STAGE
get_etape ():STAGE
PROC_ETAPE
MACRO_ETAPE
FORM_ETAPE
background image
Code_Aster
®
Version
6.4
Titrate:
Code_Aster: the maintenance of Eficas and the supervisor
Date:
02/04/04
Author (S):
C. CAREMOLI, A. YESSAYAN
Key
:
D9.02.01-A
Page
:
29/34
Data-processing manual of Description
D9.02 booklet: - HT-66/04/003/A
The whole of the classes presented below take part in the loading of the command set in
memory. They inherit all the abstract class ENTITY. And their main function is
method __call__ which ensures the role of factory (factory) of object.

















































ENTITY
__call__ (valley, name, relative):OBJECT
SIMP
__call__ (valley, name, relative):MCSIMP
FACT
__call__ (valley, name, relative):MCFACT
BLOCK
__call__ (valley, name, relative):MCBLOC
PROC
__call__ (** args):PROC_ETAPE
OPER
__call__ (reuse, ** args):STAGE
JDC_CATA
__call__ (procedure, cata, cata_ord_dico,
name, relative, ** args):JDC
MACRO
__call__ (reuse, ** args):MACRO_ETAPE
FORM
__call__ (reuse, ** args):FORM_ETAPE
background image
Code_Aster
®
Version
6.4
Titrate:
Code_Aster: the maintenance of Eficas and the supervisor
Date:
02/04/04
Author (S):
C. CAREMOLI, A. YESSAYAN
Key
:
D9.02.01-A
Page
:
30/34
Data-processing manual of Description
D9.02 booklet: - HT-66/04/003/A
4.4.2 The Accas package
The Accas package is the main package used by the supervisor of Code_Aster and the interface
Eficas graph. It contains the modules corresponding to the classes obtained by assembly
(use of the multiple heritage) of the classes of the other packages.

Class MCSIMP





























The objects of class MCSIMP are built with the manufacturer of class A_MCSIMP.MCSIMP.
The diagram above represents the main contribution of each package to the functionalities of
class MCSIMP
The method get_val () is used by the supervisor to recover the value of the simple key word and
to turn over to the operator of Code_Aster which requires it.
N_MCSIMP.MCSIMP
__init__ (valley, definition, name, relative)
get_val ():type_de_base
V_MCSIMP.MCSIMP
isvalid ():Boolean
I_MCSIMP.MCSIMP
GetText ():string
A_MCSIMP.MCSIMP
__init__ (valley, definition, name, relative)
V_OBJECT.OBJECT
I_OBJECT.OBJECT
N_OBJECT.OBJECT
background image
Code_Aster
®
Version
6.4
Titrate:
Code_Aster: the maintenance of Eficas and the supervisor
Date:
02/04/04
Author (S):
C. CAREMOLI, A. YESSAYAN
Key
:
D9.02.01-A
Page
:
31/34
Data-processing manual of Description
D9.02 booklet: - HT-66/04/003/A
Class MCCOMPO
The class MCCOMPO ­ which modelizes a composite OBJECT - does not exist in the Accas package but
it is important because it is used as a basis for classes MCFACT, MCBLOC.
















The diagram above highlights behaviors justifying the existence of class MCCOMPO.
· the method build_mc () in the package Core: it builds the objects located inside
OBJECT;
· the method carryforward () which turns over the report/ratio of validation by applying the method isvalid () to
all OBJECT located in the MCCOMPO.
V_OBJECT.OBJECT
I_OBJECT.OBJECT
N_OBJECT.OBJECT
V_MCCOMPO.MCCOMPO
carryforward ():string
I_MCCOMPO.MCSIMP
getlabeltext ():string
N_MCCOMPO.MCCOMPO
build_mc ():type_de_base
background image
Code_Aster
®
Version
6.4
Titrate:
Code_Aster: the maintenance of Eficas and the supervisor
Date:
02/04/04
Author (S):
C. CAREMOLI, A. YESSAYAN
Key
:
D9.02.01-A
Page
:
32/34
Data-processing manual of Description
D9.02 booklet: - HT-66/04/003/A
5
The macro-controls Python
Summary description of the nature of the macro-controls:
· A Python macro-control can produce one or more results (called concepts) then
that the simple controls produce zero (control of the type PROC) or a result
(ordering of type OPER);
· A macro-control has parameters like an ordinary control; it is
key words factors and of the simple key words;
· The main concept produced by macro is turned over by the macro one while the concepts
secondary products are arguments modified by the macro one;
· The secondary produced concepts must be typified: that is done via one
function provided by the developer of macro via the argument sd_prod of
the macro one;
· The body of the macro-control is fascinating a Python function charges of it the processing which
the call to other controls includes (or even with other macro-controls).
To define a macro-control, its developer must thus define:
· key words of the control;
· the type of the produced concepts;
· the body of the macro-control.

6 Some
questions
6.1
How to know which file catalog is used by a calculation?
The situation is as follows:
· a calculation was carried out with Code_Aster;
· several files of catalog of the controls are present in the environment;
· the user ­ or the developer ­ wants to know that which is actually used.
A solution can be as follows:
· to import the catalog in the command file, for example in ahlv100a. COM;
· to insert in the command file the following sequence which:
- the catalog imports,
- writing the reference of the catalog on the standard exit,
- the processing stops.
importation cata, sys
print “ahlv100a. COM:cata=”, cata
sys.exit (0)
With this sequence, one obtains a result of the following style:
cata=<module “cata” from '/home/Salome/yessayan/Devel/Asterv7/bibpyt/Cata/cata.pyc'>
From where it is deduced that the catalog used can be in the file:
/home/Salome/yessayan/Devel/Asterv7/bibpyt/Cata/cata.py
background image
Code_Aster
®
Version
6.4
Titrate:
Code_Aster: the maintenance of Eficas and the supervisor
Date:
02/04/04
Author (S):
C. CAREMOLI, A. YESSAYAN
Key
:
D9.02.01-A
Page
:
33/34
Data-processing manual of Description
D9.02 booklet: - HT-66/04/003/A
6.2
How mode DEBUG is managed?
In Eficas and the supervisor - in fact, in any script Python - mode DEBUG is managed via one
standard variable defined in the total space of names __builtin__: __debug__. In mode
normal of interpretation (python main.py), __debug__ is put at 1 (in main.pyc) but in
mode optimized (python ­ O main.py) __debug__ is put at 0 (in main.pyo)
At any moment, in all the modules, the variable __debug__ can be used to condition it
processing.
6.3
Where the catalog of control is it charged in the memory
That it is in the supervisor or the graphic interface Eficas, JdC, the Python object containing it
catalog is created in module cata Cata package. More exactly, JdC is created at the time
where the module cata is imported: the importation is carried out in the method imports class SUPERV
modulate Execution/E_SUPERV. After the importation, the JdC object contains ­ in its attribute controls,
of list type - the definition of all the controls available like that of all the key words
associated each control.
6.3.1 Creation of the JdC object
At the beginning of script cata.py, JdC is declared by the instruction:
JdC = JDC_CATA (code=' ASTER',
execmodul=None,
rules = (AU_MOINS_UN (“BEGINNING”, “CONTINUATION”),
AU_MOINS_UN (“FINE”),
A_CLASSER ((“BEGINNING”, “CONTINUATION”), “END”)))

This instruction calls mainly upon the method __init__ class
N_JDC_CATA.JDC_CATA (package Core). In this method, the JdC object created is recorded in
total space __builtins__, via the variable _cata in module CONTEXT:
__builtins__ [“CONTEXT”]._cata.
A reference on the catalog running is always available in L `total space of names
__builtins__.
6.3.2 Loading of the entities of the catalog in the JdC object
After creation the loading is always carried out at the time of the importation of the catalog in
method imports, by creating objects of the types
· OPER:
· PROC:
· MACRO:
6.4
Where the command set is carried out by the supervisor?
The command set J (object of the Accas.A_JDC.JDC type) is carried out in the Execute method
class SUPERV in module E_SUPERV of the package Execution.
background image
Code_Aster
®
Version
6.4
Titrate:
Code_Aster: the maintenance of Eficas and the supervisor
Date:
02/04/04
Author (S):
C. CAREMOLI, A. YESSAYAN
Key
:
D9.02.01-A
Page
:
34/34
Data-processing manual of Description
D9.02 booklet: - HT-66/04/003/A
Two cases are possible:
· In mode PAR_LOT=' OUI' (in script the attribute j.par_lot of the command set is
positioned with “YES”), the processing is carried out by the call
j.exec_compile ();
· In mode PAR_LOT=' NON' (in script the attribute j.par_lot of the command set is
positioned with “NOT”), the processing is carried out by the call
ier= self.ParLotMixte (J).
6.5
With what is used the key word _F used in the command file?
Into the command file, a key word factor is introduced by the character string _F. In fact
this character string is a name of class which deals with creation in memory of
dictionary corresponding to the key word factor starting from a description using the equal sign “=” and
brackets rather than the two points “:” and the accodances which it would be necessary to use with one
dictionary standard Python.
For example:
ELAS=_F (E = 2.1E11, NAKED = 0.3, ALPHA = 1.E-5, RHO = 8000.)
is equivalent to:
ELAS= {E: 2.1E11, NAKED: 0.3, ALPHA: 1.E-5, RHO: 8000.}
This presentation is more adapted to the wishes of the end-users and the tradition of
process control language of Code_Aster.
6.6 Where
the interface
getvxx of the command set find-such?
The methods getvxx belong to the class STAGE defined in module B_ETAPE of the package
Build.


7 Bibliography
[1]
Introduction to Python, Lutz Mark & David Ascher, O' REILLY, Paris, 2001
[2]
Python, Essential Reference, David Mr. Beazley, New Riders, 2001
[3]
Python 2.1 Bible, Dave Brueck & Stephen To tan, 2001