<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Dear Dune developers,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I have two things I'd like to discuss with you.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
1.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I would like to propose an interface addition for the Preconditioner template of dune-istl, namely to add a virtual method:</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
</div>
<span>    /*! \brief Update preconditioner.<br>
</span>
<div><br>
</div>
<div>       This method can be called to update the preconditioner,<br>
</div>
<div>       assuming that the sparsity structure of the underlying operator<br>
</div>
<div>       or matrix is unchanged but that its entries may have<br>
</div>
<div>       changed. For simple preconditioners this may be a no-op whereas<br>
</div>
<div>       for more complex preconditioners like ILU or AMG it will not.<br>
</div>
<div>     */<br>
</div>
<div><span style="background: var(--white);">    virtual void update () = 0;</span><br>
</div>
<span></span>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
The intention of this method is to make it possible to reuse expensive structures of a preconditioner, in the common case that the sparsity structure is stable while the coefficients change. Typically, all time-dependent problems will have such behaviour, when
 adaptivity is not used (or not used at every step). Nonlinear problems will benefit even more, even with adaptivity (assuming one does not adapt the grid between nonlinear iterations).</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Prototype implementations have been made in the OPM module opm-simulators (directory opm/simulators/linalg). A new class there, PreconditionerWithUpdate, adds the new interface, and existing preconditioners are made to inherit from it either using a simple
 no-op wrapper, or by adding a proper implementation of update(). The latter has only been done for the AMG and ILU0 preconditioners, but the results are very promising, it significantly cuts linear solve times for OPM Flow using CPR/AMG preconditioning, with
 only marginal increase in linear iterations observed.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
2.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
The changes to dune-istl in Dune 2.6 made it possible to exploit object-oriented techniques for linear solvers and preconditioners. With those changes it became feasible to treat preconditioners polymorphically at runtime. In the opm-simulators module mentioned
 above, we have made a few classes, PreconditionerFactory and FlexibleSolver that exploit this to let itself be configured entirely at runtime, using a parameter tree. It works for both serial and parallel cases, as it is templated on the operator type. I hope
 that this is interesting to the Dune community, and would like to contribute this to dune-istl. There are a few issues to discuss first, though:</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
a) The PreconditionerFactory we have made uses the preconditioner interface with update() as described above, because it is important to us. In any case the interface should be decided on before adding any PreconditionerFactory to dune-istl.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
b) The runtime-flexible classes are controlled by using boost::property_tree::ptree, which in turn is typically created from a JSON file. I imagine that this must change to Dune::ParameterTree? We then need to replace the JSON by something else, or can we add
 JSON support to ParameterTree?</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
This is an example of a JSON file setting up a BiCGStab solver with a CPR preconditioner using AMG as its inner preconditioner (with ILU0 as its smoother), and  ParallelOverlappingILU0 as its outer preconditioner:</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span>{<br>
</span>
<div>    "tol": "1e-2",<br>
</div>
<div>    "maxiter": "20",<br>
</div>
<div>    "verbosity": "0",<br>
</div>
<div>    "solver": "bicgstab",<br>
</div>
<div>    "preconditioner": {<br>
</div>
<div>        "type": "cpr",<br>
</div>
<div>        "pressure_var_index": "1",<br>
</div>
<div>        "finesmoother": {<br>
</div>
<div>            "type": "ParOverILU0",<br>
</div>
<div>            "relaxation": "1.0"<br>
</div>
<div>        },<br>
</div>
<div>        "coarsesolver": {<br>
</div>
<div>            "tol": "1e-1",<br>
</div>
<div>            "maxiter": "1",<br>
</div>
<div>            "verbosity": "0",<br>
</div>
<div>            "solver": "loopsolver",<br>
</div>
<div>            "preconditioner": {<br>
</div>
<div>                "type": "amg",<br>
</div>
<div>                "smoother": "ILU0",<br>
</div>
<div>                "maxlevel": "5",<br>
</div>
<div>                "coarsenTarget": "1000",<br>
</div>
<div>                "alpha": "0.2",<br>
</div>
<div>                "beta": "0.0001",<br>
</div>
<div>                "verbosity": "0",<br>
</div>
<div>                "relaxation": "1.0",<br>
</div>
<div>                "iterations": "1"<br>
</div>
<div>            }<br>
</div>
<div>        },<br>
</div>
<div>        "verbosity": "0"<br>
</div>
<div>    }<br>
</div>
<div>}<br>
</div>
<span></span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I hope this is interesting to you, and welcome any feedback. Also, to ensure any code is formatted according to Dune standards, do anyone have a spec file for clang-format?</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Sincerely Yours,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Atgeirr Flø Rasmussen</div>
</body>
</html>