• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python Jacobian.Jacobian类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: setUp

  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
开发者ID:panzhengyang,项目名称:pylith,代码行数:32,代码来源:TestJacobian.py


示例2: initialize

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

    from pylith.mpi.Communicator import mpi_comm_world
    comm = mpi_comm_world()

    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)
    return
开发者ID:youngsolar,项目名称:pylith,代码行数:59,代码来源:Implicit.py


示例3: test_integrateJacobian

  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,代码行数:18,代码来源:TestNeumann.py


示例4: test_integrateJacobian

  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,代码行数:19,代码来源:TestAbsorbingDampers.py


示例5: test_integrateJacobian

  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,代码行数:19,代码来源:TestFaultCohesiveDyn.py


示例6: test_integrateJacobian

  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,代码行数:20,代码来源:TestElasticityImplicitLgDeform.py


示例7: test_write

  def test_write(self):
    """
    Test write().

    :WARNING: This is not a complete test of write(). We do not
    verify the results.
    """
    self.jacobian = Jacobian(self.fields.solution(), "aij")
    self.jacobian.assemble("final_assembly")

    self.jacobian.write("jacobian.mat", self.mesh.comm())

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


示例8: TestJacobian

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,代码行数:101,代码来源:TestJacobian.py


示例9: Implicit

class Implicit(Formulation, ModuleImplicit):
  """
  Python Implicit object for solving equations using an implicit
  formulation.

  The formulation has the general form,

  [A(t+dt)] {u(t+dt)} = {b(t+dt)}. 

  We know the solution at time t, so we write {u(t+dt)} as {u(t)} +
  {du(t)}, where {du(t)} is the increment in the solution from time t
  to time t+dt. Thus, we solve

  [A(t+dt)] {du(t)} = {b(t+dt)} - [A(t+dt)]{u(t)}.

  We solve this system by forming the Jacobian, A, and the residual

  {r(t+dt)} = {b(t+dt)} - [A(t+dt)]{u(t)} - [A(t+dt)]{du(t)}

  which we combine into

  {r(t+dt)} = {b(t+dt)} - [A(t+dt)]{u(t)+du(t)}.

  The method reformJacobian() computes [A(t+dt)] and the method
  reformResidual computes {r(t+dt)}. Note that in forming the residual
  we compute the action [A(t+dt)]{u(t)+du(t)} and do not perform a
  matrix-vector multiplication.

  [A(t+dt)] generally depends on {u(t+dt)} as well as the current
  stresses and additional state variables.  

  For linear elastic or viscoelastic problems with constant time step
  size, A is a constant (after the elastic solution).  {b(t+dt)}
  generally depends on the loads applied for time step t+dt (including
  the contributions to the internal force vector from
  displacement/velocity BC) as well as the internal force vector
  computed from the current stresses.

  Factory: pde_formulation.
  """

  # INVENTORY //////////////////////////////////////////////////////////

  class Inventory(Formulation.Inventory):
    """
    Python object for managing Implicit facilities and properties.
    """

    ## @class Inventory
    ## Python object for managing Implicit facilities and properties.
    ##
    ## \b Properties
    ## @li None
    ##
    ## \b Facilities
    ## @li None

    import pyre.inventory


  # PUBLIC METHODS /////////////////////////////////////////////////////

  def __init__(self, name="implicit"):
    """
    Constructor.
    """
    Formulation.__init__(self, name)
    ModuleImplicit.__init__(self)
    self._loggingPrefix = "TSIm "
    return


  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.")
#.........这里部分代码省略.........
开发者ID:rishabhdutta,项目名称:pylith,代码行数:101,代码来源:Implicit.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python Mesh.Mesh类代码示例发布时间:2022-05-25
下一篇:
Python Fault.check_vertex_fields函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap