Skip to content

Commit

Permalink
Merge pull request #16187 from bangerth/move
Browse files Browse the repository at this point in the history
Move things into place, rather than swap.
  • Loading branch information
drwells committed Oct 26, 2023
2 parents c741a44 + c0f8ec1 commit d2d239f
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 20 deletions.
8 changes: 4 additions & 4 deletions source/fe/fe_dgq.cc
Original file line number Diff line number Diff line change
Expand Up @@ -448,8 +448,8 @@ FE_DGQ<dim, spacedim>::get_prolongation_matrix(
FETools::compute_embedding_matrices(FE_DGQ<dim>(this->degree),
isotropic_matrices,
true);
this_nonconst.prolongation[refinement_case - 1].swap(
isotropic_matrices.back());
this_nonconst.prolongation[refinement_case - 1] =
std::move(isotropic_matrices.back());
}
else
{
Expand Down Expand Up @@ -524,8 +524,8 @@ FE_DGQ<dim, spacedim>::get_restriction_matrix(
FETools::compute_projection_matrices(FE_DGQ<dim>(this->degree),
isotropic_matrices,
true);
this_nonconst.restriction[refinement_case - 1].swap(
isotropic_matrices.back());
this_nonconst.restriction[refinement_case - 1] =
std::move(isotropic_matrices.back());
}
else
{
Expand Down
14 changes: 7 additions & 7 deletions source/fe/fe_q_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1438,9 +1438,9 @@ FE_Q_Base<dim, spacedim>::get_prolongation_matrix(
}
# endif

// swap matrices
prolongate.swap(const_cast<FullMatrix<double> &>(
this->prolongation[refinement_case - 1][child]));
// move result into place
const_cast<FullMatrix<double> &>(
this->prolongation[refinement_case - 1][child]) = std::move(prolongate);
}

// finally return the matrix
Expand Down Expand Up @@ -1581,10 +1581,10 @@ FE_Q_Base<dim, spacedim>::get_restriction_matrix(
RefinementCase<dim>(refinement_case));
}

// swap the just computed restriction matrix into the
// element of the vector stored in the base class
my_restriction.swap(const_cast<FullMatrix<double> &>(
this->restriction[refinement_case - 1][child]));
// move result into place
const_cast<FullMatrix<double> &>(
this->restriction[refinement_case - 1][child]) =
std::move(my_restriction);
}

return this->restriction[refinement_case - 1][child];
Expand Down
8 changes: 4 additions & 4 deletions source/fe/fe_raviart_thomas_nodal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -703,8 +703,8 @@ FE_RaviartThomasNodal<dim>::get_prolongation_matrix(
FullMatrix<double>(this->n_dofs_per_cell(),
this->n_dofs_per_cell()));
FETools::compute_embedding_matrices(*this, isotropic_matrices, true);
this_nonconst.prolongation[refinement_case - 1].swap(
isotropic_matrices.back());
this_nonconst.prolongation[refinement_case - 1] =
std::move(isotropic_matrices.back());
}
else
{
Expand Down Expand Up @@ -761,8 +761,8 @@ FE_RaviartThomasNodal<dim>::get_restriction_matrix(
FullMatrix<double>(this->n_dofs_per_cell(),
this->n_dofs_per_cell()));
FETools::compute_projection_matrices(*this, isotropic_matrices, true);
this_nonconst.restriction[refinement_case - 1].swap(
isotropic_matrices.back());
this_nonconst.restriction[refinement_case - 1] =
std::move(isotropic_matrices.back());
}
else
{
Expand Down
8 changes: 4 additions & 4 deletions source/fe/fe_simplex_p.cc
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,8 @@ FE_SimplexPoly<dim, spacedim>::get_prolongation_matrix(

FETools::compute_embedding_matrices(*this, isotropic_matrices, true);

this_nonconst.prolongation[refinement_case - 1].swap(
isotropic_matrices.back());
this_nonconst.prolongation[refinement_case - 1] =
std::move(isotropic_matrices.back());
}

// finally return the matrix
Expand Down Expand Up @@ -427,8 +427,8 @@ FE_SimplexPoly<dim, spacedim>::get_restriction_matrix(

FETools::compute_projection_matrices(*this, isotropic_matrices, true);

this_nonconst.restriction[refinement_case - 1].swap(
isotropic_matrices.back());
this_nonconst.restriction[refinement_case - 1] =
std::move(isotropic_matrices.back());
}

// finally return the matrix
Expand Down
3 changes: 2 additions & 1 deletion source/fe/fe_system.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2616,7 +2616,8 @@ FESystem<dim, spacedim>::get_constant_modes() const
for (unsigned int r = 0; r < comp; ++r)
for (unsigned int c = 0; c < this->n_dofs_per_cell(); ++c)
new_constant_modes(r, c) = constant_modes(r, c);
constant_modes.swap(new_constant_modes);

constant_modes = std::move(new_constant_modes);
}

// next, fill the constant modes from the individual components as well
Expand Down

0 comments on commit d2d239f

Please sign in to comment.