Skip to content
Open
42 changes: 26 additions & 16 deletions paper2_examples/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
The code in this repository supplements a paper that is currently in production.

# Computational Experiments to accompany the paper

## Computational Experiments for the paper Analysis and Performance Evaluation of Adjoint-Guided Adaptive Mesh Refinement Using Clawpack
### "Analysis and Performance Evaluation of Adjoint-Guided Adaptive Mesh Refinement Using Clawpack"

The code in this repository supplements the paper (currently in production): "Analysis and Performance Evaluation of Adjoint-Guided Adaptive Mesh Refinement Using Clawpack."
by Brisa N. Davis and Randall J. LeVeque

This version goes with version 2 of the paper, currently submitted for publication.

Check out the `paper2v1` branch for the version of the code that accompanies the original preprint https://arxiv.org/abs/1810.00927.

This version is updated in the following ways:
- It uses Clawpack v5.6.1, which has the adjoint flagging now built in.
- Example 1 from the original paper has been dropped from v2 of the paper, so the subdirectories have been renamed.

The code is designed to work with the Clawpack 5 software. For more information visit
[the Clawpack webpage](http://www.clawpack.org/ ).
The Clawpack software is open source, and the code is openly available at
Expand All @@ -18,10 +26,10 @@ the use of the adjoint method for guiding adaptive mesh refinement in Clawpack i

* gfortran 5.0.0
* python 2.7.10
* clawpack 5.3.0 : [Clawpack](http://www.clawpack.org/ )
* clawpack 5.6.1 : [Clawpack](http://www.clawpack.org/ )
* git: to clone this repository

Note: Clawpack 5.0 or higher is required, other versions of gfortran and python might work as well.
Note: Later versions of Clawpack should work, other versions of gfortran and python might work as well.

**Operating system.**

Expand All @@ -30,24 +38,24 @@ Note: Clawpack 5.0 or higher is required, other versions of gfortran and python

### Examples Included and Folder Organization

* **acoustics_1d_ex1:** contains the code to run the first one-dimensional variable coefficients
linear acoustics equations example.
* **acoustics_1d_ex1_old:** contains the code to run the first one-dimensional variable coefficients
linear acoustics example from v1 of the paper, not used in v2 of the paper.
The internal folder: **adjoint**, contains the code for the adjoint problem.

* **acoustics_1d_ex2:** contains the code to run the second one-dimensional variable coefficients
linear acoustics equations example.
* **acoustics_1d_example1:** contains the code to run the one-dimensional variable coefficients
linear acoustics example that is Example 1 in v2 of the paper.
The internal folder: **adjoint**, contains the code for the adjoint problem.

* **acoustics_2d_ex1:** contains the code to run the first two-dimensional variable coefficients
linear acoustics equations example.
* **acoustics_2d_example2:** contains the code to run the first two-dimensional variable coefficients
linear acoustics problem that is Example 2 in v2 of the paper.
The internal folder: **adjoint**, contains the code for the adjoint problem.

* **acoustics_2d_ex2:** contains the code to run the second two-dimensional variable coefficients
linear acoustics equations example.
* **acoustics_2d_example3:** contains the code to run the second two-dimensional variable coefficients
linear acoustics problem that is Example 3 in v2 of the paper.
The internal folder: **adjoint**, contains the code for the adjoint problem.

### Running the Code
* **Install Clawpack 5.3.0:**
* **Install Clawpack 5.6.1:**
- Go to: http://www.clawpack.org/installing.html#installation-instructions
- Follow the download and installation intructions in the section: Install all Clawpack packages
- Follow the setup instructions in the section: Set environment variables.
Expand All @@ -60,9 +68,11 @@ The internal folder: **adjoint**, contains the code for the adjoint problem.
- Create a copy of the adjoint repository by running the code:

```
git://github.com/BrisaDavis/adjoint.git
git clone https://github.com/clawpack/adjoint.git
cd adjoint
git checkout paper2v2
```

* **Run the code**

* Go any of the folders and follow the instructions in the README.md in that folder.
* Go any of the folders in `paper2_examples` and follow the instructions in the README.md in that folder.
105 changes: 0 additions & 105 deletions paper2_examples/acoustics_1d_ex1/setplot.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ FFLAGS ?=
# package sources for this program:
# ---------------------------------

AMRLIB = $(CLAW)/amrclaw/src/1d_adjoint
include $(AMRLIB)/Makefile.adjoint_amr_1d
AMRLIB = $(CLAW)/amrclaw/src/1d
include $(AMRLIB)/Makefile.amr_1d

# ---------------------------------------
# package sources specifically to exclude
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,15 @@ subroutine setaux(mbc,mx,xlower,dx,maux,aux)
common /comaux/ Zl, cl, Zr, cr
double precision Zl, cl, Zr, cr

integer i,ii
integer i
double precision xcell

do i=1-mbc,mx+mbc

if (aux(1,i) .eq. NEEDS_TO_BE_SET) then
aux(innerprod_index,i) = 0.d0
endif

xcell = xlower + (i-0.5d0)*dx
if (xcell .lt. 0.0d0) then
aux(1,i) = Zl
Expand All @@ -36,10 +41,5 @@ subroutine setaux(mbc,mx,xlower,dx,maux,aux)
endif
enddo

! Initialize innerproduct to zero.
do ii=1-mbc,mx+mbc
aux(innerprod_index,ii) = 0.d0
enddo

return
end
165 changes: 165 additions & 0 deletions paper2_examples/acoustics_1d_ex1_old/setplot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@

"""
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.

"""

from __future__ import absolute_import
from __future__ import print_function

amr_color = ['g','b','r','c','k']
amr_marker = ['x','s','o','^','.']
amr_linestyle = ['-','-','-','-','-']
amr_plotstyle = [ma+li for ma,li in zip(amr_marker,amr_linestyle)]
print('amr_plotstyle = ',amr_plotstyle)
#amr_plotstyle = ['x-','s-','o-','^-','.-']

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

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

"""


if plotdata is None:
from clawpack.visclaw.data import ClawPlotData
plotdata = ClawPlotData()

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

def draw_interface_add_legend(current_data):
from pylab import plot
plot([0., 0.], [-1000., 1000.], 'k--')
try:
from clawpack.visclaw import legend_tools
labels = ['Level 1','Level 2', 'Level 3', 'Level 4', 'Level 5']
legend_tools.add_legend(labels, colors=amr_color,
markers=amr_marker, linestyles=amr_linestyle,
loc='upper left')
except:
pass

def draw_interface_add_legend_innerprod(current_data):
from pylab import plot
plot([0., 0.], [-1000., 1000.], 'k--')
try:
from clawpack.visclaw import legend_tools
labels = ['Level 3','Level 4']
legend_tools.add_legend(labels, colors=['r','c'],
markers=['o','^'], linestyles=['',''],
loc='upper left')
except:
pass


# Figure for q[0]
plotfigure = plotdata.new_plotfigure(name='Pressure and Velocity', figno=1)
plotfigure.kwargs = {'figsize': (8,8)}
# Set up for axes in this figure:
plotaxes = plotfigure.new_plotaxes()
plotaxes.axescmd = 'subplot(2,1,1)' # top figure
plotaxes.xlimits = [-12,12]
plotaxes.ylimits = [-.5,1.1]
plotaxes.title = 'Pressure'
plotaxes.afteraxes = draw_interface_add_legend

# Set up for item on these axes:
plotitem = plotaxes.new_plotitem(plot_type='1d_plot')
plotitem.plot_var = 0
plotitem.amr_color = amr_color
plotitem.amr_plotstyle = amr_plotstyle
plotitem.amr_data_show = [1,1,1]
plotitem.amr_kwargs = [{'markersize':5},{'markersize':4},{'markersize':3}]

# Figure for q[1]

# Set up for axes in this figure:
plotaxes = plotfigure.new_plotaxes()
plotaxes.axescmd = 'subplot(2,1,2)' # bottom figure
plotaxes.xlimits = [-12,12]
plotaxes.ylimits = [-.5,1.1]
plotaxes.title = 'Velocity'
plotaxes.afteraxes = draw_interface_add_legend

# Set up for item on these axes:
plotitem = plotaxes.new_plotitem(plot_type='1d_plot')
plotitem.plot_var = 1
plotitem.amr_color = amr_color
plotitem.amr_plotstyle = amr_plotstyle
plotitem.amr_data_show = [1,1,1]
plotitem.amr_kwargs = [{'markersize':5},{'markersize':4},{'markersize':3}]

# Figure for inner product, q[2]

plotfigure = plotdata.new_plotfigure(name='Inner Product', figno=10)

# Set up for axes in this figure:
plotaxes = plotfigure.new_plotaxes()
plotaxes.xlimits = [-12,12]
plotaxes.ylimits = [-0.1,1] # use when taking inner product with forward solution
#plotaxes.ylimits = [-0.01,0.02] # use when taking inner product with Richardson error
plotaxes.title = 'Inner Product'
plotaxes.afteraxes = draw_interface_add_legend_innerprod

# Set up for item on these axes:
plotitem = plotaxes.new_plotitem(plot_type='1d')
plotitem.plot_var = plot_innerprod
plotitem.amr_color = amr_color
plotitem.amr_plotstyle = amr_plotstyle
plotitem.amr_data_show = [0,0,1,1,0]
plotitem.show = True # show on plot?


#-----------------------------------------
# Figures for gauges
#-----------------------------------------
plotfigure = plotdata.new_plotfigure(name='q', figno=300, \
type='each_gauge')
plotfigure.clf_each_gauge = True
plotfigure.kwargs = {'figsize': (10,10)}

plotaxes = plotfigure.new_plotaxes()
plotaxes.axescmd = 'subplot(211)'
plotaxes.xlimits = 'auto'
plotaxes.ylimits = 'auto'
plotaxes.title = 'Pressure'
plotitem = plotaxes.new_plotitem(plot_type='1d_plot')
plotitem.plot_var = 0
plotitem.plotstyle = 'b-'

plotaxes = plotfigure.new_plotaxes()
plotaxes.axescmd = 'subplot(212)'
plotaxes.xlimits = 'auto'
plotaxes.ylimits = 'auto'
plotaxes.title = 'Velocity'
plotitem = plotaxes.new_plotitem(plot_type='1d_plot')
plotitem.plot_var = 1
plotitem.plotstyle = 'b-'

# 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'
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

def plot_innerprod(current_data):
return current_data.aux[2,:]

Loading