From 824b8842861767115cbfc09c9a1b3596ef1b96d4 Mon Sep 17 00:00:00 2001 From: Dmitri Naumov <dmitri.naumov@ufz.de> Date: Tue, 20 Feb 2018 17:56:53 +0100 Subject: [PATCH] [NL] LeastSqExt: Fix global vector creation. Especially the creation of ghost nodes. --- .../LocalLinearLeastSquaresExtrapolator.cpp | 33 +++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/NumLib/Extrapolation/LocalLinearLeastSquaresExtrapolator.cpp b/NumLib/Extrapolation/LocalLinearLeastSquaresExtrapolator.cpp index 9800d5b3423..656051d76b5 100644 --- a/NumLib/Extrapolation/LocalLinearLeastSquaresExtrapolator.cpp +++ b/NumLib/Extrapolation/LocalLinearLeastSquaresExtrapolator.cpp @@ -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(); -- GitLab