Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix do_reinit of FEPointEvaluation for empty unit_points #15176

Merged
merged 1 commit into from
May 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 12 additions & 7 deletions include/deal.II/matrix_free/fe_point_evaluation.h
Original file line number Diff line number Diff line change
Expand Up @@ -1495,8 +1495,18 @@ FEPointEvaluation<n_components, dim, spacedim, Number>::do_reinit()
current_face_number);

const_cast<unsigned int &>(n_q_points) =
n_q_points_scalar / n_lanes_user_interface +
(n_q_points_scalar % n_lanes_user_interface > 0 ? 1 : 0);
(n_q_points_scalar + n_lanes_user_interface - 1) / n_lanes_user_interface;

if (update_flags & update_values)
values.resize(n_q_points, numbers::signaling_nan<value_type>());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resize() and not assign is wanted? It feels odd that only the new entries are set to nan.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If at all possible, I would avoid using assign at least in release mode, because these operations are not for free. When resizing, we have no other choice, but for the remaining entries we should not.

if (update_flags & update_gradients)
gradients.resize(n_q_points, numbers::signaling_nan<gradient_type>());

if (n_q_points == 0)
{
is_reinitialized = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The early return looks not correct. All the pointers should be set nullptr.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, they should be set nullptr and then we return early.

return;
}

// set unit point pointer
const unsigned int unit_point_offset =
Expand All @@ -1521,11 +1531,6 @@ FEPointEvaluation<n_components, dim, spacedim, Number>::do_reinit()
if (update_flags_mapping & UpdateFlags::update_JxW_values)
JxW_ptr = mapping_info->get_JxW(data_offset);

if (update_flags & update_values)
values.resize(n_q_points, numbers::signaling_nan<value_type>());
if (update_flags & update_gradients)
gradients.resize(n_q_points, numbers::signaling_nan<gradient_type>());

if (fast_path && !polynomials_are_hat_functions)
{
const std::size_t n_batches =
Expand Down