diff --git a/dune/elasticity/materials/exphenckyenergy.hh b/dune/elasticity/materials/exphenckyenergy.hh index d684227803067be93313c03fb6bc20aabb17aaca..1721e78aad0608d07ce2ccf6d990b436aa572e79 100644 --- a/dune/elasticity/materials/exphenckyenergy.hh +++ b/dune/elasticity/materials/exphenckyenergy.hh @@ -14,7 +14,7 @@ template<class GridView, class LocalFiniteElement, class field_type=double> class ExpHenckyEnergy : public LocalFEStiffness<GridView, LocalFiniteElement, - std::vector<Dune::FieldVector<field_type,3> > > + std::vector<Dune::FieldVector<field_type,GridView::dimension> > > { // grid types typedef typename GridView::Grid::ctype DT; diff --git a/dune/elasticity/materials/henckyenergy.hh b/dune/elasticity/materials/henckyenergy.hh index c603a3451957e107a5360b894082f1e1a192ab27..7a5131599b1521b175d0dc2f6bd73c9a48e93b70 100644 --- a/dune/elasticity/materials/henckyenergy.hh +++ b/dune/elasticity/materials/henckyenergy.hh @@ -12,7 +12,7 @@ namespace Dune { template<class GridView, class LocalFiniteElement, class field_type=double> class HenckyEnergy - : public LocalFEStiffness<GridView,LocalFiniteElement,std::vector<Dune::FieldVector<field_type,3> > > + : public LocalFEStiffness<GridView,LocalFiniteElement,std::vector<Dune::FieldVector<field_type,GridView::dimension> > > { // grid types typedef typename GridView::Grid::ctype DT; diff --git a/dune/elasticity/materials/neohookeenergy.hh b/dune/elasticity/materials/neohookeenergy.hh index 09118d0756843d5ad9853ff31b72d876e18854b8..6989214e725483b1be85600e1c2c67dce0372562 100644 --- a/dune/elasticity/materials/neohookeenergy.hh +++ b/dune/elasticity/materials/neohookeenergy.hh @@ -14,7 +14,7 @@ template<class GridView, class LocalFiniteElement, class field_type=double> class NeoHookeEnergy : public LocalFEStiffness<GridView, LocalFiniteElement, - std::vector<Dune::FieldVector<field_type,3> > > + std::vector<Dune::FieldVector<field_type,GridView::dimension> > > { // grid types typedef typename GridView::Grid::ctype DT; diff --git a/dune/elasticity/materials/neumannenergy.hh b/dune/elasticity/materials/neumannenergy.hh index 539418d3fb6edaa0bbb0d719da292680594d04ce..3c16d38aed877246696983398a22b4ac2a8cc6b7 100644 --- a/dune/elasticity/materials/neumannenergy.hh +++ b/dune/elasticity/materials/neumannenergy.hh @@ -15,7 +15,7 @@ namespace Dune { template<class GridView, class LocalFiniteElement, class field_type=double> class NeumannEnergy -: public LocalFEStiffness<GridView,LocalFiniteElement,std::vector<Dune::FieldVector<field_type,3> > > +: public LocalFEStiffness<GridView,LocalFiniteElement,std::vector<Dune::FieldVector<field_type,GridView::dimension> > > { // grid types typedef typename GridView::ctype ctype; @@ -29,7 +29,7 @@ public: * \param parameters The material parameters */ NeumannEnergy(const BoundaryPatch<GridView>* neumannBoundary, - const Dune::VirtualFunction<Dune::FieldVector<ctype,dim>, Dune::FieldVector<double,3> >* neumannFunction) + const Dune::VirtualFunction<Dune::FieldVector<ctype,dim>, Dune::FieldVector<double,dim> >* neumannFunction) : neumannBoundary_(neumannBoundary), neumannFunction_(neumannFunction) {} @@ -70,10 +70,10 @@ public: value[j] += shapeFunctionValues[i] * localConfiguration[i][j]; // Value of the Neumann data at the current position - Dune::FieldVector<double,3> neumannValue; + Dune::FieldVector<double,dim> neumannValue; - if (dynamic_cast<const VirtualGridViewFunction<GridView,Dune::FieldVector<double,3> >*>(neumannFunction_)) - dynamic_cast<const VirtualGridViewFunction<GridView,Dune::FieldVector<double,3> >*>(neumannFunction_)->evaluateLocal(element, quadPos, neumannValue); + if (dynamic_cast<const VirtualGridViewFunction<GridView,Dune::FieldVector<double,dim> >*>(neumannFunction_)) + dynamic_cast<const VirtualGridViewFunction<GridView,Dune::FieldVector<double,dim> >*>(neumannFunction_)->evaluateLocal(element, quadPos, neumannValue); else neumannFunction_->evaluate(it.geometry().global(quad[pt].position()), neumannValue); @@ -93,7 +93,7 @@ private: const BoundaryPatch<GridView>* neumannBoundary_; /** \brief The function implementing the Neumann data */ - const Dune::VirtualFunction<Dune::FieldVector<double,dim>, Dune::FieldVector<double,3> >* neumannFunction_; + const Dune::VirtualFunction<Dune::FieldVector<double,dim>, Dune::FieldVector<double,dim> >* neumannFunction_; }; } diff --git a/dune/elasticity/materials/sumenergy.hh b/dune/elasticity/materials/sumenergy.hh index c316a163bea1918606b85e2662e3500f10a1b7ce..b2c9f507abdf1e1e66b5370b34d09aa7336ccc10 100644 --- a/dune/elasticity/materials/sumenergy.hh +++ b/dune/elasticity/materials/sumenergy.hh @@ -15,7 +15,7 @@ namespace Dune { template<class GridView, class LocalFiniteElement, class field_type=double> class SumEnergy -: public LocalFEStiffness<GridView,LocalFiniteElement,std::vector<Dune::FieldVector<field_type,3> > > +: public LocalFEStiffness<GridView,LocalFiniteElement,std::vector<Dune::FieldVector<field_type,GridView::dimension> > > { // grid types typedef typename GridView::ctype ctype; @@ -28,8 +28,8 @@ public: /** \brief Constructor with a set of material parameters * \param parameters The material parameters */ - SumEnergy(std::shared_ptr<LocalFEStiffness<GridView,LocalFiniteElement,std::vector<Dune::FieldVector<field_type,3> > > > a, - std::shared_ptr<LocalFEStiffness<GridView,LocalFiniteElement,std::vector<Dune::FieldVector<field_type,3> > > > b) + SumEnergy(std::shared_ptr<LocalFEStiffness<GridView,LocalFiniteElement,std::vector<Dune::FieldVector<field_type,dim> > > > a, + std::shared_ptr<LocalFEStiffness<GridView,LocalFiniteElement,std::vector<Dune::FieldVector<field_type,dim> > > > b) : a_(a), b_(b) {} @@ -45,9 +45,9 @@ public: private: - std::shared_ptr<LocalFEStiffness<GridView,LocalFiniteElement,std::vector<Dune::FieldVector<field_type,3> > > > a_; + std::shared_ptr<LocalFEStiffness<GridView,LocalFiniteElement,std::vector<Dune::FieldVector<field_type,dim> > > > a_; - std::shared_ptr<LocalFEStiffness<GridView,LocalFiniteElement,std::vector<Dune::FieldVector<field_type,3> > > > b_; + std::shared_ptr<LocalFEStiffness<GridView,LocalFiniteElement,std::vector<Dune::FieldVector<field_type,dim> > > > b_; }; } diff --git a/src/finite-strain-elasticity.cc b/src/finite-strain-elasticity.cc index 81f60944b60e5c027f28fa666d661bc2c30b6af6..5976142faa23d5821a150c095cf8fbe69779060b 100644 --- a/src/finite-strain-elasticity.cc +++ b/src/finite-strain-elasticity.cc @@ -49,21 +49,21 @@ 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,dim>, FieldVector<double,dim> > { - NeumannFunction(const FieldVector<double,3> values, + NeumannFunction(const FieldVector<double,dim> values, double homotopyParameter) : values_(values), homotopyParameter_(homotopyParameter) {} - void evaluate(const FieldVector<double, dim>& x, FieldVector<double,3>& out) const + void evaluate(const FieldVector<double, dim>& x, FieldVector<double,dim>& out) const { out = 0; out.axpy(-homotopyParameter_, values_); } - FieldVector<double,3> values_; + FieldVector<double,dim> values_; double homotopyParameter_; }; @@ -205,7 +205,7 @@ int main (int argc, char *argv[]) try SolutionType x(feBasis.size()); 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,dim>, FieldVector<double,dim> > pythonInitialDeformation(Python::evaluate(lambda)); ::Functions::interpolate(fufemFEBasis, x, pythonInitialDeformation); @@ -225,7 +225,7 @@ int main (int argc, char *argv[]) try // We need to subsample, because VTK cannot natively display real second-order functions SubsamplingVTKWriter<GridView> vtkWriter(gridView, Dune::refinementLevels(2)); - vtkWriter.addVertexData(localDisplacementFunction, VTK::FieldInfo("displacement", VTK::FieldInfo::Type::scalar, 3)); + vtkWriter.addVertexData(localDisplacementFunction, VTK::FieldInfo("displacement", VTK::FieldInfo::Type::scalar, dim)); vtkWriter.write(resultPath + "finite-strain_homotopy_0"); for (int i=0; i<numHomotopySteps; i++) @@ -242,10 +242,10 @@ int main (int argc, char *argv[]) try const ParameterTree& materialParameters = parameterSet.sub("materialParameters"); std::shared_ptr<NeumannFunction> neumannFunction; if (parameterSet.hasKey("neumannValues")) - neumannFunction = make_shared<NeumannFunction>(parameterSet.get<FieldVector<double,3> >("neumannValues"), + neumannFunction = make_shared<NeumannFunction>(parameterSet.get<FieldVector<double,dim> >("neumannValues"), homotopyParameter); - std::cout << "Neumann values: " << parameterSet.get<FieldVector<double,3> >("neumannValues") << std::endl; + std::cout << "Neumann values: " << parameterSet.get<FieldVector<double,dim> >("neumannValues") << std::endl; if (mpiHelper.rank() == 0) { @@ -257,7 +257,7 @@ int main (int argc, char *argv[]) try std::cout << "Selected energy is: " << parameterSet.get<std::string>("energy") << std::endl; std::shared_ptr<LocalFEStiffness<GridView, FEBasis::LocalView::Tree::FiniteElement, - std::vector<Dune::FieldVector<adouble, 3> > > > elasticEnergy; + std::vector<Dune::FieldVector<adouble, dim> > > > elasticEnergy; if (parameterSet.get<std::string>("energy") == "stvenantkirchhoff") elasticEnergy = std::make_shared<StVenantKirchhoffEnergy<GridView, @@ -329,7 +329,7 @@ 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> > dirichletValues(dirichletValuesPythonObject.get("dirichletValues")); + PythonFunction<FieldVector<double,dim>, FieldVector<double,dim> > dirichletValues(dirichletValuesPythonObject.get("dirichletValues")); ::Functions::interpolate(fufemFEBasis, x, dirichletValues, dirichletDofs); @@ -355,7 +355,7 @@ int main (int argc, char *argv[]) try // We need to subsample, because VTK cannot natively display real second-order functions SubsamplingVTKWriter<GridView> vtkWriter(gridView, Dune::refinementLevels(2)); - vtkWriter.addVertexData(localDisplacementFunction, VTK::FieldInfo("displacement", VTK::FieldInfo::Type::scalar, 3)); + vtkWriter.addVertexData(localDisplacementFunction, VTK::FieldInfo("displacement", VTK::FieldInfo::Type::scalar, dim)); vtkWriter.write(resultPath + "finite-strain_homotopy_" + std::to_string(i+1)); }