Wave equation
2D wave equation with Dirichlet boundary conditions
Consider the time dependent solution to 2D wave equation on annulus shaped domain
\( \begin{align*} \frac{ \partial^2 u}{\partial t^2} &= c^2 \nabla^2 u &&\text{in } \Omega, \\ u &= 0 &&\text{on } \partial \Omega_O,\\ u &= f(t) &&\text{on } \partial \Omega_I, \end{align*} \)
where $\partial\Omega_I$ denotes the inner and $\partial\Omega_O$ the outer boundary of the domain. Through the boundary condition on the inner boundary the source is introduced to the problem as a function of time
\( \begin{align*} f(t)= u_o \sin \omega_o t. \end{align*} \)
First the domain is constructed by subtracting a smaller circle domain from a larger one. Boundaries of the domain are populated in the same step.
1 // // identifier to be added to nodes on the inner boundary
2 int CENTRE = -10;
3
4 // build circle domain
5 BallShape<Vec2d> domain({0, 0}, outer_radius);
6 auto discretization = domain.discretizeBoundaryWithStep(dx);
7
8 // build source domain
9 BallShape<Vec2d> empty({0, 0}, inner_radius);
10 auto discretization_empty = empty.discretizeBoundaryWithStep(dx, CENTRE);
11
12 // substract the source domain
13 discretization -= discretization_empty;
Next the domain is populated with nodes in acordance with the desired density function.
1 // Lambda function for setting the density of nodes
2 auto fill_density = [=](const Vec2d& p) {
3 double r = p.norm();
4 double default_value = dx;
5 double dens = default_value;
6 double r1 = 15*inner_radius;
7 double r2 = 0.8*outer_radius;
8 if (r < r1) dens = linear(inner_radius, 0.8*default_value, r1, default_value, r );
9 if (r > r2) dens = linear(r2, default_value, outer_radius, 0.8* default_value, r);
10 return dens;
11 };
12
13 GeneralFill<Vec2d> fill;
14 fill.seed(fill_seed);
15 discretization.fill(fill, fill_density);
16
17 // find support
18 FindClosest find_support(n);
19 discretization.findSupport(find_support);