Exemplo n.º 1
0
    def setUp(self):
        """
    Setup for test.
    """
        TestTri3.setUp(self)
        self.nverticesO = self.mesh['nvertices']

        # Fault x
        self.mesh['nvertices'] += 9
        self.faultMeshX = {
            'nvertices': 9,
            'spaceDim': 2,
            'ncells': 8,
            'ncorners': 2
        }
        # Fault y
        self.mesh['nvertices'] += 1
        self.faultMeshY = {
            'nvertices': 3,
            'spaceDim': 2,
            'ncells': 2,
            'ncorners': 2
        }

        run_pylith(FaultsIntersectApp)
        self.outputRoot = "faultsintersect"

        self.soln = AnalyticalSoln()
        return
Exemplo n.º 2
0
  def setUp(self):
    """
    Setup for test.
    """
    TestHex8.setUp(self)
    self.nverticesO = self.mesh['nvertices']

    # Fault x
    self.mesh['nvertices'] += 55
    self.faultMeshX = {'nvertices': 55,
                       'spaceDim': 3,
                       'ncells': 40,
                       'ncorners': 4}

    # Fault y
    self.mesh['nvertices'] += 4
    self.faultMeshY = {'nvertices': 12,
                       'spaceDim': 3,
                       'ncells': 6,
                       'ncorners': 4}

    run_pylith(FaultsIntersectApp)
    self.outputRoot = "faultsintersect"

    self.soln = AnalyticalSoln()
    return
Exemplo n.º 3
0
  def setUp(self):
    """
    Setup for test.
    """
    TestHex8.setUp(self)
    self.nverticesO = self.mesh['nvertices']

    # Fault x
    self.mesh['nvertices'] += 55
    self.faultMeshX = {'nvertices': 55,
                       'spaceDim': 3,
                       'ncells': 40,
                       'ncorners': 4}

    # Fault y
    self.mesh['nvertices'] += 4
    self.faultMeshY = {'nvertices': 12,
                       'spaceDim': 3,
                       'ncells': 6,
                       'ncorners': 4}

    run_pylith()
    self.outputRoot = "faultsintersect"

    self.soln = AnalyticalSoln()
    return
Exemplo n.º 4
0
  def setUp(self):
    """
    Setup for test.
    """
    TestTet4.setUp(self)
    self.nverticesO = self.mesh['nvertices']

    # Fault x
    self.mesh['nvertices'] += 50
    self.faultMeshX = {'nvertices': 50,
                       'spaceDim': 3,
                       'ncells': 72,
                       'ncorners': 3}

    # Fault y
    self.mesh['nvertices'] += 2
    self.faultMeshY = {'nvertices': 9,
                       'spaceDim': 3,
                       'ncells': 8,
                       'ncorners': 3}
    run_pylith(FaultsIntersectApp)
    self.outputRoot = "faultsintersect"

    self.soln = AnalyticalSoln()
    return
Exemplo n.º 5
0
  def setUp(self):
    """
    Setup for test.
    """
    TestTri3.setUp(self)
    self.nverticesO = self.mesh['nvertices']

    # Fault x
    self.mesh['nvertices'] += 9
    self.faultMeshX = {'nvertices': 9,
                      'spaceDim': 2,
                      'ncells': 8,
                      'ncorners': 2}
    # Fault y
    self.mesh['nvertices'] += 1
    self.faultMeshY = {'nvertices': 3,
                      'spaceDim': 2,
                      'ncells': 2,
                      'ncorners': 2}

    run_pylith()
    self.outputRoot = "faultsintersect"

    self.soln = AnalyticalSoln()
    return
Exemplo n.º 6
0
  def setUp(self):
    """
    Setup for test.
    """
    TestTet4.setUp(self)
    self.nverticesO = self.mesh['nvertices']
    self.mesh['nvertices'] += 50
    self.faultMesh = {'nvertices': 50,
                      'spaceDim': 3,
                      'ncells': 72,
                      'ncorners': 3}
    run_pylith(SlipOneFaultApp)
    self.outputRoot = "sliponefault"

    self.soln = AnalyticalSoln()
    return
