Skip to content

Commit 40c3658

Browse files
committed
Fix ExactSolution refactor w/unused context FEs
We were hitting this case with adaptivity_ex4 in our "zero_sol" code, and though that's probably not a great way for that example to calculate norms it's also not something we want to break, especially because the same bug might affect the fine-system code path too.
1 parent 8f68aa8 commit 40c3658

1 file changed

Lines changed: 19 additions & 3 deletions

File tree

src/error_estimation/exact_solution.C

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,9 @@ void ExactSolution::_compute_error(std::string_view sys_name,
578578
coarse_values->init();
579579
}
580580

581+
// Grab which element dimensions are present in the mesh
582+
const std::set<unsigned char> & elem_dims = mesh.elem_dimensions();
583+
581584
// Initialize any functors we're going to use
582585
for (auto & ev : _exact_values)
583586
if (ev)
@@ -600,12 +603,25 @@ void ExactSolution::_compute_error(std::string_view sys_name,
600603
eh->init_context(context);
601604
}
602605

606+
// If we have *no* functors we intend to use (because we're using a
607+
// fine system, or because our exact solution is zero and we're just
608+
// computing norms in an outdated way) then let our FE objects know
609+
// we don't actually need anything from them, so they don't think
610+
// we've just invoked them in a deprecated "compute everything"
611+
// fashion.
612+
if (_exact_values.empty() && _exact_derivs.empty() &&
613+
_exact_hessians.empty())
614+
for (auto dim : elem_dims)
615+
for (auto v : make_range(computed_system.n_vars()))
616+
{
617+
FEAbstract * fe;
618+
context.get_element_fe(v, fe, dim);
619+
fe->get_nothing();
620+
}
621+
603622
// Get a reference to the dofmap and mesh for that system
604623
const DofMap & computed_dof_map = computed_system.get_dof_map();
605624

606-
// Grab which element dimensions are present in the mesh
607-
const std::set<unsigned char> & elem_dims = mesh.elem_dimensions();
608-
609625
// Zero the error before summation
610626
// 0 - sum of square of function error (L2)
611627
// 1 - sum of square of gradient error (H1 semi)

0 commit comments

Comments
 (0)