Commit d13f4857 authored by Dennis Gläser's avatar Dennis Gläser
Browse files

[pmflow][fluxvariables] add experimental implementation

parent 64d3fa8f
......@@ -25,6 +25,9 @@
#define DUMUX_DISCRETIZATION_FLUXVARIABLESBASE_HH
#include <vector>
#include <optional>
#include <dumux/discretization/method.hh>
namespace Dumux {
......@@ -93,6 +96,82 @@ private:
const ElementFluxVariablesCache* elemFluxVarsCachePtr_; //!< Pointer to the current element flux variables cache
};
namespace Experimental {
/*!
* \ingroup Flux
* \brief Base class for the flux variables living on a sub control volume face
* \tparam LocalContext the element stencil-local context, consisting of
* the local geometry and primary & secondary variables
*/
template<class LocalContext>
class FluxVariablesBase
{
using FVElementGeometry = typename LocalContext::ElementGridGeometry;
using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
using GridGeometry = typename FVElementGeometry::GridGeometry;
using GridView = typename GridGeometry::GridView;
using Element = typename GridView::template Codim<0>::Entity;
using Stencil = std::vector<std::size_t>;
static constexpr bool isBox = GridGeometry::discMethod == DiscretizationMethod::box;
public:
//! Initialize the flux variables storing some temporary pointers
void init(const LocalContext& context,
const SubControlVolumeFace& scvf)
{
contextPtr_ = &context;
scvFacePtr_ = &scvf;
// for cell-centered methods, the element inside of the scvf may
// not be the one the FVElementGeometry is bound to.
if constexpr (!isBox)
{
const auto& fvGeometry = context.elementGridGeometry();
const auto& gridGeometry = fvGeometry.gridGeometry();
const auto& boundElement = fvGeometry.element();
const auto& insideScv = fvGeometry.scv(scvf.insideScvIdx());
const auto boundElementIdx = gridGeometry.elementMapper().index(boundElement);
if (insideScv.elementIndex() != boundElementIdx)
element_ = gridGeometry.element(boundElementIdx);
}
}
decltype(auto) problem() const
{ return elemVolVars().gridVolVars().problem(); }
decltype(auto) elemVolVars() const
{ return contextPtr_->elementVariables().elemVolVars(); }
decltype(auto) elemFluxVarsCache() const
{ return contextPtr_->elementVariables().elemFluxVarsCache(); }
const SubControlVolumeFace& scvFace() const
{ return *scvFacePtr_; }
const FVElementGeometry& fvGeometry() const
{ return contextPtr_->elementGridGeometry(); }
const Element& element() const
{
if constexpr (isBox)
return contextPtr_->elementGridGeometry().element();
else
return element_ ? *element_
: contextPtr_->elementGridGeometry().element();
}
private:
const LocalContext* contextPtr_; //!< Pointer to the local context
const SubControlVolumeFace* scvFacePtr_; //!< Pointer to the sub control volume face for which the flux variables are created
std::optional<Element> element_; //!< The element on the inside of the sub-control volume face
};
} // end namespace Experimental
} // end namespace Dumux
#endif
......@@ -29,27 +29,17 @@
#include <array>
#include <dumux/common/properties.hh>
#include <dumux/discretization/localcontext.hh>
#include <dumux/flux/fluxvariablesbase.hh>
#include <dumux/flux/upwindscheme.hh>
namespace Dumux {
namespace Detail {
/*!
* \ingroup PorousmediumflowModels
* \brief The porous medium flux variables class that computes advective / convective,
* molecular diffusive and heat conduction fluxes.
*
* \param TypeTag The type tag for access to type traits
* \param UpScheme The upwind scheme to be applied to advective fluxes
* \note Not all specializations are currently implemented
*/
template<class TypeTag,
class UpScheme = UpwindScheme<GetPropType<TypeTag, Properties::GridGeometry>> >
class PorousMediumFluxVariables
: public FluxVariablesBase<GetPropType<TypeTag, Properties::Problem>,
typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView,
typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView,
typename GetPropType<TypeTag, Properties::GridFluxVariablesCache>::LocalView>
//! Implementation of the flux variables to achieve compatibility-layer with experimental assembly
template<class TypeTag, class BaseFluxVariables, class UpScheme>
class PorousMediumFluxVariablesImpl
: public BaseFluxVariables
{
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
using ModelTraits = GetPropType<TypeTag, Properties::ModelTraits>;
......@@ -72,7 +62,7 @@ public:
static constexpr bool enableThermalNonEquilibrium = getPropValue<TypeTag, Properties::EnableThermalNonEquilibrium>();
//! The constructor
PorousMediumFluxVariables()
PorousMediumFluxVariablesImpl()
{
advFluxIsCached_.reset();
advFluxBeforeUpwinding_.fill(0.0);
......@@ -165,6 +155,47 @@ private:
mutable std::array<Scalar, numPhases> advFluxBeforeUpwinding_;
};
} // end namespace Detail
/*!
* \ingroup PorousmediumflowModels
* \brief The porous medium flux variables class that computes advective / convective,
* molecular diffusive and heat conduction fluxes.
*
* \param TypeTag The type tag for access to type traits
* \param UpScheme The upwind scheme to be applied to advective fluxes
* \note Not all specializations are currently implemented
*/
template<class TypeTag,
class UpScheme = UpwindScheme<GetPropType<TypeTag, Properties::GridGeometry>> >
using PorousMediumFluxVariables
= Detail::PorousMediumFluxVariablesImpl<TypeTag,
FluxVariablesBase<GetPropType<TypeTag, Properties::Problem>,
typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView,
typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView,
typename GetPropType<TypeTag, Properties::GridFluxVariablesCache>::LocalView>,
UpScheme>;
namespace Experimental {
/*!
* \ingroup PorousmediumflowModels
* \brief The porous medium flux variables class that computes advective / convective,
* molecular diffusive and heat conduction fluxes.
*
* \param TypeTag The type tag for access to type traits
* \param UpScheme The upwind scheme to be applied to advective fluxes
* \note Not all specializations are currently implemented
* \todo Get rid of type tag as template arg somehow!
*/
template<class TypeTag,
class UpScheme = UpwindScheme<GetPropType<TypeTag, Properties::GridGeometry>> >
using PorousMediumFluxVariables
= Dumux::Detail::PorousMediumFluxVariablesImpl<TypeTag,
FluxVariablesBase<DefaultLocalContext<typename GetPropType<TypeTag, Dumux::Properties::GridVariables>::LocalView>>,
UpScheme>;
} // end namespace Experimental
} // end namespace Dumux
#endif
......@@ -151,28 +151,8 @@ public:
const LocalContext& context,
const SubControlVolumeFace& scvf)
{
const auto& fvGeometry = context.elementGridGeometry();
const auto& elemVolVars = context.elementVariables().elemVolVars();
const auto& elemFluxVarsCache = context.elementVariables().elemFluxVarsCache();
FluxVariables fluxVars;
// for box, the "inside" element is always the one the grid geom is bound to
if constexpr (GridGeometry::discMethod == DiscretizationMethod::box)
fluxVars.init(problem, fvGeometry.element(), fvGeometry, elemVolVars, scvf, elemFluxVarsCache);
else
{
const auto& gridGeom = fvGeometry.gridGeometry();
const auto& insideScv = fvGeometry.scv(scvf.insideScvIdx());
const auto boundElementIdx = gridGeom.elementMapper().index(fvGeometry.element());
if (insideScv.elementIndex() == boundElementIdx)
fluxVars.init(problem, fvGeometry.element(), fvGeometry, elemVolVars, scvf, elemFluxVarsCache);
else
fluxVars.init(problem, gridGeom.element(insideScv.elementIndex()),
fvGeometry, elemVolVars, scvf, elemFluxVarsCache);
}
fluxVars.init(context, scvf);
NumEqVector flux;
for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
......
......@@ -41,6 +41,7 @@
#include <dumux/linear/seqsolverbackend.hh>
#include <dumux/porousmediumflow/immiscible/operators.hh>
#include <dumux/porousmediumflow/fluxvariables.hh>
#include <dumux/timestepping/multistagemethods.hh>
#include <dumux/assembly/fv/localoperator.hh>
......@@ -127,8 +128,8 @@ int main(int argc, char** argv)
// the assembler (we use the immiscible operators to define the system of equations)
using ModelTraits = GetPropType<TypeTag, Properties::ModelTraits>;
using FluxVariables = GetPropType<TypeTag, Properties::FluxVariables>;
using ElementVariables = typename GridVariables::LocalView;
using FluxVariables = Experimental::PorousMediumFluxVariables<TypeTag>;
using Operators = Experimental::FVImmiscibleOperators<ModelTraits, FluxVariables, ElementVariables>;
using LocalOperator = Experimental::FVLocalOperator<Operators>;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment