Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions pygrt/C_extension/include/grt/common/model.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@ typedef struct {
cplx_t uiz_R_EV[2][2];
cplx_t uiz_R_EVL;

/* 震源处的震源系数 \f$ P_m, SV_m, SH_m */
cplxChnlGrid src_coefD;
cplxChnlGrid src_coefU;

} GRT_MODEL1D;


Expand Down
13 changes: 7 additions & 6 deletions pygrt/C_extension/include/grt/dynamic/source.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,17 @@

/**
* 根据公式(4.6.6),(4.6.15),(4.6.21,26),(4.8.34)计算不同震源不同阶数的震源系数,
* 数组形状代表在[i][j][p]时表示i类震源的
* P(j=0),SV(j=1)的震源系数(分别对应q,w),且分为下行波(p=0)和上行波(p=1).
* 数组形状代表在[i][j]时表示i类震源的P(j=0),SV(j=1),SH(j=2)的震源系数(分别对应q,w,v).
*
* @param[in,out] mod1d 模型结构体指针,结果保存在 src_coef
* @param[in] mod1d 模型结构体指针
* @param[out] src_coefD 下行震源系数
* @param[out] src_coefU 上行震源系数
*
*/
void grt_source_coef(GRT_MODEL1D *mod1d);
void grt_source_coef(const GRT_MODEL1D *mod1d, cplxChnlGrid src_coefD, cplxChnlGrid src_coefU);

/* P-SV 波的震源系数 */
void grt_source_coef_PSV(GRT_MODEL1D *mod1d);
void grt_source_coef_PSV(const GRT_MODEL1D *mod1d, cplxChnlGrid src_coefD, cplxChnlGrid src_coefU);

/* SH 波的震源系数 */
void grt_source_coef_SH(GRT_MODEL1D *mod1d);
void grt_source_coef_SH(const GRT_MODEL1D *mod1d, cplxChnlGrid src_coefD, cplxChnlGrid src_coefU);
19 changes: 10 additions & 9 deletions pygrt/C_extension/include/grt/static/static_source.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,17 @@
/**
* 计算不同震源的静态震源系数,文献/书中仅提供剪切源的震源系数,其它震源系数重新推导
*
* 数组形状代表在[i][j][p]时表示i类震源的
* P(j=0),SV(j=1)的震源系数(分别对应q,w),且分为下行波(p=0)和上行波(p=1).
* 数组形状代表在[i][j]时表示i类震源的P(j=0),SV(j=1),SH(j=2)的震源系数(分别对应q,w,v).
*
* @param[in] mod1d 模型结构体指针
* @param[out] src_coefD 下行震源系数
* @param[out] src_coefU 上行震源系数
*
* @param[in,out] mod1d 模型结构体指针,结果保存在 src_coef
*/
void grt_static_source_coef(GRT_MODEL1D *mod1d);

void grt_static_source_coef(const GRT_MODEL1D *mod1d, cplxChnlGrid src_coefD, cplxChnlGrid src_coefU);

/* P-SV 波的静态震源系数 */
void grt_static_source_coef_PSV(GRT_MODEL1D *mod1d);
/* P-SV 波的静态震源系数 */
void grt_static_source_coef_PSV(const GRT_MODEL1D *mod1d, cplxChnlGrid src_coefD, cplxChnlGrid src_coefU);

/* SH 波的静态震源系数 */
void grt_static_source_coef_SH(GRT_MODEL1D *mod1d);
/* SH 波的静态震源系数 */
void grt_static_source_coef_SH(const GRT_MODEL1D *mod1d, cplxChnlGrid src_coefD, cplxChnlGrid src_coefU);
18 changes: 9 additions & 9 deletions pygrt/C_extension/src/dynamic/source.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,18 @@ inline GCC_ALWAYS_INLINE void _source_SH(const cplx_t xb, const cplx_t cbcb, con
}


