Skip to content

Commit 5e645f5

Browse files
authored
REFAC: remove macro GRT_QWV_NUM, and some adjustments to the related date types. (#168)
1 parent 42d6370 commit 5e645f5

File tree

27 files changed

+118
-116
lines changed

27 files changed

+118
-116
lines changed

pygrt/C_extension/include/grt/common/const.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,8 @@ typedef double complex cplx_t;
106106
})
107107

108108
// -----------------------------------------------------------------------------
109-
#define GRT_CHANNEL_NUM 3 ///< 3, 代码中分量个数(ZRT,ZNE)
109+
#define GRT_CHANNEL_NUM 3 ///< 3, 代码中分量个数(ZRT,ZNE),也是核函数类型个数(q, w, v)
110110

111-
#define GRT_QWV_NUM 3 ///< 3, 代码中核函数类型个数(q, w, v)
112111
#define GRT_INTEG_NUM 4 ///< 4, 代码中积分类型个数
113112
#define GRT_MORDER_MAX 2 ///< 2, 代码中阶数m的最大值
114113
#define GRT_SRC_M_NUM 6 ///< 6, 代码中不同震源、不同阶数的个数
@@ -123,7 +122,11 @@ typedef double complex cplx_t;
123122

124123
#define GRT_GTYPES_MAX 2 ///< 2, 所有震源根据是否使用格林函数导数分为两类
125124

126-
typedef cplx_t cplxQWVGrid[GRT_SRC_M_NUM][GRT_QWV_NUM];
125+
typedef cplx_t cplxChnlGrid[GRT_SRC_M_NUM][GRT_CHANNEL_NUM];
126+
typedef cplx_t *pt_cplxChnlGrid[GRT_SRC_M_NUM][GRT_CHANNEL_NUM];
127+
typedef real_t realChnlGrid[GRT_SRC_M_NUM][GRT_CHANNEL_NUM];
128+
typedef real_t *pt_realChnlGrid[GRT_SRC_M_NUM][GRT_CHANNEL_NUM];
129+
typedef int intChnlGrid [GRT_SRC_M_NUM][GRT_CHANNEL_NUM];
127130

128131
typedef cplx_t cplxIntegGrid[GRT_SRC_M_NUM][GRT_INTEG_NUM];
129132
typedef real_t realIntegGrid[GRT_SRC_M_NUM][GRT_INTEG_NUM];

pygrt/C_extension/include/grt/common/integral.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
* @param[out] SUM 该dk区间内的积分值
2525
*
2626
*/
27-
void grt_int_Pk(real_t k, real_t r, const cplxQWVGrid QWV, bool calc_uir, cplxIntegGrid SUM);
27+
void grt_int_Pk(real_t k, real_t r, const cplxChnlGrid QWV, bool calc_uir, cplxIntegGrid SUM);
2828

2929

3030

