Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
S
swe_solvers
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Gaurav Kukreja
swe_solvers
Commits
1b7f0cc8
Commit
1b7f0cc8
authored
Jun 24, 2012
by
breuera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed wrong particle velocities Added a main routine to simplify the usage. Updated the test file.
parent
65fd4d24
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
64 additions
and
12 deletions
+64
-12
testphi_1000000.nc
unit_tests/files/testphi_1000000.nc
+0
-0
calculate_hstar.m
unit_tests/scripts/calculate_hstar.m
+5
-0
create_nc_testphi.m
unit_tests/scripts/create_nc_testphi.m
+21
-12
main.m
unit_tests/scripts/main.m
+38
-0
No files found.
unit_tests/files/testphi_1000000.nc
View file @
1b7f0cc8
No preview for this file type
unit_tests/scripts/calculate_hstar.m
View file @
1b7f0cc8
% Author: Alexander Breuer, breuera AT in.tum.de
%
% This function computes the middle state of a given homogenous
% Riemann-problem
function
[
hStar
]
=
calculate_hstar
(
hLow
,
hHigh
,
huLow
,
huHigh
)
function
[
hStar
]
=
calculate_hstar
(
hLow
,
hHigh
,
huLow
,
huHigh
)
%%% constants
%%% constants
zeroTol
=
0.00000001
;
zeroTol
=
0.00000001
;
...
...
unit_tests/scripts/create_nc_testphi.m
View file @
1b7f0cc8
% Author: Alexander Breuer, breuera AT in.tum.de
%
% This function deletes and recreates and net-cdf file at the specified path.
% Its content is filled by a number of random values, which is asked for
% during execution.
%
function
[
size
]
=
create_nc_testphi
(
path
)
function
[
size
]
=
create_nc_testphi
(
path
)
%250 meters should be enough (we dont want "extreme"-problems)
%maximum depth of the ocean: 10923 meters
maxWaterHeight
=
250
;
maxWaterHeight
=
10923
;
maxHeightVariation
=
50
;
%variation of the Height in the Riemann-Problem (depends on the space discretization)
%300km/h = 5000 m/s should be enough
maxHeightVariation
=
500
;
maxWaveSpeed
=
5000
;
%maximum velocity of the water particles: 10cm/s
%25km/h = 416.6666 m/s;
maxParticleSpeed
=
0.1
;
maxSpeedVariation
=
416.666666
;
%variation of the velocities: 5cm/s
dryTol
=
0.001
;
maxSpeedVariation
=
0.05
;
zeroTol
=
0.0000001
;
%dry tolerance
dryTol
=
0.1
;
%zero tolerance
zeroTol
=
0.00001
;
%delete old file
%delete old file
delete
(
path
)
delete
(
path
)
...
@@ -71,7 +80,7 @@ tic
...
@@ -71,7 +80,7 @@ tic
netcdf
.
putVar
(
ncid
,
varid
,
wallSize
,
randomSize
,
randHeights
)
netcdf
.
putVar
(
ncid
,
varid
,
wallSize
,
randomSize
,
randHeights
)
%fill huLow with random values
%fill huLow with random values
randSpeeds
=
transpose
((
2
*
(
rand
(
1
,
size
)
-
0.5
))
*
max
Wav
eSpeed
);
randSpeeds
=
transpose
((
2
*
(
rand
(
1
,
size
)
-
0.5
))
*
max
Particl
eSpeed
);
netcdf
.
sync
(
ncid
);
%sync before reading
netcdf
.
sync
(
ncid
);
%sync before reading
hLowVec
=
ncread
(
path
,
'hLow'
,
1
,
size
);
hLowVec
=
ncread
(
path
,
'hLow'
,
1
,
size
);
%hu = h * u
%hu = h * u
...
@@ -101,10 +110,10 @@ ncwriteatt(path,'/','author','Alexander Breuer')
...
@@ -101,10 +110,10 @@ ncwriteatt(path,'/','author','Alexander Breuer')
ncwriteatt
(
path
,
'/'
,
'history'
,
...
ncwriteatt
(
path
,
'/'
,
'history'
,
...
strcat
(
...
strcat
(
...
'MATLAB R2011b, shallowwater.m ('
,
...
'MATLAB R2011b, shallowwater.m ('
,
...
'maxWaterHeight='
,
num2str
(
maxWaterHeight
),
' maxHeightVariation='
,
num2str
(
maxHeightVariation
),
' max
WaveSpeed='
,
num2str
(
maxWav
eSpeed
),
' maxSpeedVariation='
,
num2str
(
maxSpeedVariation
),
' dryTol='
,
num2str
(
dryTol
),
' zeroTol='
,
num2str
(
zeroTol
)
...
'maxWaterHeight='
,
num2str
(
maxWaterHeight
),
' maxHeightVariation='
,
num2str
(
maxHeightVariation
),
' max
ParticleSpeed='
,
num2str
(
maxParticl
eSpeed
),
' maxSpeedVariation='
,
num2str
(
maxSpeedVariation
),
' dryTol='
,
num2str
(
dryTol
),
' zeroTol='
,
num2str
(
zeroTol
)
...
,
')'
...
,
')'
...
))
))
ncwriteatt
(
path
,
'/'
,
'institution'
,
'Technische Universit
t Mnc
hen, Department of Informatics, Chair of Scientific Computing'
)
ncwriteatt
(
path
,
'/'
,
'institution'
,
'Technische Universit
aet Mue
nchen, Department of Informatics, Chair of Scientific Computing'
)
ncwriteatt
(
path
,
'/'
,
'source'
,
'roots of an algebraic function'
)
ncwriteatt
(
path
,
'/'
,
'source'
,
'roots of an algebraic function'
)
ncwriteatt
(
path
,
'/'
,
'references'
,
'http://www5.in.tum.de'
)
ncwriteatt
(
path
,
'/'
,
'references'
,
'http://www5.in.tum.de'
)
...
...
unit_tests/scripts/main.m
0 → 100644
View file @
1b7f0cc8
% Author: Alexander Breuer, breuera AT in.tum.de
%
% This function creates a .nc files, fills it with random values and
% computes the hStar values (see create_nc_testphi)
%
function
[]
=
main
()
path
=
input
(
'Please enter the path (including the filename),\nwhere the file should be written to (needs to be quoted
''
/home/[...]/tesphi.nc
''
): '
);
fprintf
(
'file path: %s\n'
,
path
);
size
=
create_nc_testphi
(
path
)
hLow
=
ncread
(
path
,
'hLow'
,
1
,
size
);
hHigh
=
ncread
(
path
,
'hHigh'
,
1
,
size
);
huLow
=
ncread
(
path
,
'huLow'
,
1
,
size
);
huHigh
=
ncread
(
path
,
'huHigh'
,
1
,
size
);
hStar
=
zeros
(
size
,
1
);
disp
(
'computing middle heights'
);
tic
for
j
=
1
:
size
hStar
(
j
)
=
calculate_hstar
(
hLow
(
j
),
hHigh
(
j
),
huLow
(
j
),
huHigh
(
j
));
if
mod
(
j
,(
size
/
10
))
==
0
fprintf
(
'%i %% done.\n'
,
(
j
*
100
/
size
));
end
end
toc
disp
(
'writing hStar to the file'
)
%open file (low level)
ncid
=
netcdf
.
open
(
path
,
'NC_WRITE'
);
varid
=
netcdf
.
inqVarID
(
ncid
,
'hStar'
);
%write the values
netcdf
.
putVar
(
ncid
,
varid
,
0
,
size
,
hStar
);
netcdf
.
close
(
ncid
)
disp
(
'script finished'
);
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment