Commit 1b7f0cc8 authored by breuera's avatar breuera

Fixed wrong particle velocities Added a main routine to simplify the usage. Updated the test file.

parent 65fd4d24
% 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)
%%% constants
zeroTol = 0.00000001;
......
% 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)
%250 meters should be enough (we dont want "extreme"-problems)
maxWaterHeight = 250;
maxHeightVariation = 50;
%300km/h = 5000 m/s should be enough
maxWaveSpeed = 5000;
%25km/h = 416.6666 m/s;
maxSpeedVariation = 416.666666;
dryTol = 0.001;
zeroTol = 0.0000001;
%maximum depth of the ocean: 10923 meters
maxWaterHeight = 10923;
%variation of the Height in the Riemann-Problem (depends on the space discretization)
maxHeightVariation = 500;
%maximum velocity of the water particles: 10cm/s
maxParticleSpeed = 0.1;
%variation of the velocities: 5cm/s
maxSpeedVariation = 0.05;
%dry tolerance
dryTol = 0.1;
%zero tolerance
zeroTol = 0.00001;
%delete old file
delete(path)
......@@ -71,7 +80,7 @@ tic
netcdf.putVar(ncid, varid, wallSize, randomSize, randHeights)
%fill huLow with random values
randSpeeds = transpose((2*(rand(1, size)-0.5))*maxWaveSpeed);
randSpeeds = transpose((2*(rand(1, size)-0.5))*maxParticleSpeed);
netcdf.sync(ncid); %sync before reading
hLowVec = ncread(path, 'hLow', 1, size);
%hu = h * u
......@@ -101,10 +110,10 @@ ncwriteatt(path,'/','author','Alexander Breuer')
ncwriteatt(path,'/','history', ...
strcat(...
'MATLAB R2011b, shallowwater.m (',...
'maxWaterHeight=', num2str(maxWaterHeight), ' maxHeightVariation=', num2str(maxHeightVariation), ' maxWaveSpeed=', num2str(maxWaveSpeed), ' maxSpeedVariation=', num2str(maxSpeedVariation), ' dryTol=', num2str(dryTol), ' zeroTol=', num2str(zeroTol)...
'maxWaterHeight=', num2str(maxWaterHeight), ' maxHeightVariation=', num2str(maxHeightVariation), ' maxParticleSpeed=', num2str(maxParticleSpeed), ' maxSpeedVariation=', num2str(maxSpeedVariation), ' dryTol=', num2str(dryTol), ' zeroTol=', num2str(zeroTol)...
,')'...
))
ncwriteatt(path,'/','institution','Technische Universitt Mnchen, Department of Informatics, Chair of Scientific Computing')
ncwriteatt(path,'/','institution','Technische Universitaet Muenchen, Department of Informatics, Chair of Scientific Computing')
ncwriteatt(path,'/','source','roots of an algebraic function')
ncwriteatt(path,'/','references','http://www5.in.tum.de')
......
% 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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment