# Static condensation for hybrid discontinuous Galerkin methods

**URL:** <https://community.freefem.org/t/static-condensation-for-hybrid-discontinuous-galerkin-methods/524>\
**Category:** General Discussion\
**Created:** [July 28, 2020, 12:35pm UTC](https://community.freefem.org/t/static-condensation-for-hybrid-discontinuous-galerkin-methods/524 "2020-07-28T12:35:02Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![rochabm](https://avatars.discourse-cdn.com/v4/letter/r/c6cbf5/32.png) [@rochabm](https://community.freefem.org/u/rochabm)\
**Post date:** [July 28, 2020, 12:35pm UTC](https://community.freefem.org/t/static-condensation-for-hybrid-discontinuous-galerkin-methods/524/1 "2020-07-28T12:35:03Z")

</div>

Hello everyone,

I’ve been playing around with FF++ to solve some problems quite successfully. We are using a hybrid discontinuous Galerkin formulation. Currently, we are solving a time-dependent Cahn-Hilliard-like problem.

However, we were not able to implement the static condensation (Schur complement) approach to reduce the size of the global linear system.

I’ve looked around and in the documentation, but I haven’t found many tips about this.  
Also I’ve seen papers citing FreeFEM++ and which seem to use this approach.  
I wonder if there is an example somewhere so that I could learn how to do it on FF++ efficiently.

Thanks for your attention.  
Best regards,  
Bernardo

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [July 28, 2020, 2:00pm UTC](https://community.freefem.org/t/static-condensation-for-hybrid-discontinuous-galerkin-methods/524/2 "2020-07-28T14:00:25Z")

</div>

What do you want to do efficiently? Static condensation or solving Cahn–Hilliard equation?

---

<div class="post-metadata">

**Author:** ![rochabm](https://avatars.discourse-cdn.com/v4/letter/r/c6cbf5/32.png) [@rochabm](https://community.freefem.org/u/rochabm)\
**Post date:** [July 28, 2020, 2:23pm UTC](https://community.freefem.org/t/static-condensation-for-hybrid-discontinuous-galerkin-methods/524/3 "2020-07-28T14:23:34Z")

</div>

Sorry if the message was confusing.

I would like to perform the static condensation.  
The CH code is working, but without static condensation.

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [July 29, 2020, 4:48pm UTC](https://community.freefem.org/t/static-condensation-for-hybrid-discontinuous-galerkin-methods/524/4 "2020-07-29T16:48:48Z")

</div>

You want to do static condensation on each element? Or for the global system?

---

<div class="post-metadata">

**Author:** ![frederichecht](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/frederichecht/32/15_2.png) [@frederichecht](https://community.freefem.org/u/frederichecht)\
**Post date:** [July 30, 2020, 1:56pm UTC](https://community.freefem.org/t/static-condensation-for-hybrid-discontinuous-galerkin-methods/524/5 "2020-07-30T13:56:09Z")

</div>

To day they no sparse static condensation in FreeFem++  
in fact you want to eliminate of internal dof of the formulation.

Il is not to hard of code with the HashMatrix, it is the same ShurComplement.cpp algorithm of plugin  
but the result is a sparse matrix (ie. a hash matrix in freefem++)

the only difficulty is to compute  
I given numbering of Schur complement I[i] is the index in A of the i in S if I[i] \>=0  
the matrix A is split in 4 blocks [[AII,AIJ],[AJI, AJJ]] where

J = index not in I, AII = A(I,I),  
S = AII - AIJ AJJ^-1 AJI

but le matrix AJJ^-1 is a diagonal block matrix  
if we get the correct numbering J. (ie. we get a numbering by connect component  
of the graphe G\_A defined by A (ie i,j a link if a\_ij is non zero) restricted on J. ).  
then S is Sparse matrix.

If you are able to code this you are well come.  
F. Hecht.

---

<div class="post-metadata">

**Author:** ![rochabm](https://avatars.discourse-cdn.com/v4/letter/r/c6cbf5/32.png) [@rochabm](https://community.freefem.org/u/rochabm)\
**Post date:** [July 31, 2020, 11:47am UTC](https://community.freefem.org/t/static-condensation-for-hybrid-discontinuous-galerkin-methods/524/6 "2020-07-31T11:47:22Z")

</div>

Thanks a lot for the reply.  
In fact I notice it would be difficult to do it on the element level.  
And later on I found this link:

> <https://github.com/FreeFem/FreeFem-sources/blob/develop/examples/hpddm/Schur-complement-PETSc.edp>

which could be helpful for doing it globally.  
I will check it.  
Best regards.

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [July 31, 2020, 5:23pm UTC](https://community.freefem.org/t/static-condensation-for-hybrid-discontinuous-galerkin-methods/524/7 "2020-07-31T17:23:21Z")

</div>

There are a lot of PETSc things to help you out. You could also use a fieldsplit preconditioner, and approximate the Schur complement, see this [documentation](https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/PC/PCFIELDSPLIT.html) page.
