Code_Aster, Salome-Meca course material

Transcription

Code_Aster, Salome-Meca course material
Tips for optimizing your computations
with Code_Aster
Code_Aster, Salome-Meca course material
GNU FDL licence (http://www.gnu.org/copyleft/fdl.html)
Outline
Where does the code spend time ?
Some tips to optimize a (sequential) study
Parallel version of Code_Aster
Parametric studies
2 - Code_Aster and Salome-Meca course material
GNU FDL Licence
Where does Code_Aster spend time?
3 - Code_Aster and Salome-Meca course material
GNU FDL Licence
A simple simulation with Code_Aster
Prepare
data
• Read mesh
• Define the model
• Define boundary conditions
• Define material properties
Compute
• Compute elementary matrices
and build the problem matrix K
• Solve KU =F
Post solve
• Compute fields
• Write results
4 - Code_Aster and Salome-Meca course material
GNU FDL Licence
Nonlinear
solver
Time loop
Dominating steps : Assembly/Solve
Elementary matrices computations to build K
may take time if the material constitutive equations are
complex
Solving the linear system KU = F
Usually (and always for linear problems) the most
expensive step
These steps should be efficient since they are
called by:
the iterative loop of the nonlinear solver
the time loop
5 - Code_Aster and Salome-Meca course material
GNU FDL Licence
Tips for optimizing a (sequential) study
6 - Code_Aster and Salome-Meca course material
GNU FDL Licence
Definition of the problem
Optimize the mesh
to keep a reasonable number of unknowns
Prefer AFFE_CHAR_CINE (to AFFE_CHAR_MECA) to define
boundary conditions:
AFFE_CHAR_MECA uses dualization :
Pros :
general and flexible approach
Cons :
it increases the number of unknowns and results to a saddle-point matrix.
AFFE_CHAR_CINE uses elimination :
Pros :
no additional unknowns
better numerical properties for the resulting matrix : allows to use more efficient (iterative) solvers.
Cons :
less general: it allows local boundary conditions (u=u0) but no global linear relations (ex
AFFE_CHAR_MECA/LIAISON_SOLIDE)
7 - Code_Aster and Salome-Meca course material
GNU FDL Licence
Choose an efficient linear solver
Direct solvers are classically preferred in computational
mechanics
Based on a LU factorization of K followed by triangular solves.
Robust method (though costly for large systems)
In Code_Aster
native direct solver (sequential only) : DEFAULT
RES = STAT_NON_LINE( …
SOLVEUR=_F(METHODE=‘MULT_FRONT’,)
…)
external direct solver (sequential and parallel)
RES = STAT_NON_LINE( …
SOLVEUR=_F(METHODE=‘MUMPS’,)
…)
8 - Code_Aster and Salome-Meca course material
GNU FDL Licence
Choose an efficient linear solver
Iterative solvers may be very efficient
They are faster than direct solvers but sometimes fail to converge.
They demand a good preconditioner
Matrices may have a very poor conditionning number when structural elements (beams,
…) are present
In Code_Aster
native iterative solver (sequential only)
RES = STAT_NON_LINE( …
SOLVEUR=_F(METHODE=‘GCPC’,)
…)
external iterative solver (ONLY parallel …)
RES = STAT_NON_LINE( …
SOLVEUR=_F(METHODE=‘PETSC’,)
…)
9 - Code_Aster and Salome-Meca course material
GNU FDL Licence
Select relevant memory parameters
It is very important to select an appropriate value in ASTK
10 - Code_Aster and Salome-Meca course material
GNU FDL Licence
Evaluate the memory requirement of your job
If the required memory is overestimated, the job will have a very
low priority on Aster5 .. and it will wait before starting.
If the required memory is underestimated, the job will transfer
data between the disk and the RAM and this process slows the
computation.
Reporting on memory usage can be found in the .mess file
11 - Code_Aster and Salome-Meca course material
GNU FDL Licence
Example : test case perf005b – 512Mo
System time is large wrt
user time
=> indicates a potential
lack of memory
12 - Code_Aster and Salome-Meca course material
GNU FDL Licence
Example : test case perf005b – 512Mo
NOMBRE TOTAL DE
LIBERATIONS > 0,
indicates that
data is transferred to/from
the disk during the
computation. The diagnosis
« lack of memory » is
confirmed.
13 - Code_Aster and Salome-Meca course material
GNU FDL Licence
Example : test case perf005b – 1Go
This number has
decreased a lot
System time is
now(much) smaller
than CPU user time
Total CPU Time has
decreased
from 195.40s to 98.46s
14 - Code_Aster and Salome-Meca course material
GNU FDL Licence
Use Code_Aster parallel version (_mpi)
15 - Code_Aster and Salome-Meca course material
GNU FDL Licence
Is it worth it using a parallel version of
Code_Aster ?
Aster5 is a cluster
1 node = 2 CPUs (Intel® Xeon® E5-2600 V2), each with 12 cores
48 « standard » nodes with 24 Go RAM
48 « large memory » nodes
24 with 256 Go RAM and 24 with 512 Mo RAM
Parallel version of Code_Aster are available (_mpi)
But every studies will not benefit from being run on several cores
You can predict from simple rules of thumb if using parallelism is
worthwhile for your study
16 - Code_Aster and Salome-Meca course material
GNU FDL Licence
Practical rules of thumb
Always start with a sequential run and try to optimize it
Find out where Code_Aster spends time
In elementary computations ?
In the solver process ?
A lot of time steps are necessary to model your problem ?
….
What is the size (i.e. the number of degrees of freedom) of your
problem ?
Now
Do you intend to increase the (space) resolution (mesh refinement, …) ?
17 - Code_Aster and Salome-Meca course material
GNU FDL Licence
What can you expect if using parallelism ?
Elementary computations are slow
Elementary computations are independent tasks
They are distributed in a very efficient way if several processors are used
Use a parallel version
The solver is slow
If the number of degrees of freedom is small (< 50000)
Parallelism will not be very efficient
If the number of degrees of freedom is large enough,
Choose a parallel solver (MUMPS or PETSC)
Use a parallel version
There are a lot of time steps
There is no time parallelism facility in Code_Aster
Do not use a parallel version
18 - Code_Aster and Salome-Meca course material
GNU FDL Licence
Where does Code_Aster spend time ?
Summary
Solver
Elementary
computations
A lot of time
steps
What is the size
of the problem?
Use an MPI
version ,
scalability will
be optimal
No gain with
an MPI version
MPI
No MPI
< 50000 DoFs
> 50000 DoFs
You won’t gain
much with an
MPI version
Choose a parallel solver
(MUMPS/PETSC) and use
an MPI version
No MPI
MPI
19 - Code_Aster and Salome-Meca course material
GNU FDL Licence
How to use MPI with Code_Aster ?
Select an
MPI
version
( *_mpi)
20 - Code_Aster and Salome-Meca course material
GNU FDL Licence
How to use MPI with Code_Aster ?
Choose the number
of processors
mpi_nbcpu = 2, 4, 8
Do not change
mpi_nbnoeud
(remains equal to 1)
21 - Code_Aster and Salome-Meca course material
GNU FDL Licence
Parametric studies
22 - Code_Aster and Salome-Meca course material
GNU FDL Licence
What for?
A parametric study is a series of simulations where one or more
parameters of the problem are varied.
The purpose is to investigate the impact of a variation of the
parameter(s)
a geometrical size, physical material property, mechanical load ….
Astk includes a facility for running parametric studies
23 - Code_Aster and Salome-Meca course material
GNU FDL Licence
Key steps to define a parametric study
.comm
• Define the template study
• Declare a Python variable for each varying parameter,
and use it : young=0, temp=0
.distr
• Define the range of values of each parameter
• VALE=(_F(young = 2.E11, temp=10.),
_F(young=7.E10, temp=20.))
astk
• Choose distrib ='OUI‘ in « Options » menu.
• Select a .distr file
• Choose a directory for the storage of the results (repe)
24 - Code_Aster and Salome-Meca course material
GNU FDL Licence
More advanced features
u2.08.07 contains a complete tutorial showing how to:
define (syntax of the .distr file, …),
run (simulations are distributed among the processors)
analyze a parametric study (structure of the results
directory, how to use a « base » … )
25 - Code_Aster and Salome-Meca course material
GNU FDL Licence
End of presentation
Is something missing or unclear in this document?
Or feeling happy to have read such a clear tutorial?
Please, we welcome any feedbacks about Code_Aster training materials.
Do not hesitate to share with us your comments on the Code_Aster forum
dedicated thread.
26 - Code_Aster and Salome-Meca course material
GNU FDL Licence