本文整理匯總了Python中dolfin.UnitSquareMesh.mpi_comm方法的典型用法代碼示例。如果您正苦於以下問題:Python UnitSquareMesh.mpi_comm方法的具體用法?Python UnitSquareMesh.mpi_comm怎麽用?Python UnitSquareMesh.mpi_comm使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類dolfin.UnitSquareMesh
的用法示例。
在下文中一共展示了UnitSquareMesh.mpi_comm方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_compute_entity_collisions_tree_2d
# 需要導入模塊: from dolfin import UnitSquareMesh [as 別名]
# 或者: from dolfin.UnitSquareMesh import mpi_comm [as 別名]
def test_compute_entity_collisions_tree_2d(self):
references = [[set([20, 21, 22, 23, 28, 29, 30, 31]),
set([0, 1, 2, 3, 8, 9, 10, 11])],
[set([6]),
set([25])]]
points = [Point(0.52, 0.51), Point(0.9, -0.9)]
for i, point in enumerate(points):
mesh_A = UnitSquareMesh(4, 4)
mesh_B = UnitSquareMesh(4, 4)
mesh_B.translate(point)
tree_A = BoundingBoxTree()
tree_A.build(mesh_A)
tree_B = BoundingBoxTree()
tree_B.build(mesh_B)
entities_A, entities_B = tree_A.compute_entity_collisions(tree_B)
if MPI.size(mesh_A.mpi_comm()) == 1:
self.assertEqual(set(entities_A), references[i][0])
self.assertEqual(set(entities_B), references[i][1])
示例2: test_compute_first_entity_collision_2d
# 需要導入模塊: from dolfin import UnitSquareMesh [as 別名]
# 或者: from dolfin.UnitSquareMesh import mpi_comm [as 別名]
def test_compute_first_entity_collision_2d(self):
reference = [136, 137]
p = Point(0.3, 0.3)
mesh = UnitSquareMesh(16, 16)
tree = BoundingBoxTree()
tree.build(mesh)
first = tree.compute_first_entity_collision(p)
if MPI.size(mesh.mpi_comm()) == 1:
self.assertIn(first, reference)
tree = mesh.bounding_box_tree()
first = tree.compute_first_entity_collision(p)
if MPI.size(mesh.mpi_comm()) == 1:
self.assertIn(first, reference)
示例3: test_compute_first_collision_2d
# 需要導入模塊: from dolfin import UnitSquareMesh [as 別名]
# 或者: from dolfin.UnitSquareMesh import mpi_comm [as 別名]
def test_compute_first_collision_2d(self):
reference = {1: [226],
2: [136, 137]}
p = Point(0.3, 0.3)
mesh = UnitSquareMesh(16, 16)
for dim in range(1, 3):
tree = BoundingBoxTree()
tree.build(mesh, dim)
first = tree.compute_first_collision(p)
if MPI.size(mesh.mpi_comm()) == 1:
self.assertIn(first, reference[dim])
tree = mesh.bounding_box_tree()
first = tree.compute_first_collision(p)
if MPI.size(mesh.mpi_comm()) == 1:
self.assertIn(first, reference[mesh.topology().dim()])
示例4: test_compute_entity_collisions_2d
# 需要導入模塊: from dolfin import UnitSquareMesh [as 別名]
# 或者: from dolfin.UnitSquareMesh import mpi_comm [as 別名]
def test_compute_entity_collisions_2d(self):
reference = set([136, 137])
p = Point(0.3, 0.3)
mesh = UnitSquareMesh(16, 16)
tree = BoundingBoxTree()
tree.build(mesh)
entities = tree.compute_entity_collisions(p)
if MPI.size(mesh.mpi_comm()) == 1:
self.assertEqual(set(entities), reference)
tree = mesh.bounding_box_tree()
entities = tree.compute_entity_collisions(p)
if MPI.size(mesh.mpi_comm()) == 1:
self.assertEqual(set(entities), reference)
示例5: test_compute_closest_entity_2d
# 需要導入模塊: from dolfin import UnitSquareMesh [as 別名]
# 或者: from dolfin.UnitSquareMesh import mpi_comm [as 別名]
def test_compute_closest_entity_2d(self):
reference = (1, 1.0)
p = Point(-1.0, 0.01)
mesh = UnitSquareMesh(16, 16)
tree = BoundingBoxTree()
tree.build(mesh)
entity, distance = tree.compute_closest_entity(p)
if MPI.size(mesh.mpi_comm()) == 1:
self.assertEqual(entity, reference[0])
self.assertAlmostEqual(distance, reference[1])
tree = mesh.bounding_box_tree()
entity, distance = tree.compute_closest_entity(p)
if MPI.size(mesh.mpi_comm()) == 1:
self.assertEqual(entity, reference[0])
self.assertAlmostEqual(distance, reference[1])
示例6: test_mesh_point_2d
# 需要導入模塊: from dolfin import UnitSquareMesh [as 別名]
# 或者: from dolfin.UnitSquareMesh import mpi_comm [as 別名]
def test_mesh_point_2d(self):
"Test mesh-point intersection in 2D"
point = Point(0.1, 0.2)
mesh = UnitSquareMesh(16, 16)
intersection = intersect(mesh, point)
if MPI.size(mesh.mpi_comm()) == 1:
self.assertEqual(intersection.intersected_cells(), [98])
示例7: test_compute_collisions_point_2d
# 需要導入模塊: from dolfin import UnitSquareMesh [as 別名]
# 或者: from dolfin.UnitSquareMesh import mpi_comm [as 別名]
def test_compute_collisions_point_2d(self):
reference = {1: set([226]),
2: set([136, 137])}
p = Point(0.3, 0.3)
mesh = UnitSquareMesh(16, 16)
for dim in range(1, 3):
tree = BoundingBoxTree()
tree.build(mesh, dim)
entities = tree.compute_collisions(p)
if MPI.size(mesh.mpi_comm()) == 1:
self.assertEqual(set(entities), reference[dim])
示例8: test_lu_cholesky
# 需要導入模塊: from dolfin import UnitSquareMesh [as 別名]
# 或者: from dolfin.UnitSquareMesh import mpi_comm [as 別名]
def test_lu_cholesky():
"""Test that PETScLUSolver selects LU or Cholesky solver based on
symmetry of matrix operator.
"""
from petsc4py import PETSc
mesh = UnitSquareMesh(MPI.comm_world, 12, 12)
V = FunctionSpace(mesh, "Lagrange", 1)
u, v = TrialFunction(V), TestFunction(V)
A = PETScMatrix(mesh.mpi_comm())
assemble(Constant(1.0)*u*v*dx, tensor=A)
# Check that solver type is LU
solver = PETScLUSolver(mesh.mpi_comm(), A, "petsc")
pc_type = solver.ksp().getPC().getType()
assert pc_type == "lu"
# Set symmetry flag
A.mat().setOption(PETSc.Mat.Option.SYMMETRIC, True)
# Check symmetry flags
symm = A.mat().isSymmetricKnown()
assert symm[0] == True
assert symm[1] == True
# Check that solver type is Cholesky since matrix has now been
# marked as symmetric
solver = PETScLUSolver(mesh.mpi_comm(), A, "petsc")
pc_type = solver.ksp().getPC().getType()
assert pc_type == "cholesky"
# Re-assemble, which resets symmetry flag
assemble(Constant(1.0)*u*v*dx, tensor=A)
solver = PETScLUSolver(mesh.mpi_comm(), A, "petsc")
pc_type = solver.ksp().getPC().getType()
assert pc_type == "lu"