[cig-commits] r6840 - in short/3D/PyLith/trunk/pylith: . bc problems

brad at geodynamics.org brad at geodynamics.org
Thu May 10 12:00:15 PDT 2007


Author: brad
Date: 2007-05-10 12:00:15 -0700 (Thu, 10 May 2007)
New Revision: 6840

Added:
   short/3D/PyLith/trunk/pylith/bc/
   short/3D/PyLith/trunk/pylith/bc/BCIntegrator.py
   short/3D/PyLith/trunk/pylith/bc/BoundaryCondition.py
   short/3D/PyLith/trunk/pylith/bc/Dirichlet.py
   short/3D/PyLith/trunk/pylith/bc/__init__.py
   short/3D/PyLith/trunk/pylith/problems/BCPrism.py
   short/3D/PyLith/trunk/pylith/problems/BCQuadrilateral.py
   short/3D/PyLith/trunk/pylith/problems/BoundaryConditions.py
Log:
Started laying out code for boundary conditions.

Added: short/3D/PyLith/trunk/pylith/bc/BCIntegrator.py
===================================================================
--- short/3D/PyLith/trunk/pylith/bc/BCIntegrator.py	2007-05-10 17:32:56 UTC (rev 6839)
+++ short/3D/PyLith/trunk/pylith/bc/BCIntegrator.py	2007-05-10 19:00:15 UTC (rev 6840)
@@ -0,0 +1,87 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+#                           Brad T. Aagaard
+#                        U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file pylith/bc/BCIntegrator.py
+##
+## @brief Python abstract base class for managing a boundary condition
+## that requires integration.
+##
+## This implementation of a boundary condition applies to a single
+## face of an domain and associates both a quadrature scheme with a
+## physical boundary condition. Thus, applying different quadrature
+## schemes along a face with the same physical boundary condition
+## requires two "bc", which can use the same database.
+##
+## Factory: boundary_condition
+
+from BoundaryCondition import BoundaryCondition
+
+# BCIntegrator class
+class BCIntegrator(BoundaryCondition):
+  """
+  Python abstract base class for managing a boundary condition that
+  requires integration.
+
+  This implementation of a boundary condition applies to a single
+  face of an domain and associates both a quadrature scheme with a
+  physical boundary condition. Thus, applying different quadrature
+  schemes along a face with the same physical boundary condition
+  requires two 'bc', which can use the same database.
+
+  Factory: boundary_condition
+  """
+
+  # INVENTORY //////////////////////////////////////////////////////////
+
+  class Inventory(BoundaryCondition.Inventory):
+    """
+    Python object for managing BCIntegrator facilities and properties.
+    """
+    
+    ## @class Inventory
+    ## Python object for managing BCIntegrator facilities and properties.
+    ##
+    ## \b Properties
+    ## @li None
+    ##
+    ## \b Facilities
+    ## @li \b quadrature Quadrature object for numerical integration
+
+    import pyre.inventory
+
+    from pylith.feassemble.quadrature.Quadrature import Quadrature
+    quadrature = pyre.inventory.facility("quadrature", factory=Quadrature)
+    quadrature.meta['tip'] = "Quadrature object for numerical integration."
+
+
+  # PUBLIC METHODS /////////////////////////////////////////////////////
+
+  def __init__(self, name="bcintegrator"):
+    """
+    Constructor.
+    """
+    BoundaryCondition.__init__(self, name)
+    return
+
+
+  # PRIVATE METHODS ////////////////////////////////////////////////////
+
+  def _configure(self):
+    """
+    Setup members using inventory.
+    """
+    BoundaryCondition._configure(self)
+    self.quadrature = self.inventory.quadrature
+    return
+
+  
+# End of file 

Added: short/3D/PyLith/trunk/pylith/bc/BoundaryCondition.py
===================================================================
--- short/3D/PyLith/trunk/pylith/bc/BoundaryCondition.py	2007-05-10 17:32:56 UTC (rev 6839)
+++ short/3D/PyLith/trunk/pylith/bc/BoundaryCondition.py	2007-05-10 19:00:15 UTC (rev 6840)
@@ -0,0 +1,121 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+#                           Brad T. Aagaard
+#                        U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file pylith/bc/BoundaryCondition.py
+##
+## @brief Python abstract base class for managing a boundary condition.
+##
+## This implementation of a boundary condition applies to a single
+## face of an domain and associates both a quadrature scheme with a
+## physical boundary condition. Thus, applying different quadrature
+## schemes along a face with the same physical boundary condition
+## requires two "bc", which can use the same database.
+##
+## Factory: boundary_condition
+
+from pyre.components.Component import Component
+
+# BoundaryCondition class
+class BoundaryCondition(Component):
+  """
+  Python abstract base class for managing a boundary condition.
+
+  This implementation of a boundary condition applies to a single
+  face of an domain.
+
+  Factory: boundary_condition
+  """
+
+  # INVENTORY //////////////////////////////////////////////////////////
+
+  class Inventory(Component.Inventory):
+    """
+    Python object for managing BoundaryCondition facilities and properties.
+    """
+    
+    ## @class Inventory
+    ## Python object for managing BoundaryCondition facilities and properties.
+    ##
+    ## \b Properties
+    ## @li \b id Object face identifier (from mesh generator)
+    ## @li \b name Name identifier for object face
+    ##
+    ## \b Facilities
+    ## @li \b db Database of boundary condition parameters
+
+    import pyre.inventory
+
+    id = pyre.inventory.int("id", default=0)
+    id.meta['tip'] = "Object face identifier (from mesh generator)."
+
+    label = pyre.inventory.str("label", default="")
+    label.meta['tip'] = "Name identifier for object face."
+
+    from spatialdata.spatialdb.SimpleDB import SimpleDB
+    db = pyre.inventory.facility("db", factory=SimpleDB,
+                                 args=["db"])
+    db.meta['tip'] = "Database of boundary condition parameters."
+    
+
+  # PUBLIC METHODS /////////////////////////////////////////////////////
+
+  def __init__(self, name="boundarycondition"):
+    """
+    Constructor.
+    """
+    Component.__init__(self, name, facility="boundary_condition")
+    self.cppHandle = None
+    return
+
+
+  def initialize(self, mesh):
+    """
+    Initialize boundary condition.
+    """
+    return
+
+
+  def integrateJacobian(self, jacobian, field):
+    """
+    Integrate contribution to Jacobian.
+    """
+    return
+
+
+  def integrateResidual(self, residual, fieldT, fieldTmdt):
+    """
+    Integrate contribution to residual.
+    """
+    return
+
+
+  def setField(self, field, t):
+    """
+    Set solution field at time t.
+    """
+    return
+  
+
+  # PRIVATE METHODS ////////////////////////////////////////////////////
+
+  def _configure(self):
+    """
+    Setup members using inventory.
+    """
+    Component._configure(self)
+    self.id = self.inventory.id
+    self.label = self.inventory.label
+    self.db = self.inventory.db
+    return
+
+  
+# End of file 

Added: short/3D/PyLith/trunk/pylith/bc/Dirichlet.py
===================================================================
--- short/3D/PyLith/trunk/pylith/bc/Dirichlet.py	2007-05-10 17:32:56 UTC (rev 6839)
+++ short/3D/PyLith/trunk/pylith/bc/Dirichlet.py	2007-05-10 19:00:15 UTC (rev 6840)
@@ -0,0 +1,67 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+#                           Brad T. Aagaard
+#                        U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file pylith/bc/Dirichlet.py
+##
+## @brief Python object for managing a Dirichlet (prescribed
+## displacements) boundary condition.
+##
+## Factory: boundary_condition
+
+from BoundaryCondition import BoundaryCondition
+
+# Dirichlet class
+class Dirichlet(BoundaryCondition):
+  """
+  Python object for managing a Dirichlet (prescribed displacements)
+  boundary condition.
+
+  Factory: boundary_condition
+  """
+
+  # PUBLIC METHODS /////////////////////////////////////////////////////
+
+  def __init__(self, name="dirichlet"):
+    """
+    Constructor.
+    """
+    BoundaryCondition.__init__(self, name)
+    #import pylith.bc.bc as bindings
+    #self.cppHandle = bindings.Dirichlet()
+    return
+
+
+  def initialize(self, mesh):
+    """
+    Initialize Dirichlet boundary condition.
+    """
+    return
+  
+
+  def setField(self, field, t):
+    """
+    Set solution field at time t.
+    """
+    return
+  
+
+  # PRIVATE METHODS ////////////////////////////////////////////////////
+
+  def _configure(self):
+    """
+    Setup members using inventory.
+    """
+    BoundaryCondition._configure(self)
+    return
+
+  
+# End of file 

Added: short/3D/PyLith/trunk/pylith/bc/__init__.py
===================================================================
--- short/3D/PyLith/trunk/pylith/bc/__init__.py	2007-05-10 17:32:56 UTC (rev 6839)
+++ short/3D/PyLith/trunk/pylith/bc/__init__.py	2007-05-10 19:00:15 UTC (rev 6840)
@@ -0,0 +1,22 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+#                           Brad T. Aagaard
+#                        U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file pylith/bc/__init__.py
+##
+## @brief Python PyLith boundary condition module initialization
+
+__all__ = ['BoundaryCondition',
+           'BCIntegrator',
+           'Dirichlet']
+
+
+# End of file

Added: short/3D/PyLith/trunk/pylith/problems/BCPrism.py
===================================================================
--- short/3D/PyLith/trunk/pylith/problems/BCPrism.py	2007-05-10 17:32:56 UTC (rev 6839)
+++ short/3D/PyLith/trunk/pylith/problems/BCPrism.py	2007-05-10 19:00:15 UTC (rev 6840)
@@ -0,0 +1,119 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+#                           Brad T. Aagaard
+#                        U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file pylith/problems/BCPrism.py
+##
+## @brief Python boundary conditions container for a 3-D prism.
+##
+## Boundary conditions can be applied to any of the six faces.
+##
+## Factory: boundary_conditions
+
+from BoundaryConditions import BoundaryConditions
+
+# BCPrism class
+class BCPrism(BoundaryConditions):
+  """
+  Python boundary conditions container for a 3-D prism.
+
+  Boundary conditions can be applied to any of the six faces.
+
+  Factory: boundary_conditions
+  """
+
+  # INVENTORY //////////////////////////////////////////////////////////
+
+  class Inventory(BoundaryConditions.Inventory):
+    """
+    Python object for managing BCPrism facilities and properties.
+    """
+    
+    ## @class Inventory
+    ## Python object for managing BCPrism facilities and properties.
+    ##
+    ## \b Properties
+    ## @li None
+    ##
+    ## \b Facilities
+    ## @li \b x_pos Boundary condition on +x face of prism.
+    ## @li \b x_neg Boundary condition on -x face of prism.
+    ## @li \b y_pos Boundary condition on +y face of prism.
+    ## @li \b y_neg Boundary condition on -y face of prism.
+    ## @li \b z_pos Boundary condition on +z face of prism.
+    ## @li \b z_neg Boundary condition on -z face of prism.
+
+    import pyre.inventory
+    
+    from pylith.bc.Dirichlet import Dirichlet
+    from pylith.bc.BoundaryCondition import BoundaryCondition
+
+    xPos = pyre.inventory.facility("x_pos", family="boundary_condition",
+                                   factory=Dirichlet)
+    xPos.meta['tip'] = "Boundary condition on +x face of prism."
+
+    xNeg = pyre.inventory.facility("x_neg", family="boundary_condition",
+                                   factory=Dirichlet)
+    xNeg.meta['tip'] = "Boundary condition on -x face of prism."
+
+    yPos = pyre.inventory.facility("y_pos", family="boundary_condition",
+                                   factory=Dirichlet)
+    yPos.meta['tip'] = "Boundary condition on +y face of prism."
+
+    yNeg = pyre.inventory.facility("y_neg", family="boundary_condition",
+                                   factory=Dirichlet)
+    yNeg.meta['tip'] = "Boundary condition on -y face of prism."
+
+    zPos = pyre.inventory.facility("z_pos", family="boundary_condition",
+                                   factory=BoundaryCondition)
+    zPos.meta['tip'] = "Boundary condition on +z face of prism."
+
+    zNeg = pyre.inventory.facility("z_neg", family="boundary_condition",
+                                   factory=Dirichlet)
+    zNeg.meta['tip'] = "Boundary condition on -z face of prism."
+
+
+  # PUBLIC METHODS /////////////////////////////////////////////////////
+
+  def __init__(self, name="bcprism"):
+    """
+    Constructor.
+    """
+    BoundaryConditions.__init__(self, name)
+    return
+
+
+  # PRIVATE METHODS ////////////////////////////////////////////////////
+
+  def _configure(self):
+    """
+    Set attributes from inventory.
+    """
+    BoundaryConditions._configure(self)
+    self.bc = [self.inventory.xPos,
+               self.inventory.xNeg,
+               self.inventory.yPos,
+               self.inventory.yNeg,
+               self.inventory.zPos,
+               self.inventory.zNeg]
+    return
+
+  
+# FACTORIES ////////////////////////////////////////////////////////////
+
+def boundary_conditions():
+  """
+  Factory associated with BCPrism.
+  """
+  return BCPrism()
+
+
+# End of file 

