Page **1** of **1**

### Solutions at time steps n and n-1

Posted: **23 Jun 2016, 22:42**

by **amrueda**

Dear Elmer team,

I am writing a solver for a system of 12 coupled PDEs. Since some of my equations are advection-dominated, I am implementing an FCT-stabilization algorihm, which needs the solutions at time steps

*n* and

*n-1* in order to calculate the flux corrections and solve the system at time step

*n+1*.

I checked some source files and found out that the solution at time step

*n* is stored in

Is there a way to get the solution at time step

*n-1*?

Thank you very much.

Kind regards,

Andrés

### Re: Solutions at time steps n and n-1

Posted: **24 Jun 2016, 12:29**

by **mzenker**

Hi,

I don't know for sure, but I think you would need to store it by yourself. You can examine the adaptive timestepping code for a possible way to do that.

HTH,

Matthias

### Re: Solutions at time steps n and n-1

Posted: **05 Jul 2016, 15:33**

by **raback**

Hi Andrés

The number of previous timesteps that are stored depends on the time stepping method. If you use bdf then there is the keyword "bdf order" that defines the order, and this is also the number of previous timesteps required: N:th order scheme requires N previous timesteps.

Currently this may be married with the timestepping strategy. So if you do you require 2 previous steps, but use a 1st order scheme then you may need to do it yourself. The order of the solver is found in "Solver % Order".

It would probably be a rather small modification to the library to allow number of steps to be stored be larger than order of timestepping scheme but to my knowledge it has not been done.

-Peter

### Re: Solutions at time steps n and n-1

Posted: **05 Jul 2016, 23:20**

by **amrueda**

Hello,

Thank you both. I am using BDF of order 1. Therefore, I have tried the following, but it still doesn't work:

- Add the integer variable
*StoreSteps* to the type Solver_t in the file Types.F90 (line 721).
- Add the keyword to SOLVER.KEYWORDS
Code: Select all

`Simulation:Integer: 'BDF Store Steps'`

- Read the value from the SIF file in MainUtils.F90 (add line 849-850):
Code: Select all

```
Solver % StoreSteps = ListGetInteger( SolverParams, &
'BDF Store Steps', Found)
```

- Allocate
*Solver % Variable % PrevValues* correctly by modifying MainUtils.F90 (lines 1431-1433)
Code: Select all

```
ALLOCATE(Solver % Variable % PrevValues( &
SIZE(Solver % Variable % Values), MAX(Solver % TimeOrder, &
Solver % StoreSteps)))
```

- Store results of time step
*n-1* by modifying SolverUtils.F90 (line 7180)
Code: Select all

` Order = MAX(MIN(Solver % DoneTime, Solver % Order),Solver % StoreSteps)`

What else should I do?

Thank you for your attention.

Kind regards,

Andrés