Commit 8abb7c57 authored by Florian Wittkamp's avatar Florian Wittkamp

Higher temporal order with Adams-Basthforth method

Added a new switch FDORDER_TIME to use a fourth order accurate temporal FD-scheme. This is realized with the Adams-Bashforth method.
Possible values for FDORDER_TIME are 2 and 4, whereas 2 refers to the classical leapfrog scheme.
parent 158387de
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
# Sofi2D specific # Sofi2D specific
sofi2D sofi2D
sofi2D_bench
snapmerge snapmerge
guide_sofi2D.pdf guide_sofi2D.pdf
......
...@@ -12,7 +12,8 @@ ...@@ -12,7 +12,8 @@
"FD order" : "comment", "FD order" : "comment",
"FDORDER" : "4", "FDORDER" : "4",
"MAXRELERROR" : "1", "FDORDER_TIME" : "4",
"MAXRELERROR" : "0",
"2-D Grid" : "comment", "2-D Grid" : "comment",
"NX" : "300", "NX" : "300",
...@@ -48,7 +49,7 @@ ...@@ -48,7 +49,7 @@
"WRITE_MODELFILES" : "2", "WRITE_MODELFILES" : "2",
"Q-approximation" : "comment", "Q-approximation" : "comment",
"L" : "0", "L" : "1",
"FL1" : "5.0", "FL1" : "5.0",
"TAU" : "0.00001", "TAU" : "0.00001",
......
...@@ -95,6 +95,7 @@ SOFI2D_SRC= \ ...@@ -95,6 +95,7 @@ SOFI2D_SRC= \
operators_v.c \ operators_v.c \
PML_pro.c \ PML_pro.c \
prepare_update_s.c \ prepare_update_s.c \
prepare_update_s_4.c \
psource.c \ psource.c \
rd_sour.c \ rd_sour.c \
read_checkpoint.c\ read_checkpoint.c\
...@@ -115,23 +116,37 @@ SOFI2D_SRC= \ ...@@ -115,23 +116,37 @@ SOFI2D_SRC= \
surface.c \ surface.c \
surface_elastic.c \ surface_elastic.c \
update_s_elastic_abs.c \ update_s_elastic_abs.c \
update_s_elastic_abs_4.c \
update_s_elastic_interior.c \ update_s_elastic_interior.c \
update_s_elastic_interior_4.c \
update_s_elastic_PML.c \ update_s_elastic_PML.c \
update_s_elastic_PML_4.c \
update_s_visc_abs.c \ update_s_visc_abs.c \
update_s_visc_interior.c \ update_s_visc_interior.c \
update_s_visc_PML.c \ update_s_visc_PML.c \
update_s_visc_abs_4.c \
update_s_visc_interior_4.c \
update_s_visc_PML_4.c \
update_v_abs.c \ update_v_abs.c \
update_v_abs_4.c \
update_v_interior.c \ update_v_interior.c \
update_v_interior_4.c \
update_v_PML.c \ update_v_PML.c \
update_v_PML_4.c \
util.c \ util.c \
wavefield_update_s_el.c \ wavefield_update_s_el.c \
wavefield_update_s_el_4.c \
wavefield_update_s_visc.c \ wavefield_update_s_visc.c \
wavefield_update_s_visc_4.c \
wavefield_update_v.c \ wavefield_update_v.c \
wavefield_update_v_4.c \
wavelet.c \ wavelet.c \
write_par.c \ write_par.c \
writedsk.c \ writedsk.c \
writemod.c \ writemod.c \
zero_elastic.c \ zero_elastic.c \
zero_elastic_4.c \
zero_visco_4.c \
zero_visc.c \ zero_visc.c \
zero_PML_elastic.c \ zero_PML_elastic.c \
zero_PML_visc.c zero_PML_visc.c
...@@ -170,6 +185,7 @@ SOFI2D_BENCH_SRC= \ ...@@ -170,6 +185,7 @@ SOFI2D_BENCH_SRC= \
operators_v.c \ operators_v.c \
PML_pro.c \ PML_pro.c \
prepare_update_s.c \ prepare_update_s.c \
prepare_update_s_4.c \
psource.c \ psource.c \
rd_sour.c \ rd_sour.c \
read_checkpoint.c\ read_checkpoint.c\
...@@ -190,23 +206,37 @@ SOFI2D_BENCH_SRC= \ ...@@ -190,23 +206,37 @@ SOFI2D_BENCH_SRC= \
surface.c \ surface.c \
surface_elastic.c \ surface_elastic.c \
update_s_elastic_abs.c \ update_s_elastic_abs.c \
update_s_elastic_abs_4.c \
update_s_elastic_interior.c \ update_s_elastic_interior.c \
update_s_elastic_interior_4.c \
update_s_elastic_PML.c \ update_s_elastic_PML.c \
update_s_visc_abs.c \ update_s_visc_abs.c \
update_s_visc_interior.c \ update_s_visc_interior.c \
update_s_visc_PML.c \ update_s_visc_PML.c \
update_s_elastic_PML_4.c \
update_s_visc_abs_4.c \
update_s_visc_interior_4.c \
update_s_visc_PML_4.c \
update_v_abs.c \ update_v_abs.c \
update_v_abs_4.c \
update_v_interior.c \ update_v_interior.c \
update_v_interior_4.c \
update_v_PML.c \ update_v_PML.c \
update_v_PML_4.c \
util.c \ util.c \
wavefield_update_s_el.c \ wavefield_update_s_el.c \
wavefield_update_s_el_4.c \
wavefield_update_s_visc.c \ wavefield_update_s_visc.c \
wavefield_update_s_visc_4.c \
wavefield_update_v.c \ wavefield_update_v.c \
wavefield_update_v_4.c \
wavelet.c \ wavelet.c \
write_par.c \ write_par.c \
writedsk.c \ writedsk.c \
writemod.c \ writemod.c \
zero_elastic.c \ zero_elastic.c \
zero_elastic_4.c \
zero_visco_4.c \
zero_visc.c \ zero_visc.c \
zero_PML_elastic.c \ zero_PML_elastic.c \
zero_PML_visc.c \ zero_PML_visc.c \
......
...@@ -35,7 +35,7 @@ void checkfd ( FILE *fp, float ** prho, float ** ppi, float ** pu, ...@@ -35,7 +35,7 @@ void checkfd ( FILE *fp, float ** prho, float ** ppi, float ** pu,
extern float DH, DT, TS, TIME, TSNAP2; extern float DH, DT, TS, TIME, TSNAP2;
extern float XREC1, XREC2, YREC1, YREC2; extern float XREC1, XREC2, YREC1, YREC2;
extern int NX, NY, L, MYID, IDX, IDY, NT, NDT, RSG; extern int NX, NY, L, MYID, IDX, IDY, NT, NDT, RSG;
extern int READREC, NPROCX,NPROCY, SRCREC, FREE_SURF, ABS_TYPE, FW, BOUNDARY; extern int READREC, NPROCX,NPROCY, SRCREC, FREE_SURF, ABS_TYPE, FW, BOUNDARY,FDORDER_TIME;
extern int SNAP, SEISMO, CHECKPTREAD, CHECKPTWRITE, SEIS_FORMAT[6], SNAP_FORMAT, POS[4]; extern int SNAP, SEISMO, CHECKPTREAD, CHECKPTWRITE, SEIS_FORMAT[6], SNAP_FORMAT, POS[4];
extern char SEIS_FILE[STRING_SIZE], CHECKPTFILE[STRING_SIZE], SNAP_FILE[STRING_SIZE]; extern char SEIS_FILE[STRING_SIZE], CHECKPTFILE[STRING_SIZE], SNAP_FILE[STRING_SIZE];
extern char SOURCE_FILE[STRING_SIZE], REC_FILE[STRING_SIZE]; extern char SOURCE_FILE[STRING_SIZE], REC_FILE[STRING_SIZE];
...@@ -43,10 +43,11 @@ void checkfd ( FILE *fp, float ** prho, float ** ppi, float ** pu, ...@@ -43,10 +43,11 @@ void checkfd ( FILE *fp, float ** prho, float ** ppi, float ** pu,
/* local variables */ /* local variables */
float c, cmax_p=0.0, cmin_p=1e9, cmax_s=0.0, cmin_s=1e9, cwater=1.0, fmax, gamma; float c, cmax_p=0.0, cmin_p=1e9, cmax_s=0.0, cmin_s=1e9, cwater=1.0, fmax, gamma;
float cmax=0.0, cmin=1e9, sum, dtstab, dhstab, ts, cmax_r, cmin_r; float cmax=0.0, cmin=1e9, sum, dtstab, dhstab, ts, cmax_r, cmin_r, temporal;
float snapoutx=0.0, snapouty=0.0; float snapoutx=0.0, snapouty=0.0;
float srec_minx=DH*NX*NPROCX+1, srec_miny=DH*NY*NPROCY+1; float srec_minx=DH*NX*NPROCX+1, srec_miny=DH*NY*NPROCY+1;
float srec_maxx=-1.0, srec_maxy=-1.0; float srec_maxx=-1.0, srec_maxy=-1.0;
float CFL;
const float w=2.0*PI/TS; /*center frequency of source*/ const float w=2.0*PI/TS; /*center frequency of source*/
int i, j, k, l, ny1=1, nx, ny, myidcounter, nfw; int i, j, k, l, ny1=1, nx, ny, myidcounter, nfw;
...@@ -351,14 +352,14 @@ void checkfd ( FILE *fp, float ** prho, float ** ppi, float ** pu, ...@@ -351,14 +352,14 @@ void checkfd ( FILE *fp, float ** prho, float ** ppi, float ** pu,
MPI_Allreduce ( &cmin,&cmin_r,1,MPI_FLOAT,MPI_MIN,MPI_COMM_WORLD ); MPI_Allreduce ( &cmin,&cmin_r,1,MPI_FLOAT,MPI_MIN,MPI_COMM_WORLD );
cmax=cmax_r; cmax=cmax_r;
cmin=cmin_r; cmin=cmin_r;
if (FDORDER_TIME==4) {temporal=3.0/2.0;} else {temporal=1.0;}
fmax=2.0/TS; fmax=2.0/TS;
dhstab = ( cmin/ ( hc[0]*fmax ) ); dhstab = ( cmin/ ( hc[0]*fmax ) );
gamma = fabs ( hc[1] ) + fabs ( hc[2] ) + fabs ( hc[3] ) + fabs ( hc[4] ) + fabs ( hc[5] ) + fabs ( hc[6] ); gamma = fabs ( hc[1] ) + fabs ( hc[2] ) + fabs ( hc[3] ) + fabs ( hc[4] ) + fabs ( hc[5] ) + fabs ( hc[6] );
dtstab = DH/ ( sqrt ( 2 ) *gamma*cmax ); dtstab = DH/ ( sqrt ( 2 ) *gamma*cmax*temporal );
if ( RSG ) dtstab=DH/cmax; CFL=cmax*DT/DH;
if ( RSG ) dtstab=DH/cmax;
if ( MYID == 0 ) { if ( MYID == 0 ) {
fprintf ( fp," Global values for entire model: \n" ); fprintf ( fp," Global values for entire model: \n" );
...@@ -388,6 +389,7 @@ void checkfd ( FILE *fp, float ** prho, float ** ppi, float ** pu, ...@@ -388,6 +389,7 @@ void checkfd ( FILE *fp, float ** prho, float ** ppi, float ** pu,
fprintf ( fp," In the current simulation cmax is %8.2f m/s .\n\n",cmax ); fprintf ( fp," In the current simulation cmax is %8.2f m/s .\n\n",cmax );
fprintf ( fp," DT is the timestep and DH is the grid size.\n\n" ); fprintf ( fp," DT is the timestep and DH is the grid size.\n\n" );
fprintf ( fp," In this simulation the Courant-Friedrichs-Lewy number is %2.4f.\n",CFL );
fprintf ( fp," In this simulation the stability limit for timestep DT is %e seconds .\n",dtstab ); fprintf ( fp," In this simulation the stability limit for timestep DT is %e seconds .\n",dtstab );
fprintf ( fp," You have specified DT= %e s.\n", DT ); fprintf ( fp," You have specified DT= %e s.\n", DT );
if ( DT>dtstab ) if ( DT>dtstab )
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
void exchange_par(void){ void exchange_par(void){
/* declaration of extern variables */ /* declaration of extern variables */
extern int NX, NY, FDORDER, MAXRELERROR, SOURCE_TYPE, SOURCE_SHAPE, SNAP, SNAP_FORMAT, L; extern int NX, NY, FDORDER, MAXRELERROR, SOURCE_TYPE, SOURCE_SHAPE, SNAP, SNAP_FORMAT, L, FDORDER_TIME;
extern float DH, TIME, DT, TS, *FL, TAU, DAMPING, FPML, NPOWER, K_MAX_CPML, VPPML, PLANE_WAVE_DEPTH, PLANE_WAVE_ANGLE, SRCPOSXYZ[3]; extern float DH, TIME, DT, TS, *FL, TAU, DAMPING, FPML, NPOWER, K_MAX_CPML, VPPML, PLANE_WAVE_DEPTH, PLANE_WAVE_ANGLE, SRCPOSXYZ[3];
extern float XREC1, XREC2, YREC1, YREC2; extern float XREC1, XREC2, YREC1, YREC2;
extern float REC_ARRAY_DEPTH, REC_ARRAY_DIST; extern float REC_ARRAY_DEPTH, REC_ARRAY_DIST;
...@@ -126,6 +126,8 @@ void exchange_par(void){ ...@@ -126,6 +126,8 @@ void exchange_par(void){
idum[34] = WRITE_MODELFILES; idum[34] = WRITE_MODELFILES;
idum[35] = ABS_TYPE; idum[35] = ABS_TYPE;
idum[36] = FDORDER_TIME;
} /** if (MYID == 0) **/ } /** if (MYID == 0) **/
...@@ -219,7 +221,10 @@ void exchange_par(void){ ...@@ -219,7 +221,10 @@ void exchange_par(void){
RUN_MULTIPLE_SHOTS = idum[33]; RUN_MULTIPLE_SHOTS = idum[33];
WRITE_MODELFILES = idum[34]; WRITE_MODELFILES = idum[34];
ABS_TYPE = idum[35]; ABS_TYPE = idum[35];
FDORDER_TIME = idum[36];
MPI_Bcast(&FL[1],L,MPI_FLOAT,0,MPI_COMM_WORLD); MPI_Bcast(&FL[1],L,MPI_FLOAT,0,MPI_COMM_WORLD);
......
This diff is collapsed.
...@@ -33,7 +33,7 @@ int RUNMODE, WRITE_MODELFILES=0, ABS_TYPE; ...@@ -33,7 +33,7 @@ int RUNMODE, WRITE_MODELFILES=0, ABS_TYPE;
int OUTNTIMESTEPINFO=1; /*every OUTNTIMESTEPINFO th timestep, information on the time step will be given to screen/file */ int OUTNTIMESTEPINFO=1; /*every OUTNTIMESTEPINFO th timestep, information on the time step will be given to screen/file */
int SEISMO=0, NDT=1, NSRC=1, SEIS_FORMAT=0, FREE_SURF=0, READMOD=0, READREC=0, SRCREC=0, RSG=0, FW=0; int SEISMO=0, NDT=1, NSRC=1, SEIS_FORMAT=0, FREE_SURF=0, READMOD=0, READREC=0, SRCREC=0, RSG=0, FW=0;
int NX=1, NY=1, NT=0, SOURCE_TYPE=0, SOURCE_SHAPE=0, SNAP=0, SNAP_FORMAT=0, LOG=0, REC_ARRAY=0; int NX=1, NY=1, NT=0, SOURCE_TYPE=0, SOURCE_SHAPE=0, SNAP=0, SNAP_FORMAT=0, LOG=0, REC_ARRAY=0;
int L=0, BOUNDARY=0, DC=0, DRX=0, NXG=0, NYG=0, IDX=1, IDY=1, CHECKPTREAD=0, CHECKPTWRITE=0, FDORDER=0, MAXRELERROR=0; int L=0, BOUNDARY=0, DC=0, DRX=0, NXG=0, NYG=0, IDX=1, IDY=1, CHECKPTREAD=0, CHECKPTWRITE=0, FDORDER=0, FDORDER_TIME=0, MAXRELERROR=0;
int RUN_MULTIPLE_SHOTS=0; /* Added for multiple shots */ int RUN_MULTIPLE_SHOTS=0; /* Added for multiple shots */
char SNAP_FILE[STRING_SIZE]="", SOURCE_FILE[STRING_SIZE]="", SIGNAL_FILE[STRING_SIZE]=""; char SNAP_FILE[STRING_SIZE]="", SOURCE_FILE[STRING_SIZE]="", SIGNAL_FILE[STRING_SIZE]="";
char MFILE[STRING_SIZE]="", REC_FILE[STRING_SIZE]="", CHECKPTFILE[STRING_SIZE]=""; char MFILE[STRING_SIZE]="", REC_FILE[STRING_SIZE]="", CHECKPTFILE[STRING_SIZE]="";
......
/*------------------------------------------------------------------------
* Copyright (C) 2011 For the list of authors, see file AUTHORS.
*
* This file is part of SOFI2D.
*
* SOFI2D is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 2.0 of the License only.
*
* SOFI2D is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with SOFI2D. See file COPYING and/or
* <http://www.gnu.org/licenses/gpl-2.0.html>.
--------------------------------------------------------------------------*/
/* ------------------------------------------------------------------------
* prepare of update of the stress tensor
* ------------------------------------------------------------------------*/
/* ------------------------------------------------------------------------
* ATTENTION: The parameters below will be scaled by factor c* due to
* Adams-Bashforth method, so be aware and only call this function when
* FDORDER_TIME is set to 4
* ------------------------------------------------------------------------*/
#include "fd.h"
void prepare_update_s_4(float *etajm, float *etaip, float *peta, float **fipjp, float **pu,
float **puipjp, float **ppi, float **ptaus, float **ptaup,
float **ptausipjp, float **f, float **g, float *bip, float *bjm,
float *cip, float *cjm, float ***dip, float ***d, float ***e) {
extern int NX, NY, L;
extern float DT;
int i, j, l;
float c1; /* Coefficients for Adam Bashforth */
c1=13.0/12.0;
for (l=1;l<=L;l++){
etajm[l] = peta[l];
etaip[l] = peta[l];
}
for (j=1;j<=NY;j++){
for (i=1;i<=NX;i++){
fipjp[j][i] = puipjp[j][i]*DT*(1.0+L*ptausipjp[j][i]);
f[j][i] = pu[j][i]*DT*(1.0+L*ptaus[j][i]);
g[j][i] = ppi[j][i]*DT*(1.0+L*ptaup[j][i]);
for (l=1;l<=L;l++){
bip[l] = 1.0/(1.0+(c1*etaip[l]*0.5));
bjm[l] = 1.0/(1.0+(c1*etajm[l]*0.5));
cip[l] = 1.0-(c1*etaip[l]*0.5);
cjm[l] = 1.0-(c1*etajm[l]*0.5);
dip[j][i][l] = puipjp[j][i]*etaip[l]*ptausipjp[j][i];
d[j][i][l] = pu[j][i]*etajm[l]*ptaus[j][i];
e[j][i][l] = ppi[j][i]*etajm[l]*ptaup[j][i];
}
}
}
}
\ No newline at end of file
...@@ -30,7 +30,7 @@ char ** varname_list,** value_list; ...@@ -30,7 +30,7 @@ char ** varname_list,** value_list;
void read_par_json(FILE *fp, char *fileinp){ void read_par_json(FILE *fp, char *fileinp){
/* declaration of extern variables */ /* declaration of extern variables */
extern int NX, NY, FDORDER, MAXRELERROR, SOURCE_TYPE, SOURCE_SHAPE, SNAP, SNAP_FORMAT, L; extern int NX, NY, FDORDER, FDORDER_TIME, MAXRELERROR, SOURCE_TYPE, SOURCE_SHAPE, SNAP, SNAP_FORMAT, L;
extern int SEISMO, NDT, SEIS_FORMAT, FREE_SURF, READMOD, READREC, SRCREC; extern int SEISMO, NDT, SEIS_FORMAT, FREE_SURF, READMOD, READREC, SRCREC;
extern int BOUNDARY, REC_ARRAY, DRX, LOG, WRITE_MODELFILES; //RSG extern int BOUNDARY, REC_ARRAY, DRX, LOG, WRITE_MODELFILES; //RSG
extern int NPROCX, NPROCY, MYID, IDX, IDY, CHECKPTREAD, CHECKPTWRITE, RUN_MULTIPLE_SHOTS, ABS_TYPE, FW; extern int NPROCX, NPROCY, MYID, IDX, IDY, CHECKPTREAD, CHECKPTWRITE, RUN_MULTIPLE_SHOTS, ABS_TYPE, FW;
...@@ -81,6 +81,13 @@ void read_par_json(FILE *fp, char *fileinp){ ...@@ -81,6 +81,13 @@ void read_par_json(FILE *fp, char *fileinp){
err("Variable RSG could not be retrieved from the json input file!");*/ err("Variable RSG could not be retrieved from the json input file!");*/
if (get_int_from_objectlist("FDORDER",number_readobjects,&FDORDER,varname_list, value_list)) if (get_int_from_objectlist("FDORDER",number_readobjects,&FDORDER,varname_list, value_list))
err("Variable FDORDER could not be retrieved from the json input file!"); err("Variable FDORDER could not be retrieved from the json input file!");
if (get_int_from_objectlist("FDORDER_TIME",number_readobjects,&FDORDER_TIME,varname_list, value_list)) {
FDORDER_TIME=2;
} else {
if(FDORDER_TIME!=2 && FDORDER_TIME!=4) {
err("Only FDORDER_TIME 2 or 4 are supported!");
}
}
if (get_int_from_objectlist("MAXRELERROR",number_readobjects,&MAXRELERROR,varname_list, value_list)) if (get_int_from_objectlist("MAXRELERROR",number_readobjects,&MAXRELERROR,varname_list, value_list))
err("Variable MAXRELERROR could not be retrieved from the json input file!"); err("Variable MAXRELERROR could not be retrieved from the json input file!");
if (get_int_from_objectlist("NX",number_readobjects,&NX,varname_list, value_list)) if (get_int_from_objectlist("NX",number_readobjects,&NX,varname_list, value_list))
...@@ -261,9 +268,9 @@ void read_par_json(FILE *fp, char *fileinp){ ...@@ -261,9 +268,9 @@ void read_par_json(FILE *fp, char *fileinp){
err("Variable TAU could not be retrieved from the json input file!"); err("Variable TAU could not be retrieved from the json input file!");
if (get_int_from_objectlist("L",number_readobjects,&L,varname_list, value_list)) if (get_int_from_objectlist("L",number_readobjects,&L,varname_list, value_list))
err("Variable L could not be retrieved from the json input file!"); err("Variable L could not be retrieved from the json input file!");
else { else {
FL=vector(1,L); FL=vector(1,L);
switch(L) { switch(L) {
case 0: case 0:
break; break;
case 5: case 5:
......
This diff is collapsed.
/*-----------------------------------------------------------------------------------------
* Copyright (C) 2015 For the list of authors, see file AUTHORS.
*
* This file is part of SOFI2D.
*
* SOFI2D is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 2.0 of the License only.
*
* SOFI2D is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with SOFI2D See file COPYING and/or <http://www.gnu.org/licenses/gpl-2.0.html>.
-----------------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------
* updating stress components at gridpoints of the CPML-frame (ABS=1 in the json file)
* by a staggered grid finite difference scheme of arbitrary (FDORDER) order accuracy in space
* and second order accuracy in time
* T. Bohlen
*
* gx and gy are arrays with the locations of the boundary specified in subgrid_bounds.c
* for each subgrid
* ----------------------------------------------------------------------*/
#include "fd.h"
void update_s_elastic_PML_4 ( int nx1, int nx2, int ny1, int ny2, int * gx, int * gy, int nt,
float ** vx, float ** vy, float ** sxx, float ** syy,
float ** sxy, float ** pi, float ** u, float ** uipjp, float *hc,
float * K_x, float * a_x, float * b_x, float * K_x_half, float * a_x_half, float * b_x_half,
float * K_y, float * a_y, float * b_y, float * K_y_half, float * a_y_half, float * b_y_half,
float ** psi_vxx, float ** psi_vyy, float ** psi_vxy, float ** psi_vyx,float ** vxx_1,float ** vxx_2,float ** vxx_3,float ** vxx_4,float ** vyy_1,float ** vyy_2,float ** vyy_3,float ** vyy_4,float ** vxy_1,float ** vxy_2,float ** vxy_3,float ** vxy_4,float ** vyx_1,float ** vyx_2,float ** vyx_3,float ** vyx_4 )
{
int i,j, h1,fdoh;
float vxx, vyy, vxy, vyx;
extern int MYID, FDORDER, FW;
extern FILE *FP;
extern int OUTNTIMESTEPINFO;
double time1=0.0, time2=0.0;
fdoh=FDORDER/2;
/*Pointer array to the locations of the fd-operator functions*/
void ( *FD_op_s[7] ) ();
FD_op_s[1] = &operator_s_fd2;
FD_op_s[2] = &operator_s_fd4;
FD_op_s[3] = &operator_s_fd6;
FD_op_s[4] = &operator_s_fd8;
FD_op_s[5] = &operator_s_fd10;
FD_op_s[6] = &operator_s_fd12;
if ( ( MYID==0 ) && ( ( nt+ ( OUTNTIMESTEPINFO-1 ) ) %OUTNTIMESTEPINFO ) ==0 ) {
time1=MPI_Wtime();
fprintf ( FP,"\n **Message from update_s_PML_4 (printed by PE %d):\n",MYID );
fprintf ( FP," Updating stress components ..." );
}
/* interior */
/*for ( j=gy[2]+1; j<=gy[3]; j++ ) {
for ( i=gx[2]+1; i<=gx[3]; i++ ) {
FD_op_s[fdoh] ( i,j,&vxx,&vyx,&vxy,&vyy,vx,vy,hc );
wavefield_update_s_el ( i,j,vxx,vyx,vxy,vyy,sxy,sxx,syy,pi,u,uipjp );
}
}*/
/* left boundary */
for ( j=gy[2]+1; j<=gy[3]; j++ ) {
for ( i=gx[1]; i<=gx[2]; i++ ) {
FD_op_s[fdoh] ( i,j,&vxx,&vyx,&vxy,&vyy,vx,vy,hc );
cpml_update_s_x ( i,j,&vxx,&vyx,K_x,a_x,
b_x, K_x_half, a_x_half, b_x_half ,psi_vxx,psi_vyx );
wavefield_update_s_el_4 ( i,j,vxx,vyx,vxy,vyy,sxy,sxx,syy,pi,u,uipjp,vxx_1,vxx_2,vxx_3,vxx_4,vyy_1,vyy_2,vyy_3,vyy_4,vxy_1,vxy_2,vxy_3,vxy_4,vyx_1,vyx_2,vyx_3,vyx_4 );
}
}
/* right boundary */
for ( j=gy[2]+1; j<=gy[3]; j++ ) {
for ( i=gx[3]+1; i<=gx[4]; i++ ) {
FD_op_s[fdoh] ( i,j,&vxx,&vyx,&vxy,&vyy,vx,vy,hc );
h1 = ( i-nx2+2*FW );
cpml_update_s_x ( h1,j,&vxx,&vyx,K_x,a_x,
b_x, K_x_half, a_x_half, b_x_half ,psi_vxx,psi_vyx );
wavefield_update_s_el_4 ( i,j,vxx,vyx,vxy,vyy,sxy,sxx,syy,pi,u,uipjp,vxx_1,vxx_2,vxx_3,vxx_4,vyy_1,vyy_2,vyy_3,vyy_4,vxy_1,vxy_2,vxy_3,vxy_4,vyx_1,vyx_2,vyx_3,vyx_4 );
}
}
/* top boundary */
for ( j=gy[1]; j<=gy[2]; j++ ) {
for ( i=gx[2]+1; i<=gx[3]; i++ ) {
FD_op_s[fdoh] ( i,j,&vxx,&vyx,&vxy,&vyy,vx,vy,hc );
cpml_update_s_y ( i,j,&vxy,&vyy,K_y,a_y,
b_y, K_y_half, a_y_half, b_y_half ,psi_vyy,psi_vxy );
wavefield_update_s_el_4 ( i,j,vxx,vyx,vxy,vyy,sxy,sxx,syy,pi,u,uipjp,vxx_1,vxx_2,vxx_3,vxx_4,vyy_1,vyy_2,vyy_3,vyy_4,vxy_1,vxy_2,vxy_3,vxy_4,vyx_1,vyx_2,vyx_3,vyx_4 );
}
}
/* bottom boundary */
for ( j=gy[3]+1; j<=gy[4]; j++ ) {
for ( i=gx[2]+1; i<=gx[3]; i++ ) {
FD_op_s[fdoh] ( i,j,&vxx,&vyx,&vxy,&vyy,vx,vy,hc );
h1 = ( j-ny2+2*FW );
cpml_update_s_y ( i,h1,&vxy,&vyy,K_y,a_y,
b_y, K_y_half, a_y_half, b_y_half ,psi_vyy,psi_vxy );
wavefield_update_s_el_4 ( i,j,vxx,vyx,vxy,vyy,sxy,sxx,syy,pi,u,uipjp,vxx_1,vxx_2,vxx_3,vxx_4,vyy_1,vyy_2,vyy_3,vyy_4,vxy_1,vxy_2,vxy_3,vxy_4,vyx_1,vyx_2,vyx_3,vyx_4 );
}
}
/* corners */
/*left-top*/
for ( j=gy[1]; j<=gy[2]; j++ ) {
for ( i=gx[1]; i<=gx[2]; i++ ) {
FD_op_s[fdoh] ( i,j,&vxx,&vyx,&vxy,&vyy,vx,vy,hc );
cpml_update_s_x ( i,j,&vxx,&vyx,K_x,a_x,
b_x, K_x_half, a_x_half, b_x_half ,psi_vxx,psi_vyx );
cpml_update_s_y ( i,j,&vxy,&vyy,K_y,a_y,
b_y, K_y_half, a_y_half, b_y_half ,psi_vyy,psi_vxy );
wavefield_update_s_el_4 ( i,j,vxx,vyx,vxy,vyy,sxy,sxx,syy,pi,u,uipjp,vxx_1,vxx_2,vxx_3,vxx_4,vyy_1,vyy_2,vyy_3,vyy_4,vxy_1,vxy_2,vxy_3,vxy_4,vyx_1,vyx_2,vyx_3,vyx_4 );
}
}
/*left-bottom*/
for ( j=gy[3]+1; j<=gy[4]; j++ ) {
for ( i=gx[1]; i<=gx[2]; i++ ) {
FD_op_s[fdoh] ( i,j,&vxx,&vyx,&vxy,&vyy,vx,vy,hc );
cpml_update_s_x ( i,j,&vxx,&vyx,K_x,a_x,
b_x, K_x_half, a_x_half, b_x_half ,psi_vxx,psi_vyx );
h1 = ( j-ny2+2*FW );
cpml_update_s_y ( i,h1,&vxy,&vyy,K_y,a_y,
b_y, K_y_half, a_y_half, b_y_half ,psi_vyy,psi_vxy );
wavefield_update_s_el_4 ( i,j,vxx,vyx,vxy,vyy,sxy,sxx,syy,pi,u,uipjp,vxx_1,vxx_2,vxx_3,vxx_4,vyy_1,vyy_2,vyy_3,vyy_4,vxy_1,vxy_2,vxy_3,vxy_4,vyx_1,vyx_2,vyx_3,vyx_4 );
}
}
/* right-top */
for ( j=gy[1]; j<=gy[2]; j++ ) {
for ( i=gx[3]+1; i<=gx[4]; i++ ) {
FD_op_s[fdoh] ( i,j,&vxx,&vyx,&vxy,&vyy,vx,vy,hc );
h1 = ( i-nx2+2*FW );
cpml_update_s_x ( h1,j,&vxx,&vyx,K_x,a_x,
b_x, K_x_half, a_x_half, b_x_half ,psi_vxx,psi_vyx );
cpml_update_s_y ( i,j,&vxy,&vyy,K_y,a_y,
b_y, K_y_half, a_y_half, b_y_half ,psi_vyy,psi_vxy );
wavefield_update_s_el_4 ( i,j,vxx,vyx,vxy,vyy,sxy,sxx,syy,pi,u,uipjp,vxx_1,vxx_2,vxx_3,vxx_4,vyy_1,vyy_2,vyy_3,vyy_4,vxy_1,vxy_2,vxy_3,vxy_4,vyx_1,vyx_2,vyx_3,vyx_4 );
}
}
/* right-bottom */
for ( j=gy[3]+1; j<=gy[4]; j++ ) {
for ( i=gx[3]+1; i<=gx[4]; i++ ) {
FD_op_s[fdoh] ( i,j,&vxx,&vyx,&vxy,&vyy,vx,vy,hc );
h1 = ( i-nx2+2*FW );
cpml_update_s_x ( h1,j,&vxx,&vyx,K_x,a_x,
b_x, K_x_half, a_x_half, b_x_half ,psi_vxx,psi_vyx );
h1 = ( j-ny2+2*FW );
cpml_update_s_y ( i,h1,&vxy,&vyy,K_y,a_y,
b_y, K_y_half, a_y_half, b_y_half ,psi_vyy,psi_vxy );
wavefield_update_s_el_4 ( i,j,vxx,vyx,vxy,vyy,sxy,sxx,syy,pi,u,uipjp,vxx_1,vxx_2,vxx_3,vxx_4,vyy_1,vyy_2,vyy_3,vyy_4,vxy_1,vxy_2,vxy_3,vxy_4,vyx_1,vyx_2,vyx_3,vyx_4 );
}
}
if ( ( MYID==0 ) && ( ( nt+ ( OUTNTIMESTEPINFO-1 ) ) %OUTNTIMESTEPINFO ) ==0 ) {
time2=MPI_Wtime();
fprintf ( FP," finished (real time: %4.3f s).\n",time2-time1 );
}
}
/*-----------------------------------------------------------------------------------------
* Copyright (C) 2015 For the list of authors, see file AUTHORS.
*
* This file is part of SOFI2D.
*
* SOFI2D is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 2.0 of the License only.
*
* SOFI2D is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with SOFI2D See file COPYING and/or <http://www.gnu.org/licenses/gpl-2.0.html>.
-----------------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------
* updating stress components at gridpoints of the absorbing frame (ABS=2 in the json file)
* by a staggered grid finite difference scheme of arbitrary (FDORDER) order accuracy in space
* and second order accuracy in time
* T. Bohlen
*
* gx and gy are arrays with the locations of the boundary specified in subgrid_bounds.c
* for each subgrid
* ----------------------------------------------------------------------*/
#include "fd.h"
void update_s_elastic_abs_4 ( int nx1, int nx2, int ny1, int ny2, int * gx, int * gy, int nt,
float ** vx, float ** vy, float ** sxx, float ** syy,
float ** sxy, float ** pi, float ** u, float ** uipjp,
float ** absorb_coeff, float *hc ,float ** vxx_1,float ** vxx_2,float ** vxx_3,float ** vxx_4,float ** vyy_1,float ** vyy_2,float ** vyy_3,float ** vyy_4,float ** vxy_1,float ** vxy_2,float ** vxy_3,float ** vxy_4,float ** vyx_1,float ** vyx_2,float ** vyx_3,float ** vyx_4)
{
int i,j,fdoh;
float vxx, vyy, vxy, vyx;
extern int MYID, FDORDER;
extern FILE *FP;
extern int OUTNTIMESTEPINFO;
double time1=0.0, time2=0.0;
fdoh=FDORDER/2;
/*Pointer array to the locations of the fd-operator functions*/
void ( *FD_op_s[7] ) ();
FD_op_s[1] = &operator_s_fd2;
FD_op_s[2] = &operator_s_fd4;
FD_op_s[3] = &operator_s_fd6;
FD_op_s[4] = &operator_s_fd8;
FD_op_s[5] = &operator_s_fd10;
FD_op_s[6] = &operator_s_fd12;
if ( ( MYID==0 ) && ( ( nt+ ( OUTNTIMESTEPINFO-1 ) ) %OUTNTIMESTEPINFO ) ==0 ) {
time1=MPI_Wtime();
fprintf ( FP,"\n **Message from update_s_PML_4 (printed by PE %d):\n",MYID );
fprintf ( FP," Updating stress components ..." );
}
/* left boundary */
for ( j=gy[2]+1; j<=gy[3]; j++ ) {
for ( i=gx[1]; i<=gx[2]; i++ ) {
FD_op_s[fdoh] ( i,j,&vxx,&vyx,&vxy,&vyy,vx,vy,hc );
wavefield_update_s_el_4 ( i,j,vxx,vyx,vxy,vyy,sxy,sxx,syy,pi,u,uipjp,vxx_1,vxx_2,vxx_3,vxx_4,vyy_1,vyy_2,vyy_3,vyy_4,vxy_1,vxy_2,vxy_3,vxy_4,vyx_1,vyx_2,vyx_3,vyx_4 );
abs_update_s ( i,j,sxx,sxy,syy,absorb_coeff );
}
}
/* right boundary */
for ( j=gy[2]+1; j<=gy[3]; j++ ) {
for ( i=gx[3]+1; i<=gx[4]; i++ ) {