14#ifndef DUMUX_DISCRETIZATION_CC_MPFA_LOCAL_ASSEMBLER_HELPER_HH 
   15#define DUMUX_DISCRETIZATION_CC_MPFA_LOCAL_ASSEMBLER_HELPER_HH 
   36    struct HasMatrixResize
 
   39        auto operator()(
const M& m) -> 
decltype(std::declval<M>().resize(0, 0))
 
   44    struct HasVectorResize
 
   47        auto operator()(
const V& v) -> 
decltype(std::declval<V>().resize(0))
 
   51    template<
class Matrix>
 
   52    static constexpr auto matrixHasResizeFunction()
 
   53    { 
return decltype( 
isValid(HasMatrixResize())(std::declval<Matrix>()) )::value; }
 
   55    template<
class Vector>
 
   56    static constexpr auto vectorHasResizeFunction()
 
   57    { 
return decltype( 
isValid(HasVectorResize())(std::declval<Vector>()) )::value; }
 
   69    template< 
class FVElementGeometry, 
class DataHandle, 
class IV >
 
   74        assert(iv.numUnknowns() > 0);
 
   78        handle.CA().rightmultiply(handle.A());
 
   80        handle.AB().leftmultiply(handle.A());
 
   83        using GridView = 
typename IV::Traits::GridView;
 
   84        static constexpr int dim = GridView::dimension;
 
   85        static constexpr int dimWorld = GridView::dimensionworld;
 
   89            auto& tijOut = handle.tijOutside();
 
   90            tijOut.resize(iv.numFaces());
 
   91            using LocalIndexType = 
typename IV::Traits::IndexSet::LocalIndexType;
 
   92            for (LocalIndexType fIdx = 0; fIdx < iv.numFaces(); ++fIdx)
 
   94                const auto& curGlobalScvf = fvGeometry.scvf(iv.localScvf(fIdx).gridScvfIndex());
 
   95                const auto numOutsideFaces = curGlobalScvf.boundary() ? 0 : curGlobalScvf.numOutsideScvs();
 
   97                tijOut[fIdx].resize(numOutsideFaces);
 
   98                std::for_each(tijOut[fIdx].begin(),
 
  104            for (
const auto& localFaceData : iv.localFaceData())
 
  107                if (!localFaceData.isOutsideFace())
 
  110                const auto scvIdx = localFaceData.ivLocalInsideScvIndex();
 
  111                const auto scvfIdx = localFaceData.ivLocalScvfIndex();
 
  112                const auto idxInOut = localFaceData.scvfLocalOutsideScvfIndex();
 
  114                const auto& wijk = handle.omegas()[scvfIdx][idxInOut+1];
 
  115                auto& tij = tijOut[scvfIdx][idxInOut];
 
  118                for (
unsigned int dir = 0; dir < dim; dir++)
 
  121                    const auto& scvf = iv.localScvf(iv.localScv(scvIdx).localScvfIndex(dir));
 
  124                    if (!scvf.isDirichlet())
 
  126                        auto tmp = handle.AB()[scvf.localDofIndex()];
 
  131                        tij[scvf.localDofIndex()] -= wijk[dir];
 
  134                    tij[scvIdx] += wijk[dir];
 
 
  147    template< 
class DataHandle, 
class IV >
 
  148    static typename IV::Traits::MatVecTraits::FaceVector
 
  151        typename IV::Traits::MatVecTraits::FaceVector 
u;
 
  160        handle.AB().mv(handle.uj(), 
u);
 
  163        if (handle.deltaG().size() == iv.numUnknowns())
 
  164            handle.A().umv(handle.deltaG(), 
u);
 
 
  177    template< 
class DataHandle, 
class IV >
 
  178    static std::vector< typename IV::Traits::LocalScvType::GlobalCoordinate >
 
  183        using LocalScv = 
typename IV::Traits::LocalScvType;
 
  184        using Gradient = 
typename LocalScv::GlobalCoordinate;
 
  186        std::vector<Gradient> result; result.reserve(iv.numScvs());
 
  187        for (
unsigned int scvIdx = 0; scvIdx < iv.numScvs(); ++scvIdx)
 
  189            const auto& scv = iv.localScv(scvIdx);
 
  192            for (
unsigned int dir = 0; dir < LocalScv::myDimension; ++dir)
 
  194                auto nu = scv.nu(dir);
 
  197                const auto& scvf = iv.localScvf( scv.localScvfIndex(dir) );
 
  198                const auto faceU = !scvf.isDirichlet() ? 
u[scvf.localDofIndex()]
 
  199                                                       : handle.uj()[scvf.localDofIndex()];
 
  201                nu *= faceU - handle.uj()[scv.localDofIndex()];
 
  206            result.emplace_back( std::move(gradU) );
 
 
  213    template< 
class Matrix,
 
  215              std::enable_if_t<matrixHasResizeFunction<Matrix>(), 
int> = 0 >
 
  218        M.resize(rows, cols);
 
 
  222    template< 
class Matrix,
 
  224              std::enable_if_t<!matrixHasResizeFunction<Matrix>(), 
int> = 0 >
 
  229    template< 
class Vector,
 
  231              std::enable_if_t<vectorHasResizeFunction<Vector>(), 
int> = 0 >
 
  238    template< 
class Vector,
 
  240              std::enable_if_t<!vectorHasResizeFunction<Vector>(), 
int> = 0 >
 
 
A class that contains helper functions as well as functionality which is common to different mpfa sch...
Definition localassemblerhelper.hh:34
static void resizeVector(Vector &v, size_type rows)
resizes a vector to the given size (specialization for static vector type - do nothing)
Definition localassemblerhelper.hh:241
static void solveLocalSystem(const FVElementGeometry &fvGeometry, DataHandle &handle, IV &iv)
Solves a previously assembled iv-local system of equations and stores the resulting transmissibilitie...
Definition localassemblerhelper.hh:70
static std::vector< typename IV::Traits::LocalScvType::GlobalCoordinate > assembleScvGradients(const DataHandle &handle, const IV &iv)
Assembles the solution gradients in the sub-control volumes within an interaction volume.
Definition localassemblerhelper.hh:179
static void resizeMatrix(Matrix &M, size_type rows, size_type cols)
resizes a matrix to the given sizes (specialization for dynamic matrix type)
Definition localassemblerhelper.hh:216
static void resizeVector(Vector &v, size_type size)
resizes a vector to the given size (specialization for dynamic matrix type)
Definition localassemblerhelper.hh:232
static IV::Traits::MatVecTraits::FaceVector assembleFaceUnkowns(const DataHandle &handle, const IV &iv)
Assembles the vector of face unknowns within an interaction volume.
Definition localassemblerhelper.hh:149
Dune::DynamicMatrix< Scalar > multiplyMatrices(const Dune::DynamicMatrix< Scalar > &M1, const Dune::DynamicMatrix< Scalar > &M2)
Multiply two dynamic matrices.
Definition math.hh:751
constexpr auto isValid(const Expression &t)
A function that creates a test functor to do class member introspection at compile time.
Definition isvalid.hh:81
A helper function for class member function introspection.
const Scalar PengRobinsonMixture< Scalar, StaticParameters >::u
Definition pengrobinsonmixture.hh:138