(self)
| 11 | class TestSPH(TestCase): |
| 12 | |
| 13 | def test_matrix_adv_diff(self): |
| 14 | points = [(0, 0), (0, 1), (1, 1), (1, 0)] |
| 15 | mesh = mesh_from_numpy(points, [(0, 1, 2), (0, 2, 3)], {'x': [(1, 2), (3, 0)], 'y': [(0, 1), (2, 3)]}) |
| 16 | def momentum_eq(u, u_prev, dt, diffusivity=0.01): |
| 17 | diffusion_term = dt * diffuse.differential(u, diffusivity, correct_skew=False) |
| 18 | advection_term = dt * advect.differential(u, u_prev, order=1) |
| 19 | return u + advection_term + diffusion_term |
| 20 | velocity = Field(mesh, tensor(vec(x=1, y=0)), {'x': vec(x=.1, y=0), 'y': ZERO_GRADIENT}) |
| 21 | A, b = math.matrix_from_function(momentum_eq, velocity, velocity, 0.01) |
| 22 | r_lin = A @ velocity.values + b |
| 23 | r_call = momentum_eq(velocity, velocity, 0.01) |
| 24 | math.assert_close(r_lin, r_call.values) |
| 25 |
nothing calls this directly
no test coverage detected