Skip to content

Commit

Permalink
Patch tests WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
JDBetteridge committed Jan 26, 2024
1 parent aeafd92 commit ec5af85
Show file tree
Hide file tree
Showing 27 changed files with 249 additions and 164 deletions.
4 changes: 3 additions & 1 deletion tests/equation_bcs/test_equation_bcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import pytest

from firedrake import *
from firedrake.petsc import DEFAULT_DIRECT_SOLVER
import math


Expand Down Expand Up @@ -265,6 +266,7 @@ def test_EquationBC_poisson_matfree(with_bbc):
assert abs(math.log2(err[0]) - math.log2(err[1]) - (porder+1)) < 0.05


##SKIPMUMPS?
@pytest.mark.parametrize("eq_type", ["linear", "nonlinear"])
def test_EquationBC_mixedpoisson_matrix(eq_type):
mat_type = "aij"
Expand All @@ -275,7 +277,7 @@ def test_EquationBC_mixedpoisson_matrix(eq_type):
solver_parameters = {"mat_type": mat_type,
"ksp_type": "preonly",
"pc_type": "lu",
"pc_factor_mat_solver_type": "mumps"}
"pc_factor_mat_solver_type": DEFAULT_DIRECT_SOLVER}
err = []
mesh_sizes = [16, 32]
if eq_type == "linear":
Expand Down
21 changes: 13 additions & 8 deletions tests/extrusion/test_variable_layers_numbering.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ def test_bcs_nodes(domain, expected):

@pytest.mark.parallel(nprocs=4)
def test_layer_extents_parallel():
from petsc4py import PETSc
# +-----+-----+
# |\ 1 |\ 3 | cell_layers = [[0, 1],
# | \ | \ | [0, 1],
Expand All @@ -462,25 +463,27 @@ def test_layer_extents_parallel():
else:
sizes = None
points = None


print("BEFORE MESH")
mesh = UnitSquareMesh(2, 1, reorder=False, distribution_parameters={"partition":
(sizes, points)})
print("AFTER MESH")
V = FunctionSpace(mesh, "DG", 0)

print("2")
x, _ = SpatialCoordinate(mesh)
selector = assemble(interpolate(x - 0.5, V))

print("3")
layers = numpy.empty((mesh.num_cells(), 2), dtype=IntType)

print("4")
data = selector.dat.data_ro_with_halos.real
for cell in V.cell_node_map().values_with_halo:
if data[cell] < 0.25:
layers[cell, :] = [0, 1]
else:
layers[cell, :] = [0, 2]

print("5")
extmesh = ExtrudedMesh(mesh, layers=layers, layer_height=1)

print("6")
if mesh.comm.rank == 0:
# Top view, plex points
# 4--8--6
Expand Down Expand Up @@ -585,12 +588,14 @@ def test_layer_extents_parallel():
[0, 2, 0, 2],
[0, 3, 0, 3],
[0, 3, 0, 3]], dtype=IntType)

print("7")
assert numpy.equal(extmesh.layer_extents, expected).all()

V = FunctionSpace(extmesh, "CG", 1)

assert V.dof_dset.layout_vec.getSize() == 15

print("END")


@pytest.mark.parallel(nprocs=3)
Expand Down
7 changes: 5 additions & 2 deletions tests/multigrid/test_nested_split.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from firedrake import *
from firedrake.petsc import DEFAULT_AMG_PC
import pytest


Expand All @@ -8,6 +9,7 @@
"snes_type": "newtonls",
"snes_linesearch_type": "bt",
"ksp_type": "cg",
"ksp_rtol": 1e-6,
# Fieldsplit PC
"pc_type": "fieldsplit",
"pc_fieldsplit_type": "additive",
Expand All @@ -19,7 +21,7 @@
"fieldsplit_0_mg_levels_pc_type": "icc",
# V-cycle of hypre for Poisson
"fieldsplit_1_ksp_type": "preonly",
"fieldsplit_1_pc_type": "hypre",
"fieldsplit_1_pc_type": DEFAULT_AMG_PC,
# ILU(0) for DG mass matrix
"fieldsplit_2_ksp_type": "preonly",
"fieldsplit_2_pc_type": "bjacobi",
Expand All @@ -29,6 +31,7 @@
"snes_type": "newtonls",
"snes_linesearch_type": "bt",
"ksp_type": "cg",
"ksp_rtol": 1e-6,
# Same as before, just with a recursive split, so we need an aij matrix
"mat_type": "aij",
"pc_type": "fieldsplit",
Expand All @@ -46,7 +49,7 @@
"fieldsplit_0_fieldsplit_0_mg_levels_pc_type": "icc",
# V-cycle of hypre for Poisson
"fieldsplit_0_fieldsplit_1_ksp_type": "preonly",
"fieldsplit_0_fieldsplit_1_pc_type": "hypre",
"fieldsplit_0_fieldsplit_1_pc_type": DEFAULT_AMG_PC,
# ILU(0) for DG mass matrix
"fieldsplit_1_ksp_type": "preonly",
"fieldsplit_1_pc_type": "bjacobi",
Expand Down
4 changes: 2 additions & 2 deletions tests/multigrid/test_non_nested.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from firedrake import *
from firedrake.mg.ufl_utils import coarsen as symbolic_coarsen
from firedrake.petsc import DEFAULT_DIRECT_SOLVER_PARAMETERS
from functools import singledispatch


