[petsc-users] Implementing FEM with PLEX/DS/SNES

Ellen M. Price ellen.price at cfa.harvard.edu
Mon Oct 8 16:49:13 CDT 2018


Can anyone shed some light on SNES example 12?

https://www.mcs.anl.gov/petsc/petsc-current/src/snes/examples/tutorials/ex12.c.html

I am solving a Poisson problem, but with a source term defined on mesh
points, so I don't have an analytic form. The part I am confused about
is the role of the functions f0, f1, and g3 that go into the DS.

Suppose I have the Poisson problem nabla^2 u = f. Then the weak form is,
for test function phi,

\int_{\partial \Omega} \phi \nabla u - \int_\Omega \nabla u \cdot \nabla
\phi = \int_\Omega \phi f

Based on the documentation of PetscDSSetResidual(), I'm a little
confused about f0 and f1:

\int_\Omega \phi f_0(u, u_t, \nabla u, x, t) + \nabla\phi \cdot {\vec
f}_1(u, u_t, \nabla u, x, t)

So f0 is, for the Poisson problem, zero, and f1 is just -grad u? Do we
need to do anything with the surface term, or is that handled
internally? Because neither of these terms are a surface integral term,
both are volume integrals.

I can't figure out the purpose of g0, g1, g2, g3 in
PetscDSSetJacobian(), either. Is g supposed to be the source term? Is
psi a second basis function? What even *is* the Jacobian in a FEM
problem? I've only seen them formulated as linear problems in tutorials,
so I'm not even clear why we need a nonlinear solver or Jacobian...

Any help is appreciated. I like the idea of a general framework for FEM,
as I think it will reduce human error on my part, but I also want to
understand what I'm doing.

Ellen Price


More information about the petsc-users mailing list