GEOS icon indicating copy to clipboard operation
GEOS copied to clipboard

Unified residual norm calculations in flow/well solvers

Open francoishamon opened this issue 3 years ago • 1 comments

This PR unifies the calculation of the residual norms in the flow and well solvers.

It works using the following approach:

  • In SolverBaseKernels, the class ResidualNormKernelBase defines two kernels: one for the $L^\infty$ norm and one for the $L^2$ norm. In these two kernels, the compute functions are pure virtual and have to be implemented in derived classes.
  • In the kernel file of each flow solver, the class ResidualNormKernel implements the two compute functions to define how the $L^\infty$ norm and the $L^2$ norm should be computed for each physics.
  • Each flow solver has a new xml attribute normType that the user can use to choose between the $L^\infty$ norm (default) and the $L^2$ norm.

In this PR, the $L^\infty$ norm is computed as: $|| R ||_{\infty} = max_i \bigg( \displaystyle \frac{|R_i|}{(\rho_t)_i \phi_i V_i} \bigg)$ and the $L^2$ norm is computed as: $|| R ||_2 = \displaystyle \frac{ \sqrt{ \sum_i R_i \times R_i }}{ \sqrt{\sum_i (\rho_t)_i \phi_i V_i}}$

  • [X] SinglePhaseFVM
  • [X] ThermalSinglePhaseFVM
  • [X] SinglePhaseHybridFVM
  • [X] SinglePhaseWell
  • [X] CompositionalMultiphaseFVM
  • [X] ThermalCompositionalMultiphaseFVM
  • [X] CompositionalMultiphaseHybridFVM
  • [X] CompositionalMultiphaseWell
  • [X] ProppantTransport

The PR works for all the integrated tests but will probably introduce some small diffs (particularly, $L^2$ is now very different from what is was in SinglePhaseFVM for large meshes because I removed the multiplier).

The PR is ready for review. There are many small things that may make it difficult to review, like:

  • Removed m_inputFluxEstimate from flow solvers
  • Removed m_currentTime and m_currentDt from wells
  • Passed time_n and dt as arguments of calculateResidualNorm (for normalization in wells and mimetic)

but if necessary, we can break the PR into smaller ones

Resolves #1936

francoishamon avatar Aug 03 '22 22:08 francoishamon

If someone has a little bit of time in the next weeks, this (low-priority) PR is ready to be reviewed. It implements the option to choose between the $L^2$ and $L^\infty$ norms for all flow/well solvers. The main file to review in the PR is this kernel file, used here for single-phase flow for instance.

francoishamon avatar Aug 23 '22 01:08 francoishamon