Beginning with Salome and Code_Aster for Windows

This post provides a step by step quickstart for beginners. Before to start, a working installation of Salome and Code_Aster on Windows is required, some help can be found in this previous post.

Introduction

The usual way to learn about a new mechanical simulation framework is to do step by step:

  • geometry
  • mesh
  • model and materials
  • run
  • post-processing

Salome + Code_Aster framework is known to be less intuitive comparing to commercial solutions. At the same time, Code_Aster is much better than the latter in term of ease to access documentation, freely available at code-aster.org, and examples (more than 3000), available in the release version. The key point is that each example, available in the release (install\testing\tests\ directory), has an online dedicated validation document.

The step by step way to start with Code_Aster that I propose here is:

  • Pick up an existing case
  • Set up input files
  • Run and analyze results
  • Customize for your needs

Pick up an existing case

Go to the  DOCUMENTATION page, on http://code-aster.org/

Code_Aster documentation page

On the left panel, click on Code_Aster version 13, then testcases by name

FORMAT cases correspond to the official training material. Let’s open the example Practical training in basic use of Code_Aster corresponding to FORMA02:

Code_Aster practical training cases

In this dedicated document, the format02 cases are summarized in the Reference problem section:

Code_Aster document example: Reference problem

And the particular case format02a is described in the Modelization A section:

Code_Aster document example: Modelization A

It is possible to verify that the case forma02a runs successfully in the installed version. Navigate into the Code_Aster installation directory and launch:

install\bin\as_run.bat --test forma02a

Launch as_run.bat to run forma02a testcase on Code_Aster for Windows 6-bit

At the end of the run, cmd console should display:

DIAGNOSTIC JOB : OK

Code_Aster testcase forma02a ended successfully on Windows 7 64-bit

Set up input files

Copy and past the forma01a files from install\testing\tests into a dedicated working directory forma02:

  • forma02a.mmed
  • forma02a.comm
  • forma02a.export

Copy Code_Aster input files from the Code_Aster for Windows 64-bit installation directory to a Windows working directory

The “mmed” file

Binary file containing the mesh of the model : nodes, elements and groups. It is possible to open it using Salome for Windows.

Launch Salome and create a new document. Then open the mesh module.

Launch Salome_Meca on Windows 64-bit and open Mesh Module

It is then possible to import a mmed file by selecting in the menu, File -> Import -> MED file. Go to the dedicated directory forma02 and open forma02a.mmed.

Open a Code_Aster med file with Salome_Meca on Windows 7 64-bit

Click on the eye to show the mesh, the scale button may also be helpful.

Salome_Meca Mesh module running on Windows 7 64-bit

On the left, the object browser allows to navigate into the opened mesh.

Salome_Meca Mesh module ObjectBrowser usage on Windows 7 64-bit

The “comm” file

Contains all Code_Aster operator calls, that will be interpreted and executed sequentially by the code aster executable. It also use Python syntax. Let’s open forma02a.comm to have an overview on some operators.

DEBUT(CODE=_F(NIV_PUB_WEB='INTERNET'),DEBUG=_F(SDVERI='OUI'));

DEBUT is used to start with the command file

MAIL=LIRE_MAILLAGE(FORMAT='MED',);

LIRE_MAILLAGE will read the mesh file forma02.mmed

TEMPE=THER_LINEAIRE(MODELE=MODTH,
                    CHAM_MATER=CHMATER,
                    EXCIT=_F(CHARGE=CHARTH,
                             FONC_MULT=F_MULT,),
                    INCREMENT=_F(LIST_INST=LINST,),
                    ETAT_INIT=_F(VALE=20,),);

THER_LINEAIRE resolve a linear thermal problem.

RESU=MECA_STATIQUE(MODELE=MODMECA,
                   CHAM_MATER=CHMECATH,
                   EXCIT=_F(CHARGE=CHMECA,),
                   LIST_INST=LINST,);

MECA_STATIQUE resolve a linear mechanic problem. Since the chaining with THER_LINEAIRE, one can notice a thermo-mechanic case.

IMPR_RESU(FORMAT='MED',
          RESU=(_F(MAILLAGE=MAIL,
                   RESULTAT=RESU,),
                _F(RESULTAT=TEMPE,),),);