void grt_source_coef(GRT_MODEL1D *mod1d)
void grt_source_coef(const GRT_MODEL1D *mod1d, cplxChnlGrid src_coefD, cplxChnlGrid src_coefU)
{
// 先全部赋0
memset(mod1d->src_coefD, 0, sizeof(cplxChnlGrid));
memset(mod1d->src_coefU, 0, sizeof(cplxChnlGrid));
memset(src_coefD, 0, sizeof(cplxChnlGrid));
memset(src_coefU, 0, sizeof(cplxChnlGrid));

grt_source_coef_PSV(mod1d);
grt_source_coef_SH(mod1d);
grt_source_coef_PSV(mod1d, src_coefD, src_coefU);
grt_source_coef_SH(mod1d, src_coefD, src_coefU);
}


void grt_source_coef_PSV(GRT_MODEL1D *mod1d)
void grt_source_coef_PSV(const GRT_MODEL1D *mod1d, cplxChnlGrid src_coefD, cplxChnlGrid src_coefU)
{
size_t isrc = mod1d->isrc;
cplx_t xa = mod1d->xa[isrc];
Expand All @@ -83,18 +83,18 @@ void grt_source_coef_PSV(GRT_MODEL1D *mod1d)
cplx_t cbcb = mod1d->cbcb[isrc];
real_t k = mod1d->k;

_source_PSV(xa, caca, xb, cbcb, k, mod1d->src_coefD, mod1d->src_coefU);
_source_PSV(xa, caca, xb, cbcb, k, src_coefD, src_coefU);
}


void grt_source_coef_SH(GRT_MODEL1D *mod1d)
void grt_source_coef_SH(const GRT_MODEL1D *mod1d, cplxChnlGrid src_coefD, cplxChnlGrid src_coefU)
{
size_t isrc = mod1d->isrc;
cplx_t xb = mod1d->xb[isrc];
cplx_t cbcb = mod1d->cbcb[isrc];
real_t k = mod1d->k;

_source_SH(xb, cbcb, k, mod1d->src_coefD, mod1d->src_coefU);
_source_SH(xb, cbcb, k, src_coefD, src_coefU);
}


