Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
easyWave
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Merge Requests
0
Merge Requests
0
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
geoperil
easyWave
Commits
04ef2c31
Commit
04ef2c31
authored
Apr 06, 2014
by
Johannes Spazier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed strange control character '^M' from files.
parent
b940b99c
Changes
61
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
61 changed files
with
16858 additions
and
16858 deletions
+16858
-16858
code/branches/multi-gpu/EasyWave.cu
code/branches/multi-gpu/EasyWave.cu
+180
-180
code/branches/multi-gpu/cOgrd.cpp
code/branches/multi-gpu/cOgrd.cpp
+1159
-1159
code/branches/multi-gpu/cOgrd.h
code/branches/multi-gpu/cOgrd.h
+75
-75
code/branches/multi-gpu/cOkadaEarthquake.cpp
code/branches/multi-gpu/cOkadaEarthquake.cpp
+292
-292
code/branches/multi-gpu/cOkadaEarthquake.h
code/branches/multi-gpu/cOkadaEarthquake.h
+38
-38
code/branches/multi-gpu/cOkadaFault.cpp
code/branches/multi-gpu/cOkadaFault.cpp
+440
-440
code/branches/multi-gpu/cOkadaFault.h
code/branches/multi-gpu/cOkadaFault.h
+64
-64
code/branches/multi-gpu/cSphere.cpp
code/branches/multi-gpu/cSphere.cpp
+328
-328
code/branches/multi-gpu/cSphere.h
code/branches/multi-gpu/cSphere.h
+36
-36
code/branches/multi-gpu/easywave.h
code/branches/multi-gpu/easywave.h
+99
-99
code/branches/multi-gpu/ewGrid.cpp
code/branches/multi-gpu/ewGrid.cpp
+225
-225
code/branches/multi-gpu/ewOut2D.cpp
code/branches/multi-gpu/ewOut2D.cpp
+142
-142
code/branches/multi-gpu/ewPOIs.cpp
code/branches/multi-gpu/ewPOIs.cpp
+245
-245
code/branches/multi-gpu/ewParam.cpp
code/branches/multi-gpu/ewParam.cpp
+187
-187
code/branches/multi-gpu/ewReset.cpp
code/branches/multi-gpu/ewReset.cpp
+24
-24
code/branches/multi-gpu/ewSource.cpp
code/branches/multi-gpu/ewSource.cpp
+187
-187
code/branches/multi-gpu/ewStep.cpp
code/branches/multi-gpu/ewStep.cpp
+344
-344
code/branches/multi-gpu/okada.cpp
code/branches/multi-gpu/okada.cpp
+348
-348
code/branches/multi-gpu/utilits.cpp
code/branches/multi-gpu/utilits.cpp
+1039
-1039
code/branches/multi-gpu/utilits.h
code/branches/multi-gpu/utilits.h
+132
-132
code/branches/web/EasyWave.cu
code/branches/web/EasyWave.cu
+174
-174
code/branches/web/cOgrd.cpp
code/branches/web/cOgrd.cpp
+1159
-1159
code/branches/web/cOgrd.h
code/branches/web/cOgrd.h
+75
-75
code/branches/web/cOkadaEarthquake.cpp
code/branches/web/cOkadaEarthquake.cpp
+292
-292
code/branches/web/cOkadaEarthquake.h
code/branches/web/cOkadaEarthquake.h
+38
-38
code/branches/web/cOkadaFault.cpp
code/branches/web/cOkadaFault.cpp
+440
-440
code/branches/web/cOkadaFault.h
code/branches/web/cOkadaFault.h
+64
-64
code/branches/web/cSphere.cpp
code/branches/web/cSphere.cpp
+328
-328
code/branches/web/cSphere.h
code/branches/web/cSphere.h
+36
-36
code/branches/web/easywave.h
code/branches/web/easywave.h
+104
-104
code/branches/web/ewGrid.cpp
code/branches/web/ewGrid.cpp
+290
-290
code/branches/web/ewOut2D.cpp
code/branches/web/ewOut2D.cpp
+142
-142
code/branches/web/ewPOIs.cpp
code/branches/web/ewPOIs.cpp
+245
-245
code/branches/web/ewParam.cpp
code/branches/web/ewParam.cpp
+187
-187
code/branches/web/ewReset.cpp
code/branches/web/ewReset.cpp
+24
-24
code/branches/web/ewSource.cpp
code/branches/web/ewSource.cpp
+227
-227
code/branches/web/ewStep.cpp
code/branches/web/ewStep.cpp
+344
-344
code/branches/web/okada.cpp
code/branches/web/okada.cpp
+348
-348
code/branches/web/utilits.cpp
code/branches/web/utilits.cpp
+1039
-1039
code/branches/web/utilits.h
code/branches/web/utilits.h
+132
-132
code/trunk/src/EasyWave.cpp
code/trunk/src/EasyWave.cpp
+182
-182
code/trunk/src/cOgrd.cpp
code/trunk/src/cOgrd.cpp
+1159
-1159
code/trunk/src/cOgrd.h
code/trunk/src/cOgrd.h
+75
-75
code/trunk/src/cOkadaEarthquake.cpp
code/trunk/src/cOkadaEarthquake.cpp
+292
-292
code/trunk/src/cOkadaEarthquake.h
code/trunk/src/cOkadaEarthquake.h
+38
-38
code/trunk/src/cOkadaFault.cpp
code/trunk/src/cOkadaFault.cpp
+440
-440
code/trunk/src/cOkadaFault.h
code/trunk/src/cOkadaFault.h
+64
-64
code/trunk/src/cSphere.cpp
code/trunk/src/cSphere.cpp
+328
-328
code/trunk/src/cSphere.h
code/trunk/src/cSphere.h
+36
-36
code/trunk/src/easywave.h
code/trunk/src/easywave.h
+99
-99
code/trunk/src/ewGrid.cpp
code/trunk/src/ewGrid.cpp
+225
-225
code/trunk/src/ewOut2D.cpp
code/trunk/src/ewOut2D.cpp
+142
-142
code/trunk/src/ewPOIs.cpp
code/trunk/src/ewPOIs.cpp
+245
-245
code/trunk/src/ewParam.cpp
code/trunk/src/ewParam.cpp
+187
-187
code/trunk/src/ewReset.cpp
code/trunk/src/ewReset.cpp
+24
-24
code/trunk/src/ewSource.cpp
code/trunk/src/ewSource.cpp
+187
-187
code/trunk/src/ewStep.cpp
code/trunk/src/ewStep.cpp
+344
-344
code/trunk/src/okada.cpp
code/trunk/src/okada.cpp
+348
-348
code/trunk/src/utilits.cpp
code/trunk/src/utilits.cpp
+1039
-1039
code/trunk/src/utilits.h
code/trunk/src/utilits.h
+132
-132
code/trunk/tools/FreeMonoBold.ttf
code/trunk/tools/FreeMonoBold.ttf
+0
-0
No files found.
code/branches/multi-gpu/EasyWave.cu
View file @
04ef2c31
...
...
@@ -22,183 +22,183 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define HEADER "\neasyWave ver.2013-04-11\n"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <utilits.h>
#include "easywave.h"
#include "ewGpuNode.cuh"
CNode
*
gNode
;
double
diff
(
timespec
start
,
timespec
end
)
{
timespec
temp
;
if
((
end
.
tv_nsec
-
start
.
tv_nsec
)
<
0
)
{
temp
.
tv_sec
=
end
.
tv_sec
-
start
.
tv_sec
-
1
;
temp
.
tv_nsec
=
1000000000
+
end
.
tv_nsec
-
start
.
tv_nsec
;
}
else
{
temp
.
tv_sec
=
end
.
tv_sec
-
start
.
tv_sec
;
temp
.
tv_nsec
=
end
.
tv_nsec
-
start
.
tv_nsec
;
}
return
(
double
)((
double
)
temp
.
tv_nsec
/
1000000000.0
+
(
double
)
temp
.
tv_sec
);
}
int
commandLineHelp
(
void
);
int
main
(
int
argc
,
char
**
argv
)
{
char
buf
[
1024
];
int
ierr
,
argn
,
elapsed
;
int
lastProgress
,
lastPropagation
,
lastDump
;
int
loop
;
printf
(
HEADER
);
Err
.
setchannel
(
MSG_OUTFILE
);
// Read parameters from command line and use default
ierr
=
ewParam
(
argc
,
argv
);
if
(
ierr
)
return
commandLineHelp
();
// Log command line
/* FIXME: buffer overflow */
sprintf
(
buf
,
"Command line: "
);
for
(
argn
=
1
;
argn
<
argc
;
argn
++
)
{
strcat
(
buf
,
" "
);
strcat
(
buf
,
argv
[
argn
]
);
}
Log
.
print
(
"%s"
,
buf
);
if
(
Par
.
gpu
)
{
gNode
=
new
CGpuNode
();
}
else
{
gNode
=
new
CStructNode
();
//gNode = new CArrayNode();
}
CNode
&
Node
=
*
gNode
;
// Read bathymetry
ierr
=
ewLoadBathymetry
();
if
(
ierr
)
return
ierr
;
// Read points of interest
ierr
=
ewLoadPOIs
();
if
(
ierr
)
return
ierr
;
// Init tsunami with faults or uplift-grid
ierr
=
ewSource
();
if
(
ierr
)
return
ierr
;
Log
.
print
(
"Read source from %s"
,
Par
.
fileSource
);
// Write model parameters into the log
ewLogParams
();
if
(
Par
.
outPropagation
)
ewStart2DOutput
();
Node
.
copyToGPU
();
// Main loop
Log
.
print
(
"Starting main loop..."
);
printf
(
"Starting main loop %ld msec
\n
"
,
clock
()
/
(
CLOCKS_PER_SEC
/
1000
)
);
timespec
start
,
end
;
clock_gettime
(
CLOCK_MONOTONIC
,
&
start
);
for
(
Par
.
time
=
0
,
loop
=
1
,
lastProgress
=
Par
.
outProgress
,
lastPropagation
=
Par
.
outPropagation
,
lastDump
=
0
;
Par
.
time
<=
Par
.
timeMax
;
loop
++
,
Par
.
time
+=
Par
.
dt
,
lastProgress
+=
Par
.
dt
,
lastPropagation
+=
Par
.
dt
)
{
/* FIXME: check if Par.poiDt can be used for those purposes */
if
(
Par
.
filePOIs
&&
Par
.
poiDt
&&
((
Par
.
time
/
Par
.
poiDt
)
*
Par
.
poiDt
==
Par
.
time
)
)
{
Node
.
copyPOIs
();
ewSavePOIs
();
}
Node
.
run
();
elapsed
=
((
int
)
clock
())
/
CLOCKS_PER_SEC
;
if
(
Par
.
outProgress
)
{
if
(
lastProgress
>=
Par
.
outProgress
)
{
printf
(
"Model time = %s, elapsed: %ld msec
\n
"
,
utlTimeSplitString
(
Par
.
time
),
clock
()
/
(
CLOCKS_PER_SEC
/
1000
)
);
Log
.
print
(
"Model time = %s, elapsed: %ld msec"
,
utlTimeSplitString
(
Par
.
time
),
clock
()
/
(
CLOCKS_PER_SEC
/
1000
)
);
lastProgress
=
0
;
}
}
if
(
Par
.
outPropagation
)
{
if
(
lastPropagation
>=
Par
.
outPropagation
)
{
Node
.
copyIntermediate
();
ewOut2D
();
lastPropagation
=
0
;
}
}
fflush
(
stdout
);
if
(
Par
.
outDump
)
{
if
(
(
elapsed
-
lastDump
)
>=
Par
.
outDump
)
{
Node
.
copyIntermediate
();
/* FIXME: needs tArr as well */
ewDumpPOIs
();
ewDump2D
();
lastDump
=
elapsed
;
}
}
}
// main loop
clock_gettime
(
CLOCK_MONOTONIC
,
&
end
);
Log
.
print
(
"Finishing main loop"
);
/* TODO: check if theses calls can be combined */
Node
.
copyIntermediate
();
Node
.
copyFromGPU
();
// Final output
Log
.
print
(
"Final dump..."
);
ewDumpPOIs
();
ewDump2D
();
Node
.
freeMem
();
printf_v
(
"Runtime: %.3lf
\n
"
,
diff
(
start
,
end
)
*
1000.0
);
delete
gNode
;
return
0
;
}
//========================================================================
int
commandLineHelp
(
void
)
{
printf
(
"Usage: easyWave -grid ... -source ... -time ... [optional parameters]
\n
"
);
printf
(
"-grid ... bathymetry in GoldenSoftware(C) GRD format (text or binary)
\n
"
);
printf
(
"-source ... input wave either als GRD-file or file with Okada faults
\n
"
);
printf
(
"-time ... simulation time in [min]
\n
"
);
printf
(
"Optional parameters:
\n
"
);
printf
(
"-step ... simulation time step, default- estimated from bathymetry
\n
"
);
printf
(
"-coriolis use Coriolis fource, default- no
\n
"
);
printf
(
"-poi ... POIs file
\n
"
);
printf
(
"-label ... model name, default- 'eWave'
\n
"
);
printf
(
"-progress ... show simulation progress each ... minutes, default- 10
\n
"
);
printf
(
"-propagation ... write wave propagation grid each ... minutes, default- 5
\n
"
);
printf
(
"-dump ... make solution dump each ... physical seconds, default- 0
\n
"
);
printf
(
"-nolog deactivate logging
\n
"
);
printf
(
"-poi_dt_out ... output time step for mariograms in [sec], default- 30
\n
"
);
printf
(
"-poi_search_dist ... in [km], default- 10
\n
"
);
printf
(
"-poi_min_depth ... in [m], default- 1
\n
"
);
printf
(
"-poi_max_depth ... in [m], default- 10 000
\n
"
);
printf
(
"-poi_report enable POIs loading report, default- disabled
\n
"
);
printf
(
"-ssh0_rel ... relative threshold for initial wave, default- 0.01
\n
"
);
printf
(
"-ssh0_abs ... absolute threshold for initial wave in [m], default- 0
\n
"
);
printf
(
"-ssh_arrival ... threshold for arrival times in [m], default- 0.001
\n
"
);
printf
(
" negative value considered as relative threshold
\n
"
);
printf
(
"-gpu start GPU version of EasyWave (requires a CUDA capable device)
\n
"
);
printf
(
"-verbose generate verbose output on stdout
\n
"
);
printf
(
"
\n
Example:
\n
"
);
printf
(
"
\t
easyWave -grid gebcoIndonesia.grd -source fault.inp -time 120
\n\n
"
);
return
-
1
;
}
#define HEADER "\neasyWave ver.2013-04-11\n"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <utilits.h>
#include "easywave.h"
#include "ewGpuNode.cuh"
CNode
*
gNode
;
double
diff
(
timespec
start
,
timespec
end
)
{
timespec
temp
;
if
((
end
.
tv_nsec
-
start
.
tv_nsec
)
<
0
)
{
temp
.
tv_sec
=
end
.
tv_sec
-
start
.
tv_sec
-
1
;
temp
.
tv_nsec
=
1000000000
+
end
.
tv_nsec
-
start
.
tv_nsec
;
}
else
{
temp
.
tv_sec
=
end
.
tv_sec
-
start
.
tv_sec
;
temp
.
tv_nsec
=
end
.
tv_nsec
-
start
.
tv_nsec
;
}
return
(
double
)((
double
)
temp
.
tv_nsec
/
1000000000.0
+
(
double
)
temp
.
tv_sec
);
}
int
commandLineHelp
(
void
);
int
main
(
int
argc
,
char
**
argv
)
{
char
buf
[
1024
];
int
ierr
,
argn
,
elapsed
;
int
lastProgress
,
lastPropagation
,
lastDump
;
int
loop
;
printf
(
HEADER
);
Err
.
setchannel
(
MSG_OUTFILE
);
// Read parameters from command line and use default
ierr
=
ewParam
(
argc
,
argv
);
if
(
ierr
)
return
commandLineHelp
();
// Log command line
/* FIXME: buffer overflow */
sprintf
(
buf
,
"Command line: "
);
for
(
argn
=
1
;
argn
<
argc
;
argn
++
)
{
strcat
(
buf
,
" "
);
strcat
(
buf
,
argv
[
argn
]
);
}
Log
.
print
(
"%s"
,
buf
);
if
(
Par
.
gpu
)
{
gNode
=
new
CGpuNode
();
}
else
{
gNode
=
new
CStructNode
();
//gNode = new CArrayNode();
}
CNode
&
Node
=
*
gNode
;
// Read bathymetry
ierr
=
ewLoadBathymetry
();
if
(
ierr
)
return
ierr
;
// Read points of interest
ierr
=
ewLoadPOIs
();
if
(
ierr
)
return
ierr
;
// Init tsunami with faults or uplift-grid
ierr
=
ewSource
();
if
(
ierr
)
return
ierr
;
Log
.
print
(
"Read source from %s"
,
Par
.
fileSource
);
// Write model parameters into the log
ewLogParams
();
if
(
Par
.
outPropagation
)
ewStart2DOutput
();
Node
.
copyToGPU
();
// Main loop
Log
.
print
(
"Starting main loop..."
);
printf
(
"Starting main loop %ld msec
\n
"
,
clock
()
/
(
CLOCKS_PER_SEC
/
1000
)
);
timespec
start
,
end
;
clock_gettime
(
CLOCK_MONOTONIC
,
&
start
);
for
(
Par
.
time
=
0
,
loop
=
1
,
lastProgress
=
Par
.
outProgress
,
lastPropagation
=
Par
.
outPropagation
,
lastDump
=
0
;
Par
.
time
<=
Par
.
timeMax
;
loop
++
,
Par
.
time
+=
Par
.
dt
,
lastProgress
+=
Par
.
dt
,
lastPropagation
+=
Par
.
dt
)
{
/* FIXME: check if Par.poiDt can be used for those purposes */
if
(
Par
.
filePOIs
&&
Par
.
poiDt
&&
((
Par
.
time
/
Par
.
poiDt
)
*
Par
.
poiDt
==
Par
.
time
)
)
{
Node
.
copyPOIs
();
ewSavePOIs
();
}
Node
.
run
();
elapsed
=
((
int
)
clock
())
/
CLOCKS_PER_SEC
;
if
(
Par
.
outProgress
)
{
if
(
lastProgress
>=
Par
.
outProgress
)
{
printf
(
"Model time = %s, elapsed: %ld msec
\n
"
,
utlTimeSplitString
(
Par
.
time
),
clock
()
/
(
CLOCKS_PER_SEC
/
1000
)
);
Log
.
print
(
"Model time = %s, elapsed: %ld msec"
,
utlTimeSplitString
(
Par
.
time
),
clock
()
/
(
CLOCKS_PER_SEC
/
1000
)
);
lastProgress
=
0
;
}
}
if
(
Par
.
outPropagation
)
{
if
(
lastPropagation
>=
Par
.
outPropagation
)
{
Node
.
copyIntermediate
();
ewOut2D
();
lastPropagation
=
0
;
}
}
fflush
(
stdout
);
if
(
Par
.
outDump
)
{
if
(
(
elapsed
-
lastDump
)
>=
Par
.
outDump
)
{
Node
.
copyIntermediate
();
/* FIXME: needs tArr as well */
ewDumpPOIs
();
ewDump2D
();
lastDump
=
elapsed
;
}
}
}
// main loop
clock_gettime
(
CLOCK_MONOTONIC
,
&
end
);
Log
.
print
(
"Finishing main loop"
);
/* TODO: check if theses calls can be combined */
Node
.
copyIntermediate
();
Node
.
copyFromGPU
();
// Final output
Log
.
print
(
"Final dump..."
);
ewDumpPOIs
();
ewDump2D
();
Node
.
freeMem
();
printf_v
(
"Runtime: %.3lf
\n
"
,
diff
(
start
,
end
)
*
1000.0
);
delete
gNode
;
return
0
;
}
//========================================================================
int
commandLineHelp
(
void
)
{
printf
(
"Usage: easyWave -grid ... -source ... -time ... [optional parameters]
\n
"
);
printf
(
"-grid ... bathymetry in GoldenSoftware(C) GRD format (text or binary)
\n
"
);
printf
(
"-source ... input wave either als GRD-file or file with Okada faults
\n
"
);
printf
(
"-time ... simulation time in [min]
\n
"
);
printf
(
"Optional parameters:
\n
"
);
printf
(
"-step ... simulation time step, default- estimated from bathymetry
\n
"
);
printf
(
"-coriolis use Coriolis fource, default- no
\n
"
);
printf
(
"-poi ... POIs file
\n
"
);
printf
(
"-label ... model name, default- 'eWave'
\n
"
);
printf
(
"-progress ... show simulation progress each ... minutes, default- 10
\n
"
);
printf
(
"-propagation ... write wave propagation grid each ... minutes, default- 5
\n
"
);
printf
(
"-dump ... make solution dump each ... physical seconds, default- 0
\n
"
);
printf
(
"-nolog deactivate logging
\n
"
);
printf
(
"-poi_dt_out ... output time step for mariograms in [sec], default- 30
\n
"
);
printf
(
"-poi_search_dist ... in [km], default- 10
\n
"
);
printf
(
"-poi_min_depth ... in [m], default- 1
\n
"
);
printf
(
"-poi_max_depth ... in [m], default- 10 000
\n
"
);
printf
(
"-poi_report enable POIs loading report, default- disabled
\n
"
);
printf
(
"-ssh0_rel ... relative threshold for initial wave, default- 0.01
\n
"
);
printf
(
"-ssh0_abs ... absolute threshold for initial wave in [m], default- 0
\n
"
);
printf
(
"-ssh_arrival ... threshold for arrival times in [m], default- 0.001
\n
"
);
printf
(
" negative value considered as relative threshold
\n
"
);
printf
(
"-gpu start GPU version of EasyWave (requires a CUDA capable device)
\n
"
);
printf
(
"-verbose generate verbose output on stdout
\n
"
);
printf
(
"
\n
Example:
\n
"
);
printf
(
"
\t
easyWave -grid gebcoIndonesia.grd -source fault.inp -time 120
\n\n
"
);
return
-
1
;
}
code/branches/multi-gpu/cOgrd.cpp
View file @
04ef2c31
This diff is collapsed.
Click to expand it.
code/branches/multi-gpu/cOgrd.h
View file @
04ef2c31
...
...
@@ -22,78 +22,78 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OGRD_H
#define OGRD_H
class
cOgrd
{
protected:
public:
int
nx
,
ny
;
int
nnod
;
double
noval
;
double
xmin
,
xmax
;
double
ymin
,
ymax
;
double
dx
,
dy
;
double
*
val
;
cOgrd
();
cOgrd
(
const
cOgrd
&
);
cOgrd
(
double
xmin0
,
double
xmax0
,
int
nx0
,
double
ymin0
,
double
ymax0
,
int
ny0
);
cOgrd
(
double
xmin0
,
double
xmax0
,
double
dx0
,
double
ymin0
,
double
ymax0
,
double
dy0
);
~
cOgrd
();
void
setNoval
(
double
val
);
double
getNoval
();
int
initialize
(
double
xmin0
,
double
xmax0
,
int
nx0
,
double
ymin0
,
double
ymax0
,
int
ny0
);
int
initialize
(
double
xmin0
,
double
xmax0
,
double
dx0
,
double
ymin0
,
double
ymax0
,
double
dy0
);
int
readShape
(
const
char
*
grdfile
);
int
readHeader
(
const
char
*
grdfile
);
int
readGRD
(
const
char
*
grdfile
);
int
readXYZ
(
const
char
*
xyzfile
);
int
readRasterStream
(
FILE
*
fp
,
int
ordering
,
int
ydirection
);
cOgrd
*
extract
(
int
i1
,
int
i2
,
int
j1
,
int
j2
);
cOgrd
*
extract
(
double
x1
,
double
x2
,
double
y1
,
double
y2
);
int
idx
(
int
i
,
int
j
);
double
&
operator
()
(
int
i
,
int
j
);
double
&
operator
()
(
int
idx
);
cOgrd
&
operator
=
(
const
cOgrd
&
grd
);
cOgrd
&
operator
*=
(
double
coeff
);
cOgrd
&
operator
+=
(
cOgrd
&
grd
);
void
getIJ
(
int
idx
,
int
&
i
,
int
&
j
);
int
getIJ
(
double
x
,
double
y
,
int
&
i
,
int
&
j
);
double
getX
(
int
i
,
int
j
);
double
getX
(
int
idx
);
double
getY
(
int
i
,
int
j
);
double
getY
(
int
idx
);
double
getVal
(
int
idx
);
double
getVal
(
int
i
,
int
j
);
double
getVal
(
double
x
,
double
y
);
double
getMaxVal
();
double
getMaxVal
(
int
&
i
,
int
&
j
);
double
getMinVal
();
double
getMinVal
(
int
&
i
,
int
&
j
);
double
getMaxAbsVal
();
double
getMaxAbsVal
(
int
&
i
,
int
&
j
);
double
getMaxAbsValBnd
();
void
setVal
(
double
value
,
int
i
,
int
j
);
void
setVal
(
double
value
,
int
idx
);
void
reset
();
void
resetVal
();
int
getIntersectionRegion
(
const
cOgrd
&
grd
,
int
&
imin
,
int
&
imax
,
int
&
jmin
,
int
&
jmax
);
int
interpolateFrom
(
cOgrd
&
grd
,
int
resetValues
);
int
getNearestIdx
(
double
x
,
double
y
);
int
getNearestIdx
(
double
x
,
double
y
,
double
rangemin
,
double
rangemax
);
int
equalTo
(
cOgrd
&
grd
);
int
isSameShapeTo
(
cOgrd
&
grd
);
void
smooth
(
int
radius
);
int
writeGRD
(
const
char
*
fname
);
int
writeGRDbin
(
const
char
*
fname
);
int
writeXYZ
(
const
char
*
fname
);
};
#endif // OGRD_H
#ifndef OGRD_H
#define OGRD_H
class
cOgrd
{
protected:
public:
int
nx
,
ny
;
int
nnod
;
double
noval
;
double
xmin
,
xmax
;
double
ymin
,
ymax
;
double
dx
,
dy
;
double
*
val
;
cOgrd
();
cOgrd
(
const
cOgrd
&
);
cOgrd
(
double
xmin0
,
double
xmax0
,
int
nx0
,
double
ymin0
,
double
ymax0
,
int
ny0
);
cOgrd
(
double
xmin0
,
double
xmax0
,
double
dx0
,
double
ymin0
,
double
ymax0
,
double
dy0
);
~
cOgrd
();
void
setNoval
(
double
val
);
double
getNoval
();
int
initialize
(
double
xmin0
,
double
xmax0
,
int
nx0
,
double
ymin0
,
double
ymax0
,
int
ny0
);
int
initialize
(
double
xmin0
,
double
xmax0
,
double
dx0
,
double
ymin0
,
double
ymax0
,
double
dy0
);
int
readShape
(
const
char
*
grdfile
);
int
readHeader
(
const
char
*
grdfile
);
int
readGRD
(
const
char
*
grdfile
);
int
readXYZ
(
const
char
*
xyzfile
);
int
readRasterStream
(
FILE
*
fp
,
int
ordering
,
int
ydirection
);
cOgrd
*
extract
(
int
i1
,
int
i2
,
int
j1
,
int
j2
);
cOgrd
*
extract
(
double
x1
,
double
x2
,
double
y1
,
double
y2
);
int
idx
(
int
i
,
int
j
);
double
&
operator
()
(
int
i
,
int
j
);
double
&
operator
()
(
int
idx
);
cOgrd
&
operator
=
(
const
cOgrd
&
grd
);
cOgrd
&
operator
*=
(
double
coeff
);
cOgrd
&
operator
+=
(
cOgrd
&
grd
);
void
getIJ
(
int
idx
,
int
&
i
,
int
&
j
);
int
getIJ
(
double
x
,
double
y
,
int
&
i
,
int
&
j
);
double
getX
(
int
i
,
int
j
);
double
getX
(
int
idx
);
double
getY
(
int
i
,
int
j
);
double
getY
(
int
idx
);
double
getVal
(
int
idx
);
double
getVal
(
int
i
,
int
j
);
double
getVal
(
double
x
,
double
y
);
double
getMaxVal
();
double
getMaxVal
(
int
&
i
,
int
&
j
);
double
getMinVal
();
double
getMinVal
(
int
&
i
,
int
&
j
);
double
getMaxAbsVal
();
double
getMaxAbsVal
(
int
&
i
,
int
&
j
);
double
getMaxAbsValBnd
();
void
setVal
(
double
value
,
int
i
,
int
j
);
void
setVal
(
double
value
,
int
idx
);
void
reset
();
void
resetVal
();
int
getIntersectionRegion
(
const
cOgrd
&
grd
,
int
&
imin
,
int
&
imax
,
int
&
jmin
,
int
&
jmax
);
int
interpolateFrom
(
cOgrd
&
grd
,
int
resetValues
);
int
getNearestIdx
(
double
x
,
double
y
);
int
getNearestIdx
(
double
x
,
double
y
,
double
rangemin
,
double
rangemax
);
int
equalTo
(
cOgrd
&
grd
);
int
isSameShapeTo
(
cOgrd
&
grd
);
void
smooth
(
int
radius
);
int
writeGRD
(
const
char
*
fname
);
int
writeGRDbin
(
const
char
*
fname
);
int
writeXYZ
(
const
char
*
fname
);
};
#endif // OGRD_H
code/branches/multi-gpu/cOkadaEarthquake.cpp
View file @
04ef2c31
...
...
@@ -22,295 +22,295 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// cOkadaEarthquake.cpp: implementation of the cOkadaEarthquake class
//
//=========================================================================
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <utilits.h>
#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
<
nfault
;
n
++
)
{
ierr
=
utlReadNextRecord
(
fp
,
record
,
&
line
);
if
(
ierr
==
EOF
)
return
Err
.
post
(
Err
.
msgReadFile
(
fname
,
line
,
"Unexpected EOF"
));
ierr
=
fault
[
n
].
read
(
record
);
if
(
ierr
)
return
ierr
;
}
fclose
(
fp
);
return
0
;
}
//=========================================================================
// check all ruptures for parameter integrity
int
cOkadaEarthquake
::
finalizeInput
()
{
char
msg
[
32
];
int
ierr
,
n
;
for
(
m0
=
0.
,
n
=
0
;
n
<
nfault
;
n
++
)
{
ierr
=
fault
[
n
].
check
();
if
(
ierr
)
{
Err
.
post
(
"Fault number: %d"
,
n
+
1
);
return
(
10
*
n
+
ierr
);
}