Added: short/3D/PyLith/trunk/pylith/problems/BCQuadrilateral.py
===================================================================
--- short/3D/PyLith/trunk/pylith/problems/BCQuadrilateral.py	2007-05-10 17:32:56 UTC (rev 6839)
+++ short/3D/PyLith/trunk/pylith/problems/BCQuadrilateral.py	2007-05-10 19:00:15 UTC (rev 6840)
@@ -0,0 +1,107 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+#                           Brad T. Aagaard
+#                        U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file pylith/problems/BCQuadrilateral.py
+##
+## @brief Python boundary conditions container for a 2-D quadrilateral.
+##
+## Boundary conditions can be applied to any of the four edges.
+##
+## Factory: boundary_conditions
+
+from BoundaryConditions import BoundaryConditions
+
+# BCQuadrilateral class
+class BCQuadrilateral(BoundaryConditions):
+  """
+  Python boundary conditions container for a 2-D quadrilateral.
+
+  Boundary conditions can be applied to any of the four edges.
+
+  Factory: boundary_conditions
+  """
+
+  # INVENTORY //////////////////////////////////////////////////////////
+
+  class Inventory(BoundaryConditions.Inventory):
+    """
+    Python object for managing BCQuadrilateral facilities and properties.
+    """
+    
+    ## @class Inventory
+    ## Python object for managing BCQuadrilateral facilities and properties.
+    ##
+    ## \b Properties
+    ## @li None
+    ##
+    ## \b Facilities
+    ## @li \b x_pos Boundary condition on +x face of prism.
+    ## @li \b x_neg Boundary condition on -x face of prism.
+    ## @li \b y_pos Boundary condition on +y face of prism.
+    ## @li \b y_neg Boundary condition on -y face of prism.
+
+    import pyre.inventory
+    
+    from pylith.bc.Dirichlet import Dirichlet
+    from pylith.bc.BoundaryCondition import BoundaryCondition
+
+    xPos = pyre.inventory.facility("x_pos", family="boundary_condition",
+                                   factory=Dirichlet)
+    xPos.meta['tip'] = "Boundary condition on +x face of prism."
+
+    xNeg = pyre.inventory.facility("x_neg", family="boundary_condition",
+                                   factory=Dirichlet)
+    xNeg.meta['tip'] = "Boundary condition on -x face of prism."
+
+    yPos = pyre.inventory.facility("y_pos", family="boundary_condition",
+                                   factory=BoundaryCondition)
+    yPos.meta['tip'] = "Boundary condition on +y face of prism."
+
+    yNeg = pyre.inventory.facility("y_neg", family="boundary_condition",
+                                   factory=Dirichlet)
+    yNeg.meta['tip'] = "Boundary condition on -y face of prism."
+
+
+  # PUBLIC METHODS /////////////////////////////////////////////////////
+
+  def __init__(self, name="bcquadrilateral"):
+    """
+    Constructor.
+    """
+    BoundaryConditions.__init__(self, name)
+    return
+
+
+  # PRIVATE METHODS ////////////////////////////////////////////////////
+
+  def _configure(self):
+    """
+    Set attributes from inventory.
+    """
+    BoundaryConditions._configure(self)
+    self.bc = [self.inventory.xPos,
+               self.inventory.xNeg,
+               self.inventory.yPos,
+               self.inventory.yNeg]
+    return
+
+  
+# FACTORIES ////////////////////////////////////////////////////////////
+
+def boundary_conditions():
+  """
+  Factory associated with BCQuadrilateral.
+  """
+  return BCQuadrilateral()
+
+
+# End of file 

Added: short/3D/PyLith/trunk/pylith/problems/BoundaryConditions.py
===================================================================
--- short/3D/PyLith/trunk/pylith/problems/BoundaryConditions.py	2007-05-10 17:32:56 UTC (rev 6839)
+++ short/3D/PyLith/trunk/pylith/problems/BoundaryConditions.py	2007-05-10 19:00:15 UTC (rev 6840)
@@ -0,0 +1,40 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+#                           Brad T. Aagaard
+#                        U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file pylith/problem/BoundaryConditions.py
+##
+## @brief Python container for boundary conditions.
+##
+## Factory: boundary_conditions
+
+from pyre.components.Component import Component
+
+# BoundaryConditions class
+class BoundaryConditions(Component):
+  """
+  Python container for boundary conditions.
+
+  Factory: boundary_conditions
+  """
+
+  # PUBLIC METHODS /////////////////////////////////////////////////////
+
+  def __init__(self, name="boundaryconditions"):
+    """
+    Constructor.
+    """
+    Component.__init__(self, name, facility="boundary_conditions")
+    self.bc = []
+    return
+
+
+# End of file 



More information about the cig-commits mailing list