Skip to content

Commit 0a60e4e

Browse files
committed
Resolved the link issue
1 parent af523c1 commit 0a60e4e

20 files changed

Lines changed: 523 additions & 0 deletions
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
### Elliptic1D
2+
3+
Solves the 1D Poisson equation with Robin boundary conditions.
4+
5+
$$
6+
\nabla^2 u(x) = f(x)
7+
$$
8+
9+
with $x\in[0,1]$, and $f(x) =e^x$. The boundary conditions are given by
10+
11+
$$
12+
au + b\frac{du}{dx} = g
13+
$$
14+
15+
with $a=1$, $b=1$, and $g=0$, and
16+
17+
$$
18+
au(0) + b\frac{du(0)}{dx} = 0
19+
$$
20+
21+
$$
22+
au(1) + b\frac{du(1)}{dx} = 2e
23+
$$
24+
25+
This corresponds to the call to robinBC2D of `robinBC2D(k, m, dx, a, b)`.
26+
27+
---
28+
29+
This example is implemented in:
30+
- [MATLAB](https://github.com/csrc-sdsu/mole/blob/main/examples/matlab/Elliptic/1D/elliptic1D.m)
31+
- [C++](https://github.com/csrc-sdsu/mole/blob/main/examples/cpp/Elliptic/1D/elliptic1D.cpp)
32+
33+
Additional MATLAB variants of this example with different boundary conditions:
34+
- [Homogeneous Dirichlet](https://github.com/csrc-sdsu/mole/blob/main/examples/matlab/Elliptic/1D/elliptic1DHomogeneousDirichlet.m)
35+
- [Non-Homogeneous Dirichlet](https://github.com/csrc-sdsu/mole/blob/main/examples/matlab/Elliptic/1D/elliptic1DNonHomogeneousDirichlet.m)
36+
- [Left Dirichlet, Right Neumann](https://github.com/csrc-sdsu/mole/blob/main/examples/matlab/Elliptic/1D/elliptic1DLeftDirichletRightNeumann.m)
37+
- [Left Dirichlet, Right Robin](https://github.com/csrc-sdsu/mole/blob/main/examples/matlab/Elliptic/1D/elliptic1DLeftDirichletRightRobin.m)
38+
- [Left Neumann, Right Neumann](https://github.com/csrc-sdsu/mole/blob/main/examples/matlab/Elliptic/1D/elliptic1DLeftNeumannRightNeumann.m)
39+
- [Left Neumann, Right Robin](https://github.com/csrc-sdsu/mole/blob/main/examples/matlab/Elliptic/1D/elliptic1DLeftNeumannRightRobin.m)
40+
- [Left Robin, Right Robin](https://github.com/csrc-sdsu/mole/blob/main/examples/matlab/Elliptic/1D/elliptic1DLeftRobinRightRobin.m)
41+
- [Periodic Boundary Conditions](https://github.com/csrc-sdsu/mole/blob/main/examples/matlab/Elliptic/1D/elliptic1DPeriodicBC.m)
42+
- [Non-Periodic Boundary Conditions](https://github.com/csrc-sdsu/mole/blob/main/examples/matlab/Elliptic/1D/elliptic1DNonPeriodicBC.m)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
### Poisson1D
2+
3+
Solves the 1D Poisson equation with Robin boundary conditions.
4+
5+
$$
6+
-\frac{d^2 C}{d x^2} = f(x)
7+
$$
8+
9+
The boundary conditions are given by
10+
11+
$$
12+
au + b\frac{du}{dx} = g
13+
$$
14+
15+
The equation is discretized using mimetic operators.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
### Elliptic2D Case 2
2+
3+
Solves the 2D Poisson equation with Robin boundary conditions on a nonuniform sinusoidal grid.
4+
5+
$$
6+
\nabla^2 u(x,y) = f(x,y)
7+
$$
8+
9+
with $x\in[-\pi, 2\pi], y\in[-\pi, \pi]$, and
10+
11+
$$
12+
f(x,y) = \begin{cases}
13+
\sin(x)\sin(y) & \text{ along boundaries } \\
14+
-2\sin(x)\sin(y) & \text{ otherwise }
15+
\end{cases}
16+
$$
17+
18+
The boundary conditions are given by
19+
20+
$$
21+
au + b\nabla u = g
22+
$$
23+
24+
with $a=1$, $b=0$, and $g=0$, which is equivalent to Dirichlet conditions along each boundary.
25+
This corresponds to the call to robinBC2D of `robinBC2D(k, m, 1, n, 1, 1, 0)`.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
### Elliptic2D Nodal Curv Sinusoidal
2+
3+
Solves the 2D Poisson equation with Robin boundary conditions on a curvilinear sinusoidal grid using the nodal mimetic operator. This requires manually setting the boundary condition in the Laplacian, as there is no boundary condition operator for the nodal curvilinear operators.
4+
5+
$$
6+
\nabla^2 u(x,y) = f(x,y)
7+
$$
8+
9+
with $x\in[-\pi, 2\pi], y\in[-\pi, \pi]$, and
10+
11+
$$
12+
f(x,y) = \begin{cases}
13+
\sin(x)+\cos(y) & \text{ along boundaries } \\
14+
-\sin(x) - \cos(y) & \text{ otherwise }
15+
\end{cases}
16+
$$
17+
18+
The boundary conditions are given by
19+
20+
$$
21+
au + b\nabla u = g
22+
$$
23+
24+
with $a=1$, $b=0$, and $g=0$, which is equivalent to Dirichlet conditions along each boundary.
25+
The MATLAB code uses the function `boundaryIdx2D` to find the correct locations for the weights of the boundary condition in the Laplacian node. The code then sets the appropriate values to $0$ or $1$.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
### Elliptic2D Nodal Curv
2+
3+
Solves the 2D Poisson equation with Robin boundary conditions on a curvilinear grid using the nodal mimetic operator. This requires manually setting the boundary condition in the Laplacian, as there is no boundary condition operator for the nodal curvilinear operators.
4+
5+
$$
6+
\nabla^2 u(x,y) = f(x,y)
7+
$$
8+
9+
with $x\in[0,50], y\in[0,50]$, and
10+
11+
$$
12+
f(x,y) = \begin{cases}
13+
(x-0.5)^2+(y-0.5)^2 & \text{ along boundaries } \\
14+
4 & \text{ otherwise }
15+
\end{cases}
16+
$$
17+
18+
The boundary conditions are given by
19+
20+
$$
21+
au + b\nabla u = g
22+
$$
23+
24+
The MATLAB code uses the function `boundaryIdx2D` to find the correct locations for boundary condition weights in the nodal Laplacian. The code then sets the appropriate values to $0$ or $1$.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
### Elliptic2D
2+
3+
Solves the 2D Poisson equation with Robin boundary conditions on a nonuniform grid.
4+
5+
$$
6+
\nabla^2 u(x,y) = f(x,y)
7+
$$
8+
9+
with $x\in[0,10], y\in[0,10]$, and
10+
11+
$$
12+
f(x,y) = \begin{cases}
13+
(x-0.5)^2+(y-0.5)^2 & \text{ along boundaries } \\
14+
4 & \text{ otherwise }
15+
\end{cases}
16+
$$
17+
18+
The boundary conditions are given by
19+
20+
$$
21+
au + b\nabla u = g
22+
$$
23+
24+
with $a=1$, $b=0$, and $g=0$, which is equivalent to Dirichlet conditions along each boundary.
25+
This corresponds to the call to robinBC2D of `robinBC2D(k, m, 1, n, 1, 1, 0)`.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
### Minimal Poisson 2D
2+
3+
Solves the 2D Poisson equation with Robin boundary conditions on a uniform grid where $\Delta x=\Delta y = 1$.
4+
5+
$$
6+
\nabla^2 u(x,y) = f(x,y)
7+
$$
8+
9+
with $x\in[0,5], y\in[0,5]$, and
10+
11+
$$
12+
f(x,y) = \begin{cases}
13+
100 & \text{ if y = 0} \\
14+
0 & \text{ otherwise }
15+
\end{cases}
16+
$$
17+
18+
The boundary conditions are given by
19+
20+
$$
21+
au + b\nabla u = g
22+
$$
23+
24+
with $a=1$, $b=0$, and $g=0$.
25+
This corresponds to the call to robinBC2D of `robinBC2D(k, m, 1, n, 1, 1, 0)`.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
### Elliptic3D
2+
3+
Similar to `minimal_poisson2D`, this solves a 3D problem using mimetic Laplacian, where one side of the domain is set to 100, and allowed to diffuse.
4+
5+
$$
6+
\nabla^2 u(x,y,z) = f(x,y,z)
7+
$$
8+
9+
with $x\in[0,5], y\in[0,6], z\in[0,7]$, and
10+
11+
$$
12+
f(x,y) = \begin{cases}
13+
100 & \text{ if z = 0} \\
14+
0 & \text{ otherwise }
15+
\end{cases}
16+
$$
17+
18+
The boundary conditions are given by
19+
20+
$$
21+
au + b\nabla u = g
22+
$$
23+
24+
with $a=1$, $b=0$, and $g=0$.
25+
This corresponds to the call to robinBC3D of `robinBC2D(k, m, 1, n, 1, o, 1, 1, 0)`.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
### Burgers1D
2+
3+
This example deals with the conservative form of the inviscid Burgers equation in 1D.
4+
5+
$$
6+
\frac{\partial U}{\partial t} + \frac{\partial}{\partial x}\Big(\frac{U^2}{2}\Big) = 0
7+
$$
8+
9+
with $U = u(x,t)$ defined on the domain $x\in[-15,15]$, from time $t\in[0,10]$ and initial conditions
10+
11+
$$
12+
u(x,0) = e^{\frac{-x^2}{50}}
13+
$$
14+
15+
The wave is allowed to propagate across the domain while the area under the curve is calculated.
16+
17+
---
18+
19+
This example is implemented in:
20+
- [MATLAB](https://github.com/csrc-sdsu/mole/blob/main/examples/matlab/Hyperbolic/1D/burgers1D.m)
21+
- [C++](https://github.com/csrc-sdsu/mole/blob/main/examples/cpp/Hyperbolic/1D/Burgers1D.cpp)
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
### Hyperbolic1D Lax Friedrichs
2+
3+
Solves the 1D advection equation with periodic boundary conditions using a sided nodal mimetic operator and the Lax-Friedrichs scheme for time integration. The main feature of this code is the lack of an interpolator. This is first order in both time and space, even though a second order mimetic operator is used.
4+
5+
$$
6+
\frac{\partial U}{\partial t} + a\frac{\partial U}{\partial x} = 0
7+
$$
8+
9+
where $U=u(x,t)$ and $a=1$ is the advection velocity. The domain $x\in[0,1]$ and $t\in[0,1]$ with initial condition
10+
11+
$$
12+
u(x,0) = \sin(2\pi x)
13+
$$
14+
15+
Periodic boundary conditions are used
16+
17+
$$
18+
u(0,t) = u(1,t)
19+
$$
20+
21+
Using finite differences for the time derivative
22+
23+
$$
24+
\frac{\partial U}{\partial t} = \frac{U^{n+1}_i - U^{n}_i}{\Delta t}
25+
$$
26+
27+
where $U_i^n$ is $u(x_i, t_n)$, and the mimetic operator $\mathbf{D}$ for the space derivative.
28+
29+
$$
30+
\frac{U^{n+1}_i - U^{n}_i}{\Delta t} + a \mathbf{D} U^n_i = 0
31+
$$
32+
33+
$$
34+
\frac{U^{n+1}_i - U^{n}_i}{\Delta t} = -a \mathbf{D} U^n_i
35+
$$
36+
37+
$$
38+
U^{n+1}_i = \mathbf{U}^n_i - a \Delta t \mathbf{D} U^n_i
39+
$$
40+
41+
The last line $\mathbf{U}$ is the derived (average) value of the U from the $U^n$ timestep.

0 commit comments

Comments
 (0)