xref: /libCEED/examples/ceed/index.md (revision 2d3e8ae507b7e626461a8a7f18bf4ea9099d676a)
1bcb2dfaeSJed Brown# Standalone libCEED
2bcb2dfaeSJed Brown
3*2d3e8ae5SJeremy L ThompsonThe following three examples have no dependencies, and are designed to be self-contained.
4*2d3e8ae5SJeremy 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
10*2d3e8ae5SJeremy L ThompsonThis example is located in the subdirectory {file}`examples/ceed`.
11*2d3e8ae5SJeremy 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.
12*2d3e8ae5SJeremy L ThompsonArbitrary mesh and solution orders in 1D, 2D, and 3D are supported from the same code.
13bcb2dfaeSJed Brown
14*2d3e8ae5SJeremy 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.
15*2d3e8ae5SJeremy L ThompsonIt computes:
16bcb2dfaeSJed Brown
17bcb2dfaeSJed Brown$$
18bcb2dfaeSJed BrownI = \int_{\Omega} 1 \, dV .
19bcb2dfaeSJed Brown$$ (eq-ex1-volume)
20bcb2dfaeSJed Brown
21*2d3e8ae5SJeremy 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
27*2d3e8ae5SJeremy 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
33*2d3e8ae5SJeremy L ThompsonThis example is located in the subdirectory {file}`examples/ceed`.
34*2d3e8ae5SJeremy L ThompsonIt computes the surface area of a given body using matrix-free application of a diffusion operator.
35*2d3e8ae5SJeremy L ThompsonSimilar to {ref}`Ex1-Volume`, arbitrary mesh and solution orders in 1D, 2D, and 3D are supported from the same code.
36*2d3e8ae5SJeremy 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$$
62*2d3e8ae5SJeremy L Thompson
63*2d3e8ae5SJeremy L Thompson(ex3-volume)=
64*2d3e8ae5SJeremy L Thompson
65*2d3e8ae5SJeremy L Thompson## Ex3-Volume
66*2d3e8ae5SJeremy L Thompson
67*2d3e8ae5SJeremy L ThompsonThis example is located in the subdirectory {file}`examples/ceed`.
68*2d3e8ae5SJeremy 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.
69*2d3e8ae5SJeremy L ThompsonArbitrary mesh and solution orders in 1D, 2D, and 3D are supported from the same code.
70*2d3e8ae5SJeremy L Thompson
71*2d3e8ae5SJeremy 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.
72*2d3e8ae5SJeremy L ThompsonIt computes:
73*2d3e8ae5SJeremy L Thompson
74*2d3e8ae5SJeremy L Thompson$$
75*2d3e8ae5SJeremy L ThompsonI = \int_{\Omega} \left( 1 + \nabla^2 1 \right) \, dV .
76*2d3e8ae5SJeremy L Thompson$$ (eq-ex3-volume)
77*2d3e8ae5SJeremy L Thompson
78*2d3e8ae5SJeremy 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
79*2d3e8ae5SJeremy L Thompson
80*2d3e8ae5SJeremy L Thompson$$
81*2d3e8ae5SJeremy L Thompson\sum_e \int_{\Omega_e}\left( v(x) 1 + \nabla v(x) \cdot 0 \right) \, dV
82*2d3e8ae5SJeremy L Thompson$$ (volume-sum)
83*2d3e8ae5SJeremy L Thompson
84*2d3e8ae5SJeremy 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.
85*2d3e8ae5SJeremy L Thompson
86*2d3e8ae5SJeremy L ThompsonThe addition of the Poisson term is not needed to compute the volume of the region, as shown in example 1.
87*2d3e8ae5SJeremy L ThompsonRather, this example illustrates the ability to add multiple evaluation modes for the same input or output vector in a libCEED operator.
88