当前位置: 首页>>代码示例>>Python>>正文


Python Jacobian.zero方法代码示例

本文整理汇总了Python中pylith.topology.Jacobian.Jacobian.zero方法的典型用法代码示例。如果您正苦于以下问题:Python Jacobian.zero方法的具体用法?Python Jacobian.zero怎么用?Python Jacobian.zero使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pylith.topology.Jacobian.Jacobian的用法示例。


在下文中一共展示了Jacobian.zero方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_integrateJacobian

# 需要导入模块: from pylith.topology.Jacobian import Jacobian [as 别名]
# 或者: from pylith.topology.Jacobian.Jacobian import zero [as 别名]
  def test_integrateJacobian(self):
    """
    Test integrateJacobian().

    This does nothing for Neumann BC.
    """

    (mesh, bc, fields) = self._initialize()

    from pylith.topology.Jacobian import Jacobian
    jacobian = Jacobian(fields.solution())
    jacobian.zero()
    t = 0.24
    bc.integrateJacobian(jacobian, t, fields)
    self.assertEqual(False, bc.needNewJacobian())

    # No testing of result.
    return
开发者ID:rishabhdutta,项目名称:pylith,代码行数:20,代码来源:TestNeumann.py

示例2: test_integrateJacobian

# 需要导入模块: from pylith.topology.Jacobian import Jacobian [as 别名]
# 或者: from pylith.topology.Jacobian.Jacobian import zero [as 别名]
  def test_integrateJacobian(self):
    """
    Test integrateJacobian().

    WARNING: This is not a rigorous test of integrateJacobian() because we
    don't verify the results.
    """

    (mesh, bc, fields) = self._initialize()

    from pylith.topology.Jacobian import Jacobian
    jacobian = Jacobian(fields.solution())
    jacobian.zero()
    t = 0.24
    bc.integrateJacobian(jacobian, t, fields)
    self.assertEqual(False, bc.needNewJacobian())

    # No testing of result.
    return
开发者ID:rishabhdutta,项目名称:pylith,代码行数:21,代码来源:TestAbsorbingDampers.py

示例3: test_integrateJacobian

# 需要导入模块: from pylith.topology.Jacobian import Jacobian [as 别名]
# 或者: from pylith.topology.Jacobian.Jacobian import zero [as 别名]
  def test_integrateJacobian(self):
    """
    Test integrateJacobian().

    WARNING: This is not a rigorous test of integrateJacobian() because we
    neither set the input fields or verify the results.
    """
    (mesh, fault, fields) = self._initialize()

    from pylith.topology.Jacobian import Jacobian
    jacobian = Jacobian(fields.solution())
    jacobian.zero()
    t = 1.0
    fault.integrateJacobian(jacobian, t, fields)
    self.assertEqual(False, fault.needNewJacobian())

    # We should really add something here to check to make sure things
    # actually initialized correctly    
    return
开发者ID:geodynamics,项目名称:pylith,代码行数:21,代码来源:TestFaultCohesiveDyn.py

示例4: test_integrateJacobian

# 需要导入模块: from pylith.topology.Jacobian import Jacobian [as 别名]
# 或者: from pylith.topology.Jacobian.Jacobian import zero [as 别名]
  def test_integrateJacobian(self):
    """
    Test integrateJacobian().

    WARNING: This is not a rigorous test of integrateJacobian()
    because we neither set the input fields or verify the results.
    """
    (mesh, integrator) = self._preinitialize()
    fields = self._initialize(mesh, integrator)

    from pylith.topology.Jacobian import Jacobian
    jacobian = Jacobian(fields.solution())
    jacobian.zero()
    t = 7.3
    self.assertEqual(True, integrator.needNewJacobian())
    integrator.integrateJacobian(jacobian, t, fields)
    self.assertEqual(False, integrator.needNewJacobian())
    
    # No test of result.
    return
开发者ID:rishabhdutta,项目名称:pylith,代码行数:22,代码来源:TestElasticityImplicitLgDeform.py

示例5: TestJacobian