Exemplo n.º 7
0
  def setUp(self):
    """
    Setup for test.
    """
    TestTri3.setUp(self)
    self.nverticesO = self.mesh['nvertices']
    self.mesh['nvertices'] += 9
    self.faultMesh = {'nvertices': 9,
                      'spaceDim': 2,
                      'ncells': 8,
                      'ncorners': 2}
    run_pylith()
    self.outputRoot = "sliponefault"

    self.soln = AnalyticalSoln()
    return
Exemplo n.º 8
0
  def setUp(self):
    """
    Setup for test.
    """
    TestHex8.setUp(self)
    self.nverticesO = self.mesh['nvertices']
    self.mesh['nvertices'] += 55
    self.faultMesh = {'nvertices': 55,
                      'spaceDim': 3,
                      'ncells': 40,
                      'ncorners': 4}
    run_pylith()
    self.outputRoot = "sliponefault"

    self.soln = AnalyticalSoln()
    return
Exemplo n.º 9
0
class TestFaultsIntersect(TestTri3):
    """
  Test suite for testing pylith with shear faultsintersect for 2-D box.
  """
    def setUp(self):
        """
    Setup for test.
    """
        TestTri3.setUp(self)
        self.nverticesO = self.mesh['nvertices']

        # Fault x
        self.mesh['nvertices'] += 9
        self.faultMeshX = {
            'nvertices': 9,
            'spaceDim': 2,
            'ncells': 8,
            'ncorners': 2
        }
        # Fault y
        self.mesh['nvertices'] += 1
        self.faultMeshY = {
            'nvertices': 3,
            'spaceDim': 2,
            'ncells': 2,
            'ncorners': 2
        }

        run_pylith(FaultsIntersectApp)
        self.outputRoot = "faultsintersect"

        self.soln = AnalyticalSoln()
        return

    def test_fault_info(self):
        """
    Check fault information.
    """
        if not self.checkResults:
            return

        from pylith.tests.Fault import check_vertex_fields
        fields = ["normal_dir", "final_slip", "slip_time"]

        self.fault = "x"
        filename = "%s-faultx_info.h5" % self.outputRoot
        check_vertex_fields(self, filename, self.faultMeshX, fields)

        self.fault = "y"
        filename = "%s-faulty_info.h5" % self.outputRoot
        check_vertex_fields(self, filename, self.faultMeshY, fields)

        return

    def test_fault_data(self):
        """
    Check fault information.
    """
        if not self.checkResults:
            return

        from pylith.tests.Fault import check_vertex_fields
        fields = ["slip"]

        filename = "%s-faultx.h5" % self.outputRoot
        self.fault = "x"
        check_vertex_fields(self, filename, self.faultMeshX, fields)

        filename = "%s-faulty.h5" % self.outputRoot
        self.fault = "y"
        check_vertex_fields(self, filename, self.faultMeshY, fields)

        return

    def calcDisplacements(self, vertices):
        """
    Calculate displacement field given coordinates of vertices.
    """
        return self.soln.displacement(vertices, self.nverticesO)

    def calcStateVar(self, name, vertices, cells):
        """
    Calculate state variable.
    """
        ncells = self.mesh['ncells']
        pts = numpy.zeros((ncells, 3), dtype=numpy.float64)
        if name == "total_strain":
            stateVar = self.soln.strain(pts)
        elif name == "stress" or name == "cauchy_stress":
            stateVar = self.soln.stress(pts)
        else:
            raise ValueError("Unknown state variable '%s'." % name)

        return stateVar

    def calcFaultField(self, name, vertices):
        """
    Calculate fault info.
    """

        if self.fault == "x":
            normalDir = (-1.0, 0.0)
            finalSlip = -2.0
            faultMesh = self.faultMeshX
        elif self.fault == "y":
            normalDir = (0.0, +1.0)
            finalSlip = 0.0
            faultMesh = self.faultMeshY
        slipTime = 0.0

        nvertices = faultMesh['nvertices']

        if name == "normal_dir":
            field = numpy.zeros((1, nvertices, 2), dtype=numpy.float64)
            field[0, :, 0] = normalDir[0]
            field[0, :, 1] = normalDir[1]

        elif name == "final_slip":
            field = numpy.zeros((1, nvertices, 2), dtype=numpy.float64)
            field[0, :, 0] = finalSlip

        elif name == "slip_time":
            field = slipTime * numpy.zeros(
                (1, nvertices, 1), dtype=numpy.float64)

        elif name == "slip":
            field = numpy.zeros((1, nvertices, 2), dtype=numpy.float64)
            field[0, :, 0] = finalSlip

        elif name == "traction_change":
            field = numpy.zeros((1, nvertices, 2), dtype=numpy.float64)
            field[0, :, 0] = 0.0

        else:
            raise ValueError("Unknown fault field '%s'." % name)

        return field
