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 dof_accessor warning #10788

Merged
merged 2 commits into from Aug 2, 2020
Merged

fix dof_accessor warning #10788

merged 2 commits into from Aug 2, 2020

Conversation

tjhei
Copy link
Member

@tjhei tjhei commented Aug 1, 2020

fixes:

/jenkins/workspace/dealii_PR-10786/include/deal.II/base/exceptions.h:1414:72:
error: ‘fe_index_’ may be used uninitialized in this function [-Werror
=maybe-uninitialized]
/jenkins/workspace/dealii_PR-10786/include/deal.II/dofs/dof_accessor.templates.h:284:22:
note: ‘fe_index_’ was declared here

part of #10786

fixes:
```
/jenkins/workspace/dealii_PR-10786/include/deal.II/base/exceptions.h:1414:72:
error: ‘fe_index_’ may be used uninitialized in this function [-Werror
=maybe-uninitialized]
/jenkins/workspace/dealii_PR-10786/include/deal.II/dofs/dof_accessor.templates.h:284:22:
note: ‘fe_index_’ was declared here
```

if (dof_handler.hp_capability_enabled)
Copy link
Member Author

Choose a reason for hiding this comment

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

this if is redundant because we exit a couple of lines above otherwise.

Copy link
Member

@peterrum peterrum left a comment

Choose a reason for hiding this comment

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

I am pretty sure that did what you did once. Maybe locally!?

dof_handler.hp_object_fe_ptr[d][obj_index],
ptr);
}
fe_index_ =
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
fe_index_ =
unsigned int fe_index_ =

@peterrum
Copy link
Member

peterrum commented Aug 1, 2020

OK. I did it here:

template <int dim, int spacedim, int d>
static std::pair<unsigned int, unsigned int>
process_object_range(const DoFHandler<dim, spacedim> &dof_handler,
const unsigned int obj_level,
const unsigned int obj_index,
const unsigned int fe_index,
const std::integral_constant<int, d> &)
{
Assert(d == dim || obj_level == 0, ExcNotImplemented());
// determine range of dofs in global data structure
// 1) cell
if (d == dim)
{
const unsigned int ptr_0 =
dof_handler.object_dof_ptr[obj_level][d][obj_index];
const unsigned int ptr_1 =
ptr_0 +
dof_handler.get_fe(fe_index).template n_dofs_per_object<dim>();
return {ptr_0, ptr_1};
}
// 2) hp is not used -> fe_index == 0
if (dof_handler.hp_capability_enabled == false)
{
AssertDimension(fe_index,
(DoFHandler<dim, spacedim>::default_fe_index));
// vertex -> no pointers are saved
if (d == 0)
{
const unsigned int ptr_0 =
obj_index * dof_handler.get_fe().n_dofs_per_vertex();
const unsigned int ptr_1 =
ptr_0 + dof_handler.get_fe().n_dofs_per_vertex();
return {ptr_0, ptr_1};
}
else // line or quad
{
const unsigned int ptr_0 =
dof_handler.object_dof_ptr[obj_level][d][obj_index];
const unsigned int ptr_1 =
dof_handler.object_dof_ptr[obj_level][d][obj_index + 1];
return {ptr_0, ptr_1};
}
}
// 3) hp is used
AssertIndexRange(obj_level, dof_handler.object_dof_indices.size());
AssertIndexRange(d, dof_handler.object_dof_indices[obj_level].size());
AssertIndexRange(d, dof_handler.hp_object_fe_ptr.size());
AssertIndexRange(obj_index, dof_handler.hp_object_fe_ptr[d].size());
const auto fe_index_local_ptr =
std::find(dof_handler.hp_object_fe_indices[d].begin() +
dof_handler.hp_object_fe_ptr[d][obj_index],
dof_handler.hp_object_fe_indices[d].begin() +
dof_handler.hp_object_fe_ptr[d][obj_index + 1],
fe_index);
Assert(fe_index_local_ptr !=
dof_handler.hp_object_fe_indices[d].begin() +
dof_handler.hp_object_fe_ptr[d][obj_index + 1],
ExcNotImplemented());
const unsigned int fe_index_local =
std::distance(dof_handler.hp_object_fe_indices[d].begin() +
dof_handler.hp_object_fe_ptr[d][obj_index],
fe_index_local_ptr);
AssertIndexRange(dof_handler.hp_object_fe_ptr[d][obj_index] +
fe_index_local,
dof_handler.object_dof_ptr[obj_level][d].size());
const unsigned int ptr_0 =
dof_handler
.object_dof_ptr[obj_level][d]
[dof_handler.hp_object_fe_ptr[d][obj_index] +
fe_index_local];
const unsigned int ptr_1 =
dof_handler
.object_dof_ptr[obj_level][d]
[dof_handler.hp_object_fe_ptr[d][obj_index] +
fe_index_local + 1];
return {ptr_0, ptr_1};
}

Copy link
Member

@bangerth bangerth left a comment

Choose a reason for hiding this comment

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

OK with the one change.

include/deal.II/dofs/dof_accessor.templates.h Outdated Show resolved Hide resolved
@masterleinad
Copy link
Member

/rebuild

@peterrum peterrum merged commit b845097 into dealii:master Aug 2, 2020
@tjhei tjhei deleted the fe_index_unused branch August 2, 2020 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants