/*
* EasyWave - A realtime tsunami simulation program with GPU support.
* Copyright (C) 2014 Andrey Babeyko, Johannes Spazier
* GFZ German Research Centre for Geosciences (http://www.gfz-potsdam.de)
*
* Parts of this program (especially the GPU extension) were developed
* within the context of the following publicly funded project:
* - TRIDEC, EU 7th Framework Programme, Grant Agreement 258723
* (http://www.tridec-online.eu)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
// cOkadaEarthquake.cpp: implementation of the cOkadaEarthquake class
//
//=========================================================================
#include
#include
#include
#include
#include "cOkadaEarthquake.h"
//=========================================================================
cOkadaEarthquake::cOkadaEarthquake()
{
finalized = 0;
m0 = 0;
nfault = 1;
fault = new cOkadaFault [1];
}
//=========================================================================
cOkadaEarthquake::~cOkadaEarthquake()
{
if( fault != NULL ) delete [] fault;
}
//=========================================================================
// Read fault(s) from a file
int cOkadaEarthquake::read( char *fname )
{
FILE *fp;
char record[256];
int ierr;
nfault = utlGetNumberOfRecords( fname );
if( fault != NULL ) delete [] fault;
fault = new cOkadaFault [nfault];
if( (fp = fopen(fname,"rt")) == NULL ) return Err.post(Err.msgOpenFile(fname));
for( int n=0, line=0; n lonmax ) lonmax = xmax;
if( ymin < latmin ) latmin = ymin; if( ymax > latmax ) latmax = ymax;
}
if( round ) {
lonmin = floor( lonmin ); lonmax = ceil( lonmax );
latmin = floor( latmin ); latmax = ceil( latmax );
}
return 0;
}
//=========================================================================
// Calculate surface displacements by summing effect from all ruptures
int cOkadaEarthquake::calculate( double lon, double lat, double& uz, double& ulon, double &ulat )
{
int n,ierr;
double uzf,ulonf,ulatf;
if( !finalized ) return Err.post("cOkadaEarthquake::calculate: eq not finalized");
for( ulon=ulat=uz=0, n=0; n