@@ -35,7 +35,7 @@ void grt_int_Pk(real_t k, real_t r, const cplxQWVGrid QWV, bool calc_uir, cplxIn
3535
* @param[in] sum_J 积分结果
3636
* @param[out] tol Z、R、T分量结果
3737
*/
38-
void grt_merge_Pk(const cplxIntegGrid sum_J, cplx_t tol[GRT_SRC_M_NUM][GRT_CHANNEL_NUM]);
38+
void grt_merge_Pk(const cplxIntegGrid sum_J, cplxChnlGrid tol);
3939

4040

4141

@@ -53,7 +53,7 @@ void grt_merge_Pk(const cplxIntegGrid sum_J, cplx_t tol[GRT_SRC_M_NUM][GRT_CHANN
5353
* @param[out] SUM 该dk区间内的积分值
5454
*
5555
*/
56-
void grt_int_Pk_filon(real_t k, real_t r, bool iscos, const cplxQWVGrid QWV, bool calc_uir, cplxIntegGrid SUM);
56+
void grt_int_Pk_filon(real_t k, real_t r, bool iscos, const cplxChnlGrid QWV, bool calc_uir, cplxIntegGrid SUM);
5757

5858

5959
/**
@@ -68,4 +68,4 @@ void grt_int_Pk_filon(real_t k, real_t r, bool iscos, const cplxQWVGrid QWV, boo
6868
* @param[out] SUM 该三点区间内的积分值
6969
*
7070
*/
71-
void grt_int_Pk_sa_filon(const real_t k3[3], real_t r, const cplxQWVGrid QWV3[3], bool calc_uir, cplxIntegGrid SUM);
71+
void grt_int_Pk_sa_filon(const real_t k3[3], real_t r, const cplxChnlGrid QWV3[3], bool calc_uir, cplxIntegGrid SUM);

pygrt/C_extension/include/grt/common/iostats.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
* @note 文件记录的值均为波数积分的中间结果,与最终的结果还差一系列的系数,
2727
* 记录其值主要用于参考其变化趋势。
2828
*/
29-
void grt_write_stats(FILE *f0, real_t k, const cplxQWVGrid QWV);
29+
void grt_write_stats(FILE *f0, real_t k, const cplxChnlGrid QWV);
3030

3131

3232
/**

pygrt/C_extension/include/grt/common/kernel.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
* 计算核函数的函数指针,动态与静态的接口一致
1717
*/
1818
typedef void (*GRT_KernelFunc) (
19-
GRT_MODEL1D *mod1d, const real_t k, cplxQWVGrid QWV,
20-
bool calc_uiz, cplxQWVGrid QWV_uiz);
19+
GRT_MODEL1D *mod1d, const real_t k, cplxChnlGrid QWV,
20+
bool calc_uiz, cplxChnlGrid QWV_uiz);
2121

2222

2323
/**
@@ -89,26 +89,26 @@ typedef void (*GRT_KernelFunc) (
8989
*
9090
*/
9191
void grt_kernel(
92-
GRT_MODEL1D *mod1d, const real_t k, cplxQWVGrid QWV,
93-
bool calc_uiz, cplxQWVGrid QWV_uiz);
92+
GRT_MODEL1D *mod1d, const real_t k, cplxChnlGrid QWV,
93+
bool calc_uiz, cplxChnlGrid QWV_uiz);
9494

9595
/** 构建广义反射透射系数矩阵。作为 kernel 函数中的第一部分 */
9696
void grt_GRT_matrix(GRT_MODEL1D *mod1d, const real_t k);
9797

9898
/** 从广义 R/T 矩阵出发,计算每个震源对应的核函数 QWV。 作为 kernel 函数中的第二部分 */
9999
void grt_GRT_build_QWV(
100-
GRT_MODEL1D *mod1d, cplxQWVGrid QWV,
101-
bool calc_uiz, cplxQWVGrid QWV_uiz);
100+
GRT_MODEL1D *mod1d, cplxChnlGrid QWV,
101+
bool calc_uiz, cplxChnlGrid QWV_uiz);
102102

103103
/** 静态解的核函数 */
104104
void grt_static_kernel(
105-
GRT_MODEL1D *mod1d, const real_t k, cplxQWVGrid QWV,
106-
bool calc_uiz, cplxQWVGrid QWV_uiz);
105+
GRT_MODEL1D *mod1d, const real_t k, cplxChnlGrid QWV,
106+
bool calc_uiz, cplxChnlGrid QWV_uiz);
107107

108108
/** 静态广义反射透射系数矩阵 */
109109
void grt_static_GRT_matrix(GRT_MODEL1D *mod1d, const real_t k);
110110

111111
/** 静态 QWV */
112112
void grt_static_GRT_build_QWV(
113-
GRT_MODEL1D *mod1d, cplxQWVGrid QWV,
114-
bool calc_uiz, cplxQWVGrid QWV_uiz);
113+
GRT_MODEL1D *mod1d, cplxChnlGrid QWV,
114+
bool calc_uiz, cplxChnlGrid QWV_uiz);

