-
Notifications
You must be signed in to change notification settings - Fork 3
/
linear_diff_operators.cpp
57 lines (36 loc) · 1.06 KB
/
linear_diff_operators.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include"linear.h"
#include"fields_enum.h"
// NOTE: these two are the divergence (but for a 1/V factor)
void linear::divergence(const vfield_list::take from , const sfield_list::take to )
{
VectorXd div = divergence( from );
vctr_to_field( div , to );
return;
}
VectorXd linear::divergence(const vfield_list::take from )
{
VectorXd vx, vy;
vfield_to_vctrs( from , vx, vy );
// cout << "vx cols " << vx.cols() << endl;
// cout << "vx rows " << vx.rows() << endl;
// cout << DDx << endl;
// cout << "vx " << endl;
// cout << vx << endl;
return DDx * vx + DDy * vy ;
}
// NOTE: this is the gradient (but for a 1/V factor)
// it features a minus sign, and transposition !!
void linear::gradient(const sfield_list::take from ,
VectorXd& Dx,VectorXd& Dy)
{
VectorXd p = field_to_vctr( from );
Dx = -DDx.transpose() * p;
Dy = -DDy.transpose() * p;
return;
}
// a FVM-like Laplacian (but for a 1/V factor)
VectorXd linear::Delta_laplacian(const sfield_list::take from )
{
VectorXd p = field_to_vctr( from );
return Delta * p;
}