update_s_elastic_PML_4.c 8.42 KB
Newer Older
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
/*-----------------------------------------------------------------------------------------
 * 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 );
    }
}