My Project
programmer's documentation
|
C user functions for the setting of a user solver. The cs_user_solver function allows one to replace the Code_Saturne solver by a solver of his own.
The following example shows the setting of a user solver which solves a heat equation with the finite volume method.
If the function cs_user_solver_set returns 1, the Code_Saturne solver is replaced by the solver defined in cs_user_solver .
The following variables are declared locally and will be used later in the code. Three pointers to cs_real_t are declared and will stand for the temperature at the time steps n and n-1, and for the analytical solution of the heat equation;
Three arrays of size n
are created. Several constants are initialized, and the array t_old is initialized as follows :
One can define a restart computation, as for the real Code_Saturne solver.
Monitoring points can equally be created in order to plot the evolution of the temperature over the time.
At each iteration, the new temperature is computed using the Finite Volume Method.
The boundary conditions at and are :
t_old is then updated and t_sol computed. Finally, the temperature at and at the current iteration is plotted.
A checkpoint can be created in order to restart the computation later on.
Finally, t and t_sol are postprocessed in order to be compared.