diff --git a/dune/elasticity/assemblers/mooneyrivlinfunctionalassembler.hh b/dune/elasticity/assemblers/mooneyrivlinfunctionalassembler.hh index 8e0a87fb47c18270a6d660f251206a1e609d7c10..733b0da71811a98ba0dd02652a0ed5bec8e42d77 100644 --- a/dune/elasticity/assemblers/mooneyrivlinfunctionalassembler.hh +++ b/dune/elasticity/assemblers/mooneyrivlinfunctionalassembler.hh @@ -15,7 +15,7 @@ /** \brief Local assembler for the linearization of a nonlinear Mooney-Rivlin energy at a displacement u * * \f[ - * W(u)= a tr(E(u)) + b tr(E(u))^2 + c ||E(u)||^2 + d J^2 + e J^-k, k>=2 + * W(u)= a tr(E(u)) + b tr(E(u))^2 + c ||E(u)||^2 + d J^2 + e J^-k, k>=2 * \f] * * where @@ -24,9 +24,9 @@ * - \f$J\f$ the determinant of the deformation gradient * - \f$\a\f$,...,\f$\e\f$ material parameters * - \f$k\f$ controlls orientation preservation (k \approx \floor(1/(1-2nu) -1)) -*/ +*/ template -class MooneyRivlinFunctionalAssembler : +class MooneyRivlinFunctionalAssembler : public LocalFunctionalAssembler > { @@ -58,7 +58,7 @@ public: localVector = 0.0; // get quadrature rule (should depend on k?) - const int order = (element.type().isSimplex()) + const int order = (element.type().isSimplex()) ? 6*(tFE.localBasis().order()) : 6*(tFE.localBasis().order()*dim); const auto& quad = QuadratureRuleCache::rule(element.type(), order, IsRefinedLocalFiniteElement::value(tFE) ); @@ -112,7 +112,7 @@ public: linStrain[i][k] = Dune::Elasticity::linearisedStrain(deformationGradient, localConfGrad); } - // collect terms + // collect terms FMatrix fu(0); // the linearization of the trace is just deformation gradient diff --git a/dune/elasticity/assemblers/mooneyrivlinoperatorassembler.hh b/dune/elasticity/assemblers/mooneyrivlinoperatorassembler.hh index 9e551fb4dcb462826cb3fced91c1a344215a9e5d..43f7eaf915125af32e4b685af1c9b3ec781fcba2 100644 --- a/dune/elasticity/assemblers/mooneyrivlinoperatorassembler.hh +++ b/dune/elasticity/assemblers/mooneyrivlinoperatorassembler.hh @@ -18,7 +18,7 @@ /** \brief Assemble the second derivative of a Mooney-Rivlin material. * * \f[ - * W(u)= a tr(E(u)) + b tr(E(u))^2 + c ||E(u)||^2 + d J^2 + e J^-k, k>=2 + * W(u)= a tr(E(u)) + b tr(E(u))^2 + c ||E(u)||^2 + d J^2 + e J^-k, k>=2 * \f] * * where @@ -27,9 +27,9 @@ * - \f$J\f$ the determinant of the deformation gradient * - \f$\a\f$,...,\f$\e\f$ material parameters * - \f$k\f$ controlls orientation preservation (k \approx \floor(1/(1-2nu) -1)) -*/ +*/ template -class MooneyRivlinOperatorAssembler +class MooneyRivlinOperatorAssembler : public LocalOperatorAssembler < GridType, TrialLocalFE, AnsatzLocalFE, Dune::FieldMatrix > { static constexpr int dim = GridType::dimension; @@ -67,7 +67,7 @@ public: localMatrix = 0.0; // get quadrature rule (should depend on k?) - const int order = (element.type().isSimplex()) + const int order = (element.type().isSimplex()) ? 6*(tFE.localBasis().order()) : 6*(tFE.localBasis().order()*dim); const auto& quad = QuadratureRuleCache::rule(element.type(), order, IsRefinedLocalFiniteElement::value(tFE)); @@ -131,7 +131,7 @@ public: for (int row = 0; row < rows; ++row) for (int col = 0; col displacement_; - /** \brief Compute the matrix entry that arises from the second derivative of the determinant. - * Note that it is assumed the defGrad is the deformation gradient and not the displacement gradient + /** \brief Compute the matrix entry that arises from the second derivative of the determinant. + * Note that it is assumed the defGrad is the deformation gradient and not the displacement gradient */ auto hessDefDet(const Dune::FieldMatrix& defGrad, const Dune::FieldVector& testGrad, const Dune::FieldVector& ansatzGrad) const { Dune::FieldMatrix res(0); - + if (dim==2) { res[0][1] = testGrad[0]*ansatzGrad[1]-ansatzGrad[0]*testGrad[1]; res[1][0] = -res[0][1]; @@ -195,7 +195,7 @@ private: } //compute the cross product - Dune::FieldVector cross(0); + Dune::FieldVector cross(0); for (int k=0; k -class NeoHookeFunctionalAssembler : +class NeoHookeFunctionalAssembler : public LocalFunctionalAssembler > { @@ -78,8 +78,8 @@ public: { typedef Dune::FieldMatrix FMdimdim; typedef typename Element::Geometry::JacobianInverseTransposed JacInvTransType; - typedef typename TrialLocalFE::Traits::LocalBasisType::Traits::JacobianType JacobianType; - typedef typename GridType::template Codim<0>::Geometry::LocalCoordinate LocalCoordinate; + typedef typename TrialLocalFE::Traits::LocalBasisType::Traits::JacobianType JacobianType; + typedef typename GridType::template Codim<0>::Geometry::LocalCoordinate LocalCoordinate; int rows = tFE.localBasis().size(); @@ -138,12 +138,12 @@ public: // make deformation gradient out of the discplacement for (int i=0;i -class NeoHookeOperatorAssembler +class NeoHookeOperatorAssembler : public LocalOperatorAssembler < GridType, TrialLocalFE, AnsatzLocalFE, Dune::FieldMatrix > { static const int dim = GridType::dimension; typedef typename GridType::ctype ctype; - + typedef VirtualGridFunction > GridFunction; public: @@ -95,7 +95,7 @@ public: localMatrix = 0.0; // TODO get proper quadrature rule - const int order = (element.type().isSimplex()) + const int order = (element.type().isSimplex()) ? 4*(tFE.localBasis().order()) : 4*(tFE.localBasis().order()*dim); const Dune::QuadratureRule& quad = QuadratureRuleCache::rule(element.type(), order, IsRefinedLocalFiniteElement::value(tFE) ); @@ -144,7 +144,7 @@ public: // compute deformation gradient of the configuration for (int i=0;i displacement_; - /** \brief Compute the matrix entry that arises from the second derivative of the determinant. - * Note that it is assumed the defGrad is the deformation gradient and not the displacement gradient + /** \brief Compute the matrix entry that arises from the second derivative of the determinant. + * Note that it is assumed the defGrad is the deformation gradient and not the displacement gradient */ Dune::FieldMatrix hessDefDet(const Dune::FieldMatrix& defGrad, const Dune::FieldVector& testGrad, const Dune::FieldVector& ansatzGrad) const { Dune::FieldMatrix res(0); - + if (dim==2) { res[0][1] = testGrad[0]*ansatzGrad[1]-ansatzGrad[0]*testGrad[1]; res[1][0] = -res[0][1]; @@ -217,7 +217,7 @@ private: } //compute the cross product - Dune::FieldVector cross(0); + Dune::FieldVector cross(0); for (int k=0; k >::value; - + using TransferOperatorType = typename TruncatedCompressedMGTransfer::TransferOperatorType; std::vector>> transferOperators(isP1Basis ? numLevels-1 : numLevels); - + // Here we set up the restriction of the leaf grid space into the leaf grid P1/Q1 space if (not isP1Basis) { @@ -318,7 +318,7 @@ void TrustRegionSolver::solve() //Take the obstacles on the finest grid and give them to the multigrid solver, it will create a hierarchy for all coarser grids trustRegionObstacles = trustRegion.obstacles(); - + #if ! HAVE_DUNE_PARMG mgStep->setProblem(stiffnessMatrix, corr, rhs); diff --git a/dune/elasticity/estimators/zienkiewiczzhuestimator.hh b/dune/elasticity/estimators/zienkiewiczzhuestimator.hh index 38dd8e942dca508af32b7e480d37e0471282cff8..95d28438f360a06c12855def2c77d2b099bb9349 100644 --- a/dune/elasticity/estimators/zienkiewiczzhuestimator.hh +++ b/dune/elasticity/estimators/zienkiewiczzhuestimator.hh @@ -27,11 +27,11 @@ public: : grid_(&grid), E_(E), nu_(nu) {} - void estimate(const VectorType& x, + void estimate(const VectorType& x, Dune::BlockVector >& errorPerElement) { using namespace Dune; - + const auto& indexSet = grid_->leafIndexSet(); @@ -46,8 +46,8 @@ public: typedef BCRSMatrix MassMatrixType; typedef P1NodalBasis P1Basis; - - + + P1Basis p1Basis(grid_->leafGridView()); MassMatrixType massMatrix; OperatorAssembler globalAssembler(p1Basis,p1Basis); @@ -60,28 +60,28 @@ public: #ifdef LUMP_MATRIX /* BDMatrix > invMassMatrix(baseSet.size()); invMassMatrix = 0; - + for (int i=0; i invMassMatrix; invMassMatrix = 0; - + lumpMatrix(massMatrix,invMassMatrix); - + invMassMatrix.invert(); -#endif - +#endif + BlockVector > unscaledP1Stress(indexSet.size(dim)); unscaledP1Stress = 0; typedef Dune::PQkLocalFiniteElementCache FiniteElementCache; - FiniteElementCache cache; - + FiniteElementCache cache; + for (const auto& e : elements(grid_->leafGridView())) { // Element type @@ -110,10 +110,10 @@ public: auto&& geometry = e.geometry(); for (size_t g=0; g& quadPos = quad[g].position(); - + // eval jacobian inverse auto&& jac = geometry.jacobianInverseTransposed(quadPos); @@ -124,38 +124,38 @@ public: // Compute p0 stress at this quadrature node // ///////////////////////////////////////////// SymmetricTensor p0Strain(0.0); - + // evaluate gradients at Gauss points std::vector > temp; FieldVector grad; - + finiteElement.localBasis().evaluateJacobian(quadPos,temp); - + for (size_t i=0; i Grad(0); Grad[j] = grad; - + /* Computes the linear strain tensor from the deformation gradient*/ SymmetricTensor scaledStrain; computeStrain(Grad,scaledStrain); - + scaledStrain *= localSolution[i][j]; p0Strain += scaledStrain; } - + } // compute stress SymmetricTensor p0Stress = hookeTimesStrain(p0Strain); - + std::vector >values; finiteElement.localBasis().evaluateFunction(quadPos,values); @@ -163,15 +163,15 @@ public: for (size_t row=0; row > elementP1Stress(indexSet.size(dim)); elementP1Stress = 0; - + #ifdef LUMP_MATRIX /*elementP1Stress = unscaledP1Stress; for (int i=0; i >, BlockVector > > op(massMatrix); - + // A preconditioner SeqILU >, BlockVector > > ilu0(massMatrix,1.0); - + // A preconditioned conjugate-gradient solver int numIt = 100; - CGSolver > > cg(op,ilu0,1E-16,numIt,0); - + CGSolver > > cg(op,ilu0,1E-16,numIt,0); + // Object storing some statistics about the solving process InverseOperatorResult statistics; - + // Solve! cg.apply(elementP1Stress, unscaledP1Stress, statistics); #endif @@ -216,7 +216,7 @@ public: GeometryType gt = e.type(); // First order finite element - const typename FiniteElementCache::FiniteElementType& finiteElement = cache.get(gt); + const typename FiniteElementCache::FiniteElementType& finiteElement = cache.get(gt); // ///////////////////////////////////////// // Extract the solution on this element @@ -238,22 +238,22 @@ public: errorPerElement[indexSet.index(e)] = 0; for (size_t g=0; g p0Stress(0.0), p1Stress(0.0); - + // evaluate gradients at Gauss points std::vector >temp; std::vector >values; @@ -264,16 +264,16 @@ public: // loop over test function number for (size_t i=0; i Grad(0); Grad[j] = grad; - + /* Computes the linear strain tensor from the deformation gradient*/ SymmetricTensor shapeFunctionStrain; computeStrain(Grad,shapeFunctionStrain); @@ -282,7 +282,7 @@ public: // Compute stress p0Stress += hookeTimesStrain(shapeFunctionStrain); - } + } SymmetricTensor scaledStress = elementP1Stress[i]; scaledStress *= values[i]; @@ -297,7 +297,7 @@ public: } private: - + void computeStrain(const Dune::FieldMatrix& grad, SymmetricTensor& strain) const { for (int i=0; i hookeTimesStrain(const SymmetricTensor& strain) const { - + SymmetricTensor stress = strain; stress *= E_/(1+nu_); diff --git a/dune/elasticity/materials/geomexactstvenantkirchhoffmaterial.hh b/dune/elasticity/materials/geomexactstvenantkirchhoffmaterial.hh index 84c0e879a4a1a6b13acabb214c6265fe32e514f6..f899884647e8b17ba007120adaa458c3ac302c31 100644 --- a/dune/elasticity/materials/geomexactstvenantkirchhoffmaterial.hh +++ b/dune/elasticity/materials/geomexactstvenantkirchhoffmaterial.hh @@ -14,7 +14,7 @@ /* \brief Class representing a hyperelastic geometrically exact St.Venant Kirchhoff material. * - * \tparam Basis Global basis that is used for the spatial discretization. + * \tparam Basis Global basis that is used for the spatial discretization. * (This is not nice but I need a LocalFiniteElement for the local Hessian assembler :-( ) */ template @@ -111,14 +111,14 @@ public: return 0.5*energy; } - //! Return the local assembler of the first derivative of the strain energy + //! Return the local assembler of the first derivative of the strain energy LinearisationAssembler& firstDerivative(std::shared_ptr displace) { localLinearisation_.setConfiguration(displace); return localLinearisation_; } - //! Return the local assembler of the second derivative of the strain energy + //! Return the local assembler of the second derivative of the strain energy HessianAssembler& secondDerivative(std::shared_ptr displace) { localHessian_.setConfiguration(displace);