Skip to content

Commit ccb56d5

Browse files
authored
Merge pull request #31784 from YaqiWang/minor_position_eeid_fix
Excluding invalid ids when generating positions with an EEID
2 parents 853d1ff + ff24278 commit ccb56d5

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

framework/include/positions/ElementGroupCentroidPositions.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ class ElementGroupCentroidPositions : public Positions, public BlockRestrictable
4444
/// The indices of the extra element ids to use to make groups
4545
std::vector<unsigned int> _extra_id_indices;
4646
/// The particular extra id values, for each extra id of interest
47-
std::vector<std::vector<unsigned int>> _extra_id_group_indices;
47+
std::vector<std::vector<dof_id_type>> _extra_id_group_indices;
4848

4949
private:
50-
unsigned int id(const Elem & elem, unsigned int id_index, bool use_subdomains);
50+
dof_id_type id(const Elem & elem, unsigned int id_index, bool use_subdomains);
5151
};

framework/src/positions/ElementGroupCentroidPositions.C

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ ElementGroupCentroidPositions::validParams()
2525
params.addParam<MooseEnum>("grouping_type", groupTypeEnum(), "Type of group of elements");
2626
params.addParam<std::vector<ExtraElementIDName>>("extra_id_name",
2727
"Name(s) of the extra element ID(s) to use");
28-
params.addParam<std::vector<std::vector<unsigned int>>>(
28+
params.addParam<std::vector<std::vector<dof_id_type>>>(
2929
"extra_id",
3030
"Specific ID(s), for each extra id name, for grouping elements. "
3131
"If empty, all *valid* ids will be used to bin");
@@ -52,7 +52,7 @@ ElementGroupCentroidPositions::ElementGroupCentroidPositions(const InputParamete
5252
_extra_id_indices.push_back(_mesh.getMesh().get_elem_integer_index(name));
5353

5454
if (isParamValid("extra_id"))
55-
_extra_id_group_indices = getParam<std::vector<std::vector<unsigned int>>>("extra_id");
55+
_extra_id_group_indices = getParam<std::vector<std::vector<dof_id_type>>>("extra_id");
5656
else
5757
_extra_id_group_indices.resize(_extra_id_names.size());
5858

@@ -81,7 +81,7 @@ ElementGroupCentroidPositions::ElementGroupCentroidPositions(const InputParamete
8181
_blocks_in_use = true;
8282
_extra_id_names.insert(_extra_id_names.begin(), "block");
8383
_extra_id_indices.insert(_extra_id_indices.begin(), std::numeric_limits<unsigned short>::max());
84-
_extra_id_group_indices.insert(_extra_id_group_indices.begin(), std::vector<unsigned int>());
84+
_extra_id_group_indices.insert(_extra_id_group_indices.begin(), std::vector<dof_id_type>());
8585
// Add real block restriction
8686
if (blockRestricted())
8787
for (const auto & block : blockIDs())
@@ -113,9 +113,13 @@ ElementGroupCentroidPositions::initialize()
113113
auto & indices = _extra_id_group_indices[i];
114114
if (indices.empty())
115115
{
116-
std::set<unsigned int> ids;
116+
std::set<dof_id_type> ids;
117117
for (const auto & elem : _mesh.getMesh().active_local_element_ptr_range())
118-
ids.insert(id(*elem, _extra_id_indices[i], _blocks_in_use && i == 0));
118+
{
119+
auto eeid = id(*elem, _extra_id_indices[i], _blocks_in_use && i == 0);
120+
if (eeid != DofObject::invalid_id)
121+
ids.insert(eeid);
122+
}
119123
_mesh.comm().set_union(ids);
120124
for (const auto & id : ids)
121125
indices.push_back(id);
@@ -373,7 +377,7 @@ ElementGroupCentroidPositions::initialize()
373377
_initialized = true;
374378
}
375379

376-
unsigned int
380+
dof_id_type
377381
ElementGroupCentroidPositions::id(const Elem & elem, unsigned int id_index, bool use_subdomains)
378382
{
379383
mooseAssert(!use_subdomains || (id_index == std::numeric_limits<unsigned short>::max()),

0 commit comments

Comments
 (0)