Expand Down Expand Up @@ -77,8 +78,7 @@ def test_sphere_mg():
"mg_coarse_pc_type": "python",
"mg_coarse_pc_python_type": "firedrake.AssembledPC",
"mg_coarse_assembled_pc_type": "lu",
"mg_coarse_assembled_pc_factor_mat_solver_type": "mumps",
"mg_coarse_assembled_mat_mumps_icntl_14": 200,
"mg_coarse_assembled_pc_factor": DEFAULT_DIRECT_SOLVER_PARAMETERS.copy(),
"mg_levels_pc_type": "python",
"mg_levels_pc_python_type": "firedrake.AssembledPC",
"mg_levels_assembled_pc_type": "bjacobi",
Expand Down
3 changes: 2 additions & 1 deletion tests/multigrid/test_poisson_p1pcmg_extruded_serendipity.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from firedrake import *
from firedrake.petsc import DEFAULT_DIRECT_SOLVER
import pytest


Expand All @@ -18,7 +19,7 @@ def run_poisson():
"degree": coarse_deg,
"ksp_type": "preonly",
"pc_type": "lu",
"pc_factor_mat_solver_type": "mumps"
"pc_factor_mat_solver_type": DEFAULT_DIRECT_SOLVER
}}

N = 2
Expand Down
95 changes: 50 additions & 45 deletions tests/regression/test_auxiliary_dm.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from firedrake.petsc import *
from firedrake import *
from firedrake.petsc import DEFAULT_DIRECT_SOLVER_PARAMETERS
import pytest
distribution_parameters = {"partition": True, "overlap_type": (DistributedMeshOverlapType.VERTEX, 2)}

Expand Down Expand Up @@ -79,50 +79,55 @@ def test_auxiliary_dm():