Exemplo n.º 10
0
class TestSlipOneFault(TestTri3):
  """
  Test suite for testing pylith with shear sliponefault for 2-D box.
  """

  def setUp(self):
    """
    Setup for test.
    """
    TestTri3.setUp(self)
    self.nverticesO = self.mesh['nvertices']
    self.mesh['nvertices'] += 9
    self.faultMesh = {'nvertices': 9,
                      'spaceDim': 2,
                      'ncells': 8,
                      'ncorners': 2}
    run_pylith()
    self.outputRoot = "sliponefault"

    self.soln = AnalyticalSoln()
    return


  def test_fault_info(self):
    """
    Check fault information.
    """
    if not self.checkResults:
      return

    filename = "%s-fault_info.h5" % self.outputRoot
    fields = ["normal_dir", "final_slip", "slip_time"]

    from pylith.tests.Fault import check_vertex_fields
    check_vertex_fields(self, filename, self.faultMesh, fields)

    return


  def test_fault_data(self):
    """
    Check fault information.
    """
    if not self.checkResults:
      return

    filename = "%s-fault.h5" % self.outputRoot
    fields = ["slip"]

    from pylith.tests.Fault import check_vertex_fields
    check_vertex_fields(self, filename, self.faultMesh, fields)

    return


  def test_points_data(self):
    """
    Check points information.
    """
    if not self.checkResults:
      return

    filename = "%s-points.h5" % self.outputRoot
    fields = ["displacement"]
    stations = ["ZZ.AAA", "ZZ.BBB", "ZZ.CCC", "ZZ.DDD"]

    from pylith.tests.SolutionPoints import check_displacements
    check_displacements(self, filename, npoints=len(stations), spaceDim=2)

    from pylith.tests.SolutionPoints import check_stations
    check_stations(self, filename, stations)

    return


  def calcDisplacements(self, vertices):
    """
    Calculate displacement field given coordinates of vertices.
    """
    return self.soln.displacement(vertices, self.nverticesO)


  def calcDisplacementPoints(self, vertices):
    """
    Calculate displacement field given coordinates of vertices.
    """
    return self.soln.displacement(vertices)


  def calcStateVar(self, name, vertices, cells):
    """
    Calculate state variable.
    """
    ncells = self.mesh['ncells']
    pts = numpy.zeros( (ncells, 3), dtype=numpy.float64)
    if name == "total_strain":
      stateVar = self.soln.strain(pts)
    elif name == "stress":
      stateVar = self.soln.stress(pts)
    else:
      raise ValueError("Unknown state variable '%s'." % name)

    return stateVar


  def calcFaultField(self, name, vertices):
    """
    Calculate fault info.
    """

    normalDir = (-1.0, 0.0)
    finalSlip = -2.0
    slipTime = 0.0

    nvertices = self.faultMesh['nvertices']

    if name == "normal_dir":
      field = numpy.zeros( (1, nvertices, 2), dtype=numpy.float64)
      field[0,:,0] = normalDir[0]
      field[0,:,1] = normalDir[1]

    elif name == "final_slip":
      field = numpy.zeros( (1, nvertices, 2), dtype=numpy.float64)
      field[0,:,0] = finalSlip
      
    elif name == "slip_time":
      field = slipTime*numpy.zeros( (1, nvertices, 1), dtype=numpy.float64)
      
    elif name == "slip":
      field = numpy.zeros( (1, nvertices, 2), dtype=numpy.float64)
      field[0,:,0] = finalSlip

    elif name == "traction_change":
      field = numpy.zeros( (1, nvertices, 2), dtype=numpy.float64)
      field[0,:,0] = 0.0
      
    else:
      raise ValueError("Unknown fault field '%s'." % name)

    return field
Exemplo n.º 11
0
class TestSlipOneFault(TestTri3):
    """
  Test suite for testing pylith with shear sliponefault for 2-D box.
  """
    def setUp(self):
        """
    Setup for test.
    """
        TestTri3.setUp(self)
        self.nverticesO = self.mesh['nvertices']
        self.mesh['nvertices'] += 9
        self.faultMesh = {
            'nvertices': 9,
            'spaceDim': 2,
            'ncells': 8,
            'ncorners': 2
        }
        run_pylith(SlipOneFaultApp)
        self.outputRoot = "sliponefault"

        self.soln = AnalyticalSoln()
        return

    def test_fault_info(self):
        """
    Check fault information.
    """
        if not self.checkResults:
            return

        filename = "%s-fault_info.h5" % self.outputRoot
        fields = ["normal_dir", "final_slip", "slip_time"]

        from pylith.tests.Fault import check_vertex_fields
        check_vertex_fields(self, filename, self.faultMesh, fields)

        return

    def test_fault_data(self):
        """
    Check fault information.
    """
        if not self.checkResults:
            return

        filename = "%s-fault.h5" % self.outputRoot
        fields = ["slip"]

        from pylith.tests.Fault import check_vertex_fields
        check_vertex_fields(self, filename, self.faultMesh, fields)

        return

    def test_points_data(self):
        """
    Check points information.
    """
        if not self.checkResults:
            return

        filename = "%s-points.h5" % self.outputRoot
        fields = ["displacement"]
        stations = ["ZZ.AAA", "ZZ.BBB", "ZZ.CCC", "ZZ.DDD"]

        from pylith.tests.SolutionPoints import check_displacements
        check_displacements(self, filename, npoints=len(stations), spaceDim=2)

        from pylith.tests.SolutionPoints import check_stations
        check_stations(self, filename, stations)

        return

    def calcDisplacements(self, vertices):
        """
    Calculate displacement field given coordinates of vertices.
    """
        return self.soln.displacement(vertices, self.nverticesO)

    def calcDisplacementPoints(self, vertices):
        """
    Calculate displacement field given coordinates of vertices.
    """
        return self.soln.displacement(vertices)

    def calcStateVar(self, name, vertices, cells):
        """
    Calculate state variable.
    """
        ncells = self.mesh['ncells']
        pts = numpy.zeros((ncells, 3), dtype=numpy.float64)
        if name == "total_strain":
            stateVar = self.soln.strain(pts)
        elif name == "stress" or name == "cauchy_stress":
            stateVar = self.soln.stress(pts)
        else:
            raise ValueError("Unknown state variable '%s'." % name)

        return stateVar

    def calcFaultField(self, name, vertices):
        """
    Calculate fault info.
    """

        normalDir = (-1.0, 0.0)
        finalSlip = -2.0
        slipTime = 0.0

        nvertices = self.faultMesh['nvertices']

        if name == "normal_dir":
            field = numpy.zeros((1, nvertices, 2), dtype=numpy.float64)
            field[0, :, 0] = normalDir[0]
            field[0, :, 1] = normalDir[1]

        elif name == "final_slip":
            field = numpy.zeros((1, nvertices, 2), dtype=numpy.float64)
            field[0, :, 0] = finalSlip

        elif name == "slip_time":
            field = slipTime * numpy.zeros(
                (1, nvertices, 1), dtype=numpy.float64)

        elif name == "slip":
            field = numpy.zeros((1, nvertices, 2), dtype=numpy.float64)
            field[0, :, 0] = finalSlip

        elif name == "traction_change":
            field = numpy.zeros((1, nvertices, 2), dtype=numpy.float64)
            field[0, :, 0] = 0.0

        else:
            raise ValueError("Unknown fault field '%s'." % name)

        return field
