You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This tutorial presents an example of using a "multi-implicit" spectral
deferred corrections (MISDC) integrator to solve a simple scalar
advection-diffusion-reaction equation in two dimensions. Both
diffusion and reaction terms are treated implicitly but solved for
independently in an operator splitting fashion. The advection is
treated explicitly. The relative strengths of the three terms can be
adjusted by changing the coefficients a,d, and r in inputs_2d.
The advection operator is a 4th-order centered difference in flux
form. The diffusion operator is a 2nd order discretization of the
Laplacian, and the implicit diffusion solve is done using
multigrid. The "reaction" term here is just a simple linear damping
hence the implicit solve is trivial. See the routines in
functions_2d.f90 for the code that evaluates the rhs terms.
The simple form of the equation allows for an exact solution of the
PDE in a periodic geometry. There is a flag called "plot_err" in
main.cpp, which if set equal 1 will cause the code to output the error
in the solution for plotting. If the advection term is omitted (a=0),
then an exact solution to the method of lines ODE is computed and used
to compute the error. Hence the error in this case will scale in dt
with the order of the time integrator.
This code can also be run as an IMEX advection-diffusion example
simply by setting Npieces=2 in main.cpp. This should also be
equivalent to setting r=0.
The source code is located in the directory Source. To compile the example, cd to Exec and enter
>make
To run the example in Exec
> ./main2d.gnu.ed inputs_2d
After completion, one can use amrvis to view the solution or errors.
Files:
main.cpp: Main routine.
SDC_sweeper.cpp: Executes the MISDC time step
init_phi_2d.f90: Fortran routines to initialize the solution and compute error
functions_2d.f90: Evaluation of rhs terms and implicit diffusion solve
This example uses the SDCstruct class (see amrex/Src/SDC/)