Mimetic Operators Library Enhanced 4.0
Loading...
Searching...
No Matches
MixedBC Class Reference

Mimetic Mixed Boundary Condition operator. More...

#include <mixedbc.h>

Inheritance diagram for MixedBC:

Public Member Functions

 MixedBC (u16 k, u32 m, Real dx, const std::string &left, const std::vector< Real > &coeffs_left, const std::string &right, const std::vector< Real > &coeffs_right)
 1-D Constructor
 
 MixedBC (u16 k, u32 m, Real dx, u32 n, Real dy, const std::string &left, const std::vector< Real > &coeffs_left, const std::string &right, const std::vector< Real > &coeffs_right, const std::string &bottom, const std::vector< Real > &coeffs_bottom, const std::string &top, const std::vector< Real > &coeffs_top)
 2-D Constructor
 
 MixedBC (u16 k, u32 m, Real dx, u32 n, Real dy, u32 o, Real dz, const std::string &left, const std::vector< Real > &coeffs_left, const std::string &right, const std::vector< Real > &coeffs_right, const std::string &bottom, const std::vector< Real > &coeffs_bottom, const std::string &top, const std::vector< Real > &coeffs_top, const std::string &front, const std::vector< Real > &coeffs_front, const std::string &back, const std::vector< Real > &coeffs_back)
 3-D Constructor
 

Detailed Description

Mimetic Mixed Boundary Condition operator.

Definition at line 27 of file mixedbc.h.

Constructor & Destructor Documentation

◆ MixedBC() [1/3]

MixedBC::MixedBC ( u16 k,
u32 m,
Real dx,
const std::string & left,
const std::vector< Real > & coeffs_left,
const std::string & right,
const std::vector< Real > & coeffs_right )

1-D Constructor

Parameters
kOrder of accuracy
mNumber of cells
dxSpacing between cells
leftType of boundary condition at the left boundary ('Dirichlet', 'Neumann', 'Robin')
coeffs_leftCoefficients for the left boundary condition
rightType of boundary condition at the right boundary ('Dirichlet', 'Neumann', 'Robin')
coeffs_rightCoefficients for the right boundary condition

Definition at line 18 of file mixedbc.cpp.

20 {
21 sp_mat A(m + 2, m + 2);
22 sp_mat BG(m + 2, m + 2);
23
24 Gradient *grad = nullptr;
25
26 // Handle the left boundary condition
27 if (left == "Dirichlet") {
28 A.at(0, 0) = coeffs_left[0];
29 } else if (left == "Neumann") {
30 grad = new Gradient(k, m, dx);
31 BG.row(0) = -coeffs_left[0] * grad->row(0);
32 } else if (left == "Robin") {
33 A.at(0, 0) = coeffs_left[0];
34 grad = new Gradient(k, m, dx);
35 BG.row(0) = -coeffs_left[1] * grad->row(0);
36 } else {
37 throw std::invalid_argument("Unknown boundary condition type");
38 }
39
40 // Handle the right boundary condition
41 if (right == "Dirichlet") {
42 A.at(m + 1, m + 1) = coeffs_right[0];
43 } else if (right == "Neumann") {
44 if (!grad)
45 grad = new Gradient(k, m, dx);
46 BG.row(m + 1) = coeffs_right[0] * grad->row(m);
47 } else if (right == "Robin") {
48 A.at(m + 1, m + 1) = coeffs_right[0];
49 if (!grad)
50 grad = new Gradient(k, m, dx);
51 BG.row(m + 1) = coeffs_right[1] * grad->row(m);
52 } else {
53 throw std::invalid_argument("Unknown boundary condition type");
54 }
55
56 *this = A + BG;
57
58 delete grad;
59}

◆ MixedBC() [2/3]

MixedBC::MixedBC ( u16 k,
u32 m,
Real dx,
u32 n,
Real dy,
const std::string & left,
const std::vector< Real > & coeffs_left,
const std::string & right,
const std::vector< Real > & coeffs_right,
const std::string & bottom,
const std::vector< Real > & coeffs_bottom,
const std::string & top,
const std::vector< Real > & coeffs_top )

2-D Constructor

