Skip to content
Snippets Groups Projects
Commit 2a858420 authored by EXT Jean-Matthieu Etancelin's avatar EXT Jean-Matthieu Etancelin
Browse files

add simulation flag not to clamp to tend (avoid tiny and possibliy negative irrelevant dt)

parent 3d081bee
No related branches found
No related tags found
1 merge request!16MPI operators
...@@ -47,7 +47,7 @@ class Simulation(object): ...@@ -47,7 +47,7 @@ class Simulation(object):
def __init__(self, name=None, start=0.0, end=1.0, nb_iter=None, dt0=None, def __init__(self, name=None, start=0.0, end=1.0, nb_iter=None, dt0=None,
max_iter=None, t=None, dt=None, times_of_interest=None, max_iter=None, t=None, dt=None, times_of_interest=None,
mpi_params=None, quiet=False, mpi_params=None, quiet=False, clamp_t_to_end=True,
**kwds): **kwds):
""" """
Parameters Parameters
...@@ -76,6 +76,8 @@ class Simulation(object): ...@@ -76,6 +76,8 @@ class Simulation(object):
time dependent dumping. time dependent dumping.
tstart < ti <= tend tstart < ti <= tend
Defaults to empty set. Defaults to empty set.
clamp_t_to_end : bool, optional
Specify if Simulation adjst dt for last iteration to have t=end
Attributes Attributes
---------- ----------
...@@ -114,6 +116,7 @@ class Simulation(object): ...@@ -114,6 +116,7 @@ class Simulation(object):
self.current_iteration = -1 self.current_iteration = -1
self._rank = main_rank if mpi_params is None else mpi_params.rank self._rank = main_rank if mpi_params is None else mpi_params.rank
self._comm = main_comm if mpi_params is None else mpi_params.comm self._comm = main_comm if mpi_params is None else mpi_params.comm
self.clamp_t_to_end = clamp_t_to_end
if (nb_iter is not None): if (nb_iter is not None):
self.nb_iter = nb_iter self.nb_iter = nb_iter
...@@ -258,13 +261,14 @@ class Simulation(object): ...@@ -258,13 +261,14 @@ class Simulation(object):
self.update_time_step(self.target_time_of_interest - self.t()) self.update_time_step(self.target_time_of_interest - self.t())
self._last_forced_timestep = self.dt() self._last_forced_timestep = self.dt()
elif (self.tkp1 >= self.end): elif (self.tkp1 >= self.end):
msg = '** Next iteration is last iteration, clamping dt to achieve t={}. **'
msg = msg.format(self.end)
vprint()
self._print_banner(msg)
self._next_is_last = True self._next_is_last = True
self.tkp1 = self.end if self.clamp_t_to_end:
self.update_time_step(self.end - self.t()) msg = '** Next iteration is last iteration, clamping dt to achieve t={}. **'
msg = msg.format(self.end)
vprint()
self._print_banner(msg)
self.tkp1 = self.end
self.update_time_step(self.end - self.t())
elif (self.dt() == self._last_forced_timestep): elif (self.dt() == self._last_forced_timestep):
self.update_time_step(self._dt0) self.update_time_step(self._dt0)
self._last_forced_timestep = None self._last_forced_timestep = None
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment