From 841e77c3c635c8f194659578cc1b409d2cd9cb00 Mon Sep 17 00:00:00 2001 From: Oliver Sander <oliver.sander@tu-dresden.de> Date: Thu, 3 Dec 2015 15:11:43 +0100 Subject: [PATCH] Prepare the shell code for the dimworld>dim case --- dune/gfe/cosseratenergystiffness.hh | 5 +++-- src/cosserat-continuum.cc | 21 +++++++++++---------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/dune/gfe/cosseratenergystiffness.hh b/dune/gfe/cosseratenergystiffness.hh index 8b8fa351..f8726da4 100644 --- a/dune/gfe/cosseratenergystiffness.hh +++ b/dune/gfe/cosseratenergystiffness.hh @@ -34,6 +34,7 @@ class CosseratEnergyLocalStiffness // some other sizes enum {gridDim=GridView::dimension}; + enum {dimworld=GridView::dimensionworld}; /** \brief Compute the symmetric part of a matrix A, i.e. \f$ \frac 12 (A + A^T) \f$ */ @@ -120,7 +121,7 @@ public: */ CosseratEnergyLocalStiffness(const Dune::ParameterTree& parameters, const BoundaryPatch<GridView>* neumannBoundary, - const Dune::VirtualFunction<Dune::FieldVector<double,gridDim>, Dune::FieldVector<double,3> >* neumannFunction) + const Dune::VirtualFunction<Dune::FieldVector<double,dimworld>, Dune::FieldVector<double,3> >* neumannFunction) : neumannBoundary_(neumannBoundary), neumannFunction_(neumannFunction) { @@ -293,7 +294,7 @@ public: const BoundaryPatch<GridView>* neumannBoundary_; /** \brief The function implementing the Neumann data */ - const Dune::VirtualFunction<Dune::FieldVector<double,gridDim>, Dune::FieldVector<double,3> >* neumannFunction_; + const Dune::VirtualFunction<Dune::FieldVector<double,dimworld>, Dune::FieldVector<double,3> >* neumannFunction_; }; template <class Basis, int dim, class field_type> diff --git a/src/cosserat-continuum.cc b/src/cosserat-continuum.cc index 34421680..c15be256 100644 --- a/src/cosserat-continuum.cc +++ b/src/cosserat-continuum.cc @@ -43,6 +43,7 @@ // grid dimension const int dim = 2; +const int dimworld = 2; // Image space of the geodesic fe functions typedef RigidBodyMotion<double,3> TargetSpace; @@ -54,7 +55,7 @@ using namespace Dune; /** \brief A constant vector-valued function, for simple Neumann boundary values */ struct NeumannFunction - : public Dune::VirtualFunction<FieldVector<double,dim>, FieldVector<double,3> > + : public Dune::VirtualFunction<FieldVector<double,dimworld>, FieldVector<double,3> > { NeumannFunction(const FieldVector<double,3> values, double homotopyParameter) @@ -62,7 +63,7 @@ struct NeumannFunction homotopyParameter_(homotopyParameter) {} - void evaluate(const FieldVector<double, dim>& x, FieldVector<double,3>& out) const { + void evaluate(const FieldVector<double, dimworld>& x, FieldVector<double,3>& out) const { out = 0; out.axpy(homotopyParameter_, values_); } @@ -122,12 +123,12 @@ int main (int argc, char *argv[]) try shared_ptr<GridType> grid; - FieldVector<double,dim> lower(0), upper(1); + FieldVector<double,dimworld> lower(0), upper(1); if (parameterSet.get<bool>("structuredGrid")) { - lower = parameterSet.get<FieldVector<double,dim> >("lower"); - upper = parameterSet.get<FieldVector<double,dim> >("upper"); + lower = parameterSet.get<FieldVector<double,dimworld> >("lower"); + upper = parameterSet.get<FieldVector<double,dimworld> >("upper"); array<unsigned int,dim> elements = parameterSet.get<array<unsigned int,dim> >("elements"); grid = StructuredGridFactory<GridType>::createCubeGrid(lower, upper, elements); @@ -175,11 +176,11 @@ int main (int argc, char *argv[]) try // Make Python function that computes which vertices are on the Dirichlet boundary, // based on the vertex positions. std::string lambda = std::string("lambda x: (") + parameterSet.get<std::string>("dirichletVerticesPredicate") + std::string(")"); - PythonFunction<FieldVector<double,dim>, bool> pythonDirichletVertices(Python::evaluate(lambda)); + PythonFunction<FieldVector<double,dimworld>, bool> pythonDirichletVertices(Python::evaluate(lambda)); // Same for the Neumann boundary lambda = std::string("lambda x: (") + parameterSet.get<std::string>("neumannVerticesPredicate", "0") + std::string(")"); - PythonFunction<FieldVector<double,dim>, bool> pythonNeumannVertices(Python::evaluate(lambda)); + PythonFunction<FieldVector<double,dimworld>, bool> pythonNeumannVertices(Python::evaluate(lambda)); for (; vIt!=vEndIt; ++vIt) { @@ -223,7 +224,7 @@ int main (int argc, char *argv[]) try GFE::CosseratVTKReader::read(x, parameterSet.get<std::string>("initialIterateFilename")); } else { lambda = std::string("lambda x: (") + parameterSet.get<std::string>("initialDeformation") + std::string(")"); - PythonFunction<FieldVector<double,dim>, FieldVector<double,3> > pythonInitialDeformation(Python::evaluate(lambda)); + PythonFunction<FieldVector<double,dimworld>, FieldVector<double,3> > pythonInitialDeformation(Python::evaluate(lambda)); std::vector<FieldVector<double,3> > v; ::Functions::interpolate(fufemFeBasis, v, pythonInitialDeformation); @@ -305,8 +306,8 @@ int main (int argc, char *argv[]) try Python::Reference dirichletValuesPythonObject = C(homotopyParameter); // Extract object member functions as Dune functions - PythonFunction<FieldVector<double,dim>, FieldVector<double,3> > deformationDirichletValues(dirichletValuesPythonObject.get("deformation")); - PythonFunction<FieldVector<double,dim>, FieldMatrix<double,3,3> > orientationDirichletValues(dirichletValuesPythonObject.get("orientation")); + PythonFunction<FieldVector<double,dimworld>, FieldVector<double,3> > deformationDirichletValues(dirichletValuesPythonObject.get("deformation")); + PythonFunction<FieldVector<double,dimworld>, FieldMatrix<double,3,3> > orientationDirichletValues(dirichletValuesPythonObject.get("orientation")); std::vector<FieldVector<double,3> > ddV; ::Functions::interpolate(fufemFeBasis, ddV, deformationDirichletValues, dirichletDofs); -- GitLab