Parameters
kOrder of accuracy
mNumber of cells along x-axis
dxSpacing between cells along x-axis
nNumber of cells along y-axis
dySpacing between cells along y-axis
leftType of boundary condition at the left boundary ('Dirichlet', 'Neumann', 'Robin')
coeffs_leftCoefficients for the left boundary condition
rightType of boundary condition at the right boundary ('Dirichlet', 'Neumann', 'Robin')
coeffs_rightCoefficients for the right boundary condition
bottomType of boundary condition at the bottom boundary ('Dirichlet', 'Neumann', 'Robin')
coeffs_bottomCoefficients for the bottom boundary condition
topType of boundary condition at the top boundary ('Dirichlet', 'Neumann', 'Robin')
coeffs_topCoefficients for the top boundary condition

Definition at line 62 of file mixedbc.cpp.

67 {
68 MixedBC Bm(k, m, dx, left, coeffs_left, right, coeffs_right);
69 MixedBC Bn(k, n, dy, bottom, coeffs_bottom, top, coeffs_top);
70
71 sp_mat Im = speye(m + 2, m + 2);
72 sp_mat In = speye(n + 2, n + 2);
73
74 In.at(0, 0) = 0;
75 In.at(n + 1, n + 1) = 0;
76
77 sp_mat BC1 = Utils::spkron(In, Bm);
78 sp_mat BC2 = Utils::spkron(Bn, Im);
79
80 *this = BC1 + BC2;
81}
MixedBC(u16 k, u32 m, Real dx, const std::string &left, const std::vector< Real > &coeffs_left, const std::string &right, const std::vector< Real > &coeffs_right)
1-D Constructor
Definition mixedbc.cpp:18
static sp_mat spkron(const sp_mat &A, const sp_mat &B)
A wrappper for implementing a sparse Kroenecker product.
Definition utils.cpp:70

◆ MixedBC() [3/3]

MixedBC::MixedBC ( u16 k,
u32 m,
Real dx,
u32 n,
Real dy,
u32 o,
Real dz,
const std::string & left,
const std::vector< Real > & coeffs_left,
const std::string & right,
const std::vector< Real > & coeffs_right,
const std::string & bottom,
const std::vector< Real > & coeffs_bottom,
const std::string & top,
const std::vector< Real > & coeffs_top,
const std::string & front,
const std::vector< Real > & coeffs_front,
const std::string & back,
const std::vector< Real > & coeffs_back )

3-D Constructor

Parameters
kOrder of accuracy
mNumber of cells along x-axis
dxSpacing between cells along x-axis
nNumber of cells along y-axis
dySpacing between cells along y-axis
oNumber of cells along z-axis
dzSpacing between cells along z-axis
leftType of boundary condition at the left boundary ('Dirichlet', 'Neumann', 'Robin')
coeffs_leftCoefficients for the left boundary condition
rightType of boundary condition at the right boundary ('Dirichlet', 'Neumann', 'Robin')
coeffs_rightCoefficients for the right boundary condition
bottomType of boundary condition at the bottom boundary ('Dirichlet', 'Neumann', 'Robin')
coeffs_bottomCoefficients for the bottom boundary condition
topType of boundary condition at the top boundary ('Dirichlet', 'Neumann', 'Robin')
coeffs_topCoefficients for the top boundary condition
frontType of boundary condition at the front boundary ('Dirichlet', 'Neumann', 'Robin')
coeffs_frontCoefficients for the front boundary condition
backType of boundary condition at the back boundary ('Dirichlet', 'Neumann', 'Robin')
coeffs_backCoefficients for the back boundary condition

Definition at line 84 of file mixedbc.cpp.

92 {
93 MixedBC Bm(k, m, dx, left, coeffs_left, right, coeffs_right);
94 MixedBC Bn(k, n, dy, bottom, coeffs_bottom, top, coeffs_top);
95 MixedBC Bo(k, o, dz, front, coeffs_front, back, coeffs_back);
96
97 sp_mat Im = speye(m + 2, m + 2);
98 sp_mat In = speye(n + 2, n + 2);
99 sp_mat Io = speye(o + 2, o + 2);
100
101 Io.at(0, 0) = 0;
102 Io.at(o + 1, o + 1) = 0;
103
104 sp_mat In2 = In;
105 In2.at(0, 0) = 0;
106 In2.at(n + 1, n + 1) = 0;
107
108 sp_mat BC1 = Utils::spkron(Utils::spkron(Io, In2), Bm);
109 sp_mat BC2 = Utils::spkron(Utils::spkron(Io, Bn), Im);
110 sp_mat BC3 = Utils::spkron(Utils::spkron(Bo, In), Im);
111
112 *this = BC1 + BC2 + BC3;
113}

The documentation for this class was generated from the following files: