[cig-commits] r19986 - in short/3D/PyLith/benchmarks/trunk/quasistatic/sceccrustdeform/savageprescott: . figures
brad at geodynamics.org
brad at geodynamics.org
Tue Apr 24 12:50:56 PDT 2012
Author: brad
Date: 2012-04-24 12:50:55 -0700 (Tue, 24 Apr 2012)
New Revision: 19986
Added:
short/3D/PyLith/benchmarks/trunk/quasistatic/sceccrustdeform/savageprescott/plot_soln.py
short/3D/PyLith/benchmarks/trunk/quasistatic/sceccrustdeform/savageprescott/vtk_geometry.py
Removed:
short/3D/PyLith/benchmarks/trunk/quasistatic/sceccrustdeform/savageprescott/figures/Figure.py
short/3D/PyLith/benchmarks/trunk/quasistatic/sceccrustdeform/savageprescott/figures/plot_profiles.py
short/3D/PyLith/benchmarks/trunk/quasistatic/sceccrustdeform/savageprescott/figures/plot_soln.py
short/3D/PyLith/benchmarks/trunk/quasistatic/sceccrustdeform/savageprescott/figures/spbm_hex8_graded_c2.eps
short/3D/PyLith/benchmarks/trunk/quasistatic/sceccrustdeform/savageprescott/figures/spbm_hex8_graded_c9.eps
short/3D/PyLith/benchmarks/trunk/quasistatic/sceccrustdeform/savageprescott/figures/spbm_hex8_unif_c2.eps
short/3D/PyLith/benchmarks/trunk/quasistatic/sceccrustdeform/savageprescott/figures/spbm_hex8_unif_c9.eps
short/3D/PyLith/benchmarks/trunk/quasistatic/sceccrustdeform/savageprescott/figures/spbm_tet4_graded_c2.eps
short/3D/PyLith/benchmarks/trunk/quasistatic/sceccrustdeform/savageprescott/figures/spbm_tet4_graded_c9.eps
short/3D/PyLith/benchmarks/trunk/quasistatic/sceccrustdeform/savageprescott/figures/spbm_tet4_unif_c2.eps
short/3D/PyLith/benchmarks/trunk/quasistatic/sceccrustdeform/savageprescott/figures/spbm_tet4_unif_c9.eps
short/3D/PyLith/benchmarks/trunk/quasistatic/sceccrustdeform/savageprescott/figures/vtk_geometry.py
Modified:
short/3D/PyLith/benchmarks/trunk/quasistatic/sceccrustdeform/savageprescott/plot_profiles.py
Log:
Updated plot_soln for Mayavi 4.0.
Deleted: short/3D/PyLith/benchmarks/trunk/quasistatic/sceccrustdeform/savageprescott/figures/Figure.py
===================================================================
--- short/3D/PyLith/benchmarks/trunk/quasistatic/sceccrustdeform/savageprescott/figures/Figure.py 2012-04-24 15:02:42 UTC (rev 19985)
+++ short/3D/PyLith/benchmarks/trunk/quasistatic/sceccrustdeform/savageprescott/figures/Figure.py 2012-04-24 19:50:55 UTC (rev 19986)
@@ -1,141 +0,0 @@
-#!/usr/bin/env python
-#
-# ======================================================================
-#
-# Brad T. Aagaard
-# U.S. Geological Survey
-#
-# {LicenseText}
-#
-# ======================================================================
-#
-
-import pylab
-
-# ----------------------------------------------------------------------
-class Figure:
-
- def __init__(self,
- color="lightbg",
- style="hardcopy",
- fontsize=8,
- palette="blueorange"):
- """
- Constructor.
- """
- self.handle = None
- self.colorstyle = color
- self.defaults = {'figure.facecolor': 'bg',
- 'axes.facecolor': 'bg',
- 'axes.edgecolor': 'fg',
- 'axes.labelcolor': 'fg',
- 'axes.labelsize': fontsize,
- 'axes.titlesize': fontsize,
- 'xtick.color': 'fg',
- 'ytick.color': 'fg',
- 'font.size': fontsize,
- 'text.color': 'fg',
- 'legend.fontsize': fontsize,
- 'grid.color': 'fg',
- 'xtick.labelsize': fontsize,
- 'xtick.color': 'fg',
- 'ytick.labelsize': fontsize,
- 'ytick.color': 'fg',
- 'savefig.facecolor': 'bg',
- 'savefig.edgecolor': 'bg',
- }
- return
-
-
- def open(self, width, height, margins):
- """
- Open figure.
- """
- self._setup()
- for setting in self.defaults.items():
- pylab.rcParams[setting[0]] = setting[1]
- self.handle = pylab.figure(figsize=(width, height),
- facecolor='bg',
- dpi=90)
- self.handle.set_facecolor('bg')
- self.margins = margins
- return
-
-
- def close(self):
- """
- Close figure.
- """
- pylab.close(self.handle)
- self.handle = None
- return
-
-
- def subplot(self, nrows, ncols, row, col):
- """
- Create subplot in figure.
- """
- i = (row-1)*ncols+col
- h = pylab.subplot(nrows, ncols, (row-1)*ncols+col)
- return h
-
-
- def axes(self, nrows, ncols, row, col):
- """
- Create subplot in figure.
- """
- h = self.handle.get_figheight()
- w = self.handle.get_figwidth()
- margins = self.margins
- marginLeft = margins[0][0]
- hsep = margins[0][1]
- marginRight = margins[0][2]
- marginBottom = margins[1][0]
- vsep = margins[1][1]
- marginTop = margins[1][2]
- plotW = (w-marginRight-marginLeft-hsep*(ncols-1))/float(ncols)
- plotH = (h-marginTop-marginBottom-vsep*(nrows-1))/float(nrows)
-
- left = (marginLeft+(col-1)*(plotW+hsep)) / w
- right = left + plotW/w
- bottom = (marginBottom+(nrows-row)*(plotH+vsep)) / h
- top = bottom + plotH / h
- #print "left: %.4f, right: %.4f, top: %.4f, bottom: %.4f, width: %.4f, height: %.4f" % \
- # (left, right, top, bottom, plotW/w, plotH/h)
- axes = pylab.subplot(nrows, ncols, ncols*(row-1)+col)
- axes.set_position([left, bottom, plotW/w, plotH/h])
- return axes
-
-
- def _setup(self):
- if self.colorstyle == "lightbg":
- fg = (0.01, 0.01, 0.01)
- bg = (0.99, 0.99, 0.99)
- elif self.colorstyle == "darkbg":
- fg = (0.99, 0.99, 0.99)
- bg = (0.01, 0.01, 0.01)
-
- colors = {'fg': fg,
- 'bg': bg,
- 'dkgray': (0.25, 0.25, 0.25),
- 'mdgray': (0.5, 0.5, 0.5),
- 'ltgray': (0.75, 0.75, 0.75),
- 'dkslate': (0.18, 0.21, 0.28),
- 'slate': (0.45, 0.50, 0.68),
- 'ltorange': (1.0, 0.74, 0.41),
- 'orange': (0.96, 0.50, 0.0),
- 'ltred': (1.0, 0.25, 0.25),
- 'red': (0.79, 0.00, 0.01),
- 'ltblue': (0.2, 0.73, 1.0),
- 'blue': (0.12, 0.43, 0.59),
- 'ltgreen': (0.37, 0.80, 0.05),
- 'green': (0.23, 0.49, 0.03),
- 'ltpurple': (0.81, 0.57, 1.0),
- 'purple': (0.38, 0.00, 0.68)}
- from matplotlib.colors import colorConverter
- for key in colors.keys():
- colorConverter.colors[key] = colors[key]
- return
-
-
-# End of file
Deleted: short/3D/PyLith/benchmarks/trunk/quasistatic/sceccrustdeform/savageprescott/figures/plot_profiles.py
===================================================================
--- short/3D/PyLith/benchmarks/trunk/quasistatic/sceccrustdeform/savageprescott/figures/plot_profiles.py 2012-04-24 15:02:42 UTC (rev 19985)
+++ short/3D/PyLith/benchmarks/trunk/quasistatic/sceccrustdeform/savageprescott/figures/plot_profiles.py 2012-04-24 19:50:55 UTC (rev 19986)
@@ -1,137 +0,0 @@
-#!/usr/bin/env python
-#
-# ======================================================================
-#
-# Brad T. Aagaard
-# U.S. Geological Survey
-#
-# {LicenseText}
-#
-# ======================================================================
-#
-
-cycles = [2,9]
-style = "lightbg"
-fileSuffix = "eps"
-plotSize = "poster"
-
-# ======================================================================
-import numpy
-import pylab
-from mypylab.Figure import Figure
-
-# ----------------------------------------------------------------------
-class ProfileSet(object):
- """
- Set of profiles.
- """
-
- def __init__(self, filename):
- self.data = numpy.loadtxt(filename, comments="#")
- ncols = self.data.shape[1]
- self.data[:,1:ncols+1] /= 400.0 # Coseismic displacement
- self.data[:,0] /= 40.0 # Thickness of elastic layer
- return
-
-
- def plot(self, linestyle):
- data = self.data
- ncols = data.shape[1]
- if ncols == 42:
- indicesTime = [2, 10, 20, 30, 38]
- elif ncols == 21:
- indicesTime = [1, 5, 10, 15, 19]
-
- colorOrder = ('orange', 'blue', 'red', 'green', 'purple')
- i = 0
- for index in indicesTime:
- h = pylab.plot(data[:,0], data[:,1+index], linestyle, color=colorOrder[i])
- i += 1
- return h
-
-
-# ----------------------------------------------------------------------
-class Profiles(Figure):
- """
- Figure with velocity time histories for a site.
- """
-
- def __init__(self, cycle):
- if plotSize == "poster":
- fontsize = 14
- elif plotSize == "presentation":
- fontsize = 14
- elif plotSize == "manual":
- fontsize = 10
- else:
- raise ValueError("Unknown plotSize '%s'." % plotSize)
- Figure.__init__(self, color=style, fontsize=fontsize)
- self.cycle = cycle
- return
-
-
- def plot(self):
-
- self.width = 7.25
- self.height = 5.0
-
- # Create figure
- self.open(self.width, self.height, margins=[[0.70, 0, 0.20],
- [0.55, 0, 0.12]])
-
- # Plot profiles
- self.axes(1, 1, 1, 1)
- analytic = ProfileSet("savpres_displ_c%dref.txt" % self.cycle)
- ah = analytic.plot(linestyle="-")
- pylab.hold(True)
- simulation = ProfileSet("spbm_hex8_graded_c%dref.txt" % self.cycle)
- sh = simulation.plot(linestyle="--")
- pylab.hold(False)
-
- pylab.xlim(0, 10)
- pylab.ylim(0, 0.5)
-
- leg = pylab.legend((ah, sh),
- ["analytic", "simulation"],
- loc="upper left")
- leg.legendPatch.set_facecolor('bg')
- leg.legendPatch.set_edgecolor('fg')
- self._annotate()
- return
-
-
- def save(self):
- pylab.figure(self.handle.number)
- pylab.savefig("spbm_hex8_graded_profile%d.%s" % (self.cycle, fileSuffix))
- return
-
-
- def _annotate(self):
- """
- Add title and labels for axes.
- """
- pylab.xlabel("Dist. from fault / Elastic thickness")
- pylab.ylabel("Disp. / Coseismic Disp. ")
-
- pylab.text(9.9, 0.03, "t=0.05", horizontalalignment="right")
- pylab.text(9.9, 0.13, "t=0.25", horizontalalignment="right")
- pylab.text(9.9, 0.255, "t=0.50", horizontalalignment="right")
- pylab.text(9.9, 0.37, "t=0.75", horizontalalignment="right")
- pylab.text(9.9, 0.46, "t=0.95", horizontalalignment="right")
- return
-
-
-# ----------------------------------------------------------------------
-if __name__ == "__main__":
-
- figures = []
- for cycle in cycles:
- figure = Profiles(cycle)
- figure.plot()
- figures.append(figure)
-
- pylab.show()
- for figure in figures:
- figure.save()
-
-# End of file
Deleted: short/3D/PyLith/benchmarks/trunk/quasistatic/sceccrustdeform/savageprescott/figures/plot_soln.py
===================================================================
--- short/3D/PyLith/benchmarks/trunk/quasistatic/sceccrustdeform/savageprescott/figures/plot_soln.py 2012-04-24 15:02:42 UTC (rev 19985)
+++ short/3D/PyLith/benchmarks/trunk/quasistatic/sceccrustdeform/savageprescott/figures/plot_soln.py 2012-04-24 19:50:55 UTC (rev 19986)
@@ -1,200 +0,0 @@
-#!/usr/bin/env python
-#
-# ======================================================================
-#
-# Brad T. Aagaard
-# U.S. Geological Survey
-#
-# {LicenseText}
-#
-# ======================================================================
-#
-
-shape = "hex8"
-scaleFactor = 5.0/40.0
-t = 1900
-pngfile = "savageprescott_soln.png"
-
-style = {'colors': "lightbg",
- }
-
-from enthought.mayavi.app import Mayavi
-import vtk_geometry
-from enthought.mayavi.sources.vtk_data_source import VTKDataSource
-from enthought.mayavi.filters.warp_vector import WarpVector
-from enthought.mayavi.filters.extract_vector_norm import ExtractVectorNorm
-from enthought.mayavi.modules.surface import Surface
-from enthought.mayavi.modules.outline import Outline
-from enthought.mayavi.modules.axes import Axes
-from enthought.mayavi.modules.surface import Surface
-
-class PlotSoln(Mayavi):
-
- # PUBLIC METHODS /////////////////////////////////////////////////////
-
- def run(self):
-
- self._setup()
-
- self._renderScene()
- self._annotateScene()
- self._setCamera()
- scene = self.script.engine.current_scene.scene
- scene.disable_render = False
- scene.render()
- scene.save_png(pngfile)
-
- return
-
- # PRIVATE METHODS ////////////////////////////////////////////////////
-
- def _setup(self):
- """
- Plot axes, fault surface, and materials.
- """
-
- dkslate = (47/255.0, 53/255.0, 72/255.0)
- ltblue = (51/255.0, 187/255.0, 255/255.0)
- ltred = (1.0, 0.25, 0.25)
- red = (1.0, 0.40, 0.40)
- ltyellow = (1.0, 1.0, 0.45)
-
- if style['colors'] == "darkbg":
- dkslate = (47/255.0, 53/255.0, 72/255.0)
- ltblue = (51/255.0, 187/255.0, 255/255.0)
- ltred = (1.0, 0.25, 0.25)
- self.colorFg = (1,1,1)
- self.colorBg = dkslate
- self.colorSurfTrace = red
- self.colorCities = ltyellow
- else:
- self.colorFg = (0,0,0)
- self.colorBg = (1,1,1)
- self.colorSurfTrace = (0,0,1)
- self.lut = "hot"
- self.lutReverse = True
-
- self.windowSize = (1600+16, 675+120)
- self.aaframes = 4
-
- return
-
-
- def _renderScene(self):
-
- script = self.script
- w = script.get_active_window()
- w.size = self.windowSize
- script.new_scene()
- scene = script.engine.current_scene.scene
- scene.disable_render = True
- scene.anti_aliasing_frames = self.aaframes
- scene.background = self.colorBg
- scene.foreground = self.colorFg
-
-
- script = self.script
- script.add_source(VTKDataSource(data=self._readData()))
- script.engine.current_object.name = "Solution"
-
- warp = WarpVector()
- warp.filter.scale_factor = scaleFactor
- script.add_filter(warp)
-
- norm = ExtractVectorNorm()
- script.add_filter(norm)
-
- surf = Surface()
- script.add_module(surf)
-
- wire = Surface()
- script.add_module(wire)
- wire.actor.actor.property.representation = "wireframe"
- wire.actor.actor.property.color = (0.0, 0.0, 0.0)
- wire.actor.mapper.scalar_visibility = False
-
- colorbar = script.engine.current_object.module_manager.scalar_lut_manager
- colorbar.scalar_bar.label_format = "%3.1f"
- colorbar.scalar_bar.label_text_property.font_size = 18
- colorbar.scalar_bar.label_text_property.shadow = True
- colorbar.scalar_bar.label_text_property.italic = False
- colorbar.scalar_bar.title_text_property.italic = False
- colorbar.scalar_bar.title_text_property.shadow = True
- colorbar.show_scalar_bar = True
- colorbar.data_range = (0.0, 18.0)
- colorbar.number_of_labels = 7
- w,h = colorbar.scalar_bar.position2
- colorbar.scalar_bar.position2 = (0.4, 0.11)
- colorbar.scalar_bar.position = (0.25, 0.02)
- colorbar.data_name = "Displacement [m]"
-
- return
-
- def _annotateScene(self):
-
- script = self.script
-
- # Domain (axes and outline)
- script.add_source(VTKDataSource(data=vtk_geometry.domain()))
- script.engine.current_object.name = "Domain"
- outline = Outline()
- script.add_module(outline)
- outline.actor.property.opacity = 0.2
- axes = Axes()
- axes.axes.x_label = "X"
- axes.axes.y_label = "Y"
- axes.axes.z_label = "Z"
- axes.axes.label_format = "%-0.1f"
- script.add_module(axes)
-
- return
-
-
- def _setCamera(self):
- script = self.script
- vtk_geometry.setCamera(script.engine.current_scene.scene.camera)
- return
-
-
- def _readData(self):
- from enthought.tvtk.api import tvtk
- import tables
- import numpy
-
- filename = "../results/spbm_%s_graded3_20km/spbm_%s_graded3_20km_t%04d.h5" % (shape, shape, t)
- h5 = tables.openFile(filename, 'r')
-
- cells = h5.root.topology.cells[:]
- (ncells, ncorners) = cells.shape
- vertices = h5.root.geometry.vertices[:] / (1e+3 * 40.0)
- (nvertices, spaceDim) = vertices.shape
- disp = h5.root.solution.snapshot0.displacements[:]
- h5.close()
-
- if shape == "tet4":
- assert(spaceDim == 3)
- assert(ncorners == 4)
- cellType = tvtk.Tetra().cell_type
- elif shape == "hex8":
- assert(spaceDim == 3)
- assert(ncorners == 8)
- cellType = tvtk.Hexahedron().cell_type
- else:
- raise ValueError("Unknown shape '%s'." % shape)
-
- data = tvtk.UnstructuredGrid()
- data.points = vertices
- data.set_cells(cellType, cells)
- data.point_data.vectors = disp
- data.point_data.vectors.name = "Displacement [m]"
- return data
-
-
-# ----------------------------------------------------------------------
-if __name__ == "__main__":
- app = PlotSoln()
- app.main()
-
-
-# End of file
-
Deleted: short/3D/PyLith/benchmarks/trunk/quasistatic/sceccrustdeform/savageprescott/figures/spbm_hex8_graded_c2.eps
===================================================================
(Binary files differ)
Deleted: short/3D/PyLith/benchmarks/trunk/quasistatic/sceccrustdeform/savageprescott/figures/spbm_hex8_graded_c9.eps
===================================================================
(Binary files differ)
Deleted: short/3D/PyLith/benchmarks/trunk/quasistatic/sceccrustdeform/savageprescott/figures/spbm_hex8_unif_c2.eps
===================================================================
(Binary files differ)
Deleted: short/3D/PyLith/benchmarks/trunk/quasistatic/sceccrustdeform/savageprescott/figures/spbm_hex8_unif_c9.eps
===================================================================
(Binary files differ)
Deleted: short/3D/PyLith/benchmarks/trunk/quasistatic/sceccrustdeform/savageprescott/figures/spbm_tet4_graded_c2.eps
===================================================================
(Binary files differ)
Deleted: short/3D/PyLith/benchmarks/trunk/quasistatic/sceccrustdeform/savageprescott/figures/spbm_tet4_graded_c9.eps
===================================================================
(Binary files differ)
Deleted: short/3D/PyLith/benchmarks/trunk/quasistatic/sceccrustdeform/savageprescott/figures/spbm_tet4_unif_c2.eps
===================================================================
(Binary files differ)
Deleted: short/3D/PyLith/benchmarks/trunk/quasistatic/sceccrustdeform/savageprescott/figures/spbm_tet4_unif_c9.eps
===================================================================
(Binary files differ)
Deleted: short/3D/PyLith/benchmarks/trunk/quasistatic/sceccrustdeform/savageprescott/figures/vtk_geometry.py
===================================================================
--- short/3D/PyLith/benchmarks/trunk/quasistatic/sceccrustdeform/savageprescott/figures/vtk_geometry.py 2012-04-24 15:02:42 UTC (rev 19985)
+++ short/3D/PyLith/benchmarks/trunk/quasistatic/sceccrustdeform/savageprescott/figures/vtk_geometry.py 2012-04-24 19:50:55 UTC (rev 19986)
@@ -1,102 +0,0 @@
-#!/usr/bin/env python
-#
-# ======================================================================
-#
-# Brad T. Aagaard
-# U.S. Geological Survey
-#
-# {LicenseText}
-#
-# ======================================================================
-#
-
-from enthought.tvtk.api import tvtk
-import numpy
-
-# ----------------------------------------------------------------------
-def domain():
- domain = tvtk.CubeSource()
- domain.set_bounds(-1000/40.0, 1000/40.0, -500/40.0, 500/40.0, -400/40.0, 0.0)
- return domain.get_output()
-
-# ----------------------------------------------------------------------
-def fault(showTaper=False):
- vertices = numpy.array(
- [ [12.0, 0.0, 0.0], # 0
- [12.0, 12.0, 0.0], # 1
- [12.0, 16.0, 0.0], # 2
- [12.0, 0.0, -12.0], # 3
- [12.0, 12.0, -12.0], # 4
- [12.0, 0.0, -16.0], # 5
- [12.0, 12.0, -16.0], # 6
- [12.0, 16.0, -16.0] ], # 7
- dtype=numpy.float32)
-
- # Setup VTK vertices
- if not showTaper:
- polys = numpy.array(
- [ [0, 3, 1],
- [1, 3, 4],
- [3, 5, 4],
- [4, 5, 6],
- [1, 6, 2],
- [2, 6, 7] ],
- dtype=numpy.int32)
-
- # Setup VTK simplices
- data = [{'name': "fault",
- 'object': tvtk.PolyData(points=vertices, polys=polys)}]
- else:
- polys = numpy.array(
- [ [0, 3, 1],
- [1, 3, 4] ],
- dtype=numpy.int32)
- polysTaper = numpy.array(
- [ [3, 5, 4],
- [4, 5, 6],
- [1, 6, 2],
- [2, 6, 7] ],
- dtype=numpy.int32)
-
- data= [{'name': "fault",
- 'object': tvtk.PolyData(points=vertices, polys=polys)},
- {'name': "taper",
- 'object': tvtk.PolyData(points=vertices, polys=polysTaper)}]
- return data
-
-
-# ----------------------------------------------------------------------
-def materials():
- l = 24.0
- elastic = tvtk.CubeSource()
- elastic.set_bounds(0, l, 0, l, -l/2.0, 0.0)
- viscoelastic = tvtk.CubeSource()
- viscoelastic.set_bounds(0, l, 0, l, -l, -l/2.0)
- return [{'name': "elastic",
- 'object': elastic.get_output()},
- {'name': "viscoelastic",
- 'object': viscoelastic.get_output()}]
-
-# ----------------------------------------------------------------------
-def setCamera(camera):
- dist = 2000.0/40.0
- angle = 40.0
- elev = 30.0
- azimuth = 25.0
- clipRange = numpy.array( [200/40.0, 5000/40.0] )
- ptTo = numpy.array( [0.0, 0.0, -500/40.0] )
- ptFrom = ptTo + numpy.array( [0.0, -dist, 0.0])
-
- camera.view_angle = angle
- camera.view_up = (0,0,1)
- camera.focal_point = ptTo
- camera.position = ptFrom
- camera.elevation(elev)
- camera.azimuth(azimuth)
- camera.clipping_range = clipRange
- return
-
-
-# ----------------------------------------------------------------------
-def setWindow(maya):
- return
Modified: short/3D/PyLith/benchmarks/trunk/quasistatic/sceccrustdeform/savageprescott/plot_profiles.py
===================================================================
--- short/3D/PyLith/benchmarks/trunk/quasistatic/sceccrustdeform/savageprescott/plot_profiles.py 2012-04-24 15:02:42 UTC (rev 19985)
+++ short/3D/PyLith/benchmarks/trunk/quasistatic/sceccrustdeform/savageprescott/plot_profiles.py 2012-04-24 19:50:55 UTC (rev 19986)
@@ -41,9 +41,9 @@
#symdict = {'Hex8': 's',
# 'Tet4': '^',
# }
-lineStyle = [("red", (2.0, 1.0)),
- ("blue", (4.0, 1.0)),
- ("purple", (6.0, 1.0)),
+lineStyle = [("blue", (6.0, 2.0)),
+ ("red", (3.0, 2.0)),
+ ("purple", (2.0, 1.0)),
("green", (3.0, 1.0, 1.5, 1.0)),
("orange", (6.0, 1.0, 1.5, 1.0)),
("black", (None, None)),
@@ -103,13 +103,7 @@
dist = vertices[indices,0].squeeze()
disp = disp[:,indices,1].squeeze()
- # Remove value on negative side of fault and sort distances.
- numSteps = disp.shape[0]
- dispTest = disp[numSteps -1,:]
- negInd = numpy.nonzero(dispTest < 0.0)[0][0]
- distPos = numpy.delete(dist, negInd)
- indices = numpy.argsort(distPos)
-
+ indices = numpy.argsort(dist)
self.dist = dist[indices] / elastThick.value # Normalize by elastic thickness
self.disp = disp[:,indices] / eqslip.value # Normalize by eqslip
self.time = time
Added: short/3D/PyLith/benchmarks/trunk/quasistatic/sceccrustdeform/savageprescott/plot_soln.py
===================================================================
--- short/3D/PyLith/benchmarks/trunk/quasistatic/sceccrustdeform/savageprescott/plot_soln.py (rev 0)
+++ short/3D/PyLith/benchmarks/trunk/quasistatic/sceccrustdeform/savageprescott/plot_soln.py 2012-04-24 19:50:55 UTC (rev 19986)
@@ -0,0 +1,198 @@
+#!/usr/bin/env python
+#
+# ======================================================================
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# ======================================================================
+#
+
+cell = "hex8"
+scaleFactor = 5.0/40.0
+tindex = 38
+pngfile = "savageprescott_soln.png"
+
+style = {'colors': "lightbg",
+ }
+
+from mayavi.plugins.app import Mayavi
+from mayavi.sources.vtk_data_source import VTKDataSource
+from mayavi.filters.warp_vector import WarpVector
+from mayavi.filters.extract_vector_norm import ExtractVectorNorm
+from mayavi.modules.surface import Surface
+from mayavi.modules.outline import Outline
+from mayavi.modules.axes import Axes
+from mayavi.modules.surface import Surface
+import vtk_geometry
+
+class PlotSoln(Mayavi):
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def run(self):
+
+ self._setup()
+
+ self._renderScene()
+ self._annotateScene()
+ self._setCamera()
+ scene = self.script.engine.current_scene.scene
+ scene.disable_render = False
+ scene.render()
+ scene.save_png(pngfile)
+
+ return
+
+ # PRIVATE METHODS ////////////////////////////////////////////////////
+
+ def _setup(self):
+ """
+ Plot axes, fault surface, and materials.
+ """
+
+ dkslate = (47/255.0, 53/255.0, 72/255.0)
+ ltblue = (51/255.0, 187/255.0, 255/255.0)
+ ltred = (1.0, 0.25, 0.25)
+ red = (1.0, 0.40, 0.40)
+ ltyellow = (1.0, 1.0, 0.45)
+
+ if style['colors'] == "darkbg":
+ dkslate = (47/255.0, 53/255.0, 72/255.0)
+ ltblue = (51/255.0, 187/255.0, 255/255.0)
+ ltred = (1.0, 0.25, 0.25)
+ self.colorFg = (1,1,1)
+ self.colorBg = dkslate
+ self.colorSurfTrace = red
+ self.colorCities = ltyellow
+ else:
+ self.colorFg = (0,0,0)
+ self.colorBg = (1,1,1)
+ self.colorSurfTrace = (0,0,1)
+ self.lut = "hot"
+ self.lutReverse = True
+
+ #self.windowSize = (1400+16, 675+120)
+ self.windowSize = (900+16, 434+120)
+ self.aaframes = 4
+
+ return
+
+
+ def _renderScene(self):
+
+ script = self.script
+ w = script.get_active_window()
+ w.size = self.windowSize
+ script.new_scene()
+ scene = script.engine.current_scene.scene
+ scene.disable_render = True
+ scene.anti_aliasing_frames = self.aaframes
+ scene.background = self.colorBg
+ scene.foreground = self.colorFg
+
+
+ script = self.script
+ script.add_source(VTKDataSource(data=self._readData()))
+ script.engine.current_object.name = "Solution"
+
+ warp = WarpVector()
+ warp.filter.scale_factor = scaleFactor
+ script.add_filter(warp)
+
+ norm = ExtractVectorNorm()
+ script.add_filter(norm)
+
+ surf = Surface()
+ script.add_module(surf)
+
+ wire = Surface()
+ script.add_module(wire)
+ wire.actor.actor.property.representation = "wireframe"
+ wire.actor.actor.property.color = (0.0, 0.0, 0.0)
+ wire.actor.mapper.scalar_visibility = False
+
+ colorbar = script.engine.current_object.module_manager.scalar_lut_manager
+ colorbar.scalar_bar.orientation = "horizontal"
+ colorbar.scalar_bar.label_format = "%3.1f"
+ colorbar.scalar_bar.label_text_property.shadow = True
+ colorbar.scalar_bar.label_text_property.italic = False
+ colorbar.scalar_bar.title_text_property.italic = False
+ colorbar.scalar_bar.title_text_property.shadow = True
+ colorbar.show_scalar_bar = True
+ colorbar.data_range = (0.0, 18.0)
+ colorbar.number_of_labels = 7
+ colorbar.data_name = "Displacement (m)"
+ scalar_bar = colorbar.scalar_bar_widget.representation
+ scalar_bar.position2 = (0.4, 0.15)
+ scalar_bar.position = (0.25, 0.02)
+
+ return
+
+ def _annotateScene(self):
+
+ script = self.script
+
+ # Domain (axes and outline)
+ script.add_source(VTKDataSource(data=vtk_geometry.domain()))
+ script.engine.current_object.name = "Domain"
+ outline = Outline()
+ script.add_module(outline)
+ outline.actor.property.opacity = 0.2
+ axes = Axes()
+ axes.axes.x_label = "X"
+ axes.axes.y_label = "Y"
+ axes.axes.z_label = "Z"
+ axes.axes.label_format = "%-0.1f"
+ script.add_module(axes)
+
+ return
+
+
+ def _setCamera(self):
+ script = self.script
+ vtk_geometry.setCamera(script.engine.current_scene.scene.camera)
+ return
+
+
+ def _readData(self):
+ from tvtk.api import tvtk
+ import tables
+ import numpy
+
+ filename = "output/%s.h5" % cell
+ h5 = tables.openFile(filename, 'r')
+
+ cells = h5.root.topology.cells[:]
+ (ncells, ncorners) = cells.shape
+ vertices = h5.root.geometry.vertices[:] / (1e+3 * 40.0)
+ (nvertices, spaceDim) = vertices.shape
+ disp = h5.root.vertex_fields.displacement[tindex,:,:]
+ h5.close()
+
+ if cell == "tet4":
+ assert(spaceDim == 3)
+ assert(ncorners == 4)
+ cellType = tvtk.Tetra().cell_type
+ elif cell == "hex8":
+ assert(spaceDim == 3)
+ assert(ncorners == 8)
+ cellType = tvtk.Hexahedron().cell_type
+ else:
+ raise ValueError("Unknown cell '%s'." % cell)
+
+ data = tvtk.UnstructuredGrid()
+ data.points = vertices
+ data.set_cells(cellType, cells)
+ data.point_data.vectors = disp
+ data.point_data.vectors.name = "Displacement [m]"
+ return data
+
+
+# ----------------------------------------------------------------------
+if __name__ == "__main__":
+ app = PlotSoln()
+ app.main()
+
+
+# End of file
Property changes on: short/3D/PyLith/benchmarks/trunk/quasistatic/sceccrustdeform/savageprescott/plot_soln.py
___________________________________________________________________
Name: svn:executable
+ *
Added: short/3D/PyLith/benchmarks/trunk/quasistatic/sceccrustdeform/savageprescott/vtk_geometry.py
===================================================================
--- short/3D/PyLith/benchmarks/trunk/quasistatic/sceccrustdeform/savageprescott/vtk_geometry.py (rev 0)
+++ short/3D/PyLith/benchmarks/trunk/quasistatic/sceccrustdeform/savageprescott/vtk_geometry.py 2012-04-24 19:50:55 UTC (rev 19986)
@@ -0,0 +1,100 @@
+#!/usr/bin/env python
+#
+# ======================================================================
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# ======================================================================
+#
+
+from tvtk.api import tvtk
+import numpy
+
+# ----------------------------------------------------------------------
+def domain():
+ domain = tvtk.CubeSource()
+ domain.set_bounds(-1000/40.0, 1000/40.0, -500/40.0, 500/40.0, -400/40.0, 0.0)
+ return domain.get_output()
+
+# ----------------------------------------------------------------------
+def fault(showTaper=False):
+ vertices = numpy.array(
+ [ [12.0, 0.0, 0.0], # 0
+ [12.0, 12.0, 0.0], # 1
+ [12.0, 16.0, 0.0], # 2
+ [12.0, 0.0, -12.0], # 3
+ [12.0, 12.0, -12.0], # 4
+ [12.0, 0.0, -16.0], # 5
+ [12.0, 12.0, -16.0], # 6
+ [12.0, 16.0, -16.0] ], # 7
+ dtype=numpy.float32)
+
+ # Setup VTK vertices
+ if not showTaper:
+ polys = numpy.array(
+ [ [0, 3, 1],
+ [1, 3, 4],
+ [3, 5, 4],
+ [4, 5, 6],
+ [1, 6, 2],
+ [2, 6, 7] ],
+ dtype=numpy.int32)
+
+ # Setup VTK simplices
+ data = [{'name': "fault",
+ 'object': tvtk.PolyData(points=vertices, polys=polys)}]
+ else:
+ polys = numpy.array(
+ [ [0, 3, 1],
+ [1, 3, 4] ],
+ dtype=numpy.int32)
+ polysTaper = numpy.array(
+ [ [3, 5, 4],
+ [4, 5, 6],
+ [1, 6, 2],
+ [2, 6, 7] ],
+ dtype=numpy.int32)
+
+ data= [{'name': "fault",
+ 'object': tvtk.PolyData(points=vertices, polys=polys)},
+ {'name': "taper",
+ 'object': tvtk.PolyData(points=vertices, polys=polysTaper)}]
+ return data
+
+
+# ----------------------------------------------------------------------
+def materials():
+ l = 24.0
+ elastic = tvtk.CubeSource()
+ elastic.set_bounds(0, l, 0, l, -l/2.0, 0.0)
+ viscoelastic = tvtk.CubeSource()
+ viscoelastic.set_bounds(0, l, 0, l, -l, -l/2.0)
+ return [{'name': "elastic",
+ 'object': elastic.get_output()},
+ {'name': "viscoelastic",
+ 'object': viscoelastic.get_output()}]
+
+# ----------------------------------------------------------------------
+def setCamera(camera):
+ dist = 2000.0/40.0
+ angle = 40.0
+ elev = 30.0
+ azimuth = 25.0
+ clipRange = numpy.array( [200/40.0, 5000/40.0] )
+ ptTo = numpy.array( [0.0, 0.0, -500/40.0] )
+ ptFrom = ptTo + numpy.array( [0.0, -dist, 0.0])
+
+ camera.view_angle = angle
+ camera.view_up = (0,0,1)
+ camera.focal_point = ptTo
+ camera.position = ptFrom
+ camera.elevation(elev)
+ camera.azimuth(azimuth)
+ camera.clipping_range = clipRange
+ return
+
+
+# ----------------------------------------------------------------------
+def setWindow(maya):
+ return
More information about the CIG-COMMITS
mailing list