Skip to content

Commit 32681eb

Browse files
committed
reverted Makefile and created Makefile_abl and setplot_abl instead
1 parent 3bcb654 commit 32681eb

File tree

3 files changed

+213
-21
lines changed

3 files changed

+213
-21
lines changed

examples/acoustics_2d_radial/Makefile

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ OVERWRITE ?= True # False ==> make a copy of OUTDIR first
2424
# Environment variable FC should be set to fortran compiler, e.g. gfortran
2525

2626
# Compiler flags can be specified here or set as an environment variable
27-
FFLAGS ?=
27+
FFLAGS ?=
2828

2929
# ---------------------------------
3030
# package sources for this program:
@@ -34,7 +34,7 @@ include $(CLAW)/classic/src/2d/Makefile.classic_2d
3434

3535
# ---------------------------------------
3636
# package sources specifically to exclude
37-
# (i.e. if a custom replacement source
37+
# (i.e. if a custom replacement source
3838
# under a different name is provided)
3939
# ---------------------------------------
4040

@@ -53,27 +53,9 @@ SOURCES = \
5353
qinit.f \
5454
setprob.f \
5555
$(CLAW)/riemann/src/rpn2_acoustics.f90 \
56-
$(CLAW)/riemann/src/rpt2_acoustics.f90
56+
$(CLAW)/riemann/src/rpt2_acoustics.f90
5757

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

