Mimetic Operators Library Enhanced 4.0
Loading...
Searching...
No Matches
robinbc.cpp
Go to the documentation of this file.
1/*
2* SPDX-License-Identifier: GPL-3.0-or-later
3* © 2008-2024 San Diego State University Research Foundation (SDSURF).
4* See LICENSE file or https://www.gnu.org/licenses/gpl-3.0.html for details.
5*/
6
7/*
8 * @file robinbc.cpp
9 * @date 2024/10/15
10 * @brief Robin Boundary Condition Class functions
11 *
12 */
13
14#include "robinbc.h"
15
16RobinBC::RobinBC(u16 k, u32 m, Real dx, Real a, Real b) {
17 sp_mat A(m + 2, m + 2);
18 sp_mat BG(m + 2, m + 2);
19
20 A.at(0, 0) = a;
21 A.at(m + 1, m + 1) = a;
22
23 Gradient grad(k, m, dx);
24
25 BG.row(0) = -b * grad.row(0);
26 BG.row(m + 1) = b * grad.row(m);
27
28 *this = A + BG;
29}
30
31
32RobinBC::RobinBC(u16 k, u32 m, Real dx, u32 n, Real dy, Real a, Real b) {
33 RobinBC Bm(k, m, dx, a, b);
34 RobinBC Bn(k, n, dy, a, b);
35
36 sp_mat Im = speye(m + 2, m + 2);
37 sp_mat In = speye(n + 2, n + 2);
38
39 In.at(0, 0) = 0;
40 In.at(n + 1, n + 1) = 0;
41
42 sp_mat BC1 = Utils::spkron(In, Bm);
43 sp_mat BC2 = Utils::spkron(Bn, Im);
44
45 *this = BC1 + BC2;
46}
47
48
49RobinBC::RobinBC(u16 k, u32 m, Real dx, u32 n, Real dy, u32 o, Real dz, Real a,
50 Real b) {
51 RobinBC Bm(k, m, dx, a, b);
52 RobinBC Bn(k, n, dy, a, b);
53 RobinBC Bo(k, o, dz, a, b);
54
55 sp_mat Im = speye(m + 2, m + 2);
56 sp_mat In = speye(n + 2, n + 2);
57 sp_mat Io = speye(o + 2, o + 2);
58
59 Io.at(0, 0) = 0;
60 Io.at(o + 1, o + 1) = 0;
61
62 sp_mat In2 = In;
63 In2.at(0, 0) = 0;
64 In2.at(n + 1, n + 1) = 0;
65
66 sp_mat BC1 = Utils::spkron(Utils::spkron(Io, In2), Bm);
67 sp_mat BC2 = Utils::spkron(Utils::spkron(Io, Bn), Im);
68 sp_mat BC3 = Utils::spkron(Utils::spkron(Bo, In), Im);
69
70 *this = BC1 + BC2 + BC3;
71}
Mimetic Gradient operator.
Definition gradient.h:27
RobinBC(u16 k, u32 m, Real dx, Real a, Real b)
1-D Robin boundary constructor
Definition robinbc.cpp:16
static sp_mat spkron(const sp_mat &A, const sp_mat &B)
A wrappper for implementing a sparse Kroenecker product.
Definition utils.cpp:70
double Real
Definition utils.h:21