forked from llodds/ecsg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sim_utils.hpp
177 lines (152 loc) · 6.67 KB
/
sim_utils.hpp
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
#include <vector>
#include "field.hpp"
#include "array.hpp"
#ifndef SIM_UTILS
#define SIM_UTILS
//=====================================================
//functions to init and del parameter fields [init_del_par_field.hpp]
void InvertParameters(Field *density_ptr[3], Field density_obj[3],
Field *compliance_ptr[9], Field compliance_obj[9],
const Field &buoy, Field *stiffness_ptr[9], int aniso_mode);
void InitParField(//input
int num_grids,
bool check_energy,
//output
Grid *&grids,
Field *&buoys,
Field **&stiffs_obj,
Field ***&stiffs_ptr,
Field **&densities_obj,
Field ***&densities_ptr,
Field **&compliances_obj,
Field ***&compliances_ptr);
void DelParField(//input
int num_grids,
bool check_energy,
//output
Grid *&grids,
Field *&buoys,
Field **&stiffs_obj,
Field ***&stiffs_ptr,
Field **&densities_obj,
Field ***&densities_ptr,
Field **&compliances_obj,
Field ***&compliances_ptr);
//=====================================================
//functions to init and del simulation fields [init_del_sim.cpp]
void InitSim(int num_grids, int radius, bool check_energy, Grid grids[],
Field **&sim, Field **&vel_copy);
void DelSim(int num_grids, bool check_energy,
Field **&sim, Field **&vel_copy);
//=====================================================
//functions to init and del temporary containers used to compute the ghost data [init_del_ghost_container.cpp]
void InitGhostContainer(int num_grids,
Grid grids[],
int num_threads,
Array *& g_sxz,
Array *& g_tmp,
Array *& A_sxz,
Array *& B_sxz,
Array *& A_vz,
Array *& B_vz);
void DelGhostContainer(Array *& g_sxz,
Array *& g_tmp,
Array *& A_sxz,
Array *& B_sxz,
Array *& A_vz,
Array *& B_vz);
//=====================================================
//functions to init and del finite difference coefficients fields [init_del_fdcoeff.cpp]
std::vector<real> FDCoeff(int radius);
void InitFDcoeff(int num_grids, Grid grids[], int radius, real dt, real ***& coeff);
void DelFDCoeff(int num_grids, real ***& coeff);
//=====================================================
//function to init source [init_src.cpp]
void InitSrc(//output
int& src_grid,
int src_loc[],
std::valarray<float>& src_trace,
//input
Grid grids[],
int num_grids,
real dt);
//=====================================================
//function to init and del receiver traces [init_del_rec_trace.cpp]
void InitRecTrace(//input
int num_grids,
Grid grids[],
//output
int& n_rec,
int**& rec_loc,
std::vector<real>*& rec_data);
void DelRecTrace(int n_rec,
int** rec_loc,
std::vector<real>* rec_data);
//=====================================================
//function to init and del movies [init_del_movie.cpp]
void InitMovie(int num_grids,
bool movie_flags[3],
Field **sim,
Grid grids[],
int movie_nt,
real movie_dt,
oRSF*** &movie);
void InitRSFMovie(const Field &f, int nframe, Grid grid, real time_interval, oRSF *rsf_file);
void DelMovie(int num_grids,
bool movie_flags[3],
oRSF*** movie);
void PrintMovie(int num_grids,
bool movie_flags[3],
Field **sim,
oRSF ***movie);
//=====================================================
//function to init and del residue traces [init_del_res_trace.cpp]
void InitRes(int num_grids,
std::vector<float> **&res_vec);
void DelRes(int num_grids,
std::vector<float> **&res_vec);
//=====================================================
//functions to update vels/stresses/ghost data [update_*.cpp]
void UpdateVel(Field sim[9], const Field &buoy, real **coeff, int radius, int top ,int bottom, int top_bc);
void UpdateStress(Field sim[9], Field *stiffness_ptr[9], real **coeffs, int radius, int top, int bottom, int top_bc);
void Jacobi2D(Array &X, Array &A, Array &B, int n0, int n1, real tol, Array &X_tmp);
real Norm2D(Array &X1, Array &X2, int n0, int n1, int mode);
void UpdateGhostSXZ(Field sim1[9], Field sim2[9],
Field *buoy1, Field *buoy2,
real **coeff1, real **coeff2,
Array &g_sxz2, Array &A, Array &B,
Array &g_tmp, int mode);
void UpdateGhostSYZ(Field sim1[9], Field sim2[9],
Field *buoy1, Field *buoy2,
real **coeff1, real **coeff2, int mode);
void UpdateGhostVZ(Field sim1[9], Field sim2[9],
Field *stiff1[9], Field *stiff2[9],
real **coeff1, real **coeff2,
Array &A, Array &B, int mode);
//=====================================================
//functions to compute energy, residue traces [compute_*.cpp]
real ComputeEnergy(const Field sim[9], const Field vel_copy[3], Field *density_ptr[3], Field *compliance_ptr[9], const real grid_size[3]);
void compute_res_sxz_vx(int num_grids,
Grid grids[],
Field **sim,
std::vector<float> **res_vec);
void compute_res_syz_vy(int num_grids,
Grid grids[],
Field **sim,
std::vector<float> **res_vec);
void compute_res_szz_vz(int num_grids,
Grid grids[],
Field **sim,
std::vector<float> **res_vec);
//=====================================================
//functions to print fields to rsf files. [print.cpp]
void PrintToRSF(const std::vector<real> & val_array, std::string val_name, real dt);
void PrintToRSF(const Field *movie, int nframe,
Grid grid, real time_interval,
std::string movie_name);
void PrintFieldToRSF(const Field &f, oRSF *out);
void PrintRecData(int n_rec,
std::vector<real>* rec_data,
real dt,
oRSF &rec_out);
#endif