Beispiel #1
0
 def test_appy_to_vector(self):
     bc = fem.DirichletBC([1, 3, 5], [2, 4, 6])
     dof_map = fem.dofMap(np.arange(0, 6))
     b = np.arange(6)
     b, dof_map = bc.apply_to_vector(b, dof_map)
     assert np.all(dof_map.inverse == [0, 2, 4])
     assert np.allclose(b, [0, 2, 4])
Beispiel #2
0
 def test_add_to_solution(self):
     bc = fem.DirichletBC([1, 3, 5], [1, 3, 5])
     dof_map = fem.dofMap([2, 6, 4])
     x = -np.arange(3)
     x, dof_map = bc.apply_to_solution(x, dof_map)
     assert np.all(dof_map.inverse == [2, 6, 4, 1, 3, 5])
     assert np.allclose(x.T, [0, -1, -2, 1, 3, 5])
Beispiel #3
0
 def test_dirichlet_apply(self):
     bc = fem.DirichletBC([1, 3, 5], [2, 4, 6])
     dof_map = fem.dofMap(np.arange(1, 7))
     A = sparse.diags(1 + np.arange(6)).tocsc()
     b = -np.arange(6)
     A, b, dof_map = bc.apply(A, b, dof_map)
     A = A.toarray()
     assert A.shape == (3, 3)
     assert b.shape == (3, 1)
     assert A[0, 0] == 2
     assert A[1, 1] == 4
     assert A[2, 2] == 6
     assert np.all(dof_map.inverse == [2, 4, 6])
     assert dof_map[2] == 0
Beispiel #4
0
 def test_define_dof_map(self):
     dof_map = fem.dofMap(inverse=[1, 2, 5, 3])
     assert dof_map[1] == 0
     assert dof_map[2] == 1
     assert dof_map[5] == 2
     assert dof_map[3] == 3