19 const std::vector<Real> &coeffs_left,
const std::string &right,
20 const std::vector<Real> &coeffs_right) {
21 sp_mat A(m + 2, m + 2);
22 sp_mat BG(m + 2, m + 2);
27 if (left ==
"Dirichlet") {
28 A.at(0, 0) = coeffs_left[0];
29 }
else if (left ==
"Neumann") {
31 BG.row(0) = -coeffs_left[0] * grad->row(0);
32 }
else if (left ==
"Robin") {
33 A.at(0, 0) = coeffs_left[0];
35 BG.row(0) = -coeffs_left[1] * grad->row(0);
37 throw std::invalid_argument(
"Unknown boundary condition type");
41 if (right ==
"Dirichlet") {
42 A.at(m + 1, m + 1) = coeffs_right[0];
43 }
else if (right ==
"Neumann") {
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];
51 BG.row(m + 1) = coeffs_right[1] * grad->row(m);
53 throw std::invalid_argument(
"Unknown boundary condition type");
63 const std::vector<Real> &coeffs_left,
const std::string &right,
64 const std::vector<Real> &coeffs_right,
65 const std::string &bottom,
66 const std::vector<Real> &coeffs_bottom,
const std::string &top,
67 const std::vector<Real> &coeffs_top) {
68 MixedBC Bm(k, m, dx, left, coeffs_left, right, coeffs_right);
69 MixedBC Bn(k, n, dy, bottom, coeffs_bottom, top, coeffs_top);
71 sp_mat Im = speye(m + 2, m + 2);
72 sp_mat In = speye(n + 2, n + 2);
75 In.at(n + 1, n + 1) = 0;
85 const std::string &left,
const std::vector<Real> &coeffs_left,
86 const std::string &right,
87 const std::vector<Real> &coeffs_right,
88 const std::string &bottom,
89 const std::vector<Real> &coeffs_bottom,
const std::string &top,
90 const std::vector<Real> &coeffs_top,
const std::string &front,
91 const std::vector<Real> &coeffs_front,
const std::string &back,
92 const std::vector<Real> &coeffs_back) {
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);
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);
102 Io.at(o + 1, o + 1) = 0;
106 In2.at(n + 1, n + 1) = 0;
112 *
this = BC1 + BC2 + BC3;
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