From 49d5b5e9f28d778a4617d2d1419e80ba4d5ae0e7 Mon Sep 17 00:00:00 2001
From: Elias Pipping <elias.pipping@fu-berlin.de>
Date: Fri, 12 Oct 2012 16:03:16 +0200
Subject: [PATCH] Allow the normal stress to be adjusted dynamically

---
 src/one-body-sample.cc     | 18 ++++++++++++++++++
 src/one-body-sample.parset |  2 ++
 2 files changed, 20 insertions(+)

diff --git a/src/one-body-sample.cc b/src/one-body-sample.cc
index e7b1074c..c33bb2c9 100644
--- a/src/one-body-sample.cc
+++ b/src/one-body-sample.cc
@@ -51,6 +51,8 @@
 #include <dune/fufem/assemblers/localassemblers/stvenantkirchhoffassembler.hh>
 #include <dune/fufem/assemblers/localassemblers/vonmisesstressassembler.hh>
 #include <dune/fufem/assemblers/operatorassembler.hh>
+#include <dune/fufem/boundarypatch.hh>
+#include <dune/fufem/computestress.hh>
 #include <dune/fufem/dunepython.hh>
 #include <dune/fufem/functions/basisgridfunction.hh>
 #include <dune/fufem/functions/constantfunction.hh>
@@ -241,6 +243,7 @@ int main(int argc, char *argv[]) {
     auto const nodalIntegrals =
         assemble_frictional<GridType, GridView, SmallVector, P1Basis>(
             leafView, p1Basis, frictionalNodes);
+    BoundaryPatch<GridView> const frictionalBoundary(leafView, frictionalNodes);
 
     // {{{ Initialise vectors
     VectorType u(finestSize);
@@ -367,6 +370,21 @@ int main(int argc, char *argv[]) {
           timeSteppingScheme->extractDisplacement(u);
           timeSteppingScheme->extractVelocity(ud);
 
+          // Update the normal stress
+          if (parset.get<bool>("updateNormalStress")) {
+            VectorType tmp(finestSize);
+            Stress<GridView>::getElasticSurfaceNormalStress(frictionalBoundary,
+                                                            u, tmp, E, nu);
+            for (size_t i = 0; i < frictionalNodes.size(); ++i)
+              if (frictionalNodes[i][0]) {
+                if (tmp[i][1] < 0) {
+                  DUNE_THROW(Dune::Exception,
+                             "Encountered negative normal stress");
+                } else
+                  surfaceNormalStress[i] = tmp[i][1];
+              }
+          }
+
           // Update the state
           for (size_t i = 0; i < frictionalNodes.size(); ++i) {
             if (frictionalNodes[i][0]) {
diff --git a/src/one-body-sample.parset b/src/one-body-sample.parset
index e24da9d6..d19c9673 100644
--- a/src/one-body-sample.parset
+++ b/src/one-body-sample.parset
@@ -10,6 +10,8 @@ enableTimer = false
 
 timeSteppingScheme = implicitEuler
 
+updateNormalStress = false
+
 [grid]
 refinements = 4
 
-- 
GitLab