diff --git a/dumux/multidomain/embedded/couplingmanagerbase.hh b/dumux/multidomain/embedded/couplingmanagerbase.hh index 2fe4e66c55799f8cb0f5e5732e06c6d46e47246f..b1cd9c4b723764465e17ee62bc85f5f405623203 100644 --- a/dumux/multidomain/embedded/couplingmanagerbase.hh +++ b/dumux/multidomain/embedded/couplingmanagerbase.hh @@ -419,7 +419,26 @@ public: const CouplingStencil<i>& emptyStencil(Dune::index_constant<i> dom) const { return std::get<i>(emptyStencil_); } + /*! + * \brief the solution vector of the subproblem + * \param domainIdx The domain index + * \note in case of numeric differentiation the solution vector always carries the deflected solution + */ + template<std::size_t i> + auto& curSol(Dune::index_constant<i> domainIdx) + { return ParentType::curSol(domainIdx); } + + /*! + * \brief the solution vector of the subproblem + * \param domainIdx The domain index + * \note in case of numeric differentiation the solution vector always carries the deflected solution + */ + template<std::size_t i> + const auto& curSol(Dune::index_constant<i> domainIdx) const + { return ParentType::curSol(domainIdx); } + protected: + using ParentType::curSol; //! computes the vertex indices per element for the box method template<std::size_t id> diff --git a/dumux/multidomain/embedded/extendedsourcestencil.hh b/dumux/multidomain/embedded/extendedsourcestencil.hh index bfdc88d867ca5d4a05ddd62fc3ab470bec870743..6a80947f99f4af397a876f36be46cdfef73536e6 100644 --- a/dumux/multidomain/embedded/extendedsourcestencil.hh +++ b/dumux/multidomain/embedded/extendedsourcestencil.hh @@ -94,15 +94,15 @@ public: * term depends on a non-local average of a quantity of the same domain * \note This is the same for box and cc */ - template<std::size_t i, class LocalAssemblerI, class SolutionVector, class JacobianMatrixDiagBlock, class GridVariables> + template<std::size_t i, class LocalAssemblerI, class JacobianMatrixDiagBlock, class GridVariables> void evalAdditionalDomainDerivatives(CouplingManager& couplingManager, Dune::index_constant<i> domainI, const LocalAssemblerI& localAssemblerI, - const SolutionVector& curSol, JacobianMatrixDiagBlock& A, GridVariables& gridVariables) const { - constexpr auto numEq = std::decay_t<decltype(curSol[domainI][0])>::size(); + const auto& curSolI = couplingManager.curSol(domainI); + constexpr auto numEq = std::decay_t<decltype(curSolI[0])>::size(); const auto& elementI = localAssemblerI.element(); // only do something if we have an extended stencil @@ -116,7 +116,7 @@ public: for (const auto dofIndex : extendedSourceStencil_(couplingManager, domainI, elementI)) { auto partialDerivs = origResidual; - const auto origPriVars = curSol[domainI][dofIndex]; + const auto origPriVars = curSolI[dofIndex]; // calculate derivatives w.r.t to the privars at the dof at hand for (int pvIdx = 0; pvIdx < numEq; pvIdx++) @@ -135,7 +135,7 @@ public: // derive the residuals numerically static const int numDiffMethod = getParam<int>("Assembly.NumericDifferenceMethod"); - NumericDifferentiation::partialDerivative(evalResiduals, curSol[domainI][dofIndex][pvIdx], + NumericDifferentiation::partialDerivative(evalResiduals, curSolI[dofIndex][pvIdx], partialDerivs, origResidual, numDiffMethod); // update the global stiffness matrix with the current partial derivatives @@ -157,6 +157,21 @@ public: } } + /*! + * \brief Deprecated overload + */ + template<std::size_t i, class LocalAssemblerI, class SolutionVector, class JacobianMatrixDiagBlock, class GridVariables> + [[deprecated("Use signature without curSol. Will be removed after release 3.5")]] + void evalAdditionalDomainDerivatives(CouplingManager& couplingManager, + Dune::index_constant<i> domainI, + const LocalAssemblerI& localAssemblerI, + const SolutionVector& curSol, + JacobianMatrixDiagBlock& A, + GridVariables& gridVariables) const + { + evalAdditionalDomainDerivatives(couplingManager, domainI, localAssemblerI, A, gridVariables); + } + //! clear the internal data void clear() { sourceStencils_.clear(); } @@ -175,7 +190,7 @@ private: if (auto stencil = sourceStencils_.find(bulkElementIdx); stencil != sourceStencils_.end()) return stencil->second; } - + return couplingManager.emptyStencil(domainId); }