Skip to content

Commit 2ec6d25

Browse files
committed
FEAT: Allow solver_conduction to use sources w linear dependence on value
- especially useful for e- temp, where there are sources with & without dependence on temperature > This does not yet address the BC's. But that is doable now that we know how to use optional arguments w functions.
1 parent 1a20cd5 commit 2ec6d25

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

include/solvers.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ arma_vec solver_conduction(
4040
arma_vec dx,
4141
precision_t dt,
4242
int64_t nGCs,
43-
bool return_diff);
43+
bool return_diff = false,
44+
arma_vec source2 = arma_vec());
4445

4546
arma_cube solver_chemistry(arma_cube density,
4647
arma_cube source,

src/solver_conduction.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ arma_vec solver_conduction(arma_vec value,
2525
arma_vec dx,
2626
precision_t dt,
2727
int64_t nGCs,
28-
bool return_diff) {
28+
bool return_diff, // (optional) False by default (return new `value`)
29+
arma_vec source2 // (optional) Sources dependent on `value`
30+
) {
2931

3032
int64_t nPts = value.n_elem;
3133

@@ -47,14 +49,20 @@ arma_vec solver_conduction(arma_vec value,
4749
arma_vec conduction(nPts);
4850
conduction.zeros();
4951

52+
// If source2 is not given, set it to zero:
53+
if (source2.n_elem == 0){
54+
source2.set_size(source.n_elem);
55+
source2.zeros();
56+
}
57+
5058
int64_t i;
5159

5260
for (i = nGCs; i < nPts - nGCs; i++)
5361
dl(i) = di(i + 1) - di(i - 1) * r(i) * r(i) - di(i) * (1.0 - r(i) * r(i));
5462

5563
arma_vec a = di / du22 % r - dl / du12 % r % r;
5664
arma_vec c = di / du22 + dl / du12;
57-
arma_vec b = -1.0 / m - di / du22 % (1.0 + r) - dl / du12 % (1.0 - r % r);
65+
arma_vec b = -1.0 / m - di / du22 % (1.0 + r) - dl / du12 % (1.0 - r % r) + source2 % front * dt;
5866
arma_vec d = -1.0 * (value / m + source % front * dt);
5967

6068
// Lower BCs (fixed value):

0 commit comments

Comments
 (0)