update_s_elastic_PML.c 17.4 KB
Newer Older
Tilman Steinweg's avatar
Tilman Steinweg committed
1
/*-----------------------------------------------------------------------------------------
2
 * Copyright (C) 2016  For the list of authors, see file AUTHORS.
Tilman Steinweg's avatar
Tilman Steinweg committed
3
 *
Florian Wittkamp's avatar
Florian Wittkamp committed
4
 * This file is part of IFOS.
Tilman Steinweg's avatar
Tilman Steinweg committed
5
 * 
Florian Wittkamp's avatar
Florian Wittkamp committed
6
 * IFOS is free software: you can redistribute it and/or modify
Tilman Steinweg's avatar
Tilman Steinweg committed
7 8 9
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, version 2.0 of the License only.
 * 
Florian Wittkamp's avatar
Florian Wittkamp committed
10
 * IFOS is distributed in the hope that it will be useful,
Tilman Steinweg's avatar
Tilman Steinweg committed
11 12 13 14 15
 * 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
Florian Wittkamp's avatar
Florian Wittkamp committed
16
 * along with IFOS. See file COPYING and/or <http://www.gnu.org/licenses/gpl-2.0.html>.
Tilman Steinweg's avatar
Tilman Steinweg committed
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
-----------------------------------------------------------------------------------------*/

/*------------------------------------------------------------------------
 *   updating stress components at gridpoints [nx1...nx2][ny1...ny2]
 *   by a staggered grid finite difference scheme of arbitrary (FDORDER) order accuracy in space
 *   and second order accuracy in time
 *
 *  ----------------------------------------------------------------------*/

#include "fd.h"