62-
#-------------------------------------------------------------------
63-
# Add make options that use absorbing boundary layer setrun
64-
.data_abl: setrun_abl.py $(MAKEFILE_LIST) ;
65-
$(MAKE) data_abl -f $(MAKEFILE_LIST)
66-
67-
data_abl: $(MAKEFILE_LIST);
68-
-rm -f .data_abl
69-
$(CLAW_PYTHON) setrun_abl.py $(CLAW_PKG)
70-
touch .data_abl
71-
72-
.output_abl: $(EXE) .data_abl $(MAKEFILE_LIST);
73-
$(MAKE) output_abl -f $(MAKEFILE_LIST)
74-
75-
output_abl: $(MAKEFILE_LIST);
76-
-rm -f .output_abl
77-
$(CLAW_PYTHON) $(CLAW)/clawutil/src/python/clawutil/runclaw.py $(EXE) $(OUTDIR) \
78-
$(OVERWRITE) $(RESTART) . $(GIT_STATUS) $(NOHUP) $(NICE)
79-
@echo $(OUTDIR) > .output_abl
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
2+
# Makefile for Clawpack code in this directory.
3+
# This version only sets the local files and frequently changed
4+
# options, and then includes the standard makefile pointed to by CLAWMAKE.
5+
CLAWMAKE = $(CLAW)/clawutil/src/Makefile.common
6+
7+
# See the above file for details and a list of make options, or type
8+
# make .help
9+
# at the unix prompt.
10+
11+
12+
# Adjust these variables if desired:
13+
# ----------------------------------
14+
15+
CLAW_PKG = classic # Clawpack package to use
16+
EXE = xclaw # Executable to create
17+
SETRUN_FILE = setrun_abl.py # File containing function to make data
18+
OUTDIR = _output_abl # Directory for output
19+
SETPLOT_FILE = setplot_abl.py # File containing function to set plots
20+
PLOTDIR = _plots_abl # Directory for plots
21+
22+
OVERWRITE ?= True # False ==> make a copy of OUTDIR first
23+
24+
# Environment variable FC should be set to fortran compiler, e.g. gfortran
25+
26+
# Compiler flags can be specified here or set as an environment variable
27+
FFLAGS ?=
28+
29+
# ---------------------------------
30+
# package sources for this program:
31+
# ---------------------------------
32+
33+
include $(CLAW)/classic/src/2d/Makefile.classic_2d
34+
35+
# ---------------------------------------
36+
# package sources specifically to exclude
37+
# (i.e. if a custom replacement source
38+
# under a different name is provided)
39+
# ---------------------------------------
40+
41+
EXCLUDE_MODULES = \
42+
43+
EXCLUDE_SOURCES = \
44+
45+
46+
# ---------------------------------
47+
# List of custom sources for this program:
48+
# ---------------------------------
49+
50+
MODULES = \
51+
52+
SOURCES = \
53+
qinit.f \
54+
setprob.f \
55+
$(CLAW)/riemann/src/rpn2_acoustics.f90 \
56+
$(CLAW)/riemann/src/rpt2_acoustics.f90
57+
58+
#-------------------------------------------------------------------
59+
# Include Makefile containing standard definitions and make options:
60+
include $(CLAWMAKE)
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
2+
"""
3+
Set up the plot figures, axes, and items to be done for each frame.
4+
5+
This module is imported by the plotting routines and then the
6+
function setplot is called to set the plot parameters.
7+
8+
"""
9+
10+
from __future__ import absolute_import
11+
from __future__ import print_function
12+
import os
13+
if os.path.exists('./1drad/_output'):
14+
qref_dir = os.path.abspath('./1drad/_output')
15+
else:
16+
qref_dir = None
17+
print("Directory ./1drad/_output not found")
18+
19+
20+
#--------------------------
21+
def setplot(plotdata=None):
22+
#--------------------------
23+
24+
"""
25+
Specify what is to be plotted at each frame.
26+
Input: plotdata, an instance of clawpack.visclaw.data.ClawPlotData.
27+
Output: a modified version of plotdata.
28+
29+
"""
30+
31+
if plotdata is None:
32+
from clawpack.visclaw.data import ClawPlotData
33+
plotdata = ClawPlotData()
34+
35+
36+
from clawpack.visclaw import colormaps
37+
from clawpack.clawutil.data import ClawData
38+
39+
# determine original computational domain
40+
abldata = ClawData()
41+
abldata.read(plotdata.outdir + '/abl.data', force=True)
42+
clawdata = ClawData()
43+
clawdata.read(plotdata.outdir + '/claw.data', force=True)
44+
clawdata.lower[0] += abldata.depth_lower[0]
45+
clawdata.upper[0] -= abldata.depth_upper[0]
46+
clawdata.lower[1] += abldata.depth_lower[1]
47+
clawdata.upper[1] -= abldata.depth_upper[1]
48+
49+
plotdata.clearfigures() # clear any old figures,axes,items data
50+
51+
52+
# Figure for pressure
53+
# -------------------
54+
55+
plotfigure = plotdata.new_plotfigure(name='Pressure', figno=0)
56+
57+
# Set up for axes in this figure:
58+
plotaxes = plotfigure.new_plotaxes()
59+
plotaxes.xlimits = 'auto'
60+
plotaxes.ylimits = 'auto'
61+
plotaxes.title = 'Pressure'
62+
plotaxes.scaled = True # so aspect ratio is 1
63+
64+
# Set up for item on these axes:
65+
plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor')
66+
plotitem.plot_var = 0
67+
plotitem.pcolor_cmap = colormaps.blue_yellow_red
68+
plotitem.pcolor_cmin = -2.0
69+
plotitem.pcolor_cmax = 2.0
70+
plotitem.add_colorbar = True
71+
72+
def plot_original_domain(current_data):
73+
from matplotlib.pyplot import gca
74+
ax = gca()
75+
x = [clawdata.lower[0], clawdata.upper[0], clawdata.upper[0], \
76+
clawdata.lower[0], clawdata.lower[0]]
77+
y = [clawdata.lower[1], clawdata.lower[1], clawdata.upper[1], \
78+
clawdata.upper[1], clawdata.lower[1]]
79+
ax.plot(x, y, '--k')
80+
81+
plotaxes.afteraxes = plot_original_domain
82+
83+
# Figure for scatter plot
84+
# -----------------------
85+
86+
plotfigure = plotdata.new_plotfigure(name='scatter', figno=3)
87+
plotfigure.show = (qref_dir is not None) # don't plot if 1d solution is missing
88+
89+
# Set up for axes in this figure:
90+
plotaxes = plotfigure.new_plotaxes()
91+
plotaxes.xlimits = [0,1.5]
92+
plotaxes.ylimits = [-2.,4.]
93+
plotaxes.title = 'Scatter plot'
94+
95+
# Set up for item on these axes: scatter of 2d data
96+
plotitem = plotaxes.new_plotitem(plot_type='1d_from_2d_data')
97+
98+
def p_vs_r(current_data):
99+
# Return radius of each grid cell and p value in the cell
100+
from numpy.ma import MaskedArray, masked_where
101+
from pylab import sqrt
102+
x = current_data.x
103+
y = current_data.y
104+
r = sqrt(x**2 + y**2)
105+
r = masked_where(x < clawdata.lower[0], r)
106+
r = masked_where(x > clawdata.upper[0], r)
107+
r = masked_where(y < clawdata.lower[1], r)
108+
r = masked_where(y > clawdata.upper[1], r)
109+
q = current_data.q
110+
p = MaskedArray(q[0,:,:], mask=r.mask)
111+
return r,p
112+
113+
plotitem.map_2d_to_1d = p_vs_r
114+
plotitem.plot_var = 0
115+
plotitem.plotstyle = 'o'
116+
plotitem.color = 'b'
117+
plotitem.show = (qref_dir is not None) # show on plot?
118+
119+
# Set up for item on these axes: 1d reference solution
120+
plotitem = plotaxes.new_plotitem(plot_type='1d_plot')
121+
plotitem.outdir = qref_dir
122+
plotitem.plot_var = 0
123+
plotitem.plotstyle = '-'
124+
plotitem.color = 'r'
125+
plotitem.kwargs = {'linewidth': 2}
126+
plotitem.show = True # show on plot?
127+
128+
def make_legend(current_data):
129+
import matplotlib.pyplot as plt
130+
plt.legend(('2d data', '1d reference solution'))
131+
132+
plotaxes.afteraxes = make_legend
133+
134+
135+
# Parameters used only when creating html and/or latex hardcopy
136+
# e.g., via clawpack.visclaw.frametools.printframes:
137+
138+
plotdata.printfigs = True # print figures
139+
plotdata.print_format = 'png' # file format
140+
plotdata.print_framenos = 'all' # list of frames to print
141+
plotdata.print_fignos = 'all' # list of figures to print
142+
plotdata.html = True # create html files of plots?
143+
plotdata.html_homelink = '../README.html' # pointer for top of index
144+
plotdata.html_movie = 'JSAnimation' # new style, or "4.x" for old style
145+
plotdata.latex = True # create latex file of plots?
146+
plotdata.latex_figsperline = 2 # layout of plots
147+
plotdata.latex_framesperline = 1 # layout of plots
148+
plotdata.latex_makepdf = False # also run pdflatex?
149+
150+
return plotdata

0 commit comments

Comments
 (0)