Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

converted fvmbook/chap21/radialdam code from clawpack-4.x #61

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions fvmbook/chap21/radialdam/1drad/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@

# Makefile for Clawpack code in this directory.
# This version only sets the local files and frequently changed
# options, and then includes the standard makefile pointed to by CLAWMAKE.
CLAWMAKE = $(CLAW)/clawutil/src/Makefile.common

# See the above file for details and a list of make options, or type
# make .help
# at the unix prompt.


# Adjust these variables if desired:
# ----------------------------------

CLAW_PKG = classic # Clawpack package to use
EXE = xclaw # Executable to create
SETRUN_FILE = setrun.py # File containing function to make data
OUTDIR = _output # Directory for output
SETPLOT_FILE = setplot.py # File containing function to set plots
PLOTDIR = _plots # Directory for plots

OVERWRITE ?= True # False ==> make a copy of OUTDIR first
RESTART ?= False # Should = clawdata.restart in setrun

# Environment variable FC should be set to fortran compiler, e.g. gfortran

# Compiler flags can be specified here or set as an environment variable
FFLAGS ?=

# ---------------------------------
# List of sources for this program:
# ---------------------------------

MODULES = \

SOURCES = \
qinit.f \
src1.f \
setprob.f \
$(CLAW)/riemann/src/rp1_shallow_roe_with_efix.f90 \
$(CLAW)/classic/src/1d/setaux.f90 \
$(CLAW)/classic/src/1d/bc1.f \
$(CLAW)/classic/src/1d/b4step1.f90 \
$(CLAW)/classic/src/1d/driver.f90 \
$(CLAW)/classic/src/1d/claw1ez.f \
$(CLAW)/classic/src/1d/claw1.f \
$(CLAW)/classic/src/1d/copyq1.f \
$(CLAW)/classic/src/1d/inlinelimiter.f90 \
$(CLAW)/classic/src/1d/opendatafile.f \
$(CLAW)/classic/src/1d/out1.f \
$(CLAW)/classic/src/1d/step1.f90

#-------------------------------------------------------------------
# Include Makefile containing standard definitions and make options:
include $(CLAWMAKE)

16 changes: 16 additions & 0 deletions fvmbook/chap21/radialdam/1drad/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

.. _fvmbook_chap21/radialdam/1drad:

Radial dam-break problem for 2D shallow water equations
--------------------------------------------------------

Example [book/chap21/radialdam/1drad] to accompany the book
`Finite Volume Methods for Hyperbolic Problems
<http://www.clawpack.org/book.html>`_
by R. J. LeVeque.

Converted to Clawpack 5.0 form in 2016.

The code in this directory solves the 1d shallow water equations with a
geometric source term for the radial symmetry. It is used to create a
reference solution for comparison to the 2d solution.
3 changes: 3 additions & 0 deletions fvmbook/chap21/radialdam/1drad/U.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function U = U(data);
% compute the velocity from the momentum and depth:
U = data(:,2)/data(:,1);
17 changes: 17 additions & 0 deletions fvmbook/chap21/radialdam/1drad/afterframe.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

if (mq==(1:2))
subplot(2,1,1)
axis([0 2.5 0 2.1])

subplot(2,1,2)
axis([0 2.5 -.3 .7])
end

if (mq==1)
axis([0 2.5 0 2.1])
end

if (mq==2)
axis([0 2.5 -.3 .7])
end

16 changes: 16 additions & 0 deletions fvmbook/chap21/radialdam/1drad/makefig.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

% first run with 12 output times up to t=1.5


for Frame=0:2:12
for mq=1:2
clf
Haxes = axes('position',[.1 .1 .8 .3]);
set(Haxes,'fontsize',15)
plotframe1
%axis([-1 1 -1 1])
eval(['print raddam' num2str(Frame) 'q' num2str(mq) ' -deps'])
query
end
end

32 changes: 32 additions & 0 deletions fvmbook/chap21/radialdam/1drad/qinit.f
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
c
c
c =========================================================
subroutine qinit(meqn,mbc,mx,xlower,dx,q,maux,aux)
c =========================================================
c
c # Set initial conditions for q.
c
c
implicit double precision (a-h,o-z)
dimension q(meqn,1-mbc:mx+mbc)
common/cdisc/ x0,y0,alf,beta,r0,idisc
common /comic/ hin,hout
c
pi = 4.d0*datan(1.d0)
width = 0.2d0
c
write(6,*) '+++ mx = ',mx
do 150 i=1,mx
xcell = xlower + (i-0.5d0)*dx
if (xcell .lt. r0) then
h = hin
else
h = hout
endif
q(1,i) = h
q(2,i) = 0.d0
150 continue
c
return
end

