Skip to content

Commit

Permalink
Updates for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
IvarStefansson committed Aug 9, 2017
1 parent bcd6da6 commit db44ee1
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 30 deletions.
11 changes: 3 additions & 8 deletions test/unit/test_fv_fluxes.py
Expand Up @@ -299,7 +299,6 @@ def test_tpfa_fluxes_2d_1d_cross_with_elimination(self):
g1, g2 = gb.sorted_nodes_of_edge(e)
pa = data['param']
node_numbers = gb.nodes_prop([g2, g1], 'node_number')

if pa is not None:

if node_numbers == (0,1):
Expand All @@ -318,7 +317,6 @@ def test_tpfa_fluxes_2d_1d_cross_with_elimination(self):
g1, g2 = gb_r.sorted_nodes_of_edge(e)
pa = data['param']
node_numbers = gb_r.nodes_prop([g2, g1], 'node_number')

if pa is not None:

if node_numbers == (0,1):
Expand Down Expand Up @@ -544,14 +542,11 @@ def coupling_fluxes_2d_1d_cross_no_el():
return d_01, d_10, d_02, d_20, d_13, d_23
#------------------------------------------------------------------------------#
def coupling_fluxes_2d_1d_cross_with_el():
d_11 = np.array([[ 0. , -0.34984981],
[ 0. , 0. ]])
d_11 = np.array([0.34984981])

d_21 = np.array([[ 0.27718625, -0.07266356],
[ 0.27718625, -0.07266356]])
d_21 = np.array([ 0.27718625, 0.27718625, -0.07266356, -0.07266356])

d_22 = np.array([[ 0.00000000e+00, 0.00000000e+00],
[ 0.00000000e+00, 0.00000000e+00]])
d_22 = np.array([ 0.00000000e+00])

return d_11, d_21, d_22
#------------------------------------------------------------------------------#
Expand Down
53 changes: 31 additions & 22 deletions test/unit/test_upwind_elimination.py
Expand Up @@ -92,7 +92,7 @@ def test_upwind_2d_1d_cross_with_elimination(self):
param.set_bc_val('flow', bc_val)

# Transport:
source = 1*np.ones(g.num_cells)*g.cell_volumes*a_dim
source = g.cell_volumes*a_dim
param.set_source("transport", source)

bound_faces = g.get_boundary_faces()
Expand Down Expand Up @@ -123,7 +123,7 @@ def test_upwind_2d_1d_cross_with_elimination(self):

A, rhs = solver.matrix_rhs(gb)
# p = sps.linalg.spsolve(A,rhs)
p_cond, p_red, _, _ = condensation.solve_static_condensation(\
_, p_red, _, _ = condensation.solve_static_condensation(\
A, rhs, gb, dim=0)
coupling = coupler.Coupler(solver)
#coupling.split(gb, "p", p)
Expand All @@ -145,12 +145,12 @@ def test_upwind_2d_1d_cross_with_elimination(self):
U_r, rhs_u_r = advection_coupler.matrix_rhs(gb_r)
deltaT = np.amin(gb_r.apply_function(advection_discr.cfl,
advection_coupling_conditions.cfl).data)

#theta = sps.linalg.spsolve(U, rhs_u )
theta_r = sps.linalg.spsolve(U_r, rhs_u_r )
#coupling.split(gb, 'theta', theta)
#coupling.split(gb_r, 'theta', theta_r)

U_known, rhs_known, theta_known, deltaT_known = known_for_elimination()
tol = 1e-7
assert(np.isclose(deltaT, deltaT_known, tol, tol))
Expand Down Expand Up @@ -333,25 +333,34 @@ def fluxes_2d_1d_left_right_dir_neu():
return d_0, d_1
#------------------------------------------------------------------------------#
def known_for_elimination():
U = np.array([[ 0.5 , 0. , 0. , 0. , 0. ,
0. , 0. , 0. ],
[ 0. , 0.05288884, 0. , 0. , 0. ,
0. , 0. , -0.05288884],
[ 0. , 0. , 0.5 , 0. , 0. ,
0. , 0. , 0. ],
[ 0. , 0. , 0. , 0.05288884, 0. ,
0. , -0.05288884, 0. ],
[ 0. , -0.00365602, 0. , -0.00365602, 0.91153437,
0. , -0.27718625, -0.27718625],
[-0.24258847, 0. , -0.24258847, 0. , 0. ,
0.49517693, 0. , 0. ],
[ 0. , 0. , -0.25741153, 0. , 0. ,
-0.07266356, 0.33007509, 0. ],
[-0.25741153, 0. , 0. , 0. , 0. ,
-0.07266356, 0. , 0.33007509]])
U = np.array([[ 5.00000000e-01, 0.00000000e+00, 0.00000000e+00,
0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
0.00000000e+00, 0.00000000e+00],
[ 0.00000000e+00, 5.28888404e-02, 0.00000000e+00,
0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
0.00000000e+00, -5.28888404e-02],
[ 0.00000000e+00, 0.00000000e+00, 5.00000000e-01,
0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
0.00000000e+00, 0.00000000e+00],
[ 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
5.28888404e-02, 0.00000000e+00, 0.00000000e+00,
-5.28888404e-02, 0.00000000e+00],
[ 0.00000000e+00, -3.65602442e-03, 0.00000000e+00,
-3.65602442e-03, 9.11534368e-01, -3.49849812e-01,
-2.77186253e-01, -2.77186253e-01],
[ -2.42588465e-01, 0.00000000e+00, -2.42588465e-01,
0.00000000e+00, 0.00000000e+00, 4.95176930e-01,
0.00000000e+00, 0.00000000e+00],
[ 0.00000000e+00, 0.00000000e+00, -2.57411535e-01,
0.00000000e+00, 0.00000000e+00, -7.26635590e-02,
3.30075094e-01, -3.55271368e-15],
[ -2.57411535e-01, 0.00000000e+00, 0.00000000e+00,
0.00000000e+00, 0.00000000e+00, -7.26635590e-02,
0.00000000e+00, 3.30075094e-01]])

rhs = np.array([ 0.25 , 0.25 , 0.25 , 0.25 , 0.005, 0.005, 0.005, 0.005])
t = np.array([ 0.5, 5.24204316, 0.5, 5.24204316, 0.36083555,
0.5, 0.51514807, 0.51514807])
t = np.array([ 0.5 , 5.24204316, 0.5 , 5.24204316, 0.55273715,
0.5 , 0.51514807, 0.51514807])
dT = 0.00274262835006

return U, rhs, t, dT
Expand Down

0 comments on commit db44ee1

Please sign in to comment.