Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Iteration number based time stepping #2318

Merged
merged 26 commits into from
Jan 22, 2019
Merged

Iteration number based time stepping #2318

merged 26 commits into from
Jan 22, 2019

Conversation

endJunction
Copy link
Member

The main algorithm was implemented quite some time already, but there was no driver for it. Here it goes.

I'd suggest commit-wise review.

EXECUTABLE_ARGS RichardsFlow_2d_small_iteration_adaptive_dt.prj
TESTER vtkdiff
REQUIREMENTS NOT OGS_USE_MPI
# No vtkdiff comparison here, because of the different file names for
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then I guess you have to remove TESTER vtkdiff-line.

Copy link
Member

@wenqing wenqing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

dt = _min_ts;
else if (dt > _max_ts)
dt = _max_ts;
if (dt < _min_dt)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dt = std::max(dt, _min_dt);

{
dt = _min_dt;
}
else if (dt > _max_dt)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dt = std::min(dt, _max_dt);

_min_dt(min_dt),
_max_dt(max_dt),
_initial_dt(initial_dt),
_max_iter(_iter_times_vector.empty() ? 0 : _iter_times_vector.back())
Copy link
Member

@TomFischer TomFischer Jan 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I'm not so familiar with the time stepping. Could you give a simple and short example what data is stored in _iter_times_vector? Docu is below.

"\n\tSingleStep,"
"\n\tFixedTimeStepping,"
"\n\tEvolutionaryPIDcontroller,",
"\n\t IterationNumberBasedTimeStepping\n",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation of IterationNumberBasedTimeStepping is inconsistent with other time stepping schemas.

Copy link
Member

@TomFischer TomFischer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. ⏩

@jbathmann
Copy link

jbathmann commented Jan 17, 2019

I did some tests with the setup attached to this post on this and found some points, which were not exactly clear to me:

  • The algorithm seems to fail if nonlinear_solvers/nonlinear_solver/max_iter == max(number_iterations), because last element of list does not seem to be taken into account

  • The algorithm seems to fail, if max_iterations (same as above) > max(number_iterations), because multiplier is set to 1

  • I needed some time to figure out, what number_iterations and multiplier tag mean. Maybe some comments on this in the .md files would be really nice. Or did I miss on finding the documentation?

  • -The fixed output times from the project file are not hit. This might be the reason the lack of output files for the fixed times?

Hope this helps?
testsetup.zip

endJunction and others added 22 commits January 20, 2019 22:14
Obligatory clang-format too.

Choosing int over size_t for number of iterations -- nobody
is going to wait that long anyway.
It contains a boolean for met error norms and a
number of iterations of the solver made.

The number of iterations is needed for
a timestepping scheme.
Aside of the I/F changes, the expected result also changed.
The first zero in nr_iterations is added, for the simulated
first time step.
The iteration number is now set through the next() call.
Remove duplicate docu from the inherited functions.
Otherwise the timestepper will repeat the second iteration
of the first time step with the initial_dt and simulation will
be aborted. In the current implementation the minimum dt
will be taken for the second iteration.
Change the way a multiplier is computed, s.t. for
a set of iterations and multipliers as:
i = 5 8 10
m = 2 1 0.5
following multiplier is taken
m(<5) = 2
m(5-7) = 2
m(8-9) = 1
m(>=10) = 0.5

This is easier to comprehend in the project files.
@endJunction
Copy link
Member Author

As @jbathmann mentioned above there are some issues with the repeating of the time steps for certain combinations of number_of_iterations vector and the max_iter in the non-linear solver; the simulations stops, although it could have succeeded. Increasing the max_iter seems to resolve this kind of problems.

Real fix need a major rewrite of the time loop.

Please review from the "[doc] Add IterationNumberBasedTS prj tags docu." commit 'til the end, especially the changes in the ProcessLib/UncoupledProcessesTimeLoop.cpp

First removal force the convergence checks to be executed.
Last two changes handle the t being (almost) equal to the
end time.
Copy link
Member

@wenqing wenqing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good in these three commits.

@@ -431,7 +425,8 @@ double UncoupledProcessesTimeLoop::computeTimeStepping(
}
else
{
if (t < _end_time)
if (t < _end_time || std::abs(t - _end_time) <
std::numeric_limits<double>::epsilon())
Copy link
Member

@wenqing wenqing Jan 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just found a std function: std::islessequal.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I didn't know that function. But from cppreference it seems that the only difference to operator<=(x, y) is that the floating point exceptions are not raised (and we do like exceptions).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see.

@@ -451,7 +446,8 @@ double UncoupledProcessesTimeLoop::computeTimeStepping(
}
else
{
if (t < _end_time)
if (t < _end_time || std::abs(t - _end_time) <
std::numeric_limits<double>::epsilon())
Copy link
Member

@wenqing wenqing Jan 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be replaced with std::islessequal.

Copy link
Member

@TomFischer TomFischer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@endJunction endJunction merged commit 83cb86a into ufz:master Jan 22, 2019
@endJunction endJunction deleted the TimeStepping branch January 22, 2019 11:25
@ogsbot
Copy link
Member

ogsbot commented Jun 19, 2020

OpenGeoSys development has been moved to GitLab.

See this pull request on GitLab.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants