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

Local-Global Solver API #144

Draft
wants to merge 26 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
c95cc7c
Prototyping.
termi-official Aug 26, 2024
9a537e0
Inconsistent version for multilevel newton works.
termi-official Aug 28, 2024
5d4d5b2
Rename and stricter convergence criterion.
termi-official Aug 28, 2024
2e4a246
Inconsistent tangent.
termi-official Aug 28, 2024
a39e31b
Local solver derp.
termi-official Aug 28, 2024
4f17a3b
Dunno how that happened. Now it at least converges linearly.
termi-official Aug 28, 2024
7b3178f
Can reproduce issue in 1D
termi-official Aug 28, 2024
a049963
Fixed some issues
termi-official Aug 29, 2024
e7c072f
Cleanup.
termi-official Aug 29, 2024
1fd1e19
Chasing some very stupid error.
termi-official Aug 30, 2024
487c58f
Works finally.
termi-official Aug 30, 2024
a8dc58b
Alternative version
termi-official Aug 30, 2024
f9c950e
Refactor backward Euler for affine right hand side
termi-official Sep 3, 2024
9f9724d
Generalize the affine function API.
termi-official Sep 3, 2024
3f53053
Stash current state
termi-official Sep 4, 2024
735e937
Merge main
termi-official Sep 4, 2024
ca9ce8e
Fix precompilation
termi-official Sep 4, 2024
80db657
Some temporary changes
termi-official Sep 14, 2024
f2271d9
More changes
termi-official Sep 17, 2024
2ea9641
Recover 1D-v2
termi-official Sep 17, 2024
2efda1a
Trying to generalize
termi-official Sep 18, 2024
794fae3
Generalize example with local solve
termi-official Sep 18, 2024
3cedb0d
Docs
termi-official Sep 19, 2024
110b573
More comments for v2
termi-official Sep 19, 2024
f7f038b
First step to strip down the nonlinear operator and add de-/compressi…
termi-official Nov 5, 2024
0228b37
Update example manifest and typos
termi-official Nov 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ bibtex_plugin = CitationBibliography(
"topics/operators.md",
"topics/couplers.md",
"topics/time-integration.md",
"topics/nonlinear-solver.md",
],
"How-to guides" => [
"Overview" => "howto/index.md",
Expand Down
1 change: 1 addition & 0 deletions docs/src/api-reference/solver.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ SchurComplementLinearSolver

```@docs
NewtonRaphsonSolver
MultiLevelNewtonRaphsonSolver
```


Expand Down
14 changes: 14 additions & 0 deletions docs/src/assets/references.bib
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ @article{God:1959:dmn
year={1959},
publisher={Russian Academy of Sciences, Steklov Mathematical Institute of Russian~…}
}

@article{Ges:1989:ote,
author={Geselowitz, D.B.},
journal={Proceedings of the IEEE},
Expand All @@ -282,6 +283,7 @@ @article{Ges:1989:ote
pages={857-876},
doi={10.1109/5.29327}
}

@article{PotDubRicVinGul:2006:cmb,
author={Potse, Mark and Dube, Bruno and Richer, Jacques and Vinet, Alain and Gulrajani, Ramesh M.},
journal={IEEE Transactions on Biomedical Engineering},
Expand All @@ -292,6 +294,7 @@ @article{PotDubRicVinGul:2006:cmb
pages={2425-2435},
doi={10.1109/TBME.2006.880875}
}

@article{OgiBalPer:2023:seats,
author = {Ogiermann, Dennis and Perotti, Luigi E. and Balzani, Daniel},
journal = {International Journal for Numerical Methods in Biomedical Engineering},
Expand All @@ -302,3 +305,14 @@ @article{OgiBalPer:2023:seats
pages = {e3670},
doi = {https://doi.org/10.1002/cnm.3670},
}

@article{RabSanHsu:1979:mna,
title={A multilevel Newton algorithm with macromodeling and latency for the analysis of large-scale nonlinear circuits in the time domain},
author={Rabbat, N and Sangiovanni-Vincentelli, Alberto and Hsieh, Hsueh},
journal={IEEE Transactions on Circuits and Systems},
volume={26},
number={9},
pages={733--741},
year={1979},
publisher={IEEE}
}
97 changes: 97 additions & 0 deletions docs/src/topics/nonlinear-solver.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# Nonlinear Solver

## Multi-Level Newton-Raphson

A quadratically convergent Newton-Raphson scheme has been proposed by [RabSanHsu:1979:mna](@citet).
Let us assume we have a block-nonlinear problem with unknowns $\hat{\bm{u}}$ and $\hat{\bm{q}}$ of the following form:

```math
\begin{aligned}
\bm{\hat{f}_{\textrm{G}}}(\hat{\bm{u}}, \hat{\bm{q}}) &= 0 \\
\bm{\hat{f}_{\textrm{L}}}(\hat{\bm{u}}, \hat{\bm{q}}) &= 0
\end{aligned}
```

where solving $\bm{\hat{f}_{\textrm{L}}}(\hat{\bm{u}}, \hat{\bm{q}}) = 0$ is easy to solve for fixed $\hat{\bm{u}}$.
If we can enforce this constraint, then we can rewrite the first equation by *implicit function theorem* as:
```math
\bm{\hat{f}_{\textrm{G}}}(\hat{\bm{u}}, \hat{\bm{q}}(\hat{\bm{u}})) = 0
```
Solving this modified problem with a Newton-Raphson algorithm requires a linearization around $\hat{\bm{u}}$, such that we have to solve at each Newton step the following linear problem
```math
\left( \frac{\partial \bm{\hat{f}_{\textrm{G}}} }{\partial \hat{\bm{u}}} + \frac{\partial \bm{\hat{f}_{\textrm{G}}} }{\partial \hat{\bm{q}}} \frac{\mathrm{d} \hat{\bm{q}} }{\mathrm{d} \hat{\bm{u}}} \right) \Delta \hat{\bm{u}} = -\bm{\hat{f}_{\textrm{G}}}(\hat{\bm{u}}, \hat{\bm{q}}(\hat{\bm{u}}))
```
In the continuum mechanics community the system matrix is also known as the *consistent linearization*.

The last missing piece the implicit function part for the system matrix, which is determined by solving an additional linear system:
```math
\frac{\partial \bm{\hat{f}_{\textrm{L}}}(\hat{\bm{u}}^{i}, \hat{\bm{q}}^{i}) }{\partial \hat{\bm{q}}} \frac{\mathrm{d} \hat{\bm{q}} }{\mathrm{d} \hat{\bm{u}}} = -\frac{\partial \bm{\hat{f}_{\textrm{L}}}(\hat{\bm{u}}^{i}, \hat{\bm{q}}^{i}) }{\partial \hat{\bm{u}}}
```

### Using finite-element structure

Time discretization schemes applied to finite element semi-discretizations with $L_2$ variables (called *internal variables*) usually lead to block-nonlinear problems with *local-global structure*, as described above.
This is commonly found in continuum mechanics problems.
The local-global structure is simply a result of the algebraic decoupling of the internal variables, as they are associated with the quadrature points.
For the resulting nonlinear form of the space-time discretization with field unknowns $u$ and internal unknowns $q = (q_1, ... q_{nqp})$, we can write the finite element discretization formally as

```math
\begin{aligned}
f_G(u,q,p,t) =& ... \\
f_{Q}(u,q,p,t) =& ... \\
\end{aligned}
```

TODO picture with the fundamental decomposition operators

The internal unknowns $q$ are located at the quadrature points which implies the following structure

```math
\begin{aligned}
f_{Q_1}(u,q_1,p,t) =& ... \\
f_{Q_2}(u,q_2,p,t) =& ... \\
\vdots \\
f_{Q_{nqp}}(u,q_{nqp},p,t) = &... \\
\end{aligned}
```

### Example: Creep Test of 1D Linear Viscoelasticity

A simple linear viscoelastic material model in 1D in weak form is:

```math
\begin{aligned}
0 =& \int_{\Omega} (E_0 \partial_x u(x,t) + E_1 (\partial_x u(x,t) + q(x,t))) \cdot \partial_x \delta u(x) \textrm{d}x + Neumann \\
\partial_t q(x,t) =& \frac{E_1}{\eta_1} (\partial_x u(x,t)-q(x,t))
\end{aligned}
```

Assuming we have a single 1D element $\Omega = [-1,1]$ with linear ansatz functions and Gauss-Legendre quadrature (i.e. 2 points) the Neumann conditon $\partial_x u(1,t) = 1$ and the Dirichlet condition $u(-1,t) = 0$, then applying a Galerkin semi-discretization yields the following linear DAE in mass matrix form:

```math
\begin{aligned}
0 &= \tilde{u}_1 \\
0 &= 0.5\left(-(E_0 + E_1) \tilde{u}_1 + (E_0 + E_1) \tilde{u}_2 - E_1 \tilde{q}_1 - E_1 \tilde{q}_2 + 1\right) \\
d_t \tilde{q}_1 &= \frac{E_1}{\eta_1} (-\tilde{u}_1+\tilde{u}_2-\tilde{q}_1) \\
d_t \tilde{q}_2 &= \frac{E_1}{\eta_1} (-\tilde{u}_1+\tilde{u}_2-\tilde{q}_2)
\end{aligned}
```
or, after condensing the first equation,
```math
\begin{aligned}
0 &= 0.5\left((E_0 + E_1) \tilde{u}_2(t) - E_1 \tilde{q}_1(t) - E_1 \tilde{q}_2(t) + 1\right) \\
d_t \tilde{q}_1(t) &= \frac{E_1}{\eta_1} (-\tilde{u}_1+\tilde{u}_2(t)-\tilde{q}_1(t)) \\
d_t \tilde{q}_2(t) &= \frac{E_1}{\eta_1} (-\tilde{u}_1+\tilde{u}_2(t)-\tilde{q}_2(t))
\end{aligned}
```

Applying the Backward Euler in time to this system we obtain the ,,nonlinear'' system
```math
\begin{aligned}
0 &= 0.5\left((E_0 + E_1) \hat{\tilde{u}}^n_2 - E_1 \hat{\tilde{q}}_1 - E_1 \hat{\tilde{q}}_2 + f(t_n)\right) &= f_G(\hat{\tilde{u}}_2, \hat{\tilde{q}}_1, \hat{\tilde{q}}_2) \\
0 &= \hat{\tilde{q}}^n_1 - \hat{\tilde{q}}^{n-1}_1 - \Delta t_n \frac{E_1}{\eta_1} (-\hat{\tilde{u}}_1+\hat{\tilde{u}}_2-\hat{\tilde{q}}_1) &= f_{Q_1}(\hat{\tilde{u}}_2, \hat{\tilde{q}}_1) \\
0 &= \hat{\tilde{q}}^n_2 - \hat{\tilde{q}}^{n-1}_2 - \Delta t_n \frac{E_1}{\eta_1} (-\hat{\tilde{u}}_1+\hat{\tilde{u}}_2-\hat{\tilde{q}}_2) &= f_{Q_2}(\hat{\tilde{u}}_2, \hat{\tilde{q}}_2) \\
\end{aligned}
```

where we can observe that the internal problems are decoupled. The system can now be solved with the multi-level Newton-Raphson as described above.
Loading