/* HWT_3D_mm: Acoustical 3-D Huygens wavefront/ray tracing for moving media. An extension for moving media by N. Zabotin, O.A. Godin and L.Ye. Zabotina (Copyright (C) 2013 University of Colorado Boulder) of an algorithm developed by P. Sava and S. Fomel as a part of Madagascar open project (Copyright (C) 2007 Colorado School of Mines). This program 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; either version 2 of the License, or (at your option) any later version. This program 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 (file COPYING.txt). You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Make file for Linux (tested with Intel C++ compiler): HWT_3D_mm_make For Windows: Use MS Visual Studio standard procedures (tested with Intel compiler) USAGE: HWT_3D_mm par= PARAMETERS: infile - name of text file containing parameters of the model of propagation medium: description of the grid used and names of binary files with sound speed and current data; example files for a model with linear profiles: linz3d_u1.txt, a01_u05_gama005.rsf, a01_u05_gama005_x.rsf, a01_u05_gama005_y.rsf; example program write_rsf_3d.cpp demonstrates creation of the binary files. dt,nt - time step (in s) and total number of time steps; ng,og,dg - number of steps, initial value, and step for the grazing angle (in deg); nh,oh,dh - number of steps, initial value, and step for the bearing angle (in deg); xsou,ysou,zsou - coordinates of a point source (in km); refl - switch reflections from the plane surface z=0 on (=y) or off (=n). Input parameters triggering specific modes of calculation: 1. 1D timefront calculation (time dependence of 1D coordinates of intersection of a 3D wavefront with a straight line set in 3D space by coordinates of two points on it) tR - a set of six floating numbers (x,y,z coordinates of the 1st point and x,y,z coordinates of the 2nd point, separated by commas (in km)). 2. Wavefront calculation (3D shape for a specific time) tw - specific time for wavefront calculation (in s). 3. Intersection of a 3D wavefront with horizontal (z=0) plane at a specific time tz - specific time for the wavefront intersection calculation (in s). 4. Intersection of a 3D wavefront with vertical (y=0) plane at a specific time ty - specific time for the wavefront intersection calculation (in s). 5. 3D ray trajectories x(t),y(t),z(t) are written in output file if no parameters mentioned in items 1-4 are set. */ #include #include #include #include #include #include "alloc.h" #include "_bool.h" #include "axa.h" #include "_defs.h" #include "error.h" #include "file.h" #include "getpar.h" #include "point.h" #include "simtab.h" #include "vector.h" #include "HWT_3D_mm.h" int main(int argc, char* argv[]) { bool verb,tfront=false,refl=false; float scaleray; sf_axis az,ax,ay; /* Cartesian coordinates */ sf_axis at,ag,ah,aa; /* Ray coordinates */ int it,ig,ih; float xsou,ysou,zsou; /* source coordinates */ sf_file Fv; /* velocity file */ float ***vv=NULL; /* velocity */ float ***curx=NULL; /* current x-component*/ float ***cury=NULL; /* current z-component*/ float ***curz=NULL; /* current z-component*/ pt3d_cur **wm=NULL; /* wavefront it-1 */ pt3d_cur **wo=NULL; /* wavefront it */ pt3d_cur **wp=NULL; /* wavefront it+1 */ pt3d_cur Tm,To,Tp; /* points on ray ig,ih: it-1,it,it+1 */ int n; float o,d; float tt=0; vm v; int smth=1; char* tag; double tw,tz,ty; // z reflections pt3d_cur **wg=NULL; bool **lg=NULL; float Asurf=0.0, Bsurf=0.0, Csurf=1.0, dsurf=0.0; /* horizontal plane*/ point3d pz0; // y reflections double Apy=0.0, Bpy=1.0, Cpy=0.0, Dpy=0; /* vertical plane*/ point3d py0; // timefront ray3d R={0.0}; triangle3d T; point3d Intsec; int cod=0; double dd,g,h; size_t tn=6; double *tR; FILE *stream; char*outfile; /*------------------------------------------------------------*/ sf_init(argc,argv); /*Parameters from command line*/ if(! sf_getbool("verb",&verb)) verb=false; // output on the screen y/n if(! sf_getfloat("scaleray",&scaleray)) scaleray=1.0; if(! sf_getbool("refl",&refl)) refl=false; // surface reflections y/n tR=sf_doublealloc(tn); if ( sf_getdoubles("tR",tR,tn)) { tfront=true; memcpy(&R,&tR[0],6*sizeof(double)); } free(tR); if(! sf_getdouble("tw",&tw)) tw=0.0; // Wavefront calculation if(! sf_getdouble("ty",&ty)) ty=0.0; // Intersection of a 3D wavefront with vertical (y=0) plane if(! sf_getdouble("tz",&tz)) tz=0.0; // Intersection of a 3D wavefront with horizontal (z=0) plane /* input file */ tag=sf_getstring("infile"); Fv = sf_input( tag ); // ("in"); /* information about axes from input file */ az=sf_iaxa(Fv,1); sf_setlabel(az,"z"); ax=sf_iaxa(Fv,2); sf_setlabel(ax,"x"); ay=sf_iaxa(Fv,3); sf_setlabel(ay,"y"); if(verb) { /*print axes information to the screen*/ sf_raxa(az); sf_raxa(ax); sf_raxa(ay); fprintf(stderr,"tw=%f tfront=%d ty=%f tz=%f\n",tw,tfront,ty,tz); fprintf(stderr,"R=%f %f %f %f %f %f\n",R.P0.x,R.P0.y,R.P0.z,R.P1.x,R.P1.y,R.P1.z); fprintf(stderr,"refl=%d\n",refl); } /* velocity file */ vv=sf_floatalloc3(sf_n(az),sf_n(ax),sf_n(ay)); sf_floatread(vv[0][0],sf_n(az)*sf_n(ax)*sf_n(ay),Fv); if (verb) fprintf(stderr,"vv0=%f vv1=%f \n",vv[0][0][0],vv[6][10][99]); /* current file */ curx=sf_floatalloc3(sf_n(az),sf_n(ax),sf_n(ay)); cury=sf_floatalloc3(sf_n(az),sf_n(ax),sf_n(ay)); curz=sf_floatalloc3(sf_n(az),sf_n(ax),sf_n(ay)); for( it=0; it=tz ) { pz0=zeropoint(0); pz0 = zinterp(To,So); //Tp g=sf_o(ag)+ig*sf_d(ag); h=sf_o(ah)+ih*sf_d(ah); fprintf(stream,"%8.2f %8.2f %10.5f %10.5f %6.1f\n",g,h,pz0.x,pz0.y,tt); So=zeropoint(0); } } //-------------------------------------------------------------------------- wp[ih][ig] = Tp; } } /* write wavefront */ if (!ty && !tfront && !tz) if (tw) { if (fabs(tt-tw)0 && ig=5) { T.V0=get_point3d(wp[ih-1][ig]); T.V1=get_point3d(wp[ih][ig]); T.V2=get_point3d(wp[ih][ig+1]); cod=intersect_RayTriangle( R, T, &Intsec); g=sf_o(ag)+ig*sf_d(ag); h=sf_o(ah)+ih*sf_d(ah); if (cod==1) fprintf(stream,"%7.3f %7.3f %10.5f %10.5f %10.5f %10.5f\n",g,h,tt,Intsec.x,Intsec.y,Intsec.z); } } } } } /* end it */ fclose( stream ); /*------------------------------------------------------------*/ free(**vv); free(*vv); free(vv); ; free(*wm); free(wm); ; free(*wo); free(wo); ; free(*wp); free(wp); /*------------------------------------------------------------*/ exit (0); }