xref: /libCEED/examples/ceed/index.md (revision bcb2dfae4c301ddfdddf58806f08f6e7d17f4ea5)
1*bcb2dfaeSJed Brown# Standalone libCEED
2*bcb2dfaeSJed Brown
3*bcb2dfaeSJed BrownThe following two examples have no dependencies, and are designed to be self-contained.
4*bcb2dfaeSJed BrownFor additional examples that use external discretization libraries (MFEM, PETSc, Nek5000
5*bcb2dfaeSJed Brownetc.) see the subdirectories in {file}`examples/`.
6*bcb2dfaeSJed Brown
7*bcb2dfaeSJed Brown(ex1-volume)=
8*bcb2dfaeSJed Brown
9*bcb2dfaeSJed Brown## Ex1-Volume
10*bcb2dfaeSJed Brown
11*bcb2dfaeSJed BrownThis example is located in the subdirectory {file}`examples/ceed`. It illustrates a
12*bcb2dfaeSJed Brownsimple usage of libCEED to compute the volume of a given body using a matrix-free
13*bcb2dfaeSJed Brownapplication of the mass operator. Arbitrary mesh and solution orders in 1D, 2D, and 3D
14*bcb2dfaeSJed Brownare supported from the same code.
15*bcb2dfaeSJed Brown
16*bcb2dfaeSJed BrownThis example shows how to compute line/surface/volume integrals of a 1D, 2D, or 3D
17*bcb2dfaeSJed Browndomain $\Omega$ respectively, by applying the mass operator to a vector of
18*bcb2dfaeSJed Brown$1$s. It computes:
19*bcb2dfaeSJed Brown
20*bcb2dfaeSJed Brown$$
21*bcb2dfaeSJed BrownI = \int_{\Omega} 1 \, dV .
22*bcb2dfaeSJed Brown$$ (eq-ex1-volume)
23*bcb2dfaeSJed Brown
24*bcb2dfaeSJed BrownUsing the same notation as in {ref}`theoretical-framework`, we write here the vector
25*bcb2dfaeSJed Brown$u(x)\equiv 1$ in the Galerkin approximation,
26*bcb2dfaeSJed Brownand find the volume of $\Omega$ as
27*bcb2dfaeSJed Brown
28*bcb2dfaeSJed Brown$$
29*bcb2dfaeSJed Brown\sum_e \int_{\Omega_e} v(x) 1 \, dV
30*bcb2dfaeSJed Brown$$ (volume-sum)
31*bcb2dfaeSJed Brown
32*bcb2dfaeSJed Brownwith $v(x) \in \mathcal{V}_p = \{ v \in H^{1}(\Omega_e) \,|\, v \in P_p(\bm{I}), e=1,\ldots,N_e \}$,
33*bcb2dfaeSJed Brownthe test functions.
34*bcb2dfaeSJed Brown
35*bcb2dfaeSJed Brown(ex2-surface)=
36*bcb2dfaeSJed Brown
37*bcb2dfaeSJed Brown## Ex2-Surface
38*bcb2dfaeSJed Brown
39*bcb2dfaeSJed BrownThis example is located in the subdirectory {file}`examples/ceed`. It computes the
40*bcb2dfaeSJed Brownsurface area of a given body using matrix-free application of a diffusion operator.
41*bcb2dfaeSJed BrownSimilar to {ref}`Ex1-Volume`, arbitrary mesh and solution orders in 1D, 2D, and 3D
42*bcb2dfaeSJed Brownare supported from the same code. It computes:
43*bcb2dfaeSJed Brown
44*bcb2dfaeSJed Brown$$
45*bcb2dfaeSJed BrownI = \int_{\partial \Omega} 1 \, dS ,
46*bcb2dfaeSJed Brown$$ (eq-ex2-surface)
47*bcb2dfaeSJed Brown
48*bcb2dfaeSJed Brownby applying the divergence theorem.
49*bcb2dfaeSJed 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$.
50*bcb2dfaeSJed Brown
51*bcb2dfaeSJed BrownGiven Laplace's equation,
52*bcb2dfaeSJed Brown
53*bcb2dfaeSJed Brown$$
54*bcb2dfaeSJed Brown\nabla \cdot \nabla u = 0, \textrm{ for  } \bm{x} \in \Omega ,
55*bcb2dfaeSJed Brown$$
56*bcb2dfaeSJed Brown
57*bcb2dfaeSJed Brownlet us multiply by a test function $v$ and integrate by parts to obtain
58*bcb2dfaeSJed Brown
59*bcb2dfaeSJed Brown$$
60*bcb2dfaeSJed Brown\int_\Omega \nabla v \cdot \nabla u \, dV - \int_{\partial \Omega} v \nabla u \cdot \hat{\bm n}\, dS = 0 .
61*bcb2dfaeSJed Brown$$
62*bcb2dfaeSJed Brown
63*bcb2dfaeSJed 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 {math:numref}`volume-sum`, we can evaluate the surface integral by applying the volumetric Laplacian as follows
64*bcb2dfaeSJed Brown
65*bcb2dfaeSJed Brown$$
66*bcb2dfaeSJed Brown\int_\Omega \nabla v \cdot \nabla u \, dV \approx \sum_e \int_{\partial \Omega_e} v(x) 1 \, dS .
67*bcb2dfaeSJed Brown$$
68