From 789592110eeed3bf0198d2f29f3416ae45e5376e Mon Sep 17 00:00:00 2001 From: Jonathan Youett <youett@mi.fu-berlin.de> Date: Thu, 27 Oct 2011 16:52:30 +0000 Subject: [PATCH] transform gradients from reference to element coordinates [[Imported from SVN: r8070]] --- dune/gfe/globalgeodesicfefunction.hh | 11 +++++++++-- dune/gfe/globalgfetestfunction.hh | 19 +++++++++++++++---- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/dune/gfe/globalgeodesicfefunction.hh b/dune/gfe/globalgeodesicfefunction.hh index c3f88258..00afb3c2 100644 --- a/dune/gfe/globalgeodesicfefunction.hh +++ b/dune/gfe/globalgeodesicfefunction.hh @@ -72,9 +72,16 @@ public: // create local gfe function LocalGFEFunction localGFE(basis_.getLocalFiniteElement(element),localCoeff); - + // use it to evaluate the derivative - out = localGFE.evaluateDerivative(local); + Dune::FieldMatrix<ctype, embeddedDim, gridDim> refJac = localGFE.evaluateDerivative(local); + + out =0.0; + //transform the gradient + const Dune::FieldMatrix<double,gridDim,gridDim>& jacInvTrans = element.geometry().jacobianInverseTransposed(local); + for (size_t k=0; k< refJac.N(); k++) + jacInvTrans.umv(refJac[k],out[k]); + } /** \brief Export basis */ diff --git a/dune/gfe/globalgfetestfunction.hh b/dune/gfe/globalgfetestfunction.hh index a74f06b0..48c503b1 100644 --- a/dune/gfe/globalgfetestfunction.hh +++ b/dune/gfe/globalgfetestfunction.hh @@ -75,7 +75,7 @@ void GlobalGFETestFunction<Basis,TargetSpace,CoefficientType>::evaluateLocal(con basis_.getLocalFiniteElement(element).localBasis().evaluateFunction(local, values); // multiply values with the corresponding test coefficients and sum them up - out = 0; + out = 0.0; for (size_t i=0; i<values.size(); i++) { int index = basis_.index(element,i); @@ -91,13 +91,24 @@ void GlobalGFETestFunction<Basis,TargetSpace,CoefficientType>::evaluateDerivativ Dune::FieldMatrix<ctype, embeddedDim, gridDim>& out) const { // jacobians of the test basis function - a lot of dims here... - std::vector<Dune::array<Dune::FieldMatrix<ctype, embeddedDim, gridDim>, tangentDim> > jacobians; + std::vector<Dune::array<Dune::FieldMatrix<ctype, embeddedDim, gridDim>, tangentDim> > refJacobians,jacobians; // evaluate local gfe test function basis - basis_.getLocalFiniteElement(element).localBasis().evaluateJacobian(local, jacobians); + basis_.getLocalFiniteElement(element).localBasis().evaluateJacobian(local, refJacobians); + + const Dune::FieldMatrix<double,gridDim,gridDim>& jacInvTrans = element.geometry().jacobianInverseTransposed(local); + + //transform the gradients + jacobians.resize(refJacobians.size()); + for (size_t i = 0; i<jacobians.size(); i++) + for (int j=0; j<tangentDim; j++) {// the local basis has a block structure + jacobians[i][j] = 0; + for (size_t comp=0; comp<jacobians[i][j].N(); comp++) + jacInvTrans.umv(refJacobians[i][j][comp], jacobians[i][j][comp]); + } // multiply values with the corresponding test coefficients and sum them up - out = 0; + out = 0.0; for (int i=0; i<jacobians.size(); i++) { int index = basis_.index(element,i); -- GitLab