geo-fluid-dynamics / phaseflow-fenics

Phaseflow simulates the convection-coupled melting and solidification of phase-change materials.
MIT License
52 stars 23 forks source link

Formulate an error estimator #119

Closed agzimmerman closed 6 years ago

agzimmerman commented 7 years ago

Right now our adaptive mesh refinement is much too ad-hoc.

agzimmerman commented 7 years ago

One easy idea would be to always solve the grid also on something with every cell uniformly refined. Some thought would need to be put into how to compute the error between those two solutions on each cell of the fine mesh.

agzimmerman commented 6 years ago

This paper discusses a hierarchical error estimator for the solution of the Stefan problem with adaptive finite elements.

agzimmerman commented 6 years ago

Now I'm having some luck using fenics.AdaptiveNonlinearVariationalSolver here.

agzimmerman commented 6 years ago

I got the built-in fenics.AdaptiveNonlinearVariationalSolver to work on the branch https://github.com/geo-fluid-dynamics/phaseflow-fenics/tree/feature/adaptive_solver

Here's the result:

t0p05

On that branch I've thrown away a lot of features of Phaseflow that were complicating the code and making it too difficult to debug. So the branch requires plenty of cleaning up before we can use it as master.

agzimmerman commented 6 years ago

@julekowalski , regarding our conversation yesterday: Now the adaptive solver, using the dual-problem error estimator, works as expected :)

agzimmerman commented 6 years ago

We can begin with the coarsest possible mesh and this still works great: t0p05

agzimmerman commented 6 years ago

Here is the source code where the error is estimated: https://bitbucket.org/fenics-project/dolfin/src/3d1f687ec9ee39afc0fe6e01800431995b42ad04/dolfin/adaptivity/ErrorControl.cpp?at=2017.1.0&fileviewer=file-view-default

agzimmerman commented 6 years ago

The implementation now fails when solving problems where some of the unknowns are trivial, e.g. the lid-driven cavity problem where T_k and P(T_k) are constant. I'm investigating this in issue #137.

Update: The issue is not related to trivial unknowns, or at least we have working examples with trivial unknowns.

agzimmerman commented 6 years ago

The estimator worked well for the toy PCM problem, but is not working well for the octadecane melting benchmark (issue #79).

agzimmerman commented 6 years ago

The adaptive goal functional M = $\phi(T)$ is working well for the Stefan problem and the octadecane PCM melting benchmark as of PR #180.

Still our selection of the functional and of the adaptive solver tolerance is ad-hoc. For now the plan is to let the user provide any functional (see issue #192).

Ideally we could provide a selection of useful goal functionals and recommendations for the tolerance. These will be demonstrated with the tests, examples, and notebooks. For now we have much to learn before this can be done robustly.