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

Add an assertion for p4est weights. #13448

Merged
merged 2 commits into from
Feb 26, 2022
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
13 changes: 11 additions & 2 deletions source/distributed/tria.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1508,8 +1508,17 @@ namespace
Assert(this_object->current_pointer < this_object->cell_weights_list.end(),
ExcInternalError());

// get the weight, increment the pointer, and return the weight
return *this_object->current_pointer++;
// Get the weight, increment the pointer, and return the weight. Also
// make sure that we don't exceed the 'int' data type that p4est uses
// to represent weights
const unsigned int weight = *this_object->current_pointer;
++this_object->current_pointer;

Assert(weight < std::numeric_limits<int>::max(),
ExcMessage("p4est uses 'signed int' to represent the partition "
"weights for cells. The weight provided here exceeds "
"the maximum value represented as a 'signed int'."));
return static_cast<int>(weight);
}

template <int dim, int spacedim>
Expand Down