Repository navigation
Expand file tree
/
Copy pathfcns.cpp
More file actions
67 lines (52 loc) · 1.95 KB
/
Copy pathfcns.cpp
File metadata and controls
67 lines (52 loc) · 1.95 KB
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
58
59
60
61
62
63
64
65
66
67
#include <cmath>
using namespace std;
#include "debug.h"
#include "fcns.h"
#include <assert.h>
////////////////////////////////////////////////////////////////////////////////
// SPATIALLY DEPENDENT PDE FUNCTIONS
// Coefficients
static const double PI = 3.141592653589793238462643383279502884197169399375105820974944;
double coefA(double x, double y, double z) {
return 0;
}
void coefB(double x, double y, double z, Tensor1& b) {
b.set(0,0,0);
}
void coefC(double x, double y, double z, Tensor1& c) {
c.set(0,0,0);
}
void coefD(double x, double y, double z, Tensor2& d) {
d.set(1,0,0,0,1,0,0,0,1);
}
void coefD_inv(double x, double y, double z, Tensor2& d) {
d.set(1,0,0,0,1,0,0,0,1);
}
Tensor2 trueHessianSoln(double x, double y, double z);
// Source f
double sourceVal(double x, double y, double z) {
//Id D=I, a=b=0
Tensor2 h = trueHessianSoln(x,y,z);
return - h(0,0) - h(1,1) - h(2,2);
}
// BC values g
double bcVal(double x, double y, double z) {
return trueSoln(x,y,z);
}
////////////////////////////////////////////////////////////////////////////////
// TRUE SOLUTION (IF KNOWN)
bool trueSolnKnown() { return true; }
// Real solution
double trueSoln(double x, double y, double z) {
return sin(PI*x)*sin(PI*y)*sin(PI*z);
}
Tensor1 trueGradSoln(double x, double y, double z) {
return Tensor1(PI*cos(PI*x)*sin(PI*y)*sin(PI*z),
PI*sin(PI*x)*cos(PI*y)*sin(PI*z),
PI*sin(PI*x)*sin(PI*y)*cos(PI*z));
}
Tensor2 trueHessianSoln(double x, double y, double z) {
return Tensor2(-PI*PI*sin(PI*x)*sin(PI*y)*sin(PI*z), PI*PI*cos(PI*x)*cos(PI*y)*sin(PI*z), PI*PI*cos(PI*x)*sin(PI*y)*cos(PI*z),
PI*PI*cos(PI*x)*cos(PI*y)*sin(PI*z), -PI*PI*sin(PI*x)*sin(PI*y)*sin(PI*z), PI*PI*sin(PI*x)*cos(PI*y)*cos(PI*z),
PI*PI*cos(PI*x)*sin(PI*y)*cos(PI*z), PI*PI*sin(PI*x)*cos(PI*y)*cos(PI*z), -PI*PI*sin(PI*x)*sin(PI*y)*sin(PI*z));
}