Skip to content
Snippets Groups Projects
Commit 9baf7d4b authored by podlesny's avatar podlesny
Browse files

fixed bodyIdx computation and offSet, needs testing

parent 4122a70d
No related branches found
No related tags found
No related merge requests found
...@@ -36,11 +36,12 @@ class GlobalRateStateFriction : public GlobalFriction<Matrix, Vector> { ...@@ -36,11 +36,12 @@ class GlobalRateStateFriction : public GlobalFriction<Matrix, Vector> {
using ContactCoupling = DualMortarCoupling<field_type, GridType>; using ContactCoupling = DualMortarCoupling<field_type, GridType>;
size_t bodyIndex(const size_t globalIdx) { size_t bodyIndex(const size_t globalIdx) {
size_t i=0; size_t i = offSet_.size()-1;
for (; i<offSet_.size()-1; i++) { for (; i>0; ) {
if (globalIdx < offSet_[i]) if (globalIdx >= offSet_[i])
break; break;
i--;
} }
return i; return i;
} }
...@@ -58,7 +59,7 @@ class GlobalRateStateFriction : public GlobalFriction<Matrix, Vector> { ...@@ -58,7 +59,7 @@ class GlobalRateStateFriction : public GlobalFriction<Matrix, Vector> {
const auto nBodies = weights.size(); const auto nBodies = weights.size();
offSet_.resize(nBodies, 0); offSet_.resize(nBodies, 0);
for (size_t i=1; i<nBodies; i++) { 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 std::vector<std::vector<int>> nonmortarBodies(nBodies); // first index body, second index coupling
...@@ -97,16 +98,12 @@ class GlobalRateStateFriction : public GlobalFriction<Matrix, Vector> { ...@@ -97,16 +98,12 @@ class GlobalRateStateFriction : public GlobalFriction<Matrix, Vector> {
} }
void updateAlpha(const std::vector<ScalarVector>& alpha) override { void updateAlpha(const std::vector<ScalarVector>& alpha) override {
//print(alpha, "alpha");
for (size_t j = 0; j < restrictions_.size(); ++j) { for (size_t j = 0; j < restrictions_.size(); ++j) {
const auto globalDof = localToGlobal_[j]; const auto globalDof = localToGlobal_[j];
const auto bodyIdx = bodyIndex(globalDof); 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]); restrictions_[j].updateAlpha(alpha[bodyIdx][bodyDof]);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment