From 1af69331b048cd0ecd6e9524008f6f2d2073c2c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dennis=20Gl=C3=A4ser?= <dennis.glaeser@iws.uni-stuttgart.de> Date: Thu, 22 Nov 2018 13:44:45 +0100 Subject: [PATCH] [mpfa][localassemblerbase] add function to compute scv-wise gradients --- .../cellcentered/mpfa/localassemblerbase.hh | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/dumux/discretization/cellcentered/mpfa/localassemblerbase.hh b/dumux/discretization/cellcentered/mpfa/localassemblerbase.hh index 9d0d8516e5..381466e123 100644 --- a/dumux/discretization/cellcentered/mpfa/localassemblerbase.hh +++ b/dumux/discretization/cellcentered/mpfa/localassemblerbase.hh @@ -161,6 +161,49 @@ class InteractionVolumeAssemblerBase return u; } + /*! + * \brief Assembles the solution gradients in the + * sub-control volumes within an interaction volume. + * \note This requires the data handle to be fully assembled already. + * + * \param handle The data handle in which the vector is stored + * \param iv The interaction volume + */ + template< class DataHandle, class IV > + static std::vector< typename IV::Traits::LocalScvType::GlobalCoordinate > + assembleScvGradients(const DataHandle& handle, const IV& iv) + { + const auto u = assembleFaceUnkowns(handle, iv); + + using LocalScv = typename IV::Traits::LocalScvType; + using Gradient = typename LocalScv::GlobalCoordinate; + + std::vector<Gradient> result; result.reserve(iv.numScvs()); + for (unsigned int scvIdx = 0; scvIdx < iv.numScvs(); ++scvIdx) + { + const auto& scv = iv.localScv(scvIdx); + + Gradient gradU(0.0); + for (unsigned int dir = 0; dir < LocalScv::myDimension; ++dir) + { + auto nu = scv.nu(dir); + + // obtain face pressure + const auto& scvf = iv.localScvf( scv.localScvfIndex(dir) ); + const auto faceU = !scvf.isDirichlet() ? u[scvf.localDofIndex()] + : handle.uj()[scvf.localDofIndex()]; + + nu *= faceU - handle.uj()[scv.localDofIndex()]; + gradU += nu; + } + + gradU /= scv.detX(); + result.emplace_back( std::move(gradU) ); + } + + return result; + } + /*! * \brief Assembles the gravitational flux contributions on the scvfs within an * interaction volume. -- GitLab