# Assertion failed on ResidualSumPreconditioner

**URL:** <https://precice.discourse.group/t/assertion-failed-on-residualsumpreconditioner/241>\
**Category:** Using preCICE\
**Tags:** acceleration\
**Created:** [May 14, 2020, 10:06am UTC](https://precice.discourse.group/t/assertion-failed-on-residualsumpreconditioner/241 "2020-05-14T10:06:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Claudio](https://avatars.discourse-cdn.com/v4/letter/c/7cd45c/32.png) [@Claudio](https://precice.discourse.group/u/Claudio)\
**Post date:** [May 14, 2020, 10:06am UTC](https://precice.discourse.group/t/assertion-failed-on-residualsumpreconditioner/241/1 "2020-05-14T10:06:46Z")

</div>

Hi,  
sometimes during coupling, at the beginning or after afew timesteps, I get this error:

```plaintext
ASSERTION FAILED
  Location: virtual void precice::acceleration::impl::ResidualSumPreconditioner::_update_(bool, const VectorXd&, const VectorXd&)
  File: .... /PreCICE/precice-2.0.1/src/acceleration/impl/ResidualSumPreconditioner.cpp:43
  Rank: 0
  Failed expression: sum > 0
 0# getStacktrace[abi:cxx11]() in /usr/local/lib/libprecice.so.2
 1# precice::acceleration::impl::ResidualSumPreconditioner::_update_(bool, Eigen::Matrix<double, -1, 1, 0, -1, 1> const&, Eigen::Matrix<double, -1, 1, 0, -1, 1> const&) in /usr/local/lib/libprecice.so.2
 2# precice::acceleration::impl::Preconditioner::update(bool, Eigen::Matrix<double, -1, 1, 0, -1, 1> const&, Eigen::Matrix<double, -1, 1, 0, -1, 1> const&) in /usr/local/lib/libprecice.so.2
 3# precice::acceleration::BaseQNAcceleration::performAcceleration(std::map<int, std::shared_ptr<precice::cplscheme::CouplingData>, std::less<int>, std::allocator<std::pair<int const, std::shared_ptr<precice::cplscheme::CouplingData> > > >&) in /usr/local/lib/libprecice.so.2

```

Generally I manage to avoid this by tweaking with the config file, i.e. by changing the order of participants and changing data on which I apply acceleration. Nevertheless I have no a clear understanding on what is really going on so that I can avoid some try and error, because sometimes the data on the interface meshes seem ok also during each iteration.  
Thank you  
Claudio

---

<div class="post-metadata">

**Author:** ![uekerman](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/uekerman/32/2199_2.png) [@uekerman](https://precice.discourse.group/u/uekerman)\
**Post date:** [May 15, 2020, 7:17am UTC](https://precice.discourse.group/t/assertion-failed-on-residualsumpreconditioner/241/2 "2020-05-15T07:17:47Z")

</div>

Hi @Claudio

This is kind of a known bug, but I just saw that we have no issue yet for this.  
Could you please open a [bug report](https://github.com/precice/precice/issues/new/choose) ?  
To better understand the problem please attach a config that gave this problem and one where your tweaks fixed the problem. That would be very helpful. Maybe also the complete log of the solver that runs into the problem.

As a workaround, I guess you could always just remove the

```xml
<preconditioner type="residual-sum"/>

```

Thanks already,  
Benjamin

---

<div class="post-metadata">

**Author:** ![Claudio](https://avatars.discourse-cdn.com/v4/letter/c/7cd45c/32.png) [@Claudio](https://precice.discourse.group/u/Claudio)\
**Post date:** [June 8, 2020, 3:10pm UTC](https://precice.discourse.group/t/assertion-failed-on-residualsumpreconditioner/241/3 "2020-06-08T15:10:24Z")

</div>

Hi @uekerman  
sorry for the huge delay. I have seen that this happens to me both in parallel-implicit and serial implicit coupling schemes when I have displacements in the acceleration configuration with IQN-ILS.  
So I just switch solvers in serial implicit coupling scheme or I use only Forces in parallel-implicit schemes.  
I have also noticed that changing preconditioner type does not change the behavior.  
If I just remove the preconditioner everything works fine. Does this (removing the preconditioner) affect performance or not?  
Do you still want me to open a bug report?

Thnak you  
Claudio

The following is an example of config file where the use of the preconditioner gives the error:

```
<coupling-scheme:parallel-implicit>
        <time-window-size value="1.e-2" />
        <max-time value="10."/>
        <participants first="Fluid" second="Solid"/>
        <exchange data="Forces0" mesh="Solid-Mesh" from="Fluid" to="Solid" initialize="0"/>
        <exchange data="Displacements0" mesh="Solid-Mesh" from="Solid" to="Fluid" initialize="0"/>

        <max-iterations value="50"/>
        <relative-convergence-measure limit="1e-3" data="Displacements0" mesh="Solid-Mesh"/>
        <relative-convergence-measure limit="1e-3" data="Forces0" mesh="Solid-Mesh"/>
        <extrapolation-order value="2"/>
   
         <acceleration:IQN-ILS>
            <data name="Forces0" mesh="Solid-Mesh"/>
            <data name="Displacements0" mesh="Solid-Mesh"/>
            <!--<preconditioner type="residual-sum"/>-->
            <filter type="QR1" limit="1e-6"/>
            <initial-relaxation value="0.1"/> 
            <max-used-iterations value="50"/>
            <time-windows-reused value="10"/> 
        </acceleration:IQN-ILS>

</coupling-scheme:parallel-implicit>
```

---

<div class="post-metadata">

**Author:** ![uekerman](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/uekerman/32/2199_2.png) [@uekerman](https://precice.discourse.group/u/uekerman)\
**Post date:** [June 10, 2020, 10:48am UTC](https://precice.discourse.group/t/assertion-failed-on-residualsumpreconditioner/241/4 "2020-06-10T10:48:39Z")

</div>

I opened an issue and will “close” this post here. It is a bug. I am just not sure yet whether it is a wrong user input or a wrong assumption in our implementation.

> <https://github.com/precice/precice/issues/771>
>
> We often run into this assertion:
> 
> https://github.com/precice/precice/blob/ec7…36a5663757b97286d2d8553c808b64f2091ad/src/acceleration/impl/ResidualSumPreconditioner.cpp#L43
> 
> if all coupling variables are 0. I am not yet sure if this is a wrong usage of preCICE or just an edge case that needs a more robust treatment. So do we need an error message or do we need a workaround?
> 
> Let's collect more information here.

> [@Claudio](#):
>
> If I just remove the preconditioner everything works fine. Does this (removing the preconditioner) affect performance or not?

Yes, it does if your variables (forces and displacements) live on very different scales. For an example, see [my thesis](https://mediatum.ub.tum.de/doc/1320661/document.pdf), section 3.6.3 .

---

<div class="post-metadata">

**Author:** ![uekerman](https://yyz2.discourse-cdn.com/free1/user_avatar/precice.discourse.group/uekerman/32/2199_2.png) [@uekerman](https://precice.discourse.group/u/uekerman)\
**Post date:** [July 6, 2020, 5:31pm UTC](https://precice.discourse.group/t/assertion-failed-on-residualsumpreconditioner/241/5 "2020-07-06T17:31:36Z")

</div>

Hi @Claudio

After I had a deeper look into this and safeguarded the assertion by understandable error messages I suspect that it actually also points to a potential problem in your adapter. Probably you write the same values twice to preCICE in MBDyn. Maybe because you miss a `read_(block)_scalar/vector_data`?  
A common mistake is to forget that new data can already be available after `initialize`, not only after `advance`, compare the [adapter example](https://github.com/precice/precice/wiki/Adapter-Example#mesh-and-data-access).

> <https://github.com/precice/precice/pull/787>
