From 9baf7d4be663bc20addf18f5ceacbffebe815d9c Mon Sep 17 00:00:00 2001 From: podlesny <podlesny@zedat.fu-berlin.de> Date: Fri, 26 Feb 2021 15:25:50 +0100 Subject: [PATCH] fixed bodyIdx computation and offSet, needs testing --- .../friction/globalratestatefriction.hh | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/dune/tectonic/data-structures/friction/globalratestatefriction.hh b/dune/tectonic/data-structures/friction/globalratestatefriction.hh index 4663d516..395edd2e 100644 --- a/dune/tectonic/data-structures/friction/globalratestatefriction.hh +++ b/dune/tectonic/data-structures/friction/globalratestatefriction.hh @@ -36,11 +36,12 @@ class GlobalRateStateFriction : public GlobalFriction<Matrix, Vector> { using ContactCoupling = DualMortarCoupling<field_type, GridType>; size_t bodyIndex(const size_t globalIdx) { - size_t i=0; + size_t i = offSet_.size()-1; - for (; i<offSet_.size()-1; i++) { - if (globalIdx < offSet_[i]) + for (; i>0; ) { + if (globalIdx >= offSet_[i]) break; + i--; } return i; } @@ -58,7 +59,7 @@ class GlobalRateStateFriction : public GlobalFriction<Matrix, Vector> { const auto nBodies = weights.size(); offSet_.resize(nBodies, 0); for (size_t i=1; i<nBodies; i++) { - offSet_[i] = weights[i-1].size(); + offSet_[i] = offSet_[i-1] + weights[i-1].size(); } std::vector<std::vector<int>> nonmortarBodies(nBodies); // first index body, second index coupling @@ -97,16 +98,12 @@ class GlobalRateStateFriction : public GlobalFriction<Matrix, Vector> { } void updateAlpha(const std::vector<ScalarVector>& alpha) override { + //print(alpha, "alpha"); for (size_t j = 0; j < restrictions_.size(); ++j) { const auto globalDof = localToGlobal_[j]; const auto bodyIdx = bodyIndex(globalDof); + size_t bodyDof = globalDof - offSet_[bodyIdx]; - size_t bodyDof; - if (bodyIdx>0) { - bodyDof = globalDof - offSet_[bodyIdx-1]; - } else { - bodyDof = globalDof; - } restrictions_[j].updateAlpha(alpha[bodyIdx][bodyDof]); } } -- GitLab