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

You are not logged in.

#1 2022-01-10 08:43:36

lskrinjar
Member
Registered: 2015-10-16
Posts: 43

[SOLVED] Save results of CALC_CHAMP() in for loop to MED file

I am running a simple simulation (files attached) of a 2D beam elements in a for loop for different parameters of a cross section. I have managed to save the DEPL results of every i-th step in one MED file as below:

disp = [None for i in range(0, N)]
affe = [None for i in range(0, N)]
for i in range(0, N):
    disp[i] = CREA_CHAMP(TYPE_CHAM = 'NOEU_DEPL_R',
                         NOM_CHAM = 'DEPL',
                         OPERATION = 'EXTR',
                         RESULTAT = res[i],
                         INST = 0)

    affe[i] = _F(MODELE = model,
                 CARA_ELEM = elpr[i],
                 CHAM_GD = disp[i],
                 INST = i)

# create result file
reslin = CREA_RESU(OPERATION = 'AFFE',
                    TYPE_RESU = 'EVOL_ELAS',
                    NOM_CHAM = 'DEPL',
                    AFFE = affe)

IMPR_RESU(FORMAT='MED',
          RESU=_F(RESULTAT=reslin),
          UNITE=3)

I would also like to include SIEF_ELNO and SIPO_ELNO....from CALC_CHAMP() to the MED file of each i-th step. Can you please give me some guidelines/direction how to add this data to CREA_RESU and save to MED file with IMPR_RESU.
Thank you very much!
lskrinjar

Last edited by lskrinjar (2022-01-10 21:16:52)

Offline

#2 2022-01-10 08:58:54

lskrinjar
Member
Registered: 2015-10-16
Posts: 43

Re: [SOLVED] Save results of CALC_CHAMP() in for loop to MED file

lskrinjar wrote:

I am running a simple simulation (files attached) of a 2D beam elements in a for loop for different parameters of a cross section. I have managed to save the DEPL results of every i-th step in one MED file as below:

disp = [None for i in range(0, N)]
affe = [None for i in range(0, N)]
for i in range(0, N):
    disp[i] = CREA_CHAMP(TYPE_CHAM = 'NOEU_DEPL_R',
                         NOM_CHAM = 'DEPL',
                         OPERATION = 'EXTR',
                         RESULTAT = res[i],
                         INST = 0)

    affe[i] = _F(MODELE = model,
                 CARA_ELEM = elpr[i],
                 CHAM_GD = disp[i],
                 INST = i)

# create result file
reslin = CREA_RESU(OPERATION = 'AFFE',
                    TYPE_RESU = 'EVOL_ELAS',
                    NOM_CHAM = 'DEPL',
                    AFFE = affe)

IMPR_RESU(FORMAT='MED',
          RESU=_F(RESULTAT=reslin),
          UNITE=3)

I would also like to include SIEF_ELNO and SIPO_ELNO....from CALC_CHAMP() to the MED file of each i-th step. Can you please give me some guidelines/direction how to add this data to CREA_RESU and save to MED file with IMPR_RESU.
Thank you very much!
lskrinjar


Attachments:
profile_S_V0_1_analysis.zip, Size: 16.14 KiB, Downloads: 81

Offline

#3 2022-01-10 11:39:41

jeanpierreaubry
Guru
From: nantes (france)
Registered: 2009-03-12
Posts: 3,798

Re: [SOLVED] Save results of CALC_CHAMP() in for loop to MED file

hello

on first question
what is the use of
import pandas as pd
and what is pandas,

the reslin you create contains only displacement it is not possible to calculate stress and so on directly  from it it is clearly stated in the message file

   !----------------------------------------------------------------------------------------------------!
   ! <A> <CALCCHAMP_6>                                                                                  !
   !                                                                                                    !
   ! Le mot clef EXCIT de la commande n'est pas renseigné et la récupération des chargements concernant !
   ! le résultat reslin n'est actuellement pas possible.                                                !
   !                                                                                                    !
   ! Conseil : Il faut renseigner le mot clef EXCIT de la commande CALC_CHAMP,                          !
   !                                                                                                    !
   !                                                                                                    !
   ! This is a warning. If you do not understand the meaning of this                                    !
   !  warning, you can obtain unexpected results!                                                       !
   !----------------------------------------------------------------------------------------------------!

why not just simply adding in the first loop
the right operator to print the indexed stress field in the med file

jean pierre aubry


consider reading my book
freely available here https://framabook.org/beginning-with-code_aster/

Offline

#4 2022-01-10 11:56:40

lskrinjar
Member
Registered: 2015-10-16
Posts: 43

Re: [SOLVED] Save results of CALC_CHAMP() in for loop to MED file

jeanpierreaubry wrote:

hello

on first question
what is the use of
import pandas as pd
and what is pandas,

