From 1afba9df02e36a2152c94317d74317f1fad18d1a Mon Sep 17 00:00:00 2001 From: Roy Stogner Date: Wed, 25 Feb 2026 11:59:30 -0600 Subject: [PATCH 1/4] Fix mesh preparation in misc ex15 --- .../miscellaneous/miscellaneous_ex15/miscellaneous_ex15.C | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/examples/miscellaneous/miscellaneous_ex15/miscellaneous_ex15.C b/examples/miscellaneous/miscellaneous_ex15/miscellaneous_ex15.C index 558f91947cf..c290431cf36 100644 --- a/examples/miscellaneous/miscellaneous_ex15/miscellaneous_ex15.C +++ b/examples/miscellaneous/miscellaneous_ex15/miscellaneous_ex15.C @@ -221,6 +221,10 @@ int main (int argc, char** argv) sync_obj); } + // We'll need to update caches of subdomain ids too, to keep the + // mesh prepared. + mesh.cache_elem_data(); + // Now we set the sources of the field: prism-shaped objects that are // determined here by containing certain points: auto p_pt_lctr = mesh.sub_point_locator(); From 91f139f89c6f91154f3b4aca5c7d4234fbb2c338 Mon Sep 17 00:00:00 2001 From: Roy Stogner Date: Tue, 14 Apr 2026 17:42:49 -0500 Subject: [PATCH 2/4] Handle unprepared meshes in VariationalSmoother --- src/mesh/mesh_smoother_vsmoother.C | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/mesh/mesh_smoother_vsmoother.C b/src/mesh/mesh_smoother_vsmoother.C index e4261089cf5..854b8aa4fd2 100644 --- a/src/mesh/mesh_smoother_vsmoother.C +++ b/src/mesh/mesh_smoother_vsmoother.C @@ -64,6 +64,9 @@ VariationalMeshSmoother::VariationalMeshSmoother( void VariationalMeshSmoother::setup() { // Check for multiple dimensions + if (!_mesh.preparation().has_cached_elem_data) + _mesh.cache_elem_data(); + if (_mesh.elem_dimensions().size() > 1) libmesh_not_implemented_msg("Meshes containing elements of differing dimension are not yet supported."); From d88be54df7a4d3251d52e3e9d347d7b3b7847558 Mon Sep 17 00:00:00 2001 From: Roy Stogner Date: Tue, 14 Apr 2026 17:43:57 -0500 Subject: [PATCH 3/4] Make test work w/redistribute() cache invalidation --- tests/mesh/mesh_smoother_test.C | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/mesh/mesh_smoother_test.C b/tests/mesh/mesh_smoother_test.C index e828e9f6533..7f499c97617 100644 --- a/tests/mesh/mesh_smoother_test.C +++ b/tests/mesh/mesh_smoother_test.C @@ -592,12 +592,15 @@ public: mesh.comm().sum(distorted_subdomain_volumes[sub_id]); } - - // We've just invalidated the get_mesh_subdomains() cache by - // adding a new one; fix it. - mesh.cache_elem_data(); } + // We may have just invalidated the get_mesh_subdomains() cache by + // adding a new one, and libMesh marked our spatial_dimension() + // cache as invalidated in redistribute(). Just rebuild our + // caches before we start asking for anything like + // elem_default_orders(). + mesh.cache_elem_data(); + // Get the mesh order const auto & elem_orders = mesh.elem_default_orders(); libmesh_error_msg_if(elem_orders.size() != 1, From 23a77e5e4adf5f1725b6b26958074af6c6594803 Mon Sep 17 00:00:00 2001 From: Roy Stogner Date: Mon, 27 Jul 2026 12:23:49 -0500 Subject: [PATCH 4/4] Build test mesh before trying to add vector var --- tests/mesh/mesh_input.C | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/mesh/mesh_input.C b/tests/mesh/mesh_input.C index b69dd834150..8dd2f8cbe00 100644 --- a/tests/mesh/mesh_input.C +++ b/tests/mesh/mesh_input.C @@ -888,15 +888,19 @@ public: MeshType mesh(*TestCommWorld); EquationSystems es(mesh); - System & sys = es.add_system ("SimpleSystem"); - auto e_var = sys.add_variable("e", CONSTANT, MONOMIAL_VEC); - auto e_no_p_var = sys.add_variable("e_no_p", - FEType(CONSTANT, MONOMIAL_VEC).set_p_refinement(false)); + // We need a mesh.spatial_dimension() *before* adding a + // vector-valued variable, so add_variable() can figure out how + // many components it needs. MeshTools::Generation::build_square (mesh, 3, 3, 0., 1., 0., 1.); + System & sys = es.add_system ("SimpleSystem"); + auto e_var = sys.add_variable("e", CONSTANT, MONOMIAL_VEC); + auto e_no_p_var = sys.add_variable("e_no_p", + FEType(CONSTANT, MONOMIAL_VEC).set_p_refinement(false)); + es.init(); // Here, we're going to manually set up the solution because the 'project_solution()' and