Skip to content
Snippets Groups Projects
Commit 824b8842 authored by Dmitri Naumov's avatar Dmitri Naumov Committed by Dmitri Naumov
Browse files

[NL] LeastSqExt: Fix global vector creation.

Especially the creation of ghost nodes.
parent ad5723d8
No related branches found
No related tags found
No related merge requests found
......@@ -47,12 +47,39 @@ void LocalLinearLeastSquaresExtrapolator::extrapolate(
{
auto const num_nodal_dof_result =
_dof_table_single_component.dofSizeWithoutGhosts() * num_components;
std::vector<GlobalIndexType> ghost_indices;
{ // Create num_components times version of ghost_indices arranged by
// location. For example for 3 components and ghost_indices {5,6,10} we
// compute {15, 16, 17, 18, 19, 20, 30, 31, 32}.
auto const& single_component_ghost_indices =
_dof_table_single_component.getGhostIndices();
auto const single_component_ghost_indices_size =
single_component_ghost_indices.size();
ghost_indices.reserve(single_component_ghost_indices_size *
num_components);
for (unsigned i = 0; i < single_component_ghost_indices_size; ++i)
{
for (unsigned c = 0; c < num_components; ++c)
{
ghost_indices.push_back(
single_component_ghost_indices[i] * num_components + c);
}
}
}
if (!_nodal_values ||
static_cast<std::size_t>(_nodal_values->size()) != num_nodal_dof_result)
#ifdef USE_PETSC
static_cast<std::size_t>(_nodal_values->getLocalSize() +
_nodal_values->getGhostSize())
#else
_nodal_values->size()
#endif
!= num_nodal_dof_result)
{
_nodal_values = MathLib::MatrixVectorTraits<GlobalVector>::newInstance(
MathLib::MatrixSpecifications{
num_nodal_dof_result, num_nodal_dof_result, nullptr, nullptr});
{num_nodal_dof_result, num_nodal_dof_result, &ghost_indices,
nullptr});
}
_nodal_values->setZero();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment