From af925a45978b7bfda49054016e7a420d1a6f3d95 Mon Sep 17 00:00:00 2001 From: Jean-Paul Pelteret Date: Wed, 29 Apr 2020 22:54:30 +0200 Subject: [PATCH] Update physics tests to use cell DoF range based loop --- tests/physics/step-18-rotation_matrix.cc | 6 +++--- tests/physics/step-18.cc | 6 +++--- ...ep-44-standard_tensors-material_push_forward.cc | 14 ++++++++------ tests/physics/step-44-standard_tensors-spatial.cc | 14 ++++++++------ tests/physics/step-44.cc | 14 ++++++++------ 5 files changed, 30 insertions(+), 24 deletions(-) diff --git a/tests/physics/step-18-rotation_matrix.cc b/tests/physics/step-18-rotation_matrix.cc index 9fce0e15a6..5449d1b3d6 100644 --- a/tests/physics/step-18-rotation_matrix.cc +++ b/tests/physics/step-18-rotation_matrix.cc @@ -400,8 +400,8 @@ namespace Step18 cell_matrix = 0; cell_rhs = 0; fe_values.reinit(cell); - for (unsigned int i = 0; i < dofs_per_cell; ++i) - for (unsigned int j = 0; j < dofs_per_cell; ++j) + for (const unsigned int i : fe_values.dof_indices()) + for (const unsigned int j : fe_values.dof_indices()) for (const unsigned int q_point : fe_values.quadrature_point_indices()) { @@ -415,7 +415,7 @@ namespace Step18 reinterpret_cast *>(cell->user_pointer()); body_force.vector_value_list(fe_values.get_quadrature_points(), body_force_values); - for (unsigned int i = 0; i < dofs_per_cell; ++i) + for (const unsigned int i : fe_values.dof_indices()) { const unsigned int component_i = fe.system_to_component_index(i).first; diff --git a/tests/physics/step-18.cc b/tests/physics/step-18.cc index cdda878fa0..82b686ba29 100644 --- a/tests/physics/step-18.cc +++ b/tests/physics/step-18.cc @@ -416,8 +416,8 @@ namespace Step18 cell_matrix = 0; cell_rhs = 0; fe_values.reinit(cell); - for (unsigned int i = 0; i < dofs_per_cell; ++i) - for (unsigned int j = 0; j < dofs_per_cell; ++j) + for (const unsigned int i : fe_values.dof_indices()) + for (const unsigned int j : fe_values.dof_indices()) for (const unsigned int q_point : fe_values.quadrature_point_indices()) { @@ -431,7 +431,7 @@ namespace Step18 reinterpret_cast *>(cell->user_pointer()); body_force.vector_value_list(fe_values.get_quadrature_points(), body_force_values); - for (unsigned int i = 0; i < dofs_per_cell; ++i) + for (const unsigned int i : fe_values.dof_indices()) { const unsigned int component_i = fe.system_to_component_index(i).first; diff --git a/tests/physics/step-44-standard_tensors-material_push_forward.cc b/tests/physics/step-44-standard_tensors-material_push_forward.cc index ddff955d07..f8c4189312 100644 --- a/tests/physics/step-44-standard_tensors-material_push_forward.cc +++ b/tests/physics/step-44-standard_tensors-material_push_forward.cc @@ -1697,12 +1697,13 @@ namespace Step44 scratch.symm_grad_Nx[q_point]; const std::vector> &grad_Nx = scratch.grad_Nx[q_point]; const double JxW = scratch.fe_values_ref.JxW(q_point); - for (unsigned int i = 0; i < dofs_per_cell; ++i) + for (const unsigned int i : scratch.fe_values_ref.dof_indices()) { const unsigned int component_i = fe.system_to_component_index(i).first; const unsigned int i_group = fe.system_to_base_index(i).first.first; - for (unsigned int j = 0; j <= i; ++j) + for (const unsigned int j : + scratch.fe_values_ref.dof_indices_ending_at(i)) { const unsigned int component_j = fe.system_to_component_index(j).first; @@ -1736,8 +1737,9 @@ namespace Step44 } } } - for (unsigned int i = 0; i < dofs_per_cell; ++i) - for (unsigned int j = i + 1; j < dofs_per_cell; ++j) + for (const unsigned int i : scratch.fe_values_ref.dof_indices()) + for (const unsigned int j : + scratch.fe_values_ref.dof_indices_starting_at(i + 1)) data.cell_matrix(i, j) = data.cell_matrix(j, i); } template @@ -1820,7 +1822,7 @@ namespace Step44 const std::vector> &symm_grad_Nx = scratch.symm_grad_Nx[q_point]; const double JxW = scratch.fe_values_ref.JxW(q_point); - for (unsigned int i = 0; i < dofs_per_cell; ++i) + for (const unsigned int i : scratch.fe_values_ref.dof_indices()) { const unsigned int i_group = fe.system_to_base_index(i).first.first; if (i_group == u_dof) @@ -1848,7 +1850,7 @@ namespace Step44 const double time_ramp = (time.current() / time.end()); const double pressure = p0 * parameters.p_p0 * time_ramp; const Tensor<1, dim> traction = pressure * N; - for (unsigned int i = 0; i < dofs_per_cell; ++i) + for (const unsigned int i : scratch.fe_values_ref.dof_indices()) { const unsigned int i_group = fe.system_to_base_index(i).first.first; diff --git a/tests/physics/step-44-standard_tensors-spatial.cc b/tests/physics/step-44-standard_tensors-spatial.cc index ac83a20a5d..b5799bbf95 100644 --- a/tests/physics/step-44-standard_tensors-spatial.cc +++ b/tests/physics/step-44-standard_tensors-spatial.cc @@ -1497,12 +1497,13 @@ namespace Step44 scratch.symm_grad_Nx[q_point]; const std::vector> &grad_Nx = scratch.grad_Nx[q_point]; const double JxW = scratch.fe_values_ref.JxW(q_point); - for (unsigned int i = 0; i < dofs_per_cell; ++i) + for (const unsigned int i : scratch.fe_values_ref.dof_indices()) { const unsigned int component_i = fe.system_to_component_index(i).first; const unsigned int i_group = fe.system_to_base_index(i).first.first; - for (unsigned int j = 0; j <= i; ++j) + for (const unsigned int j : + scratch.fe_values_ref.dof_indices_ending_at(i)) { const unsigned int component_j = fe.system_to_component_index(j).first; @@ -1536,8 +1537,9 @@ namespace Step44 } } } - for (unsigned int i = 0; i < dofs_per_cell; ++i) - for (unsigned int j = i + 1; j < dofs_per_cell; ++j) + for (const unsigned int i : scratch.fe_values_ref.dof_indices()) + for (const unsigned int j : + scratch.fe_values_ref.dof_indices_starting_at(i + 1)) data.cell_matrix(i, j) = data.cell_matrix(j, i); } template @@ -1620,7 +1622,7 @@ namespace Step44 const std::vector> &symm_grad_Nx = scratch.symm_grad_Nx[q_point]; const double JxW = scratch.fe_values_ref.JxW(q_point); - for (unsigned int i = 0; i < dofs_per_cell; ++i) + for (const unsigned int i : scratch.fe_values_ref.dof_indices()) { const unsigned int i_group = fe.system_to_base_index(i).first.first; if (i_group == u_dof) @@ -1648,7 +1650,7 @@ namespace Step44 const double time_ramp = (time.current() / time.end()); const double pressure = p0 * parameters.p_p0 * time_ramp; const Tensor<1, dim> traction = pressure * N; - for (unsigned int i = 0; i < dofs_per_cell; ++i) + for (const unsigned int i : scratch.fe_values_ref.dof_indices()) { const unsigned int i_group = fe.system_to_base_index(i).first.first; diff --git a/tests/physics/step-44.cc b/tests/physics/step-44.cc index 0cbbecb2fb..9c1dd702d8 100644 --- a/tests/physics/step-44.cc +++ b/tests/physics/step-44.cc @@ -1510,12 +1510,13 @@ namespace Step44 scratch.symm_grad_Nx[q_point]; const std::vector> &grad_Nx = scratch.grad_Nx[q_point]; const double JxW = scratch.fe_values_ref.JxW(q_point); - for (unsigned int i = 0; i < dofs_per_cell; ++i) + for (const unsigned int i : scratch.fe_values_ref.dof_indices()) { const unsigned int component_i = fe.system_to_component_index(i).first; const unsigned int i_group = fe.system_to_base_index(i).first.first; - for (unsigned int j = 0; j <= i; ++j) + for (const unsigned int j : + scratch.fe_values_ref.dof_indices_ending_at(i)) { const unsigned int component_j = fe.system_to_component_index(j).first; @@ -1547,8 +1548,9 @@ namespace Step44 } } } - for (unsigned int i = 0; i < dofs_per_cell; ++i) - for (unsigned int j = i + 1; j < dofs_per_cell; ++j) + for (const unsigned int i : scratch.fe_values_ref.dof_indices()) + for (const unsigned int j : + scratch.fe_values_ref.dof_indices_starting_at(i + 1)) data.cell_matrix(i, j) = data.cell_matrix(j, i); } template @@ -1631,7 +1633,7 @@ namespace Step44 const std::vector> &symm_grad_Nx = scratch.symm_grad_Nx[q_point]; const double JxW = scratch.fe_values_ref.JxW(q_point); - for (unsigned int i = 0; i < dofs_per_cell; ++i) + for (const unsigned int i : scratch.fe_values_ref.dof_indices()) { const unsigned int i_group = fe.system_to_base_index(i).first.first; if (i_group == u_dof) @@ -1659,7 +1661,7 @@ namespace Step44 const double time_ramp = (time.current() / time.end()); const double pressure = p0 * parameters.p_p0 * time_ramp; const Tensor<1, dim> traction = pressure * N; - for (unsigned int i = 0; i < dofs_per_cell; ++i) + for (const unsigned int i : scratch.fe_values_ref.dof_indices()) { const unsigned int i_group = fe.system_to_base_index(i).first.first; -- 2.39.5