void update_s_elastic_PML(int nx1, int nx2, int ny1, int ny2,
	float **  vx, float **   vy, float **  ux, float **   uy, float **  uxy, float **   uyx, float **   sxx, float **   syy,
	float **   sxy, float ** pi, float ** u, float ** uipjp, float ** absorb_coeff, float **rho, float *hc, int infoout,
      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){


	int i,j, m, fdoh, h, h1;
	float fipjp, f, g;
	float  vxx, vyy, vxy, vyx;
	float  dhi;	
	extern float DT, DH;
41
	extern int MYID, FDORDER, PARAMETERIZATION, FW;
Tilman Steinweg's avatar
Tilman Steinweg committed
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
        extern int FREE_SURF, BOUNDARY;
	extern int NPROCX, NPROCY, POS[3];
	extern FILE *FP;
	double time1, time2;
	
	

	dhi = DT/DH;
	fdoh = FDORDER/2;

	
	if (infoout && (MYID==0)){
		time1=MPI_Wtime();
		fprintf(FP,"\n **Message from update_s (printed by PE %d):\n",MYID);
		fprintf(FP," Updating stress components ...");
	}
	


	switch (FDORDER){

	case 2:
		for (j=ny1;j<=ny2;j++){
65
		for (i=nx1;i<=nx2;i++){
Tilman Steinweg's avatar
Tilman Steinweg committed
66 67 68 69 70 71 72 73
			vxx = (  hc[1]*(vx[j][i]  -vx[j][i-1]))*dhi;
			
			vyx = (  hc[1]*(vy[j][i+1]-vy[j][i]))*dhi;

                        vxy = (  hc[1]*(vx[j+1][i]-vx[j][i]))*dhi;

                        vyy = (  hc[1]*(vy[j][i]  -vy[j-1][i]))*dhi; 

74 75 76 77 78
			/* left boundary */                                         
			if((!BOUNDARY) && (POS[1]==0) && (i<=FW)){
				
				psi_vxx[j][i] = b_x[i] * psi_vxx[j][i] + a_x[i] * vxx;
				vxx = vxx / K_x[i] + psi_vxx[j][i];
Tilman Steinweg's avatar
Tilman Steinweg committed
79

80 81 82
				psi_vyx[j][i] = b_x_half[i] * psi_vyx[j][i] + a_x_half[i] * vyx;
				vyx = vyx / K_x_half[i] + psi_vyx[j][i];                 
			}
Tilman Steinweg's avatar
Tilman Steinweg committed
83

84 85 86 87 88
			/* right boundary */                                         
			if((!BOUNDARY) && (POS[1]==NPROCX-1) && (i>=nx2-FW+1)){
			
				h1 = (i-nx2+2*FW);
				h = i;
Tilman Steinweg's avatar
Tilman Steinweg committed
89
				
90 91 92 93 94
				psi_vxx[j][h1] = b_x[h1] * psi_vxx[j][h1] + a_x[h1] * vxx;
				vxx = vxx / K_x[h1] + psi_vxx[j][h1]; 

				/*psi_vyx[j][h] = b_x_half[h] * psi_vyx[j][h] + a_x_half[h] * vyx;
				vyx = vyx / K_x_half[h] + psi_vyx[j][h];*/
Tilman Steinweg's avatar
Tilman Steinweg committed
95
				
96 97 98 99 100 101 102 103 104 105
				psi_vyx[j][h1] = b_x_half[h1] * psi_vyx[j][h1] + a_x_half[h1] * vyx;
				vyx = vyx / K_x_half[h1] + psi_vyx[j][h1];
							
			}

			/* top boundary */                                         
			if((POS[2]==0) && (!(FREE_SURF)) && (j<=FW)){
							
				psi_vyy[j][i] = b_y[j] * psi_vyy[j][i] + a_y[j] * vyy;                                            
				psi_vxy[j][i] = b_y_half[j] * psi_vxy[j][i] + a_y_half[j] * vxy;
Tilman Steinweg's avatar
Tilman Steinweg committed
106
				
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
				vyy = vyy / K_y[j] + psi_vyy[j][i];
				vxy = vxy / K_y_half[j] + psi_vxy[j][i];

			}

			/* bottom boundary */                                         
			if((POS[2]==NPROCY-1) && (j>=ny2-FW+1)){

				h1 = (j-ny2+2*FW);                                        
				h = j;
							
				psi_vyy[h1][i] = b_y[h1] * psi_vyy[h1][i] + a_y[h1] * vyy;                                            
				vyy = vyy / K_y[h1] + psi_vyy[h1][i];
				
				/*psi_vxy[j][i] = b_y_half[j] * psi_vxy[j][i] + a_y_half[j] * vxy;
				vxy = vxy / K_y_half[j] + psi_vxy[j][i];*/
Tilman Steinweg's avatar
Tilman Steinweg committed
123
				
124 125 126
				psi_vxy[h1][i] = b_y_half[h1] * psi_vxy[h1][i] + a_y_half[h1] * vxy;
				vxy = vxy / K_y_half[h1] + psi_vxy[h1][i];

Tilman Steinweg's avatar
Tilman Steinweg committed
127
			}
128 129 130 131

			fipjp=uipjp[j][i];
			
			/* lambda - mu relationship*/
132
			if (PARAMETERIZATION==3){
133 134 135
				f = u[j][i];
				g = pi[j][i];}  
			
136
			if (PARAMETERIZATION==1){
137 138 139 140 141 142 143 144 145 146 147
				f = rho[j][i] * u[j][i] * u[j][i];
				g = rho[j][i] * ((pi[j][i] * pi[j][i]) - 2 * u[j][i] * u[j][i]);}
			
			sxy[j][i] += fipjp*(vyx+vxy);
			sxx[j][i] += g*(vxx+vyy)+(2.0*f*vxx);
			syy[j][i] += g*(vxx+vyy)+(2.0*f*vyy);
			
			uxy[j][i] = (fipjp/DT)*(vyx+vxy);
			ux[j][i] = (g/DT)*(vxx+vyy)+((2.0*f/DT)*vxx);
			uy[j][i] = (g/DT)*(vxx+vyy)+((2.0*f/DT)*vyy);
		}
Tilman Steinweg's avatar
Tilman Steinweg committed
148
		}
149
	break;
Tilman Steinweg's avatar
Tilman Steinweg committed
150 151 152

	case 4:
		for (j=ny1;j<=ny2;j++){
153
		for (i=nx1;i<=nx2;i++){
Tilman Steinweg's avatar
Tilman Steinweg committed
154 155 156 157 158 159 160 161 162 163 164 165
			vxx = (  hc[1]*(vx[j][i]  -vx[j][i-1])
				       + hc[2]*(vx[j][i+1]-vx[j][i-2]))*dhi;
			
			vyx = (  hc[1]*(vy[j][i+1]-vy[j][i])
				       + hc[2]*(vy[j][i+2]-vy[j][i-1]))*dhi;

                        vxy = (  hc[1]*(vx[j+1][i]-vx[j][i])
				       + hc[2]*(vx[j+2][i]-vx[j-1][i]))*dhi;

                        vyy = (  hc[1]*(vy[j][i]  -vy[j-1][i])
				       + hc[2]*(vy[j+1][i]-vy[j-2][i]))*dhi; 

166 167 168 169 170
			/* left boundary */                                         
			if((!BOUNDARY) && (POS[1]==0) && (i<=FW)){
				
				psi_vxx[j][i] = b_x[i] * psi_vxx[j][i] + a_x[i] * vxx;
				vxx = vxx / K_x[i] + psi_vxx[j][i];
Tilman Steinweg's avatar
Tilman Steinweg committed
171

172 173 174
				psi_vyx[j][i] = b_x_half[i] * psi_vyx[j][i] + a_x_half[i] * vyx;
				vyx = vyx / K_x_half[i] + psi_vyx[j][i];                 
			}
Tilman Steinweg's avatar
Tilman Steinweg committed
175

176 177 178 179 180
			/* right boundary */                                         
			if((!BOUNDARY) && (POS[1]==NPROCX-1) && (i>=nx2-FW+1)){
			
				h1 = (i-nx2+2*FW);
				h = i;
Tilman Steinweg's avatar
Tilman Steinweg committed
181
				
182 183 184 185 186
				psi_vxx[j][h1] = b_x[h1] * psi_vxx[j][h1] + a_x[h1] * vxx;
				vxx = vxx / K_x[h1] + psi_vxx[j][h1]; 

				/*psi_vyx[j][h] = b_x_half[h] * psi_vyx[j][h] + a_x_half[h] * vyx;
				vyx = vyx / K_x_half[h] + psi_vyx[j][h];*/
Tilman Steinweg's avatar
Tilman Steinweg committed
187
				
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211
				psi_vyx[j][h1] = b_x_half[h1] * psi_vyx[j][h1] + a_x_half[h1] * vyx;
				vyx = vyx / K_x_half[h1] + psi_vyx[j][h1];
						
			}

			/* top boundary */                                         
			if((POS[2]==0) && (!(FREE_SURF)) && (j<=FW)){
							
				psi_vyy[j][i] = b_y[j] * psi_vyy[j][i] + a_y[j] * vyy;                                            
				psi_vxy[j][i] = b_y_half[j] * psi_vxy[j][i] + a_y_half[j] * vxy;
			
				vyy = vyy / K_y[j] + psi_vyy[j][i];
				vxy = vxy / K_y_half[j] + psi_vxy[j][i];

			}
		
			/* bottom boundary */                                         
			if((POS[2]==NPROCY-1) && (j>=ny2-FW+1)){

				h1 = (j-ny2+2*FW);                                        
				h = j;
							
				psi_vyy[h1][i] = b_y[h1] * psi_vyy[h1][i] + a_y[h1] * vyy;                                            
				vyy = vyy / K_y[h1] + psi_vyy[h1][i];
Tilman Steinweg's avatar
Tilman Steinweg committed
212
				
213 214
				/*psi_vxy[j][i] = b_y_half[j] * psi_vxy[j][i] + a_y_half[j] * vxy;
				vxy = vxy / K_y_half[j] + psi_vxy[j][i];*/
Tilman Steinweg's avatar
Tilman Steinweg committed
215
				
216 217 218
				psi_vxy[h1][i] = b_y_half[h1] * psi_vxy[h1][i] + a_y_half[h1] * vxy;
				vxy = vxy / K_y_half[h1] + psi_vxy[h1][i];
		
Tilman Steinweg's avatar
Tilman Steinweg committed
219
			}
220 221 222 223

			fipjp=uipjp[j][i];
			
			/* lambda - mu relationship*/
224
			if (PARAMETERIZATION==3){
225 226 227
				f = u[j][i];
				g = pi[j][i];}  
			
228
			if (PARAMETERIZATION==1){
229 230 231 232 233 234 235 236 237 238 239
				f = rho[j][i] * u[j][i] * u[j][i];
				g = rho[j][i] * ((pi[j][i] * pi[j][i]) - 2 * u[j][i] * u[j][i]);}
			
			sxy[j][i] += fipjp*(vyx+vxy);
			sxx[j][i] += g*(vxx+vyy)+(2.0*f*vxx);
			syy[j][i] += g*(vxx+vyy)+(2.0*f*vyy);
			
			uxy[j][i] = (fipjp/DT)*(vyx+vxy);
			ux[j][i] = (g/DT)*(vxx+vyy)+((2.0*f/DT)*vxx);
			uy[j][i] = (g/DT)*(vxx+vyy)+((2.0*f/DT)*vyy);
		}
Tilman Steinweg's avatar
Tilman Steinweg committed
240
		}
241
	break;
Tilman Steinweg's avatar
Tilman Steinweg committed
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261

	case 6:
		for (j=ny1;j<=ny2;j++){
			for (i=nx1;i<=nx2;i++){
			vxx = (  hc[1]*(vx[j][i]  -vx[j][i-1])
				       + hc[2]*(vx[j][i+1]-vx[j][i-2])
				       + hc[3]*(vx[j][i+2]-vx[j][i-3]))*dhi;
			
			vyx = (  hc[1]*(vy[j][i+1]-vy[j][i])
				       + hc[2]*(vy[j][i+2]-vy[j][i-1])
				       + hc[3]*(vy[j][i+3]-vy[j][i-2]))*dhi;

                        vxy = (  hc[1]*(vx[j+1][i]-vx[j][i])
				       + hc[2]*(vx[j+2][i]-vx[j-1][i])
				       + hc[3]*(vx[j+3][i]-vx[j-2][i]))*dhi;

                        vyy = (  hc[1]*(vy[j][i]  -vy[j-1][i])
				       + hc[2]*(vy[j+1][i]-vy[j-2][i])
				       + hc[3]*(vy[j+2][i]-vy[j-3][i]))*dhi; 

262 263 264 265 266
			/* left boundary */                                         
			if((!BOUNDARY) && (POS[1]==0) && (i<=FW)){
				
				psi_vxx[j][i] = b_x[i] * psi_vxx[j][i] + a_x[i] * vxx;
				vxx = vxx / K_x[i] + psi_vxx[j][i];
Tilman Steinweg's avatar
Tilman Steinweg committed
267

268 269 270
				psi_vyx[j][i] = b_x_half[i] * psi_vyx[j][i] + a_x_half[i] * vyx;
				vyx = vyx / K_x_half[i] + psi_vyx[j][i];                 
			}
Tilman Steinweg's avatar
Tilman Steinweg committed
271

272 273 274 275 276
			/* right boundary */                                         
			if((!BOUNDARY) && (POS[1]==NPROCX-1) && (i>=nx2-FW+1)){
			
				h1 = (i-nx2+2*FW);
				h = i;
Tilman Steinweg's avatar
Tilman Steinweg committed
277
				
278 279 280 281 282
				psi_vxx[j][h1] = b_x[h1] * psi_vxx[j][h1] + a_x[h1] * vxx;
				vxx = vxx / K_x[h1] + psi_vxx[j][h1]; 

				/*psi_vyx[j][h] = b_x_half[h] * psi_vyx[j][h] + a_x_half[h] * vyx;
				vyx = vyx / K_x_half[h] + psi_vyx[j][h];*/
Tilman Steinweg's avatar
Tilman Steinweg committed
283
				
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307
				psi_vyx[j][h1] = b_x_half[h1] * psi_vyx[j][h1] + a_x_half[h1] * vyx;
				vyx = vyx / K_x_half[h1] + psi_vyx[j][h1];
						
			}

			/* top boundary */                                         
			if((POS[2]==0) && (!(FREE_SURF)) && (j<=FW)){
							
				psi_vyy[j][i] = b_y[j] * psi_vyy[j][i] + a_y[j] * vyy;                                            
				psi_vxy[j][i] = b_y_half[j] * psi_vxy[j][i] + a_y_half[j] * vxy;
			
				vyy = vyy / K_y[j] + psi_vyy[j][i];
				vxy = vxy / K_y_half[j] + psi_vxy[j][i];

			}
			
			/* bottom boundary */                                         
			if((POS[2]==NPROCY-1) && (j>=ny2-FW+1)){

				h1 = (j-ny2+2*FW);                                        
				h = j;
							
				psi_vyy[h1][i] = b_y[h1] * psi_vyy[h1][i] + a_y[h1] * vyy;                                            
				vyy = vyy / K_y[h1] + psi_vyy[h1][i];
Tilman Steinweg's avatar
Tilman Steinweg committed
308
				
309 310
				/*psi_vxy[j][i] = b_y_half[j] * psi_vxy[j][i] + a_y_half[j] * vxy;
				vxy = vxy / K_y_half[j] + psi_vxy[j][i];*/
Tilman Steinweg's avatar
Tilman Steinweg committed
311
				
312 313 314
				psi_vxy[h1][i] = b_y_half[h1] * psi_vxy[h1][i] + a_y_half[h1] * vxy;
				vxy = vxy / K_y_half[h1] + psi_vxy[h1][i];
		
Tilman Steinweg's avatar
Tilman Steinweg committed
315
			}
316 317 318 319

			fipjp=uipjp[j][i];
			
			/* lambda - mu relationship*/
320
			if (PARAMETERIZATION==3){
321 322 323
				f = u[j][i];
				g = pi[j][i];}  
			
324
			if (PARAMETERIZATION==1){
325 326 327 328 329 330 331 332 333 334 335
				f = rho[j][i] * u[j][i] * u[j][i];
				g = rho[j][i] * ((pi[j][i] * pi[j][i]) - 2 * u[j][i] * u[j][i]);}
			
			sxy[j][i] += fipjp*(vyx+vxy);
			sxx[j][i] += g*(vxx+vyy)+(2.0*f*vxx);
			syy[j][i] += g*(vxx+vyy)+(2.0*f*vyy);
			
			uxy[j][i] = (fipjp/DT)*(vyx+vxy);
			ux[j][i] = (g/DT)*(vxx+vyy)+((2.0*f/DT)*vxx);
			uy[j][i] = (g/DT)*(vxx+vyy)+((2.0*f/DT)*vyy);
		}
Tilman Steinweg's avatar
Tilman Steinweg committed
336
		}
337
	break;
Tilman Steinweg's avatar
Tilman Steinweg committed
338 339 340

	case 8:

341 342
		for (j=ny1;j<=ny2;j++){
		for (i=nx1;i<=nx2;i++){
Tilman Steinweg's avatar
Tilman Steinweg committed
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363

			vxx = (  hc[1]*(vx[j][i]  -vx[j][i-1])
				       + hc[2]*(vx[j][i+1]-vx[j][i-2])
				       + hc[3]*(vx[j][i+2]-vx[j][i-3])
				       + hc[4]*(vx[j][i+3]-vx[j][i-4]))*dhi;
			
			vyx = (  hc[1]*(vy[j][i+1]-vy[j][i])
				       + hc[2]*(vy[j][i+2]-vy[j][i-1])
				       + hc[3]*(vy[j][i+3]-vy[j][i-2])
				       + hc[4]*(vy[j][i+4]-vy[j][i-3]))*dhi;

                        vxy = (  hc[1]*(vx[j+1][i]-vx[j][i])
				       + hc[2]*(vx[j+2][i]-vx[j-1][i])
				       + hc[3]*(vx[j+3][i]-vx[j-2][i])
				       + hc[4]*(vx[j+4][i]-vx[j-3][i]))*dhi;

                        vyy = (  hc[1]*(vy[j][i]  -vy[j-1][i])
				       + hc[2]*(vy[j+1][i]-vy[j-2][i])
				       + hc[3]*(vy[j+2][i]-vy[j-3][i])
				       + hc[4]*(vy[j+3][i]-vy[j-4][i]))*dhi; 

364 365 366 367 368
			/* left boundary */                                         
			if((!BOUNDARY) && (POS[1]==0) && (i<=FW)){
				
				psi_vxx[j][i] = b_x[i] * psi_vxx[j][i] + a_x[i] * vxx;
				vxx = vxx / K_x[i] + psi_vxx[j][i];
Tilman Steinweg's avatar
Tilman Steinweg committed
369

370 371 372
				psi_vyx[j][i] = b_x_half[i] * psi_vyx[j][i] + a_x_half[i] * vyx;
				vyx = vyx / K_x_half[i] + psi_vyx[j][i];                 
			}
Tilman Steinweg's avatar
Tilman Steinweg committed
373

374 375 376 377 378
			/* right boundary */                                         
			if((!BOUNDARY) && (POS[1]==NPROCX-1) && (i>=nx2-FW+1)){
			
				h1 = (i-nx2+2*FW);
				h = i;
Tilman Steinweg's avatar
Tilman Steinweg committed
379
				
380 381 382 383 384
				psi_vxx[j][h1] = b_x[h1] * psi_vxx[j][h1] + a_x[h1] * vxx;
				vxx = vxx / K_x[h1] + psi_vxx[j][h1]; 

				/*psi_vyx[j][h] = b_x_half[h] * psi_vyx[j][h] + a_x_half[h] * vyx;
				vyx = vyx / K_x_half[h] + psi_vyx[j][h];*/
Tilman Steinweg's avatar
Tilman Steinweg committed
385
				
386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409
				psi_vyx[j][h1] = b_x_half[h1] * psi_vyx[j][h1] + a_x_half[h1] * vyx;
				vyx = vyx / K_x_half[h1] + psi_vyx[j][h1];
						
			}

			/* top boundary */                                         
			if((POS[2]==0) && (!(FREE_SURF)) && (j<=FW)){
							
				psi_vyy[j][i] = b_y[j] * psi_vyy[j][i] + a_y[j] * vyy;                                            
				psi_vxy[j][i] = b_y_half[j] * psi_vxy[j][i] + a_y_half[j] * vxy;
			
				vyy = vyy / K_y[j] + psi_vyy[j][i];
				vxy = vxy / K_y_half[j] + psi_vxy[j][i];

			}
			
			/* bottom boundary */                                         
			if((POS[2]==NPROCY-1) && (j>=ny2-FW+1)){

				h1 = (j-ny2+2*FW);                                        
				h = j;
							
				psi_vyy[h1][i] = b_y[h1] * psi_vyy[h1][i] + a_y[h1] * vyy;                                            
				vyy = vyy / K_y[h1] + psi_vyy[h1][i];
Tilman Steinweg's avatar
Tilman Steinweg committed
410
				
411 412
				/*psi_vxy[j][i] = b_y_half[j] * psi_vxy[j][i] + a_y_half[j] * vxy;
				vxy = vxy / K_y_half[j] + psi_vxy[j][i];*/
Tilman Steinweg's avatar
Tilman Steinweg committed
413
				
414 415 416 417
				psi_vxy[h1][i] = b_y_half[h1] * psi_vxy[h1][i] + a_y_half[h1] * vxy;
				vxy = vxy / K_y_half[h1] + psi_vxy[h1][i];
		
			}
Tilman Steinweg's avatar
Tilman Steinweg committed
418

419 420 421
			fipjp=uipjp[j][i];
			
			/* lambda - mu relationship*/
422
			if (PARAMETERIZATION==3){
423 424 425
				f = u[j][i];
				g = pi[j][i];}  
			
426
			if (PARAMETERIZATION==1){
427 428 429 430 431 432 433 434 435 436 437 438 439 440
				f = rho[j][i] * u[j][i] * u[j][i];
				g = rho[j][i] * ((pi[j][i] * pi[j][i]) - 2 * u[j][i] * u[j][i]);}
			
			sxy[j][i] += fipjp*(vyx+vxy);
			sxx[j][i] += g*(vxx+vyy)+(2.0*f*vxx);
			syy[j][i] += g*(vxx+vyy)+(2.0*f*vyy);
			
			uxy[j][i] = (fipjp/DT)*(vyx+vxy);
			ux[j][i] = (g/DT)*(vxx+vyy)+((2.0*f/DT)*vxx);
			uy[j][i] = (g/DT)*(vxx+vyy)+((2.0*f/DT)*vyy);
			
		}
		}
	break;
Tilman Steinweg's avatar
Tilman Steinweg committed
441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569

	case 10:
		for (j=ny1;j<=ny2;j++){
			for (i=nx1;i<=nx2;i++){
				vxx = (  hc[1]*(vx[j][i]  -vx[j][i-1])
				       + hc[2]*(vx[j][i+1]-vx[j][i-2])
				       + hc[3]*(vx[j][i+2]-vx[j][i-3])
				       + hc[4]*(vx[j][i+3]-vx[j][i-4])
				       + hc[5]*(vx[j][i+4]-vx[j][i-5])
				      )*dhi;
				vyy = (  hc[1]*(vy[j][i]  -vy[j-1][i])
				       + hc[2]*(vy[j+1][i]-vy[j-2][i])
				       + hc[3]*(vy[j+2][i]-vy[j-3][i])
				       + hc[4]*(vy[j+3][i]-vy[j-4][i])
				       + hc[5]*(vy[j+4][i]-vy[j-5][i])
				      )*dhi;
				vyx = (  hc[1]*(vy[j][i+1]-vy[j][i])
				       + hc[2]*(vy[j][i+2]-vy[j][i-1])
				       + hc[3]*(vy[j][i+3]-vy[j][i-2])
				       + hc[4]*(vy[j][i+4]-vy[j][i-3])
				       + hc[5]*(vy[j][i+5]-vy[j][i-4])
				      )*dhi;
				vxy = (  hc[1]*(vx[j+1][i]-vx[j][i])
				       + hc[2]*(vx[j+2][i]-vx[j-1][i])
				       + hc[3]*(vx[j+3][i]-vx[j-2][i])
				       + hc[4]*(vx[j+4][i]-vx[j-3][i])
				       + hc[5]*(vx[j+5][i]-vx[j-4][i])
				      )*dhi;
				      
				ux[j][i] += DT*vxx;
				uy[j][i] += DT*vyy;      
		       		
				fipjp=uipjp[j][i]*DT;
				f=u[j][i]*DT;
				g=pi[j][i]*DT;
				
				sxy[j][i]+=(fipjp*(vxy+vyx));
				sxx[j][i]+=(g*(vxx+vyy))-(2.0*f*vyy);
				syy[j][i]+=(g*(vxx+vyy))-(2.0*f*vxx);
				
				/*
				piv = pi[j][i]*(vxx+vyy);
				sxy[j][i]+=(uipjp[j][i]*(vxy+vyx));
				sxx[j][i]+=piv-(2.0*u[j][i]*vyy);
				syy[j][i]+=piv-(2.0*u[j][i]*vxx);
				*/
			}
		}
		break;
		
	case 12:
		for (j=ny1;j<=ny2;j++){
			for (i=nx1;i<=nx2;i++){
				vxx = (  hc[1]*(vx[j][i]  -vx[j][i-1])
				       + hc[2]*(vx[j][i+1]-vx[j][i-2])
				       + hc[3]*(vx[j][i+2]-vx[j][i-3])
				       + hc[4]*(vx[j][i+3]-vx[j][i-4])
				       + hc[5]*(vx[j][i+4]-vx[j][i-5])
				       + hc[6]*(vx[j][i+5]-vx[j][i-6])
				      )*dhi;
				vyy = (  hc[1]*(vy[j][i]  -vy[j-1][i])
				       + hc[2]*(vy[j+1][i]-vy[j-2][i])
				       + hc[3]*(vy[j+2][i]-vy[j-3][i])
				       + hc[4]*(vy[j+3][i]-vy[j-4][i])
				       + hc[5]*(vy[j+4][i]-vy[j-5][i])
				       + hc[6]*(vy[j+5][i]-vy[j-6][i])
				      )*dhi;
				vyx = (  hc[1]*(vy[j][i+1]-vy[j][i])
				       + hc[2]*(vy[j][i+2]-vy[j][i-1])
				       + hc[3]*(vy[j][i+3]-vy[j][i-2])
				       + hc[4]*(vy[j][i+4]-vy[j][i-3])
				       + hc[5]*(vy[j][i+5]-vy[j][i-4])
				       + hc[6]*(vy[j][i+6]-vy[j][i-5])
				      )*dhi;
				vxy = (  hc[1]*(vx[j+1][i]-vx[j][i])
				       + hc[2]*(vx[j+2][i]-vx[j-1][i])
				       + hc[3]*(vx[j+3][i]-vx[j-2][i])
				       + hc[4]*(vx[j+4][i]-vx[j-3][i])
				       + hc[5]*(vx[j+5][i]-vx[j-4][i])
				       + hc[6]*(vx[j+6][i]-vx[j-5][i])
				      )*dhi;
				      
				ux[j][i] += DT*vxx;
				uy[j][i] += DT*vyy;
		       
				fipjp=uipjp[j][i]*DT;
				f=u[j][i]*DT;
				g=pi[j][i]*DT;

				sxy[j][i]+=(fipjp*(vxy+vyx));
				sxx[j][i]+=(g*(vxx+vyy))-(2.0*f*vyy);
				syy[j][i]+=(g*(vxx+vyy))-(2.0*f*vxx);
			}
		}
		break;
		
	default:
		for (j=ny1;j<=ny2;j++){
			for (i=nx1;i<=nx2;i++){
				vxx = 0.0;
				vyy = 0.0;
				vyx = 0.0;
				vxy = 0.0;
				for (m=1; m<=fdoh; m++) {
					vxx += hc[m]*(vx[j][i+m-1] -vx[j][i-m]  );
					vyy += hc[m]*(vy[j+m-1][i] -vy[j-m][i]  );
					vyx += hc[m]*(vy[j][i+m]   -vy[j][i-m+1]);
					vxy += hc[m]*(vx[j+m][i]   -vx[j-m+1][i]);
				}	
	
				fipjp=uipjp[j][i]*DT;
				f=u[j][i]*DT;
				g=pi[j][i]*DT;	

				sxy[j][i]+=(fipjp*(vxy+vyx))*dhi;
				sxx[j][i]+=((g*(vxx+vyy))-(2.0*f*vyy))*dhi;
				syy[j][i]+=((g*(vxx+vyy))-(2.0*f*vxx))*dhi;
			}
		}
		break;
		
	} /* end of switch(FDORDER) */


	if (infoout && (MYID==0)){
		time2=MPI_Wtime();
		fprintf(FP," finished (real time: %4.2f s).\n",time2-time1);
	}
}