14 changes: 8 additions & 6 deletions pygrt/C_extension/src/integral/kernel_template.c_
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,10 @@ void __BUILD_QWV__(
RT_MATRIX *M_FA = &mod1d->M_FA;
RT_MATRIX *M_FB = &mod1d->M_FB;

// 计算震源系数
__grt_source_coef(mod1d);
// 计算震源系数 P_m, SV_m, SH_m
cplxChnlGrid src_coefD;
cplxChnlGrid src_coefU;
__grt_source_coef(mod1d, src_coefD, src_coefU);

// 临时中转矩阵 (temperary)
cplx_t tmpR2[2][2], tmp2x2[2][2], tmpRL, tmp2x2_uiz[2][2], tmpRL2;
Expand Down Expand Up @@ -221,7 +223,7 @@ void __BUILD_QWV__(
tmpRL = M_FB->invTL / (1.0 - M_BL->RDL * M_FB->RUL);
tmpRL2 = mod1d->R_EVL * tmpRL;

grt_construct_qwv(ircvup, tmp2x2, tmpRL2, M_BL->RD, M_BL->RDL, mod1d->src_coefD, mod1d->src_coefU, QWV);
grt_construct_qwv(ircvup, tmp2x2, tmpRL2, M_BL->RD, M_BL->RDL, src_coefD, src_coefU, QWV);


if(calc_uiz){
Expand All @@ -230,7 +232,7 @@ void __BUILD_QWV__(
grt_cmat2x2_mul(mod1d->uiz_R_EV, tmp2x2_uiz, tmp2x2_uiz);
tmpRL2 = mod1d->uiz_R_EVL * tmpRL;

grt_construct_qwv(ircvup, tmp2x2_uiz, tmpRL2, M_BL->RD, M_BL->RDL, mod1d->src_coefD, mod1d->src_coefU, QWV_uiz);
grt_construct_qwv(ircvup, tmp2x2_uiz, tmpRL2, M_BL->RD, M_BL->RDL, src_coefD, src_coefU, QWV_uiz);
}
}
else { // A震源 B接收
Expand All @@ -255,7 +257,7 @@ void __BUILD_QWV__(
tmpRL = M_AL->invTL / (1.0 - M_FA->RUL * M_AL->RDL);
tmpRL2 = mod1d->R_EVL * tmpRL;

grt_construct_qwv(ircvup, tmp2x2, tmpRL2, M_FA->RU, M_FA->RUL, mod1d->src_coefD, mod1d->src_coefU, QWV);
grt_construct_qwv(ircvup, tmp2x2, tmpRL2, M_FA->RU, M_FA->RUL, src_coefD, src_coefU, QWV);


if(calc_uiz){
Expand All @@ -264,7 +266,7 @@ void __BUILD_QWV__(
grt_cmat2x2_mul(mod1d->uiz_R_EV, tmp2x2_uiz, tmp2x2_uiz);
tmpRL2 = mod1d->uiz_R_EVL * tmpRL;

grt_construct_qwv(ircvup, tmp2x2_uiz, tmpRL2, M_FA->RU, M_FA->RUL, mod1d->src_coefD, mod1d->src_coefU, QWV_uiz);
grt_construct_qwv(ircvup, tmp2x2_uiz, tmpRL2, M_FA->RU, M_FA->RUL, src_coefD, src_coefU, QWV_uiz);
}

} // END if
Expand Down
18 changes: 9 additions & 9 deletions pygrt/C_extension/src/static/static_source.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,32 +61,32 @@ inline GCC_ALWAYS_INLINE void _source_SH(const real_t k, cplxChnlGrid coefD, cpl
}


void grt_static_source_coef(GRT_MODEL1D *mod1d)
void grt_static_source_coef(const GRT_MODEL1D *mod1d, cplxChnlGrid src_coefD, cplxChnlGrid src_coefU)
{
// 先全部赋0
memset(mod1d->src_coefD, 0, sizeof(cplxChnlGrid));
memset(mod1d->src_coefU, 0, sizeof(cplxChnlGrid));
memset(src_coefD, 0, sizeof(cplxChnlGrid));
memset(src_coefU, 0, sizeof(cplxChnlGrid));

grt_static_source_coef_PSV(mod1d);
grt_static_source_coef_SH(mod1d);
grt_static_source_coef_PSV(mod1d, src_coefD, src_coefU);
grt_static_source_coef_SH(mod1d, src_coefD, src_coefU);
}


void grt_static_source_coef_PSV(GRT_MODEL1D *mod1d)
void grt_static_source_coef_PSV(const GRT_MODEL1D *mod1d, cplxChnlGrid src_coefD, cplxChnlGrid src_coefU)
{
size_t isrc = mod1d->isrc;
cplx_t delta = mod1d->delta[isrc];
real_t k = mod1d->k;

_source_PSV(delta, k, mod1d->src_coefD, mod1d->src_coefU);
_source_PSV(delta, k, src_coefD, src_coefU);
}


void grt_static_source_coef_SH(GRT_MODEL1D *mod1d)
void grt_static_source_coef_SH(const GRT_MODEL1D *mod1d, cplxChnlGrid src_coefD, cplxChnlGrid src_coefU)
{
real_t k = mod1d->k;

_source_SH(k, mod1d->src_coefD, mod1d->src_coefU);
_source_SH(k, src_coefD, src_coefU);
}


2 changes: 0 additions & 2 deletions pygrt/c_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,6 @@ class c_GRT_MODEL1D(Structure):
('R_EVL', CPLX),
('uiz_R_EV', CPLX * 4),
('uiz_R_EVL', CPLX),

('src_coef', CPLX * SRC_M_NUM * QWV_NUM * 2)
]


Expand Down