-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsim_1d.cpp
More file actions
47 lines (36 loc) · 1.23 KB
/
Copy pathsim_1d.cpp
File metadata and controls
47 lines (36 loc) · 1.23 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
#include <iostream>
#include "./include/Wave1D.hpp"
int main(int argc, char const *argv[])
{
// Space discretization
float y_start = 0; float y_end = 20; unsigned int ny = 2001;
// Time discretization
float t_start = 0; float t_end = 10; unsigned int nt = 10001;
// Medium velocity
float c_air = 2.0f;
float c_ground = 5.0f;
int interface_loc = ny / 4;
float *c = new float[ny];
for (unsigned int i = 0; i < ny; i++)
{
if (i < interface_loc)
c[i] = c_air;
else
c[i] = c_ground;
}
// Required resources
double sizeof_float = sizeof(float);
std::cout << "Need atleast: " << (ny*nt*sizeof_float + ny*sizeof_float) / 1073741824.0 << " GB \n \n";
// Define 1D wave simulation settings
Wave1D simulation = Wave1D(y_start, y_end, ny, t_start, t_end, nt);
// Define source function
simulation.add_src_dGaussian(0.15f, 5.0f, (y_end-y_start)/2.0f);
// Solve using 3 point stencil with top:0 & bottom:0 boundary conditions
simulation.solve_3pt_00(c);
simulation.solve_3pt_da(c, 0.75);
simulation.solve_5pt_da(c, 0.75);
simulation.solve_7pt_da(c, 0.75);
// Free dynamic array
delete[] c;
return 0;
}