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

Request for input: Laplace-based linear and bilinear integrators #4238

Open
IdoAkkerman opened this issue Apr 8, 2024 · 12 comments
Open

Request for input: Laplace-based linear and bilinear integrators #4238

IdoAkkerman opened this issue Apr 8, 2024 · 12 comments

Comments

@IdoAkkerman
Copy link
Contributor

IdoAkkerman commented Apr 8, 2024

I am interested in implementing LinearFormIntegrator and BilinearFormIntegrator involving the Laplacian.

Any heads up on potential conflicting or duplicate effort is highly appreciated.
Any tips or warning for pitfalls are also welcome.
Last but not least, if I am skipping some useful functionality for other use cases please let me know.

My personal interest for these terms are stabilized methods. So first would be the scalar convection-diffusion case which would require the following:

  • $(\Delta w, f)$ Linear form for a given Coefficient f
  • $(w,q\Delta \phi)$ Bilinear form for a given Coefficient q
  • $({\bf a}\cdot \nabla w,\Delta \phi)$ Bilinear form for a given VectorCoefficient a
  • $(\Delta w,q \phi)$ Bilinear form for a given Coefficient q
  • $(\Delta w,{\bf a}\cdot \nabla \phi)$ Bilinear form for a given VectorCoefficient a
  • $(\Delta w,q\phi)$ Bilinear form for a given Coefficient q

Next would be vector based case, such as navier-stokes. Which would require the same as above but all the scalar shape functions become vector shape function. The coefficients will in principle be of Matrix form, probably more efficient routines are available for scalar or vector (= diagonal of matrix). I will consider implementing all three.

To enable the pressure and PSPG terms two mixed terms are required.

  • $(\nabla q, Q \Delta {\bf u})$ Bilinear form for a given MatrixCoefficient Q
  • $(\Delta {\bf w}, Q \nabla p)$ Bilinear form for a given MatrixCoefficient Q

Hessian based integrators will not be considered in this PR.

@IdoAkkerman
Copy link
Contributor Author

Implementation effort can be reduced by using the TransposeIntegrator I assume?

@IdoAkkerman
Copy link
Contributor Author

Is there a need for a Trans.LaplaceOrder(fe) ? As place holder I am going with fe.GetOrder() - 2 for now.

@v-dobrev
Copy link
Member

v-dobrev commented Apr 9, 2024

This sounds great to me!

Is there a need for a Trans.LaplaceOrder(fe) ? As place holder I am going with fe.GetOrder() - 2 for now.

I'm not sure we really need to target exact integration of Laplacian terms, even if that is possible in some cases. I think using the lowest quadrature order (e.g., ignoring the transformation order) that works robustly is best. It is hard to test all possible use cases for "works robustly", so go with what you find in your tests or what is recommended in the literature, if there are such recommendations.

How do you plan to compute the Laplacian on a general element? Do you plan to use exact computation at quadrature points using the Hessian and the Jacobian of the transformation? An approximate alternative that only requires the Jacobian is to project the gradient (e.g. using nodal interpolation) back into the same FE space and then take the divergence. I think @bslazarov and/or @vladotomov wanted to try something like that but I'm not 100% certain.

@IdoAkkerman
Copy link
Contributor Author

The Laplacian/Hessian is already implemented - in principle.
The base class has the (some) interfaces defined and for NURBS elements it should work.
I do not know about other elements.
There is likely still room for extensions, improvements and simplifications.

The Laplacian is compute as the trace of the Hessian which sounds expensive but is the easiest way to have the correct effect of the mapping . There is a check of to see if the Transformation is affine,
in that case a faster, more direct, way of computing the Laplacian is available.

@IdoAkkerman
Copy link
Contributor Author

@michi002 My apologies, I pushed it to an other local repo. I will push it tomorrow, unfortunately I can not ssh into my machine due to overly zealous security...

@michi002
Copy link
Member

@IdoAkkerman thank you. I had a look on your commit.
I think you only need non-mixed spaces for your purpose. However I would also need
$$ \langle \Delta u, v \rangle $$
for v piecewise constant.
Is it ok for you, if I just add the mixed version in your branch? Or should I branch out from your branch for that?
I will adpat to your workflow, as you started it :)

