7
$\begingroup$

Usually I write the weak form by hand for my FEM code, but it's a little annoying and mechanic sometimes.

So, I wonder, is there any way to generate the symbolic weak form in Mathematica? For instance, if I have this strong form:

$$\nabla\cdot(\nabla u) = f$$

I'd like to have an automation of multiplying by a shape function $\phi$, and integrating it obtaining

$$\nabla \phi \ \nabla u = \phi f$$

So the procedure is as follows.

  • take the left hand side and left-multiply with $\phi$: $\phi \; (\nabla\cdot(\nabla u))$
  • integrate by parts (usually): $\int \phi \; (\nabla\cdot(\nabla u)) = \int \nabla\phi \cdot \nabla u - \int_\partial \phi \cdot \nabla u$
  • by definition $\phi$ is zero on the boundary $\int_\partial \phi \cdot \nabla u = 0$
  • hence only the left hand side (integrated) remains $\int \nabla\phi \cdot \nabla u$

The very same procedure could be applied to the right hand side.

This would be great to achieve symbolically, as I am planning to implement a FEM software, not using NDSolve or other functions.

The top would be even generating the symbolic sum with Jacobians and Gauss integration points, but this is maybe asking too much! In a very classical FEM formulation, as for instance here in deal.II for a simple Laplace problem, $u$ and $\phi$ are just interpolated with a shape function, for instance $\phi$ itself, as $u(x) = \sum_j U_j \phi_j(x)$. The integral is then reduced to a sum of integrals over a triangulated domain, but as I said, I'd be glad to just extract the weak form in general (not just for linear problems, but also for instance for $\nabla \cdot ( A(x) \nabla u) = -f$ for a general $A(x)$.

Thanks!

$\endgroup$
  • 1
    $\begingroup$ I think you should add example(s) i.e. desired input, output, etc. for others to play with. Also, it's better to link materials explaining what's "weak form" in the question. $\endgroup$ – xzczd Dec 15 '16 at 11:46
  • $\begingroup$ I've tried to explain better @xzczd, but MathJax is not working apparently. $\endgroup$ – senseiwa Dec 15 '16 at 12:44
  • 1
    $\begingroup$ Yes, give us an example in which you did the transformation by hand and it will be much easier to figure out how to do the operation in Mathematica. $\endgroup$ – Musang Dec 15 '16 at 14:54
  • 2
    $\begingroup$ What type of application do you have in mind? Is this purely educational, do you hope to solve a problem that NDSolve can not solve? Or is there another reason altogether? $\endgroup$ – user21 Dec 15 '16 at 17:33
  • 1
    $\begingroup$ Do you want to use NDSolve / Mathematica as a pre-processor for deal.II ? $\endgroup$ – user21 Dec 15 '16 at 17:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.