Skip to content

Commit 5fb6732

Browse files
committed
Add a test using system parameters over equation system parameters
1 parent 65da3a6 commit 5fb6732

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

tests/systems/systems_test.C

+62
Original file line numberDiff line numberDiff line change
@@ -1256,6 +1256,68 @@ public:
12561256
LIBMESH_ASSERT_FP_EQUAL(system.solution->l1_norm(), ref_l1_norm, TOLERANCE*TOLERANCE);
12571257
}
12581258

1259+
1260+
void testSetSystemParameterOverEquationSystem()
1261+
{
1262+
LOG_UNIT_TEST;
1263+
1264+
ReplicatedMesh mesh(*TestCommWorld);
1265+
1266+
MeshTools::Generation::build_cube (mesh,
1267+
1,
1268+
0,
1269+
0,
1270+
0., 1.,
1271+
0., 0.,
1272+
0., 0.,
1273+
EDGE2);
1274+
1275+
Point new_point_a(2.);
1276+
Point new_point_b(3.);
1277+
Node* new_node_a = mesh.add_point( new_point_a );
1278+
Node* new_node_b = mesh.add_point( new_point_b );
1279+
auto new_edge_elem = mesh.add_elem(Elem::build(EDGE2));
1280+
new_edge_elem->set_node(0) = new_node_a;
1281+
new_edge_elem->set_node(1) = new_node_b;
1282+
1283+
mesh.elem_ref(0).subdomain_id() = 10;
1284+
mesh.elem_ref(1).subdomain_id() = 10;
1285+
1286+
mesh.prepare_for_use();
1287+
1288+
// Create an equation systems object.
1289+
EquationSystems equation_systems (mesh);
1290+
LinearImplicitSystem & system =
1291+
equation_systems.add_system<LinearImplicitSystem> ("test");
1292+
1293+
system.add_variable ("u", libMesh::FIRST);
1294+
system.add_variable ("v", libMesh::FIRST);
1295+
system.add_variable ("w", libMesh::FIRST);
1296+
1297+
system.attach_assemble_function (assemble_matrix_and_rhs);
1298+
1299+
// LASPACK GMRES + ILU defaults don't like this problem, but it's
1300+
// small enough to just use a simpler iteration.
1301+
system.get_linear_solver()->set_solver_type(JACOBI);
1302+
system.get_linear_solver()->set_preconditioner_type(IDENTITY_PRECOND);
1303+
1304+
// Set some parameters to the equation system that would cause a failed solve
1305+
equation_systems.parameters.set<unsigned int>("nonlinear solver maximum iterations") = 0;
1306+
1307+
// Set some parameters to the system that work for the solve
1308+
system.parameters.set<unsigned int>("nonlinear solver maximum iterations") = 100;
1309+
1310+
// See the solve pass, indicating system parameters are used over equation system parameters
1311+
equation_systems.init ();
1312+
system.solve();
1313+
1314+
// We set the solution to be 1 everywhere, so the final l1 norm of the
1315+
// solution is the product of the number of variables and number of nodes.
1316+
Real ref_l1_norm = static_cast<Real>(mesh.n_nodes() * system.n_vars());
1317+
1318+
LIBMESH_ASSERT_FP_EQUAL(system.solution->l1_norm(), ref_l1_norm, TOLERANCE*TOLERANCE);
1319+
}
1320+
12591321
void testAssemblyWithDgFemContext()
12601322
{
12611323
LOG_UNIT_TEST;

0 commit comments

Comments
 (0)