# 需要导入模块: from pylith.topology.Jacobian import Jacobian [as 别名]
# 或者: from pylith.topology.Jacobian.Jacobian import zero [as 别名]
class TestJacobian(unittest.TestCase):
  """
  Unit testing of Jacobian object.
  """

  def setUp(self):
    """
    Setup mesh and associated field.
    """
    from spatialdata.geocoords.CSCart import CSCart
    cs = CSCart()
    cs.inventory.spaceDim = 2
    cs._configure()

    from spatialdata.units.Nondimensional import Nondimensional
    normalizer = Nondimensional()
    normalizer._configure()    

    from pylith.meshio.MeshIOAscii import MeshIOAscii
    importer = MeshIOAscii()
    importer.inventory.filename = "data/tri3.mesh"
    importer.inventory.coordsys = cs
    importer._configure()
    self.mesh = importer.read(debug=False, interpolate=False)

    from pylith.topology.SolutionFields import SolutionFields
    fields = SolutionFields(self.mesh)
    fields.add("disp t+dt", "displacement")
    fields.solutionName("disp t+dt")
    solution = fields.solution()
    solution.newSection(solution.VERTICES_FIELD, self.mesh.dimension())
    solution.allocate()
    solution.zero()

    self.fields = fields
    self.jacobian = Jacobian(solution)
    return


  def tearDown(self):
    self.jacobian.cleanup()
    return


  def test_constructor(self):
    """
    Test constructor.
    """
    # setUp() tests constructor with default type
    jacobianA = Jacobian(self.fields.solution(), "aij")
    jacobianB = Jacobian(self.fields.solution(), "baij")
    return


  def test_matrix(self):
    """
    Test matrix().

    :WARNING: This is not a complete test of matrix(). We do not
    verify the results.
    """
    matrix = self.jacobian.matrix()

    # No testing of result.
    return


  def test_assemble(self):
    """
    Test assemble().

    :WARNING: This is not a complete test of assemble(). We do not
    verify the results.
    """
    self.jacobian.assemble("flush_assembly")
    self.jacobian.assemble("final_assembly")

    # No testing of result.
    return


  def test_zero(self):
    """
    Test zero().

    :WARNING: This is not a complete test of zero(). We do not
    verify the results.
    """
    self.jacobian.zero()

    # No testing of result.
    return


  def test_view(self):
    """
    Test view().

    :WARNING: This is not a complete test of view(). We do not
    verify the results.
#.........这里部分代码省略.........
开发者ID:panzhengyang,项目名称:pylith,代码行数:103,代码来源:TestJacobian.py

示例6: Implicit

# 需要导入模块: from pylith.topology.Jacobian import Jacobian [as 别名]
# 或者: from pylith.topology.Jacobian.Jacobian import zero [as 别名]

#.........这里部分代码省略.........
  def elasticityIntegrator(self):
    """
    Get integrator for elastic material.
    """
    from pylith.feassemble.ElasticityImplicit import ElasticityImplicit
    integrator = ElasticityImplicit()
    return integrator


  def initialize(self, dimension, normalizer):
    """
    Initialize problem for implicit time integration.
    """
    logEvent = "%sinit" % self._loggingPrefix
    self._eventLogger.eventBegin(logEvent)

    comm = self.mesh().comm()

    self._initialize(dimension, normalizer)

    #from pylith.utils.petsc import MemoryLogger
    #memoryLogger = MemoryLogger.singleton()
    #memoryLogger.setDebug(0)
    #memoryLogger.stagePush("Problem")

    # Allocate other fields, reusing layout from dispIncr
    if 0 == comm.rank:
      self._info.log("Creating other fields.")
    self.fields.add("velocity(t)", "velocity")
    self.fields.copyLayout("dispIncr(t->t+dt)")

    # Setup fields and set to zero
    dispT = self.fields.get("disp(t)")
    dispT.zeroAll()
    residual = self.fields.get("residual")
    residual.zeroAll()
    residual.createScatter(residual.mesh())

    lengthScale = normalizer.lengthScale()
    timeScale = normalizer.timeScale()
    velocityScale = lengthScale / timeScale
    velocityT = self.fields.get("velocity(t)")
    velocityT.scale(velocityScale.value)
    velocityT.zeroAll()

    self._debug.log(resourceUsageString())
    #memoryLogger.stagePop()

    # Allocates memory for nonzero pattern and Jacobian
    if 0 == comm.rank:
      self._info.log("Creating Jacobian matrix.")
    self._setJacobianMatrixType()
    from pylith.topology.Jacobian import Jacobian
    self.jacobian = Jacobian(self.fields.solution(),
                             self.matrixType, self.blockMatrixOkay)
    self.jacobian.zero() # TEMPORARY, to get correct memory usage
    self._debug.log(resourceUsageString())

    #memoryLogger.stagePush("Problem")
    if 0 == comm.rank:
      self._info.log("Initializing solver.")
    self.solver.initialize(self.fields, self.jacobian, self)
    self._debug.log(resourceUsageString())

    #memoryLogger.stagePop()
    #memoryLogger.setDebug(0)
开发者ID:rishabhdutta,项目名称:pylith,代码行数:70,代码来源:Implicit.py


注:本文中的pylith.topology.Jacobian.Jacobian.zero方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。