# Parameters for block factorization
block_fact = {
"mat_type": "aij", # noqa: E126
"snes_type": "newtonls",
"snes_atol": 2.0e-5,
"snes_rtol": 1.0e-5,
"snes_monitor": None,
"ksp_type": "fgmres",
"ksp_norm_type": "unpreconditioned",
"ksp_monitor": None,
"ksp_converged_reason": None,
"ksp_atol": 1e-10,
"ksp_rtol": 1e-10,
"ksp_max_it": 100,
"pc_type": "fieldsplit",
"pc_fieldsplit_0_fields": "0",
"pc_fieldsplit_1_fields": "1,2",
"pc_fieldsplit_type": "schur",
"pc_fieldsplit_schur_fact_type": "full",
"pc_fieldsplit_schur_precondition": "user",
"fieldsplit_0_ksp_type": "richardson",
"fieldsplit_0_pc_type": "ilu",
"fieldsplit_0_ksp_max_it": 1,
"fieldsplit_0_ksp_convergence_test": "skip",
"fieldsplit_1_ksp_type": "gmres",
"fieldsplit_1_ksp_max_it": 1,
"fieldsplit_1_ksp_convergence_test": "skip",
"fieldsplit_1_ksp_monitor_true_residual": None,
"fieldsplit_1_pc_type": "python",
"fieldsplit_1_pc_python_type": "test_auxiliary_dm.ApproximateSchur",
"fieldsplit_1_aux_pc_type": "mg",
"fieldsplit_1_aux_mg_levels_ksp_type": "richardson",
"fieldsplit_1_aux_mg_levels_ksp_richardson_scale": 1/3,
"fieldsplit_1_aux_mg_levels_pc_type": "python",
"fieldsplit_1_aux_mg_levels_pc_python_type": "firedrake.PatchPC",
"fieldsplit_1_aux_mg_levels_patch_pc_patch_save_operators": True,
"fieldsplit_1_aux_mg_levels_patch_pc_patch_partition_of_unity": False,
"fieldsplit_1_aux_mg_levels_patch_pc_patch_sub_mat_type": "seqdense",
"fieldsplit_1_aux_mg_levels_patch_pc_patch_construct_dim": 0,
"fieldsplit_1_aux_mg_levels_patch_pc_patch_construct_type": "star",
"fieldsplit_1_aux_mg_levels_patch_sub_ksp_type": "preonly",
"fieldsplit_1_aux_mg_levels_patch_sub_pc_type": "svd",
"fieldsplit_1_aux_mg_levels_patch_sub_pc_factor_shift_type": "nonzero",
"fieldsplit_1_aux_mg_coarse_pc_type": "lu",
"fieldsplit_1_aux_mg_coarse_pc_factor_mat_solver_type": "mumps",
"fieldsplit_1_aux_mg_coarse_mat_mumps_icntl_14": 200,
"mat_type": "aij", # noqa: E126
"snes_type": "newtonls",
"snes_atol": 2.0e-5,
"snes_rtol": 1.0e-5,
"snes_monitor": None,
"ksp_type": "fgmres",
"ksp_norm_type": "unpreconditioned",
"ksp_monitor": None,
"ksp_converged_reason": None,
"ksp_atol": 1e-10,
"ksp_rtol": 1e-10,
"ksp_max_it": 100,
"pc_type": "fieldsplit",
"pc_fieldsplit_0_fields": "0",
"pc_fieldsplit_1_fields": "1,2",
"pc_fieldsplit_type": "schur",
"pc_fieldsplit_schur_fact_type": "full",
"pc_fieldsplit_schur_precondition": "user",
"fieldsplit_0": {
"ksp_type": "richardson",
"pc_type": "ilu",
"ksp_max_it": 1,
"ksp_convergence_test": "skip"
},
"fieldsplit_1": {
"ksp_type": "gmres",
"ksp_max_it": 1,
"ksp_convergence_test": "skip",
"ksp_monitor_true_residual": None,
"pc_type": "python",
"pc_python_type": "test_auxiliary_dm.ApproximateSchur",
"aux_pc_type": "mg",
"aux_mg_levels": {
"ksp_type": "richardson",
"ksp_richardson_scale": 1/3,
"pc_type": "python",
"pc_python_type": "firedrake.PatchPC",
"patch_pc_patch_save_operators": True,
"patch_pc_patch_partition_of_unity": False,
"patch_pc_patch_sub_mat_type": "seqdense",
"patch_pc_patch_construct_dim": 0,
"patch_pc_patch_construct_type": "star",
"patch_sub_ksp_type": "preonly",
"patch_sub_pc_type": "svd",
"patch_sub_pc_factor_shift_type": "nonzero"
},
"aux_mg_coarse_pc_type": "lu",
"aux_mg_coarse_pc_factor": DEFAULT_DIRECT_SOLVER_PARAMETERS
}
}

# Solve variational form
Expand Down
12 changes: 7 additions & 5 deletions tests/regression/test_bdmc_riesz_map.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from firedrake import *
from firedrake.petsc import DEFAULT_DIRECT_SOLVER_PARAMETERS
import pytest
import numpy

Expand All @@ -13,11 +14,12 @@ def degree(request):
return request.param


sp = {"snes_type": "ksponly",
"ksp_type": "preonly",
"pc_type": "lu",
"pc_factor_mat_solver_type": "mumps",
"mat_mumps_icntl_14": 200}
sp = {
"snes_type": "ksponly",
"ksp_type": "preonly",
"pc_type": "lu",
"pc_factor": DEFAULT_DIRECT_SOLVER_PARAMETERS
}


def error(N, problem, degree):
Expand Down
12 changes: 7 additions & 5 deletions tests/regression/test_ensembleparallelism.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from firedrake import *
from firedrake.petsc import DEFAULT_DIRECT_SOLVER_PARAMETERS
from pyop2.mpi import MPI
import pytest

Expand Down Expand Up @@ -356,11 +357,12 @@ def test_ensemble_solvers(ensemble, W, urank, urank_sum):
u_combined = Function(W)
u_separate = Function(W)

params = {'ksp_type': 'preonly',
'pc_type': 'redundant',
"redundant_pc_type": "lu",
"redundant_pc_factor_mat_solver_type": "mumps",
"redundant_mat_mumps_icntl_14": 200}
params = {
"ksp_type": "preonly",
"pc_type": "redundant",
"redundant_pc_type": "lu",
"redundant_pc_factor": DEFAULT_DIRECT_SOLVER_PARAMETERS
}

