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

You are not logged in.

#1 2021-03-03 19:34:14

rodrigofarias
Member
Registered: 2020-09-03
Posts: 26

[SOLVED] Automatically generate filenames and units for .export file

Hello.

Below the code snippet that I assembled for Aster (I deleted the unnecessary parts.).
Using the same mesh file, it loops to apply different loads to different groups on this same mesh.
The simulation runs with no problems on Salome-Meca.

DEBUT(PAR_LOT='NON')

CONDUC = DEFI_FONCTION(....

ENTHAL = DEFI_FONCTION(....

mater = DEFI_MATERIAU(THER_NL=...

# my groups names
hs_groups=['group_1', 'group_2', 'group_3']

#meshes=[None]*ng
model=[None]*ng
fmat=[None]*ng
lt=[None]*ng
load=[None]*ng
rter=[None]*ng
proj=[None]*ng

mesh = LIRE_MAILLAGE(UNITE=3)

for i in range(0,2):
            
    model[i] = AFFE_MODELE(AFFE=_F(MODELISATION=('3D', ),
	                            PHENOMENE='THERMIQUE',
	                            TOUT='OUI'),
	                    MAILLAGE=mesh)

    fmat[i] = AFFE_MATERIAU(AFFE=_F(MATER=(mater, ),
	                                 TOUT='OUI'),
	                         MODELE=model[i])

    lt[i] = DEFI_LIST_REEL(...

    load[i] = AFFE_CHAR_THER(...
    .
    .
    
FIN()

Unfortunately, to run this case in Salome-Meca, after loading the .comm file,
I have to go to the "Data files ..." tree, click on "Add files", and manually select 'Mode', 'Filename' and 'Unit',
for Aster be able to generate the .export file correctly and run the simulation.

For just one mesh and one output file, doing it manually is not a problem.
But my next step involves a similar simulation in several meshes (.MED), and generating several output files (.RMED).

Is there a way to do this via script, automatically? Maybe generate the .export file automatically, assigning filenames and Units as necessary?

Thank you for your help!

PS: for meshes, I know that I can export them as a single .MED file. However, the file will become extremely large.
The ideal would be to use separate mesh files for each loop, so that I can even delete the ones I no longer need during the run.

Last edited by rodrigofarias (2021-03-05 18:57:32)

Offline

#2 2021-03-04 12:00:46

GPSalachs
Member
Registered: 2018-03-10
Posts: 239

Re: [SOLVED] Automatically generate filenames and units for .export file

Hello,

i think you should look into the DEFI_FISCHIER command. (V2/doc/v13/en/man_u/u4/u4.12.03.pdf).
It could give you the possibility to add a counter and a path to your results.
A question if i may, does the assignment of the groups happen in different parts of the mesh?
Very interesting work!!

Last edited by GPSalachs (2021-03-04 12:02:37)

Offline

#3 2021-03-04 13:50:04

rodrigofarias
Member
Registered: 2020-09-03
Posts: 26

Re: [SOLVED] Automatically generate filenames and units for .export file

GPSalachs wrote:

Hello,

i think you should look into the DEFI_FISCHIER command. (V2/doc/v13/en/man_u/u4/u4.12.03.pdf).
It could give you the possibility to add a counter and a path to your results.
A question if i may, does the assignment of the groups happen in different parts of the mesh?
Very interesting work!!

Thanks.

I read the document and it looks like it allows me to do what I need to do. I will test it later.

As for your question, yes. My python that generates the mesh has a loop that selects nodes based on position, and then selects the elements connected to these nodes, to create my groups of elements. I have a solved topic about this:

/forum2/viewtopic.php?id=25488

As soon as I test it I will come back here and give feedback.

Thanks!

Offline

#4 2021-03-04 15:08:22

GPSalachs
Member
Registered: 2018-03-10
Posts: 239

Re: [SOLVED] Automatically generate filenames and units for .export file

I would like to know more on the usage because it is very interesting and i would like to know how it would affect optimization processes!

Offline

#5 2021-03-04 15:30:48

rodrigofarias
Member
Registered: 2020-09-03
Posts: 26

Re: [SOLVED] Automatically generate filenames and units for .export file

Hello.

I tried it as follows, and unfortunately it didn't work:

name1 = DEFI_FICHIER(ACCES='OLD',
                    ACTION='ASSOCIER',
                    FICHIER='my_mesh.med',
                    TYPE='LIBRE',
                    UNITE=3)

name2 = DEFI_FICHIER(ACCES='NEW',
                    ACTION='ASSOCIER',
                    FICHIER='temporary_result.rmed',
                    TYPE='LIBRE',
                    UNITE=2)

name3 = DEFI_FICHIER(ACCES='NEW',
                    ACTION='ASSOCIER',
                    FICHIER='final_result.rmed',
                    TYPE='LIBRE',
                    UNITE=80)

mesh = LIRE_MAILLAGE(UNITE=3)

The same error happened before, the simulation did not run because there was no file assigned to the mesh.
Am I doing correct GPSalachs? Was this how you described it?

Another thing, I found your previous post here: forum2/viewtopic.php?id=25490

MESH = code_aster.Mesh()
MESH.readMedFile(path+"/NAMEOFTHEFILE.med")

myResult.printMEDFile("myPath")

Are these commands (readMedFile, printMEDFile) in the Mesh module or in Asterstudy? I didn't know that Aster had functions written in python like this. In Aster I just thought it was possible to create variables, lists, loops, etc.

What details would you like to know?

Thanks!!

Offline

#6 2021-03-04 15:49:30

GPSalachs
Member
Registered: 2018-03-10
Posts: 239

Re: [SOLVED] Automatically generate filenames and units for .export file

rodrigofarias wrote:

Hello.

I tried it as follows, and unfortunately it didn't work:

name1 = DEFI_FICHIER(ACCES='OLD',
                    ACTION='ASSOCIER',
                    FICHIER='my_mesh.med',
                    TYPE='LIBRE',
                    UNITE=3)

name2 = DEFI_FICHIER(ACCES='NEW',
                    ACTION='ASSOCIER',
                    FICHIER='temporary_result.rmed',
                    TYPE='LIBRE',
                    UNITE=2)

name3 = DEFI_FICHIER(ACCES='NEW',
                    ACTION='ASSOCIER',
                    FICHIER='final_result.rmed',
                    TYPE='LIBRE',
                    UNITE=80)

mesh = LIRE_MAILLAGE(UNITE=3)

The same error happened before, the simulation did not run because there was no file assigned to the mesh.
Am I doing correct GPSalachs? Was this how you described it?

Another thing, I found your previous post here: forum2/viewtopic.php?id=25490

MESH = code_aster.Mesh()
MESH.readMedFile(path+"/NAMEOFTHEFILE.med")

myResult.printMEDFile("myPath")

Are these commands (readMedFile, printMEDFile) in the Mesh module or in Asterstudy? I didn't know that Aster had functions written in python like this. In Aster I just thought it was possible to create variables, lists, loops, etc.

What details would you like to know?

Thanks!!

These commands i think, due to me also not being expert enough, used in the Aster Study environment. You could also try to run this through ASTK and change the .export file to your needs.Also it seems from what i have gathered that the mesh module and other modules can be called in AsterStudy.

Try not adding the name1, name2, name3 and leave DEFI_FISCHIER as it is

DEFI_FICHIER(ACCES='OLD',
                    ACTION='ASSOCIER',
                    FICHIER='my_mesh.med',
                    TYPE='LIBRE',
                    UNITE=3)

Otherwise i think it assigns the definition on the name and it gets confused there.

The video here is on OpenTurns but it gives a lot of information on how to use the available modules. (https:  //  www. youtube.com/watch ?v=dh4ATfcrHxk&t=1303s&ab_channel=CyprienRusu )

Offline

#7 2021-03-04 16:05:06

rodrigofarias
Member
Registered: 2020-09-03
Posts: 26

Re: [SOLVED] Automatically generate filenames and units for .export file

GPSalachs wrote:

Try not adding the name1, name2, name3 and leave DEFI_FISCHIER as it is

DEFI_FICHIER(ACCES='OLD',
                    ACTION='ASSOCIER',
                    FICHIER='my_mesh.med',
                    TYPE='LIBRE',
                    UNITE=3)

Otherwise i think it assigns the definition on the name and it gets confused there.

I tried and unfortunately the same error occurred.
Also, manually modifying the .export is not desirable, as I described in the first message.
Like the attached figure, I have to manually "Add file" (1). I would like the make this step in a script, inside Aster or maybe using a python file.


Attachments:
Capturee.PNG, Size: 60.37 KiB, Downloads: 29

Offline

#8 2021-03-04 17:03:26

konyaro
Member
From: Genève
Registered: 2016-04-02
Posts: 259

Re: [SOLVED] Automatically generate filenames and units for .export file

Hello,
I often use the following without problems:

DEFI_FICHIER(ACTION='ASSOCIER',
             FICHIER=r'/usr/temp/Mesh.med',
             UNITE=3)
             
MAIL = LIRE_MAILLAGE(FORMAT='MED',
                     UNITE=3)

Don't forget the path of the file.

Konyaro


失敗は成功のもと (L'échec est la base de la réussite)

Offline

#9 2021-03-04 19:06:07

rodrigofarias
Member
Registered: 2020-09-03
Posts: 26

Re: [SOLVED] Automatically generate filenames and units for .export file

konyaro wrote:

Don't forget the path of the file.

Konyaro

Thank you both my friends! Its working!

The approach using DEFI_FICHIER really worked. As Konyaro pointed out, the full path to the files is required.

I was able to open the Salome-Meca GUI, load the python that generates the geometry and mesh; and then just enter Asterstudy, add the .comm file and hit Run. I will test this later on ASTK. It is very good not to have to set up a .export file every time.

While we're at it, I noticed that this operator (DEFI_FICHIER) appears as 'Deprecated' in Aster's command list. Has it been replaced by another method?

Offline

#10 2021-03-05 07:45:17

GPSalachs
Member
Registered: 2018-03-10
Posts: 239

Re: [SOLVED] Automatically generate filenames and units for .export file

rodrigofarias wrote:
konyaro wrote:

Don't forget the path of the file.

Konyaro

Thank you both my friends! Its working!

The approach using DEFI_FICHIER really worked. As Konyaro pointed out, the full path to the files is required.

I was able to open the Salome-Meca GUI, load the python that generates the geometry and mesh; and then just enter Asterstudy, add the .comm file and hit Run. I will test this later on ASTK. It is very good not to have to set up a .export file every time.

While we're at it, I noticed that this operator (DEFI_FICHIER) appears as 'Deprecated' in Aster's command list. Has it been replaced by another method?

I do not know of another method.

Offline

#11 2021-03-08 18:25:19

jlf
Member
Registered: 2007-11-22
Posts: 246

Re: [SOLVED] Automatically generate filenames and units for .export file

Hello,

The best way, is to use the './REPE_OUT/'

lefic = './REPE_OUT/{nom}.med'.format(nom=NomEssais.lower())
unit = DEFI_FICHIER(ACTION='ASSOCIER', FICHIER=lefic, ACCES='NEW', TYPE='LIBRE')
IMPR_RESU(FORMAT='MED',UNITE=unit, RESU=_F(RESULTAT=LEDEPL,),)
DEFI_FICHIER(ACTION='LIBERER', UNITE=unit)

In your export file, declare a directory in 'R'esult
R repe  my_result_xxx R 0
In 'my_result_xxx' you have all the output files

You can make the same thing with 'REPE_IN' for input files like meshes, ....
lefic = './REPE_IN/{nom}.med'.format(nom=NomEssais.lower())
unit = DEFI_FICHIER(ACTION='ASSOCIER', FICHIER=lefic, ACCES='OLD', TYPE='LIBRE')
mesh=LIRE_MAILLAGE(UNITE=unit)
DEFI_FICHIER(ACTION='LIBERER', UNITE=unit)

In your export file, declare a directory in 'D'ata
R repe  my_data_xxx D 0
In 'my_data_xxx' you have all the input files, or link to these files

JLF

Offline