surface_ssg_elastic.c 8.21 KB
Newer Older
Simone Butzer's avatar
Simone Butzer committed
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
/*------------------------------------------------------------------------
 * Copyright (C) 2015 For the list of authors, see file AUTHORS.
 *
 * This file is part of IFOS3D.
 * 
 * IFOS3D 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.
 * 
 * IFOS3D 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 IFOS3D. See file COPYING and/or 
 * <http://www.gnu.org/licenses/gpl-2.0.html>.
--------------------------------------------------------------------------*/

/*------------------------------------------------------------------------
 *   stress free surface condition, elastic case
 *  ----------------------------------------------------------------------*/

#include "fd.h"

void surface_elastic(int ndepth, float *** u, float *** pi,
		float *** sxx, float ***syy, float ***szz, float *** sxy,float *** syz,
		float *** vx, float *** vy, float *** vz){

	int i, k ,j, fdoh,m;
	float  vxx, vyy, vzz;
	float f, g, h;


	extern int NX, NZ, FDORDER, FDCOEFF;
	register float b1, b2, b3, b4, b5, b6;
	extern float DT, DX, DY, DZ;

39
	j=ndepth;     /* The free surface is located exactly in y=ndepth*dh meter!! */
Simone Butzer's avatar
Simone Butzer committed
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 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 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 308 309 310

	/*dthalbe=DT/2.0;*/
	fdoh=FDORDER/2;


	switch (FDORDER){
	case 2 :

		for (k=1;k<=NZ;k++){
			for (i=1;i<=NX;i++){


				/*Mirroring the components of the stress tensor to make
					  a stress free surface (method of imaging, Levander, 1988)*/
				syy[j][i][k]=0.0;

				syy[j-1][i][k]=-syy[j+1][i][k];
				sxy[j-1][i][k]=-sxy[j][i][k];
				sxy[j-2][i][k]=-sxy[j+1][i][k];
				syz[j-1][i][k]=-syz[j][i][k];
				syz[j-2][i][k]=-syz[j+1][i][k];

				vxx = (vx[j][i][k]-vx[j][i-1][k])/DX;
				vyy = (vy[j][i][k]-vy[j-1][i][k])/DY;
				vzz = (vz[j][i][k]-vz[j][i][k-1])/DZ;


				f=u[j][i][k]*2.0;
				g=pi[j][i][k];
				h=-(DT*(g-f)*(g-f)*(vxx+vzz)/g)-(DT*(g-f)*vyy);
				sxx[j][i][k]+=h;
				szz[j][i][k]+=h;


			}
		}
		break;

	case 4 :

		b1=9.0/8.0; b2=-1.0/24.0; /* Taylor coefficients */

		if(FDCOEFF==2){
			b1=1.1382; b2=-0.046414;} /* Holberg coefficients E=0.1 %*/

		for (k=1;k<=NZ;k++){
			for (i=1;i<=NX;i++){


				/*Mirroring the components of the stress tensor to make
					  a stress free surface (method of imaging, Levander, 1988)*/
				syy[j][i][k]=0.0;

				for (m=1; m<=fdoh; m++) {
					syy[j-m][i][k]=-syy[j+m][i][k];
					sxy[j-m][i][k]=-sxy[j+m-1][i][k];
					syz[j-m][i][k]=-syz[j+m-1][i][k];
				}
				vxx = (b1*(vx[j][i][k]-vx[j][i-1][k])+b2*(vx[j][i+1][k]-vx[j][i-2][k]))/DX;
				vyy = (b1*(vy[j][i][k]-vy[j-1][i][k])+b2*(vy[j+1][i][k]-vy[j-2][i][k]))/DY;
				vzz = (b1*(vz[j][i][k]-vz[j][i][k-1])+b2*(vz[j][i][k+1]-vz[j][i][k-2]))/DZ;


				f=u[j][i][k]*2.0;
				g=pi[j][i][k];
				h=-(DT*(g-f)*(g-f)*(vxx+vzz)/g)-(DT*(g-f)*vyy);
				sxx[j][i][k]+=h;
				szz[j][i][k]+=h;


			}
		}
		break;

	case 6 :

		b1=75.0/64.0; b2=-25.0/384.0; b3=3.0/640.0; /* Taylor coefficients */
		if(FDCOEFF==2){
			b1=1.1965; b2=-0.078804; b3=0.0081781;}   /* Holberg coefficients E=0.1 %*/

		for (k=1;k<=NZ;k++){
			for (i=1;i<=NX;i++){


				/*Mirroring the components of the stress tensor to make
					  a stress free surface (method of imaging, Levander, 1988)*/
				syy[j][i][k]=0.0;

				for (m=1; m<=fdoh; m++) {
					syy[j-m][i][k]=-syy[j+m][i][k];
					sxy[j-m][i][k]=-sxy[j+m-1][i][k];
					syz[j-m][i][k]=-syz[j+m-1][i][k];
				}


				vxx = (b1*(vx[j][i][k]-vx[j][i-1][k])+
						b2*(vx[j][i+1][k]-vx[j][i-2][k])+
						b3*(vx[j][i+2][k]-vx[j][i-3][k]))/DX;

				vyy = (b1*(vy[j][i][k]-vy[j-1][i][k])+
						b2*(vy[j+1][i][k]-vy[j-2][i][k])+
						b3*(vy[j+2][i][k]-vy[j-3][i][k]))/DY;

				vzz = (b1*(vz[j][i][k]-vz[j][i][k-1])+
						b2*(vz[j][i][k+1]-vz[j][i][k-2])+
						b3*(vz[j][i][k+2]-vz[j][i][k-3]))/DZ;


				f=u[j][i][k]*2.0;
				g=pi[j][i][k];
				h=-(DT*(g-f)*(g-f)*(vxx+vzz)/g)-(DT*(g-f)*vyy);
				sxx[j][i][k]+=h;
				szz[j][i][k]+=h;
			}
		}
		break;

	case 8 :

		b1=1225.0/1024.0; b2=-245.0/3072.0; b3=49.0/5120.0; b4=-5.0/7168.0; /* Taylor coefficients */

		if(FDCOEFF==2){
			b1=1.2257; b2=-0.099537; b3=0.018063; b4=-0.0026274;} /* Holberg coefficients E=0.1 %*/

		for (k=1;k<=NZ;k++){
			for (i=1;i<=NX;i++){


				/*Mirroring the components of the stress tensor to make
					  a stress free surface (method of imaging, Levander, 1988)*/
				syy[j][i][k]=0.0;

				for (m=1; m<=fdoh; m++) {
					syy[j-m][i][k]=-syy[j+m][i][k];
					sxy[j-m][i][k]=-sxy[j+m-1][i][k];
					syz[j-m][i][k]=-syz[j+m-1][i][k];
				}


				vxx = (b1*(vx[j][i][k]-vx[j][i-1][k])+
						b2*(vx[j][i+1][k]-vx[j][i-2][k])+
						b3*(vx[j][i+2][k]-vx[j][i-3][k])+
						b4*(vx[j][i+3][k]-vx[j][i-4][k]))/DX;

				vyy = (b1*(vy[j][i][k]-vy[j-1][i][k])+
						b2*(vy[j+1][i][k]-vy[j-2][i][k])+
						b3*(vy[j+2][i][k]-vy[j-3][i][k])+
						b4*(vy[j+3][i][k]-vy[j-4][i][k]))/DY;

				vzz = (b1*(vz[j][i][k]-vz[j][i][k-1])+
						b2*(vz[j][i][k+1]-vz[j][i][k-2])+
						b3*(vz[j][i][k+2]-vz[j][i][k-3])+
						b4*(vz[j][i][k+3]-vz[j][i][k-4]))/DZ;


				f=u[j][i][k]*2.0;
				g=pi[j][i][k];
				h=-(DT*(g-f)*(g-f)*(vxx+vzz)/g)-(DT*(g-f)*vyy);
				sxx[j][i][k]+=h;
				szz[j][i][k]+=h;


			}
		}
		break;

	case 10 :

		b1=19845.0/16384.0; b2=-735.0/8192.0; b3=567.0/40960.0; b4=-405.0/229376.0; b5=35.0/294912.0; /* Taylor coefficients */

		if(FDCOEFF==2){
			b1=1.2415; b2=-0.11231; b3=0.026191; b4=-0.0064682; b5=0.001191;} /* Holberg coefficients E=0.1 %*/

		for (k=1;k<=NZ;k++){
			for (i=1;i<=NX;i++){


				/*Mirroring the components of the stress tensor to make
					  a stress free surface (method of imaging, Levander, 1988)*/
				syy[j][i][k]=0.0;

				for (m=1; m<=fdoh; m++) {
					syy[j-m][i][k]=-syy[j+m][i][k];
					sxy[j-m][i][k]=-sxy[j+m-1][i][k];
					syz[j-m][i][k]=-syz[j+m-1][i][k];
				}


				vxx = (b1*(vx[j][i][k]-vx[j][i-1][k])+
						b2*(vx[j][i+1][k]-vx[j][i-2][k])+
						b3*(vx[j][i+2][k]-vx[j][i-3][k])+
						b4*(vx[j][i+3][k]-vx[j][i-4][k])+
						b5*(vx[j][i+4][k]-vx[j][i-5][k]))/DX;

				vyy = (b1*(vy[j][i][k]-vy[j-1][i][k])+
						b2*(vy[j+1][i][k]-vy[j-2][i][k])+
						b3*(vy[j+2][i][k]-vy[j-3][i][k])+
						b4*(vy[j+3][i][k]-vy[j-4][i][k])+
						b5*(vy[j+4][i][k]-vy[j-5][i][k]))/DY;

				vzz = (b1*(vz[j][i][k]-vz[j][i][k-1])+
						b2*(vz[j][i][k+1]-vz[j][i][k-2])+
						b3*(vz[j][i][k+2]-vz[j][i][k-3])+
						b4*(vz[j][i][k+3]-vz[j][i][k-4])+
						b5*(vz[j][i][k+4]-vz[j][i][k-5]))/DZ;

				f=u[j][i][k]*2.0;
				g=pi[j][i][k];
				h=-(DT*(g-f)*(g-f)*(vxx+vzz)/g)-(DT*(g-f)*vyy);
				sxx[j][i][k]+=h;
				szz[j][i][k]+=h;
			}
		}
		break;

	case 12 :

		/* Taylor coefficients */
		b1=160083.0/131072.0; b2=-12705.0/131072.0; b3=22869.0/1310720.0;
		b4=-5445.0/1835008.0; b5=847.0/2359296.0; b6=-63.0/2883584;

		/* Holberg coefficients E=0.1 %*/
		if(FDCOEFF==2){
			b1=1.2508; b2=-0.12034; b3=0.032131; b4=-0.010142; b5=0.0029857; b6=-0.00066667;}

		for (k=1;k<=NZ;k++){
			for (i=1;i<=NX;i++){


				/*Mirroring the components of the stress tensor to make
					  a stress free surface (method of imaging, Levander, 1988)*/
				syy[j][i][k]=0.0;

				for (m=1; m<=fdoh; m++) {
					syy[j-m][i][k]=-syy[j+m][i][k];
					sxy[j-m][i][k]=-sxy[j+m-1][i][k];
					syz[j-m][i][k]=-syz[j+m-1][i][k];
				}


				vxx = (b1*(vx[j][i][k]-vx[j][i-1][k])+
						b2*(vx[j][i+1][k]-vx[j][i-2][k])+
						b3*(vx[j][i+2][k]-vx[j][i-3][k])+
						b4*(vx[j][i+3][k]-vx[j][i-4][k])+
						b5*(vx[j][i+4][k]-vx[j][i-5][k])+
						b6*(vx[j][i+5][k]-vx[j][i-6][k]))/DX;

				vyy = (b1*(vy[j][i][k]-vy[j-1][i][k])+
						b2*(vy[j+1][i][k]-vy[j-2][i][k])+
						b3*(vy[j+2][i][k]-vy[j-3][i][k])+
						b4*(vy[j+3][i][k]-vy[j-4][i][k])+
						b5*(vy[j+4][i][k]-vy[j-5][i][k])+
						b6*(vy[j+5][i][k]-vy[j-6][i][k]))/DY;

				vzz = (b1*(vz[j][i][k]-vz[j][i][k-1])+
						b2*(vz[j][i][k+1]-vz[j][i][k-2])+
						b3*(vz[j][i][k+2]-vz[j][i][k-3])+
						b4*(vz[j][i][k+3]-vz[j][i][k-4])+
						b5*(vz[j][i][k+4]-vz[j][i][k-5])+
						b6*(vz[j][i][k+5]-vz[j][i][k-6]))/DZ;

				f=u[j][i][k]*2.0;
				g=pi[j][i][k];
				h=-(DT*(g-f)*(g-f)*(vxx+vzz)/g)-(DT*(g-f)*vyy);
				sxx[j][i][k]+=h;
				szz[j][i][k]+=h;
			}
		}
		break;
	}
}