Exemplo n.º 12
0
class TestFaultsIntersect(TestHex8):
  """
  Test suite for testing pylith with shear slip on two faults.
  """

  def setUp(self):
    """
    Setup for test.
    """
    TestHex8.setUp(self)
    self.nverticesO = self.mesh['nvertices']

    # Fault x
    self.mesh['nvertices'] += 55
    self.faultMeshX = {'nvertices': 55,
                       'spaceDim': 3,
                       'ncells': 40,
                       'ncorners': 4}

    # Fault y
    self.mesh['nvertices'] += 4
    self.faultMeshY = {'nvertices': 12,
                       'spaceDim': 3,
                       'ncells': 6,
                       'ncorners': 4}

    run_pylith()
    self.outputRoot = "faultsintersect"

    self.soln = AnalyticalSoln()
    return


  def test_fault_info(self):
    """
    Check fault information.
    """
    if not self.checkResults:
      return

    from pylith.tests.Fault import check_vertex_fields
    fields = ["normal_dir", "final_slip", "slip_time"]

    self.fault = "x"
    filename = "%s-faultx_info.h5" % self.outputRoot
    check_vertex_fields(self, filename, self.faultMeshX, fields)

    self.fault = "y"
    filename = "%s-faulty_info.h5" % self.outputRoot
    check_vertex_fields(self, filename, self.faultMeshY, fields)

    return


  def test_fault_data(self):
    """
    Check fault information.
    """
    if not self.checkResults:
      return

    from pylith.tests.Fault import check_vertex_fields
    fields = ["slip"]

    filename = "%s-faultx.h5" % self.outputRoot
    self.fault = "x"
    check_vertex_fields(self, filename, self.faultMeshX, fields)

    filename = "%s-faulty.h5" % self.outputRoot
    self.fault = "y"
    check_vertex_fields(self, filename, self.faultMeshY, fields)

    return


  def calcDisplacements(self, vertices):
    """
    Calculate displacement field given coordinates of vertices.
    """
    return self.soln.displacement(vertices, self.nverticesO)


  def calcStateVar(self, name, vertices, cells):
    """
    Calculate state variable.
    """
    ncells = self.mesh['ncells']
    pts = numpy.zeros( (ncells, 3), dtype=numpy.float64)
    if name == "total_strain":
      stateVar = self.soln.strain(pts)
    elif name == "stress":
      stateVar = self.soln.stress(pts)
    else:
      raise ValueError("Unknown state variable '%s'." % name)

    return stateVar


  def calcFaultField(self, name, vertices):
    """
    Calculate fault info.
    """

    if self.fault == "x":
      normalDir = (-1.0, 0.0, 0.0)
      finalSlip = -2.0
      faultMesh = self.faultMeshX
    elif self.fault == "y":
      normalDir = (0.0,-1.0, 0.0)
      finalSlip = 0.0
      faultMesh = self.faultMeshY

    slipTime = 0.0
    dim = 3

    nvertices = faultMesh['nvertices']

    if name == "normal_dir":
      field = numpy.zeros( (1, nvertices, dim), dtype=numpy.float64)
      field[0,:,0] = normalDir[0]
      field[0,:,1] = normalDir[1]
      field[0,:,2] = normalDir[2]

    elif name == "final_slip":
      field = numpy.zeros( (1, nvertices, dim), dtype=numpy.float64)
      field[0,:,0] = finalSlip

    elif name == "slip_time":
      field = slipTime*numpy.zeros( (1, nvertices, 1), dtype=numpy.float64)
      
    elif name == "slip":
      field = numpy.zeros( (1, nvertices, dim), dtype=numpy.float64)
      field[0,:,0] = finalSlip

    elif name == "traction_change":
      field = numpy.zeros( (1, nvertices, dim), dtype=numpy.float64)
      field[0,:,0] = 0.0
      
    else:
      raise ValueError("Unknown fault field '%s'." % name)

    return field