combinedProblem = LinearVariationalProblem(a, Lcombined, u_combined)
combinedSolver = LinearVariationalSolver(combinedProblem,
Expand Down
10 changes: 4 additions & 6 deletions tests/regression/test_fas_snespatch.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest
from firedrake import *
from firedrake.petsc import DEFAULT_DIRECT_SOLVER_PARAMETERS


@pytest.fixture(scope='module')
Expand Down Expand Up @@ -62,8 +63,7 @@ def solver_params(request):
"fas_coarse_pc_python_type": "firedrake.AssembledPC",
"fas_coarse_assembled_mat_type": "aij",
"fas_coarse_assembled_pc_type": "lu",
"fas_coarse_assembled_pc_factor_mat_solver_type": "mumps",
"fas_coarse_assembled_mat_mumps_icntl_14": 200,
"fas_coarse_assembled_pc_factor": DEFAULT_DIRECT_SOLVER_PARAMETERS.copy(),
"snes_view": None
}
elif request.param == 1:
Expand Down Expand Up @@ -110,8 +110,7 @@ def solver_params(request):
"fas_coarse_pc_python_type": "firedrake.AssembledPC",
"fas_coarse_assembled_mat_type": "aij",
"fas_coarse_assembled_pc_type": "lu",
"fas_coarse_assembled_pc_factor_mat_solver_type": "mumps",
"fas_coarse_assembled_mat_mumps_icntl_14": 200,
"fas_coarse_assembled_pc_factor": DEFAULT_DIRECT_SOLVER_PARAMETERS.copy(),
"snes_view": None
}
else:
Expand Down Expand Up @@ -159,8 +158,7 @@ def solver_params(request):
"fas_coarse_pc_python_type": "firedrake.AssembledPC",
"fas_coarse_assembled_mat_type": "aij",
"fas_coarse_assembled_pc_type": "lu",
"fas_coarse_assembled_pc_factor_mat_solver_type": "mumps",
"fas_coarse_assembled_mat_mumps_icntl_14": 200
"fas_coarse_assembled_pc_factor": DEFAULT_DIRECT_SOLVER_PARAMETERS.copy(),
}


Expand Down
4 changes: 3 additions & 1 deletion tests/regression/test_fdm.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import pytest
from firedrake import *
from firedrake.petsc import DEFAULT_DIRECT_SOLVER


ksp = {
"mat_type": "matfree",
Expand Down Expand Up @@ -324,7 +326,7 @@ def test_ipdg_direct_solver(fs):
"pc_type": "python",
"pc_python_type": "firedrake.PoissonFDMPC",
"fdm_pc_type": "cholesky",
"fdm_pc_factor_mat_solver_type": "mumps",
"fdm_pc_factor_mat_solver_type": DEFAULT_DIRECT_SOLVER,
"fdm_pc_factor_mat_ordering_type": "nd",
}, appctx={"eta": eta, })
solver.solve()
Expand Down
7 changes: 3 additions & 4 deletions tests/regression/test_fieldsplit_split_reorder_bcs.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pytest
import numpy
from firedrake import *
from firedrake.petsc import DEFAULT_DIRECT_SOLVER_PARAMETERS


class SchurPC(AuxiliaryOperatorPC):
Expand Down Expand Up @@ -37,8 +38,7 @@ def solver_parameters(permute):
"pc_python_type": f"{__name__}.SchurPC",
"aux_pc_mat_type": "aij",
"aux_pc_type": "lu",
"aux_pc_factor_mat_solver_type": "mumps",
"aux_mat_mumps_icntl_14": 200,
"aux_pc_factor": DEFAULT_DIRECT_SOLVER_PARAMETERS
}

return {
Expand All @@ -52,8 +52,7 @@ def solver_parameters(permute):
"pc_fieldsplit_1_fields": B,
"fieldsplit_0_ksp_type": "preonly",
"fieldsplit_0_pc_type": "lu",
"fieldsplit_0_pc_factor_mat_solver_type": "mumps",
"fieldsplit_0_mat_mumps_icntl_14": 200,
"fieldsplit_0_pc_factor": DEFAULT_DIRECT_SOLVER_PARAMETERS,
"fieldsplit_1": schurlu,
}

Expand Down
Loading

0 comments on commit ec5af85

Please sign in to comment.