pygrt/C_extension/include/grt/common/model.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ typedef struct {
6868
cplx_t uiz_R_EVL;
6969

7070
/* 震源处的震源系数 \f$ P_m, SV_m, SH_m */
71-
cplxQWVGrid src_coefD;
72-
cplxQWVGrid src_coefU;
71+
cplxChnlGrid src_coefD;
72+
cplxChnlGrid src_coefU;
7373

7474
} GRT_MODEL1D;
7575

pygrt/C_extension/include/grt/common/radiation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@
3434
* 对于张量源,mchn={Mxx, Mxy, Mxz, Myy, Myz, Mzz}
3535
*/
3636
void grt_set_source_radiation(
37-
real_t srcRadi[GRT_SRC_M_NUM][GRT_CHANNEL_NUM], const int computeType, const bool par_theta,
37+
realChnlGrid srcRadi, const int computeType, const bool par_theta,
3838
const real_t M0, const real_t coef, const real_t azrad, const real_t mchn[GRT_MECHANISM_NUM]
3939
);

pygrt/C_extension/include/grt/common/util.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,6 @@ void grt_GF_freq2time_write_to_file(
131131
const real_t delayT0, const real_t delayV0, const bool calc_upar,
132132
const bool doEX, const bool doVF, const bool doHF, const bool doDC,
133133
const char *chalst,
134-
cplx_t *grn[nr][GRT_SRC_M_NUM][GRT_CHANNEL_NUM],
135-
cplx_t *grn_uiz[nr][GRT_SRC_M_NUM][GRT_CHANNEL_NUM],
136-
cplx_t *grn_uir[nr][GRT_SRC_M_NUM][GRT_CHANNEL_NUM]);
134+
pt_cplxChnlGrid grn[nr],
135+
pt_cplxChnlGrid grn_uiz[nr],
136+
pt_cplxChnlGrid grn_uir[nr]);

pygrt/C_extension/include/grt/dynamic/grn.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ void grt_integ_grn_spec(
5656
bool print_progressbar,
5757

5858
// 返回值,代表Z、R、T分量
59-
cplx_t *grn[nr][GRT_SRC_M_NUM][GRT_CHANNEL_NUM],
59+
pt_cplxChnlGrid grn[nr],
6060

6161
bool calc_upar,
62-
cplx_t *grn_uiz[nr][GRT_SRC_M_NUM][GRT_CHANNEL_NUM],
63-
cplx_t *grn_uir[nr][GRT_SRC_M_NUM][GRT_CHANNEL_NUM],
62+
pt_cplxChnlGrid grn_uiz[nr],
63+
pt_cplxChnlGrid grn_uir[nr],
6464

6565
const char *statsstr, // 积分过程输出
6666
size_t nstatsidxs, // 仅输出特定频点

pygrt/C_extension/include/grt/static/static_grn.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ void grt_integ_static_grn(
4646
real_t filonLength, real_t safilonTol, real_t filonCut,
4747

4848
// 返回值,代表Z、R、T分量
49-
real_t grn[nr][GRT_SRC_M_NUM][GRT_CHANNEL_NUM],
49+
realChnlGrid grn[nr],
5050

5151
bool calc_upar,
52-
real_t grn_uiz[nr][GRT_SRC_M_NUM][GRT_CHANNEL_NUM],
53-
real_t grn_uir[nr][GRT_SRC_M_NUM][GRT_CHANNEL_NUM],
52+
realChnlGrid grn_uiz[nr],
53+
realChnlGrid grn_uir[nr],
5454

5555
const char *statsstr // 积分结果输出
5656
);

pygrt/C_extension/src/common/dwm.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ real_t grt_discrete_integ(
3636
cplxIntegGrid SUM = {0};
3737

3838
// 不同震源不同阶数的核函数 F(k, w)
39-
cplxQWVGrid QWV = {0};
40-
cplxQWVGrid QWV_uiz = {0};
39+
cplxChnlGrid QWV = {0};
40+
cplxChnlGrid QWV_uiz = {0};
4141

4242
real_t k = 0.0;
4343
size_t ik = 0;

0 commit comments

Comments
 (0)