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
Organization (S): EDF-R & D/SINETICS
Handbook of Descriptif Informatique
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.
Handbook of Descriptif Informatique
D9.02 booklet: - HT-66/04/003/A
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
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 repertories 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 Python language 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 Python command 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 commands 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 command .............................................................. 22
4.2.1 Addition of classes PROC and PROC_ETAPE with the factory ......................................................... 23
4.2.2 Concept of catalog of commands .................................................................................... 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 command ................................................................................................. 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 Noyau ................................................................ 28
4.4.2 The package Accas ................................................................................................................ 30
The 5 macro-commands Python ........................................................................................................... 32
Handbook of Descriptif Informatique
D9.02 booklet: - HT-66/04/003/A
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
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 command 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
Handbook of Descriptif Informatique
D9.02 booklet: - HT-66/04/003/A
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
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 command. A command 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 command otherwise-known as them
parameters of the digital processing, are data introduced by means of key words them
identifier. For a given command, a certain number of parameters must be defined.
The description of the commands and the key words is carried out by the developers of Code_Aster.
in a file called “catalogs commands”.
The end-user uses the code via a file called “command file”. He provides to it
commands whose composition must be compatible with their description in the catalog of
commands. The commands are numerous but the number of associated data is much
more important with possible combinations themselves very many.
Finally the computer code stores information (commands 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 commands in the Python memory,
· it charges the commands and their key words in the Python memory,
· it carries out the processing orders by command,
· it provides - at the request of FORTRAN the value of the parameters to the functionalities of
Code_Aster. stored in the Python memory. For that the supervisor proposes a 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 commands 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 commands 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 “Noyau”. The comprehension of these sources is obviously a condition necessary for
to undertake the maintenance of the two tools which use them.
Handbook of Descriptif Informatique
D9.02 booklet: - HT-66/04/003/A
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
Principal actors
The principal 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-command,
the drafting of corresponding Python script; it enriches and/or modifies the catalog of
order and it uses the 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 commands and command set; it is also occupied
module python aster written out of C (astermodule.c) which is used 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 commands, 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 repertories:
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 command 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.
Handbook of Descriptif Informatique
D9.02 booklet: - HT-66/04/003/A
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
1.1 Definitions
Mode “by batch”
The treatment of the commands user by Code_Aster can be carried out according to two
modes.
In the first mode, the file command 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
correspondents.
This first mode is called “mode by batch”. The end-user selects this mode while specifying
value “OUI” for key word PAR_LOT under command DEBUT.
In the second mode, the command file is charged in memory to create the play of
commands. Then the stages (equivalent to the commands) are built and carried out
sequentially.
The end-user selects this mode by specifying value “NON” for key word PAR_LOT under
order DEBUT.
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 grid 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 (command).
Order
A command 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 commands: OPER, PROC, MACRO and FORMULE.
The developer of the numerical operator defines - in the catalog of the command -
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 handbook 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 Aster data produced by the operator and turned over by
order;
Handbook of Descriptif Informatique
D9.02 booklet: - HT-66/04/003/A
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
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 command
Macro is a function written in Python by the Aster developer - which calls commands
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 type MACRO 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 command
The catalog of a command is the whole of the Python instructions describing the definition of
order i.e. the values assigned to the attributes of the command.
The catalog of a command 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 commands
otherwise-known as containing the catalogs of all the commands.
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 commands.
Structure of Aster data
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.
Handbook of Descriptif Informatique
D9.02 booklet: - HT-66/04/003/A
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
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 command 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 command 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 commands. Then it charges (and checks) possibly the value of
parameter of the command 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 command. A command
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 command 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 handbook and the chapter devoted to this key word in the documentation of
Code_Aster.
Handbook of Descriptif Informatique
D9.02 booklet: - HT-66/04/003/A
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
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 command, 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 command 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 commands 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.
EXCLUS
Rule EXCLUS expresses that 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.
ENSEMBLE
Rule ENSEMBLE 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.
Handbook of Descriptif Informatique
D9.02 booklet: - HT-66/04/003/A
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
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 commands: 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 zones of codes concerned)
must be considered;
· To examine Python scripts or the sources C brought into play at the time of requests of
modification 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 (Noyau, Execution, Validation, Build and
Accas) only one class is defined by module i.e. by file * .py;
· in the packages used by the supervisor (Noyau, Execution, Validation, Build and
Accas) the name of each module starts with a prefix indicating the name of the package.
- N_ for Noyau
- V_ for Validation
- E_ for Execution
- B_ for Build
- A_ for Accas
Handbook of Descriptif Informatique
D9.02 booklet: - HT-66/04/003/A
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
2.2
Typology of the Python modules
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 (Noyau) 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 (commands,
conditional blocks, key words,…).
Build This package is present only in the supervisor contains the modules treating the commands
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 commands:
· 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 Noyau 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.
Handbook of Descriptif Informatique
D9.02 booklet: - HT-66/04/003/A
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
2.3
Hierarchy of the repertories 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 repertories containing the Python sources of the supervisor.
Eficas
Core
Accas
Validation
Build
Execution
Macro
Handbook of Descriptif Informatique
D9.02 booklet: - HT-66/04/003/A
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
2.3.2 Sources of the Eficas interface-graph
The sources are organized in repertories under the repertory of Eficas installation:
Eficas
Core
Accas
Validation
Editor
Ihm
Extensio
Macro
Misc
Tools
2.4 Environment
This paragraph describes the pre-necessary conditions with the operation of Superviseur and the interface
Eficas graph.
2.4.1 Installation of the Python interpreter
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
Handbook of Descriptif Informatique
D9.02 booklet: - HT-66/04/003/A
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
3
Use of the Python language 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 output:
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 Python module, 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.
Handbook of Descriptif Informatique
D9.02 booklet: - HT-66/04/003/A
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
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 Noyau script/__init__.py.
3.2.3 Execution of a Python command 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
Handbook of Descriptif Informatique
D9.02 booklet: - HT-66/04/003/A
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
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 (Editeur packages 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.
Handbook of Descriptif Informatique
D9.02 booklet: - HT-66/04/003/A
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
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 commands of
Code_Aster then displays on the standard output the name of each command.
importation sys
Local TOP='//yessayan/Eficas/EficasPourSalome' # repertory of installation
sys.path.append (TOP)
sys.path.append (TOP+'/Aster')
from Cata importation cata
for command in cata.JdC.commandes:
print commande.nom
It can be written:
importation sys
Local TOP='//yessayan/Eficas/EficasPourSalome'
sys.path.append (TOP)
sys.path.append (TOP+'/Aster')
package=__import__ (“Cata.cata”)
module_cata= getattr (package, “cata”)
for command 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 command __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
Handbook of Descriptif Informatique
D9.02 booklet: - HT-66/04/003/A
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
4
The general catalog of the commands 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,… Dans
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 principal role of an object of the type MCSIMP is to wrap the value of a simple key word
otherwise-known as the principal attribute of an object of the type MCSIMP is a value;
· an object of the type SIMP has two principal 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).
Handbook of Descriptif Informatique
D9.02 booklet: - HT-66/04/003/A
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
# 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=' MASSE VOLUMIQUE', type=' float'),
“FICHIER_MAILLAGE”: SIMP (nom=' FICHIER 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 (“FIN NORMALE 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 GRID
maillage.d
Let us consider the lines
s_commande = “rho=MASSE_VOLUMIQUE (7800.0)”
exec s_commande in d_context, locals ()
Handbook of Descriptif Informatique
D9.02 booklet: - HT-66/04/003/A
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
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 command becomes:
rho=SIMP (nom=' MASSE VOLUMIQUE', type=' float') (7800.0)
then it is carried out;
· An object of the type SIMP is built with name “MASSE VOLUMIQUE”;
· 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 command 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 VOLUMIQUE (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 a Python identifier: 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 Python scripts - 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
commands 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
Handbook of Descriptif Informatique
D9.02 booklet: - HT-66/04/003/A
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
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 command.
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=' MASSE VOLUMIQUE', type=' float',
“FICHIER_MAILLAGE”:SIMP (nom= `FICHIER 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')
Handbook of Descriptif Informatique
D9.02 booklet: - HT-66/04/003/A
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
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=' MASSE VOLUMIQUE', type=' float'),
“FICHIER_MAILLAGE”:SIMP (nom=' FICHIER 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 command
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 commands of the type
“procedure” and that each command 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 commands of the type PROC_ETAPE.
Handbook of Descriptif Informatique
D9.02 booklet: - HT-66/04/003/A
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
4.2.1 Addition of classes PROC and PROC_ETAPE with the factory
The class PROC_ETAPE which models 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 command
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 command and addition in
# the dictionary of the key words of command 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)
Handbook of Descriptif Informatique
D9.02 booklet: - HT-66/04/003/A
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
During its creation carried out starting from the catalog, object PROC memorizes in the dictionary
self.entites, the composition of the command in simple key words; this information will be
used in the second time to build the simple key words of the command 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 command 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 commands
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 commands and their contents via a Python script then to convert it
script in a dictionary which will be used as space of names for the loading of the commands.
For our second example, the catalog can be written thus;
# script cata.py
print 1 * '\ t'+ " Import of “+__name__
from SIMP importation *
from PROC importation *
AFFE_MATERIAU=PROC (nom=' AFFE_MATERIAU',
op=10,
MASSE_VOLUMIQUE=SIMP (nom= " MASSE VOLUMIQUE ", type=' float'),
FICHIER_MAILLAGE=SIMP (nom= " FICHIER MAILLAGE ", type=' string'))
This catalog contains only one command: 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 commands. For example:
# script commandes.py
AFFE_MATERIAU (MASSE_VOLUMIQUE=7800.0, FICHIER_MAILLAGE= " maillage.unv ")
Handbook of Descriptif Informatique
D9.02 booklet: - HT-66/04/003/A
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
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 command 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+ " DEBUT 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 commands
# Reading of the command file (the text of the commands east stores in
one
# chains of caratčres)
print 3 * '\ n'+prefixe+ " reading of the text of the commands "
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 command 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 commands (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+ " Affichage of the command set "
importation standards
for K, v in d_context.items ():
yew
type (v) ==types.InstanceType
and
v. __class__. __name__==
“PROC_ETAPE”:
Handbook of Descriptif Informatique
D9.02 booklet: - HT-66/04/003/A
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
# if the attribute is a command, 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+ " FIN NORMALE of ", script_file
4.3
The file catalogs
4.3.1 Catalog of a command
The catalog of a command contains the description of the command. Each command is one
authority of class OPER, PROC or MACRO
Attribute Description
name
name of the command (character string without white space)
COp
number of operator FORTRAN: entirety ranging between 1 and 199
sd_prod
type of the result, for the commands of the type OPER
regulate
list rules of composition of the command
Fr
French comment
Doc.
reference of Aster documentation
reentrant
repetable
entities
Composition of the command: arguments containing the description of the key words
used to provide values to the key words of the command
Example
ASSE_MAILLAGE=OPER (nom=' ASSE_MAILLAGE', op= 105, sd_prod=maillage,
fr=' Assembler two grids under only one nom',
docu=' U4.23.03-e', reentrant=',
MAILLAGE =SIMP (statut=' o', typ=maillage, min=2, max=2),
);
In this example, drawn from the true catalog of commands of Code_Aster:
· the described command is called ASSE_MAILLAGE;
· it makes it possible to start operator FORTRAN op0105;
· it turns over a data of the grid 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 grid type
Handbook of Descriptif Informatique
D9.02 booklet: - HT-66/04/003/A
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
4.3.2 General structure of the file catalogs
The file catalogs commands 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
· declaration 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 commands; for example types:
- entirety, reality, complex, list, chains;
- the geometrical ones, No (node), groupno, my (mesh), groupma;
- grid, model, MATER
- etc
· the list of the catalogs of the commands i.e. the description of all the commands,
with for each command
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 ()
Handbook of Descriptif Informatique
D9.02 booklet: - HT-66/04/003/A
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
4.4.1 The structure of data in the Noyau package
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 ():ETAPE
MCSIMP
JDC
get_val ():type_de_base
get_etape ():ETAPE
MCCOMPO
get_mocle (key):OBJECT
MCFACT
MCBLOC
get_val ():OBJECT
get_val ():OBJECT
ETAPE
get_etape ():ETAPE
PROC_ETAPE
MACRO_ETAPE
FORM_ETAPE
Handbook of Descriptif Informatique
D9.02 booklet: - HT-66/04/003/A
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
The whole of the classes presented below take part in the loading of the command set in
memory. They inherit all abstract class ENTITE. And their principal function is
method __call__ which ensures the role of factory (factory) of object.
ENTITE
__call__ (valley, name, relative):OBJECT
SIMP
PROC
__call__ (valley, name, relative):MCSIMP
__call__ (** args):PROC_ETAPE
FACT
OPER
__call__ (valley, name, relative):MCFACT
__call__ (reuse, ** args):ETAPE
BLOC
JDC_CATA
__call__ (procedure, cata, cata_ord_dico,
__call__ (valley, name, relative):MCBLOC
name, relative, ** args):JDC
MACRO
__call__ (reuse, ** args):MACRO_ETAPE
FORM
__call__ (reuse, ** args):FORM_ETAPE
Handbook of Descriptif Informatique
D9.02 booklet: - HT-66/04/003/A
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
4.4.2 The Accas package
The Accas package is the principal 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
N_OBJECT.OBJECT
V_OBJECT.OBJECT
I_OBJECT.OBJECT
N_MCSIMP.MCSIMP
V_MCSIMP.MCSIMP
I_MCSIMP.MCSIMP
__init__ (valley, definition, name, relative)
get_val ():type_de_base
isvalid ():Boolean
GetText ():string
A_MCSIMP.MCSIMP
__init__ (valley, definition, name, relative)
The objects of class MCSIMP are built with the manufacturer of class A_MCSIMP.MCSIMP.
The diagram above represents the principal 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.
Handbook of Descriptif Informatique
D9.02 booklet: - HT-66/04/003/A
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
Class MCCOMPO
The class MCCOMPO which models 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.
N_OBJECT.OBJECT
V_OBJECT.OBJECT
I_OBJECT.OBJECT
N_MCCOMPO.MCCOMPO
V_MCCOMPO.MCCOMPO
I_MCCOMPO.MCSIMP
build_mc ():type_de_base
carryforward ():string
getlabeltext ():string
The diagram above highlights behaviors justifying the existence of class MCCOMPO.
· the method build_mc () in the Noyau package: 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.
Handbook of Descriptif Informatique
D9.02 booklet: - HT-66/04/003/A
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
5
The Python macro-commands
Summary description of the nature of the macro-commands:
· A Python macro-command can produce one or more results (called concepts) then
that the simple commands produce zero (command of the type PROC) or a result
(ordering of type OPER);
· A macro-command has parameters like an ordinary command; it is
key words factors and of the simple key words;
· The principal 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-command is fascinating a Python function charges of it the processing which
the call to other commands includes (or even with other macro-commands).
To define a macro-command, its developer must thus define:
· key words of the command;
· the type of the produced concepts;
· the body of the macro-command.
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 commands 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 output,
- 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
Handbook of Descriptif Informatique
D9.02 booklet: - HT-66/04/003/A
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
6.2
How mode DEBUG is managed?
In Eficas and the supervisor - in fact, in any Python script - 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 command 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 commands,
of list type - the definition of all the commands available like that of all the key words
associated each command.
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 (“DEBUT”, “POURSUITE”),
AU_MOINS_UN (“FINE”),
A_CLASSER ((“BEGINNING”, “CONTINUATION”), “END”)))
This instruction calls mainly upon the method __init__ class
N_JDC_CATA.JDC_CATA (Noyau package). 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 of
class SUPERV in module E_SUPERV of the Execution package.
Handbook of Descriptif Informatique
D9.02 booklet: - HT-66/04/003/A
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
Two cases are possible:
· In mode PAR_LOT=' OUI' (in script the attribute j.par_lot of the command set is
positioned with “OUI”), 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 “NON”), 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
standard Python dictionary.
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 class ETAPE defined in module B_ETAPE of the package
Build.
7 Bibliography
[1]
Introduction to Python, Mark Lutz & 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
Handbook of Descriptif Informatique
D9.02 booklet: - HT-66/04/003/A
Outline document