2.4.12.1. A skeleton of the user’s main program
While SplittingStep usage generally follows the same pattern as the rest of ARKODE, since it is the composition of other steppers, we summarize the differences in using SplittingStep here. Steps that are unchanged from the skeleton program presented in §2.4.2 are italicized.
Initialize parallel or multi-threaded environment, if appropriate.
Create the SUNDIALS simulation context object
Set problem dimensions, etc.
Set vector of initial values
Create a stepper object for each problem partition
If using an ARKODE stepper module as an partition integrator, create and configure the stepper as normal following the steps detailed in the section for the desired stepper.
Once the ARKODE stepper object is setup, create a
SUNStepper
object withARKodeCreateSUNStepper()
.If supplying a user-defined partition integrator, create the
SUNStepper
object as described in section §14.2.
Note
When using ARKODE for partition integrators, it is the user’s responsibility to create and configure the integrator. User-specified options regarding how the integration should be performed (e.g., adaptive vs. fixed time step, explicit/implicit/ImEx partitioning, algebraic solvers, etc.) will be respected during evolution of a partition during SplittingStep integration.
If a user_data pointer needs to be passed to user functions called by a partition integrator then it should be attached to the partition integrator here by calling
ARKodeSetUserData()
. This user_data pointer will only be passed to user-supplied functions that are attached to a partition integrator. To supply a user_data pointer to user-supplied functions called by the SplittingStep integrator, the desired pointer should be attached by callingARKodeSetUserData()
after creating the SplittingStep memory below. The user_data pointers attached to the partition and SplittingStep integrators may be the same or different depending on what is required by the user code.Specifying a rootfinding problem for a partition integrator is not supported. Rootfinding problems should be created and initialized with SplittingStep. See the steps below and
ARKodeRootInit()
for more details.Create a SplittingStep object
Create the SplittingStep object by calling
SplittingStepCreate()
. One of the inputs toSplittingStepCreate()
is an array ofSUNStepper
objects with one to evolve each partition.Set the SplittingStep step size
Call
ARKodeSetFixedStep()
on the SplittingStep object to specify the overall time step size.Set optional inputs
Specify rootfinding problem
Advance solution in time
Get optional outputs
Deallocate memory for solution vector
Free solver memory
If an ARKODE stepper module was used as a partition IVP integrator, call
SUNStepper_Destroy()
andARKodeFree()
to free the memory allocated for that integrator.If a user-defined partition integrator was supplied, free the integrator content and call
SUNStepper_Destroy()
to free theSUNStepper
object.Call
ARKodeFree()
to free the memory allocated for the SplittingStep integration object.
Free the SUNContext object
Finalize MPI, if used