seismo_ssg.c 5.21 KB
Newer Older
tilman.metz's avatar
tilman.metz committed
1
/*-----------------------------------------------------------------------------------------
2
 * Copyright (C) 2016  For the list of authors, see file AUTHORS.
tilman.metz's avatar
tilman.metz committed
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
 *
 * This file is part of DENISE.
 * 
 * DENISE is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, version 2.0 of the License only.
 * 
 * DENISE is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with DENISE. See file COPYING and/or <http://www.gnu.org/licenses/gpl-2.0.html>.
-----------------------------------------------------------------------------------------*/

/*------------------------------------------------------------------------
 *   store amplitudes (particle velocities or pressure or curl and div) 
 *    at receiver positions in arrays
 *   last update 27/12/01, T. Bohlen
 *  ----------------------------------------------------------------------*/

#include "fd.h"

27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
void seismo_ssg(int lsamp, int ntr, int **recpos, float **sectionvx,
                float **sectionvy,float **sectionvz, float **sectionp, float **sectioncurl, float **sectiondiv,
                float **vx, float **vy, float **vz, float **sxx, float **syy, float **sp, float **pi, float **u, float *hc){
    
    extern int NDT, SEISMO, FDORDER, ACOUSTIC,WAVETYPE;
    extern float DH, DT;
    extern FILE *FP;
    int i,j, itr, ins, nxrec, nyrec, m, fdoh;
    float dh24, dhi, vxx, vyy, vxy, vyx;
    
    
    dh24=1.0/(DH*24.0);
    fdoh = FDORDER/2;
    dhi = DT/DH;
    
    /*ins=lsamp/NDT;*/
    ins=lsamp;
    for (itr=1;itr<=ntr;itr++){
        nxrec=recpos[1][itr];
        nyrec=recpos[2][itr];
        switch (SEISMO){
            case 1 :
                if (WAVETYPE==1 || WAVETYPE==3) {
                    sectionvx[itr][ins]=vx[nyrec][nxrec];
                    sectionvy[itr][ins]=vy[nyrec][nxrec];
                }
                if (WAVETYPE==2 || WAVETYPE==3) {
                    sectionvz[itr][ins]=vz[nyrec][nxrec];
                }
                break;
                
            case 2 :
                if(!ACOUSTIC)
                    sectionp[itr][ins]=-sxx[nyrec][nxrec]-syy[nyrec][nxrec];
                else
                    sectionp[itr][ins]=-sp[nyrec][nxrec];
                break;
                
            case 3 :
                i=nxrec; j=nyrec;
                
                vxx = 0;
                vyy = 0;
                vyx = 0;
                vxy = 0;
                for (m=1; m<=fdoh; m++) {
                    vxx += hc[m]*(vx[j][i+m-1] -vx[j][i-m]  );
                    vyy += hc[m]*(vy[j+m-1][i] -vy[j-m][i]  );
                    vyx += hc[m]*(vy[j][i+m]   -vy[j][i-m+1]);
                    vxy += hc[m]*(vx[j+m][i]   -vx[j-m+1][i]);
                }
                vxx *= dhi;
                vyy *= dhi;
                vyx *= dhi;
                vxy *= dhi;
                
                sectiondiv[itr][ins]=(vxx+vyy)*sqrt(pi[j][i]);
                if(!ACOUSTIC)
                    sectioncurl[itr][ins]=(vxy-vyx)*sqrt(u[j][i]);
                else
                    sectioncurl[itr][ins]=0;
                break;
                
            case 4 :
                i=nxrec; j=nyrec;
                
                vxx = 0;
                vyy = 0;
                vyx = 0;
                vxy = 0;
                for (m=1; m<=fdoh; m++) {
                    vxx += hc[m]*(vx[j][i+m-1] -vx[j][i-m]  );
                    vyy += hc[m]*(vy[j+m-1][i] -vy[j-m][i]  );
                    vyx += hc[m]*(vy[j][i+m]   -vy[j][i-m+1]);
                    vxy += hc[m]*(vx[j+m][i]   -vx[j-m+1][i]);
                }
                vxx *= dhi;
                vyy *= dhi;
                vyx *= dhi;
                vxy *= dhi;
                
                sectiondiv[itr][ins]=(vxx+vyy)*sqrt(pi[j][i]);
                if(!ACOUSTIC)
                    sectioncurl[itr][ins]=(vxy-vyx)*sqrt(u[j][i]);
                else
                    sectioncurl[itr][ins]=0;
                sectionvx[itr][ins]=vx[nyrec][nxrec];
                sectionvy[itr][ins]=vy[nyrec][nxrec];
                if (WAVETYPE==2 || WAVETYPE==3) {
                    sectionvz[itr][ins]=vz[nyrec][nxrec];
                }
                if(!ACOUSTIC)
                    sectionp[itr][ins]=-sxx[nyrec][nxrec]-syy[nyrec][nxrec];
                else
                    sectionp[itr][ins]=-sp[nyrec][nxrec];
                break;
                
            case 5 :
                if (WAVETYPE==1 || WAVETYPE==3) {
                    sectionvx[itr][ins]=vx[nyrec][nxrec];
                    sectionvy[itr][ins]=vy[nyrec][nxrec];
                    if(!ACOUSTIC)
                        sectionp[itr][ins]=-sxx[nyrec][nxrec]-syy[nyrec][nxrec];
                    else
                        sectionp[itr][ins]=-sp[nyrec][nxrec];
                }
                if (WAVETYPE==2 || WAVETYPE==3) {
                    sectionvz[itr][ins]=vz[nyrec][nxrec];
                }
                break;
                
        }
tilman.metz's avatar
tilman.metz committed
139 140 141

	}
}