Mimetic Operators Library Enhanced 4.0
Loading...
Searching...
No Matches
addscalarbc.h
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
24
25#ifndef ADDSCALARBC_H
26#define ADDSCALARBC_H
27
28#include "utils.h"
29#include "gradient.h"
30#include <vector>
31#include <cassert>
32
33using namespace arma;
34
35namespace AddScalarBC {
36
42struct BC1D {
43 vec dc; // Dirichlet coefficients a0 (2x1: left, right)
44 vec nc; // Neumann coefficients b0 (2x1: left, right)
45 vec v; // Boundary values g (2x1: left, right)
46
47 BC1D() : dc(2, fill::zeros), nc(2, fill::zeros), v(2, fill::zeros) {}
48};
49
55struct BC2D {
56 vec dc; // Dirichlet coefficients a0 (4x1: left, right, bottom, top)
57 vec nc; // Neumann coefficients b0 (4x1: left, right, bottom, top)
58 std::vector<vec> v; // Boundary values g (4 vectors: left, right, bottom, top)
59
60 BC2D() : dc(4, fill::zeros), nc(4, fill::zeros), v(4) {}
61};
62
68struct BC3D {
69 vec dc; // Dirichlet coefficients a0 (6x1: left, right, bottom, top, front, back)
70 vec nc; // Neumann coefficients b0 (6x1: left, right, bottom, top, front, back)
71 std::vector<vec> v; // Boundary values g (6 vectors: left, right, bottom, top, front, back)
72
73 BC3D() : dc(6, fill::zeros), nc(6, fill::zeros), v(6) {}
74};
75
76// ============================================================================
77// LHS: Boundary matrix construction (1D, 2D, 3D overloads)
78// ============================================================================
79
91void addScalarBClhs(u16 k, u32 m, Real dx,
92 const vec &dc, const vec &nc,
93 sp_mat &Al, sp_mat &Ar);
94
110void addScalarBClhs(u16 k, u32 m, Real dx, u32 n, Real dy,
111 const vec &dc, const vec &nc,
112 sp_mat &Al, sp_mat &Ar, sp_mat &Ab, sp_mat &At);
113
133void addScalarBClhs(u16 k, u32 m, Real dx, u32 n, Real dy, u32 o, Real dz,
134 const vec &dc, const vec &nc,
135 sp_mat &Al, sp_mat &Ar, sp_mat &Ab,
136 sp_mat &At, sp_mat &Af, sp_mat &Ak);
137
138// ============================================================================
139// RHS: Boundary value application (1D, 2D, 3D overloads)
140// ============================================================================
141
149void addScalarBCrhs(vec &b, const vec &v, const uvec &indices);
150
163void addScalarBCrhs(vec &b, const vec &dc, const vec &nc,
164 const std::vector<vec> &v,
165 const uvec &rl, const uvec &rr,
166 const uvec &rb, const uvec &rt);
167
182void addScalarBCrhs(vec &b, const vec &dc, const vec &nc,
183 const std::vector<vec> &v,
184 const uvec &rl, const uvec &rr, const uvec &rb,
185 const uvec &rt, const uvec &rf, const uvec &rk);
186
187// ============================================================================
188// Top-level BC application (1D, 2D, 3D overloads)
189// ============================================================================
190
203void addScalarBC(sp_mat &A, vec &b, u16 k, u32 m, Real dx, const BC1D &bc);
204
219void addScalarBC(sp_mat &A, vec &b, u16 k, u32 m, Real dx,
220 u32 n, Real dy, const BC2D &bc);
221
238void addScalarBC(sp_mat &A, vec &b, u16 k, u32 m, Real dx,
239 u32 n, Real dy, u32 o, Real dz, const BC3D &bc);
240
241
242
243} // namespace AddScalarBC
244
245#endif // ADDSCALARBC_H
void addScalarBC(sp_mat &A, vec &b, u16 k, u32 m, Real dx, const BC1D &bc)
Apply boundary conditions to a 1D discrete operator and RHS.
void addScalarBCrhs(vec &b, const vec &v, const uvec &indices)
Apply boundary values to the RHS vector for a 1D problem.
void addScalarBClhs(u16 k, u32 m, Real dx, const vec &dc, const vec &nc, sp_mat &Al, sp_mat &Ar)
Compute LHS boundary condition matrices for a 1D problem.
std::vector< vec > v
Definition addscalarbc.h:58
std::vector< vec > v
Definition addscalarbc.h:71
double Real
Definition utils.h:21