Welcome to the forums. Please post in English or French.

You are not logged in.

#1 2021-11-03 10:19:05

APereira
Member
Registered: 2021-09-30
Posts: 29

Store last converged step

Hello,

In order to debug my simulation, I want to save the last converged step in my rmed before the simulation crashs. Is it possible to do so in Salome Meca / Code_aster ?

Thanks a lot for your help

Adrien

Offline

#2 2021-11-11 14:54:37

GuillermoBarraza
Member
Registered: 2016-05-24
Posts: 49

Re: Store last converged step

Hi APereira,

How exactly are you running your simulation? Is everything in a single .comm file (i.e. the IMPR_RESU operator printing the results to the MED file is in the same file as your e.g. STAT_NON_LINE)? If this is the case, then I'd recommend that you split your .comm file into 2 of them: one for the DEBUT procedure (where the material assignment, boundary condition definition, mesh group creations, etc., are defined) and in a second file the POURSUITE (i.e. continuation) procedure, which will contain everything related to your post-processing steps.

Here is a small example for your first file:

# Input file start
DEBUT(
    LANG='en',
    PAR_LOT='NON',
    );

# Definition of material(s)
MAT_1=DEFI_MATERIAU(
            ...
    );

# Define mesh file
MESH=LIRE_MAILLAGE(
    FORMAT='MED',
    UNITE=20,
    );

# Creation of node groups and so ...
MESH=DEFI_GROUP(
    CREA_GROUP_NO=_F(
        ...
        ),
    MAILLAGE=MESH,
    reuse=MESH,
    );


# Model definition of phenomena and element types
MODEL=AFFE_MODELE(
    AFFE=(
        ...
    );

# First bc
BC_1=AFFE_CHAR_MECA(
    ...
    );

# Second bc
BC[1]=AFFE_CHAR_CINE(
       ...
    );

# and more

# Nonlinear static analysis definition
SIM=STAT_NON_LINE(
    CARA_ELEM=CARAELEM,
    CHAM_MATER=MAT_1,
    EXCIT=(_F(
            CHARGE=BC_1,
            ),
        _F(
            CHARGE=BC_2,
            ),
        ),
     # And whatever other setting you might have or want
    );

# End of your simulation step (WITHOUT POSTPROCESSING)
FIN(
    INFO_RESU='NON',
    RETASSAGE='NON',
    );

In a second file:

# Input file start

POURSUITE(
    IGNORE_ALARM=('SUPERVIS_1', 'ALGORITH11_87'),
    LANG='en',
    PAR_LOT='NON',
    IMPR_MACRO='OUI'
    );

# Solution fields in file
IMPR_RESU(
    FORMAT='MED',
    RESU=(
        ... # Whatever field you'd like to post-process
        ),
    UNITE=80,
    );
# End of your post-processing step 
FIN(
    INFO_RESU='NON',
    RETASSAGE='NON',
    );

Now, I normally run my simulations with as_run by executing from the terminal:

as_run simulation.export

and subsequently:

as_run postproc.export

where simulation.export and postproc.export would look something like this, respectively:

P actions make_etude
P aster_root <PATH_TO_YOUR_ASTER_INSTALATION>
#OTHER SYSTEM CONFIGURATION, DEPENDING ON YOUR CASE (memory and whatnot)

P rep_trav <#IMPORTANT: here goes the PATH where the global directory will be written to. This directory will contain all partial/complete data generated by your simulation (independently whether it was successful or not, meaning that if you had already some written steps, they'll appear here)>

F comm PATH_TO_YOUR_SIMULATION_COMM/simulation.comm D  1
F mmed PATH_TO_YOUR_MED_MESH D/mesh.med  D 20
F mess PATH_TO_YOUR_SIMULATION_MESSAGES/messages.mess R  6
F erre PATH_TO_YOUR_ERROR_MESSAGES/errors.mess R  9

and:

P actions make_etude
P aster_root <PATH_TO_YOUR_ASTER_INSTALATION>
#OTHER SYSTEM CONFIGURATION, DEPENDING ON YOUR CASE (memory and whatnot)

P rep_trav <#IMPORTANT: here goes the PATH where the global directory was written to. This directory will contain all partial/complete data generated by your simulation (independently whether it was successful or not, meaning that if you had already some written steps, they'll appear here) and will be used in this step as a starting point>

F comm PATH_TO_YOUR_POSTPROC_COMM/postproc.comm D  1
F rmed PATH_TO_YOUR_RESULT_MED_MESH D/result.rmed  R 80
F mess PATH_TO_YOUR_POURSUITE_MESSAGES/postproc.mess R  6
F erre PATH_TO_YOUR_ERROR_MESSAGES/errors.mess R  9

If you instead use ASTK within Salome Meca, then all the info in the .export files is exactly the one that you will fill in there (but with a somehow "nicer" UI).

Now, if you use AsterStudy... then I cannot further help you smile

With this you should at least be able to access the last converged simulation step (ofc, as long as you printed it out in ARCHIVAGE or something alike)


Cheers,
Guillermo

Offline

#3 2021-11-11 15:32:09

filjan
Member
From: Poland, Cracow
Registered: 2016-07-11
Posts: 85

Re: Store last converged step

APereira wrote:

Hello,

In order to debug my simulation, I want to save the last converged step in my rmed before the simulation crashs. Is it possible to do so in Salome Meca / Code_aster ?

Thanks a lot for your help

Adrien

Hi!

Add in .comm python clause try/except, like:

try:
    res = STAT_NON_LINE
   ....
except:
    pass

Regards

Offline

#4 2021-11-11 16:21:38

GuillermoBarraza
Member
Registered: 2016-05-24
Posts: 49

Re: Store last converged step

filjan wrote:

Add in .comm python clause try/except, like:

You are right, this might be an easier approach if you want to keep it on the same .comm file as per in this document: code-aster.org/V2/doc/v14/en/man_d/d5/d5.01.02.pdf (page 8, 5.5. Recovery of the exceptions in macro):

try:
    __resu = STAT_NON_LINE (...)
except NonConvergenceError ace exc:
    resu = self.get_last_concept ()
    # I assume here you'll have to do your IMPR_RESU:
    IMPR_RESU(RESULTAT=resu, FORMAT='MED')

Guillermo

Offline