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: 2 additions & 2 deletions pygrt/C_extension/src/dynamic/grt_stress.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ int main(int argc, char **argv){
float rho=hd.user3;
float Qainv=hd.user4;
float Qbinv=hd.user5;
if(va <= 0.0 || vb <= 0.0 || rho <= 0.0){
fprintf(stderr, "[%s] " BOLD_RED "Error! read necessary header value from \"%s\" error.\n" DEFAULT_RESTORE, command, s_filepath);
if(va <= 0.0 || vb < 0.0 || rho <= 0.0){
fprintf(stderr, "[%s] " BOLD_RED "Error! Bad rcv_va, rcv_vb or rcv_rho in \"%s\" header.\n" DEFAULT_RESTORE, command, s_filepath);
exit(EXIT_FAILURE);
}
// 申请内存
Expand Down
17 changes: 13 additions & 4 deletions pygrt/C_extension/src/dynamic/grt_syn.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,14 +239,23 @@ static void check_grn_exist(const char *name){
exit(EXIT_FAILURE);
}
// 检查文件的同时将src_mu计算出来
if(src_mu == 0.0){
if(src_mu == 0.0 && mult_src_mu){
SACHEAD hd;
read_SAC_HEAD(command, buffer, &hd);
double vb, rho;
double va, vb, rho;
va = hd.user6;
vb = hd.user7;
rho = hd.user8;
if(vb <= 0.0 || rho <= 0.0){
fprintf(stderr, "[%s] " BOLD_RED "Error! read necessary header value from \"%s\" error.\n" DEFAULT_RESTORE, command, buffer);
if(va <= 0.0 || vb < 0.0 || rho <= 0.0){
fprintf(stderr, "[%s] " BOLD_RED "Error! Bad src_va, src_vb or src_rho in \"%s\" header.\n" DEFAULT_RESTORE, command, buffer);
exit(EXIT_FAILURE);
}
if(vb == 0.0){
fprintf(stderr, "[%s] " BOLD_RED
"Error! Zero src_vb in \"%s\" header. "
"Maybe you try to use -Su<scale> but the source is in the liquid. "
"Use -S<scale> instead.\n"
DEFAULT_RESTORE, command, buffer);
exit(EXIT_FAILURE);
}
src_mu = vb*vb*rho*1e10;
Expand Down
9 changes: 8 additions & 1 deletion pygrt/C_extension/src/static/stgrt_stress.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,21 @@ int main(int argc, char **argv){
fprintf(stderr, "[%s] " BOLD_RED "Error! Unable to read src property from \"%s\". \n" DEFAULT_RESTORE, command, line);
exit(EXIT_FAILURE);
}
if(src_va <= 0.0 || src_vb < 0.0 || src_rho <= 0.0){
fprintf(stderr, "[%s] " BOLD_RED "Error! Bad src_va, src_vb or src_rho from \"%s\".\n" DEFAULT_RESTORE, command, line);
exit(EXIT_FAILURE);
}
}
else if(iline == 2){
// 读取场点物性参数
if(3 != sscanf(line, "# %lf %lf %lf", &rcv_va, &rcv_vb, &rcv_rho)){
fprintf(stderr, "[%s] " BOLD_RED "Error! Unable to read rcv property from \"%s\". \n" DEFAULT_RESTORE, command, line);
exit(EXIT_FAILURE);
}

if(rcv_va <= 0.0 || rcv_vb < 0.0 || rcv_rho <= 0.0){
fprintf(stderr, "[%s] " BOLD_RED "Error! Bad rcv_va, rcv_vb or rcv_rho in line %d from \"%s\".\n" DEFAULT_RESTORE, command, iline, line);
exit(EXIT_FAILURE);
}
rcv_mu = rcv_vb*rcv_vb*rcv_rho*1e10;
rcv_lam = rcv_va*rcv_va*rcv_rho*1e10 - 2.0*rcv_mu;
}
Expand Down
18 changes: 17 additions & 1 deletion pygrt/C_extension/src/static/stgrt_syn.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,19 @@ int main(int argc, char **argv){
fprintf(stderr, "[%s] " BOLD_RED "Error! Unable to read src property from \"%s\". \n" DEFAULT_RESTORE, command, line);
exit(EXIT_FAILURE);
}
src_mu = src_vb*src_vb*src_rho*1e10;
if(src_va <= 0.0 || src_vb < 0.0 || src_rho <= 0.0){
fprintf(stderr, "[%s] " BOLD_RED "Error! Bad src_va, src_vb or src_rho from \"%s\".\n" DEFAULT_RESTORE, command, line);
exit(EXIT_FAILURE);
}
if(src_vb == 0.0 && mult_src_mu){
fprintf(stderr, "[%s] " BOLD_RED
"Error! Zero src_vb from \"%s\". "
"Maybe you try to use -Su<scale> but the source is in the liquid. "
"Use -S<scale> instead.\n"
DEFAULT_RESTORE, command, line);
exit(EXIT_FAILURE);
src_mu = src_vb*src_vb*src_rho*1e10;
}

if(mult_src_mu) M0 *= src_mu;
}
Expand All @@ -360,6 +372,10 @@ int main(int argc, char **argv){
fprintf(stderr, "[%s] " BOLD_RED "Error! Unable to read rcv property from \"%s\". \n" DEFAULT_RESTORE, command, line);
exit(EXIT_FAILURE);
}
if(rcv_va <= 0.0 || rcv_vb < 0.0 || rcv_rho <= 0.0){
fprintf(stderr, "[%s] " BOLD_RED "Error! Bad rcv_va, rcv_vb or rcv_rho in line %d from \"%s\".\n" DEFAULT_RESTORE, command, iline, line);
exit(EXIT_FAILURE);
}
}
else if(iline == 3){
// 根据列长度判断是否有位移空间导数
Expand Down