diff --git a/extrap/demo/model.scr b/extrap/demo/model.scr new file mode 100755 index 0000000000000000000000000000000000000000..692e6469c9f236b7329bf9cd23ada1b62fb6ef27 --- /dev/null +++ b/extrap/demo/model.scr @@ -0,0 +1,8 @@ +#!/bin/bash + +makemod par=syncline.makemod + +makewave \ + fmax=60 db=-30 shift=1 \ + dt=0.004 nt=512 file_out=ricker.su + diff --git a/extrap/demo/syncline.makemod b/extrap/demo/syncline.makemod new file mode 100644 index 0000000000000000000000000000000000000000..a915da525c0b719d06f0bc7d91a278e05b983e05 --- /dev/null +++ b/extrap/demo/syncline.makemod @@ -0,0 +1,46 @@ +# +file_base=syncline.su +cp0=2000 +ro0=1500 +sizex=3000 +sizez=2000 +dx=2.5 +dz=2.5 +orig=0,0 +writeint=1 + +intt=def +poly=0 +cp=2200 +ro=2200 +x=0,3000 +z=300,300 + +intt=def +poly=2 +cp=2700 +ro=2800 +x=0,500,1000,1100,1500,1900,3000 +z=700,700,750,800,950,800,500 + +intt=def +poly=0 +cp=2400 +ro=2200 +x=1500,3000 +z=1200,1200 + +intt=def +poly=0 +cp=3000 +ro=3200 +x=0,1500,3000 +z=1200,1200,1400 + +#intt=diffr +#cp=0 +#ro=2200 +#x=750 +#z=1000 + + diff --git a/fdelmodc/applySource.c.old b/fdelmodc/applySource.c.old deleted file mode 100644 index b8ecf4949f2c8a9639711c16203fa47d5e74ebfb..0000000000000000000000000000000000000000 --- a/fdelmodc/applySource.c.old +++ /dev/null @@ -1,309 +0,0 @@ -#include<stdlib.h> -#include<stdio.h> -#include<math.h> -#include<assert.h> -#include"fdelmodc.h" - -void vmess(char *fmt, ...); - -/********************************************************************* - * - * Add's the source amplitude(s) to the grid. - * - * For the acoustic schemes, the source-type must not be txx tzz or txz. - * - * AUTHOR: - * Jan Thorbecke (janth@xs4all.nl) - * The Netherlands - * - **********************************************************************/ - -int applySource(modPar mod, srcPar src, wavPar wav, bndPar bnd, int itime, int ixsrc, int izsrc, float *vx, float *vz, float *tzz, float *txx, float *txz, float *rox, float *roz, float *l2m, float **src_nwav, int verbose) -{ - int is0, ibndz, ibndx; - int isrc, ix, iz, n1; - int id1, id2; - float src_ampl, time, scl, dt, sdx; - static int first=1; - - if (src.type==6) { - ibndz = mod.ioXz; - ibndx = mod.ioXx; - } - else if (src.type==7) { - ibndz = mod.ioZz; - ibndx = mod.ioZx; - } - else if (src.type==2) { - ibndz = mod.ioTz; - ibndx = mod.ioTx; - } - else { - ibndz = mod.ioPz; - ibndx = mod.ioPx; - } - n1 = mod.naz; - dt = mod.dt; - sdx = 1.0/mod.dx; - - /* special txz source activated? */ - - if ((bnd.top==1) && (src.type==2)) { - iz = izsrc + ibndz; - if (iz==ibndz) { - if (src.orient != 1) { - if (first) { - vmess("Only monopole Txz source allowed at surface. Reset to monopole"); - first = 0; - } - src.orient=1; - } - } - } - -/* -* for plane wave sources the sources are placed -* around the central shot position -* the first source position has an offset in x of is0 -* -* itime = 0 corresponds with time=0 -* itime = 1 corresponds with time=dt -* src[0] (the first sample) corresponds with time = 0 -*/ - - is0 = -1*floor((src.n-1)/2); -#pragma omp for private (isrc, src_ampl, ix, iz, time, id1, id2, scl) - for (isrc=0; isrc<src.n; isrc++) { - src_ampl=0.0; - /* calculate the source position */ - if (src.random) { - ix = src.x[isrc] + ibndx; - iz = src.z[isrc] + ibndz; - } - else { /* plane wave and point sources */ - ix = ixsrc + ibndx + is0 + isrc; - iz = izsrc + ibndz; - } - time = itime*dt - src.tbeg[isrc]; - id1 = floor(time/dt); - id2 = id1+1; - - /* delay not reached or no samples left in source wavelet? */ - if ( (time < 0.0) || ( (itime*dt) >= src.tend[isrc]) ) continue; - -// fprintf(stderr,"isrc=%d ix=%d iz=%d src.x=%d src.z=%d\n", isrc, ix, iz, src.x[isrc], src.z[isrc]); - - if (!src.multiwav) { /* only one wavelet for all sources */ - src_ampl = src_nwav[0][id1]*(id2-time/dt) + src_nwav[0][id2]*(time/dt-id1); - } - else { /* multi-wavelet sources */ - src_ampl = src_nwav[isrc][id1]*(id2-time/dt) + src_nwav[isrc][id2]*(time/dt-id1); - } - - if (src_ampl==0.0) continue; - if ( ((ix-ibndx)<0) || ((ix-ibndx)>mod.nx) ) continue; /* source outside grid */ - - if (verbose>4) { - fprintf(stderr,"Source %d at grid [ix=%d,iz=%d] at itime %d has value %e\n",isrc, ix,iz, itime, src_ampl); - } - - /* cosine squared windowing to reduce edge effects on shot arrays */ - if ( (src.n>1) && src.window) { - if (isrc < src.window) { - scl = cos(0.5*M_PI*(src.window - isrc)/src.window); - } - else if (isrc > src.n-src.window+1) { - scl = cos(0.5*M_PI*(src.window - (src.n-isrc+1))/src.window); - } - src_ampl *= scl*scl; - } - - /* source scaling factor to compensate for discretisation */ - - /* old amplitude setting does not obey reciprocity */ - // src_ampl *= rox[ix*n1+iz]*l2m[ix*n1+iz]/(dt); - - src_ampl *= (1.0/mod.dx)*l2m[ix*n1+iz]; - - /* Force source */ - - if (src.type == 6) { -// vx[ix*n1+iz] += src_ampl*(dt/mod.dx)/(l2m[ix*n1+iz]); - vx[ix*n1+iz] += src_ampl*rox[ix*n1+iz]/(l2m[ix*n1+iz]); - } - else if (src.type == 7) { -// fprintf(stderr,"l2m=%e rox=%e rho=%e dt=%e dx=%e\n", l2m[ix*n1+iz], roz[ix*n1+iz], dt/(mod.dx*roz[ix*n1+iz]), dt, mod.dx); - /* old amplitude setting does not obey reciprocity */ -// vz[ix*n1+iz] += src_ampl*(dt/mod.dx)/(l2m[ix*n1+iz]); - vz[ix*n1+iz] += src_ampl*roz[ix*n1+iz]/(l2m[ix*n1+iz]); - } /* src.type */ - - - /* Stress source */ - - if (mod.ischeme <= 2) { /* Acoustic scheme */ - /* Compressional source */ - if (src.type == 1) { - if (src.orient != 1) src_ampl=src_ampl/mod.dx; - - if (src.orient==1) { /* monopole */ - tzz[ix*n1+iz] += src_ampl; - } - else if (src.orient==2) { /* dipole +/- */ - tzz[ix*n1+iz] += src_ampl; - tzz[ix*n1+iz+1] -= src_ampl; - } - else if (src.orient==3) { /* dipole - + */ - tzz[ix*n1+iz] += src_ampl; - tzz[(ix-1)*n1+iz] -= src_ampl; - } - else if (src.orient==4) { /* dipole +/0/- */ - if (iz > ibndz) - tzz[ix*n1+iz-1]+= 0.5*src_ampl; - if (iz < mod.nz+ibndz-1) - tzz[ix*n1+iz+1] -= 0.5*src_ampl; - } - else if (src.orient==5) { /* dipole + - */ - tzz[ix*n1+iz] += src_ampl; - tzz[(ix+1)*n1+iz] -= src_ampl; - } - } - } - else { /* Elastic scheme */ - /* Compressional source */ - if (src.type == 1) { - if (src.orient==1) { /* monopole */ - txx[ix*n1+iz] += src_ampl; - tzz[ix*n1+iz] += src_ampl; - } - else if (src.orient==2) { /* dipole +/- */ - txx[ix*n1+iz] += src_ampl; - tzz[ix*n1+iz] += src_ampl; - txx[ix*n1+iz+1] -= src_ampl; - tzz[ix*n1+iz+1] -= src_ampl; - } - else if (src.orient==3) { /* dipole - + */ - txx[ix*n1+iz] += src_ampl; - tzz[ix*n1+iz] += src_ampl; - txx[(ix-1)*n1+iz] -= src_ampl; - tzz[(ix-1)*n1+iz] -= src_ampl; - } - else if (src.orient==4) { /* dipole +/0/- */ - if (iz > ibndz) { - txx[ix*n1+iz-1]+= 0.5*src_ampl; - tzz[ix*n1+iz-1]+= 0.5*src_ampl; - } - if (iz < mod.nz+ibndz-1) { - txx[ix*n1+iz+1] -= 0.5*src_ampl; - tzz[ix*n1+iz+1] -= 0.5*src_ampl; - } - } - else if (src.orient==5) { /* dipole + - */ - txx[ix*n1+iz] += src_ampl; - tzz[ix*n1+iz] += src_ampl; - txx[(ix+1)*n1+iz] -= src_ampl; - tzz[(ix+1)*n1+iz] -= src_ampl; - } - } - else if (src.type == 2) { - /* Txz source */ - if ((iz == ibndz) && bnd.top==1) { - txz[(ix-1)*n1+iz-1] += src_ampl; - txz[ix*n1+iz-1] += src_ampl; - } - else { - txz[ix*n1+iz] += src_ampl; - } - /* possible dipole orientations for a txz source */ - if (src.orient == 2) { /* dipole +/- */ - txz[ix*n1+iz+1] -= src_ampl; - } - else if (src.orient == 3) { /* dipole - + */ - txz[(ix-1)*n1+iz] -= src_ampl; - } - else if (src.orient == 4) { /* dipole +/O/- */ - /* correction: subtrace previous value to prevent z-1 values. */ - txz[ix*n1+iz] -= 2.0*src_ampl; - txz[ix*n1+iz+1] += src_ampl; - } - else if (src.orient == 5) { /* dipole + - */ - txz[(ix+1)*n1+iz] -= src_ampl; - } - } - /* Tzz source */ - else if(src.type == 3) { - tzz[ix*n1+iz] += src_ampl; - } - /* Txx source */ - else if(src.type == 4) { - txx[ix*n1+iz] += src_ampl; - } - -/*********************************************************************** -* pure potential shear S source (experimental) -***********************************************************************/ - else if(src.type == 5) { - src_ampl = src_ampl*rox[ix*n1+iz]/(l2m[ix*n1+iz]); - if (src.orient == 3 || src.orient == 4) src_ampl = -src_ampl; - vx[ix*n1+iz] += src_ampl*sdx; - vx[ix*n1+iz-1] -= src_ampl*sdx; - vz[ix*n1+iz] -= src_ampl*sdx; - vz[(ix-1)*n1+iz] += src_ampl*sdx; - /* determine second position of dipole */ - if (src.orient == 2) { /* dipole +/- */ - iz += 1; - } - else if (src.orient == 3) { /* dipole - + */ - ix += 1; - } - else if (src.orient == 4) { /* dipole +/0/- */ - iz += 1; - } - else if (src.orient == 5) { /* dipole + - */ - ix += 1; - } - if (src.orient != 1) { - src_ampl = -src_ampl; - vx[ix*n1+iz] -= src_ampl; - vz[ix*n1+iz] += src_ampl; - vx[ix*n1+iz-1] += src_ampl; - vz[(ix-1)*n1+iz] -= src_ampl; - } - } -/*********************************************************************** -* pure potential pressure P source (experimental) -***********************************************************************/ - else if(src.type == 8) { - src_ampl = src_ampl*rox[ix*n1+iz]/(l2m[ix*n1+iz]); - if (src.orient == 3 || src.orient == 4) src_ampl = -src_ampl; - vx[(ix+1)*n1+iz] += src_ampl*sdx; - vx[ix*n1+iz] -= src_ampl*sdx; - vz[ix*n1+iz+1] += src_ampl*sdx; - vz[ix*n1+iz] -= src_ampl*sdx; - /* determine second position of dipole */ - if (src.orient == 2) { /* dipole +/- */ - iz += 1; - } - else if (src.orient == 3) { /* dipole - + */ - ix += 1; - } - else if (src.orient == 4) { /* dipole +/0/- */ - iz += 1; - } - else if (src.orient == 5) { /* dipole + - */ - ix += 1; - } - if (src.orient != 1) { - src_ampl = -src_ampl; - vx[ix*n1+iz] -= src_ampl; - vz[ix*n1+iz] -= src_ampl; - vx[ix*n1+iz-1] += src_ampl; - vz[(ix-1)*n1+iz] += src_ampl; - } - - } /* src.type */ - } /* ischeme */ - } /* loop over isrc */ - - return 0; -} diff --git a/fdelmodc/boundaries.c.botok b/fdelmodc/boundaries.c.botok deleted file mode 100644 index 3f8e12c5d5ef0b7d46dffbc04bfafca2b82aceb0..0000000000000000000000000000000000000000 --- a/fdelmodc/boundaries.c.botok +++ /dev/null @@ -1,1430 +0,0 @@ -#include<stdlib.h> -#include<stdio.h> -#include<math.h> -#include<assert.h> -#include"fdelmodc.h" - -float *exL, *exR, *eyT, *eyB; -int first=0; - -int boundariesP(modPar mod, bndPar bnd, float *vx, float *vz, float *tzz, float *txx, float *txz, float *rox, float *roz, float *l2m, float *lam, float *mul, int verbose) -{ -/********************************************************************* - - AUTHOR: - Jan Thorbecke (janth@xs4all.nl) - The Netherlands - -***********************************************************************/ - - float c1, c2; - float dp, dvx, dvz; - int ix, iz, ixs, izs, ibnd, ib, ibx, ibz; - int nx, nz, n1; - int is0, isrc, ioXx, ioXz, ioZz, ioZx, ioPx, ioPz, ioTx, ioTz; - int ixo, ixe, izo, ize; - - - c1 = 9.0/8.0; - c2 = -1.0/24.0; - nx = mod.nx; - nz = mod.nz; - n1 = mod.naz; - - ibnd = mod.iorder/2-1; - /* Vx: rox */ - ioXx=mod.ioXx; - ioXz=mod.ioXz; - /* Vz: roz */ - ioZz=mod.ioZz; - ioZx=mod.ioZz; - /* P, Txx, Tzz: lam, l2m */ - ioPx=mod.ioPx; - ioPz=mod.ioPz; - /* Txz: muu */ - ioTx=mod.ioTx; - ioTz=mod.ioTz; - -/************************************************************/ -/* rigid boundary condition clears velocities on boundaries */ -/************************************************************/ - - if (bnd.top==3) { /* rigid surface at top */ -#pragma omp for private (ix, iz) nowait -#pragma ivdep - for (ix=1; ix<=nx; ix++) { - vx[ix*n1+ibnd] = 0.0; - vz[ix*n1+ibnd] = -vz[ix*n1+ibnd+1]; - if (mod.iorder >= 4) vz[ix*n1+ibnd-1] = -vz[ix*n1+ibnd+2]; - if (mod.iorder >= 6) vz[ix*n1+ibnd-2] = -vz[ix*n1+ibnd+3]; - } - } - if (bnd.rig==3) { /* rigid surface at right */ -#pragma omp for private (ix, iz) nowait -#pragma ivdep - for (iz=1; iz<=nz; iz++) { - vz[(nx+ibnd-1)*n1+iz] = 0.0; - vx[(nx+ibnd)*n1+iz] = -vx[(nx+ibnd-1)*n1+iz]; - if (mod.iorder == 4) vx[(nx+2)*n1+iz] = -vx[(nx-1)*n1+iz]; - if (mod.iorder == 6) { - vx[(nx+1)*n1+iz] = -vx[(nx)*n1+iz]; - vx[(nx+3)*n1+iz] = -vx[(nx-2)*n1+iz]; - } - } - } - if (bnd.bot==3) { /* rigid surface at bottom */ -#pragma omp for private (ix, iz) nowait -#pragma ivdep - for (ix=1; ix<=nx; ix++) { - vx[ix*n1+nz+ibnd-1] = 0.0; - vz[ix*n1+nz+ibnd] = -vz[ix*n1+nz+ibnd-1]; - if (mod.iorder == 4) vz[ix*n1+nz+2] = -vz[ix*n1+nz-1]; - if (mod.iorder == 6) { - vz[ix*n1+nz+1] = -vz[ix*n1+nz]; - vz[ix*n1+nz+3] = -vz[ix*n1+nz-2]; - } - } - } - if (bnd.lef==3) { /* rigid surface at left */ -#pragma omp for private (ix, iz) nowait -#pragma ivdep - for (iz=1; iz<=nz; iz++) { - vz[ibnd*n1+iz] = 0.0; - vx[ibnd*n1+iz] = -vx[(ibnd+1)*n1+iz]; - if (mod.iorder == 4) vx[0*n1+iz] = -vx[3*n1+iz]; - if (mod.iorder == 6) { - vx[1*n1+iz] = -vx[4*n1+iz]; - vx[0*n1+iz] = -vx[5*n1+iz]; - } - } - } - -/************************************************************/ -/* PML boundaries : only for acoustic 4th order scheme */ -/************************************************************/ - - if (bnd.top==2) { /* PML at top */ - } - -/************************************************************/ -/* Tapered boundaries for both elastic and acoustic schemes */ -/* compute all field values in tapered areas */ -/************************************************************/ - - /*********/ - /* Top */ - /*********/ - if (bnd.top==4) { - - if (mod.ischeme <= 2) { /* Acoustic scheme */ - - /* Vx field */ - ixo = mod.ioXx; - ixe = mod.ieXx; -// if (bnd.lef==4) ixo -= bnd.ntap; -// if (bnd.rig==4) ixe += bnd.ntap; - izo = mod.ioXz-bnd.ntap; - ize = mod.ioXz; - - ib = (bnd.ntap+izo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[(ix-1)*n1+iz]) + - c2*(tzz[(ix+1)*n1+iz] - tzz[(ix-2)*n1+iz])); - - vx[ix*n1+iz] *= bnd.tapx[ib-iz]; - } - } - /* right top corner */ - if (bnd.rig==4) { - ixo = mod.ieXx; - ixe = ixo+bnd.ntap; - ibz = (bnd.ntap+izo-1); - ibx = (ixo); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[(ix-1)*n1+iz]) + - c2*(tzz[(ix+1)*n1+iz] - tzz[(ix-2)*n1+iz])); - - vx[ix*n1+iz] *= bnd.tapxz[(ix-ibx)*bnd.ntap+(ibz-iz)]; - } - } - } - /* left top corner */ - if (bnd.lef==4) { - ixo = mod.ioXx-bnd.ntap; - ixe = mod.ioXx; - ibz = (bnd.ntap+izo-1); - ibx = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[(ix-1)*n1+iz]) + - c2*(tzz[(ix+1)*n1+iz] - tzz[(ix-2)*n1+iz])); - - vx[ix*n1+iz] *= bnd.tapxz[(ibx-ix)*bnd.ntap+(ibz-iz)]; - } - } - } - - - /* Vz field */ - ixo = mod.ioZx; - ixe = mod.ieZx; -// if (bnd.lef==4) ixo -= bnd.ntap; -// if (bnd.rig==4) ixe += bnd.ntap; - izo = mod.ioZz-bnd.ntap; - ize = mod.ioZz; - - ib = (bnd.ntap+izo-1); -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2])); - - vz[ix*n1+iz] *= bnd.tapz[ib-iz]; - } - } - /* right top corner */ - if (bnd.rig==4) { - ixo = mod.ieZx; - ixe = ixo+bnd.ntap; - ibz = (bnd.ntap+izo-1); - ibx = (ixo); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2])); - - vz[ix*n1+iz] *= bnd.tapxz[(ix-ibx)*bnd.ntap+(ibz-iz)]; - } - } - } - /* left top corner */ - if (bnd.lef==4) { - ixo = mod.ioZx-bnd.ntap; - ixe = mod.ioZx; - ibz = (bnd.ntap+izo-1); - ibx = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2])); - - vz[ix*n1+iz] *= bnd.tapxz[(ibx-ix)*bnd.ntap+(ibz-iz)]; - } - } - } - - } - else { /* Elastic scheme */ - - /* Vx field */ - ixo = mod.ioXx; - ixe = mod.ieXx; -// if (bnd.lef==4) ixo -= bnd.ntap; -// if (bnd.rig==4) ixe += bnd.ntap; - izo = mod.ioXz-bnd.ntap; - ize = mod.ioXz; - - ib = (bnd.ntap+izo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(txx[ix*n1+iz] - txx[(ix-1)*n1+iz] + - txz[ix*n1+iz+1] - txz[ix*n1+iz]) + - c2*(txx[(ix+1)*n1+iz] - txx[(ix-2)*n1+iz] + - txz[ix*n1+iz+2] - txz[ix*n1+iz-1]) ); - - vx[ix*n1+iz] *= bnd.tapx[ib-iz]; - } - } - /* right top corner */ - if (bnd.rig==4) { - ixo = mod.ieXx; - ixe = ixo+bnd.ntap; - ibz = (bnd.ntap+izo-1); - ibx = (ixo); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(txx[ix*n1+iz] - txx[(ix-1)*n1+iz] + - txz[ix*n1+iz+1] - txz[ix*n1+iz]) + - c2*(txx[(ix+1)*n1+iz] - txx[(ix-2)*n1+iz] + - txz[ix*n1+iz+2] - txz[ix*n1+iz-1]) ); - - vx[ix*n1+iz] *= bnd.tapxz[(ix-ibx)*bnd.ntap+(ibz-iz)]; - } - } - } - /* left top corner */ - if (bnd.lef==4) { - ixo = mod.ioXx-bnd.ntap; - ixe = mod.ioXx; - ibz = (bnd.ntap+izo-1); - ibx = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(txx[ix*n1+iz] - txx[(ix-1)*n1+iz] + - txz[ix*n1+iz+1] - txz[ix*n1+iz]) + - c2*(txx[(ix+1)*n1+iz] - txx[(ix-2)*n1+iz] + - txz[ix*n1+iz+2] - txz[ix*n1+iz-1]) ); - - vx[ix*n1+iz] *= bnd.tapxz[(ibx-ix)*bnd.ntap+(ibz-iz)]; - } - } - } - - /* Vz field */ - ixo = mod.ioZx; - ixe = mod.ieZx; -// if (bnd.lef==4) ixo -= bnd.ntap; -// if (bnd.rig==4) ixe += bnd.ntap; - izo = mod.ioZz-bnd.ntap; - ize = mod.ioZz; - - ib = (bnd.ntap+izo-1); -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1] + - txz[(ix+1)*n1+iz] - txz[ix*n1+iz]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2] + - txz[(ix+2)*n1+iz] - txz[(ix-1)*n1+iz]) ); - - vz[ix*n1+iz] *= bnd.tapz[ib-iz]; - } - } - /* right top corner */ - if (bnd.rig==4) { - ixo = mod.ieZx; - ixe = ixo+bnd.ntap; - ibz = (bnd.ntap+izo-1); - ibx = (ixo); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1] + - txz[(ix+1)*n1+iz] - txz[ix*n1+iz]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2] + - txz[(ix+2)*n1+iz] - txz[(ix-1)*n1+iz]) ); - - vz[ix*n1+iz] *= bnd.tapxz[(ix-ibx)*bnd.ntap+(ibz-iz)]; - } - } - } - /* left top corner */ - if (bnd.lef==4) { - ixo = mod.ioZx-bnd.ntap; - ixe = mod.ioZx; - ibz = (bnd.ntap+izo-1); - ibx = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1] + - txz[(ix+1)*n1+iz] - txz[ix*n1+iz]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2] + - txz[(ix+2)*n1+iz] - txz[(ix-1)*n1+iz]) ); - - vz[ix*n1+iz] *= bnd.tapxz[(ibx-ix)*bnd.ntap+(ibz-iz)]; - } - } - } - - - } /* end elastic scheme */ - } - - /*********/ - /* Bottom */ - /*********/ - if (bnd.bot==4) { - - if (mod.ischeme <= 2) { /* Acoustic scheme */ - - /* Vx field */ - ixo = mod.ioXx; - ixe = mod.ieXx; -// if (bnd.lef==4) ixo -= bnd.ntap; -// if (bnd.rig==4) ixe += bnd.ntap; - izo = mod.ieXz; - ize = mod.ieXz+bnd.ntap; - - ib = (ize-bnd.ntap); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[(ix-1)*n1+iz]) + - c2*(tzz[(ix+1)*n1+iz] - tzz[(ix-2)*n1+iz])); - vx[ix*n1+iz] *= bnd.tapx[iz-ib]; - } - } - /* right bottom corner */ - if (bnd.rig==4) { - ixo = mod.ieXx; - ixe = ixo+bnd.ntap; - ibz = (izo); - ibx = (ixo); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[(ix-1)*n1+iz]) + - c2*(tzz[(ix+1)*n1+iz] - tzz[(ix-2)*n1+iz])); - - vx[ix*n1+iz] *= bnd.tapxz[(ix-ibx)*bnd.ntap+(iz-ibz)]; - } - } - } - /* left bottom corner */ - if (bnd.lef==4) { - ixo = mod.ioXx-bnd.ntap; - ixe = mod.ioXx; - ibz = (izo); - ibx = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[(ix-1)*n1+iz]) + - c2*(tzz[(ix+1)*n1+iz] - tzz[(ix-2)*n1+iz])); - - vx[ix*n1+iz] *= bnd.tapxz[(ibx-ix)*bnd.ntap+(iz-ibz)]; - } - } - } - - - /* Vz field */ - ixo = mod.ioZx; - ixe = mod.ieZx; -// if (bnd.lef==4) ixo -= bnd.ntap; -// if (bnd.rig==4) ixe += bnd.ntap; - izo = mod.ieZz; - ize = mod.ieZz+bnd.ntap; - - ib = (ize-bnd.ntap); -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2])); - vz[ix*n1+iz] *= bnd.tapz[iz-ib]; - } - } - /* right bottom corner */ - if (bnd.rig==4) { - ixo = mod.ieZx; - ixe = ixo+bnd.ntap; - ibz = (izo); - ibx = (ixo); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2])); - - vz[ix*n1+iz] *= bnd.tapxz[(ix-ibx)*bnd.ntap+(iz-ibz)]; - } - } - } - /* left bottom corner */ - if (bnd.lef==4) { - ixo = mod.ioZx-bnd.ntap; - ixe = mod.ioZx; - ibz = (izo); - ibx = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2])); - - vz[ix*n1+iz] *= bnd.tapxz[(ibx-ix)*bnd.ntap+(iz-ibz)]; - } - } - } - - - } - else { /* Elastic scheme */ - - /* Vx field */ - ixo = mod.ioXx; - ixe = mod.ieXx; -// if (bnd.lef==4) ixo -= bnd.ntap; -// if (bnd.rig==4) ixe += bnd.ntap; - izo = mod.ieXz; - ize = mod.ieXz+bnd.ntap; - - ib = (ize-bnd.ntap); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(txx[ix*n1+iz] - txx[(ix-1)*n1+iz] + - txz[ix*n1+iz+1] - txz[ix*n1+iz]) + - c2*(txx[(ix+1)*n1+iz] - txx[(ix-2)*n1+iz] + - txz[ix*n1+iz+2] - txz[ix*n1+iz-1]) ); - - vx[ix*n1+iz] *= bnd.tapx[iz-ib]; - } - } - /* right bottom corner */ - if (bnd.rig==4) { - ixo = mod.ieXx; - ixe = ixo+bnd.ntap; - ibz = (izo); - ibx = (ixo); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(txx[ix*n1+iz] - txx[(ix-1)*n1+iz] + - txz[ix*n1+iz+1] - txz[ix*n1+iz]) + - c2*(txx[(ix+1)*n1+iz] - txx[(ix-2)*n1+iz] + - txz[ix*n1+iz+2] - txz[ix*n1+iz-1]) ); - - vx[ix*n1+iz] *= bnd.tapxz[(ix-ibx)*bnd.ntap+(iz-ibz)]; - } - } - } - /* left bottom corner */ - if (bnd.lef==4) { - ixo = mod.ioXx-bnd.ntap; - ixe = mod.ioXx; - ibz = (izo); - ibx = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(txx[ix*n1+iz] - txx[(ix-1)*n1+iz] + - txz[ix*n1+iz+1] - txz[ix*n1+iz]) + - c2*(txx[(ix+1)*n1+iz] - txx[(ix-2)*n1+iz] + - txz[ix*n1+iz+2] - txz[ix*n1+iz-1]) ); - - vx[ix*n1+iz] *= bnd.tapxz[(ibx-ix)*bnd.ntap+(iz-ibz)]; - } - } - } - - /* Vz field */ - ixo = mod.ioZx; - ixe = mod.ieZx; -// if (bnd.lef==4) ixo -= bnd.ntap; -// if (bnd.rig==4) ixe += bnd.ntap; - izo = mod.ieZz; - ize = mod.ieZz+bnd.ntap; - - ib = (ize-bnd.ntap); -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1] + - txz[(ix+1)*n1+iz] - txz[ix*n1+iz]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2] + - txz[(ix+2)*n1+iz] - txz[(ix-1)*n1+iz]) ); - - vz[ix*n1+iz] *= bnd.tapz[iz-ib]; - } - } - /* right bottom corner */ - if (bnd.rig==4) { - ixo = mod.ieZx; - ixe = ixo+bnd.ntap; - ibz = (izo); - ibx = (ixo); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1] + - txz[(ix+1)*n1+iz] - txz[ix*n1+iz]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2] + - txz[(ix+2)*n1+iz] - txz[(ix-1)*n1+iz]) ); - - vz[ix*n1+iz] *= bnd.tapxz[(ix-ibx)*bnd.ntap+(iz-ibz)]; - } - } - } - /* left bottom corner */ - if (bnd.lef==4) { - ixo = mod.ioZx-bnd.ntap; - ixe = mod.ioZx; - ibz = (izo); - ibx = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1] + - txz[(ix+1)*n1+iz] - txz[ix*n1+iz]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2] + - txz[(ix+2)*n1+iz] - txz[(ix-1)*n1+iz]) ); - - vz[ix*n1+iz] *= bnd.tapxz[(ibx-ix)*bnd.ntap+(iz-ibz)]; - } - } - } - - - } /* end elastic scheme */ - - } - - /*********/ - /* Left */ - /*********/ - if (bnd.lef==4) { - - if (mod.ischeme <= 2) { /* Acoustic scheme */ - - /* Vx field */ - ixo = mod.ioXx-bnd.ntap; - ixe = mod.ioXx; - izo = mod.ioXz; - ize = mod.ieXz; - - ib = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[(ix-1)*n1+iz]) + - c2*(tzz[(ix+1)*n1+iz] - tzz[(ix-2)*n1+iz])); - - vx[ix*n1+iz] *= bnd.tapx[ib-ix]; - } - } - - /* Vz field */ - ixo = mod.ioZx-bnd.ntap; - ixe = mod.ioZx; - izo = mod.ioZz; - ize = mod.ieZz; - - ib = (bnd.ntap+ixo-1); -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2])); - - vz[ix*n1+iz] *= bnd.tapz[ib-ix]; - } - } - - } - else { /* Elastic scheme */ - - /* Vx field */ - ixo = mod.ioXx-bnd.ntap; - ixe = mod.ioXx; - izo = mod.ioXz; - ize = mod.ieXz; - - ib = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(txx[ix*n1+iz] - txx[(ix-1)*n1+iz] + - txz[ix*n1+iz+1] - txz[ix*n1+iz]) + - c2*(txx[(ix+1)*n1+iz] - txx[(ix-2)*n1+iz] + - txz[ix*n1+iz+2] - txz[ix*n1+iz-1]) ); - - vx[ix*n1+iz] *= bnd.tapx[ib-ix]; - } - } - - /* Vz field */ - ixo = mod.ioZx-bnd.ntap; - ixe = mod.ioZx; - izo = mod.ioZz; - ize = mod.ieZz; - - ib = (bnd.ntap+ixo-1); -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1] + - txz[(ix+1)*n1+iz] - txz[ix*n1+iz]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2] + - txz[(ix+2)*n1+iz] - txz[(ix-1)*n1+iz]) ); - - vz[ix*n1+iz] *= bnd.tapz[ib-ix]; - } - } - } /* end elastic scheme */ - - } - - /*********/ - /* Right */ - /*********/ - if (bnd.rig==4) { - - if (mod.ischeme <= 2) { /* Acoustic scheme */ - - /* Vx field */ - ixo = mod.ieXx; - ixe = mod.ieXx+bnd.ntap; - izo = mod.ioXz; - ize = mod.ieXz; - - ib = (ixe-bnd.ntap); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[(ix-1)*n1+iz]) + - c2*(tzz[(ix+1)*n1+iz] - tzz[(ix-2)*n1+iz])); - - vx[ix*n1+iz] *= bnd.tapx[ix-ib]; - } - } - - /* Vz field */ - ixo = mod.ieZx; - ixe = mod.ieZx+bnd.ntap; - izo = mod.ioZz; - ize = mod.ieZz; - - ib = (ixe-bnd.ntap); -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2])); - - vz[ix*n1+iz] *= bnd.tapz[ix-ib]; - } - } - - } - else { /* Elastic scheme */ - - /* Vx field */ - ixo = mod.ieXx; - ixe = mod.ieXx+bnd.ntap; - izo = mod.ioXz; - ize = mod.ieXz; - - ib = (ixe-bnd.ntap); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(txx[ix*n1+iz] - txx[(ix-1)*n1+iz] + - txz[ix*n1+iz+1] - txz[ix*n1+iz]) + - c2*(txx[(ix+1)*n1+iz] - txx[(ix-2)*n1+iz] + - txz[ix*n1+iz+2] - txz[ix*n1+iz-1]) ); - - vx[ix*n1+iz] *= bnd.tapx[ix-ib]; - } - } - - /* Vz field */ - ixo = mod.ieZx; - ixe = mod.ieZx+bnd.ntap; - izo = mod.ioZz; - ize = mod.ieZz; - - ib = (ixe-bnd.ntap); -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1] + - txz[(ix+1)*n1+iz] - txz[ix*n1+iz]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2] + - txz[(ix+2)*n1+iz] - txz[(ix-1)*n1+iz]) ); - - vz[ix*n1+iz] *= bnd.tapz[ix-ib]; - } - } - - } /* end elastic scheme */ - - } - - - return 0; -} - -int boundariesV(modPar mod, bndPar bnd, float *vx, float *vz, float *tzz, float *txx, float *txz, float *rox, float *roz, float *l2m, float *lam, float *mul, int verbose) -{ -/********************************************************************* - - AUTHOR: - Jan Thorbecke (janth@xs4all.nl) - The Netherlands - -***********************************************************************/ - - float c1, c2; - float dp, dvx, dvz; - int ix, iz, ixs, izs, izp; - int nx, nz, n1; - int is0, isrc; - int ixo, ixe, izo, ize; - - c1 = 9.0/8.0; - c2 = -1.0/24.0; - nx = mod.nx; - nz = mod.nz; - n1 = mod.naz; - -/************************************************************/ -/* Tapered boundaries for both elastic and acoustic schemes */ -/* compute all field values in tapered areas */ -/************************************************************/ - - /*********/ - /* Top */ - /*********/ - if (bnd.top==4) { - - if (mod.ischeme <= 2) { /* Acoustic scheme */ - - /* P field */ - ixo = mod.ioPx; - ixe = mod.iePx; - if (bnd.lef==4) ixo -= bnd.ntap; - if (bnd.rig==4) ixe += bnd.ntap; - izo = mod.ioPz-bnd.ntap; - ize = mod.ioPz; - -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - tzz[ix*n1+iz] -= l2m[ix*n1+iz]*( - c1*(vx[(ix+1)*n1+iz] - vx[ix*n1+iz]) + - c2*(vx[(ix+2)*n1+iz] - vx[(ix-1)*n1+iz]) + - c1*(vz[ix*n1+iz+1] - vz[ix*n1+iz]) + - c2*(vz[ix*n1+iz+2] - vz[ix*n1+iz-1])); - } - } - } - else { /* Elastic scheme */ - - /* Txx Tzz field */ - ixo = mod.ioPx; - ixe = mod.iePx; - if (bnd.lef==4) ixo -= bnd.ntap; - if (bnd.rig==4) ixe += bnd.ntap; - izo = mod.ioPz-bnd.ntap; - ize = mod.ioPz; - -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - dvx = c1*(vx[(ix+1)*n1+iz] - vx[ix*n1+iz]) + - c2*(vx[(ix+2)*n1+iz] - vx[(ix-1)*n1+iz]); - dvz = c1*(vz[ix*n1+iz+1] - vz[ix*n1+iz]) + - c2*(vz[ix*n1+iz+2] - vz[ix*n1+iz-1]); - txx[ix*n1+iz] -= l2m[ix*n1+iz]*dvx + lam[ix*n1+iz]*dvz; - tzz[ix*n1+iz] -= l2m[ix*n1+iz]*dvz + lam[ix*n1+iz]*dvx; - } - } - - /* Txz field */ - ixo = mod.ioTx; - ixe = mod.ieTx; - if (bnd.lef==4) ixo -= bnd.ntap; - if (bnd.rig==4) ixe += bnd.ntap; - izo = mod.ioTz-bnd.ntap; - ize = mod.ioTz; - -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - txz[ix*n1+iz] -= mul[ix*n1+iz]*( - c1*(vx[ix*n1+iz] - vx[ix*n1+iz-1] + - vz[ix*n1+iz] - vz[(ix-1)*n1+iz]) + - c2*(vx[ix*n1+iz+1] - vx[ix*n1+iz-2] + - vz[(ix+1)*n1+iz] - vz[(ix-2)*n1+iz]) ); - } - } - } /* end elastic scheme */ - } - - /*********/ - /* Bottom */ - /*********/ - if (bnd.bot==4) { - - if (mod.ischeme <= 2) { /* Acoustic scheme */ - - /* P field */ - ixo = mod.ioPx; - ixe = mod.iePx; - if (bnd.lef==4) ixo -= bnd.ntap; - if (bnd.rig==4) ixe += bnd.ntap; - izo = mod.iePz; - ize = mod.iePz+bnd.ntap; - -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - tzz[ix*n1+iz] -= l2m[ix*n1+iz]*( - c1*(vx[(ix+1)*n1+iz] - vx[ix*n1+iz]) + - c2*(vx[(ix+2)*n1+iz] - vx[(ix-1)*n1+iz]) + - c1*(vz[ix*n1+iz+1] - vz[ix*n1+iz]) + - c2*(vz[ix*n1+iz+2] - vz[ix*n1+iz-1])); - } - } - } - else { /* Elastic scheme */ - - /* Txx Tzz field */ - ixo = mod.ioPx; - ixe = mod.iePx; - if (bnd.lef==4) ixo -= bnd.ntap; - if (bnd.rig==4) ixe += bnd.ntap; - izo = mod.iePz; - ize = mod.iePz+bnd.ntap; - -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - dvx = c1*(vx[(ix+1)*n1+iz] - vx[ix*n1+iz]) + - c2*(vx[(ix+2)*n1+iz] - vx[(ix-1)*n1+iz]); - dvz = c1*(vz[ix*n1+iz+1] - vz[ix*n1+iz]) + - c2*(vz[ix*n1+iz+2] - vz[ix*n1+iz-1]); - txx[ix*n1+iz] -= l2m[ix*n1+iz]*dvx + lam[ix*n1+iz]*dvz; - tzz[ix*n1+iz] -= l2m[ix*n1+iz]*dvz + lam[ix*n1+iz]*dvx; - } - } - - /* Txz field */ - ixo = mod.ioTx; - ixe = mod.ieTx; - if (bnd.lef==4) ixo -= bnd.ntap; - if (bnd.rig==4) ixe += bnd.ntap; - izo = mod.ieTz; - ize = mod.ieTz+bnd.ntap; - -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - txz[ix*n1+iz] -= mul[ix*n1+iz]*( - c1*(vx[ix*n1+iz] - vx[ix*n1+iz-1] + - vz[ix*n1+iz] - vz[(ix-1)*n1+iz]) + - c2*(vx[ix*n1+iz+1] - vx[ix*n1+iz-2] + - vz[(ix+1)*n1+iz] - vz[(ix-2)*n1+iz]) ); - } - } - } /* end elastic scheme */ - - } - - /*********/ - /* Left */ - /*********/ - if (bnd.lef==4) { - - if (mod.ischeme <= 2) { /* Acoustic scheme */ - - /* P field */ - ixo = mod.ioPx-bnd.ntap; - ixe = mod.ioPx; - izo = mod.ioPz; - ize = mod.iePz; - -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - tzz[ix*n1+iz] -= l2m[ix*n1+iz]*( - c1*(vx[(ix+1)*n1+iz] - vx[ix*n1+iz]) + - c2*(vx[(ix+2)*n1+iz] - vx[(ix-1)*n1+iz]) + - c1*(vz[ix*n1+iz+1] - vz[ix*n1+iz]) + - c2*(vz[ix*n1+iz+2] - vz[ix*n1+iz-1])); - } - } - } - else { /* Elastic scheme */ - - /* Txx Tzz field */ - ixo = mod.ioPx-bnd.ntap; - ixe = mod.ioPx; - izo = mod.ioPz; - ize = mod.iePz; - -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - dvx = c1*(vx[(ix+1)*n1+iz] - vx[ix*n1+iz]) + - c2*(vx[(ix+2)*n1+iz] - vx[(ix-1)*n1+iz]); - dvz = c1*(vz[ix*n1+iz+1] - vz[ix*n1+iz]) + - c2*(vz[ix*n1+iz+2] - vz[ix*n1+iz-1]); - txx[ix*n1+iz] -= l2m[ix*n1+iz]*dvx + lam[ix*n1+iz]*dvz; - tzz[ix*n1+iz] -= l2m[ix*n1+iz]*dvz + lam[ix*n1+iz]*dvx; - } - } - - /* Txz field */ - ixo = mod.ioTx-bnd.ntap; - ixe = mod.ioTx; - izo = mod.ioTz; - ize = mod.ieTz; - -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - txz[ix*n1+iz] -= mul[ix*n1+iz]*( - c1*(vx[ix*n1+iz] - vx[ix*n1+iz-1] + - vz[ix*n1+iz] - vz[(ix-1)*n1+iz]) + - c2*(vx[ix*n1+iz+1] - vx[ix*n1+iz-2] + - vz[(ix+1)*n1+iz] - vz[(ix-2)*n1+iz]) ); - } - } - } /* end elastic scheme */ - - } - - /*********/ - /* Right */ - /*********/ - if (bnd.rig==4) { - - if (mod.ischeme <= 2) { /* Acoustic scheme */ - - /* P field */ - ixo = mod.iePx; - ixe = mod.iePx+bnd.ntap; - izo = mod.ioPz; - ize = mod.iePz; - -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - tzz[ix*n1+iz] -= l2m[ix*n1+iz]*( - c1*(vx[(ix+1)*n1+iz] - vx[ix*n1+iz]) + - c2*(vx[(ix+2)*n1+iz] - vx[(ix-1)*n1+iz]) + - c1*(vz[ix*n1+iz+1] - vz[ix*n1+iz]) + - c2*(vz[ix*n1+iz+2] - vz[ix*n1+iz-1])); - } - } - } - else { /* Elastic scheme */ - - /* Txx Tzz field */ - ixo = mod.iePx; - ixe = mod.iePx+bnd.ntap; - izo = mod.ioPz; - ize = mod.iePz; - -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - dvx = c1*(vx[(ix+1)*n1+iz] - vx[ix*n1+iz]) + - c2*(vx[(ix+2)*n1+iz] - vx[(ix-1)*n1+iz]); - dvz = c1*(vz[ix*n1+iz+1] - vz[ix*n1+iz]) + - c2*(vz[ix*n1+iz+2] - vz[ix*n1+iz-1]); - txx[ix*n1+iz] -= l2m[ix*n1+iz]*dvx + lam[ix*n1+iz]*dvz; - tzz[ix*n1+iz] -= l2m[ix*n1+iz]*dvz + lam[ix*n1+iz]*dvx; - } - } - - /* Txz field */ - ixo = mod.ieTx; - ixe = mod.ieTx+bnd.ntap; - izo = mod.ioTz; - ize = mod.ieTz; - -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - txz[ix*n1+iz] -= mul[ix*n1+iz]*( - c1*(vx[ix*n1+iz] - vx[ix*n1+iz-1] + - vz[ix*n1+iz] - vz[(ix-1)*n1+iz]) + - c2*(vx[ix*n1+iz+1] - vx[ix*n1+iz-2] + - vz[(ix+1)*n1+iz] - vz[(ix-2)*n1+iz]) ); - } - } - } /* end elastic scheme */ - - } - - /****************/ - /* Free surface */ - - ixo = mod.ioPx; - ixe = mod.iePx; - if (bnd.lef==4) ixo -= bnd.ntap; - if (bnd.rig==4) ixe += bnd.ntap; - izo = mod.ioPz; - ize = mod.iePz; - if (bnd.top==4) izo -= bnd.ntap; - if (bnd.bot==4) ize += bnd.ntap; - - if (mod.ischeme <= 2) { /* Acoustic scheme */ - - if (bnd.top==1) { /* free surface at top */ -#pragma omp for private (ix) nowait - for (ix=ixo; ix<ixe; ix++) { - iz = bnd.surface[ix]; - tzz[ix*n1+iz] = 0.0; - } - } - if (bnd.rig==1) { /* free surface at right */ -#pragma omp for private (iz) nowait - for (iz=izo; iz<ize; iz++) { - tzz[ixe*n1+iz] = 0.0; - } - } - if (bnd.bot==1) { /* free surface at bottom */ -#pragma omp for private (ix) nowait - for (ix=ixo; ix<ixe; ix++) { - tzz[ix*n1+ize] = 0.0; - } - } - if (bnd.lef==1) { /* free surface at left */ -#pragma omp for private (iz) nowait - for (iz=izo; iz<ize; iz++) { - tzz[ixo*n1+iz] = 0.0; - } - } - } - else { /* Elastic scheme */ - - /* Free surface: calculate free surface conditions for stresses - * Conditions (for upper boundary): - * 1. Tzz = 0 - * 2. Txz = 0 - * 3. Txx: remove term with dVz/dz, computed in e2/e4 routines - * and add extra term with dVx/dx, - * corresponding to free-surface condition for Txx. - * In this way, dVz/dz is not needed in computing Txx - * on the upper stress free boundary. Other boundaries - * are treated similar. - * For the 4th order schemes, the whole virtual boundary - * must be taken into account in the removal terms, - * because the algorithm sets - * velocities on this boundary! - * - * Compute the velocities on the virtual boundary to make interpolation - * possible for receivers. - */ - - if (bnd.top==1) { /* free surface at top */ - izp = bnd.surface[ixo]; -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { - iz = bnd.surface[ix-1]; - if ( izp==iz ) { - /* clear normal pressure */ - tzz[ix*n1+iz] = 0.0; - /* This update to Vz might become unstable (2nd order scheme) */ -// vz[ix*n1+iz] = vz[ix*n1+iz+1] - (vx[(ix+1)*n1+iz]-vx[ix*n1+iz])* -// lam[ix*n1+iz]/l2m[ix*n1+iz]; - } - izp=iz; - } - - izp = bnd.surface[ixo]; -#pragma omp for private (ix, iz) - for (ix=ixo+1; ix<ixe+1; ix++) { - iz = bnd.surface[ix-1]; - if ( izp==iz ) { - /* assure that txz=0 on boundary by filling virtual boundary */ - txz[ix*n1+iz] = -txz[ix*n1+iz+1]; - /* extra line of txz has to be copied */ - txz[ix*n1+iz-1] = -txz[ix*n1+iz+2]; - } - izp=iz; - } - - /* calculate txx on top stress-free boundary */ - izp = bnd.surface[ixo]; -#pragma omp for private (ix, iz, dp, dvx) - for (ix=ixo; ix<ixe; ix++) { - iz = bnd.surface[ix-1]; - if ( izp==iz ) { - dp = l2m[ix*n1+iz]-lam[ix*n1+iz]*lam[ix*n1+iz]/l2m[ix*n1+iz]; - dvx = c1*(vx[(ix+1)*n1+iz] - vx[(ix)*n1+iz]) + - c2*(vx[(ix+2)*n1+iz] - vx[(ix-1)*n1+iz]); - txx[ix*n1+iz] = -dvx*dp; - } - izp=iz; - } - - - /* if surface has also left or right edges */ - izp = bnd.surface[ixo]; -#pragma omp for private (ix, iz, dp, dvz) - for (ix=ixo+1; ix<ixe; ix++) { - iz = bnd.surface[ix-1]; - if ( izp < iz ) { /* right boundary */ -// fprintf(stderr,"right boundary\n"); - /* clear normal pressure */ - txx[ix*n1+iz] = 0.0; - if ( (iz-izp) >= 2 ) { /* VR point */ - /* assure that txz=0 on boundary */ - txz[(ix+1)*n1+iz] = -txz[ix*n1+iz]; - txz[(ix+2)*n1+iz] = -txz[(ix-1)*n1+iz] ; - /* calculate tzz on right stress-free boundary */ - dvz = c1*(vz[ix*n1+iz+1] - vz[ix*n1+iz]) + - c2*(vz[ix*n1+iz+2] - vz[ix*n1+iz-1]); - dp = l2m[ix*n1+iz]-lam[ix*n1+iz]*lam[ix*n1+iz]/l2m[ix*n1+iz]; - tzz[ix*n1+iz] = -dvz*dp; - } - else { - // if (izp) { /* IR point */ - // txz[ix*n1+iz] = -txz[ix*n1+iz+1] ; - // txz[ix*n1+iz-1] = -txz[ix*n1+iz+2]; - txz[(ix+1)*n1+iz] = -txz[ix*n1+iz]; - txz[(ix+2)*n1+iz] = -txz[(ix-1)*n1+iz] ; - tzz[ix*n1+iz] = 0.0; - // } - // else { /* OR point */ - txz[(ix-1)*n1+iz] = 0.0; - txz[(ix+1)*n1+iz] = -txz[ix*n1+iz]; - txz[(ix+2)*n1+iz] = -txz[(ix-1)*n1+iz] ; - vz[ix*n1+iz] = vz[ix*n1+iz+1] - (vx[(ix+1)*n1+iz]-vx[ix*n1+iz])* - lam[ix*n1+iz]/l2m[ix*n1+iz]; - // } - } - - } /* end if right */ - if ( izp > iz ) { /* left boundary */ -// fprintf(stderr,"left boundary\n"); - /* clear normal pressure */ - txx[ix*n1+iz] = 0.0; - /* assure that txz=0 on boundary */ - txz[(ix-1)*n1+iz] = -txz[ix*n1+iz]; - /* extra line of txz has to be copied */ - txz[(ix-2)*n1+iz] = -txz[(ix+1)*n1+iz] ; - /* calculate tzz on left stress-free boundary */ - dvz = c1*(vz[ix*n1+iz+1] - vz[ix*n1+iz]) + - c2*(vz[ix*n1+iz+2] - vz[ix*n1+iz-1]); - dp = l2m[ix*n1+iz]-lam[ix*n1+iz]*lam[ix*n1+iz]/l2m[ix*n1+iz]; - tzz[ix*n1+iz] = -dvz*dp; - } /* end if left */ - izp=iz; - // izp=bnd.surface[MAX(ix-2,0)];; - } /* end ix loop */ - } - - /* when all boundaries are rigid then the behaviour of left top - is different than right bottom. This is not yet solved */ - - if (bnd.rig==1) { /* free surface at right */ - ix = ixe-1; -#pragma omp for private (ix, iz) - for (iz=izo; iz<ize; iz++) { - /* clear normal pressure */ - txx[(ix)*n1+iz] = 0.0; - } - ix = ixe-1; -#pragma omp for private (ix, iz) - for (iz=izo+1; iz<ize+1; iz++) { - /* assure that txz=0 on boundary by filling virtual boundary */ - txz[(ix)*n1+iz] = -txz[(ix-1)*n1+iz]; - /* extra line of txz has to be copied */ - txz[(ix+1)*n1+iz] = -txz[(ix-2)*n1+iz] ; - } - /* calculate tzz on right stress-free boundary */ - ix = ixe-1; -#pragma omp for private (iz) - for (iz=izo; iz<ize; iz++) { - dvz = c1*(vz[ix*n1+iz+1] - vz[ix*n1+iz]) + - c2*(vz[ix*n1+iz+2] - vz[ix*n1+iz-1]); - dp = l2m[(ix)*n1+iz]-lam[(ix)*n1+iz]*lam[(ix)*n1+iz]/l2m[(ix)*n1+iz]; - tzz[(ix)*n1+iz] = -dvz*dp; - } - /* - if (bnd.top==1) { - iz = izo; - tzz[ix*n1+iz] = 0.0; - txx[ix*n1+iz] = 0.0; - - // assure that txz=0 on boundary by filling virtual boundary - txz[ix*n1+iz] = -txz[(ix-1)*n1+iz+1]; - txz[ix*n1+iz+1] = -txz[(ix-1)*n1+iz+1]; - txz[(ix-1)*n1+iz] = -txz[(ix-1)*n1+iz+1]; - // extra line of txz has to be copied - txz[(ix+1)*n1+iz+1] = -txz[(ix-2)*n1+iz+1]; - txz[(ix-1)*n1+iz-1] = -txz[(ix-1)*n1+iz+2]; - txz[(ix)*n1+iz-1] = -txz[(ix-1)*n1+iz+2]; - txz[(ix+1)*n1+iz] = -txz[(ix-2)*n1+iz+1]; - txz[(ix+1)*n1+iz-1] = -txz[(ix-2)*n1+iz+2]; - - dp = l2m[ix*n1+iz]-lam[ix*n1+iz]*lam[ix*n1+iz]/l2m[ix*n1+iz]; - dvx = c1*(vx[(ix+1)*n1+iz] - vx[(ix)*n1+iz]) + - c2*(vx[(ix+2)*n1+iz] - vx[(ix-1)*n1+iz]); - txx[ix*n1+iz] = -dvx*dp; - - dvz = c1*(vz[ix*n1+iz+1] - vz[ix*n1+iz]) + - c2*(vz[ix*n1+iz+2] - vz[ix*n1+iz-1]); - dp = l2m[(ix)*n1+iz]-lam[(ix)*n1+iz]*lam[(ix)*n1+iz]/l2m[(ix)*n1+iz]; - tzz[(ix)*n1+iz] = -dvz*dp; - } - - if (bnd.bot==1) { - iz = ize-1; - tzz[ix*n1+iz] = 0.0; - - // assure that txz=0 on boundary by filling virtual boundary - txz[ix*n1+iz] = -txz[ix*n1+iz+1]; - // extra line of txz has to be copied - txz[ix*n1+iz-1] = -txz[ix*n1+iz+2]; - - dp = l2m[ix*n1+iz]-lam[ix*n1+iz]*lam[ix*n1+iz]/l2m[ix*n1+iz]; - dvx = c1*(vx[(ix+1)*n1+iz] - vx[(ix)*n1+iz]) + - c2*(vx[(ix+2)*n1+iz] - vx[(ix-1)*n1+iz]); - txx[ix*n1+iz] = -dvx*dp; - } - */ - - } - - if (bnd.bot==1) { /* free surface at bottom */ - iz = ize-1; -#pragma omp for private (ix) - for (ix=ixo; ix<ixe; ix++) { - /* clear normal pressure */ - tzz[ix*n1+iz] = 0.0; - } -#pragma omp for private (ix) - iz = ize; - for (ix=ixo+1; ix<ixe+1; ix++) { - /* assure that txz=0 on boundary by filling virtual boundary */ - txz[ix*n1+iz] = -txz[ix*n1+iz-1]; - /* extra line of txz has to be copied */ - txz[ix*n1+iz+1] = -txz[ix*n1+iz-2]; - } - /* calculate txx on bottom stress-free boundary */ -#pragma omp for private (ix) - iz = ize-1; - for (ix=ixo; ix<ixe; ix++) { - dp = l2m[ix*n1+iz]-lam[ix*n1+iz]*lam[ix*n1+iz]/l2m[ix*n1+iz]; - dvx = c1*(vx[(ix+1)*n1+iz] - vx[ix*n1+iz]) + - c2*(vx[(ix+2)*n1+iz] - vx[(ix-1)*n1+iz]); - txx[ix*n1+iz] = -dvx*dp; - } - } - - if (bnd.lef==1) { /* free surface at left */ - ix = ixo; -#pragma omp for private (iz) - for (iz=izo; iz<ize; iz++) { - /* clear normal pressure */ - txx[ix*n1+iz] = 0.0; - } -#pragma omp for private (iz) - for (iz=izo+1; iz<ize+1; iz++) { - /* assure that txz=0 on boundary by filling virtual boundary */ - txz[(ix)*n1+iz] = -txz[(ix+1)*n1+iz]; - /* extra line of txz has to be copied */ - txz[(ix-1)*n1+iz] = -txz[(ix+2)*n1+iz] ; - } - /* calculate tzz on left stress-free boundary */ -#pragma omp for private (iz) - for (iz=izo; iz<ize; iz++) { - dvz = c1*(vz[ix*n1+iz+1] - vz[ix*n1+iz]) + - c2*(vz[ix*n1+iz+2] - vz[ix*n1+iz-1]); - dp = l2m[ix*n1+iz]-lam[ix*n1+iz]*lam[ix*n1+iz]/l2m[ix*n1+iz]; - tzz[ix*n1+iz] = -dvz*dp; - } - } -/* - fprintf(stderr,"ixo=%d ixe=%d\n", ixo, ixe);; - for (iz=0; iz<6; iz++) { - fprintf(stderr,"Top left z=%d: %e %e %e %e %e\n",iz,txz[0*n1+iz], txz[1*n1+iz], txz[2*n1+iz], txz[3*n1+iz], txz[4*n1+iz]); - fprintf(stderr,"Top right z=%d: %e %e %e %e %e\n",iz,txz[(ixe+2)*n1+iz], txz[(ixe+1)*n1+iz], txz[(ixe)*n1+iz], txz[(ixe-1)*n1+iz], txz[(ixe-2)*n1+iz]); - - } -*/ - ix = 201; - for (iz=0; iz<6; iz++) { - fprintf(stderr,"Top z=%d: %e %e %e %e %e\n",iz,txz[ix*n1+iz], txz[(ix+1)*n1+iz], txz[(ix+2)*n1+iz], txz[(ix+3)*n1+iz], txz[(ix+4)*n1+iz]); - } - for (iz=n1-1; iz>n1-7; iz--) { - fprintf(stderr,"Bottom z=%d: %e %e %e %e %e\n",iz,txz[ix*n1+iz], txz[(ix+1)*n1+iz], txz[(ix+2)*n1+iz], txz[(ix+3)*n1+iz], txz[(ix+4)*n1+iz]); - - } - - - } - - - - - return 0; -} - - diff --git a/fdelmodc/boundaries.c.ok b/fdelmodc/boundaries.c.ok deleted file mode 100644 index 673823cfb59c67a7ffe07e27199b7f7e315d0db3..0000000000000000000000000000000000000000 --- a/fdelmodc/boundaries.c.ok +++ /dev/null @@ -1,1364 +0,0 @@ -#include<stdlib.h> -#include<stdio.h> -#include<math.h> -#include<assert.h> -#include"fdelmodc.h" - -float *exL, *exR, *eyT, *eyB; -int first=0; - -int boundariesP(modPar mod, bndPar bnd, float *vx, float *vz, float *tzz, float *txx, float *txz, float *rox, float *roz, float *l2m, float *lam, float *mul, int verbose) -{ -/********************************************************************* - - AUTHOR: - Jan Thorbecke (janth@xs4all.nl) - The Netherlands - -***********************************************************************/ - - float c1, c2; - float dp, dvx, dvz; - int ix, iz, ixs, izs, ibnd, ib, ibx, ibz; - int nx, nz, n1; - int is0, isrc, ioXx, ioXz, ioZz, ioZx, ioPx, ioPz, ioTx, ioTz; - int ixo, ixe, izo, ize; - - - c1 = 9.0/8.0; - c2 = -1.0/24.0; - nx = mod.nx; - nz = mod.nz; - n1 = mod.naz; - - ibnd = mod.iorder/2-1; - /* Vx: rox */ - ioXx=mod.ioXx; - ioXz=mod.ioXz; - /* Vz: roz */ - ioZz=mod.ioZz; - ioZx=mod.ioZz; - /* P, Txx, Tzz: lam, l2m */ - ioPx=mod.ioPx; - ioPz=mod.ioPz; - /* Txz: muu */ - ioTx=mod.ioTx; - ioTz=mod.ioTz; - -/************************************************************/ -/* rigid boundary condition clears velocities on boundaries */ -/************************************************************/ - - if (bnd.top==3) { /* rigid surface at top */ -#pragma omp for private (ix, iz) nowait -#pragma ivdep - for (ix=1; ix<=nx; ix++) { - vx[ix*n1+ibnd] = 0.0; - vz[ix*n1+ibnd] = -vz[ix*n1+ibnd+1]; - if (mod.iorder >= 4) vz[ix*n1+ibnd-1] = -vz[ix*n1+ibnd+2]; - if (mod.iorder >= 6) vz[ix*n1+ibnd-2] = -vz[ix*n1+ibnd+3]; - } - } - if (bnd.rig==3) { /* rigid surface at right */ -#pragma omp for private (ix, iz) nowait -#pragma ivdep - for (iz=1; iz<=nz; iz++) { - vz[(nx+ibnd-1)*n1+iz] = 0.0; - vx[(nx+ibnd)*n1+iz] = -vx[(nx+ibnd-1)*n1+iz]; - if (mod.iorder == 4) vx[(nx+2)*n1+iz] = -vx[(nx-1)*n1+iz]; - if (mod.iorder == 6) { - vx[(nx+1)*n1+iz] = -vx[(nx)*n1+iz]; - vx[(nx+3)*n1+iz] = -vx[(nx-2)*n1+iz]; - } - } - } - if (bnd.bot==3) { /* rigid surface at bottom */ -#pragma omp for private (ix, iz) nowait -#pragma ivdep - for (ix=1; ix<=nx; ix++) { - vx[ix*n1+nz+ibnd-1] = 0.0; - vz[ix*n1+nz+ibnd] = -vz[ix*n1+nz+ibnd-1]; - if (mod.iorder == 4) vz[ix*n1+nz+2] = -vz[ix*n1+nz-1]; - if (mod.iorder == 6) { - vz[ix*n1+nz+1] = -vz[ix*n1+nz]; - vz[ix*n1+nz+3] = -vz[ix*n1+nz-2]; - } - } - } - if (bnd.lef==3) { /* rigid surface at left */ -#pragma omp for private (ix, iz) nowait -#pragma ivdep - for (iz=1; iz<=nz; iz++) { - vz[ibnd*n1+iz] = 0.0; - vx[ibnd*n1+iz] = -vx[(ibnd+1)*n1+iz]; - if (mod.iorder == 4) vx[0*n1+iz] = -vx[3*n1+iz]; - if (mod.iorder == 6) { - vx[1*n1+iz] = -vx[4*n1+iz]; - vx[0*n1+iz] = -vx[5*n1+iz]; - } - } - } - -/************************************************************/ -/* PML boundaries : only for acoustic 4th order scheme */ -/************************************************************/ - - if (bnd.top==2) { /* PML at top */ - } - -/************************************************************/ -/* Tapered boundaries for both elastic and acoustic schemes */ -/* compute all field values in tapered areas */ -/************************************************************/ - - /*********/ - /* Top */ - /*********/ - if (bnd.top==4) { - - if (mod.ischeme <= 2) { /* Acoustic scheme */ - - /* Vx field */ - ixo = mod.ioXx; - ixe = mod.ieXx; -// if (bnd.lef==4) ixo -= bnd.ntap; -// if (bnd.rig==4) ixe += bnd.ntap; - izo = mod.ioXz-bnd.ntap; - ize = mod.ioXz; - - ib = (bnd.ntap+izo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[(ix-1)*n1+iz]) + - c2*(tzz[(ix+1)*n1+iz] - tzz[(ix-2)*n1+iz])); - - vx[ix*n1+iz] *= bnd.tapx[ib-iz]; - } - } - /* right top corner */ - if (bnd.rig==4) { - ixo = mod.ieXx; - ixe = ixo+bnd.ntap; - ibz = (bnd.ntap+izo-1); - ibx = (ixo); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[(ix-1)*n1+iz]) + - c2*(tzz[(ix+1)*n1+iz] - tzz[(ix-2)*n1+iz])); - - vx[ix*n1+iz] *= bnd.tapxz[(ix-ibx)*bnd.ntap+(ibz-iz)]; - } - } - } - /* left top corner */ - if (bnd.lef==4) { - ixo = mod.ioXx-bnd.ntap; - ixe = mod.ioXx; - ibz = (bnd.ntap+izo-1); - ibx = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[(ix-1)*n1+iz]) + - c2*(tzz[(ix+1)*n1+iz] - tzz[(ix-2)*n1+iz])); - - vx[ix*n1+iz] *= bnd.tapxz[(ibx-ix)*bnd.ntap+(ibz-iz)]; - } - } - } - - - /* Vz field */ - ixo = mod.ioZx; - ixe = mod.ieZx; -// if (bnd.lef==4) ixo -= bnd.ntap; -// if (bnd.rig==4) ixe += bnd.ntap; - izo = mod.ioZz-bnd.ntap; - ize = mod.ioZz; - - ib = (bnd.ntap+izo-1); -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2])); - - vz[ix*n1+iz] *= bnd.tapz[ib-iz]; - } - } - /* right top corner */ - if (bnd.rig==4) { - ixo = mod.ieZx; - ixe = ixo+bnd.ntap; - ibz = (bnd.ntap+izo-1); - ibx = (ixo); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2])); - - vz[ix*n1+iz] *= bnd.tapxz[(ix-ibx)*bnd.ntap+(ibz-iz)]; - } - } - } - /* left top corner */ - if (bnd.lef==4) { - ixo = mod.ioZx-bnd.ntap; - ixe = mod.ioZx; - ibz = (bnd.ntap+izo-1); - ibx = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2])); - - vz[ix*n1+iz] *= bnd.tapxz[(ibx-ix)*bnd.ntap+(ibz-iz)]; - } - } - } - - } - else { /* Elastic scheme */ - - /* Vx field */ - ixo = mod.ioXx; - ixe = mod.ieXx; -// if (bnd.lef==4) ixo -= bnd.ntap; -// if (bnd.rig==4) ixe += bnd.ntap; - izo = mod.ioXz-bnd.ntap; - ize = mod.ioXz; - - ib = (bnd.ntap+izo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(txx[ix*n1+iz] - txx[(ix-1)*n1+iz] + - txz[ix*n1+iz+1] - txz[ix*n1+iz]) + - c2*(txx[(ix+1)*n1+iz] - txx[(ix-2)*n1+iz] + - txz[ix*n1+iz+2] - txz[ix*n1+iz-1]) ); - - vx[ix*n1+iz] *= bnd.tapx[ib-iz]; - } - } - /* right top corner */ - if (bnd.rig==4) { - ixo = mod.ieXx; - ixe = ixo+bnd.ntap; - ibz = (bnd.ntap+izo-1); - ibx = (ixo); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(txx[ix*n1+iz] - txx[(ix-1)*n1+iz] + - txz[ix*n1+iz+1] - txz[ix*n1+iz]) + - c2*(txx[(ix+1)*n1+iz] - txx[(ix-2)*n1+iz] + - txz[ix*n1+iz+2] - txz[ix*n1+iz-1]) ); - - vx[ix*n1+iz] *= bnd.tapxz[(ix-ibx)*bnd.ntap+(ibz-iz)]; - } - } - } - /* left top corner */ - if (bnd.lef==4) { - ixo = mod.ioXx-bnd.ntap; - ixe = mod.ioXx; - ibz = (bnd.ntap+izo-1); - ibx = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(txx[ix*n1+iz] - txx[(ix-1)*n1+iz] + - txz[ix*n1+iz+1] - txz[ix*n1+iz]) + - c2*(txx[(ix+1)*n1+iz] - txx[(ix-2)*n1+iz] + - txz[ix*n1+iz+2] - txz[ix*n1+iz-1]) ); - - vx[ix*n1+iz] *= bnd.tapxz[(ibx-ix)*bnd.ntap+(ibz-iz)]; - } - } - } - - /* Vz field */ - ixo = mod.ioZx; - ixe = mod.ieZx; -// if (bnd.lef==4) ixo -= bnd.ntap; -// if (bnd.rig==4) ixe += bnd.ntap; - izo = mod.ioZz-bnd.ntap; - ize = mod.ioZz; - - ib = (bnd.ntap+izo-1); -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1] + - txz[(ix+1)*n1+iz] - txz[ix*n1+iz]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2] + - txz[(ix+2)*n1+iz] - txz[(ix-1)*n1+iz]) ); - - vz[ix*n1+iz] *= bnd.tapz[ib-iz]; - } - } - /* right top corner */ - if (bnd.rig==4) { - ixo = mod.ieZx; - ixe = ixo+bnd.ntap; - ibz = (bnd.ntap+izo-1); - ibx = (ixo); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1] + - txz[(ix+1)*n1+iz] - txz[ix*n1+iz]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2] + - txz[(ix+2)*n1+iz] - txz[(ix-1)*n1+iz]) ); - - vz[ix*n1+iz] *= bnd.tapxz[(ix-ibx)*bnd.ntap+(ibz-iz)]; - } - } - } - /* left top corner */ - if (bnd.lef==4) { - ixo = mod.ioZx-bnd.ntap; - ixe = mod.ioZx; - ibz = (bnd.ntap+izo-1); - ibx = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1] + - txz[(ix+1)*n1+iz] - txz[ix*n1+iz]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2] + - txz[(ix+2)*n1+iz] - txz[(ix-1)*n1+iz]) ); - - vz[ix*n1+iz] *= bnd.tapxz[(ibx-ix)*bnd.ntap+(ibz-iz)]; - } - } - } - - - } /* end elastic scheme */ - } - - /*********/ - /* Bottom */ - /*********/ - if (bnd.bot==4) { - - if (mod.ischeme <= 2) { /* Acoustic scheme */ - - /* Vx field */ - ixo = mod.ioXx; - ixe = mod.ieXx; -// if (bnd.lef==4) ixo -= bnd.ntap; -// if (bnd.rig==4) ixe += bnd.ntap; - izo = mod.ieXz; - ize = mod.ieXz+bnd.ntap; - - ib = (ize-bnd.ntap); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[(ix-1)*n1+iz]) + - c2*(tzz[(ix+1)*n1+iz] - tzz[(ix-2)*n1+iz])); - vx[ix*n1+iz] *= bnd.tapx[iz-ib]; - } - } - /* right bottom corner */ - if (bnd.rig==4) { - ixo = mod.ieXx; - ixe = ixo+bnd.ntap; - ibz = (izo); - ibx = (ixo); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[(ix-1)*n1+iz]) + - c2*(tzz[(ix+1)*n1+iz] - tzz[(ix-2)*n1+iz])); - - vx[ix*n1+iz] *= bnd.tapxz[(ix-ibx)*bnd.ntap+(iz-ibz)]; - } - } - } - /* left bottom corner */ - if (bnd.lef==4) { - ixo = mod.ioXx-bnd.ntap; - ixe = mod.ioXx; - ibz = (izo); - ibx = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[(ix-1)*n1+iz]) + - c2*(tzz[(ix+1)*n1+iz] - tzz[(ix-2)*n1+iz])); - - vx[ix*n1+iz] *= bnd.tapxz[(ibx-ix)*bnd.ntap+(iz-ibz)]; - } - } - } - - - /* Vz field */ - ixo = mod.ioZx; - ixe = mod.ieZx; -// if (bnd.lef==4) ixo -= bnd.ntap; -// if (bnd.rig==4) ixe += bnd.ntap; - izo = mod.ieZz; - ize = mod.ieZz+bnd.ntap; - - ib = (ize-bnd.ntap); -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2])); - vz[ix*n1+iz] *= bnd.tapz[iz-ib]; - } - } - /* right bottom corner */ - if (bnd.rig==4) { - ixo = mod.ieZx; - ixe = ixo+bnd.ntap; - ibz = (izo); - ibx = (ixo); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2])); - - vz[ix*n1+iz] *= bnd.tapxz[(ix-ibx)*bnd.ntap+(iz-ibz)]; - } - } - } - /* left bottom corner */ - if (bnd.lef==4) { - ixo = mod.ioZx-bnd.ntap; - ixe = mod.ioZx; - ibz = (izo); - ibx = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2])); - - vz[ix*n1+iz] *= bnd.tapxz[(ibx-ix)*bnd.ntap+(iz-ibz)]; - } - } - } - - - } - else { /* Elastic scheme */ - - /* Vx field */ - ixo = mod.ioXx; - ixe = mod.ieXx; -// if (bnd.lef==4) ixo -= bnd.ntap; -// if (bnd.rig==4) ixe += bnd.ntap; - izo = mod.ieXz; - ize = mod.ieXz+bnd.ntap; - - ib = (ize-bnd.ntap); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(txx[ix*n1+iz] - txx[(ix-1)*n1+iz] + - txz[ix*n1+iz+1] - txz[ix*n1+iz]) + - c2*(txx[(ix+1)*n1+iz] - txx[(ix-2)*n1+iz] + - txz[ix*n1+iz+2] - txz[ix*n1+iz-1]) ); - - vx[ix*n1+iz] *= bnd.tapx[iz-ib]; - } - } - /* right bottom corner */ - if (bnd.rig==4) { - ixo = mod.ieXx; - ixe = ixo+bnd.ntap; - ibz = (izo); - ibx = (ixo); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(txx[ix*n1+iz] - txx[(ix-1)*n1+iz] + - txz[ix*n1+iz+1] - txz[ix*n1+iz]) + - c2*(txx[(ix+1)*n1+iz] - txx[(ix-2)*n1+iz] + - txz[ix*n1+iz+2] - txz[ix*n1+iz-1]) ); - - vx[ix*n1+iz] *= bnd.tapxz[(ix-ibx)*bnd.ntap+(iz-ibz)]; - } - } - } - /* left bottom corner */ - if (bnd.lef==4) { - ixo = mod.ioXx-bnd.ntap; - ixe = mod.ioXx; - ibz = (izo); - ibx = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(txx[ix*n1+iz] - txx[(ix-1)*n1+iz] + - txz[ix*n1+iz+1] - txz[ix*n1+iz]) + - c2*(txx[(ix+1)*n1+iz] - txx[(ix-2)*n1+iz] + - txz[ix*n1+iz+2] - txz[ix*n1+iz-1]) ); - - vx[ix*n1+iz] *= bnd.tapxz[(ibx-ix)*bnd.ntap+(iz-ibz)]; - } - } - } - - /* Vz field */ - ixo = mod.ioZx; - ixe = mod.ieZx; -// if (bnd.lef==4) ixo -= bnd.ntap; -// if (bnd.rig==4) ixe += bnd.ntap; - izo = mod.ieZz; - ize = mod.ieZz+bnd.ntap; - - ib = (ize-bnd.ntap); -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1] + - txz[(ix+1)*n1+iz] - txz[ix*n1+iz]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2] + - txz[(ix+2)*n1+iz] - txz[(ix-1)*n1+iz]) ); - - vz[ix*n1+iz] *= bnd.tapz[iz-ib]; - } - } - /* right bottom corner */ - if (bnd.rig==4) { - ixo = mod.ieZx; - ixe = ixo+bnd.ntap; - ibz = (izo); - ibx = (ixo); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1] + - txz[(ix+1)*n1+iz] - txz[ix*n1+iz]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2] + - txz[(ix+2)*n1+iz] - txz[(ix-1)*n1+iz]) ); - - vz[ix*n1+iz] *= bnd.tapxz[(ix-ibx)*bnd.ntap+(iz-ibz)]; - } - } - } - /* left bottom corner */ - if (bnd.lef==4) { - ixo = mod.ioZx-bnd.ntap; - ixe = mod.ioZx; - ibz = (izo); - ibx = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1] + - txz[(ix+1)*n1+iz] - txz[ix*n1+iz]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2] + - txz[(ix+2)*n1+iz] - txz[(ix-1)*n1+iz]) ); - - vz[ix*n1+iz] *= bnd.tapxz[(ibx-ix)*bnd.ntap+(iz-ibz)]; - } - } - } - - - } /* end elastic scheme */ - - } - - /*********/ - /* Left */ - /*********/ - if (bnd.lef==4) { - - if (mod.ischeme <= 2) { /* Acoustic scheme */ - - /* Vx field */ - ixo = mod.ioXx-bnd.ntap; - ixe = mod.ioXx; - izo = mod.ioXz; - ize = mod.ieXz; - - ib = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[(ix-1)*n1+iz]) + - c2*(tzz[(ix+1)*n1+iz] - tzz[(ix-2)*n1+iz])); - - vx[ix*n1+iz] *= bnd.tapx[ib-ix]; - } - } - - /* Vz field */ - ixo = mod.ioZx-bnd.ntap; - ixe = mod.ioZx; - izo = mod.ioZz; - ize = mod.ieZz; - - ib = (bnd.ntap+ixo-1); -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2])); - - vz[ix*n1+iz] *= bnd.tapz[ib-ix]; - } - } - - } - else { /* Elastic scheme */ - - /* Vx field */ - ixo = mod.ioXx-bnd.ntap; - ixe = mod.ioXx; - izo = mod.ioXz; - ize = mod.ieXz; - - ib = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(txx[ix*n1+iz] - txx[(ix-1)*n1+iz] + - txz[ix*n1+iz+1] - txz[ix*n1+iz]) + - c2*(txx[(ix+1)*n1+iz] - txx[(ix-2)*n1+iz] + - txz[ix*n1+iz+2] - txz[ix*n1+iz-1]) ); - - vx[ix*n1+iz] *= bnd.tapx[ib-ix]; - } - } - - /* Vz field */ - ixo = mod.ioZx-bnd.ntap; - ixe = mod.ioZx; - izo = mod.ioZz; - ize = mod.ieZz; - - ib = (bnd.ntap+ixo-1); -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1] + - txz[(ix+1)*n1+iz] - txz[ix*n1+iz]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2] + - txz[(ix+2)*n1+iz] - txz[(ix-1)*n1+iz]) ); - - vz[ix*n1+iz] *= bnd.tapz[ib-ix]; - } - } - } /* end elastic scheme */ - - } - - /*********/ - /* Right */ - /*********/ - if (bnd.rig==4) { - - if (mod.ischeme <= 2) { /* Acoustic scheme */ - - /* Vx field */ - ixo = mod.ieXx; - ixe = mod.ieXx+bnd.ntap; - izo = mod.ioXz; - ize = mod.ieXz; - - ib = (ixe-bnd.ntap); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[(ix-1)*n1+iz]) + - c2*(tzz[(ix+1)*n1+iz] - tzz[(ix-2)*n1+iz])); - - vx[ix*n1+iz] *= bnd.tapx[ix-ib]; - } - } - - /* Vz field */ - ixo = mod.ieZx; - ixe = mod.ieZx+bnd.ntap; - izo = mod.ioZz; - ize = mod.ieZz; - - ib = (ixe-bnd.ntap); -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2])); - - vz[ix*n1+iz] *= bnd.tapz[ix-ib]; - } - } - - } - else { /* Elastic scheme */ - - /* Vx field */ - ixo = mod.ieXx; - ixe = mod.ieXx+bnd.ntap; - izo = mod.ioXz; - ize = mod.ieXz; - - ib = (ixe-bnd.ntap); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(txx[ix*n1+iz] - txx[(ix-1)*n1+iz] + - txz[ix*n1+iz+1] - txz[ix*n1+iz]) + - c2*(txx[(ix+1)*n1+iz] - txx[(ix-2)*n1+iz] + - txz[ix*n1+iz+2] - txz[ix*n1+iz-1]) ); - - vx[ix*n1+iz] *= bnd.tapx[ix-ib]; - } - } - - /* Vz field */ - ixo = mod.ieZx; - ixe = mod.ieZx+bnd.ntap; - izo = mod.ioZz; - ize = mod.ieZz; - - ib = (ixe-bnd.ntap); -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1] + - txz[(ix+1)*n1+iz] - txz[ix*n1+iz]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2] + - txz[(ix+2)*n1+iz] - txz[(ix-1)*n1+iz]) ); - - vz[ix*n1+iz] *= bnd.tapz[ix-ib]; - } - } - - } /* end elastic scheme */ - - } - - - return 0; -} - -int boundariesV(modPar mod, bndPar bnd, float *vx, float *vz, float *tzz, float *txx, float *txz, float *rox, float *roz, float *l2m, float *lam, float *mul, int verbose) -{ -/********************************************************************* - - AUTHOR: - Jan Thorbecke (janth@xs4all.nl) - The Netherlands - -***********************************************************************/ - - float c1, c2; - float dp, dvx, dvz; - int ix, iz, ixs, izs, izp; - int nx, nz, n1; - int is0, isrc; - int ixo, ixe, izo, ize; - - c1 = 9.0/8.0; - c2 = -1.0/24.0; - nx = mod.nx; - nz = mod.nz; - n1 = mod.naz; - -/************************************************************/ -/* Tapered boundaries for both elastic and acoustic schemes */ -/* compute all field values in tapered areas */ -/************************************************************/ - - /*********/ - /* Top */ - /*********/ - if (bnd.top==4) { - - if (mod.ischeme <= 2) { /* Acoustic scheme */ - - /* P field */ - ixo = mod.ioPx; - ixe = mod.iePx; - if (bnd.lef==4) ixo -= bnd.ntap; - if (bnd.rig==4) ixe += bnd.ntap; - izo = mod.ioPz-bnd.ntap; - ize = mod.ioPz; - -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - tzz[ix*n1+iz] -= l2m[ix*n1+iz]*( - c1*(vx[(ix+1)*n1+iz] - vx[ix*n1+iz]) + - c2*(vx[(ix+2)*n1+iz] - vx[(ix-1)*n1+iz]) + - c1*(vz[ix*n1+iz+1] - vz[ix*n1+iz]) + - c2*(vz[ix*n1+iz+2] - vz[ix*n1+iz-1])); - } - } - } - else { /* Elastic scheme */ - - /* Txx Tzz field */ - ixo = mod.ioPx; - ixe = mod.iePx; - if (bnd.lef==4) ixo -= bnd.ntap; - if (bnd.rig==4) ixe += bnd.ntap; - izo = mod.ioPz-bnd.ntap; - ize = mod.ioPz; - -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - dvx = c1*(vx[(ix+1)*n1+iz] - vx[ix*n1+iz]) + - c2*(vx[(ix+2)*n1+iz] - vx[(ix-1)*n1+iz]); - dvz = c1*(vz[ix*n1+iz+1] - vz[ix*n1+iz]) + - c2*(vz[ix*n1+iz+2] - vz[ix*n1+iz-1]); - txx[ix*n1+iz] -= l2m[ix*n1+iz]*dvx + lam[ix*n1+iz]*dvz; - tzz[ix*n1+iz] -= l2m[ix*n1+iz]*dvz + lam[ix*n1+iz]*dvx; - } - } - - /* Txz field */ - ixo = mod.ioTx; - ixe = mod.ieTx; - if (bnd.lef==4) ixo -= bnd.ntap; - if (bnd.rig==4) ixe += bnd.ntap; - izo = mod.ioTz-bnd.ntap; - ize = mod.ioTz; - -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - txz[ix*n1+iz] -= mul[ix*n1+iz]*( - c1*(vx[ix*n1+iz] - vx[ix*n1+iz-1] + - vz[ix*n1+iz] - vz[(ix-1)*n1+iz]) + - c2*(vx[ix*n1+iz+1] - vx[ix*n1+iz-2] + - vz[(ix+1)*n1+iz] - vz[(ix-2)*n1+iz]) ); - } - } - } /* end elastic scheme */ - } - - /*********/ - /* Bottom */ - /*********/ - if (bnd.bot==4) { - - if (mod.ischeme <= 2) { /* Acoustic scheme */ - - /* P field */ - ixo = mod.ioPx; - ixe = mod.iePx; - if (bnd.lef==4) ixo -= bnd.ntap; - if (bnd.rig==4) ixe += bnd.ntap; - izo = mod.iePz; - ize = mod.iePz+bnd.ntap; - -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - tzz[ix*n1+iz] -= l2m[ix*n1+iz]*( - c1*(vx[(ix+1)*n1+iz] - vx[ix*n1+iz]) + - c2*(vx[(ix+2)*n1+iz] - vx[(ix-1)*n1+iz]) + - c1*(vz[ix*n1+iz+1] - vz[ix*n1+iz]) + - c2*(vz[ix*n1+iz+2] - vz[ix*n1+iz-1])); - } - } - } - else { /* Elastic scheme */ - - /* Txx Tzz field */ - ixo = mod.ioPx; - ixe = mod.iePx; - if (bnd.lef==4) ixo -= bnd.ntap; - if (bnd.rig==4) ixe += bnd.ntap; - izo = mod.iePz; - ize = mod.iePz+bnd.ntap; - -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - dvx = c1*(vx[(ix+1)*n1+iz] - vx[ix*n1+iz]) + - c2*(vx[(ix+2)*n1+iz] - vx[(ix-1)*n1+iz]); - dvz = c1*(vz[ix*n1+iz+1] - vz[ix*n1+iz]) + - c2*(vz[ix*n1+iz+2] - vz[ix*n1+iz-1]); - txx[ix*n1+iz] -= l2m[ix*n1+iz]*dvx + lam[ix*n1+iz]*dvz; - tzz[ix*n1+iz] -= l2m[ix*n1+iz]*dvz + lam[ix*n1+iz]*dvx; - } - } - - /* Txz field */ - ixo = mod.ioTx; - ixe = mod.ieTx; - if (bnd.lef==4) ixo -= bnd.ntap; - if (bnd.rig==4) ixe += bnd.ntap; - izo = mod.ieTz; - ize = mod.ieTz+bnd.ntap; - -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - txz[ix*n1+iz] -= mul[ix*n1+iz]*( - c1*(vx[ix*n1+iz] - vx[ix*n1+iz-1] + - vz[ix*n1+iz] - vz[(ix-1)*n1+iz]) + - c2*(vx[ix*n1+iz+1] - vx[ix*n1+iz-2] + - vz[(ix+1)*n1+iz] - vz[(ix-2)*n1+iz]) ); - } - } - } /* end elastic scheme */ - - } - - /*********/ - /* Left */ - /*********/ - if (bnd.lef==4) { - - if (mod.ischeme <= 2) { /* Acoustic scheme */ - - /* P field */ - ixo = mod.ioPx-bnd.ntap; - ixe = mod.ioPx; - izo = mod.ioPz; - ize = mod.iePz; - -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - tzz[ix*n1+iz] -= l2m[ix*n1+iz]*( - c1*(vx[(ix+1)*n1+iz] - vx[ix*n1+iz]) + - c2*(vx[(ix+2)*n1+iz] - vx[(ix-1)*n1+iz]) + - c1*(vz[ix*n1+iz+1] - vz[ix*n1+iz]) + - c2*(vz[ix*n1+iz+2] - vz[ix*n1+iz-1])); - } - } - } - else { /* Elastic scheme */ - - /* Txx Tzz field */ - ixo = mod.ioPx-bnd.ntap; - ixe = mod.ioPx; - izo = mod.ioPz; - ize = mod.iePz; - -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - dvx = c1*(vx[(ix+1)*n1+iz] - vx[ix*n1+iz]) + - c2*(vx[(ix+2)*n1+iz] - vx[(ix-1)*n1+iz]); - dvz = c1*(vz[ix*n1+iz+1] - vz[ix*n1+iz]) + - c2*(vz[ix*n1+iz+2] - vz[ix*n1+iz-1]); - txx[ix*n1+iz] -= l2m[ix*n1+iz]*dvx + lam[ix*n1+iz]*dvz; - tzz[ix*n1+iz] -= l2m[ix*n1+iz]*dvz + lam[ix*n1+iz]*dvx; - } - } - - /* Txz field */ - ixo = mod.ioTx-bnd.ntap; - ixe = mod.ioTx; - izo = mod.ioTz; - ize = mod.ieTz; - -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - txz[ix*n1+iz] -= mul[ix*n1+iz]*( - c1*(vx[ix*n1+iz] - vx[ix*n1+iz-1] + - vz[ix*n1+iz] - vz[(ix-1)*n1+iz]) + - c2*(vx[ix*n1+iz+1] - vx[ix*n1+iz-2] + - vz[(ix+1)*n1+iz] - vz[(ix-2)*n1+iz]) ); - } - } - } /* end elastic scheme */ - - } - - /*********/ - /* Right */ - /*********/ - if (bnd.rig==4) { - - if (mod.ischeme <= 2) { /* Acoustic scheme */ - - /* P field */ - ixo = mod.iePx; - ixe = mod.iePx+bnd.ntap; - izo = mod.ioPz; - ize = mod.iePz; - -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - tzz[ix*n1+iz] -= l2m[ix*n1+iz]*( - c1*(vx[(ix+1)*n1+iz] - vx[ix*n1+iz]) + - c2*(vx[(ix+2)*n1+iz] - vx[(ix-1)*n1+iz]) + - c1*(vz[ix*n1+iz+1] - vz[ix*n1+iz]) + - c2*(vz[ix*n1+iz+2] - vz[ix*n1+iz-1])); - } - } - } - else { /* Elastic scheme */ - - /* Txx Tzz field */ - ixo = mod.iePx; - ixe = mod.iePx+bnd.ntap; - izo = mod.ioPz; - ize = mod.iePz; - -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - dvx = c1*(vx[(ix+1)*n1+iz] - vx[ix*n1+iz]) + - c2*(vx[(ix+2)*n1+iz] - vx[(ix-1)*n1+iz]); - dvz = c1*(vz[ix*n1+iz+1] - vz[ix*n1+iz]) + - c2*(vz[ix*n1+iz+2] - vz[ix*n1+iz-1]); - txx[ix*n1+iz] -= l2m[ix*n1+iz]*dvx + lam[ix*n1+iz]*dvz; - tzz[ix*n1+iz] -= l2m[ix*n1+iz]*dvz + lam[ix*n1+iz]*dvx; - } - } - - /* Txz field */ - ixo = mod.ieTx; - ixe = mod.ieTx+bnd.ntap; - izo = mod.ioTz; - ize = mod.ieTz; - -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - txz[ix*n1+iz] -= mul[ix*n1+iz]*( - c1*(vx[ix*n1+iz] - vx[ix*n1+iz-1] + - vz[ix*n1+iz] - vz[(ix-1)*n1+iz]) + - c2*(vx[ix*n1+iz+1] - vx[ix*n1+iz-2] + - vz[(ix+1)*n1+iz] - vz[(ix-2)*n1+iz]) ); - } - } - } /* end elastic scheme */ - - } - - - - - - ixo = mod.ioPx; - ixe = mod.iePx; - if (bnd.lef==4) ixo -= bnd.ntap; - if (bnd.rig==4) ixe += bnd.ntap; - izo = mod.ioPz; - ize = mod.iePz; - if (bnd.top==4) izo -= bnd.ntap; - if (bnd.bot==4) ize += bnd.ntap; - - if (mod.ischeme <= 2) { /* Acoustic scheme */ - - if (bnd.top==1) { /* free surface at top */ -#pragma omp for private (ix) nowait - for (ix=ixo; ix<ixe; ix++) { - iz = bnd.surface[ix]; - tzz[ix*n1+iz] = 0.0; - } - } - if (bnd.rig==1) { /* free surface at right */ -#pragma omp for private (iz) nowait - for (iz=izo; iz<ize; iz++) { - tzz[ixe*n1+iz] = 0.0; - } - } - if (bnd.bot==1) { /* free surface at bottom */ -#pragma omp for private (ix) nowait - for (ix=ixo; ix<ixe; ix++) { - tzz[ix*n1+ize] = 0.0; - } - } - if (bnd.lef==1) { /* free surface at left */ -#pragma omp for private (iz) nowait - for (iz=izo; iz<ize; iz++) { - tzz[ixo*n1+iz] = 0.0; - } - } - } - else { /* Elastic scheme */ - - /* Free surface: calculate free surface conditions for stresses - * Conditions (for upper boundary): - * 1. Tzz = 0 - * 2. Txz = 0 - * 3. Txx: remove term with dVz/dz, computed in e2/e4 routines - * and add extra term with dVx/dx, - * corresponding to free-surface condition for Txx. - * In this way, dVz/dz is not needed in computing Txx - * on the upper stress free boundary. Other boundaries - * are treated similar. - * For the 4th order schemes, the whole virtual boundary - * must be taken into account in the removal terms, - * because the algorithm sets - * velocities on this boundary! - * - * Compute the velocities on the virtual boundary to make interpolation - * possible for receivers. - */ - - if (bnd.top==1) { /* free surface at top */ - izp = bnd.surface[ixo]; -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { - iz = bnd.surface[ix]; - if ( izp==iz ) { - /* clear normal pressure */ - tzz[ix*n1+iz] = 0.0; - /* extra line of txz has to be copied */ -// txz[ix*n1+iz-1] = -txz[ix*n1+iz+2]; - /* This update to Vz might become unstable (2nd order scheme) */ -// vz[ix*n1+iz] = vz[ix*n1+iz+1] - (vx[(ix+1)*n1+iz]-vx[ix*n1+iz])* -// lam[ix*n1+iz]/l2m[ix*n1+iz]; - } - izp=iz; - } - - izp = bnd.surface[ixo]; -#pragma omp for private (ix, iz) - for (ix=ixo+1; ix<ixe+1; ix++) { - iz = bnd.surface[ix-1]; - if ( izp==iz ) { - /* assure that txz=0 on boundary by filling virtual boundary */ - txz[ix*n1+iz] = -txz[ix*n1+iz+1]; - /* extra line of txz has to be copied */ - txz[ix*n1+iz-1] = -txz[ix*n1+iz+2]; - } - izp=iz; - } - - /* calculate txx on top stress-free boundary */ - izp = bnd.surface[ixo]; -#pragma omp for private (ix, iz, dp, dvx) - for (ix=ixo; ix<ixe; ix++) { - iz = bnd.surface[ix]; - if ( izp==iz ) { - dp = l2m[ix*n1+iz]-lam[ix*n1+iz]*lam[ix*n1+iz]/l2m[ix*n1+iz]; - dvx = c1*(vx[(ix+1)*n1+iz] - vx[(ix)*n1+iz]) + - c2*(vx[(ix+2)*n1+iz] - vx[(ix-1)*n1+iz]); - txx[ix*n1+iz] = -dvx*dp; - } - izp=iz; - } - - - /* if surface has also left or right edges */ - izp = bnd.surface[ixo]; -#pragma omp for private (ix, iz, dp, dvz) - for (ix=ixo+1; ix<ixe; ix++) { - iz = bnd.surface[ix-1]; - if ( izp < iz ) { /* right boundary */ - /* clear normal pressure */ - txx[ix*n1+iz] = 0.0; - if ( (iz-izp) >= 2 ) { /* VR point */ - /* assure that txz=0 on boundary */ - txz[(ix+1)*n1+iz] = -txz[ix*n1+iz]; - txz[(ix+2)*n1+iz] = -txz[(ix-1)*n1+iz] ; - /* calculate tzz on right stress-free boundary */ - dvz = c1*(vz[ix*n1+iz+1] - vz[ix*n1+iz]) + - c2*(vz[ix*n1+iz+2] - vz[ix*n1+iz-1]); - dp = l2m[ix*n1+iz]-lam[ix*n1+iz]*lam[ix*n1+iz]/l2m[ix*n1+iz]; - tzz[ix*n1+iz] = -dvz*dp; - } - else { - // if (izp) { /* IR point */ - // txz[ix*n1+iz] = -txz[ix*n1+iz+1] ; - // txz[ix*n1+iz-1] = -txz[ix*n1+iz+2]; - txz[(ix+1)*n1+iz] = -txz[ix*n1+iz]; - txz[(ix+2)*n1+iz] = -txz[(ix-1)*n1+iz] ; - tzz[ix*n1+iz] = 0.0; - // } - // else { /* OR point */ - txz[(ix-1)*n1+iz] = 0.0; - txz[(ix+1)*n1+iz] = -txz[ix*n1+iz]; - txz[(ix+2)*n1+iz] = -txz[(ix-1)*n1+iz] ; - vz[ix*n1+iz] = vz[ix*n1+iz+1] - (vx[(ix+1)*n1+iz]-vx[ix*n1+iz])* - lam[ix*n1+iz]/l2m[ix*n1+iz]; - // } - } - - } /* end if right */ - if ( izp > iz ) { /* left boundary */ - /* clear normal pressure */ - txx[ix*n1+iz] = 0.0; - /* assure that txz=0 on boundary */ - txz[(ix-1)*n1+iz] = -txz[ix*n1+iz]; - /* extra line of txz has to be copied */ - txz[(ix-2)*n1+iz] = -txz[(ix+1)*n1+iz] ; - /* calculate tzz on left stress-free boundary */ - dvz = c1*(vz[ix*n1+iz+1] - vz[ix*n1+iz]) + - c2*(vz[ix*n1+iz+2] - vz[ix*n1+iz-1]); - dp = l2m[ix*n1+iz]-lam[ix*n1+iz]*lam[ix*n1+iz]/l2m[ix*n1+iz]; - tzz[ix*n1+iz] = -dvz*dp; - } /* end if left */ - izp=iz; - // izp=bnd.surface[MAX(ix-2,0)];; - } /* end ix loop */ - } - - - if (bnd.rig==1) { /* free surface at right */ - ix = ixe; -#pragma omp for private (ix, iz) - for (iz=izo; iz<ize; iz++) { - /* clear normal pressure */ - txx[(ix)*n1+iz] = 0.0; - } -#pragma omp for private (ix, iz) - for (iz=izo+1; iz<ize+1; iz++) { - /* assure that txz=0 on boundary by filling virtual boundary */ - txz[(ix+1)*n1+iz] = -txz[(ix)*n1+iz]; - /* extra line of txz has to be copied */ - txz[(ix+2)*n1+iz] = -txz[(ix-1)*n1+iz] ; - } - /* calculate tzz on right stress-free boundary */ -#pragma omp for private (iz) - for (iz=izo; iz<ize; iz++) { - dvz = c1*(vz[(ix)*n1+iz+1] - vz[(ix)*n1+iz]) + - c2*(vz[(ix)*n1+iz+2] - vz[(ix)*n1+iz-1]); - dp = l2m[(ix)*n1+iz]-lam[(ix)*n1+iz]*lam[(ix)*n1+iz]/l2m[(ix)*n1+iz]; - tzz[(ix)*n1+iz] = -dvz*dp; - } - } - - - if (bnd.bot==1) { /* free surface at bottom */ - iz = ize; -#pragma omp for private (ix) - for (ix=ixo; ix<ixe; ix++) { - /* clear normal pressure */ - tzz[ix*n1+iz] = 0.0; - } -#pragma omp for private (ix) - for (ix=ixo+1; ix<ixe+1; ix++) { - /* assure that txz=0 on boundary by filling virtual boundary */ - txz[ix*n1+iz+1] = -txz[ix*n1+iz]; - /* extra line of txz has to be copied */ - txz[ix*n1+iz+2] = -txz[ix*n1+iz-1]; - } - /* calculate txx on bottom stress-free boundary */ -#pragma omp for private (ix) - for (ix=ixo; ix<ixe; ix++) { - dvx = c1*(vx[(ix+1)*n1+iz] - vx[ix*n1+iz]) + - c2*(vx[(ix+2)*n1+iz] - vx[(ix-1)*n1+iz]); - dp = l2m[ix*n1+iz]-lam[ix*n1+iz]*lam[ix*n1+iz]/l2m[ix*n1+iz]; - txx[ix*n1+iz] = -dvx*dp; - } - } - - if (bnd.lef==1) { /* free surface at left */ - ix = ixo; -#pragma omp for private (iz) - for (iz=izo; iz<ize; iz++) { - /* clear normal pressure */ - txx[ix*n1+iz] = 0.0; - } -#pragma omp for private (iz) - for (iz=izo+1; iz<ize+1; iz++) { - /* assure that txz=0 on boundary by filling virtual boundary */ - txz[(ix)*n1+iz] = -txz[(ix+1)*n1+iz]; - /* extra line of txz has to be copied */ - txz[(ix-1)*n1+iz] = -txz[(ix+2)*n1+iz] ; - } - /* calculate tzz on left stress-free boundary */ -#pragma omp for private (iz) - for (iz=izo; iz<ize; iz++) { - dvz = c1*(vz[ix*n1+iz+1] - vz[ix*n1+iz]) + - c2*(vz[ix*n1+iz+2] - vz[ix*n1+iz-1]); - dp = l2m[ix*n1+iz]-lam[ix*n1+iz]*lam[ix*n1+iz]/l2m[ix*n1+iz]; - tzz[ix*n1+iz] = -dvz*dp; - } - } - - - } - - - - - return 0; -} diff --git a/fdelmodc/boundaries.c.ok2 b/fdelmodc/boundaries.c.ok2 deleted file mode 100644 index 0bcfc586bfc0454350bf09363c3dd2569ff3ac20..0000000000000000000000000000000000000000 --- a/fdelmodc/boundaries.c.ok2 +++ /dev/null @@ -1,1057 +0,0 @@ -#include<stdlib.h> -#include<stdio.h> -#include<math.h> -#include<assert.h> -#include"fdelmodc.h" - -float *exL, *exR, *eyT, *eyB; -int first=0; - -int boundariesP(modPar mod, bndPar bnd, float *vx, float *vz, float *tzz, float *txx, float *txz, float *rox, float *roz, float *l2m, float *lam, float *mul, int verbose) -{ -/********************************************************************* - - AUTHOR: - Jan Thorbecke (janth@xs4all.nl) - The Netherlands - -***********************************************************************/ - - float c1, c2; - float dp, dvx, dvz; - int ix, iz, ixs, izs, ibnd, ib, ibx, ibz; - int nx, nz, n1; - int is0, isrc; - int ixo, ixe, izo, ize; - - - c1 = 9.0/8.0; - c2 = -1.0/24.0; - nx = mod.nx; - nz = mod.nz; - n1 = mod.naz; - - ibnd = mod.iorder/2-1; - -/************************************************************/ -/* rigid boundary condition clears velocities on boundaries */ -/************************************************************/ - - if (bnd.top==3) { /* rigid surface at top */ -#pragma omp for private (ix, iz) nowait -#pragma ivdep - for (ix=1; ix<=nx; ix++) { - vx[ix*n1+ibnd] = 0.0; - vz[ix*n1+ibnd] = -vz[ix*n1+ibnd+1]; - if (mod.iorder >= 4) vz[ix*n1+ibnd-1] = -vz[ix*n1+ibnd+2]; - if (mod.iorder >= 6) vz[ix*n1+ibnd-2] = -vz[ix*n1+ibnd+3]; - } - } - if (bnd.rig==3) { /* rigid surface at right */ -#pragma omp for private (ix, iz) nowait -#pragma ivdep - for (iz=1; iz<=nz; iz++) { - vz[(nx+ibnd-1)*n1+iz] = 0.0; - vx[(nx+ibnd)*n1+iz] = -vx[(nx+ibnd-1)*n1+iz]; - if (mod.iorder == 4) vx[(nx+2)*n1+iz] = -vx[(nx-1)*n1+iz]; - if (mod.iorder == 6) { - vx[(nx+1)*n1+iz] = -vx[(nx)*n1+iz]; - vx[(nx+3)*n1+iz] = -vx[(nx-2)*n1+iz]; - } - } - } - if (bnd.bot==3) { /* rigid surface at bottom */ -#pragma omp for private (ix, iz) nowait -#pragma ivdep - for (ix=1; ix<=nx; ix++) { - vx[ix*n1+nz+ibnd-1] = 0.0; - vz[ix*n1+nz+ibnd] = -vz[ix*n1+nz+ibnd-1]; - if (mod.iorder == 4) vz[ix*n1+nz+2] = -vz[ix*n1+nz-1]; - if (mod.iorder == 6) { - vz[ix*n1+nz+1] = -vz[ix*n1+nz]; - vz[ix*n1+nz+3] = -vz[ix*n1+nz-2]; - } - } - } - if (bnd.lef==3) { /* rigid surface at left */ -#pragma omp for private (ix, iz) nowait -#pragma ivdep - for (iz=1; iz<=nz; iz++) { - vz[ibnd*n1+iz] = 0.0; - vx[ibnd*n1+iz] = -vx[(ibnd+1)*n1+iz]; - if (mod.iorder == 4) vx[0*n1+iz] = -vx[3*n1+iz]; - if (mod.iorder == 6) { - vx[1*n1+iz] = -vx[4*n1+iz]; - vx[0*n1+iz] = -vx[5*n1+iz]; - } - } - } - -/************************************************************/ -/* PML boundaries : only for acoustic 4th order scheme */ -/************************************************************/ - - if (bnd.top==2) { /* PML at top */ - } - -/************************************************************/ -/* Tapered boundaries for both elastic and acoustic schemes */ -/* compute all field values in tapered areas */ -/************************************************************/ - - /*********/ - /* Top */ - /*********/ - if (bnd.top==4) { - - if (mod.ischeme <= 2) { /* Acoustic scheme */ - - /* Vx field */ - ixo = mod.ioXx; - ixe = mod.ieXx; - izo = mod.ioXz-bnd.ntap; - ize = mod.ioXz; - - ib = (bnd.ntap+izo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[(ix-1)*n1+iz]) + - c2*(tzz[(ix+1)*n1+iz] - tzz[(ix-2)*n1+iz])); - - vx[ix*n1+iz] *= bnd.tapx[ib-iz]; - } - } - /* right top corner */ - if (bnd.rig==4) { - ixo = mod.ieXx; - ixe = ixo+bnd.ntap; - ibz = (bnd.ntap+izo-1); - ibx = (ixo); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[(ix-1)*n1+iz]) + - c2*(tzz[(ix+1)*n1+iz] - tzz[(ix-2)*n1+iz])); - - vx[ix*n1+iz] *= bnd.tapxz[(ix-ibx)*bnd.ntap+(ibz-iz)]; - } - } - } - /* left top corner */ - if (bnd.lef==4) { - ixo = mod.ioXx-bnd.ntap; - ixe = mod.ioXx; - ibz = (bnd.ntap+izo-1); - ibx = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[(ix-1)*n1+iz]) + - c2*(tzz[(ix+1)*n1+iz] - tzz[(ix-2)*n1+iz])); - - vx[ix*n1+iz] *= bnd.tapxz[(ibx-ix)*bnd.ntap+(ibz-iz)]; - } - } - } - - - /* Vz field */ - ixo = mod.ioZx; - ixe = mod.ieZx; - izo = mod.ioZz-bnd.ntap; - ize = mod.ioZz; - - ib = (bnd.ntap+izo-1); -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2])); - - vz[ix*n1+iz] *= bnd.tapz[ib-iz]; - } - } - /* right top corner */ - if (bnd.rig==4) { - ixo = mod.ieZx; - ixe = ixo+bnd.ntap; - ibz = (bnd.ntap+izo-1); - ibx = (ixo); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2])); - - vz[ix*n1+iz] *= bnd.tapxz[(ix-ibx)*bnd.ntap+(ibz-iz)]; - } - } - } - /* left top corner */ - if (bnd.lef==4) { - ixo = mod.ioZx-bnd.ntap; - ixe = mod.ioZx; - ibz = (bnd.ntap+izo-1); - ibx = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2])); - - vz[ix*n1+iz] *= bnd.tapxz[(ibx-ix)*bnd.ntap+(ibz-iz)]; - } - } - } - - } - else { /* Elastic scheme */ - - /* Vx field */ - ixo = mod.ioXx; - ixe = mod.ieXx; - izo = mod.ioXz-bnd.ntap; - ize = mod.ioXz; - - ib = (bnd.ntap+izo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(txx[ix*n1+iz] - txx[(ix-1)*n1+iz] + - txz[ix*n1+iz+1] - txz[ix*n1+iz]) + - c2*(txx[(ix+1)*n1+iz] - txx[(ix-2)*n1+iz] + - txz[ix*n1+iz+2] - txz[ix*n1+iz-1]) ); - - vx[ix*n1+iz] *= bnd.tapx[ib-iz]; - } - } - /* right top corner */ - if (bnd.rig==4) { - ixo = mod.ieXx; - ixe = ixo+bnd.ntap; - ibz = (bnd.ntap+izo-1); - ibx = (ixo); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(txx[ix*n1+iz] - txx[(ix-1)*n1+iz] + - txz[ix*n1+iz+1] - txz[ix*n1+iz]) + - c2*(txx[(ix+1)*n1+iz] - txx[(ix-2)*n1+iz] + - txz[ix*n1+iz+2] - txz[ix*n1+iz-1]) ); - - vx[ix*n1+iz] *= bnd.tapxz[(ix-ibx)*bnd.ntap+(ibz-iz)]; - } - } - } - /* left top corner */ - if (bnd.lef==4) { - ixo = mod.ioXx-bnd.ntap; - ixe = mod.ioXx; - ibz = (bnd.ntap+izo-1); - ibx = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(txx[ix*n1+iz] - txx[(ix-1)*n1+iz] + - txz[ix*n1+iz+1] - txz[ix*n1+iz]) + - c2*(txx[(ix+1)*n1+iz] - txx[(ix-2)*n1+iz] + - txz[ix*n1+iz+2] - txz[ix*n1+iz-1]) ); - - vx[ix*n1+iz] *= bnd.tapxz[(ibx-ix)*bnd.ntap+(ibz-iz)]; - } - } - } - - /* Vz field */ - ixo = mod.ioZx; - ixe = mod.ieZx; - izo = mod.ioZz-bnd.ntap; - ize = mod.ioZz; - - ib = (bnd.ntap+izo-1); -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1] + - txz[(ix+1)*n1+iz] - txz[ix*n1+iz]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2] + - txz[(ix+2)*n1+iz] - txz[(ix-1)*n1+iz]) ); - - vz[ix*n1+iz] *= bnd.tapz[ib-iz]; - } - } - /* right top corner */ - if (bnd.rig==4) { - ixo = mod.ieZx; - ixe = ixo+bnd.ntap; - ibz = (bnd.ntap+izo-1); - ibx = (ixo); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1] + - txz[(ix+1)*n1+iz] - txz[ix*n1+iz]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2] + - txz[(ix+2)*n1+iz] - txz[(ix-1)*n1+iz]) ); - - vz[ix*n1+iz] *= bnd.tapxz[(ix-ibx)*bnd.ntap+(ibz-iz)]; - } - } - } - /* left top corner */ - if (bnd.lef==4) { - ixo = mod.ioZx-bnd.ntap; - ixe = mod.ioZx; - ibz = (bnd.ntap+izo-1); - ibx = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1] + - txz[(ix+1)*n1+iz] - txz[ix*n1+iz]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2] + - txz[(ix+2)*n1+iz] - txz[(ix-1)*n1+iz]) ); - - vz[ix*n1+iz] *= bnd.tapxz[(ibx-ix)*bnd.ntap+(ibz-iz)]; - } - } - } - - - } /* end elastic scheme */ - } - - /*********/ - /* Bottom */ - /*********/ - if (bnd.bot==4) { - - if (mod.ischeme <= 2) { /* Acoustic scheme */ - - /* Vx field */ - ixo = mod.ioXx; - ixe = mod.ieXx; - izo = mod.ieXz; - ize = mod.ieXz+bnd.ntap; - - ib = (ize-bnd.ntap); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[(ix-1)*n1+iz]) + - c2*(tzz[(ix+1)*n1+iz] - tzz[(ix-2)*n1+iz])); - vx[ix*n1+iz] *= bnd.tapx[iz-ib]; - } - } - /* right bottom corner */ - if (bnd.rig==4) { - ixo = mod.ieXx; - ixe = ixo+bnd.ntap; - ibz = (izo); - ibx = (ixo); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[(ix-1)*n1+iz]) + - c2*(tzz[(ix+1)*n1+iz] - tzz[(ix-2)*n1+iz])); - - vx[ix*n1+iz] *= bnd.tapxz[(ix-ibx)*bnd.ntap+(iz-ibz)]; - } - } - } - /* left bottom corner */ - if (bnd.lef==4) { - ixo = mod.ioXx-bnd.ntap; - ixe = mod.ioXx; - ibz = (izo); - ibx = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[(ix-1)*n1+iz]) + - c2*(tzz[(ix+1)*n1+iz] - tzz[(ix-2)*n1+iz])); - - vx[ix*n1+iz] *= bnd.tapxz[(ibx-ix)*bnd.ntap+(iz-ibz)]; - } - } - } - - - /* Vz field */ - ixo = mod.ioZx; - ixe = mod.ieZx; - izo = mod.ieZz; - ize = mod.ieZz+bnd.ntap; - - ib = (ize-bnd.ntap); -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2])); - vz[ix*n1+iz] *= bnd.tapz[iz-ib]; - } - } - /* right bottom corner */ - if (bnd.rig==4) { - ixo = mod.ieZx; - ixe = ixo+bnd.ntap; - ibz = (izo); - ibx = (ixo); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2])); - - vz[ix*n1+iz] *= bnd.tapxz[(ix-ibx)*bnd.ntap+(iz-ibz)]; - } - } - } - /* left bottom corner */ - if (bnd.lef==4) { - ixo = mod.ioZx-bnd.ntap; - ixe = mod.ioZx; - ibz = (izo); - ibx = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2])); - - vz[ix*n1+iz] *= bnd.tapxz[(ibx-ix)*bnd.ntap+(iz-ibz)]; - } - } - } - - - } - else { /* Elastic scheme */ - - /* Vx field */ - ixo = mod.ioXx; - ixe = mod.ieXx; - izo = mod.ieXz; - ize = mod.ieXz+bnd.ntap; - - ib = (ize-bnd.ntap); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(txx[ix*n1+iz] - txx[(ix-1)*n1+iz] + - txz[ix*n1+iz+1] - txz[ix*n1+iz]) + - c2*(txx[(ix+1)*n1+iz] - txx[(ix-2)*n1+iz] + - txz[ix*n1+iz+2] - txz[ix*n1+iz-1]) ); - - vx[ix*n1+iz] *= bnd.tapx[iz-ib]; - } - } - /* right bottom corner */ - if (bnd.rig==4) { - ixo = mod.ieXx; - ixe = ixo+bnd.ntap; - ibz = (izo); - ibx = (ixo); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(txx[ix*n1+iz] - txx[(ix-1)*n1+iz] + - txz[ix*n1+iz+1] - txz[ix*n1+iz]) + - c2*(txx[(ix+1)*n1+iz] - txx[(ix-2)*n1+iz] + - txz[ix*n1+iz+2] - txz[ix*n1+iz-1]) ); - - vx[ix*n1+iz] *= bnd.tapxz[(ix-ibx)*bnd.ntap+(iz-ibz)]; - } - } - } - /* left bottom corner */ - if (bnd.lef==4) { - - - ixo = mod.ioXx-bnd.ntap; - ixe = mod.ioXx; - ibz = (izo); - ibx = (bnd.ntap+ixo-1); - - -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(txx[ix*n1+iz] - txx[(ix-1)*n1+iz] + - txz[ix*n1+iz+1] - txz[ix*n1+iz]) + - c2*(txx[(ix+1)*n1+iz] - txx[(ix-2)*n1+iz] + - txz[ix*n1+iz+2] - txz[ix*n1+iz-1]) ); - - vx[ix*n1+iz] *= bnd.tapxz[(ibx-ix)*bnd.ntap+(iz-ibz)]; - } - } - } - - /* Vz field */ - ixo = mod.ioZx; - ixe = mod.ieZx; - izo = mod.ieZz; - ize = mod.ieZz+bnd.ntap; - - ib = (ize-bnd.ntap); -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1] + - txz[(ix+1)*n1+iz] - txz[ix*n1+iz]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2] + - txz[(ix+2)*n1+iz] - txz[(ix-1)*n1+iz]) ); - - vz[ix*n1+iz] *= bnd.tapz[iz-ib]; - } - } - /* right bottom corner */ - if (bnd.rig==4) { - ixo = mod.ieZx; - ixe = ixo+bnd.ntap; - ibz = (izo); - ibx = (ixo); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1] + - txz[(ix+1)*n1+iz] - txz[ix*n1+iz]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2] + - txz[(ix+2)*n1+iz] - txz[(ix-1)*n1+iz]) ); - - vz[ix*n1+iz] *= bnd.tapxz[(ix-ibx)*bnd.ntap+(iz-ibz)]; - } - } - } - /* left bottom corner */ - if (bnd.lef==4) { - ixo = mod.ioZx-bnd.ntap; - ixe = mod.ioZx; - ibz = (izo); - ibx = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1] + - txz[(ix+1)*n1+iz] - txz[ix*n1+iz]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2] + - txz[(ix+2)*n1+iz] - txz[(ix-1)*n1+iz]) ); - - vz[ix*n1+iz] *= bnd.tapxz[(ibx-ix)*bnd.ntap+(iz-ibz)]; - } - } - } - - - } /* end elastic scheme */ - - } - - /*********/ - /* Left */ - /*********/ - if (bnd.lef==4) { - - if (mod.ischeme <= 2) { /* Acoustic scheme */ - - /* Vx field */ - ixo = mod.ioXx-bnd.ntap; - ixe = mod.ioXx; - izo = mod.ioXz; - ize = mod.ieXz; - - ib = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[(ix-1)*n1+iz]) + - c2*(tzz[(ix+1)*n1+iz] - tzz[(ix-2)*n1+iz])); - - vx[ix*n1+iz] *= bnd.tapx[ib-ix]; - } - } - - /* Vz field */ - ixo = mod.ioZx-bnd.ntap; - ixe = mod.ioZx; - izo = mod.ioZz; - ize = mod.ieZz; - - ib = (bnd.ntap+ixo-1); -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2])); - - vz[ix*n1+iz] *= bnd.tapz[ib-ix]; - } - } - - } - else { /* Elastic scheme */ - - /* Vx field */ - ixo = mod.ioXx-bnd.ntap; - ixe = mod.ioXx; - izo = mod.ioXz; - ize = mod.ieXz; - - ib = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(txx[ix*n1+iz] - txx[(ix-1)*n1+iz] + - txz[ix*n1+iz+1] - txz[ix*n1+iz]) + - c2*(txx[(ix+1)*n1+iz] - txx[(ix-2)*n1+iz] + - txz[ix*n1+iz+2] - txz[ix*n1+iz-1]) ); - - vx[ix*n1+iz] *= bnd.tapx[ib-ix]; - } - } - - /* Vz field */ - ixo = mod.ioZx-bnd.ntap; - ixe = mod.ioZx; - izo = mod.ioZz; - ize = mod.ieZz; - - ib = (bnd.ntap+ixo-1); -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1] + - txz[(ix+1)*n1+iz] - txz[ix*n1+iz]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2] + - txz[(ix+2)*n1+iz] - txz[(ix-1)*n1+iz]) ); - - vz[ix*n1+iz] *= bnd.tapz[ib-ix]; - } - } - } /* end elastic scheme */ - - } - - /*********/ - /* Right */ - /*********/ - if (bnd.rig==4) { - - if (mod.ischeme <= 2) { /* Acoustic scheme */ - - /* Vx field */ - ixo = mod.ieXx; - ixe = mod.ieXx+bnd.ntap; - izo = mod.ioXz; - ize = mod.ieXz; - - ib = (ixe-bnd.ntap); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[(ix-1)*n1+iz]) + - c2*(tzz[(ix+1)*n1+iz] - tzz[(ix-2)*n1+iz])); - - vx[ix*n1+iz] *= bnd.tapx[ix-ib]; - } - } - - /* Vz field */ - ixo = mod.ieZx; - ixe = mod.ieZx+bnd.ntap; - izo = mod.ioZz; - ize = mod.ieZz; - - ib = (ixe-bnd.ntap); -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2])); - - vz[ix*n1+iz] *= bnd.tapz[ix-ib]; - } - } - - } - else { /* Elastic scheme */ - - /* Vx field */ - ixo = mod.ieXx; - ixe = mod.ieXx+bnd.ntap; - izo = mod.ioXz; - ize = mod.ieXz; - - ib = (ixe-bnd.ntap); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(txx[ix*n1+iz] - txx[(ix-1)*n1+iz] + - txz[ix*n1+iz+1] - txz[ix*n1+iz]) + - c2*(txx[(ix+1)*n1+iz] - txx[(ix-2)*n1+iz] + - txz[ix*n1+iz+2] - txz[ix*n1+iz-1]) ); - - vx[ix*n1+iz] *= bnd.tapx[ix-ib]; - } - } - - /* Vz field */ - ixo = mod.ieZx; - ixe = mod.ieZx+bnd.ntap; - izo = mod.ioZz; - ize = mod.ieZz; - - ib = (ixe-bnd.ntap); -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1] + - txz[(ix+1)*n1+iz] - txz[ix*n1+iz]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2] + - txz[(ix+2)*n1+iz] - txz[(ix-1)*n1+iz]) ); - - vz[ix*n1+iz] *= bnd.tapz[ix-ib]; - } - } - - } /* end elastic scheme */ - - } - - - return 0; -} - -int boundariesV(modPar mod, bndPar bnd, float *vx, float *vz, float *tzz, float *txx, float *txz, float *rox, float *roz, float *l2m, float *lam, float *mul, int verbose) -{ -/********************************************************************* - - AUTHOR: - Jan Thorbecke (janth@xs4all.nl) - The Netherlands - -***********************************************************************/ - - float c1, c2; - float dp, dvx, dvz; - int ix, iz, ixs, izs, izp; - int n1; - int is0, isrc; - int ixo, ixe, izo, ize; - - c1 = 9.0/8.0; - c2 = -1.0/24.0; - n1 = mod.naz; - -/************************************************************/ -/* Tapered boundaries for both elastic and acoustic schemes */ -/* compute all field values in tapered areas */ -/************************************************************/ - - -/****************************************************************/ -/* Free surface: calculate free surface conditions for stresses */ -/****************************************************************/ - - - ixo = mod.ioPx; - ixe = mod.iePx; - izo = mod.ioPz; - ize = mod.iePz; - - if (mod.ischeme <= 2) { /* Acoustic scheme */ - - if (bnd.top==1) { /* free surface at top */ -#pragma omp for private (ix) nowait - for (ix=mod.ioPx; ix<mod.iePx; ix++) { - iz = bnd.surface[ix]; - tzz[ix*n1+iz] = 0.0; - } - } - if (bnd.rig==1) { /* free surface at right */ -#pragma omp for private (iz) nowait - for (iz=mod.ioPz; iz<mod.iePz; iz++) { - tzz[(mod.iePx-1)*n1+iz] = 0.0; - } - } - if (bnd.bot==1) { /* free surface at bottom */ -#pragma omp for private (ix) nowait - for (ix=mod.ioPx; ix<mod.iePx; ix++) { - tzz[ix*n1+mod.iePz-1] = 0.0; - } - } - if (bnd.lef==1) { /* free surface at left */ -#pragma omp for private (iz) nowait - for (iz=mod.ioPz; iz<mod.iePz; iz++) { - tzz[(mod.ioPx-1)*n1+iz] = 0.0; - } - } - } - else { /* Elastic scheme */ - - /* Free surface: calculate free surface conditions for stresses - * Conditions (for upper boundary): - * 1. Tzz = 0 - * 2. Txz = 0 - * 3. Txx: remove term with dVz/dz, computed in e2/e4 routines - * and add extra term with dVx/dx, - * corresponding to free-surface condition for Txx. - * In this way, dVz/dz is not needed in computing Txx - * on the upper stress free boundary. Other boundaries - * are treated similar. - * For the 4th order schemes, the whole virtual boundary - * must be taken into account in the removal terms, - * because the algorithm sets - * velocities on this boundary! - * - * Compute the velocities on the virtual boundary to make interpolation - * possible for receivers. - */ - - if (bnd.top==1) { /* free surface at top */ - izp = bnd.surface[ixo]; -#pragma omp for private (ix, iz) - for (ix=mod.ioPx; ix<mod.iePx; ix++) { - iz = bnd.surface[ix]; - if ( izp==iz ) { - /* clear normal pressure */ - tzz[ix*n1+iz] = 0.0; - /* extra line of txz has to be copied */ -// txz[ix*n1+iz-1] = -txz[ix*n1+iz+2]; - /* This update to Vz might become unstable (2nd order scheme) */ -// vz[ix*n1+iz] = vz[ix*n1+iz+1] - (vx[(ix+1)*n1+iz]-vx[ix*n1+iz])* -// lam[ix*n1+iz]/l2m[ix*n1+iz]; - } - izp=iz; - } - - izp = bnd.surface[ixo]; -#pragma omp for private (ix, iz) - for (ix=mod.ioTx; ix<mod.ieTx; ix++) { - iz = bnd.surface[ix]; - if ( izp==iz ) { - /* assure that txz=0 on boundary by filling virtual boundary */ - txz[ix*n1+iz] = -txz[ix*n1+iz+1]; - /* extra line of txz has to be copied */ - txz[ix*n1+iz-1] = -txz[ix*n1+iz+2]; - } - izp=iz; - } - - /* calculate txx on top stress-free boundary */ - izp = bnd.surface[ixo]; -#pragma omp for private (ix, iz, dp, dvx) - for (ix=mod.ioPx; ix<mod.iePx; ix++) { - iz = bnd.surface[ix]; - if ( izp==iz ) { - dp = l2m[ix*n1+iz]-lam[ix*n1+iz]*lam[ix*n1+iz]/l2m[ix*n1+iz]; - dvx = c1*(vx[(ix+1)*n1+iz] - vx[(ix)*n1+iz]) + - c2*(vx[(ix+2)*n1+iz] - vx[(ix-1)*n1+iz]); - txx[ix*n1+iz] = -dvx*dp; - } - izp=iz; - } - - - /* if surface has also left or right edges */ - izp = bnd.surface[ixo]; -#pragma omp for private (ix, iz, dp, dvz) - for (ix=mod.ioPx+1; ix<mod.iePx; ix++) { - iz = bnd.surface[ix-1]; - if ( izp < iz ) { /* right boundary */ - /* clear normal pressure */ - txx[ix*n1+iz] = 0.0; - if ( (iz-izp) >= 2 ) { /* VR point */ - /* assure that txz=0 on boundary */ - txz[(ix+1)*n1+iz] = -txz[ix*n1+iz]; - txz[(ix+2)*n1+iz] = -txz[(ix-1)*n1+iz] ; - /* calculate tzz on right stress-free boundary */ - dvz = c1*(vz[ix*n1+iz+1] - vz[ix*n1+iz]) + - c2*(vz[ix*n1+iz+2] - vz[ix*n1+iz-1]); - dp = l2m[ix*n1+iz]-lam[ix*n1+iz]*lam[ix*n1+iz]/l2m[ix*n1+iz]; - tzz[ix*n1+iz] = -dvz*dp; - } - else { - // if (izp) { /* IR point */ - // txz[ix*n1+iz] = -txz[ix*n1+iz+1] ; - // txz[ix*n1+iz-1] = -txz[ix*n1+iz+2]; - txz[(ix+1)*n1+iz] = -txz[ix*n1+iz]; - txz[(ix+2)*n1+iz] = -txz[(ix-1)*n1+iz] ; - tzz[ix*n1+iz] = 0.0; - // } - // else { /* OR point */ - txz[(ix-1)*n1+iz] = 0.0; - txz[(ix+1)*n1+iz] = -txz[ix*n1+iz]; - txz[(ix+2)*n1+iz] = -txz[(ix-1)*n1+iz] ; - vz[ix*n1+iz] = vz[ix*n1+iz+1] - (vx[(ix+1)*n1+iz]-vx[ix*n1+iz])* - lam[ix*n1+iz]/l2m[ix*n1+iz]; - // } - } - - } /* end if right */ - if ( izp > iz ) { /* left boundary */ - /* clear normal pressure */ - txx[ix*n1+iz] = 0.0; - /* assure that txz=0 on boundary */ - txz[(ix-1)*n1+iz] = -txz[ix*n1+iz]; - /* extra line of txz has to be copied */ - txz[(ix-2)*n1+iz] = -txz[(ix+1)*n1+iz] ; - /* calculate tzz on left stress-free boundary */ - dvz = c1*(vz[ix*n1+iz+1] - vz[ix*n1+iz]) + - c2*(vz[ix*n1+iz+2] - vz[ix*n1+iz-1]); - dp = l2m[ix*n1+iz]-lam[ix*n1+iz]*lam[ix*n1+iz]/l2m[ix*n1+iz]; - tzz[ix*n1+iz] = -dvz*dp; - } /* end if left */ - izp=iz; - // izp=bnd.surface[MAX(ix-2,0)];; - } /* end ix loop */ - } - - - if (bnd.rig==1) { /* free surface at right */ - ix = mod.iePx; -#pragma omp for private (ix, iz) - for (iz=mod.ioPz; iz<mod.iePz; iz++) { - /* clear normal pressure */ - txx[(ix)*n1+iz] = 0.0; - } -#pragma omp for private (ix, iz) - for (iz=mod.ioTz; iz<mod.ieTz; iz++) { - /* assure that txz=0 on boundary by filling virtual boundary */ - txz[(ix+1)*n1+iz] = -txz[(ix)*n1+iz]; - /* extra line of txz has to be copied */ - txz[(ix+2)*n1+iz] = -txz[(ix-1)*n1+iz] ; - } - /* calculate tzz on right stress-free boundary */ -#pragma omp for private (iz) - for (iz=mod.ioPz; iz<mod.iePz; iz++) { - dvz = c1*(vz[(ix)*n1+iz+1] - vz[(ix)*n1+iz]) + - c2*(vz[(ix)*n1+iz+2] - vz[(ix)*n1+iz-1]); - dp = l2m[(ix)*n1+iz]-lam[(ix)*n1+iz]*lam[(ix)*n1+iz]/l2m[(ix)*n1+iz]; - tzz[(ix)*n1+iz] = -dvz*dp; - } - } - - - if (bnd.bot==1) { /* free surface at bottom */ - iz = mod.iePz; -#pragma omp for private (ix) - for (ix=mod.ioPx; ix<mod.iePx; ix++) { - /* clear normal pressure */ - tzz[ix*n1+iz] = 0.0; - } -#pragma omp for private (ix) - for (ix=mod.ioTx; ix<mod.ieTx; ix++) { - /* assure that txz=0 on boundary by filling virtual boundary */ - txz[ix*n1+iz+1] = -txz[ix*n1+iz]; - /* extra line of txz has to be copied */ - txz[ix*n1+iz+2] = -txz[ix*n1+iz-1]; - } - /* calculate txx on bottom stress-free boundary */ -#pragma omp for private (ix) - for (ix=mod.ioPx; ix<mod.iePx; ix++) { - dvx = c1*(vx[(ix+1)*n1+iz] - vx[ix*n1+iz]) + - c2*(vx[(ix+2)*n1+iz] - vx[(ix-1)*n1+iz]); - dp = l2m[ix*n1+iz]-lam[ix*n1+iz]*lam[ix*n1+iz]/l2m[ix*n1+iz]; - txx[ix*n1+iz] = -dvx*dp; - } - } - - if (bnd.lef==1) { /* free surface at left */ - ix = mod.ioPx; -#pragma omp for private (iz) - for (iz=mod.ioPz; iz<mod.iePz; iz++) { - /* clear normal pressure */ - txx[ix*n1+iz] = 0.0; - } -#pragma omp for private (iz) - for (iz=mod.ioTz; iz<mod.ieTz; iz++) { - /* assure that txz=0 on boundary by filling virtual boundary */ - txz[(ix)*n1+iz] = -txz[(ix+1)*n1+iz]; - /* extra line of txz has to be copied */ - txz[(ix-1)*n1+iz] = -txz[(ix+2)*n1+iz] ; - } - /* calculate tzz on left stress-free boundary */ -#pragma omp for private (iz) - for (iz=mod.ioPz; iz<mod.iePz; iz++) { - dvz = c1*(vz[ix*n1+iz+1] - vz[ix*n1+iz]) + - c2*(vz[ix*n1+iz+2] - vz[ix*n1+iz-1]); - dp = l2m[ix*n1+iz]-lam[ix*n1+iz]*lam[ix*n1+iz]/l2m[ix*n1+iz]; - tzz[ix*n1+iz] = -dvz*dp; - } - } - - - } - - - - - return 0; -} diff --git a/fdelmodc/boundaries.c.ok3 b/fdelmodc/boundaries.c.ok3 deleted file mode 100644 index 0bcfc586bfc0454350bf09363c3dd2569ff3ac20..0000000000000000000000000000000000000000 --- a/fdelmodc/boundaries.c.ok3 +++ /dev/null @@ -1,1057 +0,0 @@ -#include<stdlib.h> -#include<stdio.h> -#include<math.h> -#include<assert.h> -#include"fdelmodc.h" - -float *exL, *exR, *eyT, *eyB; -int first=0; - -int boundariesP(modPar mod, bndPar bnd, float *vx, float *vz, float *tzz, float *txx, float *txz, float *rox, float *roz, float *l2m, float *lam, float *mul, int verbose) -{ -/********************************************************************* - - AUTHOR: - Jan Thorbecke (janth@xs4all.nl) - The Netherlands - -***********************************************************************/ - - float c1, c2; - float dp, dvx, dvz; - int ix, iz, ixs, izs, ibnd, ib, ibx, ibz; - int nx, nz, n1; - int is0, isrc; - int ixo, ixe, izo, ize; - - - c1 = 9.0/8.0; - c2 = -1.0/24.0; - nx = mod.nx; - nz = mod.nz; - n1 = mod.naz; - - ibnd = mod.iorder/2-1; - -/************************************************************/ -/* rigid boundary condition clears velocities on boundaries */ -/************************************************************/ - - if (bnd.top==3) { /* rigid surface at top */ -#pragma omp for private (ix, iz) nowait -#pragma ivdep - for (ix=1; ix<=nx; ix++) { - vx[ix*n1+ibnd] = 0.0; - vz[ix*n1+ibnd] = -vz[ix*n1+ibnd+1]; - if (mod.iorder >= 4) vz[ix*n1+ibnd-1] = -vz[ix*n1+ibnd+2]; - if (mod.iorder >= 6) vz[ix*n1+ibnd-2] = -vz[ix*n1+ibnd+3]; - } - } - if (bnd.rig==3) { /* rigid surface at right */ -#pragma omp for private (ix, iz) nowait -#pragma ivdep - for (iz=1; iz<=nz; iz++) { - vz[(nx+ibnd-1)*n1+iz] = 0.0; - vx[(nx+ibnd)*n1+iz] = -vx[(nx+ibnd-1)*n1+iz]; - if (mod.iorder == 4) vx[(nx+2)*n1+iz] = -vx[(nx-1)*n1+iz]; - if (mod.iorder == 6) { - vx[(nx+1)*n1+iz] = -vx[(nx)*n1+iz]; - vx[(nx+3)*n1+iz] = -vx[(nx-2)*n1+iz]; - } - } - } - if (bnd.bot==3) { /* rigid surface at bottom */ -#pragma omp for private (ix, iz) nowait -#pragma ivdep - for (ix=1; ix<=nx; ix++) { - vx[ix*n1+nz+ibnd-1] = 0.0; - vz[ix*n1+nz+ibnd] = -vz[ix*n1+nz+ibnd-1]; - if (mod.iorder == 4) vz[ix*n1+nz+2] = -vz[ix*n1+nz-1]; - if (mod.iorder == 6) { - vz[ix*n1+nz+1] = -vz[ix*n1+nz]; - vz[ix*n1+nz+3] = -vz[ix*n1+nz-2]; - } - } - } - if (bnd.lef==3) { /* rigid surface at left */ -#pragma omp for private (ix, iz) nowait -#pragma ivdep - for (iz=1; iz<=nz; iz++) { - vz[ibnd*n1+iz] = 0.0; - vx[ibnd*n1+iz] = -vx[(ibnd+1)*n1+iz]; - if (mod.iorder == 4) vx[0*n1+iz] = -vx[3*n1+iz]; - if (mod.iorder == 6) { - vx[1*n1+iz] = -vx[4*n1+iz]; - vx[0*n1+iz] = -vx[5*n1+iz]; - } - } - } - -/************************************************************/ -/* PML boundaries : only for acoustic 4th order scheme */ -/************************************************************/ - - if (bnd.top==2) { /* PML at top */ - } - -/************************************************************/ -/* Tapered boundaries for both elastic and acoustic schemes */ -/* compute all field values in tapered areas */ -/************************************************************/ - - /*********/ - /* Top */ - /*********/ - if (bnd.top==4) { - - if (mod.ischeme <= 2) { /* Acoustic scheme */ - - /* Vx field */ - ixo = mod.ioXx; - ixe = mod.ieXx; - izo = mod.ioXz-bnd.ntap; - ize = mod.ioXz; - - ib = (bnd.ntap+izo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[(ix-1)*n1+iz]) + - c2*(tzz[(ix+1)*n1+iz] - tzz[(ix-2)*n1+iz])); - - vx[ix*n1+iz] *= bnd.tapx[ib-iz]; - } - } - /* right top corner */ - if (bnd.rig==4) { - ixo = mod.ieXx; - ixe = ixo+bnd.ntap; - ibz = (bnd.ntap+izo-1); - ibx = (ixo); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[(ix-1)*n1+iz]) + - c2*(tzz[(ix+1)*n1+iz] - tzz[(ix-2)*n1+iz])); - - vx[ix*n1+iz] *= bnd.tapxz[(ix-ibx)*bnd.ntap+(ibz-iz)]; - } - } - } - /* left top corner */ - if (bnd.lef==4) { - ixo = mod.ioXx-bnd.ntap; - ixe = mod.ioXx; - ibz = (bnd.ntap+izo-1); - ibx = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[(ix-1)*n1+iz]) + - c2*(tzz[(ix+1)*n1+iz] - tzz[(ix-2)*n1+iz])); - - vx[ix*n1+iz] *= bnd.tapxz[(ibx-ix)*bnd.ntap+(ibz-iz)]; - } - } - } - - - /* Vz field */ - ixo = mod.ioZx; - ixe = mod.ieZx; - izo = mod.ioZz-bnd.ntap; - ize = mod.ioZz; - - ib = (bnd.ntap+izo-1); -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2])); - - vz[ix*n1+iz] *= bnd.tapz[ib-iz]; - } - } - /* right top corner */ - if (bnd.rig==4) { - ixo = mod.ieZx; - ixe = ixo+bnd.ntap; - ibz = (bnd.ntap+izo-1); - ibx = (ixo); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2])); - - vz[ix*n1+iz] *= bnd.tapxz[(ix-ibx)*bnd.ntap+(ibz-iz)]; - } - } - } - /* left top corner */ - if (bnd.lef==4) { - ixo = mod.ioZx-bnd.ntap; - ixe = mod.ioZx; - ibz = (bnd.ntap+izo-1); - ibx = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2])); - - vz[ix*n1+iz] *= bnd.tapxz[(ibx-ix)*bnd.ntap+(ibz-iz)]; - } - } - } - - } - else { /* Elastic scheme */ - - /* Vx field */ - ixo = mod.ioXx; - ixe = mod.ieXx; - izo = mod.ioXz-bnd.ntap; - ize = mod.ioXz; - - ib = (bnd.ntap+izo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(txx[ix*n1+iz] - txx[(ix-1)*n1+iz] + - txz[ix*n1+iz+1] - txz[ix*n1+iz]) + - c2*(txx[(ix+1)*n1+iz] - txx[(ix-2)*n1+iz] + - txz[ix*n1+iz+2] - txz[ix*n1+iz-1]) ); - - vx[ix*n1+iz] *= bnd.tapx[ib-iz]; - } - } - /* right top corner */ - if (bnd.rig==4) { - ixo = mod.ieXx; - ixe = ixo+bnd.ntap; - ibz = (bnd.ntap+izo-1); - ibx = (ixo); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(txx[ix*n1+iz] - txx[(ix-1)*n1+iz] + - txz[ix*n1+iz+1] - txz[ix*n1+iz]) + - c2*(txx[(ix+1)*n1+iz] - txx[(ix-2)*n1+iz] + - txz[ix*n1+iz+2] - txz[ix*n1+iz-1]) ); - - vx[ix*n1+iz] *= bnd.tapxz[(ix-ibx)*bnd.ntap+(ibz-iz)]; - } - } - } - /* left top corner */ - if (bnd.lef==4) { - ixo = mod.ioXx-bnd.ntap; - ixe = mod.ioXx; - ibz = (bnd.ntap+izo-1); - ibx = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(txx[ix*n1+iz] - txx[(ix-1)*n1+iz] + - txz[ix*n1+iz+1] - txz[ix*n1+iz]) + - c2*(txx[(ix+1)*n1+iz] - txx[(ix-2)*n1+iz] + - txz[ix*n1+iz+2] - txz[ix*n1+iz-1]) ); - - vx[ix*n1+iz] *= bnd.tapxz[(ibx-ix)*bnd.ntap+(ibz-iz)]; - } - } - } - - /* Vz field */ - ixo = mod.ioZx; - ixe = mod.ieZx; - izo = mod.ioZz-bnd.ntap; - ize = mod.ioZz; - - ib = (bnd.ntap+izo-1); -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1] + - txz[(ix+1)*n1+iz] - txz[ix*n1+iz]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2] + - txz[(ix+2)*n1+iz] - txz[(ix-1)*n1+iz]) ); - - vz[ix*n1+iz] *= bnd.tapz[ib-iz]; - } - } - /* right top corner */ - if (bnd.rig==4) { - ixo = mod.ieZx; - ixe = ixo+bnd.ntap; - ibz = (bnd.ntap+izo-1); - ibx = (ixo); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1] + - txz[(ix+1)*n1+iz] - txz[ix*n1+iz]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2] + - txz[(ix+2)*n1+iz] - txz[(ix-1)*n1+iz]) ); - - vz[ix*n1+iz] *= bnd.tapxz[(ix-ibx)*bnd.ntap+(ibz-iz)]; - } - } - } - /* left top corner */ - if (bnd.lef==4) { - ixo = mod.ioZx-bnd.ntap; - ixe = mod.ioZx; - ibz = (bnd.ntap+izo-1); - ibx = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1] + - txz[(ix+1)*n1+iz] - txz[ix*n1+iz]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2] + - txz[(ix+2)*n1+iz] - txz[(ix-1)*n1+iz]) ); - - vz[ix*n1+iz] *= bnd.tapxz[(ibx-ix)*bnd.ntap+(ibz-iz)]; - } - } - } - - - } /* end elastic scheme */ - } - - /*********/ - /* Bottom */ - /*********/ - if (bnd.bot==4) { - - if (mod.ischeme <= 2) { /* Acoustic scheme */ - - /* Vx field */ - ixo = mod.ioXx; - ixe = mod.ieXx; - izo = mod.ieXz; - ize = mod.ieXz+bnd.ntap; - - ib = (ize-bnd.ntap); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[(ix-1)*n1+iz]) + - c2*(tzz[(ix+1)*n1+iz] - tzz[(ix-2)*n1+iz])); - vx[ix*n1+iz] *= bnd.tapx[iz-ib]; - } - } - /* right bottom corner */ - if (bnd.rig==4) { - ixo = mod.ieXx; - ixe = ixo+bnd.ntap; - ibz = (izo); - ibx = (ixo); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[(ix-1)*n1+iz]) + - c2*(tzz[(ix+1)*n1+iz] - tzz[(ix-2)*n1+iz])); - - vx[ix*n1+iz] *= bnd.tapxz[(ix-ibx)*bnd.ntap+(iz-ibz)]; - } - } - } - /* left bottom corner */ - if (bnd.lef==4) { - ixo = mod.ioXx-bnd.ntap; - ixe = mod.ioXx; - ibz = (izo); - ibx = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[(ix-1)*n1+iz]) + - c2*(tzz[(ix+1)*n1+iz] - tzz[(ix-2)*n1+iz])); - - vx[ix*n1+iz] *= bnd.tapxz[(ibx-ix)*bnd.ntap+(iz-ibz)]; - } - } - } - - - /* Vz field */ - ixo = mod.ioZx; - ixe = mod.ieZx; - izo = mod.ieZz; - ize = mod.ieZz+bnd.ntap; - - ib = (ize-bnd.ntap); -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2])); - vz[ix*n1+iz] *= bnd.tapz[iz-ib]; - } - } - /* right bottom corner */ - if (bnd.rig==4) { - ixo = mod.ieZx; - ixe = ixo+bnd.ntap; - ibz = (izo); - ibx = (ixo); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2])); - - vz[ix*n1+iz] *= bnd.tapxz[(ix-ibx)*bnd.ntap+(iz-ibz)]; - } - } - } - /* left bottom corner */ - if (bnd.lef==4) { - ixo = mod.ioZx-bnd.ntap; - ixe = mod.ioZx; - ibz = (izo); - ibx = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2])); - - vz[ix*n1+iz] *= bnd.tapxz[(ibx-ix)*bnd.ntap+(iz-ibz)]; - } - } - } - - - } - else { /* Elastic scheme */ - - /* Vx field */ - ixo = mod.ioXx; - ixe = mod.ieXx; - izo = mod.ieXz; - ize = mod.ieXz+bnd.ntap; - - ib = (ize-bnd.ntap); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(txx[ix*n1+iz] - txx[(ix-1)*n1+iz] + - txz[ix*n1+iz+1] - txz[ix*n1+iz]) + - c2*(txx[(ix+1)*n1+iz] - txx[(ix-2)*n1+iz] + - txz[ix*n1+iz+2] - txz[ix*n1+iz-1]) ); - - vx[ix*n1+iz] *= bnd.tapx[iz-ib]; - } - } - /* right bottom corner */ - if (bnd.rig==4) { - ixo = mod.ieXx; - ixe = ixo+bnd.ntap; - ibz = (izo); - ibx = (ixo); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(txx[ix*n1+iz] - txx[(ix-1)*n1+iz] + - txz[ix*n1+iz+1] - txz[ix*n1+iz]) + - c2*(txx[(ix+1)*n1+iz] - txx[(ix-2)*n1+iz] + - txz[ix*n1+iz+2] - txz[ix*n1+iz-1]) ); - - vx[ix*n1+iz] *= bnd.tapxz[(ix-ibx)*bnd.ntap+(iz-ibz)]; - } - } - } - /* left bottom corner */ - if (bnd.lef==4) { - - - ixo = mod.ioXx-bnd.ntap; - ixe = mod.ioXx; - ibz = (izo); - ibx = (bnd.ntap+ixo-1); - - -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(txx[ix*n1+iz] - txx[(ix-1)*n1+iz] + - txz[ix*n1+iz+1] - txz[ix*n1+iz]) + - c2*(txx[(ix+1)*n1+iz] - txx[(ix-2)*n1+iz] + - txz[ix*n1+iz+2] - txz[ix*n1+iz-1]) ); - - vx[ix*n1+iz] *= bnd.tapxz[(ibx-ix)*bnd.ntap+(iz-ibz)]; - } - } - } - - /* Vz field */ - ixo = mod.ioZx; - ixe = mod.ieZx; - izo = mod.ieZz; - ize = mod.ieZz+bnd.ntap; - - ib = (ize-bnd.ntap); -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1] + - txz[(ix+1)*n1+iz] - txz[ix*n1+iz]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2] + - txz[(ix+2)*n1+iz] - txz[(ix-1)*n1+iz]) ); - - vz[ix*n1+iz] *= bnd.tapz[iz-ib]; - } - } - /* right bottom corner */ - if (bnd.rig==4) { - ixo = mod.ieZx; - ixe = ixo+bnd.ntap; - ibz = (izo); - ibx = (ixo); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1] + - txz[(ix+1)*n1+iz] - txz[ix*n1+iz]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2] + - txz[(ix+2)*n1+iz] - txz[(ix-1)*n1+iz]) ); - - vz[ix*n1+iz] *= bnd.tapxz[(ix-ibx)*bnd.ntap+(iz-ibz)]; - } - } - } - /* left bottom corner */ - if (bnd.lef==4) { - ixo = mod.ioZx-bnd.ntap; - ixe = mod.ioZx; - ibz = (izo); - ibx = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1] + - txz[(ix+1)*n1+iz] - txz[ix*n1+iz]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2] + - txz[(ix+2)*n1+iz] - txz[(ix-1)*n1+iz]) ); - - vz[ix*n1+iz] *= bnd.tapxz[(ibx-ix)*bnd.ntap+(iz-ibz)]; - } - } - } - - - } /* end elastic scheme */ - - } - - /*********/ - /* Left */ - /*********/ - if (bnd.lef==4) { - - if (mod.ischeme <= 2) { /* Acoustic scheme */ - - /* Vx field */ - ixo = mod.ioXx-bnd.ntap; - ixe = mod.ioXx; - izo = mod.ioXz; - ize = mod.ieXz; - - ib = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[(ix-1)*n1+iz]) + - c2*(tzz[(ix+1)*n1+iz] - tzz[(ix-2)*n1+iz])); - - vx[ix*n1+iz] *= bnd.tapx[ib-ix]; - } - } - - /* Vz field */ - ixo = mod.ioZx-bnd.ntap; - ixe = mod.ioZx; - izo = mod.ioZz; - ize = mod.ieZz; - - ib = (bnd.ntap+ixo-1); -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2])); - - vz[ix*n1+iz] *= bnd.tapz[ib-ix]; - } - } - - } - else { /* Elastic scheme */ - - /* Vx field */ - ixo = mod.ioXx-bnd.ntap; - ixe = mod.ioXx; - izo = mod.ioXz; - ize = mod.ieXz; - - ib = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(txx[ix*n1+iz] - txx[(ix-1)*n1+iz] + - txz[ix*n1+iz+1] - txz[ix*n1+iz]) + - c2*(txx[(ix+1)*n1+iz] - txx[(ix-2)*n1+iz] + - txz[ix*n1+iz+2] - txz[ix*n1+iz-1]) ); - - vx[ix*n1+iz] *= bnd.tapx[ib-ix]; - } - } - - /* Vz field */ - ixo = mod.ioZx-bnd.ntap; - ixe = mod.ioZx; - izo = mod.ioZz; - ize = mod.ieZz; - - ib = (bnd.ntap+ixo-1); -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1] + - txz[(ix+1)*n1+iz] - txz[ix*n1+iz]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2] + - txz[(ix+2)*n1+iz] - txz[(ix-1)*n1+iz]) ); - - vz[ix*n1+iz] *= bnd.tapz[ib-ix]; - } - } - } /* end elastic scheme */ - - } - - /*********/ - /* Right */ - /*********/ - if (bnd.rig==4) { - - if (mod.ischeme <= 2) { /* Acoustic scheme */ - - /* Vx field */ - ixo = mod.ieXx; - ixe = mod.ieXx+bnd.ntap; - izo = mod.ioXz; - ize = mod.ieXz; - - ib = (ixe-bnd.ntap); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[(ix-1)*n1+iz]) + - c2*(tzz[(ix+1)*n1+iz] - tzz[(ix-2)*n1+iz])); - - vx[ix*n1+iz] *= bnd.tapx[ix-ib]; - } - } - - /* Vz field */ - ixo = mod.ieZx; - ixe = mod.ieZx+bnd.ntap; - izo = mod.ioZz; - ize = mod.ieZz; - - ib = (ixe-bnd.ntap); -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2])); - - vz[ix*n1+iz] *= bnd.tapz[ix-ib]; - } - } - - } - else { /* Elastic scheme */ - - /* Vx field */ - ixo = mod.ieXx; - ixe = mod.ieXx+bnd.ntap; - izo = mod.ioXz; - ize = mod.ieXz; - - ib = (ixe-bnd.ntap); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(txx[ix*n1+iz] - txx[(ix-1)*n1+iz] + - txz[ix*n1+iz+1] - txz[ix*n1+iz]) + - c2*(txx[(ix+1)*n1+iz] - txx[(ix-2)*n1+iz] + - txz[ix*n1+iz+2] - txz[ix*n1+iz-1]) ); - - vx[ix*n1+iz] *= bnd.tapx[ix-ib]; - } - } - - /* Vz field */ - ixo = mod.ieZx; - ixe = mod.ieZx+bnd.ntap; - izo = mod.ioZz; - ize = mod.ieZz; - - ib = (ixe-bnd.ntap); -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1] + - txz[(ix+1)*n1+iz] - txz[ix*n1+iz]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2] + - txz[(ix+2)*n1+iz] - txz[(ix-1)*n1+iz]) ); - - vz[ix*n1+iz] *= bnd.tapz[ix-ib]; - } - } - - } /* end elastic scheme */ - - } - - - return 0; -} - -int boundariesV(modPar mod, bndPar bnd, float *vx, float *vz, float *tzz, float *txx, float *txz, float *rox, float *roz, float *l2m, float *lam, float *mul, int verbose) -{ -/********************************************************************* - - AUTHOR: - Jan Thorbecke (janth@xs4all.nl) - The Netherlands - -***********************************************************************/ - - float c1, c2; - float dp, dvx, dvz; - int ix, iz, ixs, izs, izp; - int n1; - int is0, isrc; - int ixo, ixe, izo, ize; - - c1 = 9.0/8.0; - c2 = -1.0/24.0; - n1 = mod.naz; - -/************************************************************/ -/* Tapered boundaries for both elastic and acoustic schemes */ -/* compute all field values in tapered areas */ -/************************************************************/ - - -/****************************************************************/ -/* Free surface: calculate free surface conditions for stresses */ -/****************************************************************/ - - - ixo = mod.ioPx; - ixe = mod.iePx; - izo = mod.ioPz; - ize = mod.iePz; - - if (mod.ischeme <= 2) { /* Acoustic scheme */ - - if (bnd.top==1) { /* free surface at top */ -#pragma omp for private (ix) nowait - for (ix=mod.ioPx; ix<mod.iePx; ix++) { - iz = bnd.surface[ix]; - tzz[ix*n1+iz] = 0.0; - } - } - if (bnd.rig==1) { /* free surface at right */ -#pragma omp for private (iz) nowait - for (iz=mod.ioPz; iz<mod.iePz; iz++) { - tzz[(mod.iePx-1)*n1+iz] = 0.0; - } - } - if (bnd.bot==1) { /* free surface at bottom */ -#pragma omp for private (ix) nowait - for (ix=mod.ioPx; ix<mod.iePx; ix++) { - tzz[ix*n1+mod.iePz-1] = 0.0; - } - } - if (bnd.lef==1) { /* free surface at left */ -#pragma omp for private (iz) nowait - for (iz=mod.ioPz; iz<mod.iePz; iz++) { - tzz[(mod.ioPx-1)*n1+iz] = 0.0; - } - } - } - else { /* Elastic scheme */ - - /* Free surface: calculate free surface conditions for stresses - * Conditions (for upper boundary): - * 1. Tzz = 0 - * 2. Txz = 0 - * 3. Txx: remove term with dVz/dz, computed in e2/e4 routines - * and add extra term with dVx/dx, - * corresponding to free-surface condition for Txx. - * In this way, dVz/dz is not needed in computing Txx - * on the upper stress free boundary. Other boundaries - * are treated similar. - * For the 4th order schemes, the whole virtual boundary - * must be taken into account in the removal terms, - * because the algorithm sets - * velocities on this boundary! - * - * Compute the velocities on the virtual boundary to make interpolation - * possible for receivers. - */ - - if (bnd.top==1) { /* free surface at top */ - izp = bnd.surface[ixo]; -#pragma omp for private (ix, iz) - for (ix=mod.ioPx; ix<mod.iePx; ix++) { - iz = bnd.surface[ix]; - if ( izp==iz ) { - /* clear normal pressure */ - tzz[ix*n1+iz] = 0.0; - /* extra line of txz has to be copied */ -// txz[ix*n1+iz-1] = -txz[ix*n1+iz+2]; - /* This update to Vz might become unstable (2nd order scheme) */ -// vz[ix*n1+iz] = vz[ix*n1+iz+1] - (vx[(ix+1)*n1+iz]-vx[ix*n1+iz])* -// lam[ix*n1+iz]/l2m[ix*n1+iz]; - } - izp=iz; - } - - izp = bnd.surface[ixo]; -#pragma omp for private (ix, iz) - for (ix=mod.ioTx; ix<mod.ieTx; ix++) { - iz = bnd.surface[ix]; - if ( izp==iz ) { - /* assure that txz=0 on boundary by filling virtual boundary */ - txz[ix*n1+iz] = -txz[ix*n1+iz+1]; - /* extra line of txz has to be copied */ - txz[ix*n1+iz-1] = -txz[ix*n1+iz+2]; - } - izp=iz; - } - - /* calculate txx on top stress-free boundary */ - izp = bnd.surface[ixo]; -#pragma omp for private (ix, iz, dp, dvx) - for (ix=mod.ioPx; ix<mod.iePx; ix++) { - iz = bnd.surface[ix]; - if ( izp==iz ) { - dp = l2m[ix*n1+iz]-lam[ix*n1+iz]*lam[ix*n1+iz]/l2m[ix*n1+iz]; - dvx = c1*(vx[(ix+1)*n1+iz] - vx[(ix)*n1+iz]) + - c2*(vx[(ix+2)*n1+iz] - vx[(ix-1)*n1+iz]); - txx[ix*n1+iz] = -dvx*dp; - } - izp=iz; - } - - - /* if surface has also left or right edges */ - izp = bnd.surface[ixo]; -#pragma omp for private (ix, iz, dp, dvz) - for (ix=mod.ioPx+1; ix<mod.iePx; ix++) { - iz = bnd.surface[ix-1]; - if ( izp < iz ) { /* right boundary */ - /* clear normal pressure */ - txx[ix*n1+iz] = 0.0; - if ( (iz-izp) >= 2 ) { /* VR point */ - /* assure that txz=0 on boundary */ - txz[(ix+1)*n1+iz] = -txz[ix*n1+iz]; - txz[(ix+2)*n1+iz] = -txz[(ix-1)*n1+iz] ; - /* calculate tzz on right stress-free boundary */ - dvz = c1*(vz[ix*n1+iz+1] - vz[ix*n1+iz]) + - c2*(vz[ix*n1+iz+2] - vz[ix*n1+iz-1]); - dp = l2m[ix*n1+iz]-lam[ix*n1+iz]*lam[ix*n1+iz]/l2m[ix*n1+iz]; - tzz[ix*n1+iz] = -dvz*dp; - } - else { - // if (izp) { /* IR point */ - // txz[ix*n1+iz] = -txz[ix*n1+iz+1] ; - // txz[ix*n1+iz-1] = -txz[ix*n1+iz+2]; - txz[(ix+1)*n1+iz] = -txz[ix*n1+iz]; - txz[(ix+2)*n1+iz] = -txz[(ix-1)*n1+iz] ; - tzz[ix*n1+iz] = 0.0; - // } - // else { /* OR point */ - txz[(ix-1)*n1+iz] = 0.0; - txz[(ix+1)*n1+iz] = -txz[ix*n1+iz]; - txz[(ix+2)*n1+iz] = -txz[(ix-1)*n1+iz] ; - vz[ix*n1+iz] = vz[ix*n1+iz+1] - (vx[(ix+1)*n1+iz]-vx[ix*n1+iz])* - lam[ix*n1+iz]/l2m[ix*n1+iz]; - // } - } - - } /* end if right */ - if ( izp > iz ) { /* left boundary */ - /* clear normal pressure */ - txx[ix*n1+iz] = 0.0; - /* assure that txz=0 on boundary */ - txz[(ix-1)*n1+iz] = -txz[ix*n1+iz]; - /* extra line of txz has to be copied */ - txz[(ix-2)*n1+iz] = -txz[(ix+1)*n1+iz] ; - /* calculate tzz on left stress-free boundary */ - dvz = c1*(vz[ix*n1+iz+1] - vz[ix*n1+iz]) + - c2*(vz[ix*n1+iz+2] - vz[ix*n1+iz-1]); - dp = l2m[ix*n1+iz]-lam[ix*n1+iz]*lam[ix*n1+iz]/l2m[ix*n1+iz]; - tzz[ix*n1+iz] = -dvz*dp; - } /* end if left */ - izp=iz; - // izp=bnd.surface[MAX(ix-2,0)];; - } /* end ix loop */ - } - - - if (bnd.rig==1) { /* free surface at right */ - ix = mod.iePx; -#pragma omp for private (ix, iz) - for (iz=mod.ioPz; iz<mod.iePz; iz++) { - /* clear normal pressure */ - txx[(ix)*n1+iz] = 0.0; - } -#pragma omp for private (ix, iz) - for (iz=mod.ioTz; iz<mod.ieTz; iz++) { - /* assure that txz=0 on boundary by filling virtual boundary */ - txz[(ix+1)*n1+iz] = -txz[(ix)*n1+iz]; - /* extra line of txz has to be copied */ - txz[(ix+2)*n1+iz] = -txz[(ix-1)*n1+iz] ; - } - /* calculate tzz on right stress-free boundary */ -#pragma omp for private (iz) - for (iz=mod.ioPz; iz<mod.iePz; iz++) { - dvz = c1*(vz[(ix)*n1+iz+1] - vz[(ix)*n1+iz]) + - c2*(vz[(ix)*n1+iz+2] - vz[(ix)*n1+iz-1]); - dp = l2m[(ix)*n1+iz]-lam[(ix)*n1+iz]*lam[(ix)*n1+iz]/l2m[(ix)*n1+iz]; - tzz[(ix)*n1+iz] = -dvz*dp; - } - } - - - if (bnd.bot==1) { /* free surface at bottom */ - iz = mod.iePz; -#pragma omp for private (ix) - for (ix=mod.ioPx; ix<mod.iePx; ix++) { - /* clear normal pressure */ - tzz[ix*n1+iz] = 0.0; - } -#pragma omp for private (ix) - for (ix=mod.ioTx; ix<mod.ieTx; ix++) { - /* assure that txz=0 on boundary by filling virtual boundary */ - txz[ix*n1+iz+1] = -txz[ix*n1+iz]; - /* extra line of txz has to be copied */ - txz[ix*n1+iz+2] = -txz[ix*n1+iz-1]; - } - /* calculate txx on bottom stress-free boundary */ -#pragma omp for private (ix) - for (ix=mod.ioPx; ix<mod.iePx; ix++) { - dvx = c1*(vx[(ix+1)*n1+iz] - vx[ix*n1+iz]) + - c2*(vx[(ix+2)*n1+iz] - vx[(ix-1)*n1+iz]); - dp = l2m[ix*n1+iz]-lam[ix*n1+iz]*lam[ix*n1+iz]/l2m[ix*n1+iz]; - txx[ix*n1+iz] = -dvx*dp; - } - } - - if (bnd.lef==1) { /* free surface at left */ - ix = mod.ioPx; -#pragma omp for private (iz) - for (iz=mod.ioPz; iz<mod.iePz; iz++) { - /* clear normal pressure */ - txx[ix*n1+iz] = 0.0; - } -#pragma omp for private (iz) - for (iz=mod.ioTz; iz<mod.ieTz; iz++) { - /* assure that txz=0 on boundary by filling virtual boundary */ - txz[(ix)*n1+iz] = -txz[(ix+1)*n1+iz]; - /* extra line of txz has to be copied */ - txz[(ix-1)*n1+iz] = -txz[(ix+2)*n1+iz] ; - } - /* calculate tzz on left stress-free boundary */ -#pragma omp for private (iz) - for (iz=mod.ioPz; iz<mod.iePz; iz++) { - dvz = c1*(vz[ix*n1+iz+1] - vz[ix*n1+iz]) + - c2*(vz[ix*n1+iz+2] - vz[ix*n1+iz-1]); - dp = l2m[ix*n1+iz]-lam[ix*n1+iz]*lam[ix*n1+iz]/l2m[ix*n1+iz]; - tzz[ix*n1+iz] = -dvz*dp; - } - } - - - } - - - - - return 0; -} diff --git a/fdelmodc/boundaries.c.ok4 b/fdelmodc/boundaries.c.ok4 deleted file mode 100644 index 62cd32d5026724cf74524a148707e137414ec749..0000000000000000000000000000000000000000 --- a/fdelmodc/boundaries.c.ok4 +++ /dev/null @@ -1,1075 +0,0 @@ -#include<stdlib.h> -#include<stdio.h> -#include<math.h> -#include<assert.h> -#include"fdelmodc.h" - -float *exL, *exR, *eyT, *eyB; -int first=0; - -int boundariesP(modPar mod, bndPar bnd, float *vx, float *vz, float *tzz, float *txx, float *txz, float *rox, float *roz, float *l2m, float *lam, float *mul, int verbose) -{ -/********************************************************************* - - AUTHOR: - Jan Thorbecke (janth@xs4all.nl) - The Netherlands - -***********************************************************************/ - - float c1, c2; - float dp, dvx, dvz; - int ix, iz, ixs, izs, ibnd, ib, ibx, ibz; - int nx, nz, n1; - int is0, isrc; - int ixo, ixe, izo, ize; - - - c1 = 9.0/8.0; - c2 = -1.0/24.0; - nx = mod.nx; - nz = mod.nz; - n1 = mod.naz; - - ibnd = mod.iorder/2-1; - -/************************************************************/ -/* rigid boundary condition clears velocities on boundaries */ -/************************************************************/ - - if (bnd.top==3) { /* rigid surface at top */ -#pragma omp for private (ix, iz) nowait -#pragma ivdep - for (ix=1; ix<=nx; ix++) { - vx[ix*n1+ibnd] = 0.0; - vz[ix*n1+ibnd] = -vz[ix*n1+ibnd+1]; - if (mod.iorder >= 4) vz[ix*n1+ibnd-1] = -vz[ix*n1+ibnd+2]; - if (mod.iorder >= 6) vz[ix*n1+ibnd-2] = -vz[ix*n1+ibnd+3]; - } - } - if (bnd.rig==3) { /* rigid surface at right */ -#pragma omp for private (ix, iz) nowait -#pragma ivdep - for (iz=1; iz<=nz; iz++) { - vz[(nx+ibnd-1)*n1+iz] = 0.0; - vx[(nx+ibnd)*n1+iz] = -vx[(nx+ibnd-1)*n1+iz]; - if (mod.iorder == 4) vx[(nx+2)*n1+iz] = -vx[(nx-1)*n1+iz]; - if (mod.iorder == 6) { - vx[(nx+1)*n1+iz] = -vx[(nx)*n1+iz]; - vx[(nx+3)*n1+iz] = -vx[(nx-2)*n1+iz]; - } - } - } - if (bnd.bot==3) { /* rigid surface at bottom */ -#pragma omp for private (ix, iz) nowait -#pragma ivdep - for (ix=1; ix<=nx; ix++) { - vx[ix*n1+nz+ibnd-1] = 0.0; - vz[ix*n1+nz+ibnd] = -vz[ix*n1+nz+ibnd-1]; - if (mod.iorder == 4) vz[ix*n1+nz+2] = -vz[ix*n1+nz-1]; - if (mod.iorder == 6) { - vz[ix*n1+nz+1] = -vz[ix*n1+nz]; - vz[ix*n1+nz+3] = -vz[ix*n1+nz-2]; - } - } - } - if (bnd.lef==3) { /* rigid surface at left */ -#pragma omp for private (ix, iz) nowait -#pragma ivdep - for (iz=1; iz<=nz; iz++) { - vz[ibnd*n1+iz] = 0.0; - vx[ibnd*n1+iz] = -vx[(ibnd+1)*n1+iz]; - if (mod.iorder == 4) vx[0*n1+iz] = -vx[3*n1+iz]; - if (mod.iorder == 6) { - vx[1*n1+iz] = -vx[4*n1+iz]; - vx[0*n1+iz] = -vx[5*n1+iz]; - } - } - } - -/************************************************************/ -/* PML boundaries : only for acoustic 4th order scheme */ -/************************************************************/ - - if (bnd.top==2) { /* PML at top */ - } - -/************************************************************/ -/* Tapered boundaries for both elastic and acoustic schemes */ -/* compute all field values in tapered areas */ -/************************************************************/ - - /*********/ - /* Top */ - /*********/ - if (bnd.top==4) { - - if (mod.ischeme <= 2) { /* Acoustic scheme */ - - /* Vx field */ - ixo = mod.ioXx; - ixe = mod.ieXx; - izo = mod.ioXz-bnd.ntap; - ize = mod.ioXz; - - ib = (bnd.ntap+izo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[(ix-1)*n1+iz]) + - c2*(tzz[(ix+1)*n1+iz] - tzz[(ix-2)*n1+iz])); - - vx[ix*n1+iz] *= bnd.tapx[ib-iz]; - } - } - /* right top corner */ - if (bnd.rig==4) { - ixo = mod.ieXx; - ixe = ixo+bnd.ntap; - ibz = (bnd.ntap+izo-1); - ibx = (ixo); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[(ix-1)*n1+iz]) + - c2*(tzz[(ix+1)*n1+iz] - tzz[(ix-2)*n1+iz])); - - vx[ix*n1+iz] *= bnd.tapxz[(ix-ibx)*bnd.ntap+(ibz-iz)]; - } - } - } - /* left top corner */ - if (bnd.lef==4) { - ixo = mod.ioXx-bnd.ntap; - ixe = mod.ioXx; - ibz = (bnd.ntap+izo-1); - ibx = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[(ix-1)*n1+iz]) + - c2*(tzz[(ix+1)*n1+iz] - tzz[(ix-2)*n1+iz])); - - vx[ix*n1+iz] *= bnd.tapxz[(ibx-ix)*bnd.ntap+(ibz-iz)]; - } - } - } - - - /* Vz field */ - ixo = mod.ioZx; - ixe = mod.ieZx; - izo = mod.ioZz-bnd.ntap; - ize = mod.ioZz; - - ib = (bnd.ntap+izo-1); -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2])); - - vz[ix*n1+iz] *= bnd.tapz[ib-iz]; - } - } - /* right top corner */ - if (bnd.rig==4) { - ixo = mod.ieZx; - ixe = ixo+bnd.ntap; - ibz = (bnd.ntap+izo-1); - ibx = (ixo); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2])); - - vz[ix*n1+iz] *= bnd.tapxz[(ix-ibx)*bnd.ntap+(ibz-iz)]; - } - } - } - /* left top corner */ - if (bnd.lef==4) { - ixo = mod.ioZx-bnd.ntap; - ixe = mod.ioZx; - ibz = (bnd.ntap+izo-1); - ibx = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2])); - - vz[ix*n1+iz] *= bnd.tapxz[(ibx-ix)*bnd.ntap+(ibz-iz)]; - } - } - } - - } - else { /* Elastic scheme */ - - /* Vx field */ - ixo = mod.ioXx; - ixe = mod.ieXx; - izo = mod.ioXz-bnd.ntap; - ize = mod.ioXz; - - ib = (bnd.ntap+izo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(txx[ix*n1+iz] - txx[(ix-1)*n1+iz] + - txz[ix*n1+iz+1] - txz[ix*n1+iz]) + - c2*(txx[(ix+1)*n1+iz] - txx[(ix-2)*n1+iz] + - txz[ix*n1+iz+2] - txz[ix*n1+iz-1]) ); - - vx[ix*n1+iz] *= bnd.tapx[ib-iz]; - } - } - /* right top corner */ - if (bnd.rig==4) { - ixo = mod.ieXx; - ixe = ixo+bnd.ntap; - ibz = (bnd.ntap+izo-1); - ibx = (ixo); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(txx[ix*n1+iz] - txx[(ix-1)*n1+iz] + - txz[ix*n1+iz+1] - txz[ix*n1+iz]) + - c2*(txx[(ix+1)*n1+iz] - txx[(ix-2)*n1+iz] + - txz[ix*n1+iz+2] - txz[ix*n1+iz-1]) ); - - vx[ix*n1+iz] *= bnd.tapxz[(ix-ibx)*bnd.ntap+(ibz-iz)]; - } - } - } - /* left top corner */ - if (bnd.lef==4) { - ixo = mod.ioXx-bnd.ntap; - ixe = mod.ioXx; - ibz = (bnd.ntap+izo-1); - ibx = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(txx[ix*n1+iz] - txx[(ix-1)*n1+iz] + - txz[ix*n1+iz+1] - txz[ix*n1+iz]) + - c2*(txx[(ix+1)*n1+iz] - txx[(ix-2)*n1+iz] + - txz[ix*n1+iz+2] - txz[ix*n1+iz-1]) ); - - vx[ix*n1+iz] *= bnd.tapxz[(ibx-ix)*bnd.ntap+(ibz-iz)]; - } - } - } - - /* Vz field */ - ixo = mod.ioZx; - ixe = mod.ieZx; - izo = mod.ioZz-bnd.ntap; - ize = mod.ioZz; - - ib = (bnd.ntap+izo-1); -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1] + - txz[(ix+1)*n1+iz] - txz[ix*n1+iz]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2] + - txz[(ix+2)*n1+iz] - txz[(ix-1)*n1+iz]) ); - - vz[ix*n1+iz] *= bnd.tapz[ib-iz]; - } - } - /* right top corner */ - if (bnd.rig==4) { - ixo = mod.ieZx; - ixe = ixo+bnd.ntap; - ibz = (bnd.ntap+izo-1); - ibx = (ixo); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1] + - txz[(ix+1)*n1+iz] - txz[ix*n1+iz]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2] + - txz[(ix+2)*n1+iz] - txz[(ix-1)*n1+iz]) ); - - vz[ix*n1+iz] *= bnd.tapxz[(ix-ibx)*bnd.ntap+(ibz-iz)]; - } - } - } - /* left top corner */ - if (bnd.lef==4) { - ixo = mod.ioZx-bnd.ntap; - ixe = mod.ioZx; - ibz = (bnd.ntap+izo-1); - ibx = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1] + - txz[(ix+1)*n1+iz] - txz[ix*n1+iz]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2] + - txz[(ix+2)*n1+iz] - txz[(ix-1)*n1+iz]) ); - - vz[ix*n1+iz] *= bnd.tapxz[(ibx-ix)*bnd.ntap+(ibz-iz)]; - } - } - } - - - } /* end elastic scheme */ - } - - /*********/ - /* Bottom */ - /*********/ - if (bnd.bot==4) { - - if (mod.ischeme <= 2) { /* Acoustic scheme */ - - /* Vx field */ - ixo = mod.ioXx; - ixe = mod.ieXx; - izo = mod.ieXz; - ize = mod.ieXz+bnd.ntap; - - ib = (ize-bnd.ntap); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[(ix-1)*n1+iz]) + - c2*(tzz[(ix+1)*n1+iz] - tzz[(ix-2)*n1+iz])); - vx[ix*n1+iz] *= bnd.tapx[iz-ib]; - } - } - /* right bottom corner */ - if (bnd.rig==4) { - ixo = mod.ieXx; - ixe = ixo+bnd.ntap; - ibz = (izo); - ibx = (ixo); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[(ix-1)*n1+iz]) + - c2*(tzz[(ix+1)*n1+iz] - tzz[(ix-2)*n1+iz])); - - vx[ix*n1+iz] *= bnd.tapxz[(ix-ibx)*bnd.ntap+(iz-ibz)]; - } - } - } - /* left bottom corner */ - if (bnd.lef==4) { - ixo = mod.ioXx-bnd.ntap; - ixe = mod.ioXx; - ibz = (izo); - ibx = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[(ix-1)*n1+iz]) + - c2*(tzz[(ix+1)*n1+iz] - tzz[(ix-2)*n1+iz])); - - vx[ix*n1+iz] *= bnd.tapxz[(ibx-ix)*bnd.ntap+(iz-ibz)]; - } - } - } - - - /* Vz field */ - ixo = mod.ioZx; - ixe = mod.ieZx; - izo = mod.ieZz; - ize = mod.ieZz+bnd.ntap; - - ib = (ize-bnd.ntap); -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2])); - vz[ix*n1+iz] *= bnd.tapz[iz-ib]; - } - } - /* right bottom corner */ - if (bnd.rig==4) { - ixo = mod.ieZx; - ixe = ixo+bnd.ntap; - ibz = (izo); - ibx = (ixo); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2])); - - vz[ix*n1+iz] *= bnd.tapxz[(ix-ibx)*bnd.ntap+(iz-ibz)]; - } - } - } - /* left bottom corner */ - if (bnd.lef==4) { - ixo = mod.ioZx-bnd.ntap; - ixe = mod.ioZx; - ibz = (izo); - ibx = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2])); - - vz[ix*n1+iz] *= bnd.tapxz[(ibx-ix)*bnd.ntap+(iz-ibz)]; - } - } - } - - - } - else { /* Elastic scheme */ - - /* Vx field */ - ixo = mod.ioXx; - ixe = mod.ieXx; - izo = mod.ieXz; - ize = mod.ieXz+bnd.ntap; - - ib = (ize-bnd.ntap); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(txx[ix*n1+iz] - txx[(ix-1)*n1+iz] + - txz[ix*n1+iz+1] - txz[ix*n1+iz]) + - c2*(txx[(ix+1)*n1+iz] - txx[(ix-2)*n1+iz] + - txz[ix*n1+iz+2] - txz[ix*n1+iz-1]) ); - - vx[ix*n1+iz] *= bnd.tapx[iz-ib]; - } - } - /* right bottom corner */ - if (bnd.rig==4) { - ixo = mod.ieXx; - ixe = ixo+bnd.ntap; - ibz = (izo); - ibx = (ixo); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(txx[ix*n1+iz] - txx[(ix-1)*n1+iz] + - txz[ix*n1+iz+1] - txz[ix*n1+iz]) + - c2*(txx[(ix+1)*n1+iz] - txx[(ix-2)*n1+iz] + - txz[ix*n1+iz+2] - txz[ix*n1+iz-1]) ); - - vx[ix*n1+iz] *= bnd.tapxz[(ix-ibx)*bnd.ntap+(iz-ibz)]; - } - } - } - /* left bottom corner */ - if (bnd.lef==4) { - - - ixo = mod.ioXx-bnd.ntap; - ixe = mod.ioXx; - ibz = (izo); - ibx = (bnd.ntap+ixo-1); - - -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(txx[ix*n1+iz] - txx[(ix-1)*n1+iz] + - txz[ix*n1+iz+1] - txz[ix*n1+iz]) + - c2*(txx[(ix+1)*n1+iz] - txx[(ix-2)*n1+iz] + - txz[ix*n1+iz+2] - txz[ix*n1+iz-1]) ); - - vx[ix*n1+iz] *= bnd.tapxz[(ibx-ix)*bnd.ntap+(iz-ibz)]; - } - } - } - - /* Vz field */ - ixo = mod.ioZx; - ixe = mod.ieZx; - izo = mod.ieZz; - ize = mod.ieZz+bnd.ntap; - - ib = (ize-bnd.ntap); -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1] + - txz[(ix+1)*n1+iz] - txz[ix*n1+iz]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2] + - txz[(ix+2)*n1+iz] - txz[(ix-1)*n1+iz]) ); - - vz[ix*n1+iz] *= bnd.tapz[iz-ib]; - } - } - /* right bottom corner */ - if (bnd.rig==4) { - ixo = mod.ieZx; - ixe = ixo+bnd.ntap; - ibz = (izo); - ibx = (ixo); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1] + - txz[(ix+1)*n1+iz] - txz[ix*n1+iz]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2] + - txz[(ix+2)*n1+iz] - txz[(ix-1)*n1+iz]) ); - - vz[ix*n1+iz] *= bnd.tapxz[(ix-ibx)*bnd.ntap+(iz-ibz)]; - } - } - } - /* left bottom corner */ - if (bnd.lef==4) { - ixo = mod.ioZx-bnd.ntap; - ixe = mod.ioZx; - ibz = (izo); - ibx = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1] + - txz[(ix+1)*n1+iz] - txz[ix*n1+iz]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2] + - txz[(ix+2)*n1+iz] - txz[(ix-1)*n1+iz]) ); - - vz[ix*n1+iz] *= bnd.tapxz[(ibx-ix)*bnd.ntap+(iz-ibz)]; - } - } - } - - - } /* end elastic scheme */ - - } - - /*********/ - /* Left */ - /*********/ - if (bnd.lef==4) { - - if (mod.ischeme <= 2) { /* Acoustic scheme */ - - /* Vx field */ - ixo = mod.ioXx-bnd.ntap; - ixe = mod.ioXx; - izo = mod.ioXz; - ize = mod.ieXz; - - ib = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[(ix-1)*n1+iz]) + - c2*(tzz[(ix+1)*n1+iz] - tzz[(ix-2)*n1+iz])); - - vx[ix*n1+iz] *= bnd.tapx[ib-ix]; - } - } - - /* Vz field */ - ixo = mod.ioZx-bnd.ntap; - ixe = mod.ioZx; - izo = mod.ioZz; - ize = mod.ieZz; - - ib = (bnd.ntap+ixo-1); -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2])); - - vz[ix*n1+iz] *= bnd.tapz[ib-ix]; - } - } - - } - else { /* Elastic scheme */ - - /* Vx field */ - ixo = mod.ioXx-bnd.ntap; - ixe = mod.ioXx; - izo = mod.ioXz; - ize = mod.ieXz; - - ib = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(txx[ix*n1+iz] - txx[(ix-1)*n1+iz] + - txz[ix*n1+iz+1] - txz[ix*n1+iz]) + - c2*(txx[(ix+1)*n1+iz] - txx[(ix-2)*n1+iz] + - txz[ix*n1+iz+2] - txz[ix*n1+iz-1]) ); - - vx[ix*n1+iz] *= bnd.tapx[ib-ix]; - } - } - - /* Vz field */ - ixo = mod.ioZx-bnd.ntap; - ixe = mod.ioZx; - izo = mod.ioZz; - ize = mod.ieZz; - - ib = (bnd.ntap+ixo-1); -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1] + - txz[(ix+1)*n1+iz] - txz[ix*n1+iz]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2] + - txz[(ix+2)*n1+iz] - txz[(ix-1)*n1+iz]) ); - - vz[ix*n1+iz] *= bnd.tapz[ib-ix]; - } - } - } /* end elastic scheme */ - - } - - /*********/ - /* Right */ - /*********/ - if (bnd.rig==4) { - - if (mod.ischeme <= 2) { /* Acoustic scheme */ - - /* Vx field */ - ixo = mod.ieXx; - ixe = mod.ieXx+bnd.ntap; - izo = mod.ioXz; - ize = mod.ieXz; - - ib = (ixe-bnd.ntap); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[(ix-1)*n1+iz]) + - c2*(tzz[(ix+1)*n1+iz] - tzz[(ix-2)*n1+iz])); - - vx[ix*n1+iz] *= bnd.tapx[ix-ib]; - } - } - - /* Vz field */ - ixo = mod.ieZx; - ixe = mod.ieZx+bnd.ntap; - izo = mod.ioZz; - ize = mod.ieZz; - - ib = (ixe-bnd.ntap); -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2])); - - vz[ix*n1+iz] *= bnd.tapz[ix-ib]; - } - } - - } - else { /* Elastic scheme */ - - /* Vx field */ - ixo = mod.ieXx; - ixe = mod.ieXx+bnd.ntap; - izo = mod.ioXz; - ize = mod.ieXz; - - ib = (ixe-bnd.ntap); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(txx[ix*n1+iz] - txx[(ix-1)*n1+iz] + - txz[ix*n1+iz+1] - txz[ix*n1+iz]) + - c2*(txx[(ix+1)*n1+iz] - txx[(ix-2)*n1+iz] + - txz[ix*n1+iz+2] - txz[ix*n1+iz-1]) ); - - vx[ix*n1+iz] *= bnd.tapx[ix-ib]; - } - } - - /* Vz field */ - ixo = mod.ieZx; - ixe = mod.ieZx+bnd.ntap; - izo = mod.ioZz; - ize = mod.ieZz; - ib = (ixe-bnd.ntap); -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1] + - txz[(ix+1)*n1+iz] - txz[ix*n1+iz]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2] + - txz[(ix+2)*n1+iz] - txz[(ix-1)*n1+iz]) ); - - vz[ix*n1+iz] *= bnd.tapz[ix-ib]; - } - } -/* - for (ix=ixo-5; ix<ixo+5; ix++) { - for (iz=0; iz<5; iz++) { - fprintf(stderr,"edge ix=%d iz=%d vz=%e roz=%e tzz=%e txz=%e txx=%e lam=%e l2m=%e\n", ix, iz, vz[ix*n1+iz], roz[ix*n1+iz], -tzz[ix*n1+iz], txz[ix*n1+iz], txx[ix*n1+iz], lam[ix*n1+iz], l2m[ix*n1+iz]); - } - } -*/ - - } /* end elastic scheme */ - - } - - - return 0; -} - -int boundariesV(modPar mod, bndPar bnd, float *vx, float *vz, float *tzz, float *txx, float *txz, float *rox, float *roz, float *l2m, float *lam, float *mul, int verbose) -{ -/********************************************************************* - - AUTHOR: - Jan Thorbecke (janth@xs4all.nl) - The Netherlands - -***********************************************************************/ - - float c1, c2; - float dp, dvx, dvz; - int ix, iz, ixs, izs, izp; - int n1; - int is0, isrc; - int ixo, ixe, izo, ize; - - c1 = 9.0/8.0; - c2 = -1.0/24.0; - n1 = mod.naz; - -/************************************************************/ -/* Tapered boundaries for both elastic and acoustic schemes */ -/* compute all field values in tapered areas */ -/************************************************************/ - - -/****************************************************************/ -/* Free surface: calculate free surface conditions for stresses */ -/****************************************************************/ - - - ixo = mod.ioPx; - ixe = mod.iePx; - izo = mod.ioPz; - ize = mod.iePz; - - if (mod.ischeme <= 2) { /* Acoustic scheme */ - - if (bnd.top==1) { /* free surface at top */ -#pragma omp for private (ix) nowait - for (ix=mod.ioPx; ix<mod.iePx; ix++) { - iz = bnd.surface[ix]; - tzz[ix*n1+iz] = 0.0; - } - } - if (bnd.rig==1) { /* free surface at right */ -#pragma omp for private (iz) nowait - for (iz=mod.ioPz; iz<mod.iePz; iz++) { - tzz[(mod.iePx-1)*n1+iz] = 0.0; - } - } - if (bnd.bot==1) { /* free surface at bottom */ -#pragma omp for private (ix) nowait - for (ix=mod.ioPx; ix<mod.iePx; ix++) { - tzz[ix*n1+mod.iePz-1] = 0.0; - } - } - if (bnd.lef==1) { /* free surface at left */ -#pragma omp for private (iz) nowait - for (iz=mod.ioPz; iz<mod.iePz; iz++) { - tzz[(mod.ioPx-1)*n1+iz] = 0.0; - } - } - } - else { /* Elastic scheme */ - - /* Free surface: calculate free surface conditions for stresses - * Conditions (for upper boundary): - * 1. Tzz = 0 - * 2. Txz = 0 - * 3. Txx: remove term with dVz/dz, computed in e2/e4 routines - * and add extra term with dVx/dx, - * corresponding to free-surface condition for Txx. - * In this way, dVz/dz is not needed in computing Txx - * on the upper stress free boundary. Other boundaries - * are treated similar. - * For the 4th order schemes, the whole virtual boundary - * must be taken into account in the removal terms, - * because the algorithm sets - * velocities on this boundary! - * - * Compute the velocities on the virtual boundary to make interpolation - * possible for receivers. - */ - - if (bnd.top==1) { /* free surface at top */ - izp = bnd.surface[ixo]; -#pragma omp for private (ix, iz) - for (ix=mod.ioPx; ix<mod.iePx; ix++) { - iz = bnd.surface[ix]; - if ( izp==iz ) { - /* clear normal pressure */ - tzz[ix*n1+iz] = 0.0; - - /* extra line of txz has to be copied */ -// txz[ix*n1+iz-1] = -txz[ix*n1+iz+2]; - /* This update to Vz might become unstable (2nd order scheme) */ -// vz[ix*n1+iz] = vz[ix*n1+iz+1] - (vx[(ix+1)*n1+iz]-vx[ix*n1+iz])* -// lam[ix*n1+iz]/l2m[ix*n1+iz]; - } - izp=iz; - } - - izp = bnd.surface[ixo]; -#pragma omp for private (ix, iz) - for (ix=mod.ioTx; ix<mod.ieTx; ix++) { - iz = bnd.surface[ix]; - if ( izp==iz ) { - /* assure that txz=0 on boundary by filling virtual boundary */ - txz[ix*n1+iz] = -txz[ix*n1+iz+1]; - /* extra line of txz has to be copied */ - txz[ix*n1+iz-1] = -txz[ix*n1+iz+2]; - } - izp=iz; - } - - /* calculate txx on top stress-free boundary */ - izp = bnd.surface[ixo]; -#pragma omp for private (ix, iz, dp, dvx) - for (ix=mod.ioPx; ix<mod.iePx; ix++) { - iz = bnd.surface[ix]; - if ( izp==iz ) { - if (l2m[ix*n1+iz]!=0.0) { - dp = l2m[ix*n1+iz]-lam[ix*n1+iz]*lam[ix*n1+iz]/l2m[ix*n1+iz]; - dvx = c1*(vx[(ix+1)*n1+iz] - vx[(ix)*n1+iz]) + - c2*(vx[(ix+2)*n1+iz] - vx[(ix-1)*n1+iz]); - txx[ix*n1+iz] = -dvx*dp; - } - } - izp=iz; - } - - /* if surface has also left or right edges */ - izp = bnd.surface[ixo]; -#pragma omp for private (ix, iz, dp, dvz) - for (ix=mod.ioPx+1; ix<mod.iePx; ix++) { - iz = bnd.surface[ix-1]; - if ( izp < iz ) { /* right boundary */ - /* clear normal pressure */ - txx[ix*n1+iz] = 0.0; - if ( (iz-izp) >= 2 ) { /* VR point */ - /* assure that txz=0 on boundary */ - txz[(ix+1)*n1+iz] = -txz[ix*n1+iz]; - txz[(ix+2)*n1+iz] = -txz[(ix-1)*n1+iz] ; - /* calculate tzz on right stress-free boundary */ - if (l2m[ix*n1+iz]!=0.0) { - dvz = c1*(vz[ix*n1+iz+1] - vz[ix*n1+iz]) + - c2*(vz[ix*n1+iz+2] - vz[ix*n1+iz-1]); - dp = l2m[ix*n1+iz]-lam[ix*n1+iz]*lam[ix*n1+iz]/l2m[ix*n1+iz]; - tzz[ix*n1+iz] = -dvz*dp; - } - } - else { - // if (izp) { /* IR point */ - // txz[ix*n1+iz] = -txz[ix*n1+iz+1] ; - // txz[ix*n1+iz-1] = -txz[ix*n1+iz+2]; - txz[(ix+1)*n1+iz] = -txz[ix*n1+iz]; - txz[(ix+2)*n1+iz] = -txz[(ix-1)*n1+iz] ; - tzz[ix*n1+iz] = 0.0; - //} - // else { /* OR point */ - txz[(ix-1)*n1+iz] = 0.0; - txz[(ix+1)*n1+iz] = -txz[ix*n1+iz]; - txz[(ix+2)*n1+iz] = -txz[(ix-1)*n1+iz] ; - if (l2m[ix*n1+iz]!=0.0) { - vz[ix*n1+iz] = vz[ix*n1+iz+1] - (vx[(ix+1)*n1+iz]-vx[ix*n1+iz])* - lam[ix*n1+iz]/l2m[ix*n1+iz]; - } - // } - } - } /* end if right */ - if ( izp > iz ) { /* left boundary */ - /* clear normal pressure */ - txx[ix*n1+iz] = 0.0; - /* assure that txz=0 on boundary */ - txz[(ix-1)*n1+iz] = -txz[ix*n1+iz]; - /* extra line of txz has to be copied */ - txz[(ix-2)*n1+iz] = -txz[(ix+1)*n1+iz] ; - /* calculate tzz on left stress-free boundary */ - dvz = c1*(vz[ix*n1+iz+1] - vz[ix*n1+iz]) + - c2*(vz[ix*n1+iz+2] - vz[ix*n1+iz-1]); - if (l2m[ix*n1+iz]!=0.0) { - dp = l2m[ix*n1+iz]-lam[ix*n1+iz]*lam[ix*n1+iz]/l2m[ix*n1+iz]; - tzz[ix*n1+iz] = -dvz*dp; - } - } /* end if left */ - izp=iz; -// fprintf(stderr,"V4 ix=2123 iz=1 tzz=%e\n", tzz[2123*n1+1]); - // izp=bnd.surface[MAX(ix-2,0)];; - } /* end ix loop */ - } - - - if (bnd.rig==1) { /* free surface at right */ - ix = mod.iePx; -#pragma omp for private (ix, iz) - for (iz=mod.ioPz; iz<mod.iePz; iz++) { - /* clear normal pressure */ - txx[(ix)*n1+iz] = 0.0; - } -#pragma omp for private (ix, iz) - for (iz=mod.ioTz; iz<mod.ieTz; iz++) { - /* assure that txz=0 on boundary by filling virtual boundary */ - txz[(ix+1)*n1+iz] = -txz[(ix)*n1+iz]; - /* extra line of txz has to be copied */ - txz[(ix+2)*n1+iz] = -txz[(ix-1)*n1+iz] ; - } - /* calculate tzz on right stress-free boundary */ -#pragma omp for private (iz) - for (iz=mod.ioPz; iz<mod.iePz; iz++) { - dvz = c1*(vz[(ix)*n1+iz+1] - vz[(ix)*n1+iz]) + - c2*(vz[(ix)*n1+iz+2] - vz[(ix)*n1+iz-1]); - if (l2m[ix*n1+iz]!=0.0) { - dp = l2m[(ix)*n1+iz]-lam[(ix)*n1+iz]*lam[(ix)*n1+iz]/l2m[(ix)*n1+iz]; - tzz[(ix)*n1+iz] = -dvz*dp; - } - } - } - - - if (bnd.bot==1) { /* free surface at bottom */ - iz = mod.iePz; -#pragma omp for private (ix) - for (ix=mod.ioPx; ix<mod.iePx; ix++) { - /* clear normal pressure */ - tzz[ix*n1+iz] = 0.0; - } -#pragma omp for private (ix) - for (ix=mod.ioTx; ix<mod.ieTx; ix++) { - /* assure that txz=0 on boundary by filling virtual boundary */ - txz[ix*n1+iz+1] = -txz[ix*n1+iz]; - /* extra line of txz has to be copied */ - txz[ix*n1+iz+2] = -txz[ix*n1+iz-1]; - } - /* calculate txx on bottom stress-free boundary */ -#pragma omp for private (ix) - for (ix=mod.ioPx; ix<mod.iePx; ix++) { - dvx = c1*(vx[(ix+1)*n1+iz] - vx[ix*n1+iz]) + - c2*(vx[(ix+2)*n1+iz] - vx[(ix-1)*n1+iz]); - if (l2m[ix*n1+iz]!=0.0) { - dp = l2m[ix*n1+iz]-lam[ix*n1+iz]*lam[ix*n1+iz]/l2m[ix*n1+iz]; - txx[ix*n1+iz] = -dvx*dp; - } - } - } - - if (bnd.lef==1) { /* free surface at left */ - ix = mod.ioPx; -#pragma omp for private (iz) - for (iz=mod.ioPz; iz<mod.iePz; iz++) { - /* clear normal pressure */ - txx[ix*n1+iz] = 0.0; - } -#pragma omp for private (iz) - for (iz=mod.ioTz; iz<mod.ieTz; iz++) { - /* assure that txz=0 on boundary by filling virtual boundary */ - txz[(ix)*n1+iz] = -txz[(ix+1)*n1+iz]; - /* extra line of txz has to be copied */ - txz[(ix-1)*n1+iz] = -txz[(ix+2)*n1+iz] ; - } - /* calculate tzz on left stress-free boundary */ -#pragma omp for private (iz) - for (iz=mod.ioPz; iz<mod.iePz; iz++) { - dvz = c1*(vz[ix*n1+iz+1] - vz[ix*n1+iz]) + - c2*(vz[ix*n1+iz+2] - vz[ix*n1+iz-1]); - if (l2m[ix*n1+iz]!=0.0) { - dp = l2m[ix*n1+iz]-lam[ix*n1+iz]*lam[ix*n1+iz]/l2m[ix*n1+iz]; - tzz[ix*n1+iz] = -dvz*dp; - } - } - } - - - } - - return 0; -} diff --git a/fdelmodc/boundaries.c.try b/fdelmodc/boundaries.c.try deleted file mode 100644 index 9d3bc25655117db15363440c0115663bfc1ae28c..0000000000000000000000000000000000000000 --- a/fdelmodc/boundaries.c.try +++ /dev/null @@ -1,1654 +0,0 @@ -#include<stdlib.h> -#include<stdio.h> -#include<math.h> -#include<assert.h> -#include"fdelmodc.h" - -void vmess(char *fmt, ...); - -int boundariesP(modPar mod, bndPar bnd, float *vx, float *vz, float *tzz, float *txx, float *txz, float *rox, float *roz, float *l2m, float *lam, float *mul, int itime, int verbose) -{ -/********************************************************************* - - AUTHOR: - Jan Thorbecke (janth@xs4all.nl) - The Netherlands - -***********************************************************************/ - - float c1, c2; - float dp, dvx, dvz; - int ix, iz, ixs, izs, ibnd, ib, ibx, ibz; - int nx, nz, n1, n2; - int is0, isrc; - int ixo, ixe, izo, ize; - int npml, ipml, pml; - float kappu, alphu, sigmax, R, a, m, fac, dx, dt; - float dpx, dpz, *p; - static float *Vxpml, *Vzpml, *sigmu, *RA; - static int allocated=0; - float Jx, Jz, rho, d; - - c1 = 9.0/8.0; - c2 = -1.0/24.0; - nx = mod.nx; - nz = mod.nz; - n1 = mod.naz; - n2 = mod.nax; - dx = mod.dx; - dt = mod.dt; - fac = dt/dx; - if ( (bnd.top==2) || (bnd.bot==2) || (bnd.lef==2) || (bnd.rig==2) ) pml=1; - else pml=0; - - ibnd = mod.iorder/2-1; - - if (mod.ischeme <= 2) { /* Acoustic scheme */ - if (bnd.top==1) { /* free surface at top */ -#pragma omp for private (ix) - for (ix=mod.ioPx; ix<mod.iePx; ix++) { - iz = bnd.surface[ix]; - //fprintf(stderr,"free iz=%d\n", iz); - vz[ix*n1+iz] = vz[ix*n1+iz+1]; - vz[ix*n1+iz-1] = vz[ix*n1+iz+2]; - } - } -// if (bnd.rig==1) { /* free surface at right */ -//#pragma omp for private (iz) -// for (iz=mod.ioPz; iz<mod.iePz; iz++) { -// tzz[(mod.iePx-1)*n1+iz] = 0.0; -// } -// } -// if (bnd.bot==1) { /* free surface at bottom */ -//#pragma omp for private (ix) -// for (ix=mod.ioPx; ix<mod.iePx; ix++) { -// tzz[ix*n1+mod.iePz-1] = 0.0; -// } -// } -// if (bnd.lef==1) { /* free surface at left */ -//#pragma omp for private (iz) -// for (iz=mod.ioPz; iz<mod.iePz; iz++) { -// tzz[(mod.ioPx-1)*n1+iz] = 0.0; -// } -// } - } - -/************************************************************/ -/* rigid boundary condition clears velocities on boundaries */ -/************************************************************/ - - if (bnd.top==3) { /* rigid surface at top */ -#pragma omp for private (ix, iz) -#pragma ivdep - for (ix=1; ix<=nx; ix++) { - vx[ix*n1+ibnd] = 0.0; - vz[ix*n1+ibnd] = -vz[ix*n1+ibnd+1]; - if (mod.iorder >= 4) vz[ix*n1+ibnd-1] = -vz[ix*n1+ibnd+2]; - if (mod.iorder >= 6) vz[ix*n1+ibnd-2] = -vz[ix*n1+ibnd+3]; - } - } - if (bnd.rig==3) { /* rigid surface at right */ -#pragma omp for private (ix, iz) -#pragma ivdep - for (iz=1; iz<=nz; iz++) { - vz[(nx+ibnd-1)*n1+iz] = 0.0; - vx[(nx+ibnd)*n1+iz] = -vx[(nx+ibnd-1)*n1+iz]; - if (mod.iorder == 4) vx[(nx+2)*n1+iz] = -vx[(nx-1)*n1+iz]; - if (mod.iorder == 6) { - vx[(nx+1)*n1+iz] = -vx[(nx)*n1+iz]; - vx[(nx+3)*n1+iz] = -vx[(nx-2)*n1+iz]; - } - } - } - if (bnd.bot==3) { /* rigid surface at bottom */ -#pragma omp for private (ix, iz) -#pragma ivdep - for (ix=1; ix<=nx; ix++) { - vx[ix*n1+nz+ibnd-1] = 0.0; - vz[ix*n1+nz+ibnd] = -vz[ix*n1+nz+ibnd-1]; - if (mod.iorder == 4) vz[ix*n1+nz+2] = -vz[ix*n1+nz-1]; - if (mod.iorder == 6) { - vz[ix*n1+nz+1] = -vz[ix*n1+nz]; - vz[ix*n1+nz+3] = -vz[ix*n1+nz-2]; - } - } - } - if (bnd.lef==3) { /* rigid surface at left */ -#pragma omp for private (ix, iz) -#pragma ivdep - for (iz=1; iz<=nz; iz++) { - vz[ibnd*n1+iz] = 0.0; - vx[ibnd*n1+iz] = -vx[(ibnd+1)*n1+iz]; - if (mod.iorder == 4) vx[0*n1+iz] = -vx[3*n1+iz]; - if (mod.iorder == 6) { - vx[1*n1+iz] = -vx[4*n1+iz]; - vx[0*n1+iz] = -vx[5*n1+iz]; - } - } - } - - - -/************************************************************/ -/* PML boundaries : only for acoustic 4th order scheme */ -/************************************************************/ - - npml=bnd.npml; /* lenght of pml in grid-points */ - if ( (npml != 0) && (itime==0) && pml) { -#pragma omp master -{ - if (allocated) { - free(Vxpml); - free(Vzpml); - free(sigmu); - free(RA); - } - Vxpml = (float *)calloc(2*n1*npml,sizeof(float)); - Vzpml = (float *)calloc(2*n2*npml,sizeof(float)); - sigmu = (float *)calloc(npml,sizeof(float)); - RA = (float *)calloc(npml,sizeof(float)); - allocated = 1; - - /* calculate sigmu and RA only once with fixed velocity Cp */ - m=bnd.m; /* scaling order */ - R=bnd.R; /* the theoretical reflection coefficient after discretization */ - kappu=1.0; /* auxiliary attenuation coefficient for small angles */ - alphu=0.0; /* auxiliary attenuation coefficient for low frequencies */ - d = (npml-1)*dx; /* depth of pml */ - /* sigmu attenuation factor representing the loss in the PML depends on the grid position in the PML */ - - sigmax = ((3.0*mod.cp_min)/(2.0*d))*log(1.0/R); - for (ib=0; ib<npml; ib++) { /* ib=0 interface between PML and interior */ - a = (float) (ib/(npml-1.0)); - sigmu[ib] = sigmax*pow(a,m); - RA[ib] = (1.0)/(1.0+0.5*dt*sigmu[ib]); - if (verbose>=3) vmess("PML: sigmax=%e cp=%e sigmu[%d]=%e %e", sigmax, mod.cp_min, ib, sigmu[ib], a); - } -} - } -#pragma omp barrier - - if (mod.ischeme == 1 && pml) { /* Acoustic scheme PML */ - p = tzz; /* Tzz array pointer points to P-field */ - - /* PML left Vx */ - if (bnd.lef == 2) { - /* PML left Vx-component */ -#pragma omp for private (ix, iz, dpx, Jx, ipml, rho) - for (ix=mod.ioXx-npml,ipml = npml-1; ix<mod.ioXx; ix++,ipml--) { -#pragma simd - for (iz=mod.ioXz; iz<mod.ieXz; iz++) { - rho = (fac/rox[ix*n1+iz]); - dpx = c1*(p[ix*n1+iz] - p[(ix-1)*n1+iz]) + - c2*(p[(ix+1)*n1+iz] - p[(ix-2)*n1+iz]); - Jx = RA[ipml]*(dpx - dt*Vxpml[iz*npml+ipml]); - Vxpml[iz*npml+ipml] += sigmu[ipml]*Jx; - vx[ix*n1+iz] -= rox[ix*n1+iz]*Jx; - } - } - /* PML Vz-component same as default kernel */ -#pragma omp for private (ix, iz) - for (ix=mod.ioZx-npml; ix<mod.ioZx; ix++) { -#pragma ivdep - for (iz=mod.ioZz; iz<mod.ieZz; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(p[ix*n1+iz] - p[ix*n1+iz-1]) + - c2*(p[ix*n1+iz+1] - p[ix*n1+iz-2])); - } - } - } - - /* PML corner left-top V */ - if (bnd.lef == 2 && bnd.top == 2) { - /* PML left Vx-component */ -#pragma omp for private (ix, iz, dpx, Jx, ipml, rho) - for (ix=mod.ioXx-npml,ipml = npml-1; ix<mod.ioXx; ix++,ipml--) { - //ipml = npml-1; - for (iz=mod.ioXz-npml; iz<mod.ioXz; iz++) { - rho = (fac/rox[ix*n1+iz]); - dpx = c1*(p[ix*n1+iz] - p[(ix-1)*n1+iz]) + - c2*(p[(ix+1)*n1+iz] - p[(ix-2)*n1+iz]); - Jx = RA[ipml]*(dpx - dt*Vxpml[iz*npml+ipml]); - Vxpml[iz*npml+ipml] += sigmu[ipml]*Jx; - vx[ix*n1+iz] -= rox[ix*n1+iz]*Jx; - // ipml--; - } - } - /* PML top Vz-component */ -#pragma omp for private (ix, iz, dpz, Jz, ipml, rho) - for (ix=mod.ioZx-npml; ix<mod.ioZx; ix++) { - //ipml = npml-1; - for (iz=mod.ioZz-npml,ipml = npml-1; iz<mod.ioZz; iz++,ipml--) { - rho = (fac/roz[ix*n1+iz]); - dpz = (c1*(p[ix*n1+iz] - p[ix*n1+iz-1]) + - c2*(p[ix*n1+iz+1] - p[ix*n1+iz-2])); - Jz = RA[ipml]*(dpz - dt*Vzpml[ix*npml+ipml]); - Vzpml[ix*npml+ipml] += sigmu[ipml]*Jz; - vz[ix*n1+iz] -= roz[ix*n1+iz]*Jz; - //ipml--; - } - } - } - - /* PML right V */ - if (bnd.rig == 2) { - /* PML right Vx-component */ -#pragma omp for private (ix, iz, dpx, Jx, ipml, rho) -//#pragma simd - for (iz=mod.ioXz; iz<mod.ieXz; iz++) { - for (ix=mod.ieXx,ipml=0; ix<mod.ieXx+npml; ix++,ipml++) { - rho = (fac/rox[ix*n1+iz]); - dpx = c1*(p[ix*n1+iz] - p[(ix-1)*n1+iz]) + - c2*(p[(ix+1)*n1+iz] - p[(ix-2)*n1+iz]); - Jx = RA[ipml]*(dpx - dt*Vxpml[n1*npml+iz*npml+ipml]); - Vxpml[n1*npml+iz*npml+ipml] += sigmu[ipml]*Jx; - vx[ix*n1+iz] -= rox[ix*n1+iz]*Jx; - //ipml++; - } - } - /* PML Vz-component same as default kernel */ -#pragma omp for private (ix, iz) - for (ix=mod.ieZx; ix<mod.ieZx+npml; ix++) { -#pragma ivdep - for (iz=mod.ioZz; iz<mod.ieZz; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(p[ix*n1+iz] - p[ix*n1+iz-1]) + - c2*(p[ix*n1+iz+1] - p[ix*n1+iz-2])); - } - } - } - - /* PML corner right-top V */ - if (bnd.rig == 2 && bnd.top == 2) { - /* PML right Vx-component */ -#pragma omp for private (ix, iz, dpx, Jx, ipml, rho) - for (iz=mod.ioXz-npml; iz<mod.ioXz; iz++) { - ipml = 0; - for (ix=mod.ieXx; ix<mod.ieXx+npml; ix++) { - rho = (fac/rox[ix*n1+iz]); - dpx = c1*(p[ix*n1+iz] - p[(ix-1)*n1+iz]) + - c2*(p[(ix+1)*n1+iz] - p[(ix-2)*n1+iz]); - Jx = RA[ipml]*(dpx - dt*Vxpml[n1*npml+iz*npml+ipml]); - Vxpml[n1*npml+iz*npml+ipml] += sigmu[ipml]*Jx; - vx[ix*n1+iz] -= rox[ix*n1+iz]*Jx; - ipml++; - } - } - /* PML top Vz-component */ -#pragma omp for private (ix, iz, dpz, Jz, ipml, rho) - for (ix=mod.ieZx; ix<mod.ieZx+npml; ix++) { - ipml = npml-1; - for (iz=mod.ioZz-npml; iz<mod.ioZz; iz++) { - rho = (fac/roz[ix*n1+iz]); - dpz = (c1*(p[ix*n1+iz] - p[ix*n1+iz-1]) + - c2*(p[ix*n1+iz+1] - p[ix*n1+iz-2])); - Jz = RA[ipml]*(dpz - dt*Vzpml[ix*npml+ipml]); - Vzpml[ix*npml+ipml] += sigmu[ipml]*Jz; - vz[ix*n1+iz] -= roz[ix*n1+iz]*Jz; - ipml--; - } - } - } - - /* PML top V */ - if (bnd.top == 2) { - /* PML top Vz-component */ -#pragma omp for private (ix, iz, dpz, Jz, ipml, rho) - for (ix=mod.ioZx; ix<mod.ieZx; ix++) { - ipml = npml-1; - for (iz=mod.ioZz-npml; iz<mod.ioZz; iz++) { - rho = (fac/roz[ix*n1+iz]); - dpz = (c1*(p[ix*n1+iz] - p[ix*n1+iz-1]) + - c2*(p[ix*n1+iz+1] - p[ix*n1+iz-2])); - Jz = RA[ipml]*(dpz - dt*Vzpml[ix*npml+ipml]); - Vzpml[ix*npml+ipml] += sigmu[ipml]*Jz; - vz[ix*n1+iz] -= roz[ix*n1+iz]*Jz; - ipml--; - } - } - /* PML top Vx-component same as default kernel */ -#pragma omp for private (ix, iz) - for (ix=mod.ioXx; ix<mod.ieXx; ix++) { -#pragma ivdep - for (iz=mod.ioXz-npml; iz<mod.ioXz; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(p[ix*n1+iz] - p[(ix-1)*n1+iz]) + - c2*(p[(ix+1)*n1+iz] - p[(ix-2)*n1+iz])); - } - } - } - - /* PML bottom V */ - if (bnd.bot == 2) { - /* PML bottom Vz-component */ -#pragma omp for private (ix, iz, dpz, Jz, ipml, rho) - for (ix=mod.ioZx; ix<mod.ieZx; ix++) { - ipml = 0; - for (iz=mod.ieZz; iz<mod.ieZz+npml; iz++) { - rho = (fac/roz[ix*n1+iz]); - dpz = (c1*(p[ix*n1+iz] - p[ix*n1+iz-1]) + - c2*(p[ix*n1+iz+1] - p[ix*n1+iz-2])); - Jz = RA[ipml]*(dpz - dt*Vzpml[n2*npml+ix*npml+ipml]); - Vzpml[n2*npml+ix*npml+ipml] += sigmu[ipml]*Jz; - vz[ix*n1+iz] -= roz[ix*n1+iz]*Jz; - ipml++; - } - } - /* PML bottom Vx-component same as default kernel */ -#pragma omp for private (ix, iz) - for (ix=mod.ioXx; ix<mod.ieXx; ix++) { - for (iz=mod.ieXz; iz<mod.ieXz+npml; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(p[ix*n1+iz] - p[(ix-1)*n1+iz]) + - c2*(p[(ix+1)*n1+iz] - p[(ix-2)*n1+iz])); - } - } - } - - /* PML corner left-bottom */ - if (bnd.bot == 2 && bnd.lef == 2) { - /* PML bottom Vz-component */ -#pragma omp for private (ix, iz, dpz, Jz, ipml, rho) - for (ix=mod.ioZx-npml; ix<mod.ioZx; ix++) { - ipml = 0; - for (iz=mod.ieZz; iz<mod.ieZz+npml; iz++) { - rho = (fac/roz[ix*n1+iz]); - dpz = (c1*(p[ix*n1+iz] - p[ix*n1+iz-1]) + - c2*(p[ix*n1+iz+1] - p[ix*n1+iz-2])); - Jz = RA[ipml]*(dpz - dt*Vzpml[n2*npml+ix*npml+ipml]); - Vzpml[n2*npml+ix*npml+ipml] += sigmu[ipml]*Jz; - vz[ix*n1+iz] -= roz[ix*n1+iz]*Jz; - ipml++; - } - } - /* PML left Vx-component */ -#pragma omp for private (ix, iz, dpx, Jx, ipml, rho) - for (iz=mod.ieXz; iz<mod.ieXz+npml; iz++) { - ipml = npml-1; - for (ix=mod.ioXx-npml; ix<mod.ioXx; ix++) { - rho = (fac/rox[ix*n1+iz]); - dpx = c1*(p[ix*n1+iz] - p[(ix-1)*n1+iz]) + - c2*(p[(ix+1)*n1+iz] - p[(ix-2)*n1+iz]); - Jx = RA[ipml]*(dpx - dt*Vxpml[iz*npml+ipml]); - Vxpml[iz*npml+ipml] += sigmu[ipml]*Jx; - vx[ix*n1+iz] -= rox[ix*n1+iz]*Jx; - ipml--; - } - } - } - - /* PML corner right-bottom */ - if (bnd.bot == 2 && bnd.rig == 2) { - /* PML bottom Vz-component */ -#pragma omp for private (ix, iz, dpz, Jz, ipml, rho) - for (ix=mod.ieZx; ix<mod.ieZx+npml; ix++) { - ipml = 0; - for (iz=mod.ieZz; iz<mod.ieZz+npml; iz++) { - rho = (fac/roz[ix*n1+iz]); - dpz = (c1*(p[ix*n1+iz] - p[ix*n1+iz-1]) + - c2*(p[ix*n1+iz+1] - p[ix*n1+iz-2])); - Jz = RA[ipml]*(dpz - dt*Vzpml[n2*npml+ix*npml+ipml]); - Vzpml[n2*npml+ix*npml+ipml] += sigmu[ipml]*Jz; - vz[ix*n1+iz] -= roz[ix*n1+iz]*Jz; - ipml++; - } - } - /* PML right Vx-component */ -#pragma omp for private (ix, iz, dpx, Jx, ipml, rho) - for (iz=mod.ieXz; iz<mod.ieXz+npml; iz++) { - ipml = 0; - for (ix=mod.ieXx; ix<mod.ieXx+npml; ix++) { - rho = (fac/rox[ix*n1+iz]); - dpx = c1*(p[ix*n1+iz] - p[(ix-1)*n1+iz]) + - c2*(p[(ix+1)*n1+iz] - p[(ix-2)*n1+iz]); - Jx = RA[ipml]*(dpx - dt*Vxpml[n1*npml+iz*npml+ipml]); - Vxpml[n1*npml+iz*npml+ipml] += sigmu[ipml]*Jx; - vx[ix*n1+iz] -= rox[ix*n1+iz]*Jx; - ipml++; - } - } - } - - } /* end acoustic PML */ - - - - -/************************************************************/ -/* Tapered boundaries for both elastic and acoustic schemes */ -/* compute all field values in tapered areas */ -/************************************************************/ - - /*********/ - /* Top */ - /*********/ - if (bnd.top==4) { - - if (mod.ischeme <= 2) { /* Acoustic scheme */ - - /* Vx field */ - ixo = mod.ioXx; - ixe = mod.ieXx; - izo = mod.ioXz-bnd.ntap; - ize = mod.ioXz; - - ib = (bnd.ntap+izo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[(ix-1)*n1+iz]) + - c2*(tzz[(ix+1)*n1+iz] - tzz[(ix-2)*n1+iz])); - - vx[ix*n1+iz] *= bnd.tapx[ib-iz]; - } - } - /* right top corner */ - if (bnd.rig==4) { - ixo = mod.ieXx; - ixe = ixo+bnd.ntap; - ibz = (bnd.ntap+izo-1); - ibx = (ixo); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[(ix-1)*n1+iz]) + - c2*(tzz[(ix+1)*n1+iz] - tzz[(ix-2)*n1+iz])); - - vx[ix*n1+iz] *= bnd.tapxz[(ix-ibx)*bnd.ntap+(ibz-iz)]; - } - } - } - /* left top corner */ - if (bnd.lef==4) { - ixo = mod.ioXx-bnd.ntap; - ixe = mod.ioXx; - ibz = (bnd.ntap+izo-1); - ibx = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[(ix-1)*n1+iz]) + - c2*(tzz[(ix+1)*n1+iz] - tzz[(ix-2)*n1+iz])); - - vx[ix*n1+iz] *= bnd.tapxz[(ibx-ix)*bnd.ntap+(ibz-iz)]; - } - } - } - - - /* Vz field */ - ixo = mod.ioZx; - ixe = mod.ieZx; - izo = mod.ioZz-bnd.ntap; - ize = mod.ioZz; - - ib = (bnd.ntap+izo-1); -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2])); - - vz[ix*n1+iz] *= bnd.tapz[ib-iz]; - } - } - /* right top corner */ - if (bnd.rig==4) { - ixo = mod.ieZx; - ixe = ixo+bnd.ntap; - ibz = (bnd.ntap+izo-1); - ibx = (ixo); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2])); - - vz[ix*n1+iz] *= bnd.tapxz[(ix-ibx)*bnd.ntap+(ibz-iz)]; - } - } - } - /* left top corner */ - if (bnd.lef==4) { - ixo = mod.ioZx-bnd.ntap; - ixe = mod.ioZx; - ibz = (bnd.ntap+izo-1); - ibx = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2])); - - vz[ix*n1+iz] *= bnd.tapxz[(ibx-ix)*bnd.ntap+(ibz-iz)]; - } - } - } - - } - else { /* Elastic scheme */ - - /* Vx field */ - ixo = mod.ioXx; - ixe = mod.ieXx; - izo = mod.ioXz-bnd.ntap; - ize = mod.ioXz; - - ib = (bnd.ntap+izo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(txx[ix*n1+iz] - txx[(ix-1)*n1+iz] + - txz[ix*n1+iz+1] - txz[ix*n1+iz]) + - c2*(txx[(ix+1)*n1+iz] - txx[(ix-2)*n1+iz] + - txz[ix*n1+iz+2] - txz[ix*n1+iz-1]) ); - - vx[ix*n1+iz] *= bnd.tapx[ib-iz]; - } - } - /* right top corner */ - if (bnd.rig==4) { - ixo = mod.ieXx; - ixe = ixo+bnd.ntap; - ibz = (bnd.ntap+izo-1); - ibx = (ixo); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(txx[ix*n1+iz] - txx[(ix-1)*n1+iz] + - txz[ix*n1+iz+1] - txz[ix*n1+iz]) + - c2*(txx[(ix+1)*n1+iz] - txx[(ix-2)*n1+iz] + - txz[ix*n1+iz+2] - txz[ix*n1+iz-1]) ); - - vx[ix*n1+iz] *= bnd.tapxz[(ix-ibx)*bnd.ntap+(ibz-iz)]; - } - } - } - /* left top corner */ - if (bnd.lef==4) { - ixo = mod.ioXx-bnd.ntap; - ixe = mod.ioXx; - ibz = (bnd.ntap+izo-1); - ibx = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(txx[ix*n1+iz] - txx[(ix-1)*n1+iz] + - txz[ix*n1+iz+1] - txz[ix*n1+iz]) + - c2*(txx[(ix+1)*n1+iz] - txx[(ix-2)*n1+iz] + - txz[ix*n1+iz+2] - txz[ix*n1+iz-1]) ); - - vx[ix*n1+iz] *= bnd.tapxz[(ibx-ix)*bnd.ntap+(ibz-iz)]; - } - } - } - - /* Vz field */ - ixo = mod.ioZx; - ixe = mod.ieZx; - izo = mod.ioZz-bnd.ntap; - ize = mod.ioZz; - - ib = (bnd.ntap+izo-1); -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1] + - txz[(ix+1)*n1+iz] - txz[ix*n1+iz]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2] + - txz[(ix+2)*n1+iz] - txz[(ix-1)*n1+iz]) ); - - vz[ix*n1+iz] *= bnd.tapz[ib-iz]; - } - } - /* right top corner */ - if (bnd.rig==4) { - ixo = mod.ieZx; - ixe = ixo+bnd.ntap; - ibz = (bnd.ntap+izo-1); - ibx = (ixo); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1] + - txz[(ix+1)*n1+iz] - txz[ix*n1+iz]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2] + - txz[(ix+2)*n1+iz] - txz[(ix-1)*n1+iz]) ); - - vz[ix*n1+iz] *= bnd.tapxz[(ix-ibx)*bnd.ntap+(ibz-iz)]; - } - } - } - /* left top corner */ - if (bnd.lef==4) { - ixo = mod.ioZx-bnd.ntap; - ixe = mod.ioZx; - ibz = (bnd.ntap+izo-1); - ibx = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1] + - txz[(ix+1)*n1+iz] - txz[ix*n1+iz]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2] + - txz[(ix+2)*n1+iz] - txz[(ix-1)*n1+iz]) ); - - vz[ix*n1+iz] *= bnd.tapxz[(ibx-ix)*bnd.ntap+(ibz-iz)]; - } - } - } - - - } /* end elastic scheme */ - } - - /*********/ - /* Bottom */ - /*********/ - if (bnd.bot==4) { - - if (mod.ischeme <= 2) { /* Acoustic scheme */ - - /* Vx field */ - ixo = mod.ioXx; - ixe = mod.ieXx; - izo = mod.ieXz; - ize = mod.ieXz+bnd.ntap; - - ib = (ize-bnd.ntap); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[(ix-1)*n1+iz]) + - c2*(tzz[(ix+1)*n1+iz] - tzz[(ix-2)*n1+iz])); - vx[ix*n1+iz] *= bnd.tapx[iz-ib]; - } - } - /* right bottom corner */ - if (bnd.rig==4) { - ixo = mod.ieXx; - ixe = ixo+bnd.ntap; - ibz = (izo); - ibx = (ixo); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[(ix-1)*n1+iz]) + - c2*(tzz[(ix+1)*n1+iz] - tzz[(ix-2)*n1+iz])); - - vx[ix*n1+iz] *= bnd.tapxz[(ix-ibx)*bnd.ntap+(iz-ibz)]; - } - } - } - /* left bottom corner */ - if (bnd.lef==4) { - ixo = mod.ioXx-bnd.ntap; - ixe = mod.ioXx; - ibz = (izo); - ibx = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[(ix-1)*n1+iz]) + - c2*(tzz[(ix+1)*n1+iz] - tzz[(ix-2)*n1+iz])); - - vx[ix*n1+iz] *= bnd.tapxz[(ibx-ix)*bnd.ntap+(iz-ibz)]; - } - } - } - - - /* Vz field */ - ixo = mod.ioZx; - ixe = mod.ieZx; - izo = mod.ieZz; - ize = mod.ieZz+bnd.ntap; - - ib = (ize-bnd.ntap); -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2])); - vz[ix*n1+iz] *= bnd.tapz[iz-ib]; - } - } - /* right bottom corner */ - if (bnd.rig==4) { - ixo = mod.ieZx; - ixe = ixo+bnd.ntap; - ibz = (izo); - ibx = (ixo); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2])); - - vz[ix*n1+iz] *= bnd.tapxz[(ix-ibx)*bnd.ntap+(iz-ibz)]; - } - } - } - /* left bottom corner */ - if (bnd.lef==4) { - ixo = mod.ioZx-bnd.ntap; - ixe = mod.ioZx; - ibz = (izo); - ibx = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2])); - - vz[ix*n1+iz] *= bnd.tapxz[(ibx-ix)*bnd.ntap+(iz-ibz)]; - } - } - } - - - } - else { /* Elastic scheme */ - - /* Vx field */ - ixo = mod.ioXx; - ixe = mod.ieXx; - izo = mod.ieXz; - ize = mod.ieXz+bnd.ntap; - - ib = (ize-bnd.ntap); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(txx[ix*n1+iz] - txx[(ix-1)*n1+iz] + - txz[ix*n1+iz+1] - txz[ix*n1+iz]) + - c2*(txx[(ix+1)*n1+iz] - txx[(ix-2)*n1+iz] + - txz[ix*n1+iz+2] - txz[ix*n1+iz-1]) ); - - vx[ix*n1+iz] *= bnd.tapx[iz-ib]; - } - } - /* right bottom corner */ - if (bnd.rig==4) { - ixo = mod.ieXx; - ixe = ixo+bnd.ntap; - ibz = (izo); - ibx = (ixo); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(txx[ix*n1+iz] - txx[(ix-1)*n1+iz] + - txz[ix*n1+iz+1] - txz[ix*n1+iz]) + - c2*(txx[(ix+1)*n1+iz] - txx[(ix-2)*n1+iz] + - txz[ix*n1+iz+2] - txz[ix*n1+iz-1]) ); - - vx[ix*n1+iz] *= bnd.tapxz[(ix-ibx)*bnd.ntap+(iz-ibz)]; - } - } - } - /* left bottom corner */ - if (bnd.lef==4) { - - - ixo = mod.ioXx-bnd.ntap; - ixe = mod.ioXx; - ibz = (izo); - ibx = (bnd.ntap+ixo-1); - - -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(txx[ix*n1+iz] - txx[(ix-1)*n1+iz] + - txz[ix*n1+iz+1] - txz[ix*n1+iz]) + - c2*(txx[(ix+1)*n1+iz] - txx[(ix-2)*n1+iz] + - txz[ix*n1+iz+2] - txz[ix*n1+iz-1]) ); - - vx[ix*n1+iz] *= bnd.tapxz[(ibx-ix)*bnd.ntap+(iz-ibz)]; - } - } - } - - /* Vz field */ - ixo = mod.ioZx; - ixe = mod.ieZx; - izo = mod.ieZz; - ize = mod.ieZz+bnd.ntap; - - ib = (ize-bnd.ntap); -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1] + - txz[(ix+1)*n1+iz] - txz[ix*n1+iz]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2] + - txz[(ix+2)*n1+iz] - txz[(ix-1)*n1+iz]) ); - - vz[ix*n1+iz] *= bnd.tapz[iz-ib]; - } - } - /* right bottom corner */ - if (bnd.rig==4) { - ixo = mod.ieZx; - ixe = ixo+bnd.ntap; - ibz = (izo); - ibx = (ixo); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1] + - txz[(ix+1)*n1+iz] - txz[ix*n1+iz]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2] + - txz[(ix+2)*n1+iz] - txz[(ix-1)*n1+iz]) ); - - vz[ix*n1+iz] *= bnd.tapxz[(ix-ibx)*bnd.ntap+(iz-ibz)]; - } - } - } - /* left bottom corner */ - if (bnd.lef==4) { - ixo = mod.ioZx-bnd.ntap; - ixe = mod.ioZx; - ibz = (izo); - ibx = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1] + - txz[(ix+1)*n1+iz] - txz[ix*n1+iz]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2] + - txz[(ix+2)*n1+iz] - txz[(ix-1)*n1+iz]) ); - - vz[ix*n1+iz] *= bnd.tapxz[(ibx-ix)*bnd.ntap+(iz-ibz)]; - } - } - } - - - } /* end elastic scheme */ - - } - - /*********/ - /* Left */ - /*********/ - if (bnd.lef==4) { - - if (mod.ischeme <= 2) { /* Acoustic scheme */ - - /* Vx field */ - ixo = mod.ioXx-bnd.ntap; - ixe = mod.ioXx; - izo = mod.ioXz; - ize = mod.ieXz; - - ib = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[(ix-1)*n1+iz]) + - c2*(tzz[(ix+1)*n1+iz] - tzz[(ix-2)*n1+iz])); - - vx[ix*n1+iz] *= bnd.tapx[ib-ix]; - } - } - - /* Vz field */ - ixo = mod.ioZx-bnd.ntap; - ixe = mod.ioZx; - izo = mod.ioZz; - ize = mod.ieZz; - - ib = (bnd.ntap+ixo-1); -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2])); - - vz[ix*n1+iz] *= bnd.tapz[ib-ix]; - } - } - - } - else { /* Elastic scheme */ - - /* Vx field */ - ixo = mod.ioXx-bnd.ntap; - ixe = mod.ioXx; - izo = mod.ioXz; - ize = mod.ieXz; - - ib = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(txx[ix*n1+iz] - txx[(ix-1)*n1+iz] + - txz[ix*n1+iz+1] - txz[ix*n1+iz]) + - c2*(txx[(ix+1)*n1+iz] - txx[(ix-2)*n1+iz] + - txz[ix*n1+iz+2] - txz[ix*n1+iz-1]) ); - - vx[ix*n1+iz] *= bnd.tapx[ib-ix]; - } - } - - /* Vz field */ - ixo = mod.ioZx-bnd.ntap; - ixe = mod.ioZx; - izo = mod.ioZz; - ize = mod.ieZz; - - ib = (bnd.ntap+ixo-1); -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1] + - txz[(ix+1)*n1+iz] - txz[ix*n1+iz]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2] + - txz[(ix+2)*n1+iz] - txz[(ix-1)*n1+iz]) ); - - vz[ix*n1+iz] *= bnd.tapz[ib-ix]; - } - } - } /* end elastic scheme */ - - } - - /*********/ - /* Right */ - /*********/ - if (bnd.rig==4) { - - if (mod.ischeme <= 2) { /* Acoustic scheme */ - - /* Vx field */ - ixo = mod.ieXx; - ixe = mod.ieXx+bnd.ntap; - izo = mod.ioXz; - ize = mod.ieXz; - - ib = (ixe-bnd.ntap); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[(ix-1)*n1+iz]) + - c2*(tzz[(ix+1)*n1+iz] - tzz[(ix-2)*n1+iz])); - - vx[ix*n1+iz] *= bnd.tapx[ix-ib]; - } - } - - /* Vz field */ - ixo = mod.ieZx; - ixe = mod.ieZx+bnd.ntap; - izo = mod.ioZz; - ize = mod.ieZz; - - ib = (ixe-bnd.ntap); -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2])); - - vz[ix*n1+iz] *= bnd.tapz[ix-ib]; - } - } - - } - else { /* Elastic scheme */ - - /* Vx field */ - ixo = mod.ieXx; - ixe = mod.ieXx+bnd.ntap; - izo = mod.ioXz; - ize = mod.ieXz; - - ib = (ixe-bnd.ntap); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(txx[ix*n1+iz] - txx[(ix-1)*n1+iz] + - txz[ix*n1+iz+1] - txz[ix*n1+iz]) + - c2*(txx[(ix+1)*n1+iz] - txx[(ix-2)*n1+iz] + - txz[ix*n1+iz+2] - txz[ix*n1+iz-1]) ); - - vx[ix*n1+iz] *= bnd.tapx[ix-ib]; - } - } - - /* Vz field */ - ixo = mod.ieZx; - ixe = mod.ieZx+bnd.ntap; - izo = mod.ioZz; - ize = mod.ieZz; - ib = (ixe-bnd.ntap); -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1] + - txz[(ix+1)*n1+iz] - txz[ix*n1+iz]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2] + - txz[(ix+2)*n1+iz] - txz[(ix-1)*n1+iz]) ); - - vz[ix*n1+iz] *= bnd.tapz[ix-ib]; - } - } -/* - for (ix=ixo-5; ix<ixo+5; ix++) { - for (iz=0; iz<5; iz++) { - fprintf(stderr,"edge ix=%d iz=%d vz=%e roz=%e tzz=%e txz=%e txx=%e lam=%e l2m=%e\n", ix, iz, vz[ix*n1+iz], roz[ix*n1+iz], -tzz[ix*n1+iz], txz[ix*n1+iz], txx[ix*n1+iz], lam[ix*n1+iz], l2m[ix*n1+iz]); - } - } -*/ - - } /* end elastic scheme */ - - } - - - return 0; -} - -int boundariesV(modPar mod, bndPar bnd, float *vx, float *vz, float *tzz, float *txx, float *txz, float *rox, float *roz, float *l2m, float *lam, float *mul, int itime, int verbose) -{ -/********************************************************************* - - AUTHOR: - Jan Thorbecke (janth@xs4all.nl) - The Netherlands - -***********************************************************************/ - - float c1, c2; - float dp, dvx, dvz; - int ix, iz, ixs, izs, izp, ib; - int nx, nz, n1, n2; - int is0, isrc; - int ixo, ixe, izo, ize; - int npml, ipml, pml; - float kappu, alphu, sigmax, R, a, m, fac, dx, dt; - float *p; - static float *Pxpml, *Pzpml, *sigmu, *RA; - static int allocated=0; - float Jx, Jz, rho, d; - - c1 = 9.0/8.0; - c2 = -1.0/24.0; - nx = mod.nx; - nz = mod.nz; - n1 = mod.naz; - n2 = mod.nax; - dx = mod.dx; - dt = mod.dt; - fac = dt/dx; - if ( (bnd.top==2) || (bnd.bot==2) || (bnd.lef==2) || (bnd.rig==2) ) pml=1; - else pml=0; - -/************************************************************/ -/* PML boundaries for acoustic schemes */ -/* compute all field values in tapered areas */ -/************************************************************/ - - npml=bnd.npml; /* lenght of pml in grid-points */ - if ( (npml != 0) && (itime==0) && pml) { -#pragma omp master -{ - if (allocated) { - free(Pxpml); - free(Pzpml); - free(sigmu); - free(RA); - } - Pxpml = (float *)calloc(2*n1*npml,sizeof(float)); - Pzpml = (float *)calloc(2*n2*npml,sizeof(float)); - sigmu = (float *)calloc(npml,sizeof(float)); - RA = (float *)calloc(npml,sizeof(float)); - allocated = 1; - - /* calculate sigmu and RA only once with fixed velocity Cp */ - m=bnd.m; /* scaling order */ - R=bnd.R; /* the theoretical reflection coefficient after discretization */ - kappu = 1.0; /* auxiliary attenuation coefficient for small angles */ - alphu=0.0; /* auxiliary attenuation coefficient for low frequencies */ - d = (npml-1)*dx; /* depth of pml */ - /* sigmu attenuation factor representing the loss in the PML depends on the grid position in the PML */ - - sigmax = ((3.0*mod.cp_min)/(2.0*d))*log(1.0/R); - for (ib=0; ib<npml; ib++) { /* ib=0 interface between PML and interior */ - a = (float) (ib/(npml-1.0)); - sigmu[ib] = sigmax*pow(a,m); - RA[ib] = (1.0)/(1.0+0.5*dt*sigmu[ib]); -// if (verbose>=3) vmess("PML: sigmax=%e cp=%e sigmu[%d]=%e %e\n", sigmax, mod.cp_min, ib, sigmu[ib], a); - } -} - } - -#pragma omp barrier - if (mod.ischeme == 1 && pml) { /* Acoustic scheme PML's */ - p = tzz; /* Tzz array pointer points to P-field */ - - if (bnd.top==2) mod.ioPz += bnd.npml; - if (bnd.bot==2) mod.iePz -= bnd.npml; - if (bnd.lef==2) mod.ioPx += bnd.npml; - if (bnd.rig==2) mod.iePx -= bnd.npml; - - /* PML top P */ - if (bnd.top == 2) { - /* PML top P-Vz-component */ -#pragma omp for private (ix, iz, dvx, dvz, Jz, ipml) - for (ix=mod.ioPx; ix<mod.iePx; ix++) { - ipml = npml-1; - for (iz=mod.ioPz-npml; iz<mod.ioPz; iz++) { - dvx = c1*(vx[(ix+1)*n1+iz] - vx[ix*n1+iz]) + - c2*(vx[(ix+2)*n1+iz] - vx[(ix-1)*n1+iz]); - dvz = c1*(vz[ix*n1+iz+1] - vz[ix*n1+iz]) + - c2*(vz[ix*n1+iz+2] - vz[ix*n1+iz-1]); - Jz = RA[ipml]*dvz - RA[ipml]*dt*Pzpml[ix*npml+ipml]; - Pzpml[ix*npml+ipml] += sigmu[ipml]*Jz; - p[ix*n1+iz] -= l2m[ix*n1+iz]*(Jz+dvx); - ipml--; - } - } - } - - /* PML left P */ - if (bnd.lef == 2) { - /* PML left P-Vx-component */ -#pragma omp for private (ix, iz, dvx, dvz, Jx, ipml) - for (iz=mod.ioPz; iz<mod.iePz; iz++) { - ipml = npml-1; - for (ix=mod.ioPx-npml; ix<mod.ioPx; ix++) { - dvx = c1*(vx[(ix+1)*n1+iz] - vx[ix*n1+iz]) + - c2*(vx[(ix+2)*n1+iz] - vx[(ix-1)*n1+iz]); - dvz = c1*(vz[ix*n1+iz+1] - vz[ix*n1+iz]) + - c2*(vz[ix*n1+iz+2] - vz[ix*n1+iz-1]); - Jx = RA[ipml]*dvx - RA[ipml]*dt*Pxpml[iz*npml+ipml]; - Pxpml[iz*npml+ipml] += sigmu[ipml]*Jx; - p[ix*n1+iz] -= l2m[ix*n1+iz]*(Jx+dvz); - ipml--; - } - } - } - - /* PML corner left-top P */ - if (bnd.lef == 2 && bnd.top == 2) { - /* PML left P-Vx-component */ -#pragma omp for private (ix, iz, dvx, Jx, ipml) - for (iz=mod.ioPz-npml; iz<mod.ioPz; iz++) { - ipml = npml-1; - for (ix=mod.ioPx-npml; ix<mod.ioPx; ix++) { - dvx = c1*(vx[(ix+1)*n1+iz] - vx[ix*n1+iz]) + - c2*(vx[(ix+2)*n1+iz] - vx[(ix-1)*n1+iz]); - Jx = RA[ipml]*dvx - RA[ipml]*dt*Pxpml[iz*npml+ipml]; - Pxpml[iz*npml+ipml] += sigmu[ipml]*Jx; - p[ix*n1+iz] -= l2m[ix*n1+iz]*(Jx); - ipml--; - } - } - /* PML top P-Vz-component */ -#pragma omp for private (ix, iz, dvz, Jz, ipml) - for (ix=mod.ioPx-npml; ix<mod.ioPx; ix++) { - ipml = npml-1; - for (iz=mod.ioPz-npml; iz<mod.ioPz; iz++) { - dvz = c1*(vz[ix*n1+iz+1] - vz[ix*n1+iz]) + - c2*(vz[ix*n1+iz+2] - vz[ix*n1+iz-1]); - Jz = RA[ipml]*dvz - RA[ipml]*dt*Pzpml[ix*npml+ipml]; - Pzpml[ix*npml+ipml] += sigmu[ipml]*Jz; - p[ix*n1+iz] -= l2m[ix*n1+iz]*(Jz); - ipml--; - } - } - } - - /* PML right P */ - if (bnd.rig == 2) { - /* PML right P Vx-component */ -#pragma omp for private (ix, iz, dvx, dvz, Jx, ipml) - for (iz=mod.ioPz; iz<mod.iePz; iz++) { - ipml = 0; - for (ix=mod.iePx; ix<mod.iePx+npml; ix++) { - dvx = c1*(vx[(ix+1)*n1+iz] - vx[ix*n1+iz]) + - c2*(vx[(ix+2)*n1+iz] - vx[(ix-1)*n1+iz]); - dvz = c1*(vz[ix*n1+iz+1] - vz[ix*n1+iz]) + - c2*(vz[ix*n1+iz+2] - vz[ix*n1+iz-1]); - Jx = RA[ipml]*dvx - RA[ipml]*dt*Pxpml[n1*npml+iz*npml+ipml]; - Pxpml[n1*npml+iz*npml+ipml] += sigmu[ipml]*Jx; - p[ix*n1+iz] -= l2m[ix*n1+iz]*(Jx+dvz); - ipml++; - } - } - } - - /* PML corner right-top P */ - if (bnd.rig == 2 && bnd.top == 2) { - /* PML right P Vx-component */ -#pragma omp for private (ix, iz, dvx, Jx, ipml) - for (iz=mod.ioPz-npml; iz<mod.ioPz; iz++) { - ipml = 0; - for (ix=mod.iePx; ix<mod.iePx+npml; ix++) { - dvx = c1*(vx[(ix+1)*n1+iz] - vx[ix*n1+iz]) + - c2*(vx[(ix+2)*n1+iz] - vx[(ix-1)*n1+iz]); - Jx = RA[ipml]*dvx - RA[ipml]*dt*Pxpml[n1*npml+iz*npml+ipml]; - Pxpml[n1*npml+iz*npml+ipml] += sigmu[ipml]*Jx; - p[ix*n1+iz] -= l2m[ix*n1+iz]*(Jx); - ipml++; - } - } - /* PML top P-Vz-component */ -#pragma omp for private (ix, iz, dvz, Jz, ipml) - for (ix=mod.iePx; ix<mod.iePx+npml; ix++) { - ipml = npml-1; - for (iz=mod.ioPz-npml; iz<mod.ioPz; iz++) { - dvz = c1*(vz[ix*n1+iz+1] - vz[ix*n1+iz]) + - c2*(vz[ix*n1+iz+2] - vz[ix*n1+iz-1]); - Jz = RA[ipml]*dvz - RA[ipml]*dt*Pzpml[ix*npml+ipml]; - Pzpml[ix*npml+ipml] += sigmu[ipml]*Jz; - p[ix*n1+iz] -= l2m[ix*n1+iz]*(Jz); - ipml--; - } - } - } - - /* PML bottom P */ - if (bnd.bot == 2) { - /* PML bottom P Vz-component */ -#pragma omp for private (ix, iz, dvx, dvz, Jz, ipml) - for (ix=mod.ioPx; ix<mod.iePx; ix++) { - ipml = 0; - for (iz=mod.iePz; iz<mod.iePz+npml; iz++) { - dvx = c1*(vx[(ix+1)*n1+iz] - vx[ix*n1+iz]) + - c2*(vx[(ix+2)*n1+iz] - vx[(ix-1)*n1+iz]); - dvz = c1*(vz[ix*n1+iz+1] - vz[ix*n1+iz]) + - c2*(vz[ix*n1+iz+2] - vz[ix*n1+iz-1]); - Jz = RA[ipml]*dvz - RA[ipml]*dt*Pzpml[n2*npml+ix*npml+ipml]; - Pzpml[n2*npml+ix*npml+ipml] += sigmu[ipml]*Jz; - p[ix*n1+iz] -= l2m[ix*n1+iz]*(Jz+dvx); - ipml++; - } - } - } - - /* PML corner bottom-right P */ - if (bnd.bot == 2 && bnd.rig == 2) { - /* PML bottom P Vz-component */ -#pragma omp for private (ix, iz, dvz, Jz, ipml) - for (ix=mod.iePx; ix<mod.iePx+npml; ix++) { - ipml = 0; - for (iz=mod.iePz; iz<mod.iePz+npml; iz++) { - dvz = c1*(vz[ix*n1+iz+1] - vz[ix*n1+iz]) + - c2*(vz[ix*n1+iz+2] - vz[ix*n1+iz-1]); - Jz = RA[ipml]*dvz - RA[ipml]*dt*Pzpml[n2*npml+ix*npml+ipml]; - Pzpml[n2*npml+ix*npml+ipml] += sigmu[ipml]*Jz; - p[ix*n1+iz] -= l2m[ix*n1+iz]*(Jz); - ipml++; - } - } - /* PML right P Vx-component */ -#pragma omp for private (ix, iz, dvx, Jx, ipml) - for (iz=mod.iePz; iz<mod.iePz+npml; iz++) { - ipml = 0; - for (ix=mod.iePx; ix<mod.iePx+npml; ix++) { - dvx = c1*(vx[(ix+1)*n1+iz] - vx[ix*n1+iz]) + - c2*(vx[(ix+2)*n1+iz] - vx[(ix-1)*n1+iz]); - Jx = RA[ipml]*dvx - RA[ipml]*dt*Pxpml[n1*npml+iz*npml+ipml]; - Pxpml[n1*npml+iz*npml+ipml] += sigmu[ipml]*Jx; - p[ix*n1+iz] -= l2m[ix*n1+iz]*(Jx); - //p[ix*n1+iz] -= l2m[ix*n1+iz]*(dvx); - ipml++; - } - } - } - - /* PML corner left-bottom P */ - if (bnd.bot == 2 && bnd.lef == 2) { - /* PML bottom P Vz-component */ -#pragma omp for private (ix, iz, dvz, Jz, ipml) - for (ix=mod.ioPx-npml; ix<mod.ioPx; ix++) { - ipml = 0; - for (iz=mod.iePz; iz<mod.iePz+npml; iz++) { - dvz = c1*(vz[ix*n1+iz+1] - vz[ix*n1+iz]) + - c2*(vz[ix*n1+iz+2] - vz[ix*n1+iz-1]); - Jz = RA[ipml]*dvz - RA[ipml]*dt*Pzpml[n2*npml+ix*npml+ipml]; - Pzpml[n2*npml+ix*npml+ipml] += sigmu[ipml]*Jz; - p[ix*n1+iz] -= l2m[ix*n1+iz]*(Jz); - ipml++; - } - } - /* PML left P Vx-component */ -#pragma omp for private (ix, iz, dvx, Jx, ipml) - for (iz=mod.iePz; iz<mod.iePz+npml; iz++) { - ipml = npml-1; - for (ix=mod.ioPx-npml; ix<mod.ioPx; ix++) { - dvx = c1*(vx[(ix+1)*n1+iz] - vx[ix*n1+iz]) + - c2*(vx[(ix+2)*n1+iz] - vx[(ix-1)*n1+iz]); - Jx = RA[ipml]*dvx - RA[ipml]*dt*Pxpml[iz*npml+ipml]; - Pxpml[iz*npml+ipml] += sigmu[ipml]*Jx; - p[ix*n1+iz] -= l2m[ix*n1+iz]*(Jx); - ipml--; - } - } - } - if (bnd.top==2) mod.ioPz -= bnd.npml; - if (bnd.bot==2) mod.iePz += bnd.npml; - if (bnd.lef==2) mod.ioPx -= bnd.npml; - if (bnd.rig==2) mod.iePx += bnd.npml; - - } /* end acoustic PML */ - - - -/****************************************************************/ -/* Free surface: calculate free surface conditions for stresses */ -/****************************************************************/ - - - ixo = mod.ioPx; - ixe = mod.iePx; - izo = mod.ioPz; - ize = mod.iePz; - - if (mod.ischeme <= 2) { /* Acoustic scheme */ - if (bnd.top==1) { /* free surface at top */ -#pragma omp for private (ix) - for (ix=mod.ioPx; ix<mod.iePx; ix++) { - iz = bnd.surface[ix]; - tzz[ix*n1+iz] = 0.0; - } - } - if (bnd.rig==1) { /* free surface at right */ -#pragma omp for private (iz) - for (iz=mod.ioPz; iz<mod.iePz; iz++) { - tzz[(mod.iePx-1)*n1+iz] = 0.0; - } - } - if (bnd.bot==1) { /* free surface at bottom */ -#pragma omp for private (ix) - for (ix=mod.ioPx; ix<mod.iePx; ix++) { - tzz[ix*n1+mod.iePz-1] = 0.0; - } - } - if (bnd.lef==1) { /* free surface at left */ -#pragma omp for private (iz) - for (iz=mod.ioPz; iz<mod.iePz; iz++) { - tzz[(mod.ioPx-1)*n1+iz] = 0.0; - } - } - } - else { /* Elastic scheme */ -/* The implementation for a topgraphy surface is not yet correct */ - - /* Free surface: calculate free surface conditions for stresses - * Conditions (for upper boundary): - * 1. Tzz = 0 - * 2. Txz = 0 - * 3. Txx: remove term with dVz/dz, computed in e2/e4 routines - * and add extra term with dVx/dx, - * corresponding to free-surface condition for Txx. - * In this way, dVz/dz is not needed in computing Txx - * on the upper stress free boundary. Other boundaries - * are treated similar. - * For the 4th order schemes, the whole virtual boundary - * must be taken into account in the removal terms, - * because the algorithm sets - * velocities on this boundary! - * - * Compute the velocities on the virtual boundary to make interpolation - * possible for receivers. - */ - - if (bnd.top==1) { /* free surface at top */ - izp = bnd.surface[ixo]; -#pragma omp for private (ix, iz) - for (ix=mod.ioPx; ix<mod.iePx; ix++) { - iz = bnd.surface[ix]; - if ( izp==iz ) { - /* clear normal pressure */ - tzz[ix*n1+iz] = 0.0; - - /* This update to Vz might become unstable (2nd order scheme) */ -// vz[ix*n1+iz] = vz[ix*n1+iz+1] - (vx[(ix+1)*n1+iz]-vx[ix*n1+iz])* -// lam[ix*n1+iz]/l2m[ix*n1+iz]; - } - izp=iz; - } - - izp = bnd.surface[ixo]; -#pragma omp for private (ix, iz) - for (ix=mod.ioTx; ix<mod.ieTx; ix++) { - iz = bnd.surface[ix]; - if ( izp==iz ) { - /* assure that txz=0 on boundary by filling virtual boundary */ - txz[ix*n1+iz] = -txz[ix*n1+iz+1]; - /* extra line of txz has to be copied */ - txz[ix*n1+iz-1] = -txz[ix*n1+iz+2]; - } - izp=iz; - } - - /* calculate txx on top stress-free boundary */ - izp = bnd.surface[ixo]; -#pragma omp for private (ix, iz, dp, dvx) - for (ix=mod.ioPx; ix<mod.iePx; ix++) { - iz = bnd.surface[ix]; - if ( izp==iz ) { - if (l2m[ix*n1+iz]!=0.0) { - dp = l2m[ix*n1+iz]-lam[ix*n1+iz]*lam[ix*n1+iz]/l2m[ix*n1+iz]; - dvx = c1*(vx[(ix+1)*n1+iz] - vx[(ix)*n1+iz]) + - c2*(vx[(ix+2)*n1+iz] - vx[(ix-1)*n1+iz]); - txx[ix*n1+iz] = -dvx*dp; - } - } - izp=iz; - } - - /* if surface has also left or right edges */ - izp = bnd.surface[ixo]; -#pragma omp for private (ix, iz, dp, dvz) - for (ix=mod.ioPx+1; ix<mod.iePx; ix++) { - iz = bnd.surface[ix-1]; - if ( izp < iz ) { /* right boundary */ - /* clear normal pressure */ - txx[ix*n1+iz] = 0.0; - if ( (iz-izp) >= 2 ) { /* VR point */ - /* assure that txz=0 on boundary */ - txz[(ix+1)*n1+iz] = -txz[ix*n1+iz]; - txz[(ix+2)*n1+iz] = -txz[(ix-1)*n1+iz] ; - /* calculate tzz on right stress-free boundary */ - if (l2m[ix*n1+iz]!=0.0) { - dvz = c1*(vz[ix*n1+iz+1] - vz[ix*n1+iz]) + - c2*(vz[ix*n1+iz+2] - vz[ix*n1+iz-1]); - dp = l2m[ix*n1+iz]-lam[ix*n1+iz]*lam[ix*n1+iz]/l2m[ix*n1+iz]; - tzz[ix*n1+iz] = -dvz*dp; - } - } - else { - if (izp) { /* IR point */ -// txz[ix*n1+iz] = -txz[ix*n1+iz+1] ; -// txz[ix*n1+iz-1] = -txz[ix*n1+iz+2]; -// txz[(ix+1)*n1+iz] = -txz[ix*n1+iz]; -// txz[(ix+2)*n1+iz] = -txz[(ix-1)*n1+iz] ; -// tzz[ix*n1+iz] = 0.0; - } - else { /* OR point */ -// txz[(ix-1)*n1+iz] = 0.0; -// txz[(ix+1)*n1+iz] = -txz[ix*n1+iz]; -// txz[(ix+2)*n1+iz] = -txz[(ix-1)*n1+iz] ; -// if (l2m[ix*n1+iz]!=0.0) { -// vz[ix*n1+iz] = vz[ix*n1+iz+1] - (vx[(ix+1)*n1+iz]-vx[ix*n1+iz])* -// lam[ix*n1+iz]/l2m[ix*n1+iz]; -// } - } - } - } /* end if right */ - if ( izp > iz ) { /* left boundary */ - /* clear normal pressure */ - txx[ix*n1+iz] = 0.0; - /* assure that txz=0 on boundary */ - txz[(ix-1)*n1+iz] = -txz[ix*n1+iz]; - /* extra line of txz has to be copied */ - txz[(ix-2)*n1+iz] = -txz[(ix+1)*n1+iz] ; - /* calculate tzz on left stress-free boundary */ - dvz = c1*(vz[ix*n1+iz+1] - vz[ix*n1+iz]) + - c2*(vz[ix*n1+iz+2] - vz[ix*n1+iz-1]); - if (l2m[ix*n1+iz]!=0.0) { - dp = l2m[ix*n1+iz]-lam[ix*n1+iz]*lam[ix*n1+iz]/l2m[ix*n1+iz]; - tzz[ix*n1+iz] = -dvz*dp; - } - } /* end if left */ - izp=iz; -// fprintf(stderr,"V4 ix=2123 iz=1 tzz=%e\n", tzz[2123*n1+1]); - // izp=bnd.surface[MAX(ix-2,0)];; - } /* end ix loop */ - } - - - if (bnd.rig==1) { /* free surface at right */ - ix = mod.iePx; -#pragma omp for private (iz) - for (iz=mod.ioPz; iz<mod.iePz; iz++) { - /* clear normal pressure */ - txx[ix*n1+iz] = 0.0; - } -#pragma omp for private (iz) - for (iz=mod.ioTz; iz<mod.ieTz; iz++) { - /* assure that txz=0 on boundary by filling virtual boundary */ - txz[(ix+1)*n1+iz] = -txz[(ix)*n1+iz]; - /* extra line of txz has to be copied */ - txz[(ix+2)*n1+iz] = -txz[(ix-1)*n1+iz] ; - } - /* calculate tzz on right stress-free boundary */ -#pragma omp for private (iz) - for (iz=mod.ioPz; iz<mod.iePz; iz++) { - dvz = c1*(vz[(ix)*n1+iz+1] - vz[(ix)*n1+iz]) + - c2*(vz[(ix)*n1+iz+2] - vz[(ix)*n1+iz-1]); - if (l2m[ix*n1+iz]!=0.0) { - dp = l2m[(ix)*n1+iz]-lam[(ix)*n1+iz]*lam[(ix)*n1+iz]/l2m[(ix)*n1+iz]; - tzz[(ix)*n1+iz] = -dvz*dp; - } - } - } - - - if (bnd.bot==1) { /* free surface at bottom */ - iz = mod.iePz; -#pragma omp for private (ix) - for (ix=mod.ioPx; ix<mod.iePx; ix++) { - /* clear normal pressure */ - tzz[ix*n1+iz] = 0.0; - } -#pragma omp for private (ix) - for (ix=mod.ioTx; ix<mod.ieTx; ix++) { - /* assure that txz=0 on boundary by filling virtual boundary */ - txz[ix*n1+iz+1] = -txz[ix*n1+iz]; - /* extra line of txz has to be copied */ - txz[ix*n1+iz+2] = -txz[ix*n1+iz-1]; - } - /* calculate txx on bottom stress-free boundary */ -#pragma omp for private (ix) - for (ix=mod.ioPx; ix<mod.iePx; ix++) { - dvx = c1*(vx[(ix+1)*n1+iz] - vx[ix*n1+iz]) + - c2*(vx[(ix+2)*n1+iz] - vx[(ix-1)*n1+iz]); - if (l2m[ix*n1+iz]!=0.0) { - dp = l2m[ix*n1+iz]-lam[ix*n1+iz]*lam[ix*n1+iz]/l2m[ix*n1+iz]; - txx[ix*n1+iz] = -dvx*dp; - } - } - } - - if (bnd.lef==1) { /* free surface at left */ - ix = mod.ioPx; -#pragma omp for private (iz) - for (iz=mod.ioPz; iz<mod.iePz; iz++) { - /* clear normal pressure */ - txx[ix*n1+iz] = 0.0; - } -#pragma omp for private (iz) - for (iz=mod.ioTz; iz<mod.ieTz; iz++) { - /* assure that txz=0 on boundary by filling virtual boundary */ - txz[(ix)*n1+iz] = -txz[(ix+1)*n1+iz]; - /* extra line of txz has to be copied */ - txz[(ix-1)*n1+iz] = -txz[(ix+2)*n1+iz] ; - } - /* calculate tzz on left stress-free boundary */ -#pragma omp for private (iz) - for (iz=mod.ioPz; iz<mod.iePz; iz++) { - dvz = c1*(vz[ix*n1+iz+1] - vz[ix*n1+iz]) + - c2*(vz[ix*n1+iz+2] - vz[ix*n1+iz-1]); - if (l2m[ix*n1+iz]!=0.0) { - dp = l2m[ix*n1+iz]-lam[ix*n1+iz]*lam[ix*n1+iz]/l2m[ix*n1+iz]; - tzz[ix*n1+iz] = -dvz*dp; - } - } - } - - - } - - return 0; -} diff --git a/fdelmodc/boundaries.c.try2 b/fdelmodc/boundaries.c.try2 deleted file mode 100644 index a6e2bd15e39f1a381796feead0d24ee219f89162..0000000000000000000000000000000000000000 --- a/fdelmodc/boundaries.c.try2 +++ /dev/null @@ -1,1658 +0,0 @@ -#include<stdlib.h> -#include<stdio.h> -#include<math.h> -#include<assert.h> -#include"fdelmodc.h" - -void vmess(char *fmt, ...); - -int boundariesP(modPar mod, bndPar bnd, float *vx, float *vz, float *tzz, float *txx, float *txz, float *rox, float *roz, float *l2m, float *lam, float *mul, int itime, int verbose) -{ -/********************************************************************* - - AUTHOR: - Jan Thorbecke (janth@xs4all.nl) - The Netherlands - -***********************************************************************/ - - float c1, c2; - float dp, dvx, dvz; - int ix, iz, ixs, izs, ibnd, ib, ibx, ibz; - int nx, nz, n1, n2; - int is0, isrc; - int ixo, ixe, izo, ize; - int npml, ipml, pml; - float kappu, alphu, sigmax, R, a, m, fac, dx, dt; - float dpx, dpz, *p; - static float *Vxpml, *Vzpml, *sigmu, *RA; - static int allocated=0; - float Jx, Jz, rho, d; - - c1 = 9.0/8.0; - c2 = -1.0/24.0; - nx = mod.nx; - nz = mod.nz; - n1 = mod.naz; - n2 = mod.nax; - dx = mod.dx; - dt = mod.dt; - fac = dt/dx; - if ( (bnd.top==2) || (bnd.bot==2) || (bnd.lef==2) || (bnd.rig==2) ) pml=1; - else pml=0; - - ibnd = mod.iorder/2-1; - - if (mod.ischeme <= 2) { /* Acoustic scheme */ - if (bnd.top==1) { /* free surface at top */ -#pragma omp for private (ix) nowait - for (ix=mod.ioPx; ix<mod.iePx; ix++) { - iz = bnd.surface[ix]; - //fprintf(stderr,"free iz=%d\n", iz); - vz[ix*n1+iz] = vz[ix*n1+iz+1]; - vz[ix*n1+iz-1] = vz[ix*n1+iz+2]; - } - } -// if (bnd.rig==1) { /* free surface at right */ -//#pragma omp for private (iz) nowait -// for (iz=mod.ioPz; iz<mod.iePz; iz++) { -// tzz[(mod.iePx-1)*n1+iz] = 0.0; -// } -// } -// if (bnd.bot==1) { /* free surface at bottom */ -//#pragma omp for private (ix) nowait -// for (ix=mod.ioPx; ix<mod.iePx; ix++) { -// tzz[ix*n1+mod.iePz-1] = 0.0; -// } -// } -// if (bnd.lef==1) { /* free surface at left */ -//#pragma omp for private (iz) nowait -// for (iz=mod.ioPz; iz<mod.iePz; iz++) { -// tzz[(mod.ioPx-1)*n1+iz] = 0.0; -// } -// } - } - -/************************************************************/ -/* rigid boundary condition clears velocities on boundaries */ -/************************************************************/ - - if (bnd.top==3) { /* rigid surface at top */ -#pragma omp for private (ix, iz) nowait -#pragma ivdep - for (ix=1; ix<=nx; ix++) { - vx[ix*n1+ibnd] = 0.0; - vz[ix*n1+ibnd] = -vz[ix*n1+ibnd+1]; - if (mod.iorder >= 4) vz[ix*n1+ibnd-1] = -vz[ix*n1+ibnd+2]; - if (mod.iorder >= 6) vz[ix*n1+ibnd-2] = -vz[ix*n1+ibnd+3]; - } - } - if (bnd.rig==3) { /* rigid surface at right */ -#pragma omp for private (ix, iz) nowait -#pragma ivdep - for (iz=1; iz<=nz; iz++) { - vz[(nx+ibnd-1)*n1+iz] = 0.0; - vx[(nx+ibnd)*n1+iz] = -vx[(nx+ibnd-1)*n1+iz]; - if (mod.iorder == 4) vx[(nx+2)*n1+iz] = -vx[(nx-1)*n1+iz]; - if (mod.iorder == 6) { - vx[(nx+1)*n1+iz] = -vx[(nx)*n1+iz]; - vx[(nx+3)*n1+iz] = -vx[(nx-2)*n1+iz]; - } - } - } - if (bnd.bot==3) { /* rigid surface at bottom */ -#pragma omp for private (ix, iz) nowait -#pragma ivdep - for (ix=1; ix<=nx; ix++) { - vx[ix*n1+nz+ibnd-1] = 0.0; - vz[ix*n1+nz+ibnd] = -vz[ix*n1+nz+ibnd-1]; - if (mod.iorder == 4) vz[ix*n1+nz+2] = -vz[ix*n1+nz-1]; - if (mod.iorder == 6) { - vz[ix*n1+nz+1] = -vz[ix*n1+nz]; - vz[ix*n1+nz+3] = -vz[ix*n1+nz-2]; - } - } - } - if (bnd.lef==3) { /* rigid surface at left */ -#pragma omp for private (ix, iz) nowait -#pragma ivdep - for (iz=1; iz<=nz; iz++) { - vz[ibnd*n1+iz] = 0.0; - vx[ibnd*n1+iz] = -vx[(ibnd+1)*n1+iz]; - if (mod.iorder == 4) vx[0*n1+iz] = -vx[3*n1+iz]; - if (mod.iorder == 6) { - vx[1*n1+iz] = -vx[4*n1+iz]; - vx[0*n1+iz] = -vx[5*n1+iz]; - } - } - } - - - -/************************************************************/ -/* PML boundaries : only for acoustic 4th order scheme */ -/************************************************************/ - - npml=bnd.npml; /* lenght of pml in grid-points */ - if ( (npml != 0) && (itime==0) && pml) { -#pragma omp master -{ - if (allocated) { - free(Vxpml); - free(Vzpml); - free(sigmu); - free(RA); - } - Vxpml = (float *)calloc(2*n1*npml,sizeof(float)); - Vzpml = (float *)calloc(2*n2*npml,sizeof(float)); - sigmu = (float *)calloc(npml,sizeof(float)); - RA = (float *)calloc(npml,sizeof(float)); - allocated = 1; - - /* calculate sigmu and RA only once with fixed velocity Cp */ - m=bnd.m; /* scaling order */ - R=bnd.R; /* the theoretical reflection coefficient after discretization */ - kappu=1.0; /* auxiliary attenuation coefficient for small angles */ - alphu=0.0; /* auxiliary attenuation coefficient for low frequencies */ - d = (npml-1)*dx; /* depth of pml */ - /* sigmu attenuation factor representing the loss in the PML depends on the grid position in the PML */ - - sigmax = ((3.0*mod.cp_min)/(2.0*d))*log(1.0/R); - for (ib=0; ib<npml; ib++) { /* ib=0 interface between PML and interior */ - a = (float) (ib/(npml-1.0)); - sigmu[ib] = sigmax*pow(a,m); - RA[ib] = (1.0)/(1.0+0.5*dt*sigmu[ib]); - if (verbose>=3) vmess("PML: sigmax=%e cp=%e sigmu[%d]=%e %e", sigmax, mod.cp_min, ib, sigmu[ib], a); - } -} - } -#pragma omp barrier - - if (mod.ischeme == 1 && pml) { /* Acoustic scheme PML */ - p = tzz; /* Tzz array pointer points to P-field */ - - /* PML left Vx */ - if (bnd.lef == 2) { - /* PML left Vx-component */ -// for (ix=mod.ioXx-npml,ipml=npml-1; ix<mod.ioXx; ix++,ipml--) { -// ipml = npml-1; -#pragma omp for private (ix, iz, dpx, Jx, ipml, rho) - for (iz=mod.ioXz; iz<mod.ieXz; iz++) { -#pragma simd - for (ix=mod.ioXx-npml,ipml=npml-1; ix<mod.ioXx; ix++,ipml--) { -// for (ix=mod.ioXx-npml; ix<mod.ioXx; ix++) { - rho = (fac/rox[ix*n1+iz]); - dpx = c1*(p[ix*n1+iz] - p[(ix-1)*n1+iz]) + - c2*(p[(ix+1)*n1+iz] - p[(ix-2)*n1+iz]); - Jx = RA[ipml]*(dpx - dt*Vxpml[iz*npml+ipml]); - Vxpml[iz*npml+ipml] += sigmu[ipml]*Jx; - vx[ix*n1+iz] -= rox[ix*n1+iz]*Jx; - // ipml--; - } - } - /* PML Vz-component same as default kernel */ -#pragma omp for private (ix, iz) - for (ix=mod.ioZx-npml; ix<mod.ioZx; ix++) { -#pragma ivdep - for (iz=mod.ioZz; iz<mod.ieZz; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(p[ix*n1+iz] - p[ix*n1+iz-1]) + - c2*(p[ix*n1+iz+1] - p[ix*n1+iz-2])); - } - } - } - - /* PML corner left-top V */ - if (bnd.lef == 2 && bnd.top == 2) { - /* PML left Vx-component */ -#pragma omp for private (ix, iz, dpx, Jx, ipml, rho) - for (iz=mod.ioXz-npml; iz<mod.ioXz; iz++) { - ipml = npml-1; - for (ix=mod.ioXx-npml; ix<mod.ioXx; ix++) { - rho = (fac/rox[ix*n1+iz]); - dpx = c1*(p[ix*n1+iz] - p[(ix-1)*n1+iz]) + - c2*(p[(ix+1)*n1+iz] - p[(ix-2)*n1+iz]); - Jx = RA[ipml]*(dpx - dt*Vxpml[iz*npml+ipml]); - Vxpml[iz*npml+ipml] += sigmu[ipml]*Jx; - vx[ix*n1+iz] -= rox[ix*n1+iz]*Jx; - ipml--; - } - } - /* PML top Vz-component */ -#pragma omp for private (ix, iz, dpz, Jz, ipml, rho) - for (ix=mod.ioZx-npml; ix<mod.ioZx; ix++) { - ipml = npml-1; - for (iz=mod.ioZz-npml; iz<mod.ioZz; iz++) { - rho = (fac/roz[ix*n1+iz]); - dpz = (c1*(p[ix*n1+iz] - p[ix*n1+iz-1]) + - c2*(p[ix*n1+iz+1] - p[ix*n1+iz-2])); - Jz = RA[ipml]*(dpz - dt*Vzpml[ix*npml+ipml]); - Vzpml[ix*npml+ipml] += sigmu[ipml]*Jz; - vz[ix*n1+iz] -= roz[ix*n1+iz]*Jz; - ipml--; - } - } - } - - /* PML right V */ - if (bnd.rig == 2) { - /* PML right Vx-component */ -#pragma omp for private (ix, iz, dpx, Jx, ipml, rho) - for (iz=mod.ioXz; iz<mod.ieXz; iz++) { - ipml = 0; - for (ix=mod.ieXx; ix<mod.ieXx+npml; ix++) { - rho = (fac/rox[ix*n1+iz]); - dpx = c1*(p[ix*n1+iz] - p[(ix-1)*n1+iz]) + - c2*(p[(ix+1)*n1+iz] - p[(ix-2)*n1+iz]); - Jx = RA[ipml]*(dpx - dt*Vxpml[n1*npml+iz*npml+ipml]); - Vxpml[n1*npml+iz*npml+ipml] += sigmu[ipml]*Jx; - vx[ix*n1+iz] -= rox[ix*n1+iz]*Jx; - ipml++; - } - } - /* PML Vz-component same as default kernel */ -#pragma omp for private (ix, iz) - for (ix=mod.ieZx; ix<mod.ieZx+npml; ix++) { -#pragma ivdep - for (iz=mod.ioZz; iz<mod.ieZz; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(p[ix*n1+iz] - p[ix*n1+iz-1]) + - c2*(p[ix*n1+iz+1] - p[ix*n1+iz-2])); - } - } - } - - /* PML corner right-top V */ - if (bnd.rig == 2 && bnd.top == 2) { - /* PML right Vx-component */ -#pragma omp for private (ix, iz, dpx, Jx, ipml, rho) - for (iz=mod.ioXz-npml; iz<mod.ioXz; iz++) { - ipml = 0; - for (ix=mod.ieXx; ix<mod.ieXx+npml; ix++) { - rho = (fac/rox[ix*n1+iz]); - dpx = c1*(p[ix*n1+iz] - p[(ix-1)*n1+iz]) + - c2*(p[(ix+1)*n1+iz] - p[(ix-2)*n1+iz]); - Jx = RA[ipml]*(dpx - dt*Vxpml[n1*npml+iz*npml+ipml]); - Vxpml[n1*npml+iz*npml+ipml] += sigmu[ipml]*Jx; - vx[ix*n1+iz] -= rox[ix*n1+iz]*Jx; - ipml++; - } - } - /* PML top Vz-component */ -#pragma omp for private (ix, iz, dpz, Jz, ipml, rho) - for (ix=mod.ieZx; ix<mod.ieZx+npml; ix++) { - ipml = npml-1; - for (iz=mod.ioZz-npml; iz<mod.ioZz; iz++) { - rho = (fac/roz[ix*n1+iz]); - dpz = (c1*(p[ix*n1+iz] - p[ix*n1+iz-1]) + - c2*(p[ix*n1+iz+1] - p[ix*n1+iz-2])); - Jz = RA[ipml]*(dpz - dt*Vzpml[ix*npml+ipml]); - Vzpml[ix*npml+ipml] += sigmu[ipml]*Jz; - vz[ix*n1+iz] -= roz[ix*n1+iz]*Jz; - ipml--; - } - } - } - - /* PML top V */ - if (bnd.top == 2) { - /* PML top Vz-component */ -#pragma omp for private (ix, iz, dpz, Jz, ipml, rho) - for (ix=mod.ioZx; ix<mod.ieZx; ix++) { - ipml = npml-1; - for (iz=mod.ioZz-npml; iz<mod.ioZz; iz++) { - rho = (fac/roz[ix*n1+iz]); - dpz = (c1*(p[ix*n1+iz] - p[ix*n1+iz-1]) + - c2*(p[ix*n1+iz+1] - p[ix*n1+iz-2])); - Jz = RA[ipml]*(dpz - dt*Vzpml[ix*npml+ipml]); - Vzpml[ix*npml+ipml] += sigmu[ipml]*Jz; - vz[ix*n1+iz] -= roz[ix*n1+iz]*Jz; - ipml--; - } - } - /* PML top Vx-component same as default kernel */ -#pragma omp for private (ix, iz) - for (ix=mod.ioXx; ix<mod.ieXx; ix++) { -#pragma ivdep - for (iz=mod.ioXz-npml; iz<mod.ioXz; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(p[ix*n1+iz] - p[(ix-1)*n1+iz]) + - c2*(p[(ix+1)*n1+iz] - p[(ix-2)*n1+iz])); - } - } - } - - /* PML bottom V */ - if (bnd.bot == 2) { - /* PML bottom Vz-component */ -#pragma omp for private (ix, iz, dpz, Jz, ipml, rho) - for (ix=mod.ioZx; ix<mod.ieZx; ix++) { - ipml = 0; - for (iz=mod.ieZz; iz<mod.ieZz+npml; iz++) { - rho = (fac/roz[ix*n1+iz]); - dpz = (c1*(p[ix*n1+iz] - p[ix*n1+iz-1]) + - c2*(p[ix*n1+iz+1] - p[ix*n1+iz-2])); - Jz = RA[ipml]*(dpz - dt*Vzpml[n2*npml+ix*npml+ipml]); - Vzpml[n2*npml+ix*npml+ipml] += sigmu[ipml]*Jz; - vz[ix*n1+iz] -= roz[ix*n1+iz]*Jz; - ipml++; - } - } - /* PML bottom Vx-component same as default kernel */ -#pragma omp for private (ix, iz) - for (ix=mod.ioXx; ix<mod.ieXx; ix++) { - for (iz=mod.ieXz; iz<mod.ieXz+npml; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(p[ix*n1+iz] - p[(ix-1)*n1+iz]) + - c2*(p[(ix+1)*n1+iz] - p[(ix-2)*n1+iz])); - } - } - } - - /* PML corner left-bottom */ - if (bnd.bot == 2 && bnd.lef == 2) { - /* PML bottom Vz-component */ -#pragma omp for private (ix, iz, dpz, Jz, ipml, rho) - for (ix=mod.ioZx-npml; ix<mod.ioZx; ix++) { - ipml = 0; - for (iz=mod.ieZz; iz<mod.ieZz+npml; iz++) { - rho = (fac/roz[ix*n1+iz]); - dpz = (c1*(p[ix*n1+iz] - p[ix*n1+iz-1]) + - c2*(p[ix*n1+iz+1] - p[ix*n1+iz-2])); - Jz = RA[ipml]*(dpz - dt*Vzpml[n2*npml+ix*npml+ipml]); - Vzpml[n2*npml+ix*npml+ipml] += sigmu[ipml]*Jz; - vz[ix*n1+iz] -= roz[ix*n1+iz]*Jz; - ipml++; - } - } - /* PML left Vx-component */ -#pragma omp for private (ix, iz, dpx, Jx, ipml, rho) - for (iz=mod.ieXz; iz<mod.ieXz+npml; iz++) { - ipml = npml-1; - for (ix=mod.ioXx-npml; ix<mod.ioXx; ix++) { - rho = (fac/rox[ix*n1+iz]); - dpx = c1*(p[ix*n1+iz] - p[(ix-1)*n1+iz]) + - c2*(p[(ix+1)*n1+iz] - p[(ix-2)*n1+iz]); - Jx = RA[ipml]*(dpx - dt*Vxpml[iz*npml+ipml]); - Vxpml[iz*npml+ipml] += sigmu[ipml]*Jx; - vx[ix*n1+iz] -= rox[ix*n1+iz]*Jx; - ipml--; - } - } - } - - /* PML corner right-bottom */ - if (bnd.bot == 2 && bnd.rig == 2) { - /* PML bottom Vz-component */ -#pragma omp for private (ix, iz, dpz, Jz, ipml, rho) - for (ix=mod.ieZx; ix<mod.ieZx+npml; ix++) { - ipml = 0; - for (iz=mod.ieZz; iz<mod.ieZz+npml; iz++) { - rho = (fac/roz[ix*n1+iz]); - dpz = (c1*(p[ix*n1+iz] - p[ix*n1+iz-1]) + - c2*(p[ix*n1+iz+1] - p[ix*n1+iz-2])); - Jz = RA[ipml]*(dpz - dt*Vzpml[n2*npml+ix*npml+ipml]); - Vzpml[n2*npml+ix*npml+ipml] += sigmu[ipml]*Jz; - vz[ix*n1+iz] -= roz[ix*n1+iz]*Jz; - ipml++; - } - } - /* PML right Vx-component */ -#pragma omp for private (ix, iz, dpx, Jx, ipml, rho) - for (iz=mod.ieXz; iz<mod.ieXz+npml; iz++) { - ipml = 0; - for (ix=mod.ieXx; ix<mod.ieXx+npml; ix++) { - rho = (fac/rox[ix*n1+iz]); - dpx = c1*(p[ix*n1+iz] - p[(ix-1)*n1+iz]) + - c2*(p[(ix+1)*n1+iz] - p[(ix-2)*n1+iz]); - Jx = RA[ipml]*(dpx - dt*Vxpml[n1*npml+iz*npml+ipml]); - Vxpml[n1*npml+iz*npml+ipml] += sigmu[ipml]*Jx; - vx[ix*n1+iz] -= rox[ix*n1+iz]*Jx; - ipml++; - } - } - } - - } /* end acoustic PML */ - - - - -/************************************************************/ -/* Tapered boundaries for both elastic and acoustic schemes */ -/* compute all field values in tapered areas */ -/************************************************************/ - - /*********/ - /* Top */ - /*********/ - if (bnd.top==4) { - - if (mod.ischeme <= 2) { /* Acoustic scheme */ - - /* Vx field */ - ixo = mod.ioXx; - ixe = mod.ieXx; - izo = mod.ioXz-bnd.ntap; - ize = mod.ioXz; - - ib = (bnd.ntap+izo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[(ix-1)*n1+iz]) + - c2*(tzz[(ix+1)*n1+iz] - tzz[(ix-2)*n1+iz])); - - vx[ix*n1+iz] *= bnd.tapx[ib-iz]; - } - } - /* right top corner */ - if (bnd.rig==4) { - ixo = mod.ieXx; - ixe = ixo+bnd.ntap; - ibz = (bnd.ntap+izo-1); - ibx = (ixo); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[(ix-1)*n1+iz]) + - c2*(tzz[(ix+1)*n1+iz] - tzz[(ix-2)*n1+iz])); - - vx[ix*n1+iz] *= bnd.tapxz[(ix-ibx)*bnd.ntap+(ibz-iz)]; - } - } - } - /* left top corner */ - if (bnd.lef==4) { - ixo = mod.ioXx-bnd.ntap; - ixe = mod.ioXx; - ibz = (bnd.ntap+izo-1); - ibx = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[(ix-1)*n1+iz]) + - c2*(tzz[(ix+1)*n1+iz] - tzz[(ix-2)*n1+iz])); - - vx[ix*n1+iz] *= bnd.tapxz[(ibx-ix)*bnd.ntap+(ibz-iz)]; - } - } - } - - - /* Vz field */ - ixo = mod.ioZx; - ixe = mod.ieZx; - izo = mod.ioZz-bnd.ntap; - ize = mod.ioZz; - - ib = (bnd.ntap+izo-1); -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2])); - - vz[ix*n1+iz] *= bnd.tapz[ib-iz]; - } - } - /* right top corner */ - if (bnd.rig==4) { - ixo = mod.ieZx; - ixe = ixo+bnd.ntap; - ibz = (bnd.ntap+izo-1); - ibx = (ixo); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2])); - - vz[ix*n1+iz] *= bnd.tapxz[(ix-ibx)*bnd.ntap+(ibz-iz)]; - } - } - } - /* left top corner */ - if (bnd.lef==4) { - ixo = mod.ioZx-bnd.ntap; - ixe = mod.ioZx; - ibz = (bnd.ntap+izo-1); - ibx = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2])); - - vz[ix*n1+iz] *= bnd.tapxz[(ibx-ix)*bnd.ntap+(ibz-iz)]; - } - } - } - - } - else { /* Elastic scheme */ - - /* Vx field */ - ixo = mod.ioXx; - ixe = mod.ieXx; - izo = mod.ioXz-bnd.ntap; - ize = mod.ioXz; - - ib = (bnd.ntap+izo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(txx[ix*n1+iz] - txx[(ix-1)*n1+iz] + - txz[ix*n1+iz+1] - txz[ix*n1+iz]) + - c2*(txx[(ix+1)*n1+iz] - txx[(ix-2)*n1+iz] + - txz[ix*n1+iz+2] - txz[ix*n1+iz-1]) ); - - vx[ix*n1+iz] *= bnd.tapx[ib-iz]; - } - } - /* right top corner */ - if (bnd.rig==4) { - ixo = mod.ieXx; - ixe = ixo+bnd.ntap; - ibz = (bnd.ntap+izo-1); - ibx = (ixo); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(txx[ix*n1+iz] - txx[(ix-1)*n1+iz] + - txz[ix*n1+iz+1] - txz[ix*n1+iz]) + - c2*(txx[(ix+1)*n1+iz] - txx[(ix-2)*n1+iz] + - txz[ix*n1+iz+2] - txz[ix*n1+iz-1]) ); - - vx[ix*n1+iz] *= bnd.tapxz[(ix-ibx)*bnd.ntap+(ibz-iz)]; - } - } - } - /* left top corner */ - if (bnd.lef==4) { - ixo = mod.ioXx-bnd.ntap; - ixe = mod.ioXx; - ibz = (bnd.ntap+izo-1); - ibx = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(txx[ix*n1+iz] - txx[(ix-1)*n1+iz] + - txz[ix*n1+iz+1] - txz[ix*n1+iz]) + - c2*(txx[(ix+1)*n1+iz] - txx[(ix-2)*n1+iz] + - txz[ix*n1+iz+2] - txz[ix*n1+iz-1]) ); - - vx[ix*n1+iz] *= bnd.tapxz[(ibx-ix)*bnd.ntap+(ibz-iz)]; - } - } - } - - /* Vz field */ - ixo = mod.ioZx; - ixe = mod.ieZx; - izo = mod.ioZz-bnd.ntap; - ize = mod.ioZz; - - ib = (bnd.ntap+izo-1); -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1] + - txz[(ix+1)*n1+iz] - txz[ix*n1+iz]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2] + - txz[(ix+2)*n1+iz] - txz[(ix-1)*n1+iz]) ); - - vz[ix*n1+iz] *= bnd.tapz[ib-iz]; - } - } - /* right top corner */ - if (bnd.rig==4) { - ixo = mod.ieZx; - ixe = ixo+bnd.ntap; - ibz = (bnd.ntap+izo-1); - ibx = (ixo); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1] + - txz[(ix+1)*n1+iz] - txz[ix*n1+iz]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2] + - txz[(ix+2)*n1+iz] - txz[(ix-1)*n1+iz]) ); - - vz[ix*n1+iz] *= bnd.tapxz[(ix-ibx)*bnd.ntap+(ibz-iz)]; - } - } - } - /* left top corner */ - if (bnd.lef==4) { - ixo = mod.ioZx-bnd.ntap; - ixe = mod.ioZx; - ibz = (bnd.ntap+izo-1); - ibx = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1] + - txz[(ix+1)*n1+iz] - txz[ix*n1+iz]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2] + - txz[(ix+2)*n1+iz] - txz[(ix-1)*n1+iz]) ); - - vz[ix*n1+iz] *= bnd.tapxz[(ibx-ix)*bnd.ntap+(ibz-iz)]; - } - } - } - - - } /* end elastic scheme */ - } - - /*********/ - /* Bottom */ - /*********/ - if (bnd.bot==4) { - - if (mod.ischeme <= 2) { /* Acoustic scheme */ - - /* Vx field */ - ixo = mod.ioXx; - ixe = mod.ieXx; - izo = mod.ieXz; - ize = mod.ieXz+bnd.ntap; - - ib = (ize-bnd.ntap); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[(ix-1)*n1+iz]) + - c2*(tzz[(ix+1)*n1+iz] - tzz[(ix-2)*n1+iz])); - vx[ix*n1+iz] *= bnd.tapx[iz-ib]; - } - } - /* right bottom corner */ - if (bnd.rig==4) { - ixo = mod.ieXx; - ixe = ixo+bnd.ntap; - ibz = (izo); - ibx = (ixo); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[(ix-1)*n1+iz]) + - c2*(tzz[(ix+1)*n1+iz] - tzz[(ix-2)*n1+iz])); - - vx[ix*n1+iz] *= bnd.tapxz[(ix-ibx)*bnd.ntap+(iz-ibz)]; - } - } - } - /* left bottom corner */ - if (bnd.lef==4) { - ixo = mod.ioXx-bnd.ntap; - ixe = mod.ioXx; - ibz = (izo); - ibx = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[(ix-1)*n1+iz]) + - c2*(tzz[(ix+1)*n1+iz] - tzz[(ix-2)*n1+iz])); - - vx[ix*n1+iz] *= bnd.tapxz[(ibx-ix)*bnd.ntap+(iz-ibz)]; - } - } - } - - - /* Vz field */ - ixo = mod.ioZx; - ixe = mod.ieZx; - izo = mod.ieZz; - ize = mod.ieZz+bnd.ntap; - - ib = (ize-bnd.ntap); -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2])); - vz[ix*n1+iz] *= bnd.tapz[iz-ib]; - } - } - /* right bottom corner */ - if (bnd.rig==4) { - ixo = mod.ieZx; - ixe = ixo+bnd.ntap; - ibz = (izo); - ibx = (ixo); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2])); - - vz[ix*n1+iz] *= bnd.tapxz[(ix-ibx)*bnd.ntap+(iz-ibz)]; - } - } - } - /* left bottom corner */ - if (bnd.lef==4) { - ixo = mod.ioZx-bnd.ntap; - ixe = mod.ioZx; - ibz = (izo); - ibx = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2])); - - vz[ix*n1+iz] *= bnd.tapxz[(ibx-ix)*bnd.ntap+(iz-ibz)]; - } - } - } - - - } - else { /* Elastic scheme */ - - /* Vx field */ - ixo = mod.ioXx; - ixe = mod.ieXx; - izo = mod.ieXz; - ize = mod.ieXz+bnd.ntap; - - ib = (ize-bnd.ntap); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(txx[ix*n1+iz] - txx[(ix-1)*n1+iz] + - txz[ix*n1+iz+1] - txz[ix*n1+iz]) + - c2*(txx[(ix+1)*n1+iz] - txx[(ix-2)*n1+iz] + - txz[ix*n1+iz+2] - txz[ix*n1+iz-1]) ); - - vx[ix*n1+iz] *= bnd.tapx[iz-ib]; - } - } - /* right bottom corner */ - if (bnd.rig==4) { - ixo = mod.ieXx; - ixe = ixo+bnd.ntap; - ibz = (izo); - ibx = (ixo); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(txx[ix*n1+iz] - txx[(ix-1)*n1+iz] + - txz[ix*n1+iz+1] - txz[ix*n1+iz]) + - c2*(txx[(ix+1)*n1+iz] - txx[(ix-2)*n1+iz] + - txz[ix*n1+iz+2] - txz[ix*n1+iz-1]) ); - - vx[ix*n1+iz] *= bnd.tapxz[(ix-ibx)*bnd.ntap+(iz-ibz)]; - } - } - } - /* left bottom corner */ - if (bnd.lef==4) { - - - ixo = mod.ioXx-bnd.ntap; - ixe = mod.ioXx; - ibz = (izo); - ibx = (bnd.ntap+ixo-1); - - -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(txx[ix*n1+iz] - txx[(ix-1)*n1+iz] + - txz[ix*n1+iz+1] - txz[ix*n1+iz]) + - c2*(txx[(ix+1)*n1+iz] - txx[(ix-2)*n1+iz] + - txz[ix*n1+iz+2] - txz[ix*n1+iz-1]) ); - - vx[ix*n1+iz] *= bnd.tapxz[(ibx-ix)*bnd.ntap+(iz-ibz)]; - } - } - } - - /* Vz field */ - ixo = mod.ioZx; - ixe = mod.ieZx; - izo = mod.ieZz; - ize = mod.ieZz+bnd.ntap; - - ib = (ize-bnd.ntap); -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1] + - txz[(ix+1)*n1+iz] - txz[ix*n1+iz]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2] + - txz[(ix+2)*n1+iz] - txz[(ix-1)*n1+iz]) ); - - vz[ix*n1+iz] *= bnd.tapz[iz-ib]; - } - } - /* right bottom corner */ - if (bnd.rig==4) { - ixo = mod.ieZx; - ixe = ixo+bnd.ntap; - ibz = (izo); - ibx = (ixo); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1] + - txz[(ix+1)*n1+iz] - txz[ix*n1+iz]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2] + - txz[(ix+2)*n1+iz] - txz[(ix-1)*n1+iz]) ); - - vz[ix*n1+iz] *= bnd.tapxz[(ix-ibx)*bnd.ntap+(iz-ibz)]; - } - } - } - /* left bottom corner */ - if (bnd.lef==4) { - ixo = mod.ioZx-bnd.ntap; - ixe = mod.ioZx; - ibz = (izo); - ibx = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1] + - txz[(ix+1)*n1+iz] - txz[ix*n1+iz]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2] + - txz[(ix+2)*n1+iz] - txz[(ix-1)*n1+iz]) ); - - vz[ix*n1+iz] *= bnd.tapxz[(ibx-ix)*bnd.ntap+(iz-ibz)]; - } - } - } - - - } /* end elastic scheme */ - - } - - /*********/ - /* Left */ - /*********/ - if (bnd.lef==4) { - - if (mod.ischeme <= 2) { /* Acoustic scheme */ - - /* Vx field */ - ixo = mod.ioXx-bnd.ntap; - ixe = mod.ioXx; - izo = mod.ioXz; - ize = mod.ieXz; - - ib = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[(ix-1)*n1+iz]) + - c2*(tzz[(ix+1)*n1+iz] - tzz[(ix-2)*n1+iz])); - - vx[ix*n1+iz] *= bnd.tapx[ib-ix]; - } - } - - /* Vz field */ - ixo = mod.ioZx-bnd.ntap; - ixe = mod.ioZx; - izo = mod.ioZz; - ize = mod.ieZz; - - ib = (bnd.ntap+ixo-1); -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2])); - - vz[ix*n1+iz] *= bnd.tapz[ib-ix]; - } - } - - } - else { /* Elastic scheme */ - - /* Vx field */ - ixo = mod.ioXx-bnd.ntap; - ixe = mod.ioXx; - izo = mod.ioXz; - ize = mod.ieXz; - - ib = (bnd.ntap+ixo-1); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(txx[ix*n1+iz] - txx[(ix-1)*n1+iz] + - txz[ix*n1+iz+1] - txz[ix*n1+iz]) + - c2*(txx[(ix+1)*n1+iz] - txx[(ix-2)*n1+iz] + - txz[ix*n1+iz+2] - txz[ix*n1+iz-1]) ); - - vx[ix*n1+iz] *= bnd.tapx[ib-ix]; - } - } - - /* Vz field */ - ixo = mod.ioZx-bnd.ntap; - ixe = mod.ioZx; - izo = mod.ioZz; - ize = mod.ieZz; - - ib = (bnd.ntap+ixo-1); -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1] + - txz[(ix+1)*n1+iz] - txz[ix*n1+iz]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2] + - txz[(ix+2)*n1+iz] - txz[(ix-1)*n1+iz]) ); - - vz[ix*n1+iz] *= bnd.tapz[ib-ix]; - } - } - } /* end elastic scheme */ - - } - - /*********/ - /* Right */ - /*********/ - if (bnd.rig==4) { - - if (mod.ischeme <= 2) { /* Acoustic scheme */ - - /* Vx field */ - ixo = mod.ieXx; - ixe = mod.ieXx+bnd.ntap; - izo = mod.ioXz; - ize = mod.ieXz; - - ib = (ixe-bnd.ntap); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[(ix-1)*n1+iz]) + - c2*(tzz[(ix+1)*n1+iz] - tzz[(ix-2)*n1+iz])); - - vx[ix*n1+iz] *= bnd.tapx[ix-ib]; - } - } - - /* Vz field */ - ixo = mod.ieZx; - ixe = mod.ieZx+bnd.ntap; - izo = mod.ioZz; - ize = mod.ieZz; - - ib = (ixe-bnd.ntap); -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2])); - - vz[ix*n1+iz] *= bnd.tapz[ix-ib]; - } - } - - } - else { /* Elastic scheme */ - - /* Vx field */ - ixo = mod.ieXx; - ixe = mod.ieXx+bnd.ntap; - izo = mod.ioXz; - ize = mod.ieXz; - - ib = (ixe-bnd.ntap); -#pragma omp for private(ix,iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vx[ix*n1+iz] -= rox[ix*n1+iz]*( - c1*(txx[ix*n1+iz] - txx[(ix-1)*n1+iz] + - txz[ix*n1+iz+1] - txz[ix*n1+iz]) + - c2*(txx[(ix+1)*n1+iz] - txx[(ix-2)*n1+iz] + - txz[ix*n1+iz+2] - txz[ix*n1+iz-1]) ); - - vx[ix*n1+iz] *= bnd.tapx[ix-ib]; - } - } - - /* Vz field */ - ixo = mod.ieZx; - ixe = mod.ieZx+bnd.ntap; - izo = mod.ioZz; - ize = mod.ieZz; - ib = (ixe-bnd.ntap); -#pragma omp for private (ix, iz) - for (ix=ixo; ix<ixe; ix++) { -#pragma ivdep - for (iz=izo; iz<ize; iz++) { - vz[ix*n1+iz] -= roz[ix*n1+iz]*( - c1*(tzz[ix*n1+iz] - tzz[ix*n1+iz-1] + - txz[(ix+1)*n1+iz] - txz[ix*n1+iz]) + - c2*(tzz[ix*n1+iz+1] - tzz[ix*n1+iz-2] + - txz[(ix+2)*n1+iz] - txz[(ix-1)*n1+iz]) ); - - vz[ix*n1+iz] *= bnd.tapz[ix-ib]; - } - } -/* - for (ix=ixo-5; ix<ixo+5; ix++) { - for (iz=0; iz<5; iz++) { - fprintf(stderr,"edge ix=%d iz=%d vz=%e roz=%e tzz=%e txz=%e txx=%e lam=%e l2m=%e\n", ix, iz, vz[ix*n1+iz], roz[ix*n1+iz], -tzz[ix*n1+iz], txz[ix*n1+iz], txx[ix*n1+iz], lam[ix*n1+iz], l2m[ix*n1+iz]); - } - } -*/ - - } /* end elastic scheme */ - - } - - - return 0; -} - -int boundariesV(modPar mod, bndPar bnd, float *vx, float *vz, float *tzz, float *txx, float *txz, float *rox, float *roz, float *l2m, float *lam, float *mul, int itime, int verbose) -{ -/********************************************************************* - - AUTHOR: - Jan Thorbecke (janth@xs4all.nl) - The Netherlands - -***********************************************************************/ - - float c1, c2; - float dp, dvx, dvz; - int ix, iz, ixs, izs, izp, ib; - int nx, nz, n1, n2; - int is0, isrc; - int ixo, ixe, izo, ize; - int npml, ipml, pml; - float kappu, alphu, sigmax, R, a, m, fac, dx, dt; - float *p; - static float *Pxpml, *Pzpml, *sigmu, *RA; - static int allocated=0; - float Jx, Jz, rho, d; - - c1 = 9.0/8.0; - c2 = -1.0/24.0; - nx = mod.nx; - nz = mod.nz; - n1 = mod.naz; - n2 = mod.nax; - dx = mod.dx; - dt = mod.dt; - fac = dt/dx; - if ( (bnd.top==2) || (bnd.bot==2) || (bnd.lef==2) || (bnd.rig==2) ) pml=1; - else pml=0; - -/************************************************************/ -/* PML boundaries for acoustic schemes */ -/* compute all field values in tapered areas */ -/************************************************************/ - - npml=bnd.npml; /* lenght of pml in grid-points */ - if ( (npml != 0) && (itime==0) && pml) { -#pragma omp master -{ - if (allocated) { - free(Pxpml); - free(Pzpml); - free(sigmu); - free(RA); - } - Pxpml = (float *)calloc(2*n1*npml,sizeof(float)); - Pzpml = (float *)calloc(2*n2*npml,sizeof(float)); - sigmu = (float *)calloc(npml,sizeof(float)); - RA = (float *)calloc(npml,sizeof(float)); - allocated = 1; - - /* calculate sigmu and RA only once with fixed velocity Cp */ - m=bnd.m; /* scaling order */ - R=bnd.R; /* the theoretical reflection coefficient after discretization */ - kappu = 1.0; /* auxiliary attenuation coefficient for small angles */ - alphu=0.0; /* auxiliary attenuation coefficient for low frequencies */ - d = (npml-1)*dx; /* depth of pml */ - /* sigmu attenuation factor representing the loss in the PML depends on the grid position in the PML */ - - sigmax = ((3.0*mod.cp_min)/(2.0*d))*log(1.0/R); - for (ib=0; ib<npml; ib++) { /* ib=0 interface between PML and interior */ - a = (float) (ib/(npml-1.0)); - sigmu[ib] = sigmax*pow(a,m); - RA[ib] = (1.0)/(1.0+0.5*dt*sigmu[ib]); -// if (verbose>=3) vmess("PML: sigmax=%e cp=%e sigmu[%d]=%e %e\n", sigmax, mod.cp_min, ib, sigmu[ib], a); - } -} - } - -#pragma omp barrier - if (mod.ischeme == 1 && pml) { /* Acoustic scheme PML's */ - p = tzz; /* Tzz array pointer points to P-field */ - - if (bnd.top==2) mod.ioPz += bnd.npml; - if (bnd.bot==2) mod.iePz -= bnd.npml; - if (bnd.lef==2) mod.ioPx += bnd.npml; - if (bnd.rig==2) mod.iePx -= bnd.npml; - - /* PML top P */ - if (bnd.top == 2) { - /* PML top P-Vz-component */ -#pragma omp for private (ix, iz, dvx, dvz, Jz, ipml) - for (ix=mod.ioPx; ix<mod.iePx; ix++) { - ipml = npml-1; - for (iz=mod.ioPz-npml; iz<mod.ioPz; iz++) { - dvx = c1*(vx[(ix+1)*n1+iz] - vx[ix*n1+iz]) + - c2*(vx[(ix+2)*n1+iz] - vx[(ix-1)*n1+iz]); - dvz = c1*(vz[ix*n1+iz+1] - vz[ix*n1+iz]) + - c2*(vz[ix*n1+iz+2] - vz[ix*n1+iz-1]); - Jz = RA[ipml]*dvz - RA[ipml]*dt*Pzpml[ix*npml+ipml]; - Pzpml[ix*npml+ipml] += sigmu[ipml]*Jz; - p[ix*n1+iz] -= l2m[ix*n1+iz]*(Jz+dvx); - ipml--; - } - } - } - - /* PML left P */ - if (bnd.lef == 2) { - /* PML left P-Vx-component */ -#pragma omp for private (ix, iz, dvx, dvz, Jx, ipml) - for (iz=mod.ioPz; iz<mod.iePz; iz++) { - ipml = npml-1; - for (ix=mod.ioPx-npml; ix<mod.ioPx; ix++) { - dvx = c1*(vx[(ix+1)*n1+iz] - vx[ix*n1+iz]) + - c2*(vx[(ix+2)*n1+iz] - vx[(ix-1)*n1+iz]); - dvz = c1*(vz[ix*n1+iz+1] - vz[ix*n1+iz]) + - c2*(vz[ix*n1+iz+2] - vz[ix*n1+iz-1]); - Jx = RA[ipml]*dvx - RA[ipml]*dt*Pxpml[iz*npml+ipml]; - Pxpml[iz*npml+ipml] += sigmu[ipml]*Jx; - p[ix*n1+iz] -= l2m[ix*n1+iz]*(Jx+dvz); - ipml--; - } - } - } - - /* PML corner left-top P */ - if (bnd.lef == 2 && bnd.top == 2) { - /* PML left P-Vx-component */ -#pragma omp for private (ix, iz, dvx, Jx, ipml) - for (iz=mod.ioPz-npml; iz<mod.ioPz; iz++) { - ipml = npml-1; - for (ix=mod.ioPx-npml; ix<mod.ioPx; ix++) { - dvx = c1*(vx[(ix+1)*n1+iz] - vx[ix*n1+iz]) + - c2*(vx[(ix+2)*n1+iz] - vx[(ix-1)*n1+iz]); - Jx = RA[ipml]*dvx - RA[ipml]*dt*Pxpml[iz*npml+ipml]; - Pxpml[iz*npml+ipml] += sigmu[ipml]*Jx; - p[ix*n1+iz] -= l2m[ix*n1+iz]*(Jx); - ipml--; - } - } - /* PML top P-Vz-component */ -#pragma omp for private (ix, iz, dvz, Jz, ipml) - for (ix=mod.ioPx-npml; ix<mod.ioPx; ix++) { - ipml = npml-1; - for (iz=mod.ioPz-npml; iz<mod.ioPz; iz++) { - dvz = c1*(vz[ix*n1+iz+1] - vz[ix*n1+iz]) + - c2*(vz[ix*n1+iz+2] - vz[ix*n1+iz-1]); - Jz = RA[ipml]*dvz - RA[ipml]*dt*Pzpml[ix*npml+ipml]; - Pzpml[ix*npml+ipml] += sigmu[ipml]*Jz; - p[ix*n1+iz] -= l2m[ix*n1+iz]*(Jz); - ipml--; - } - } - } - - /* PML right P */ - if (bnd.rig == 2) { - /* PML right P Vx-component */ -#pragma omp for private (ix, iz, dvx, dvz, Jx, ipml) - for (iz=mod.ioPz; iz<mod.iePz; iz++) { - ipml = 0; - for (ix=mod.iePx; ix<mod.iePx+npml; ix++) { - dvx = c1*(vx[(ix+1)*n1+iz] - vx[ix*n1+iz]) + - c2*(vx[(ix+2)*n1+iz] - vx[(ix-1)*n1+iz]); - dvz = c1*(vz[ix*n1+iz+1] - vz[ix*n1+iz]) + - c2*(vz[ix*n1+iz+2] - vz[ix*n1+iz-1]); - Jx = RA[ipml]*dvx - RA[ipml]*dt*Pxpml[n1*npml+iz*npml+ipml]; - Pxpml[n1*npml+iz*npml+ipml] += sigmu[ipml]*Jx; - p[ix*n1+iz] -= l2m[ix*n1+iz]*(Jx+dvz); - ipml++; - } - } - } - - /* PML corner right-top P */ - if (bnd.rig == 2 && bnd.top == 2) { - /* PML right P Vx-component */ -#pragma omp for private (ix, iz, dvx, Jx, ipml) - for (iz=mod.ioPz-npml; iz<mod.ioPz; iz++) { - ipml = 0; - for (ix=mod.iePx; ix<mod.iePx+npml; ix++) { - dvx = c1*(vx[(ix+1)*n1+iz] - vx[ix*n1+iz]) + - c2*(vx[(ix+2)*n1+iz] - vx[(ix-1)*n1+iz]); - Jx = RA[ipml]*dvx - RA[ipml]*dt*Pxpml[n1*npml+iz*npml+ipml]; - Pxpml[n1*npml+iz*npml+ipml] += sigmu[ipml]*Jx; - p[ix*n1+iz] -= l2m[ix*n1+iz]*(Jx); - ipml++; - } - } - /* PML top P-Vz-component */ -#pragma omp for private (ix, iz, dvz, Jz, ipml) - for (ix=mod.iePx; ix<mod.iePx+npml; ix++) { - ipml = npml-1; - for (iz=mod.ioPz-npml; iz<mod.ioPz; iz++) { - dvz = c1*(vz[ix*n1+iz+1] - vz[ix*n1+iz]) + - c2*(vz[ix*n1+iz+2] - vz[ix*n1+iz-1]); - Jz = RA[ipml]*dvz - RA[ipml]*dt*Pzpml[ix*npml+ipml]; - Pzpml[ix*npml+ipml] += sigmu[ipml]*Jz; - p[ix*n1+iz] -= l2m[ix*n1+iz]*(Jz); - ipml--; - } - } - } - - /* PML bottom P */ - if (bnd.bot == 2) { - /* PML bottom P Vz-component */ -#pragma omp for private (ix, iz, dvx, dvz, Jz, ipml) - for (ix=mod.ioPx; ix<mod.iePx; ix++) { - ipml = 0; - for (iz=mod.iePz; iz<mod.iePz+npml; iz++) { - dvx = c1*(vx[(ix+1)*n1+iz] - vx[ix*n1+iz]) + - c2*(vx[(ix+2)*n1+iz] - vx[(ix-1)*n1+iz]); - dvz = c1*(vz[ix*n1+iz+1] - vz[ix*n1+iz]) + - c2*(vz[ix*n1+iz+2] - vz[ix*n1+iz-1]); - Jz = RA[ipml]*dvz - RA[ipml]*dt*Pzpml[n2*npml+ix*npml+ipml]; - Pzpml[n2*npml+ix*npml+ipml] += sigmu[ipml]*Jz; - p[ix*n1+iz] -= l2m[ix*n1+iz]*(Jz+dvx); - ipml++; - } - } - } - - /* PML corner bottom-right P */ - if (bnd.bot == 2 && bnd.rig == 2) { - /* PML bottom P Vz-component */ -#pragma omp for private (ix, iz, dvz, Jz, ipml) - for (ix=mod.iePx; ix<mod.iePx+npml; ix++) { - ipml = 0; - for (iz=mod.iePz; iz<mod.iePz+npml; iz++) { - dvz = c1*(vz[ix*n1+iz+1] - vz[ix*n1+iz]) + - c2*(vz[ix*n1+iz+2] - vz[ix*n1+iz-1]); - Jz = RA[ipml]*dvz - RA[ipml]*dt*Pzpml[n2*npml+ix*npml+ipml]; - Pzpml[n2*npml+ix*npml+ipml] += sigmu[ipml]*Jz; - p[ix*n1+iz] -= l2m[ix*n1+iz]*(Jz); - ipml++; - } - } - /* PML right P Vx-component */ -#pragma omp for private (ix, iz, dvx, Jx, ipml) - for (iz=mod.iePz; iz<mod.iePz+npml; iz++) { - ipml = 0; - for (ix=mod.iePx; ix<mod.iePx+npml; ix++) { - dvx = c1*(vx[(ix+1)*n1+iz] - vx[ix*n1+iz]) + - c2*(vx[(ix+2)*n1+iz] - vx[(ix-1)*n1+iz]); - Jx = RA[ipml]*dvx - RA[ipml]*dt*Pxpml[n1*npml+iz*npml+ipml]; - Pxpml[n1*npml+iz*npml+ipml] += sigmu[ipml]*Jx; - p[ix*n1+iz] -= l2m[ix*n1+iz]*(Jx); - //p[ix*n1+iz] -= l2m[ix*n1+iz]*(dvx); - ipml++; - } - } - } - - /* PML corner left-bottom P */ - if (bnd.bot == 2 && bnd.lef == 2) { - /* PML bottom P Vz-component */ -#pragma omp for private (ix, iz, dvz, Jz, ipml) - for (ix=mod.ioPx-npml; ix<mod.ioPx; ix++) { - ipml = 0; - for (iz=mod.iePz; iz<mod.iePz+npml; iz++) { - dvz = c1*(vz[ix*n1+iz+1] - vz[ix*n1+iz]) + - c2*(vz[ix*n1+iz+2] - vz[ix*n1+iz-1]); - Jz = RA[ipml]*dvz - RA[ipml]*dt*Pzpml[n2*npml+ix*npml+ipml]; - Pzpml[n2*npml+ix*npml+ipml] += sigmu[ipml]*Jz; - p[ix*n1+iz] -= l2m[ix*n1+iz]*(Jz); - ipml++; - } - } - /* PML left P Vx-component */ -#pragma omp for private (ix, iz, dvx, Jx, ipml) - for (iz=mod.iePz; iz<mod.iePz+npml; iz++) { - ipml = npml-1; - for (ix=mod.ioPx-npml; ix<mod.ioPx; ix++) { - dvx = c1*(vx[(ix+1)*n1+iz] - vx[ix*n1+iz]) + - c2*(vx[(ix+2)*n1+iz] - vx[(ix-1)*n1+iz]); - Jx = RA[ipml]*dvx - RA[ipml]*dt*Pxpml[iz*npml+ipml]; - Pxpml[iz*npml+ipml] += sigmu[ipml]*Jx; - p[ix*n1+iz] -= l2m[ix*n1+iz]*(Jx); - ipml--; - } - } - } - if (bnd.top==2) mod.ioPz -= bnd.npml; - if (bnd.bot==2) mod.iePz += bnd.npml; - if (bnd.lef==2) mod.ioPx -= bnd.npml; - if (bnd.rig==2) mod.iePx += bnd.npml; - - } /* end acoustic PML */ - - - -/****************************************************************/ -/* Free surface: calculate free surface conditions for stresses */ -/****************************************************************/ - - - ixo = mod.ioPx; - ixe = mod.iePx; - izo = mod.ioPz; - ize = mod.iePz; - - if (mod.ischeme <= 2) { /* Acoustic scheme */ - if (bnd.top==1) { /* free surface at top */ -#pragma omp for private (ix) nowait - for (ix=mod.ioPx; ix<mod.iePx; ix++) { - iz = bnd.surface[ix]; - tzz[ix*n1+iz] = 0.0; - } - } - if (bnd.rig==1) { /* free surface at right */ -#pragma omp for private (iz) nowait - for (iz=mod.ioPz; iz<mod.iePz; iz++) { - tzz[(mod.iePx-1)*n1+iz] = 0.0; - } - } - if (bnd.bot==1) { /* free surface at bottom */ -#pragma omp for private (ix) nowait - for (ix=mod.ioPx; ix<mod.iePx; ix++) { - tzz[ix*n1+mod.iePz-1] = 0.0; - } - } - if (bnd.lef==1) { /* free surface at left */ -#pragma omp for private (iz) nowait - for (iz=mod.ioPz; iz<mod.iePz; iz++) { - tzz[(mod.ioPx-1)*n1+iz] = 0.0; - } - } - } - else { /* Elastic scheme */ -/* The implementation for a topgraphy surface is not yet correct */ - - /* Free surface: calculate free surface conditions for stresses - * Conditions (for upper boundary): - * 1. Tzz = 0 - * 2. Txz = 0 - * 3. Txx: remove term with dVz/dz, computed in e2/e4 routines - * and add extra term with dVx/dx, - * corresponding to free-surface condition for Txx. - * In this way, dVz/dz is not needed in computing Txx - * on the upper stress free boundary. Other boundaries - * are treated similar. - * For the 4th order schemes, the whole virtual boundary - * must be taken into account in the removal terms, - * because the algorithm sets - * velocities on this boundary! - * - * Compute the velocities on the virtual boundary to make interpolation - * possible for receivers. - */ - - if (bnd.top==1) { /* free surface at top */ - izp = bnd.surface[ixo]; -#pragma omp for private (ix, iz) - for (ix=mod.ioPx; ix<mod.iePx; ix++) { - iz = bnd.surface[ix]; - if ( izp==iz ) { - /* clear normal pressure */ - tzz[ix*n1+iz] = 0.0; - - /* This update to Vz might become unstable (2nd order scheme) */ -// vz[ix*n1+iz] = vz[ix*n1+iz+1] - (vx[(ix+1)*n1+iz]-vx[ix*n1+iz])* -// lam[ix*n1+iz]/l2m[ix*n1+iz]; - } - izp=iz; - } - - izp = bnd.surface[ixo]; -#pragma omp for private (ix, iz) - for (ix=mod.ioTx; ix<mod.ieTx; ix++) { - iz = bnd.surface[ix]; - if ( izp==iz ) { - /* assure that txz=0 on boundary by filling virtual boundary */ - txz[ix*n1+iz] = -txz[ix*n1+iz+1]; - /* extra line of txz has to be copied */ - txz[ix*n1+iz-1] = -txz[ix*n1+iz+2]; - } - izp=iz; - } - - /* calculate txx on top stress-free boundary */ - izp = bnd.surface[ixo]; -#pragma omp for private (ix, iz, dp, dvx) - for (ix=mod.ioPx; ix<mod.iePx; ix++) { - iz = bnd.surface[ix]; - if ( izp==iz ) { - if (l2m[ix*n1+iz]!=0.0) { - dp = l2m[ix*n1+iz]-lam[ix*n1+iz]*lam[ix*n1+iz]/l2m[ix*n1+iz]; - dvx = c1*(vx[(ix+1)*n1+iz] - vx[(ix)*n1+iz]) + - c2*(vx[(ix+2)*n1+iz] - vx[(ix-1)*n1+iz]); - txx[ix*n1+iz] = -dvx*dp; - } - } - izp=iz; - } - - /* if surface has also left or right edges */ - izp = bnd.surface[ixo]; -#pragma omp for private (ix, iz, dp, dvz) - for (ix=mod.ioPx+1; ix<mod.iePx; ix++) { - iz = bnd.surface[ix-1]; - if ( izp < iz ) { /* right boundary */ - /* clear normal pressure */ - txx[ix*n1+iz] = 0.0; - if ( (iz-izp) >= 2 ) { /* VR point */ - /* assure that txz=0 on boundary */ - txz[(ix+1)*n1+iz] = -txz[ix*n1+iz]; - txz[(ix+2)*n1+iz] = -txz[(ix-1)*n1+iz] ; - /* calculate tzz on right stress-free boundary */ - if (l2m[ix*n1+iz]!=0.0) { - dvz = c1*(vz[ix*n1+iz+1] - vz[ix*n1+iz]) + - c2*(vz[ix*n1+iz+2] - vz[ix*n1+iz-1]); - dp = l2m[ix*n1+iz]-lam[ix*n1+iz]*lam[ix*n1+iz]/l2m[ix*n1+iz]; - tzz[ix*n1+iz] = -dvz*dp; - } - } - else { - if (izp) { /* IR point */ -// txz[ix*n1+iz] = -txz[ix*n1+iz+1] ; -// txz[ix*n1+iz-1] = -txz[ix*n1+iz+2]; -// txz[(ix+1)*n1+iz] = -txz[ix*n1+iz]; -// txz[(ix+2)*n1+iz] = -txz[(ix-1)*n1+iz] ; -// tzz[ix*n1+iz] = 0.0; - } - else { /* OR point */ -// txz[(ix-1)*n1+iz] = 0.0; -// txz[(ix+1)*n1+iz] = -txz[ix*n1+iz]; -// txz[(ix+2)*n1+iz] = -txz[(ix-1)*n1+iz] ; -// if (l2m[ix*n1+iz]!=0.0) { -// vz[ix*n1+iz] = vz[ix*n1+iz+1] - (vx[(ix+1)*n1+iz]-vx[ix*n1+iz])* -// lam[ix*n1+iz]/l2m[ix*n1+iz]; -// } - } - } - } /* end if right */ - if ( izp > iz ) { /* left boundary */ - /* clear normal pressure */ - txx[ix*n1+iz] = 0.0; - /* assure that txz=0 on boundary */ - txz[(ix-1)*n1+iz] = -txz[ix*n1+iz]; - /* extra line of txz has to be copied */ - txz[(ix-2)*n1+iz] = -txz[(ix+1)*n1+iz] ; - /* calculate tzz on left stress-free boundary */ - dvz = c1*(vz[ix*n1+iz+1] - vz[ix*n1+iz]) + - c2*(vz[ix*n1+iz+2] - vz[ix*n1+iz-1]); - if (l2m[ix*n1+iz]!=0.0) { - dp = l2m[ix*n1+iz]-lam[ix*n1+iz]*lam[ix*n1+iz]/l2m[ix*n1+iz]; - tzz[ix*n1+iz] = -dvz*dp; - } - } /* end if left */ - izp=iz; -// fprintf(stderr,"V4 ix=2123 iz=1 tzz=%e\n", tzz[2123*n1+1]); - // izp=bnd.surface[MAX(ix-2,0)];; - } /* end ix loop */ - } - - - if (bnd.rig==1) { /* free surface at right */ - ix = mod.iePx; -#pragma omp for private (iz) - for (iz=mod.ioPz; iz<mod.iePz; iz++) { - /* clear normal pressure */ - txx[ix*n1+iz] = 0.0; - } -#pragma omp for private (iz) - for (iz=mod.ioTz; iz<mod.ieTz; iz++) { - /* assure that txz=0 on boundary by filling virtual boundary */ - txz[(ix+1)*n1+iz] = -txz[(ix)*n1+iz]; - /* extra line of txz has to be copied */ - txz[(ix+2)*n1+iz] = -txz[(ix-1)*n1+iz] ; - } - /* calculate tzz on right stress-free boundary */ -#pragma omp for private (iz) - for (iz=mod.ioPz; iz<mod.iePz; iz++) { - dvz = c1*(vz[(ix)*n1+iz+1] - vz[(ix)*n1+iz]) + - c2*(vz[(ix)*n1+iz+2] - vz[(ix)*n1+iz-1]); - if (l2m[ix*n1+iz]!=0.0) { - dp = l2m[(ix)*n1+iz]-lam[(ix)*n1+iz]*lam[(ix)*n1+iz]/l2m[(ix)*n1+iz]; - tzz[(ix)*n1+iz] = -dvz*dp; - } - } - } - - - if (bnd.bot==1) { /* free surface at bottom */ - iz = mod.iePz; -#pragma omp for private (ix) - for (ix=mod.ioPx; ix<mod.iePx; ix++) { - /* clear normal pressure */ - tzz[ix*n1+iz] = 0.0; - } -#pragma omp for private (ix) - for (ix=mod.ioTx; ix<mod.ieTx; ix++) { - /* assure that txz=0 on boundary by filling virtual boundary */ - txz[ix*n1+iz+1] = -txz[ix*n1+iz]; - /* extra line of txz has to be copied */ - txz[ix*n1+iz+2] = -txz[ix*n1+iz-1]; - } - /* calculate txx on bottom stress-free boundary */ -#pragma omp for private (ix) - for (ix=mod.ioPx; ix<mod.iePx; ix++) { - dvx = c1*(vx[(ix+1)*n1+iz] - vx[ix*n1+iz]) + - c2*(vx[(ix+2)*n1+iz] - vx[(ix-1)*n1+iz]); - if (l2m[ix*n1+iz]!=0.0) { - dp = l2m[ix*n1+iz]-lam[ix*n1+iz]*lam[ix*n1+iz]/l2m[ix*n1+iz]; - txx[ix*n1+iz] = -dvx*dp; - } - } - } - - if (bnd.lef==1) { /* free surface at left */ - ix = mod.ioPx; -#pragma omp for private (iz) - for (iz=mod.ioPz; iz<mod.iePz; iz++) { - /* clear normal pressure */ - txx[ix*n1+iz] = 0.0; - } -#pragma omp for private (iz) - for (iz=mod.ioTz; iz<mod.ieTz; iz++) { - /* assure that txz=0 on boundary by filling virtual boundary */ - txz[(ix)*n1+iz] = -txz[(ix+1)*n1+iz]; - /* extra line of txz has to be copied */ - txz[(ix-1)*n1+iz] = -txz[(ix+2)*n1+iz] ; - } - /* calculate tzz on left stress-free boundary */ -#pragma omp for private (iz) - for (iz=mod.ioPz; iz<mod.iePz; iz++) { - dvz = c1*(vz[ix*n1+iz+1] - vz[ix*n1+iz]) + - c2*(vz[ix*n1+iz+2] - vz[ix*n1+iz-1]); - if (l2m[ix*n1+iz]!=0.0) { - dp = l2m[ix*n1+iz]-lam[ix*n1+iz]*lam[ix*n1+iz]/l2m[ix*n1+iz]; - tzz[ix*n1+iz] = -dvz*dp; - } - } - } - - - } - - return 0; -} diff --git a/fdelmodc/fdelmodc b/fdelmodc/fdelmodc deleted file mode 100755 index 2490595cb11059d767c62d36f5e165bc82028adc..0000000000000000000000000000000000000000 Binary files a/fdelmodc/fdelmodc and /dev/null differ diff --git a/raytime/JespersRayTracer.c b/raytime/JespersRayTracer.c index 67e590a6f979f10e416a9484fb331b214e3c2a02..bc49d04d31788c85ec1b154c52d3025e2cd5db4b 100644 --- a/raytime/JespersRayTracer.c +++ b/raytime/JespersRayTracer.c @@ -178,10 +178,8 @@ int getWaveParameter(float *slowness, icoord size, float dgrid, fcoord s, fcoord int getnRay(icoord size, fcoord s, fcoord r, float dx, int nRayStep) { - float x, y, z; int dn, nRayTmp; float dl, dr; - fcoord position; H = (size.z-1)*dx; L = (size.x-1)*dx; @@ -230,7 +228,6 @@ int traceTwoPoint(fcoord s, fcoord r, int nRay, fcoord *rayReference3D) int calculatePerturbedRay(fcoord *rayPerturbed3D, fcoord s, fcoord r, int nRay, fcoord *rayReference3D, float *slowness, icoord size) { float si, sl, deltaS, gso, angle, qx, qz; - float xTmp, yTmp, zTmp; int i; sl = sqrt(pow((r.x-s.x), 2) + pow((r.y-s.y), 2) + pow((r.z-s.z), 2)); diff --git a/raytime/Makefile b/raytime/Makefile index 6d454e7c26da08add57a2a606503febca3a2529e..0d70c1b74885e6a95cee6c2a78688925ac758f57 100644 --- a/raytime/Makefile +++ b/raytime/Makefile @@ -7,7 +7,7 @@ include ../Make_include ALLINC = -I. LIBS += -L$L -lgenfft -lm $(LIBSM) #LIBS += -L$L -lgenfft -lm -lc -#OPTC = -g -Wall -fsignaling-nans -O0 +OPTC = -g -Wall -fsignaling-nans -O0 #OPTC += -fopenmp -Waddress #OPTC := $(subst -O3 -ffast-math, -O1 -g ,$(OPTC)) #PGI options for compiler feedback diff --git a/raytime/getParameters.c b/raytime/getParameters.c index 265b823d1c1e37d2e9fd9c0252645ff545b6a6f6..1651e1af3281d62f9df226c622287a3bb4fefdf9 100644 --- a/raytime/getParameters.c +++ b/raytime/getParameters.c @@ -26,43 +26,28 @@ int optncr(int n); int getModelInfo(char *file_name, int *n1, int *n2, float *d1, float *d2, float *f1, float *f2, float *min, float *max, int *axis, int zeroch, int verbose); -int getWaveletInfo(char *file_src, int *n1, int *n2, float *d1, float *d2, float *f1, float *f2, float *fmax, int *nxm, int verbose); - -int getWaveletHeaders(char *file_src, int n1, int n2, float *gx, float *sx, float *gelev, float *selev, int verbose); - - int recvPar(recPar *rec, float sub_x0, float sub_z0, float dx, float dz, int nx, int nz); int writesufile(char *filename, float *data, int n1, int n2, float f1, float f2, float d1, float d2); int getParameters(modPar *mod, recPar *rec, snaPar *sna, wavPar *wav, srcPar *src, shotPar *shot, bndPar *bnd, rayPar *ray, int verbose) { - int isnapmax1, isnapmax2, isnapmax, sna_nrsna; - int n1, n2, nx, nz, nsrc, ix, axis, ioPz, is0, optn; + int nx, nz, nsrc, ix, axis, is0; int idzshot, idxshot; int src_ix0, src_iz0, src_ix1, src_iz1; - int disable_check; - float cp_min, cp_max, cs_min, cs_max, ro_min, ro_max; - float stabfactor,dispfactor, cmin, dt, fmax, scl, wfct, tapfact; - float zstart, xstart,d1,d2,f1,f2,sub_x0,sub_z0; + float cp_min, cp_max; + float sub_x0,sub_z0; float srcendx, srcendz, dx, dz; - float xsrc, zsrc, dxshot, dzshot, dtshot; + float xsrc, zsrc, dxshot, dzshot; float dxrcv,dzrcv,dxspread,dzspread; - float tsnap1, tsnap2, dtsnap, dxsnap, dzsnap, dtrcv; - float xsnap1, xsnap2, zsnap1, zsnap2, xmax, zmax; - float xsrc1, xsrc2, zsrc1, zsrc2, tsrc1, tsrc2, tlength, tactive; - float src_angle, src_velo, p, grad2rad, rdelay, scaledt; + float xmax, zmax; + float xsrc1, xsrc2, zsrc1, zsrc2; float *xsrca, *zsrca, rrcv; float rsrc, oxsrc, ozsrc, dphisrc, ncsrc; size_t nsamp; - int i, j; - int cfree; - int tapleft,tapright,taptop,tapbottom; int nxsrc, nzsrc; - int largeSUfile; - int is,ntraces,length_random; - float rand; - char *src_positions, tmpname[1024]; + int is; + char *src_positions; if (!getparint("verbose",&verbose)) verbose=0; @@ -82,15 +67,6 @@ int getParameters(modPar *mod, recPar *rec, snaPar *sna, wavPar *wav, srcPar *sr mod->nz = nz; mod->nx = nx; - if(!getparfloat("dt",&mod->dt)) mod->dt = 0.004; - if(!getparfloat("tmod",&mod->tmod)) mod->tmod=1.0; - - assert(mod->dt!=0.0); - /* check if receiver delays is defined; option inactive: add delay time to total modeling time */ - if (!getparfloat("rec_delay",&rdelay)) rdelay=0.0; - rec->delay=NINT(rdelay/mod->dt); - dt = mod->dt; - /* origin of model in real (non-grid) coordinates */ mod->x0 = sub_x0; mod->z0 = sub_z0; @@ -98,14 +74,6 @@ int getParameters(modPar *mod, recPar *rec, snaPar *sna, wavPar *wav, srcPar *sr zmax = sub_z0+(nz-1)*dz; if (verbose) { - vmess("*******************************************"); - vmess("************** general info ***************"); - vmess("*******************************************"); - vmess("tmod = %f",mod->tmod); - vmess("ntsam = %d dt = %f(%e)",mod->nt, mod->dt, mod->dt); - if (mod->ischeme == 1) vmess("Acoustic grid pressure"); - if (mod->grid_dir) vmess("Time reversed modelling"); - else vmess("Forward modelling"); vmess("*******************************************"); vmess("*************** model info ****************"); vmess("*******************************************"); @@ -121,9 +89,6 @@ int getParameters(modPar *mod, recPar *rec, snaPar *sna, wavPar *wav, srcPar *sr if (!getparfloat("xsrc",&xsrc)) xsrc=sub_x0+((nx-1)*dx)/2.0; if (!getparfloat("zsrc",&zsrc)) zsrc=sub_z0; -// if (!getparint("nsrc",&nsrc)) nsrc=1; - - //if (!getparint("nshot",&shot->n)) shot->n=1; if (!getparint("nxshot",&shot->nx)) shot->nx=1; if (!getparint("nzshot",&shot->nz)) shot->nz=1; if (!getparfloat("dxshot",&dxshot)) dxshot=dx; @@ -228,56 +193,26 @@ int getParameters(modPar *mod, recPar *rec, snaPar *sna, wavPar *wav, srcPar *sr /* number of sources per shot modeling */ if (!getparint("src_window",&src->window)) src->window=0; - if (!getparfloat("src_angle",&src_angle)) src_angle=0.; - if (!getparfloat("src_velo",&src_velo)) src_velo=1500.; if (!getparint("distribution",&src->distribution)) src->distribution=0; if (!getparfloat("amplitude", &src->amplitude)) src->amplitude=0.0; - if (!getparfloat("tlength", &tlength)) tlength=mod->dt*(mod->nt-1); if (src->random && nxsrc==0) { if (!getparint("nsrc",&nsrc)) nsrc=1; if (!getparfloat("xsrc1", &xsrc1)) xsrc1=sub_x0; if (!getparfloat("xsrc2", &xsrc2)) xsrc2=xmax; if (!getparfloat("zsrc1", &zsrc1)) zsrc1=sub_z0; if (!getparfloat("zsrc2", &zsrc2)) zsrc2=zmax; - if (!getparfloat("tsrc1", &tsrc1)) tsrc1=0.0; - if (!getparfloat("tsrc2", &tsrc2)) tsrc2=mod->tmod; - if (!getparfloat("tactive", &tactive)) tactive=tsrc2; - tsrc2 = MIN(tsrc2, mod->tmod); - if (!getparfloat("tlength", &tlength)) tlength=tsrc2-tsrc1; - if (!getparint("length_random", &length_random)) length_random=1; dxshot = xsrc2-xsrc1; dzshot = zsrc2-zsrc1; - dtshot = tsrc2-tsrc1; - src->tbeg = (float *)malloc(nsrc*sizeof(float)); - src->tend = (float *)malloc(nsrc*sizeof(float)); src->x = (int *)malloc(nsrc*sizeof(int)); src->z = (int *)malloc(nsrc*sizeof(int)); nsamp = 0; -/* write time and length of source signals */ - - if (verbose>3) { - float *dum; - dum = (float *)calloc(mod->nt, sizeof(float)); - for (is=0; is<nsrc; is++) { - dum[(int)floor(src->tbeg[is]/mod->dt)] = src->tend[is]-src->tbeg[is]; - } - FILE *fp; - sprintf(tmpname,"srcTimeLengthN=%d.bin",mod->nt); - fp = fopen(tmpname, "w+"); - fwrite(dum, sizeof(float), mod->nt, fp); - fclose(fp); - free(dum); - } - } else if (nxsrc != 0) { /* source array is defined */ nsrc=nxsrc; src->x = (int *)malloc(nsrc*sizeof(int)); src->z = (int *)malloc(nsrc*sizeof(int)); - src->tbeg = (float *)malloc(nsrc*sizeof(float)); - src->tend = (float *)malloc(nsrc*sizeof(float)); xsrca = (float *)malloc(nsrc*sizeof(float)); zsrca = (float *)malloc(nsrc*sizeof(float)); getparfloat("xsrca", xsrca); @@ -285,7 +220,6 @@ int getParameters(modPar *mod, recPar *rec, snaPar *sna, wavPar *wav, srcPar *sr for (is=0; is<nsrc; is++) { src->x[is] = NINT((xsrca[is]-sub_x0)/dx); src->z[is] = NINT((zsrca[is]-sub_z0)/dz); - src->tbeg[is] = 0.0; if (verbose>3) fprintf(stderr,"Source Array: xsrc[%d]=%f zsrc=%f\n", is, xsrca[is], zsrca[is]); } src->random = 1; @@ -306,24 +240,6 @@ int getParameters(modPar *mod, recPar *rec, snaPar *sna, wavPar *wav, srcPar *sr src->x = (int *)malloc(nsrc*sizeof(int)); src->z = (int *)malloc(nsrc*sizeof(int)); - src->tbeg = (float *)malloc(nsrc*sizeof(float)); - src->tend = (float *)malloc(nsrc*sizeof(float)); - grad2rad = 17.453292e-3; - p = sin(src_angle*grad2rad)/src_velo; - if (p < 0.0) { - for (is=0; is<nsrc; is++) { - src->tbeg[is] = fabsf((nsrc-is-1)*dx*p); - } - } - else { - for (is=0; is<nsrc; is++) { - src->tbeg[is] = is*dx*p; - } - } - for (is=0; is<nsrc; is++) { - src->tend[is] = src->tbeg[is] + (wav->nt-1)*wav->dt; - } - is0 = -1*floor((nsrc-1)/2); for (is=0; is<nsrc; is++) { src->x[is] = is0 + is; @@ -340,15 +256,11 @@ int getParameters(modPar *mod, recPar *rec, snaPar *sna, wavPar *wav, srcPar *sr vmess("*********** source array info *************"); vmess("*******************************************"); vmess("Areal source array is defined with %d sources.",nsrc); -/* vmess("Memory requirement for sources = %.2f MB.",sizeof(float)*(wav->nx*(wav->nt/(1024.0*1024.0))));*/ vmess("Memory requirement for sources = %.2f MB.",sizeof(float)*(nsamp/(1024.0*1024.0))); - if (src->plane) vmess("Computed p-value = %f.",p); } if (src->random) { vmess("Sources are placed at random locations in domain: "); vmess(" x[%.2f : %.2f] z[%.2f : %.2f] ", xsrc1, xsrc2, zsrc1, zsrc2); - vmess(" and all start in time window t[%.3f : %.3f].", tsrc1, tsrc2); - vmess(" after time %.3f the sources will not be active anymore.", tactive); } } @@ -357,47 +269,17 @@ int getParameters(modPar *mod, recPar *rec, snaPar *sna, wavPar *wav, srcPar *sr if (!getparint("sinkdepth",&rec->sinkdepth)) rec->sinkdepth=0; if (!getparint("sinkdepth_src",&src->sinkdepth)) src->sinkdepth=0; if (!getparint("sinkvel",&rec->sinkvel)) rec->sinkvel=0; - if (!getparfloat("dtrcv",&dtrcv)) dtrcv=0.004; - /* TODO check if dtrcv is integer multiple of dt */ - rec->skipdt=NINT(dtrcv/dt); - dtrcv = mod->dt*rec->skipdt; - if (!getparfloat("rec_delay",&rdelay)) rdelay=0.0; - if (!getparint("rec_ntsam",&rec->nt)) rec->nt=NINT((mod->tmod)/dtrcv)+1; - if (!getparint("rec_int_p",&rec->int_p)) rec->int_p=0; - if (!getparint("rec_int_vx",&rec->int_vx)) rec->int_vx=0; - if (!getparint("rec_int_vz",&rec->int_vz)) rec->int_vz=0; if (!getparint("max_nrec",&rec->max_nrec)) rec->max_nrec=15000; - if (!getparint("scale",&rec->scale)) rec->scale=0; if (!getparfloat("dxspread",&dxspread)) dxspread=0; if (!getparfloat("dzspread",&dzspread)) dzspread=0; - rec->nt=MIN(rec->nt, NINT((mod->tmod)/dtrcv)+1); - -/* allocation of receiver arrays is done in recvPar */ -/* - rec->max_nrec += rec->max_nrec+1; - rec->x = (int *)calloc(rec->max_nrec,sizeof(int)); - rec->z = (int *)calloc(rec->max_nrec,sizeof(int)); - rec->xr = (float *)calloc(rec->max_nrec,sizeof(float)); - rec->zr = (float *)calloc(rec->max_nrec,sizeof(float)); -*/ - + /* calculates the receiver coordinates */ recvPar(rec, sub_x0, sub_z0, dx, dz, nx, nz); - if (!getparint("rec_type_vz", &rec->type.vz)) rec->type.vz=1; - if (!getparint("rec_type_vx", &rec->type.vx)) rec->type.vx=0; - if (!getparint("rec_type_ud", &rec->type.ud)) rec->type.ud=0; - /* receivers are on a circle, use default interpolation to real (not on a grid-point) receiver position */ if (getparfloat("rrcv", &rrcv)) { if (!getparint("rec_int_p",&rec->int_p)) rec->int_p=3; - if (!getparint("rec_int_vx",&rec->int_vx)) rec->int_vx=3; - if (!getparint("rec_int_vz",&rec->int_vz)) rec->int_vz=3; - } - if (rec->int_p==3) { - rec->int_vx=3; - rec->int_vz=3; } if (verbose) { @@ -408,65 +290,14 @@ int getParameters(modPar *mod, recPar *rec, snaPar *sna, wavPar *wav, srcPar *sr vmess("************* receiver info ***************"); vmess("*******************************************"); vmess("ntrcv = %d nrcv = %d ", rec->nt, rec->n); - vmess("dtrcv = %f ", dtrcv ); vmess("dzrcv = %f dxrcv = %f ", dzrcv, dxrcv); - vmess("time-delay = %f = points = %d", rdelay, rec->delay); - if ( fmax > (1.0/(2.0*dtrcv)) ) { - vwarn("Receiver time sampling (dtrcv) is aliased."); - vwarn("time sampling should be < %.6f", 1.0/(2.0*fmax) ); - } - vmess("Receiver sampling can be => %.6e", 1.0/(2.0*fmax)); vmess("Receiver array at coordinates: "); vmess("zmin = %f zmax = %f ", rec->zr[0]+sub_z0, rec->zr[rec->n-1]+sub_z0); vmess("xmin = %f xmax = %f ", rec->xr[0]+sub_x0, rec->xr[rec->n-1]+sub_x0); vmess("which are gridpoints: "); vmess("izmin = %d izmax = %d ", rec->z[0], rec->z[rec->n-1]); vmess("ixmin = %d ixmax = %d ", rec->x[0], rec->x[rec->n-1]); - if (rec->type.p) { - fprintf(stderr," %s: Receiver interpolation for P: ",xargv[0]); - if(rec->int_p==0) fprintf(stderr,"p->p\n"); - if(rec->int_p==1) fprintf(stderr,"p->vz\n"); - if(rec->int_p==2) fprintf(stderr,"p->vx\n"); - if(rec->int_p==3) fprintf(stderr,"interpolate to actual (no-grid) position of receiver\n"); - } - if (rec->type.vx) { - fprintf(stderr," %s: Receiver interpolation for Vx: ",xargv[0]); - if(rec->int_vx==0) fprintf(stderr,"vx->vx\n"); - if(rec->int_vx==1) fprintf(stderr,"vx->vz\n"); - if(rec->int_vx==2) fprintf(stderr,"vx->txx/tzz\n"); - if(rec->int_vx==3) fprintf(stderr,"interpolate to real(no-grid) position of receiver\n"); - } - if (rec->type.vz) { - fprintf(stderr," %s: Receiver interpolation for Vz: ",xargv[0]); - if(rec->int_vz==0) fprintf(stderr,"vz->vz\n"); - if(rec->int_vz==1) fprintf(stderr,"vz->vx\n"); - if(rec->int_vz==2) fprintf(stderr,"vz->txx/tzz\n"); - if(rec->int_vz==3) fprintf(stderr,"interpolate to real(no-grid) position of receiver\n"); - } - fprintf(stderr," %s: Receiver types : ",xargv[0]); - if (rec->type.vz) fprintf(stderr,"Vz "); - if (rec->type.vx) fprintf(stderr,"Vx "); - if (rec->type.p) fprintf(stderr,"p "); - if (rec->type.ud) fprintf(stderr,"P+ P- "); - if (mod->ischeme>2) { - if (rec->type.txx) fprintf(stderr,"Txx "); - if (rec->type.tzz) fprintf(stderr,"Tzz "); - if (rec->type.txz) fprintf(stderr,"Txz "); - if (rec->type.pp) fprintf(stderr,"P "); - if (rec->type.ss) fprintf(stderr,"S "); - } fprintf(stderr,"\n"); - if ( ( ((mod->nt*mod->dt-rec->delay)/rec->skipdt)+1) > 16384) { - vwarn("Number of samples in receiver file is larger that SU can handle "); - vwarn("use the paramater rec_ntsam=nt (with nt < 16384) to avoid this"); - } - if ((mod->nt-rec->delay)*mod->dt > rec->nt*dtrcv) { - int nfiles = ceil((mod->nt*mod->dt)/(rec->nt*dtrcv)); - int lastn = floor((mod->nt)%(rec->nt*rec->skipdt)/rec->skipdt)+1; - vmess("Receiver recordings will be written to %d files",nfiles); - vmess("Last file will contain %d samples",lastn); - - } } else { vmess("*************** no receivers **************"); diff --git a/raytime/raytime.c b/raytime/raytime.c index be7fb12b2326875bdbd8b716c368b552412f3d82..1c1e2414191ffc8e3fe82a001d26a0cbd816a631 100644 --- a/raytime/raytime.c +++ b/raytime/raytime.c @@ -50,7 +50,6 @@ char *sdoc[] = { " file_rcv=recv.su .. base name for receiver files", " dx= ............... read from model file: if dx==0 then dx= can be used to set it", " dz= ............... read from model file: if dz==0 then dz= can be used to set it", -" dt= ............... read from file_src: if dt==0 then dt= can be used to set it", "" , " RAY TRACING PARAMETERS:", " smoothwindow=0 .... if set lenght of 2/3D smoothing window on slowness", @@ -133,25 +132,11 @@ int main(int argc, char **argv) bndPar bnd; shotPar shot; rayPar ray; - float **src_nwav; - float *rox, *roz, *l2m, *lam, *mul; - float *tss, *tes, *tep, *p, *q, *r; - float *vx, *vz, *tzz, *txz, *txx; - float *rec_vx, *rec_vz, *rec_p; float *velocity, *slowness; - float *rec_txx, *rec_tzz, *rec_txz; - float *rec_pp, *rec_ss; - float *rec_udp, *rec_udvz; - float *beam_vx, *beam_vz, *beam_p; - float *beam_txx, *beam_tzz, *beam_txz; - float *beam_pp, *beam_ss; - float sinkvel; - double t0, t1, t2, t3, tt, tinit; - size_t size, sizem, nsamp; - int n1, ix, iz, ir, ixshot, izshot, i; - int ioPx, ioPz; - int it0, it1, its, it, fileno, isam; - int ixsrc, izsrc, irec; + double t0, t1, tinit; + size_t size; + int n1, ix, iz, ir, ixshot, izshot; + int irec; int nRayStep; fcoord coordsx, coordgx, Time; icoord grid; @@ -161,7 +146,6 @@ int main(int argc, char **argv) size_t nwrite; int verbose; FILE *fpt, *fpa; - double ddt; t0= wallclock_time(); initargs(argc,argv); @@ -173,7 +157,6 @@ int main(int argc, char **argv) /* allocate arrays for model parameters: the different schemes use different arrays */ n1 = mod.nz; - sizem=mod.nx*mod.nz; velocity = (float *)calloc(mod.nx*mod.nz,sizeof(float)); slowness = (float *)calloc(mod.nx*mod.nz,sizeof(float)); @@ -247,8 +230,7 @@ int main(int argc, char **argv) assert(fpa != NULL); } - ddt = (double)mod.dt;/* to avoid rounding in 32 bit precision */ - hdr.dt = (unsigned short)lround((((double)1.0e6*ddt*rec.skipdt))); + hdr.dt = (unsigned short)1; hdr.scalco = -1000; hdr.scalel = -1000; hdr.trid = 1; diff --git a/raytime/readModel.c b/raytime/readModel.c index 8ac2640eb602e249c51c153290c185d1c5944584..e54c6d1ed71eda50505c954f1713a0243cd84843 100644 --- a/raytime/readModel.c +++ b/raytime/readModel.c @@ -31,18 +31,12 @@ int readModel(modPar mod, bndPar bnd, float *velocity, float *slowness) FILE *fpcp; size_t nread; int i, tracesToDo, j; - int n1, ix, iz, nz, nx; - int ixo, izo, ixe, ize; - int ioXx, ioXz, ioZz, ioZx, ioPx, ioPz, ioTx, ioTz; - float cp2, cs2, cs11, cs12, cs21, cs22, mul, mu, lamda2mu, lamda; - float cs2c, cs2b, cs2a, cpx, cpz, bx, bz, fac; - float a, b; + int nz; segy hdr; /* grid size and start positions for the components */ nz = mod.nz; - nx = mod.nx; /* open files and read first header */