From ede0268da3c53104a785c605f82cc453c143c7f9 Mon Sep 17 00:00:00 2001
From: Oliver Sander <sander@igpm.rwth-aachen.de>
Date: Tue, 17 Jun 2014 18:22:15 +0000
Subject: [PATCH] Get the initial deformation from a python lambda

[[Imported from SVN: r9797]]
---
 cosserat-continuum-twisted-strip.parset       |  3 +++
 ...continuum-wong-pellegrino-wrinkling.parset |  3 +++
 cosserat-continuum-wriggers-l-shape.parset    |  2 ++
 cosserat-continuum.cc                         | 21 ++++---------------
 4 files changed, 12 insertions(+), 17 deletions(-)

diff --git a/cosserat-continuum-twisted-strip.parset b/cosserat-continuum-twisted-strip.parset
index 2aa18566..d2cdfd39 100644
--- a/cosserat-continuum-twisted-strip.parset
+++ b/cosserat-continuum-twisted-strip.parset
@@ -88,4 +88,7 @@ kappa = 1
 # x is the vertex coordinate
 dirichletVerticesPredicate = "x[0] < 0.001 or x[0] > 0.0999"
 
+# Initial deformation
+initialDeformation = "[x[0], x[1], 0]"
+
 
diff --git a/cosserat-continuum-wong-pellegrino-wrinkling.parset b/cosserat-continuum-wong-pellegrino-wrinkling.parset
index 3d748989..fba98912 100644
--- a/cosserat-continuum-wong-pellegrino-wrinkling.parset
+++ b/cosserat-continuum-wong-pellegrino-wrinkling.parset
@@ -137,3 +137,6 @@ neumannValues =  -1e3 0 0
 structuredGrid = false
 path = /home/sander/data/shells/wriggers_L_shape/
 gridFile = wriggers-L-shape_99.msh
+
+# Initial deformation
+initialDeformation = "[x[0], x[1], 0.002*cos(1e4*x[0])]"
diff --git a/cosserat-continuum-wriggers-l-shape.parset b/cosserat-continuum-wriggers-l-shape.parset
index 89066ff0..8e809176 100644
--- a/cosserat-continuum-wriggers-l-shape.parset
+++ b/cosserat-continuum-wriggers-l-shape.parset
@@ -95,3 +95,5 @@ neumannVerticesPredicate = "x[1] < -0.239"
 ###  Neumann values, if needed
 neumannValues =  -1e3 0 0
 
+# Initial deformation
+initialDeformation = "[x[0], x[1], 0]"
diff --git a/cosserat-continuum.cc b/cosserat-continuum.cc
index d507b7c4..c3ada0cb 100644
--- a/cosserat-continuum.cc
+++ b/cosserat-continuum.cc
@@ -51,21 +51,6 @@ const int blocksize = TargetSpace::TangentVector::dimension;
 
 using namespace Dune;
 
-class Identity
-: public Dune::VirtualFunction<FieldVector<double,dim>, FieldVector<double,3>>
-{
-public:
-  void evaluate(const FieldVector<double,dim>& x, FieldVector<double,3>& y) const
-  {
-    y = 0;
-    for (int i=0; i<dim; i++)
-      y[i] = x[i];
-
-    //y[2] = 0.002*std::cos(1e4*x[0]);
-  }
-};
-
-
 // Dirichlet boundary data for the shear/wrinkling example
 class WrinklingDirichletValues
 : public Dune::VirtualFunction<FieldVector<double,dim>, FieldVector<double,3> >
@@ -312,9 +297,11 @@ int main (int argc, char *argv[]) try
 
     SolutionType x(feBasis.size());
 
-    Identity identity;
+    lambda = std::string("lambda x: (") + parameterSet.get<std::string>("initialDeformation") + std::string(")");
+    PythonFunction<FieldVector<double,dim>, FieldVector<double,3> > pythonInitialDeformation(Python::evaluate(lambda));
+
     std::vector<FieldVector<double,3> > v;
-    Functions::interpolate(feBasis, v, identity);
+    Functions::interpolate(feBasis, v, pythonInitialDeformation);
 
     for (size_t i=0; i<x.size(); i++)
       x[i].r = v[i];
-- 
GitLab