FluidNumerics / SELF

Spectral Element Library in Fortran
BSD 3-Clause "New" or "Revised" License
63 stars 7 forks source link

Add support for dynamic time integrators and riemann solvers #38

Open fluidnumerics-joe opened 2 years ago

fluidnumerics-joe commented 2 years ago

Is your feature request related to a problem? Please describe. For some models, like the shallow water equations or the compressible navier stokes, we want to have a suite of choices for the integrators, riemann solvers, or source terms.

Describe the solution you'd like To allow for dynamic selection of these methods within main programs, we can use procedure pointers as attributes in the SELF_Model* classes for these methods. The SELF_Model module can define all of the time integrators and default riemann solver methods that do nothing. The individual models (shallow water, compressible ideal gas, etc.) can define the suite of Riemann solvers that can be selected in main programs doing something like

! Set the time integrator
this % TimeIntegrator => SELF_RK3()

! Set the Riemann Solver
this % RiemannSolver => SELF_LocalLaxFriedrichs_CompressibleIdealGas()

https://riptutorial.com/fortran/example/11869/referencing-a-procedure

Describe alternatives you've considered In the code we currently use an integer flag for the time integrator and a SELECT CASE block for running with the correct time integrator. As we add more integrators, we'll need to continue writing this boiler-plate code. With procedure pointers, we can write the subroutines, and simply allow for the user to assign the procedure pointer in their program.

Additional context Procedure Pointers example

fluidnumerics-joe commented 2 years ago

So far, this feature is working well for time integrators in the SELF_Model class. Users can assign the time integrator using the model % timeIntegrator procedure pointer attribute. I've added explicit integrators that are being verified ( AB2, AB3, AB4, RK2, RK4)