@IdoAkkerman
Copy link
Contributor Author

IdoAkkerman commented Apr 17, 2024

@michi002 Convection-diffusion only requires the scalar implementation. However, the SUPG/PSPG terms for Stokes/Navier-Stokes involve terms where the velocity and pressure spaces are combined, or is there a way to bypass that?

Regarding, the term you are interested in, that can be obtained by by using the 4th term, viz.
$(\Delta w,q \phi)$ and choosing a zero order L2 finite element for $\phi$ (v in your comment) .

@michi002
Copy link
Member

@IdoAkkerman
Yes, this is the bilinear form I need. But we also need to also implement the member-routine for mixed spaces
virtual void AssembleElementMatrix2(const FiniteElement &trial_fe, const FiniteElement &test_fe, ElementTransformation &Trans, DenseMatrix &elmat);
or not?
I have only seen the routine for the same ansatz and test-function
/// Support for use in BilinearForm. Can be used only when appropriate. virtual void AssembleElementMatrix(const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &elmat)

Concerning the coefficient:
I guess you are right, If the coefficients are differentiable one can just use the chain rule.

@IdoAkkerman
Copy link
Contributor Author

Implementing AssembleElementMatrix2 should be minimal effort, so worth to include in the PR I guess.
However, the use case for AssembleElementMatrix2 is not clear to me. By itself not so much of a concern, but this would make it a bit harder to debug and test (unit_test).

Do you have a clear application in mind?

@michi002
Copy link
Member

michi002 commented Apr 19, 2024

@IdoAkkerman
Yes, I want to apply it in distributed optimal control. I want to solve the equation
$-\Delta u = z$
for $z$, where $u$ is given. For implementing control constraints we want a simple connection between $z$ and $u$.
If we choose $u$ to be a $C^1$ spline and $z$ to be piecewise constant we can easily do that by
$\underline{z}_h = M_h^{-1} K_h \underline{u}_h$,
where $M_h$ is the (diagonal) mass for piecewise constants and $K_h$ is defined via
$\langle -\Delta u_h, p_h \rangle$
and here $p_h$ is also piecewise constant.

I do not know if it is an important case for the general userbase, but I think a mixed version (AssembleElementMatrix2) might come in handy for some users.

@IdoAkkerman
Copy link
Contributor Author

So you are converting
$-\Delta u = z$
into a discrete weak form
$\langle-\Delta u^h, p_h \rangle =\langle z, p_h \rangle$
where $u^h$ are $C^1$ spline and $p_h$ are piecewise constants.
I was contemplating this as test case :)
But I do not see the logic of doing this... but perhaps it is something application specific.

Why not test with $C_1$ splines similar as used for $u^h$ -- and use integration by parts.
$\langle\nabla u^h, \nabla p_h \rangle - \langle\nabla u^h, n p_h \rangle_\Gamma=\langle z, p_h \rangle$
This will yield the standard optimal Galerkin formulation for the Poisson problem.

@michi002
Copy link
Member

michi002 commented Apr 22, 2024

@IdoAkkerman
I am considering this for distributed optimal control, where $z$ (the control) is the quantity of interest.
We want to approximate the control $z_h$ via piecewise constants. The Laplace problem for the state, I solve as you suggest with $C^1$ test and ansatzfunctions.
So suppose the state $u_h$ is given (via a minimization problem), I want to reconstruct the right hand side, that gives this state.
Then I have to find $z_h \in Z_h$ such that
$\langle z_h, p_h \rangle = \langle -\Delta u_h, p_h\rangle \quad \forall p_h \in Y_h.$
If I now take z_h to be piecewise constant, I either have to take $u_h$ to be a $C^1$ function, to apply the strong Laplacian and $Y_h=Z_h$, or $Y_h$ to be piecewise linear continuous functions, to apply integration by parts, yielding a rectangular left hand side. In the second case I would have to solve some kind of saddle point problem, which I would like to avoid.

If you are really interested why we do that, you can look at our preprint: https://arxiv.org/abs/2404.10350
But I tried to summarize it. In the preprint we also did not consider control constraints yet, where this form is also advantageous.

I hope that answers your question.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants