xref: /libCEED/examples/ceed/index.md (revision 6d7116d72e016bae92b657063812cb029c7e7da4)
1bcb2dfaeSJed Brown# Standalone libCEED
2bcb2dfaeSJed Brown
32d3e8ae5SJeremy L ThompsonThe following three examples have no dependencies, and are designed to be self-contained.
42d3e8ae5SJeremy L ThompsonFor additional examples that use external discretization libraries (MFEM, PETSc, Nek5000 etc.) see the subdirectories in {file}`examples/`.
5bcb2dfaeSJed Brown
6bcb2dfaeSJed Brown(ex1-volume)=
7bcb2dfaeSJed Brown
8bcb2dfaeSJed Brown## Ex1-Volume
9bcb2dfaeSJed Brown
102d3e8ae5SJeremy L ThompsonThis example is located in the subdirectory {file}`examples/ceed`.
112d3e8ae5SJeremy L ThompsonIt illustrates a simple usage of libCEED to compute the volume of a given body using a matrix-free application of the mass operator.
122d3e8ae5SJeremy L ThompsonArbitrary mesh and solution orders in 1D, 2D, and 3D are supported from the same code.
13bcb2dfaeSJed Brown
142d3e8ae5SJeremy L ThompsonThis example shows how to compute line/surface/volume integrals of a 1D, 2D, or 3D domain $\Omega$ respectively, by applying the mass operator to a vector of $1$s.
152d3e8ae5SJeremy L ThompsonIt computes:
16bcb2dfaeSJed Brown
17bcb2dfaeSJed Brown$$
18bcb2dfaeSJed BrownI = \int_{\Omega} 1 \, dV .
19bcb2dfaeSJed Brown$$ (eq-ex1-volume)
20bcb2dfaeSJed Brown
212d3e8ae5SJeremy L ThompsonUsing the same notation as in {ref}`theoretical-framework`, we write here the vector $u(x)\equiv 1$ in the Galerkin approximation, and find the volume of $\Omega$ as
22bcb2dfaeSJed Brown
23bcb2dfaeSJed Brown$$
24bcb2dfaeSJed Brown\sum_e \int_{\Omega_e} v(x) 1 \, dV
25bcb2dfaeSJed Brown$$ (volume-sum)
26bcb2dfaeSJed Brown
272d3e8ae5SJeremy L Thompsonwith $v(x) \in \mathcal{V}_p = \{ v \in H^{1}(\Omega_e) \,|\, v \in P_p(\bm{I}), e=1,\ldots,N_e \}$, the test functions.
28bcb2dfaeSJed Brown
29bcb2dfaeSJed Brown(ex2-surface)=
30bcb2dfaeSJed Brown
31bcb2dfaeSJed Brown## Ex2-Surface
32bcb2dfaeSJed Brown
332d3e8ae5SJeremy L ThompsonThis example is located in the subdirectory {file}`examples/ceed`.
342d3e8ae5SJeremy L ThompsonIt computes the surface area of a given body using matrix-free application of a diffusion operator.
352d3e8ae5SJeremy L ThompsonSimilar to {ref}`Ex1-Volume`, arbitrary mesh and solution orders in 1D, 2D, and 3D are supported from the same code.
362d3e8ae5SJeremy L ThompsonIt computes:
37bcb2dfaeSJed Brown
38bcb2dfaeSJed Brown$$
39bcb2dfaeSJed BrownI = \int_{\partial \Omega} 1 \, dS ,
40bcb2dfaeSJed Brown$$ (eq-ex2-surface)
41bcb2dfaeSJed Brown
42bcb2dfaeSJed Brownby applying the divergence theorem.
43bcb2dfaeSJed BrownIn particular, we select $u(\bm x) = x_0 + x_1 + x_2$, for which $\nabla u = [1, 1, 1]^T$, and thus $\nabla u \cdot \hat{\bm n} = 1$.
44bcb2dfaeSJed Brown
45bcb2dfaeSJed BrownGiven Laplace's equation,
46bcb2dfaeSJed Brown
47bcb2dfaeSJed Brown$$
48bcb2dfaeSJed Brown\nabla \cdot \nabla u = 0, \textrm{ for  } \bm{x} \in \Omega ,
49bcb2dfaeSJed Brown$$
50bcb2dfaeSJed Brown
51bcb2dfaeSJed Brownlet us multiply by a test function $v$ and integrate by parts to obtain
52bcb2dfaeSJed Brown
53bcb2dfaeSJed Brown$$
54bcb2dfaeSJed Brown\int_\Omega \nabla v \cdot \nabla u \, dV - \int_{\partial \Omega} v \nabla u \cdot \hat{\bm n}\, dS = 0 .
55bcb2dfaeSJed Brown$$
56bcb2dfaeSJed Brown
578791656fSJed BrownSince we have chosen $u$ such that $\nabla u \cdot \hat{\bm n} = 1$, the boundary integrand is $v 1 \equiv v$. Hence, similar to {eq}`volume-sum`, we can evaluate the surface integral by applying the volumetric Laplacian as follows
58bcb2dfaeSJed Brown
59bcb2dfaeSJed Brown$$
60bcb2dfaeSJed Brown\int_\Omega \nabla v \cdot \nabla u \, dV \approx \sum_e \int_{\partial \Omega_e} v(x) 1 \, dS .
61bcb2dfaeSJed Brown$$
622d3e8ae5SJeremy L Thompson
632d3e8ae5SJeremy L Thompson(ex3-volume)=
642d3e8ae5SJeremy L Thompson
652d3e8ae5SJeremy L Thompson## Ex3-Volume
662d3e8ae5SJeremy L Thompson
672d3e8ae5SJeremy L ThompsonThis example is located in the subdirectory {file}`examples/ceed`.
682d3e8ae5SJeremy L ThompsonIt illustrates a more complex usage of libCEED to compute the volume of a given body using a matrix-free application of the screened Poisson operator.
692d3e8ae5SJeremy L ThompsonArbitrary mesh and solution orders in 1D, 2D, and 3D are supported from the same code.
702d3e8ae5SJeremy L Thompson
712d3e8ae5SJeremy L ThompsonThis example shows how to compute line/surface/volume integrals of a 1D, 2D, or 3D domain $\Omega$ respectively, by applying the screened Poisson operator to a vector of $1$s.
722d3e8ae5SJeremy L ThompsonIt computes:
732d3e8ae5SJeremy L Thompson
742d3e8ae5SJeremy L Thompson$$
752d3e8ae5SJeremy L ThompsonI = \int_{\Omega} \left( 1 + \nabla^2 1 \right) \, dV .
762d3e8ae5SJeremy L Thompson$$ (eq-ex3-volume)
772d3e8ae5SJeremy L Thompson
782d3e8ae5SJeremy L ThompsonUsing the same notation as in {ref}`theoretical-framework`, we write here the vector $u(x)\equiv 1$ in the Galerkin approximation, and find the volume of $\Omega$ as
792d3e8ae5SJeremy L Thompson
802d3e8ae5SJeremy L Thompson$$
812d3e8ae5SJeremy L Thompson\sum_e \int_{\Omega_e}\left( v(x) 1 + \nabla v(x) \cdot 0 \right) \, dV
82*6d7116d7SJeremy L Thompson$$ (volume-sum-mass-diff)
832d3e8ae5SJeremy L Thompson
842d3e8ae5SJeremy L Thompsonwith $v(x) \in \mathcal{V}_p = \{ v \in H^{1}(\Omega_e) \,|\, v \in P_p(\bm{I}), e=1,\ldots,N_e \}$, the test functions.
852d3e8ae5SJeremy L Thompson
862d3e8ae5SJeremy L ThompsonThe addition of the Poisson term is not needed to compute the volume of the region, as shown in example 1.
872d3e8ae5SJeremy L ThompsonRather, this example illustrates the ability to add multiple evaluation modes for the same input or output vector in a libCEED operator.
88