Mimetic Operators Library Enhanced 4.0
Loading...
Searching...
No Matches
robinbc.cpp
Go to the documentation of this file.
1#include "robinbc.h"
2
3// 1-D Constructor
4RobinBC::RobinBC(u16 k, u32 m, Real dx, Real a, Real b)
5{
6 sp_mat A(m+2, m+2);
7 sp_mat BG(m+2, m+2);
8
9 A.at(0, 0) = a;
10 A.at(m+1, m+1) = a;
11
12 Gradient grad(k, m, dx);
13
14 BG.row(0) = -b*grad.row(0);
15 BG.row(m+1) = b*grad.row(m);
16
17 *this = A + BG;
18}
19
20// 2-D Constructor
21RobinBC::RobinBC(u16 k, u32 m, Real dx, u32 n, Real dy, Real a, Real b)
22{
23 RobinBC Bm(k, m, dx, a, b);
24 RobinBC Bn(k, n, dy, a, b);
25
26 sp_mat Im = speye(m+2, m+2);
27 sp_mat In = speye(n+2, n+2);
28
29 In.at(0, 0) = 0;
30 In.at(n+1, n+1) = 0;
31
32 sp_mat BC1 = Utils::spkron(In, Bm);
33 sp_mat BC2 = Utils::spkron(Bn, Im);
34
35 *this = BC1 + BC2;
36}
37
38// 3-D Constructor
39RobinBC::RobinBC(u16 k, u32 m, Real dx, u32 n, Real dy, u32 o, Real dz, Real a, Real b)
40{
41 RobinBC Bm(k, m, dx, a, b);
42 RobinBC Bn(k, n, dy, a, b);
43 RobinBC Bo(k, o, dz, a, b);
44
45 sp_mat Im = speye(m+2, m+2);
46 sp_mat In = speye(n+2, n+2);
47 sp_mat Io = speye(o+2, o+2);
48
49 Io.at(0, 0) = 0;
50 Io.at(o+1, o+1) = 0;
51
52 sp_mat In2 = In;
53 In2.at(0, 0) = 0;
54 In2.at(n+1, n+1) = 0;
55
56 sp_mat BC1 = Utils::spkron(Utils::spkron(Io, In2), Bm);
57 sp_mat BC2 = Utils::spkron(Utils::spkron(Io, Bn), Im);
58 sp_mat BC3 = Utils::spkron(Utils::spkron(Bo, In), Im);
59
60 *this = BC1 + BC2 + BC3;
61}
RobinBC(u16 k, u32 m, Real dx, Real a, Real b)
Definition robinbc.cpp:4
static sp_mat spkron(const sp_mat &A, const sp_mat &B)
Definition utils.cpp:53
double Real
Definition utils.h:8