1. Introduction and precautions for use#
In Code_Aster, most commands are programmed in Fortran. The data structures produced are only accessible through the JEVEUX memory manager, which is itself written in Fortran. In a standard code execution, only the names of the concepts (and not of the objects themselves carrying the calculated information) are transmitted to the supervisor level, from command to command using the keywords.
In a more advanced use of Python than simply declaring Code_Aster commands, the command file written in Python can use the content of data structures specific to Code_Aster. Indeed, Python can be used in command files to create macro commands and operations such as loops (for, while,…), tests (if,…), external command executions (via the os module), etc… The « Usage/Examples/Examples of using Python in Aster » page on the website www.code‑aster.org contains a number of application cases. It is then interesting for the user to retrieve the product of Fortran calculations in Python space, i.e. his command file. Several Python methods have been developed in order to access the content of other data structures.
To recover calculated data (in memory JEVEUX), it is absolutely necessary that the instructions causing them to be obtained have been executed beforehand. In other words, it is essential to execute the code in mode PAR_LOT =” NON “(command keyword DEBUT or POURSUITE). Indeed, in this case, there is no global analysis of the command file, but each instruction is executed sequentially. When we arrive at an instruction, all the concepts preceding it have therefore already been calculated.
DEBUT (PAR_LOT = 'NON')
It should then be noted that the command file thus produced is not readable by EFICAS which only tolerates files composed exclusively of commands specific to Code_Aster. Only simple variables (real, integer, string) defined in declarative \(a\mathrm{=}’\mathit{toto}’\) or algebraic \(n=3+4\) mode are readable by EFICAS.
The information read in memory JEVEUX, the product of a prior calculation, can be used for example to (non-exhaustive list):
Conditionally chain other commands (execution of a while loop until a calculated limit constraint value is obtained)
Manipulate the content of a table or a function in Python for calculation purposes
Retrieve the attributes of a mesh: list of groups of nodes and meshes, coordinates.