the reslin you create contains only displacement it is not possible to calculate stress and so on directly  from it it is clearly stated in the message file

   !----------------------------------------------------------------------------------------------------!
   ! <A> <CALCCHAMP_6>                                                                                  !
   !                                                                                                    !
   ! Le mot clef EXCIT de la commande n'est pas renseigné et la récupération des chargements concernant !
   ! le résultat reslin n'est actuellement pas possible.                                                !
   !                                                                                                    !
   ! Conseil : Il faut renseigner le mot clef EXCIT de la commande CALC_CHAMP,                          !
   !                                                                                                    !
   !                                                                                                    !
   ! This is a warning. If you do not understand the meaning of this                                    !
   !  warning, you can obtain unexpected results!                                                       !
   !----------------------------------------------------------------------------------------------------!

why not just simply adding in the first loop
the right operator to print the indexed stress field in the med file

jean pierre aubry

Hello jean pierre aubry,

thank you for your quick reply. The pandas is external python module that I did not remove it for this minimal working example. The edited files are attached.

I have also implemented to write the solution at each i-th step, but then in the ParaVis I am not able to use "Time" (1 or 2 in this example) to change between different "steps".

for i in range(0, N):
    A = 10 * (i+1)
    RY = 5. * (i+1)
    RZ = 5. * (i+1)
    IY = 100. * (i+1)
    IZ = 100. * (i+1)
    elpr[i]= AFFE_CARA_ELEM(identifier='2:1',
                              MODELE=model,
                              POUTRE=_F(CARA=('A', 'IY', 'IZ', 'AZ', 'AY', 'JX', 'RY', 'RZ'),
                                        GROUP_MA=('elements', ),
                                        SECTION='GENERALE',
                                        VALE=(A, IY, IZ, 1., 1., 1., RY, RZ),
                                        VARI_SECT='CONSTANT'))

    # solve
    res[i] = MECA_STATIQUE(CARA_ELEM=elpr[i],
                           CHAM_MATER=fieldmat,
                           EXCIT=(_F(CHARGE=sups),
                                  _F(CHARGE=loads)),
                           MODELE=model)

    # post process
    res[i] = CALC_CHAMP(reuse=res[i],
                        CONTRAINTE=('SIEF_ELNO', 'SIPO_ELNO', 'SIPM_ELNO', 'EFGE_NOEU', 'SIPO_NOEU'),
                        FORCE=('REAC_NODA',),
                        RESULTAT=res[i])
    IMPR_RESU(FORMAT='MED',
              RESU=_F(RESULTAT=res[i]),
              UNITE=3)

Can you please give some guidelines how could this be implemented in the first loop?
Thank you for your advice!

Last edited by lskrinjar (2022-01-10 13:45:24)


Attachments:
profile_S_V0_1_analysis.zip, Size: 15.47 KiB, Downloads: 78

Offline

#5 2022-01-10 14:32:24

jeanpierreaubry
Guru
From: nantes (france)
Registered: 2009-03-12
Posts: 3,798

Re: [SOLVED] Save results of CALC_CHAMP() in for loop to MED file

trouble with paravis,
i do not use it
the attached file produces results visible in Gmsh


Attachments:
profile_S_beam_run_test-modif.comm, Size: 3.43 KiB, Downloads: 85

consider reading my book
freely available here https://framabook.org/beginning-with-code_aster/

Offline

#6 2022-01-10 21:24:17

lskrinjar
Member
Registered: 2015-10-16
Posts: 43

Re: [SOLVED] Save results of CALC_CHAMP() in for loop to MED file

jeanpierreaubry wrote:

trouble with paravis,
i do not use it
the attached file produces results visible in Gmsh

Hello jeanpierreaubry,

thank you for the edited .comm file. The values are stored as requested and I can access/visualize it in ParaViS, although I would prefer to also have the possibility in ParaViS to step through results as in h ttps://www.youtube.com/watch?v=Fy49b0nwpXI @22:32. Any ideas?
Thank you for your kind help!

Offline

#7 2022-01-15 09:05:46

Ioannis
Member
Registered: 2016-04-01
Posts: 67

Re: [SOLVED] Save results of CALC_CHAMP() in for loop to MED file

Hi Luka,

In order to add more fields you have to use similarly a for loop to extract each one, you just have to change to the correct TYPE_CHAM and NOM_CHAM, which you can find in the CREA_CHAMP documentation. For example SIEF_ELNO and ELNO_SIEF_R.

Then, in CREA_RESU, since you will call it for a second time and more, enriching the result fields, you will have to add reuse=reslin and RESULTAT=reslin

sief = [None for i in range(0, N)]
affe = [None for i in range(0, N)]
for i in range(0, N):
    sief[i] = CREA_CHAMP(TYPE_CHAM = 'ELNO_SIEF_R',
                         NOM_CHAM = 'SIEF_ELNO',
                         OPERATION = 'EXTR',
                         RESULTAT = res[i],
                         INST = 0)

    affe[i] = _F(MODELE = model,
                 CARA_ELEM = elpr[i],
                 CHAM_GD = disp[i],
                 INST = i)

# create result file
reslin = CREA_RESU(
                    reuse = reslin,
                    RESULTAT = reslin,
                    OPERATION = 'AFFE',
                    TYPE_RESU = 'EVOL_ELAS',
                    NOM_CHAM = 'DEPL',
                    AFFE = affe)

Last edited by Ioannis (2022-01-15 09:06:30)


Aether Engineering
- aethereng.com -

Offline