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

/*------------------------------------------------------------------------
 *   store amplitudes (particle velocities or pressure or curl and div) 
 *    at receiver positions in arrays
 *  ----------------------------------------------------------------------*/

#include "fd.h"

26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
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 Steinweg's avatar
Tilman Steinweg committed
138 139 140

	}
}