Commit 3bc88abe authored by Valentin Vallaeys's avatar Valentin Vallaeys
Browse files

add DIRK1 2 3 to sw2dWD in interface

parent 4c5f612e
Pipeline #1691 failed with stage
in 26 minutes and 53 seconds
......@@ -155,7 +155,7 @@ class ShallowWater2dWD:
self._solution.setFieldName(1, 'Hu')
self._solution.setFieldName(2, 'Hv')
self._name = "sw2dC"
if temporal_scheme == "explicit" or temporal_scheme == "implicit" or temporal_scheme == "multirate":
if temporal_scheme in ["explicit","implicit","multirate","DIRK1","DIRK2","DIRK3"]:
self._temporal_scheme = temporal_scheme
else:
dgpy.Msg.Fatal("Unknown temporal scheme "+temporal_scheme+" for shallow water equation !")
......@@ -1069,9 +1069,15 @@ class Loop:
if equation._name == "sw2d" or equation._name == "sw2dC":
if equation._temporal_scheme == "explicit":
equation._temporal_solver = dgpy.dgERK(equation._equation, None, dgpy.DG_ERK_EULER)
elif equation._temporal_scheme == "implicit":
elif equation._temporal_scheme in ["implicit","DIRK1","DIRK2","DIRK3"]:
if equation._temporal_scheme == "DIRK1":
order = 1
elif equation._temporal_scheme == "DIRK3":
order = 3
else:
order = 2
equation._sys = slim_private._new_default_linear_system(equation._domain, equation._equation)
equation._temporal_solver = dgpy.dgDIRK(equation._equation, equation._sys.dof_manager, 2)
equation._temporal_solver = dgpy.dgDIRK(equation._equation, equation._sys.dof_manager, order)
equation._temporal_solver.getNewton().setVerb(10)
equation._temporal_solver.getNewton().setAtol(1e-8)
equation._temporal_solver.getNewton().setRtol(1e-8)
......@@ -1085,7 +1091,7 @@ class Loop:
equation._domain._bath_PC.compute(equation._domain._bath.getFunction(),dgpy.dataCacheMap.NODE_GROUP_MODE)
equation._domain._bath_gradient_PC.compute(equation._domain._bath.getFunctionGradient())
else:
dgpy.Msg.Fatal("Temporal Scheme "+self._temporal_scheme+" not implemented!")
dgpy.Msg.Fatal("Temporal Scheme "+equation._temporal_scheme+" not implemented!")
if equation._domain._solve_on_manifold:
self._solution_global = dgpy.dgDofContainer(equation._domain._groups, 4)
......@@ -1118,7 +1124,6 @@ class Loop:
equation._sys_tracer = slim_private._new_default_linear_system(equation._domain, equation._equation)
equation._temporal_solver = dgpy.dgMERK(equation._equation, equation._sys_tracer.dof_manager, dgpy.DG_ERK_EULER)
elif equation._temporal_scheme == "implicit":
equation._sys_tracer1 = slim_private._new_default_linear_system(equation._domain, equation._equation)
equation._sys_tracer2 = slim_private._new_default_linear_system(equation._domain, equation._equation)
equation._temporal_solver = dgpy.dgMDIRK(equation._equation, equation._sys_tracer1.dof_manager, equation._sys_tracer2.dof_manager, 2)
equation._temporal_solver.getNewton().setVerb(10)
......@@ -1167,7 +1172,7 @@ class Loop:
_length = self._number_of_equations
_scheme = self._equations[0]._temporal_scheme
if _index>-1:
if _scheme == "implicit":
if _scheme in ["implicit","DIRK1","DIRK2","DIRK3"]:
for i in range(_length):
_equations_ordered.append(self._equations[(i+_index)%_length])
self._index_sw2d_eq = 0
......@@ -1184,7 +1189,7 @@ class Loop:
def compute_dt(self):
"""compute the optimal time step"""
_temporal_scheme = self._equations[0]._temporal_scheme
if _temporal_scheme == "implicit":
if _temporal_scheme in ["implicit","DIRK1","DIRK2","DIRK3"]:
if self._index_sw2d_eq > -1:
_dt_min = min(self._max_dt, self._export_time)
else:
......@@ -1246,7 +1251,7 @@ class Loop:
dgpy.Msg.Fatal("The wetting-drying value must be the same for all equations")
if i._temporal_scheme != temporal_scheme:
dgpy.Msg.Fatal("The temporal scheme must be the same for all equations")
if i._temporal_scheme != "explicit" and i._temporal_scheme != "implicit" and i._temporal_scheme != "multirate":
if i._temporal_scheme not in ["explicit","implicit","DIRK1","DIRK2","DIRK3","multirate"] :
dgpy.Msg.Fatal(temporal_scheme + " is not implemented in the time integration loop !")
if self._index_sw2d_eq > -1 and self._equations[self._index_sw2d_eq]._wetting_drying is not None:
self._bathy = self._equations[self._index_sw2d_eq]._equation.getBathymetry()
......@@ -1282,7 +1287,7 @@ class Loop:
for j in range(self._equations[0]._temporal_solver.nstep()):
for i in self._equations:
if self._time > i._initial_time-self._eps and self._time < i._final_time+self._eps:
if offline and i._temporal_scheme == "implicit":
if offline and i._temporal_scheme in ["implicit","DIRK1","DIRK2","DIRK3"]:
if self._n_index_per_period > 0:
index = self._index_start+self._n_iter_offline%self._n_index_per_period
else:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment