[cig-commits] r20026 - in short/3D/PyLith/branches/v1.7-trunk: modulesrc/faults pylith pylith/faults pylith/meshio
brad at geodynamics.org
brad at geodynamics.org
Wed May 2 17:10:31 PDT 2012
Author: brad
Date: 2012-05-02 17:10:31 -0700 (Wed, 02 May 2012)
New Revision: 20026
Added:
short/3D/PyLith/branches/v1.7-trunk/modulesrc/faults/FaultCohesiveImpulses.i
short/3D/PyLith/branches/v1.7-trunk/pylith/faults/FaultCohesiveImpulses.py
short/3D/PyLith/branches/v1.7-trunk/pylith/meshio/OutputFaultImpulses.py
Modified:
short/3D/PyLith/branches/v1.7-trunk/modulesrc/faults/Makefile.am
short/3D/PyLith/branches/v1.7-trunk/pylith/Makefile.am
Log:
Added SWIG and Python stuff for FaultCohesiveImpulses.
Added: short/3D/PyLith/branches/v1.7-trunk/modulesrc/faults/FaultCohesiveImpulses.i
===================================================================
--- short/3D/PyLith/branches/v1.7-trunk/modulesrc/faults/FaultCohesiveImpulses.i (rev 0)
+++ short/3D/PyLith/branches/v1.7-trunk/modulesrc/faults/FaultCohesiveImpulses.i 2012-05-03 00:10:31 UTC (rev 20026)
@@ -0,0 +1,117 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard, U.S. Geological Survey
+// Charles A. Williams, GNS Science
+// Matthew G. Knepley, University of Chicago
+//
+// This code was developed as part of the Computational Infrastructure
+// for Geodynamics (http://geodynamics.org).
+//
+// Copyright (c) 2010-2012 University of California, Davis
+//
+// See COPYING for license information.
+//
+// ----------------------------------------------------------------------
+//
+
+/** @file modulesrc/faults/FaultCohesiveImpulses.i
+ *
+ * @brief Python interface to C++ FaultCohesiveImpulses object.
+ */
+
+namespace pylith {
+ namespace faults {
+
+ class FaultCohesiveImpulses : public FaultCohesiveLagrange
+ { // class FaultCohesiveImpulses
+
+ // PUBLIC METHODS /////////////////////////////////////////////////
+ public :
+
+ /// Default constructor.
+ FaultCohesiveImpulses(void);
+
+ /// Destructor.
+ ~FaultCohesiveImpulses(void);
+
+ /// Deallocate PETSc and local data structures.
+ void deallocate(void);
+
+ /** Sets the spatial database for amplitudes of the impulses.
+ *
+ * @param db spatial database for amplitudes of impulses.
+ */
+ void dbImpulseAmp(spatialdata::spatialdb::SpatialDB* db);
+
+ /** Set indices of fault degrees of freedom associated with
+ * impulses.
+ *
+ * @param flags Array of indices for degrees of freedom.
+ * @param size Size of array
+ */
+ void impulseDOF(const int* flags,
+ const int size);
+
+ /** Set threshold for nonzero impulse amplitude.
+ *
+ * @param value Threshold for detecting nonzero amplitude.
+ */
+ void threshold(const double value);
+
+ /** Get number of impulses.
+ *
+ * Multiply by number of components to get total number of impulses.
+ *
+ * @returns Number of points with impulses.
+ */
+ int numImpulses(void) const;
+
+ /** Get number of components for impulses at each point.
+ *
+ * Multiply by number of components to get total number of impulses.
+ *
+ * @returns Number of points with impulses.
+ */
+ int numComponents(void) const;
+
+ /** Initialize fault. Determine orientation and setup boundary
+ * condition parameters.
+ *
+ * @param mesh Finite-element mesh.
+ * @param upDir Direction perpendicular to along-strike direction that is
+ * not collinear with fault normal (usually "up" direction but could
+ * be up-dip direction; applies to fault surfaces in 2-D and 3-D).
+ */
+ void initialize(const pylith::topology::Mesh& mesh,
+ const PylithScalar upDir[3]);
+
+ /** Integrate contributions to residual term (r) for operator that
+ * do not require assembly across cells, vertices, or processors.
+ *
+ * @param residual Field containing values for residual
+ * @param t Current time
+ * @param fields Solution fields
+ */
+ void integrateResidual(const pylith::topology::Field<pylith::topology::Mesh>& residual,
+ const PylithScalar t,
+ pylith::topology::SolutionFields* const fields);
+
+ /** Get vertex field associated with integrator.
+ *
+ * @param name Name of cell field.
+ * @param fields Solution fields.
+ * @returns Vertex field.
+ */
+ const pylith::topology::Field<pylith::topology::SubMesh>&
+ vertexField(const char* name,
+ const pylith::topology::SolutionFields* fields =0);
+
+ }; // class FaultCohesiveImpulses
+
+ } // faults
+} // pylith
+
+
+// End of file
Modified: short/3D/PyLith/branches/v1.7-trunk/modulesrc/faults/Makefile.am
===================================================================
--- short/3D/PyLith/branches/v1.7-trunk/modulesrc/faults/Makefile.am 2012-05-02 23:32:42 UTC (rev 20025)
+++ short/3D/PyLith/branches/v1.7-trunk/modulesrc/faults/Makefile.am 2012-05-03 00:10:31 UTC (rev 20026)
@@ -37,6 +37,7 @@
FaultCohesiveLagrange.i \
FaultCohesiveKin.i \
FaultCohesiveDyn.i \
+ FaultCohesiveImpulses.i \
FaultCohesiveTract.i \
../topology/SubMesh.i \
../feassemble/Quadrature.i \
Modified: short/3D/PyLith/branches/v1.7-trunk/pylith/Makefile.am
===================================================================
--- short/3D/PyLith/branches/v1.7-trunk/pylith/Makefile.am 2012-05-02 23:32:42 UTC (rev 20025)
+++ short/3D/PyLith/branches/v1.7-trunk/pylith/Makefile.am 2012-05-03 00:10:31 UTC (rev 20026)
@@ -40,6 +40,7 @@
faults/FaultCohesive.py \
faults/FaultCohesiveKin.py \
faults/FaultCohesiveDyn.py \
+ faults/FaultCohesiveImpulses.py \
faults/FaultCohesiveTract.py \
faults/LiuCosSlipFn.py \
faults/SingleRupture.py \
@@ -108,6 +109,7 @@
meshio/OutputSoln.py \
meshio/OutputFaultKin.py \
meshio/OutputFaultDyn.py \
+ meshio/OutputFaultImpulses.py \
meshio/OutputMatElastic.py \
meshio/OutputNeumann.py \
meshio/OutputSolnSubset.py \
Added: short/3D/PyLith/branches/v1.7-trunk/pylith/faults/FaultCohesiveImpulses.py
===================================================================
--- short/3D/PyLith/branches/v1.7-trunk/pylith/faults/FaultCohesiveImpulses.py (rev 0)
+++ short/3D/PyLith/branches/v1.7-trunk/pylith/faults/FaultCohesiveImpulses.py 2012-05-03 00:10:31 UTC (rev 20026)
@@ -0,0 +1,238 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard, U.S. Geological Survey
+# Charles A. Williams, GNS Science
+# Matthew G. Knepley, University of Chicago
+#
+# This code was developed as part of the Computational Infrastructure
+# for Geodynamics (http://geodynamics.org).
+#
+# Copyright (c) 2010-2012 University of California, Davis
+#
+# See COPYING for license information.
+#
+# ----------------------------------------------------------------------
+#
+
+## @file pylith/faults/FaultCohesiveImpulses.py
+##
+
+## @brief Python object for a fault surface with slip impulses for
+## Green's function implemented with cohesive elements.
+##
+## Factory: fault
+
+from FaultCohesive import FaultCohesive
+from pylith.feassemble.Integrator import Integrator
+from faults import FaultCohesiveImpulses as ModuleFaultCohesiveImpulses
+
+def validateDOF(value):
+ """
+ Validate list of fixed degrees of freedom.
+ """
+ try:
+ size = len(value)
+ num = map(int, value)
+ for v in num:
+ if v < 0:
+ raise ValueError
+ except:
+ raise ValueError, \
+ "'impuluse_dof' must be a zero based list of indices of degrees of " \
+ "freedom at a vertex."
+ return num
+
+
+# FaultCohesiveImpulses class
+class FaultCohesiveImpulses(FaultCohesive, Integrator, ModuleFaultCohesiveImpulses):
+ """
+ Python object for a fault surface with slip impulses for Green's
+ functions implemented with cohesive elements.
+
+ Inventory
+
+ @class Inventory
+ Python object for managing FaultCohesiveImpulses facilities and properties.
+
+ \b Properties
+ @li \b threshold Threshold for non-zero amplitude.
+ @li \b impulse_dof Indices of slip components for impulses.
+
+ \b Facilities
+ @li \b db_impulse_amplitude Amplitude of slip impulses.
+ @li \b output Output manager associated with fault data.
+
+ Factory: fault
+ """
+
+ # INVENTORY //////////////////////////////////////////////////////////
+
+ import pyre.inventory
+ from pyre.units.length import m
+
+ threshold = pyre.inventory.dimensional("threshold", default=1.0e-6*m)
+
+ impulseDOF = pyre.inventory.list("impulse_dof", default=[], validator=validateDOF)
+ impulseDOF.meta['tip'] = "Indices of impulse components " \
+ "(0=1st DOF, 1=2nd DOF, etc)."
+
+ from pylith.meshio.OutputFaultKin import OutputFaultImpulses
+ output = pyre.inventory.facility("output", family="output_manager",
+ factory=OutputFaultImpulses)
+ output.meta['tip'] = "Output manager associated with fault data."
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self, name="faultcohesiveimpulses"):
+ """
+ Initialize configuration.
+ """
+ FaultCohesive.__init__(self, name)
+ Integrator.__init__(self)
+ self._loggingPrefix = "CoIm "
+
+ self.availableFields = \
+ {'vertex': \
+ {'info': ["normal_dir",
+ "impulse_amplitude"],
+ 'data': ["slip",
+ "traction_change"]},
+ 'cell': \
+ {'info': ["partition"],
+ 'data': []}}
+ return
+
+
+ def preinitialize(self, mesh):
+ """
+ Do pre-initialization setup.
+ """
+ from pylith.mpi.Communicator import mpi_comm_world
+ comm = mpi_comm_world()
+
+ if 0 == comm.rank:
+ self._info.log("Pre-initializing fault '%s'." % self.label())
+ FaultCohesive.preinitialize(self, mesh)
+ Integrator.preinitialize(self, mesh)
+
+ ModuleFaultCohesiveImpulses.quadrature(self, self.faultQuadrature)
+
+ if mesh.dimension() == 2:
+ self.availableFields['vertex']['info'] += ["strike_dir"]
+ elif mesh.dimension() == 3:
+ self.availableFields['vertex']['info'] += ["strike_dir",
+ "dip_dir"]
+ return
+
+
+ def verifyConfiguration(self):
+ """
+ Verify compatibility of configuration.
+ """
+ logEvent = "%sverify" % self._loggingPrefix
+ self._eventLogger.eventBegin(logEvent)
+
+ FaultCohesive.verifyConfiguration(self)
+ Integrator.verifyConfiguration(self)
+ ModuleFaultCohesiveImpulses.verifyConfiguration(self, self.mesh)
+
+ self._eventLogger.eventEnd(logEvent)
+ return
+
+
+ def initialize(self, totalTime, numTimeSteps, normalizer):
+ """
+ Initialize cohesive elements.
+ """
+ logEvent = "%sinit" % self._loggingPrefix
+ self._eventLogger.eventBegin(logEvent)
+
+ from pylith.mpi.Communicator import mpi_comm_world
+ comm = mpi_comm_world()
+
+ if 0 == comm.rank:
+ self._info.log("Initializing fault '%s'." % self.label())
+
+ Integrator.initialize(self, totalTime, numTimeSteps, normalizer)
+ FaultCohesive.initialize(self, totalTime, numTimeSteps, normalizer)
+
+ self._eventLogger.eventEnd(logEvent)
+ return
+
+
+ def getVertexField(self, name, fields=None):
+ """
+ Get vertex field.
+ """
+ if None == fields:
+ field = ModuleFaultCohesiveImpulses.vertexField(self, name)
+ else:
+ field = ModuleFaultCohesiveImpulses.vertexField(self, name, fields)
+ return field
+
+
+ def getCellField(self, name, fields=None):
+ """
+ Get cell field.
+ """
+ if None == fields:
+ field = ModuleFaultCohesiveImpulses.cellField(self, name)
+ else:
+ field = ModuleFaultCohesiveImpulses.cellField(self, name, fields)
+ return field
+
+
+ def finalize(self):
+ """
+ Cleanup.
+ """
+ FaultCohesive.finalize(self)
+ Integrator.finalize(self)
+ self.output.close()
+ self.output.finalize()
+ return
+
+
+ # PRIVATE METHODS ////////////////////////////////////////////////////
+
+ def _configure(self):
+ """
+ Setup members using inventory.
+ """
+ FaultCohesive._configure(self)
+ self.output = self.inventory.output
+
+ ModuleFaultCohesiveImpulses.threshold(self, self.inventory.threshold)
+ ModuleFaultCohesiveImpulses.impulseDOF(self, self.inventory.impulseDOF)
+ return
+
+
+ def _createModuleObj(self):
+ """
+ Create handle to C++ FaultCohesiveImpulses.
+ """
+ ModuleFaultCohesiveImpulses.__init__(self)
+ return
+
+
+ def _modelMemoryUse(self):
+ """
+ Model memory allocation.
+ """
+ self.perfLogger.logFault("Fault", self)
+ self.perfLogger.logFields("Fault", self.fields())
+ return
+
+
+# FACTORIES ////////////////////////////////////////////////////////////
+
+def fault():
+ """
+ Factory associated with FaultCohesiveImpulses.
+ """
+ return FaultCohesiveImpulses()
+
+
+# End of file
Added: short/3D/PyLith/branches/v1.7-trunk/pylith/meshio/OutputFaultImpulses.py
===================================================================
--- short/3D/PyLith/branches/v1.7-trunk/pylith/meshio/OutputFaultImpulses.py (rev 0)
+++ short/3D/PyLith/branches/v1.7-trunk/pylith/meshio/OutputFaultImpulses.py 2012-05-03 00:10:31 UTC (rev 20026)
@@ -0,0 +1,99 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard, U.S. Geological Survey
+# Charles A. Williams, GNS Science
+# Matthew G. Knepley, University of Chicago
+#
+# This code was developed as part of the Computational Infrastructure
+# for Geodynamics (http://geodynamics.org).
+#
+# Copyright (c) 2010-2012 University of California, Davis
+#
+# See COPYING for license information.
+#
+# ----------------------------------------------------------------------
+#
+
+## @file pyre/meshio/OutputFaultImpulses.py
+##
+## @brief Python object for managing output of finite-element
+## information for faults with Green's function slip impulses.
+##
+## Factory: output_manager
+
+from OutputManagerSubMesh import OutputManagerSubMesh
+
+# OutputFaultImpulses class
+class OutputFaultImpulses(OutputManagerSubMesh):
+ """
+ Python object for managing output of finite-element information for
+ faults with Green's function slip impulses.
+
+ Inventory
+
+ @class Inventory
+ Python object for managing OutputFaultImpulses facilities and properties.
+
+ \b Properties
+ @li \b vertex_info_fields Names of vertex info fields to output.
+ @li \b vertex_data_fields Names of vertex data fields to output.
+
+ \b Facilities
+ @li None
+
+ Factory: output_manager
+ """
+
+ # INVENTORY //////////////////////////////////////////////////////////
+
+ import pyre.inventory
+
+ vertexInfoFields = pyre.inventory.list("vertex_info_fields",
+ default=["normal_dir",
+ "impulse_amplitude"])
+ vertexInfoFields.meta['tip'] = "Names of vertex info fields to output."
+
+ vertexDataFields = pyre.inventory.list("vertex_data_fields",
+ default=["slip",
+ "traction_change"])
+ vertexDataFields.meta['tip'] = "Names of vertex data fields to output."
+
+ cellInfoFields = pyre.inventory.list("cell_info_fields", default=[])
+ cellInfoFields.meta['tip'] = "Names of cell info fields to output."
+
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self, name="outputfaultimpulses"):
+ """
+ Constructor.
+ """
+ OutputManagerSubMesh.__init__(self, name)
+ return
+
+
+ # PRIVATE METHODS ////////////////////////////////////////////////////
+
+ def _configure(self):
+ """
+ Set members based using inventory.
+ """
+ OutputManagerSubMesh._configure(self)
+ self.vertexInfoFields = self.inventory.vertexInfoFields
+ self.vertexDataFields = self.inventory.vertexDataFields
+ self.cellInfoFields = self.inventory.cellInfoFields
+ return
+
+
+# FACTORIES ////////////////////////////////////////////////////////////
+
+def output_manager():
+ """
+ Factory associated with OutputManager.
+ """
+ return OutputFaultImpulses()
+
+
+# End of file
More information about the CIG-COMMITS
mailing list