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

Help with Understanding and Deriving NonlinearFormIntegrator::AssembleElementGrad #3975

Closed
j-signorelli opened this issue Nov 11, 2023 · 3 comments
Assignees
Labels

Comments

@j-signorelli
Copy link
Contributor

j-signorelli commented Nov 11, 2023

Hello,

I have been working through understanding how to implement my own NonlinearFormIntegrator specifically for nonlinear scalar diffusion like $$\nabla \cdot (k(u) \nabla u) = 0$$

I have looked through #2791, #160, #2755, here, and the source code for DiffusionIntegrator and MassIntegrator but still have some confusions:

My main question is: How is, using the Gateaux derivative for determining the Jacobian, $\delta u$ actually represented in the code?

  • For Nonlinear Poisson/Laplace solve #2791, the nonlinearity considered is a $f(u) = e^{\alpha u}$ term in a $(f(u), v)$ inner product. When I take the Gateaux derivative of $f(u)$, I get $F'(u, \delta u) = \alpha e^{\alpha u} \delta u$. However, the code uses $F'(u, \delta u) = \alpha e^{\alpha u} u$; why is this OK to just use $\delta u = u$?
  • Similarly, for a diffusion operator $(\lambda \nabla u , \nabla v)$ represented by DiffusionIntegrator, my presumption is that the AssembleElementGrad function must implement $(F'(u, \delta u), \nabla v)$. Taking the Gateaux derivative of $f(u)=\lambda \nabla u$ gives me $F'(u, \delta u) = \lambda \nabla \delta u$. However, the code for DiffusionIntegrator::AssembleElementGrad simply just calls DiffusionIntegrator::AssembleElementMatrix, essentially assuming $\delta u = \phi_i$. Why is this acceptable?

Thank you for any assistance.

@vladotomov
Copy link
Member

vladotomov commented Nov 11, 2023

Hi @j-signorelli ,

We have $u = \sum_i u_i \phi_i$ for a FE function $u$. Then derivatives are taken w.r.t. the coefficients $u_i$:

$$\frac{\partial F(u)}{\partial u_i} = \frac{\partial F(u)}{\partial u} \frac{\partial u}{\partial u_i} = \frac{\partial F(u)}{\partial u} \phi_i$$

Does this help?

@vladotomov vladotomov self-assigned this Nov 11, 2023
@j-signorelli
Copy link
Contributor Author

j-signorelli commented Dec 5, 2023

Hi @vladotomov

Apologies for taking awhile to respond. Thank you - that is extremely helpful.

So if I understand correctly, for a nonlinear form $(e^{\alpha u}, v)$:
AssembleElementVector = $\int_\Omega e^{\alpha u} \phi_i d\vec{x}$
AssembleElementGrad = $\dfrac{\partial}{\partial u_j}\left(\int_\Omega e^{\alpha u} \phi_i d\vec{x}\right) = \int_\Omega \alpha e^{\alpha u}\phi_i \phi_j d\vec{x}$

Applying this for a DiffusionIntegrator, $(\lambda \nabla u, \nabla v)$, where $n$ sums over spatial dimensions:
AssembleElementVector = $\int_\Omega \lambda (\partial_n\phi_{i}) (\partial_n\phi_{j}) u_j d\vec{x}$
AssembleElementGrad = $\dfrac{\partial}{\partial u_k}\left(\int_\Omega \lambda (\partial_n\phi_i)(\partial_n\phi_j) u_j d\vec{x}\right) = \int_\Omega \lambda (\partial_n\phi_i)(\partial_n\phi_{j}) d\vec{x}$ = AssembleElementMatrix

Applying this for a nonlinear diffusion integrator, $(k(u) \nabla u, \nabla v)$:
AssembleElementVector = $\int_\Omega k(u) (\partial_n\phi_i) (\partial_n\phi_j) u_j d\vec{x}$
AssembleElementGrad = $\dfrac{\partial}{\partial u_k}\left(k(u) (\partial_n\phi_i) (\partial_n\phi_j) u_j d\vec{x}\right) = \int_\Omega k'(u) (\partial_n\phi_i)(\partial_n\phi_j) u_j \phi_k d\vec{x} + \int_\Omega k(u) (\partial_n\phi_i)(\partial_n\phi_k) d\vec{x}$

Is my understanding correct now for this?

Thanks again very much.

@vladotomov
Copy link
Member

vladotomov commented Dec 5, 2023

Is this in Einstein notation @j-signorelli?
If yes, then it looks correct.

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

No branches or pull requests

2 participants