Difference between revisions of "Contrib:KeesWouters/Homard/lshape/loop"
Keeswouters (Talk | contribs) m (→'''The general idea of the refinement''') |
Keeswouters (Talk | contribs) m (→'''The general idea of the refinement''') |
||
Line 66: | Line 66: | ||
[Note that 'test_%d',%3 will evaluate to 'test_3' in Python.] | [Note that 'test_%d',%3 will evaluate to 'test_3' in Python.] | ||
− | Now suppose counter=1, counterp1=2 then meshcp1 then evaluates to '' | + | Now suppose counter=1, counterp1=2 then meshcp1 then evaluates to ''mesh_2 = CO('mesh_2')''. This corresponds to mesh[2]. To check this the print commands ''print model'' and ''print mesh'' have been added at the start of this block. The output of these commands are e.g: |
− | + | ''print mesh'':<br> | |
[<maillage_sdaster(86f7f50,'mesh_0 ')>, <maillage_sdaster(6b465d0,'mesh_1 ')>, <maillage_sdaster(71b7dd0,'mesh_2 ')>, None] | [<maillage_sdaster(86f7f50,'mesh_0 ')>, <maillage_sdaster(6b465d0,'mesh_1 ')>, <maillage_sdaster(71b7dd0,'mesh_2 ')>, None] | ||
Revision as of 00:54, 23 February 2010
Contents
Mesh refinement using Python loop facility
[under construction - just started 2010-02-22 ... ]
This contribution is based on the mesh refinement described here. Two mesh refinements based on three calculations are given there. Since the three calculations are basically the same, it is convenient to use the Python looping facility. So now we will perform four calculations and three mesh refinements. The iteration is controlled by the a Python for loop.
The geometry
The geometry and the mesh of the construction
The mesh refinement is based on Homard. As usual the geometry is quite simple and is defined in the link given above.
Again, the mesh consists of coarse, tetrehedral elements to start with.
The load of the construction
The L shape is fixed in all directions at the bottom area Afix. The area at opposite end of L is denoted Apres. For simplicity, on this area a displacement of 0.1 mm is given in the y direction.
The general idea of the refinement
The general idea of the Homard refinement is to start with a rather course mesh and update the mesh according to a criterium. In this case we use the stress error estimate ERRE_ELEM_SIGM and its component ERREST. For more details on this error estimation see [....]. So to start with, a standard load case will be calculated and an error estimation on all the elements will be carried out. Again depending on a criterium the mesh will be adapted. In this example a certain percentage of the elements with the highest error estimates will be refined. A new calculation with the adapted mesh can take place. For this calculation all the models, loads and parameters need to be rebuild. So it is most suitable to define geometrical entities (GROUP_MA) in the mesh in stead of nodes.
To summarise:
- initial some parameters
- read initial mesh
- define material properties
- define number of refinement iterations (whether or not fixed)
- for counter in [0,1,2,3]:
- ...define model
- ...apply material to model
- ...apply load to model
- ...perform calculation
- ...determine element and node parameters
- ...(write output data)
- ...refinement of mesh MACR_ADAP_MAIL
The error estimation is determined in the CALC_ELEM command, by the option 'ERRE_ELEM_SIGM':
result...=CALC_ELEM(....,OPTION=(....,'ERRE_ELEM_SIGM',),);
The refinement command itself is as follows:
...... print mesh print model
counterp1 = counter+1; meshcp1=CO('mesh_%d' %counterp1) MACR_ADAP_MAIL(MAILLAGE_N=mesh[counter], MAILLAGE_NP1=meshcp1, ADAPTATION='RAFFINEMENT', RESULTAT_N=result[counter], INDICATEUR='ERRE_ELEM_SIGM', NOM_CMP_INDICA='ERREST', CRIT_RAFF_PE=0.20, QUALITE='OUI', CONNEXITE='OUI', TAILLE='OUI',);
mesh[counter+1] = meshcp1;
The command takes the current mesh mesh[counter] as input MAILLAGE_N=curmesh and the output mesh is MAILLAGE_NP1=meshcp1. Again, the meshcp1 is not defined (in the Python sense) so we need to use the CO('..') operator on forehand:
counterp1 = counter+1; meshcp1=CO('mesh_%d' %counterp1)
[Note that 'test_%d',%3 will evaluate to 'test_3' in Python.] Now suppose counter=1, counterp1=2 then meshcp1 then evaluates to mesh_2 = CO('mesh_2'). This corresponds to mesh[2]. To check this the print commands print model and print mesh have been added at the start of this block. The output of these commands are e.g:
print mesh:
[<maillage_sdaster(86f7f50,'mesh_0 ')>, <maillage_sdaster(6b465d0,'mesh_1 ')>, <maillage_sdaster(71b7dd0,'mesh_2 ')>, None]
Further keywords are the ADAPTATION='RAFFINEMENT' together with CRIT_RAFF_PE=0.10. In this case the 0.10 or 10 % of the elements with the largest error estimate (based on stress error indicator INDICATEUR='ERRE_ELEM_SIGM', NOM_CMP_INDICA='ERREST') are refined. The other elements remain untouched. At the end we need to assign the next element of array mesh to the newly defined meshcp1: mesh[counter+1] = meshcp1. The if statement is needed because in the last iteration no refinement is required anymore.
The initialisation of the calculation
Here the initialisation commands that can be left out the for loop are described:
DEBUT();
# initialise counters count = [0,1,2,3]; count0 = count[0];
# initialise model parameters mesh=[None]*4 model=[None]*4 Amat=[None]*4 result=[None]*4 Load=[None]*4
#Define material properties steel=DEFI_MATERIAU(ELAS=_F(E=2.1e5,NU=.28,),);
#Read MED mesh file mesh[count0]=LIRE_MAILLAGE(UNITE=20,FORMAT='MED',NOM_MED='mesh0',);
In the array count all the loop numbers 0 to 3 are defined. This is used to control the for loop. The array parameters mesh, model, Amat, result and Load are initialised with maximum size according to the count array.
Furthermore teh material properties are defined and the initial mesh is read.
The for loop construction
# start counter for counter in count: model[counter]=AFFE_MODELE(MAILLAGE=mesh[counter],AFFE=_F(TOUT='OUI', PHENOMENE='MECANIQUE',MODELISATION='3D',),);
#Assign material to mesh Amat[counter]=AFFE_MATERIAU(MAILLAGE=mesh[counter], AFFE=_F(TOUT='OUI',MATER=steel,),);
#define boundary conditions and loads Load[counter]=AFFE_CHAR_MECA(MODELE=model[counter], DDL_IMPO=(_F(GROUP_MA='Afix',DX=0.0,DY=0.0,DZ=0.0,), _F(GROUP_MA='Apres',DX=0.0,DY=0.1,DZ=0.0,),),);
result[counter]=MECA_STATIQUE(MODELE=model[counter], CHAM_MATER=Amat[counter], EXCIT=(_F(CHARGE=Load[counter],),),);
result[counter]=CALC_ELEM(reuse =result[counter], MODELE=model[counter], RESULTAT=result[counter], TOUT='OUI', TYPE_OPTION='TOUTES', OPTION=('EQUI_ELNO_SIGM','SIEF_ELNO_ELGA','ERRE_ELEM_SIGM',),);
result[counter]=CALC_NO(reuse =result[counter], RESULTAT=result[counter], OPTION=('EQUI_NOEU_SIGM',),);
unitnumber = 80 IMPR_RESU(FORMAT='MED', UNITE=unitnumber, RESU=_F(MAILLAGE=mesh[counter],RESULTAT=result[counter],NOM_CHAM=('DEPL',),),);
##========================## ## define mesh refinement ## ##========================## if (counter<count[len(count)-1]): print count, len(count), count[len(count)-1], counter print mesh print model counterp1 = counter+1; meshcp1=CO('mesh_%d' %counterp1) MACR_ADAP_MAIL(MAILLAGE_N=mesh[counter], MAILLAGE_NP1=meshcp1, ADAPTATION='RAFFINEMENT', RESULTAT_N=result[counter], INDICATEUR='ERRE_ELEM_SIGM', NOM_CMP_INDICA='ERREST', CRIT_RAFF_PE=0.10, QUALITE='OUI', CONNEXITE='OUI', TAILLE='OUI',);
mesh[counter+1] = meshcp1; #endif #end for loop
And close the calculations:
FIN(FORMAT_HDF='OUI',);
The results of the refinement
The numbers of nodes and quadratic elements (tetrahedrons) of the meshes:
30% 70% 30%-->new factor nodes elements changed unchanged elements change 4224 2064 620 1444 16346 9636 2890 6746 8192 13 (=8192 / 620) 65845 42537 12760 29777 35791 12 (=35791/2890)
So, from a single tetrahedron that is refined, 12 to 13 tetrahedrons are generated for this mesh.
In the graph below, the original mesh (top left) and the two successive refinements based on the discussed criteria are depicted (bottom right last iteration).
The picture below shows the stress error estimation 'ERREST'. The first refinement is based on this field: mesh0 --> mesh1.
The error estimation field 'ERROR-ELEM_SIGMA' containes 10 components:
ERREST, NUEST, SIGCAL, TERMRE,TERMR2,TERMRENO,TERMN2,TERMSA,TERMS2, TAILLE.
Any of these components can be used in the component indicator, eg. NOM_CMP_INDICA='ERREST'
The ASTK input files
The picture below shows the input and output files defined in ASTK.
Download files
This zip contains the following files
- python geometry and mesh files (load in Salome by File --> Load script (cntrl T)) and right select refresh (F5) in the object browser). Export the med file in the mesh module under mesh0.med for further processing by Code-Aster, controlled by ASTK.
- command files for Code-Aster
- astk file for file control by ASTK
- export file, generated by ASTK.
The result files resi0.med, resi1.med and resi2.med, can be viewed in the post processor module of Salome by File --> Import --> resix.med or cntrl I in the object browser.
Links
More information about the mesh refinement by Homard can be find here:
pdf file: http://www.code-aster.org/V2/doc/default/man_u/u7/u7.03.01.pdf
Homard website: http://www.code-aster.org/outils/homard
That's it for now.
Kees