## Solutions at time steps n and n-1

Discussion about coding and new developments
amrueda
Posts: 5
Joined: 19 Apr 2016, 02:43
Antispam: Yes
Location: Colombia

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

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

Code: Select all

`` Solver%Variable%PrevValues(:,1) ``
Is there a way to get the solution at time step n-1?

Thank you very much.
Kind regards,

Andrés
mzenker
Posts: 1999
Joined: 07 Dec 2009, 11:49
Location: Germany

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

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
raback
Site Admin
Posts: 4173
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

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

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
amrueda
Posts: 5
Joined: 19 Apr 2016, 02:43
Antispam: Yes
Location: Colombia

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

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