|
| 1 | +function BC = mixedBC3D(k, m, dx, n, dy, o, dz, left, coeffs_left, right, coeffs_right, bottom, coeffs_bottom, top, coeffs_top, front, coeffs_front, back, coeffs_back) |
| 2 | +% Constructs a 3D mimetic mixed boundary conditions operator |
| 3 | +% |
| 4 | +% Parameters: |
| 5 | +% k : Order of accuracy |
| 6 | +% m : Number of cells in x-direction |
| 7 | +% dx : Step size in x-direction |
| 8 | +% n : Number of cells in y-direction |
| 9 | +% dy : Step size in y-direction |
| 10 | +% o : Number of cells in z-direction |
| 11 | +% dz : Step size in z-direction |
| 12 | +% left : Type of boundary condition at the left boundary ('Dirichlet', 'Neumann', 'Robin') |
| 13 | +% coeffs_left : Coefficients for the left boundary condition (a, b for Robin, otherwise coeff. for Dirichlet or Neumann) |
| 14 | +% right : Type of boundary condition at the right boundary ('Dirichlet', 'Neumann', 'Robin') |
| 15 | +% coeffs_right : Coefficients for the right boundary condition (a, b for Robin, otherwise coeff. for Dirichlet or Neumann) |
| 16 | +% bottom : Type of boundary condition at the bottom boundary ('Dirichlet', 'Neumann', 'Robin') |
| 17 | +% coeffs_bottom : Coefficients for the bottom boundary condition (a, b for Robin, otherwise coeff. for Dirichlet or Neumann) |
| 18 | +% top : Type of boundary condition at the top boundary ('Dirichlet', 'Neumann', 'Robin') |
| 19 | +% coeffs_top : Coefficients for the top boundary condition (a, b for Robin, otherwise coeff. for Dirichlet or Neumann) |
| 20 | +% front : Type of boundary condition at the front boundary ('Dirichlet', 'Neumann', 'Robin') |
| 21 | +% coeffs_front : Coefficients for the front boundary condition (a, b for Robin, otherwise coeff. for Dirichlet or Neumann) |
| 22 | +% back : Type of boundary condition at the back boundary ('Dirichlet', 'Neumann', 'Robin') |
| 23 | +% coeffs_back : Coefficients for the back boundary condition (a, b for Robin, otherwise coeff. for Dirichlet or Neumann) |
| 24 | + |
| 25 | + % 1-D boundary operators |
| 26 | + Bx = mixedBC(k, m, dx, left, coeffs_left, right, coeffs_right); |
| 27 | + By = mixedBC(k, n, dy, bottom, coeffs_bottom, top, coeffs_top); |
| 28 | + Bz = mixedBC(k, o, dz, front, coeffs_front, back, coeffs_back); |
| 29 | + |
| 30 | + Im = speye(m+2); |
| 31 | + In = speye(n+2); |
| 32 | + Io = speye(o+2); |
| 33 | + |
| 34 | + In(1, 1) = 0; |
| 35 | + In(end, end) = 0; |
| 36 | + Io(1, 1) = 0; |
| 37 | + Io(end, end) = 0; |
| 38 | + |
| 39 | + BC1 = kron(kron(Io, In), Bx); |
| 40 | + BC2 = kron(kron(Io, By), Im); |
| 41 | + BC3 = kron(kron(Bz, In), Im); |
| 42 | + |
| 43 | + BC = BC1 + BC2 + BC3; |
| 44 | +end |
0 commit comments