IMPR_RESU write the results in forma02a.rmed

FIN();

FIN is used to ends with the command file.

The “export” file

Contains some parameters used for the code aster launch, like time, memory, … and also the input/output files. Let’s open it to do some modifications:

Set up a Code_Aster export file for Windows 64-bit

The parameters “time_limit” and “memory limit” are used for validation, we should replace them by “tpmax” and “memjeveux” (with a factor 8 i.e 512 -> 64.0) respectively.

The input/output files are defined as follow: the first letter “F” means we are dealing with a file (it is possible to define a directory as “D”), then the type of file (comm or mmed …), then the file name (or directory name), then the letter “D” means data (or “R” means result), and finally the number at the end of a line correspond to the Fortran unit. Input file “datg” is useless,  let’s remove it and add outputs “mess”, “resu” and “rmed”. The “mess” file (message) will contain the log of the run, also printed in the stdout in case of interactive run. The “rmed” file forma02a.rmed will be a med binary file, containing the results of the run. It will be possible to open it using Salome for Windows.

Add “version testing” to tell as_run we want to use testing version, and “action make_etude” means that as_run should run the study.

Finally the export file should look like this:

A tpmax 60.0
A memjeveux 64.0
P ncpus 1
P mpi_nbcpu 1
P mpi_nbnoeud 1
P testlist verification sequential

F comm forma02a.comm D 1
F mmed forma02a.mmed D 20
F mess forma02a.mess R 6
F resu forma02a.resu R 8
F rmed forma02a.rmed R 80

P version testing
P actions make_etude

Run the case and analyze the results

In a cmd, into the forma02a directory, launch Code_Aster for windows using your installed version:

Code_Aster_path_installation\install\bin\as_run.bat forma02a.export

Launch as_run.bat to run the customized format02a export file with Code_Aster for Windows 64-bit

At the end of the run, the working directory contains the mess and rmed files.

Customized Code_Aster testcase forma02a ended successfully on Windows 64-bit

Go back to Salome for Windows and open the ParaVIS module.

Open Salome_Meca on Windows 64-bit and open Paravis Paraview Module

It is then possible to import the rmed file by selecting in the menu, File -> Open ParaView File … Go to the dedicated directory forma02 and open forma02a.rmed.

Import result med file rmed as a paraview file in Salome_Meca for Windows 64-bit Paravis Paraview Module

Click apply button to load the file with default parameters and click on the eye for the mesh to appear on the viewer. Then right click on the mesh and select Color By -> RESU____DEPL.

Show displacement field in Salome_Meca for Windows 64-bit Paravis Paraview Module

The displacement field is now visible. It is possible to navigate between the different increments.

Navigate into different increment on displacement field in Salome_Meca for Windows 64-bit Paravis Paraview Module

Salome_Meca Paraview module Paravis showing a Code_Aster result on Windows

Customize for your needs

It is possible to use Salome to modify the mesh, or make a new mesh from scratch or using your geometry. Then it is also possible to modify the comm file by using other operators or modifying parameters in already used operators (young modulus, loadings, number of increment, mesh groups where loads or materials are applied …)

Playing with the input data and using the user online documentation is a good way to progress with Code_Aster operators. Once you get a sufficient understanding you may also create your own comm files from scratch.

conclusion

I hope this post will motivate some people to go into Code_Aster. Plenty of documentation available online can be found to learn about Salome (Geom, Mesh and Viewer modules) and about Code_Aster (user operators for comm file). There are also tutorials dedicated to Salome_Meca, that may be used with Code_Aster for Windows + Salome for Windows framework solution provided here.

Other ways, not discussed there, exist to use Code_Aster on Windows. One can for example use Gmsh for Windows as a pre and post pro instead of Salome.

Finally, if you want to start with Code_Aster and already have some knowledge with commercial solutions, I suggest the reading of theses posts Nastran to Code_Aster : elasto-plastic deformation, Nastran to Code_Aster: nonlinear gap elements and Abaqus to Code_Aster : plane stress.

One thought on “Beginning with Salome and Code_Aster for Windows

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s