75 changes: 75 additions & 0 deletions fvmbook/chap21/radialdam/1drad/setplot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@

"""
Set up the plot figures, axes, and items to be done for each frame.

This module is imported by the plotting routines and then the
function setplot is called to set the plot parameters.

"""

#--------------------------
def setplot(plotdata):
#--------------------------

"""
Specify what is to be plotted at each frame.
Input: plotdata, an instance of clawpack.visclaw.data.ClawPlotData.
Output: a modified version of plotdata.

"""

plotdata.clearfigures() # clear any old figures,axes,items data



# Figure for q[0]
plotfigure = plotdata.new_plotfigure(name='q[0]', figno=0)

# Set up for axes in this figure:
plotaxes = plotfigure.new_plotaxes()
plotaxes.xlimits = 'auto'
plotaxes.ylimits = [0., 2.1]
plotaxes.title = 'q[0]'

# Set up for item on these axes:
plotitem = plotaxes.new_plotitem(plot_type='1d')
plotitem.plot_var = 0
plotitem.plotstyle = '-'
plotitem.color = 'b'
plotitem.show = True # show on plot?


# Figure for q[1]
plotfigure = plotdata.new_plotfigure(name='q[1]', figno=1)

# Set up for axes in this figure:
plotaxes = plotfigure.new_plotaxes()
plotaxes.xlimits = 'auto'
plotaxes.ylimits = [-0.3, 0.7]
plotaxes.title = 'q[1]'

# Set up for item on these axes:
plotitem = plotaxes.new_plotitem(plot_type='1d')
plotitem.plot_var = 1
plotitem.plotstyle = '-'
plotitem.color = 'b'
plotitem.show = True # show on plot?


# Parameters used only when creating html and/or latex hardcopy
# e.g., via clawpack.visclaw.frametools.printframes:

plotdata.printfigs = True # print figures
plotdata.print_format = 'png' # file format
plotdata.print_framenos = 'all' # list of frames to print
plotdata.print_fignos = 'all' # list of figures to print
plotdata.html = True # create html files of plots?
plotdata.html_homelink = '../README.html' # pointer for top of index
plotdata.latex = True # create latex file of plots?
plotdata.latex_figsperline = 2 # layout of plots
plotdata.latex_framesperline = 1 # layout of plots
plotdata.latex_makepdf = False # also run pdflatex?

return plotdata


29 changes: 29 additions & 0 deletions fvmbook/chap21/radialdam/1drad/setplot1.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
% SETPLOT1 sets user defined plotting parameters
%
% User defined Matlab script for setting various Clawpack plotting
% parameters. This script is called by PLOTCLAW1. A default
% version of this script can be found in claw/matlab/setplot1.m and
% copied to users working directory and modifed to set things up
% differently.
%
% Parameters that can be set with SETPLOT1
%
% OutputFlag - set to 'ascii' or 'hdf'.
% PlotStyle - used in plot command for line color and type.
% mq - which component of q to plot
% UserVariable - Set to 1 to specify a user defined variable.
% UserVariableFile - name of m-file mapping data to q
% MappedGrid - set to 1 if mapc2p.m exists for nonuniform
% grid
% MaxFrames - max number of frames
%
% All parameters can be modified by typing 'k' at the PLOTCLAW1 prompt.
%
% See PLOTCLAW1.

mq = 1:2; % which component(s) of q to plot
UserVariable = 0; % set to 1 to specify a user-defined variable
UserVariableFile = ' '; % name of m-file mapping data to q
MappedGrid = 0; % set to 1 if mapc2p.m exists for nonuniform grid
PlotStyle = setplotstyle('b-'); % used in plot command for line color and type
MaxFrames = 1000; % max number of frames to loop over
34 changes: 34 additions & 0 deletions fvmbook/chap21/radialdam/1drad/setprob.f
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
subroutine setprob
implicit double precision (a-h,o-z)
character*12 fname
common /cparam/ grav
common /comsrc/ ndim
common/cdisc/ x0,y0,alf,beta,r0,idisc
common /comic/ hin,hout
c
c # Set the material parameters for the acoustic equations
c # Passed to the Riemann solver rp1.f in a common block
c
c
iunit = 7
fname = 'setprob.data'
c # open the unit with new routine from Clawpack 4.4 to skip over
c # comment lines starting with #:
call opendatafile(iunit, fname)

c # ndim = space dimensions (2 = cylindrical symmetry, 3 = spherical)
read(7,*) ndim

c # gravitational constant:
read(7,*) grav

c # data for radial dam-break problem:
read(7,*) x0
read(7,*) y0
read(7,*) r0
read(7,*) hin
read(7,*) hout
c
return
end

Loading