diff --git a/problems/cantilever-dirichlet-values.py b/problems/cantilever-dirichlet-values.py deleted file mode 100644 index 0d1d60a5c0b33499677be2da2c10d2e6ea91b17c..0000000000000000000000000000000000000000 --- a/problems/cantilever-dirichlet-values.py +++ /dev/null @@ -1,17 +0,0 @@ -import math - -class DirichletValues: - def __init__(self, homotopyParameter): - self.homotopyParameter = homotopyParameter - - def deformation(self, x): - # Dirichlet b.c. simply clamp the shell in the reference configuration - out = [x[0], x[1], 0] - - return out - - - def orientation(self, x): - rotation = [[1,0,0], [0, 1, 0], [0, 0, 1]] - return rotation - diff --git a/problems/cosserat-continuum-cantilever.py b/problems/cosserat-continuum-cantilever.py index 538adaa62213f07e520d0fb2c09bb07abdf47d3d..f99abbfeaa405451f3953c3adf87723014520643 100644 --- a/problems/cosserat-continuum-cantilever.py +++ b/problems/cosserat-continuum-cantilever.py @@ -106,13 +106,27 @@ parameterSet.materialParameters.b3 = 1 # Boundary values ############################################# -parameterSet.problem = "cantilever" - ### Python predicate specifying all Dirichlet grid vertices # x is the vertex coordinate parameterSet.dirichletVerticesPredicate = "[x[0] < 0.01, x[0] < 0.01, x[0] < 0.01]" parameterSet.dirichletRotationVerticesPredicate = "x[0] < 0.01" +### The actual Dirichlet values +class DirichletValues: + def __init__(self, homotopyParameter): + self.homotopyParameter = homotopyParameter + + def deformation(self, x): + # Dirichlet b.c. simply clamp the shell in the reference configuration + out = [x[0], x[1], 0] + + return out + + + def orientation(self, x): + rotation = [[1,0,0], [0, 1, 0], [0, 0, 1]] + return rotation + ### Python predicate specifying all Neumann grid vertices # x is the vertex coordinate parameterSet.neumannVerticesPredicate = "x[0] > 99.99" diff --git a/problems/cosserat-continuum-twisted-strip.py b/problems/cosserat-continuum-twisted-strip.py index b8120ec67ce72cd82f6739de129d46f2634e5281..d32cf33e4d3ffa1afc5d3b1f462cf6894db42071 100644 --- a/problems/cosserat-continuum-twisted-strip.py +++ b/problems/cosserat-continuum-twisted-strip.py @@ -103,13 +103,38 @@ parameterSet.materialParameters.b3 = 1 # Boundary values ############################################# -parameterSet.problem = "twisted-strip" - ### Python predicate specifying all Dirichlet grid vertices # x is the vertex coordinate parameterSet.dirichletVerticesPredicate = "[x[0] < 0.001 or x[0] > 0.0999, x[0] < 0.001 or x[0] > 0.0999, x[0] < 0.001 or x[0] > 0.0999]" parameterSet.dirichletRotationVerticesPredicate = "x[0] < 0.001 or x[0] > 0.0999" +### The actual Dirichlet values +class DirichletValues: + def __init__(self, homotopyParameter): + self.homotopyParameter = homotopyParameter + self.upper = [0.1, 0.01] + self.totalAngle = 6*math.pi + + def deformation(self, x): + angle = self.totalAngle * x[0]/self.upper[0] + angle *= self.homotopyParameter + + # Rotation matrix (around y-axis) + rotation = [[1,0,0], [0, math.cos(angle), -math.sin(angle)], [0, math.sin(angle), math.cos(angle)]] + + # Matrix-vector product, vector is [x[0], x[1], 0] + out = [rotation[0][0]*x[0]+rotation[0][1]*x[1], rotation[1][0]*x[0]+rotation[1][1]*x[1], rotation[2][0]*x[0]+rotation[2][1]*x[1]] + + return out + + + def orientation(self, x): + angle = self.totalAngle * x[0]/self.upper[0] + angle *= self.homotopyParameter + + rotation = [[1,0,0], [0, math.cos(angle), -math.sin(angle)], [0, math.sin(angle), math.cos(angle)]] + return rotation + # Initial deformation parameterSet.initialDeformation = "[x[0], x[1], 0]" diff --git a/problems/cosserat-continuum-wong-pellegrino-wrinkling.py b/problems/cosserat-continuum-wong-pellegrino-wrinkling.py index cffce1393db4f18dbb0afcd16b1444d78ca49703..7b8056488db556e46ccb4ec9652cc17de61a9695 100644 --- a/problems/cosserat-continuum-wong-pellegrino-wrinkling.py +++ b/problems/cosserat-continuum-wong-pellegrino-wrinkling.py @@ -102,13 +102,27 @@ parameterSet.materialParameters.b3 = 1 # Boundary values ############################################# -parameterSet.problem = "wong-pellegrino" - ### Python predicate specifying all Dirichlet grid vertices # x is the vertex coordinate parameterSet.dirichletVerticesPredicate = "[x[1] < 0.0001 or x[1] > 0.128 - 0.0001, x[1] < 0.0001 or x[1] > 0.128 - 0.0001, x[1] < 0.0001 or x[1] > 0.128 - 0.0001]" parameterSet.dirichletRotationVerticesPredicate = "x[1] < 0.0001 or x[1] > 0.128 - 0.0001" +### The actual Dirichlet values +class DirichletValues: + def __init__(self, homotopyParameter): + self.homotopyParameter = homotopyParameter + + def deformation(self, x): + out = [x[0], x[1], 0] + if x[1] > 0.128-1e-4 : + out[0] += 0.003 * self.homotopyParameter + out[1] += 0.0005 + return out + + def orientation(self, x): + rotation = [[1,0,0], [0, 1, 0], [0, 0, 1]] + return rotation + # Initial deformation #parameterSet.startFromFile = True parameterSet.initialIterateFilename = "cosserat_iterate_2.vtu" diff --git a/problems/cosserat-continuum-wriggers-l-shape.py b/problems/cosserat-continuum-wriggers-l-shape.py index 0481d04466a84ccfd9cc49cc5abbf145e5527c26..cecbc1ae74cd99743f3b41dabb0dea11f1d43f30 100644 --- a/problems/cosserat-continuum-wriggers-l-shape.py +++ b/problems/cosserat-continuum-wriggers-l-shape.py @@ -98,13 +98,31 @@ parameterSet.materialParameters.b3 = 1 # Boundary values ############################################# -parameterSet.problem = "wriggers-l-shape" - ### Python predicate specifying all Dirichlet grid vertices # x is the vertex coordinate parameterSet.dirichletVerticesPredicate = "[x[0] < 1, x[0] < 1, x[0] < 1]" parameterSet.dirichletRotationVerticesPredicate = "x[0] < 1" +### The actual Dirichlet values +class DirichletValues: + def __init__(self, homotopyParameter): + self.homotopyParameter = homotopyParameter + + # Deformation of 3d classical materials + def dirichletValues(self, x): + # Clamp the L-shape in its reference configuration + return [x[0], x[1], x[2]] + + # Deformation of Cosserat shells + def deformation(self, x): + # Clamp the L-shape in its reference configuration + return [x[0], x[1], 0] + + # Orientation of Cosserat materials + def orientation(self, x): + rotation = [[1,0,0], [0, 1, 0], [0, 0, 1]] + return rotation + ### Python predicate specifying all Dirichlet grid vertices # x is the vertex coordinate parameterSet.neumannVerticesPredicate = "x[1] < -239" diff --git a/problems/twisted-strip-dirichlet-values.py b/problems/twisted-strip-dirichlet-values.py deleted file mode 100644 index cef4f74286cc522fb6282a76100c7e9144ec4585..0000000000000000000000000000000000000000 --- a/problems/twisted-strip-dirichlet-values.py +++ /dev/null @@ -1,28 +0,0 @@ -import math - -class DirichletValues: - def __init__(self, homotopyParameter): - self.homotopyParameter = homotopyParameter - self.upper = [0.1, 0.01] - self.totalAngle = 6*math.pi - - def deformation(self, x): - angle = self.totalAngle * x[0]/self.upper[0] - angle *= self.homotopyParameter - - # Rotation matrix (around y-axis) - rotation = [[1,0,0], [0, math.cos(angle), -math.sin(angle)], [0, math.sin(angle), math.cos(angle)]] - - # Matrix-vector product, vector is [x[0], x[1], 0] - out = [rotation[0][0]*x[0]+rotation[0][1]*x[1], rotation[1][0]*x[0]+rotation[1][1]*x[1], rotation[2][0]*x[0]+rotation[2][1]*x[1]] - - return out - - - def orientation(self, x): - angle = self.totalAngle * x[0]/self.upper[0] - angle *= self.homotopyParameter - - rotation = [[1,0,0], [0, math.cos(angle), -math.sin(angle)], [0, math.sin(angle), math.cos(angle)]] - return rotation - diff --git a/problems/wong-pellegrino-dirichlet-values.py b/problems/wong-pellegrino-dirichlet-values.py deleted file mode 100644 index 4e27ee31ed2c6427abe79ba5f9d41fa25152dd41..0000000000000000000000000000000000000000 --- a/problems/wong-pellegrino-dirichlet-values.py +++ /dev/null @@ -1,14 +0,0 @@ -class DirichletValues: - def __init__(self, homotopyParameter): - self.homotopyParameter = homotopyParameter - - def deformation(self, x): - out = [x[0], x[1], 0] - if x[1] > 0.128-1e-4 : - out[0] += 0.003 * self.homotopyParameter - out[1] += 0.0005 - return out - - def orientation(self, x): - rotation = [[1,0,0], [0, 1, 0], [0, 0, 1]] - return rotation diff --git a/problems/wriggers-l-shape-dirichlet-values.py b/problems/wriggers-l-shape-dirichlet-values.py deleted file mode 100644 index eac737a0f584c379922fdf950115dd5654daac28..0000000000000000000000000000000000000000 --- a/problems/wriggers-l-shape-dirichlet-values.py +++ /dev/null @@ -1,18 +0,0 @@ -class DirichletValues: - def __init__(self, homotopyParameter): - self.homotopyParameter = homotopyParameter - - # Deformation of 3d classical materials - def dirichletValues(self, x): - # Clamp the L-shape in its reference configuration - return [x[0], x[1], x[2]] - - # Deformation of Cosserat shells - def deformation(self, x): - # Clamp the L-shape in its reference configuration - return [x[0], x[1], 0] - - # Orientation of Cosserat materials - def orientation(self, x): - rotation = [[1,0,0], [0, 1, 0], [0, 0, 1]] - return rotation diff --git a/src/cosserat-continuum.cc b/src/cosserat-continuum.cc index 2b5e301cdbf5ca15f979f4819e3d551cde3442cf..d45f1ca6f7b89370050f75f875746b323965970f 100644 --- a/src/cosserat-continuum.cc +++ b/src/cosserat-continuum.cc @@ -471,12 +471,11 @@ int main (int argc, char *argv[]) try // Set Dirichlet values //////////////////////////////////////////////////////// - Python::Reference dirichletValuesClass = Python::import(parameterSet.get<std::string>("problem") + "-dirichlet-values"); + // Dirichlet boundary value function, depending on the homotopy parameter + Python::Callable dirichletValuesPythonClass = pyModule.get("DirichletValues"); - Python::Callable C = dirichletValuesClass.get("DirichletValues"); - - // Call a constructor. - Python::Reference dirichletValuesPythonObject = C(homotopyParameter); + // Construct with a particular value of the homotopy parameter + Python::Reference dirichletValuesPythonObject = dirichletValuesPythonClass(homotopyParameter); // Extract object member functions as Dune functions auto deformationDirichletValues = Python::make_function<FieldVector<double,3> > (dirichletValuesPythonObject.get("deformation"));