def test_no_dynamics_2d(self): g_list = setup_grids.setup_2d() for g in g_list: discr = biot.Biot() bound_faces = g.get_all_boundary_faces() bound = bc.BoundaryCondition( g, bound_faces.ravel("F"), ["dir"] * bound_faces.size ) mu = np.ones(g.num_cells) c = tensor.FourthOrderTensor(g.dim, mu, mu) k = tensor.SecondOrderTensor(g.dim, np.ones(g.num_cells)) bound_val = np.zeros(g.num_faces) param = Parameters(g) param.set_bc("flow", bound) param.set_bc("mechanics", bound) param.set_tensor("flow", k) param.set_tensor("mechanics", c) param.set_bc_val("mechanics", np.tile(bound_val, g.dim)) param.set_bc_val("flow", bound_val) param.porosity = np.ones(g.num_cells) param.biot_alpha = 1 data = {"param": param, "inverter": "python", "dt": 1} A, b = discr.matrix_rhs(g, data) sol = np.linalg.solve(A.todense(), b) self.assertTrue(np.isclose(sol, np.zeros(g.num_cells * (g.dim + 1))).all())
def test_no_dynamics_2d(self): g_list = setup_grids.setup_2d() for g in g_list: discr = biot.Biot() bound_faces = g.get_all_boundary_faces() bound = bc.BoundaryCondition(g, bound_faces.ravel('F'), ['dir'] * bound_faces.size) mu = np.ones(g.num_cells) c = tensor.FourthOrderTensor(g.dim, mu, mu) k = tensor.SecondOrderTensor(g.dim, np.ones(g.num_cells)) bound_val = np.zeros(g.num_faces) param = Parameters(g) param.set_bc('flow', bound) param.set_bc('mechanics', bound) param.set_tensor('flow', k) param.set_tensor('mechanics', c) param.set_bc_val('mechanics', np.tile(bound_val, g.dim)) param.set_bc_val('flow', bound_val) param.porosity = np.ones(g.num_cells) param.biot_alpha = 1 data = {'param': param, 'inverter': 'python', 'dt': 1} A, b = discr.matrix_rhs(g, data) sol = np.linalg.solve(A.todense(), b) assert np.isclose(sol, np.zeros(g.num_cells * (g.dim + 1))).all()
def test_face_vector_to_scalar(self): # Test of function face_vector_to_scalar nf = 3 nd = 2 rows = np.array([0, 0, 1, 1, 2, 2]) cols = np.arange(6) vals = np.ones(6) known_matrix = sps.coo_matrix((vals, (rows, cols))).tocsr().toarray() a = biot.Biot()._face_vector_to_scalar(3, 2).toarray() self.assertTrue(np.allclose(known_matrix, a))