Commit ff54a3c1 authored by Timo Koch's avatar Timo Koch
Browse files

[discretization] Add interfaces element/isBound to grid geometry local views

parent f1a8c705
......@@ -26,6 +26,7 @@
#ifndef DUMUX_DISCRETIZATION_BOX_FV_ELEMENT_GEOMETRY_HH
#define DUMUX_DISCRETIZATION_BOX_FV_ELEMENT_GEOMETRY_HH
#include <optional>
#include <dune/geometry/type.hh>
#include <dune/localfunctions/lagrange/pqkfactory.hh>
......@@ -114,7 +115,7 @@ public:
//! Get a local finite element basis
const FeLocalBasis& feLocalBasis() const
{
return gridGeometry().feCache().get(elemGeometryType_).localBasis();
return gridGeometry().feCache().get(element_->type()).localBasis();
}
//! The total number of sub control volumes
......@@ -142,10 +143,19 @@ public:
//! For compatibility reasons with the FVGeometry cache being disabled
void bindElement(const Element& element)
{
elemGeometryType_ = element.type();
element_ = element;
// cache element index
eIdx_ = gridGeometry().elementMapper().index(element);
}
//! Returns true if bind/bindElement has already been called
bool isBound() const
{ return static_cast<bool>(element_); }
//! The bound element
const Element& element() const
{ return *element_; }
//! The grid geometry we are a restriction of
const GridGeometry& gridGeometry() const
{ return *gridGeometryPtr_; }
......@@ -155,10 +165,10 @@ public:
{ return gridGeometry().hasBoundaryScvf(eIdx_); }
private:
Dune::GeometryType elemGeometryType_;
const GridGeometry* gridGeometryPtr_;
GridIndexType eIdx_;
std::optional<Element> element_;
};
//! specialization in case the FVElementGeometries are not stored
......@@ -231,7 +241,7 @@ public:
//! Get a local finite element basis
const FeLocalBasis& feLocalBasis() const
{
return gridGeometry().feCache().get(elemGeometryType_).localBasis();
return gridGeometry().feCache().get(element_->type()).localBasis();
}
//! The total number of sub control volumes
......@@ -259,10 +269,19 @@ public:
//! For compatibility reasons with the FVGeometry cache being disabled
void bindElement(const Element& element)
{
element_ = element;
eIdx_ = gridGeometry().elementMapper().index(element);
makeElementGeometries(element);
}
//! Returns true if bind/bindElement has already been called
bool isBound() const
{ return static_cast<bool>(element_); }
//! The bound element
const Element& element() const
{ return *element_; }
//! The grid geometry we are a restriction of
const GridGeometry& gridGeometry() const
{ return *gridGeometryPtr_; }
......@@ -279,7 +298,6 @@ private:
// get the element geometry
auto elementGeometry = element.geometry();
elemGeometryType_ = elementGeometry.type();
const auto refElement = referenceElement(elementGeometry);
// get the sub control volume geometries of this element
......@@ -348,8 +366,8 @@ private:
}
//! The bound element
Dune::GeometryType elemGeometryType_;
GridIndexType eIdx_;
std::optional<Element> element_;
//! The global geometry this is a restriction of
const GridGeometry* gridGeometryPtr_;
......
......@@ -26,6 +26,7 @@
#ifndef DUMUX_DISCRETIZATION_CCMPFA_FV_ELEMENT_GEOMETRY_HH
#define DUMUX_DISCRETIZATION_CCMPFA_FV_ELEMENT_GEOMETRY_HH
#include <optional>
#include <dune/common/exceptions.hh>
#include <dune/common/iteratorrange.hh>
......@@ -148,9 +149,18 @@ public:
//! Bind only element-local
void bindElement(const Element& element)
{
element_ = element;
scvIndices_[0] = gridGeometry().elementMapper().index(element);
}
//! Returns true if bind/bindElement has already been called
bool isBound() const
{ return static_cast<bool>(element_); }
//! The bound element
const Element& element() const
{ return *element_; }
//! The global finite volume geometry we are a restriction of
const GridGeometry& gridGeometry() const
{ return *gridGeometryPtr_; }
......@@ -161,6 +171,7 @@ public:
private:
std::optional<Element> element_;
std::array<GridIndexType, 1> scvIndices_;
const GridGeometry* gridGeometryPtr_;
};
......@@ -307,9 +318,18 @@ public:
void bindElement(const Element& element)
{
clear();
element_ = element;
makeElementGeometries(element);
}
//! Returns true if bind/bindElement has already been called
bool isBound() const
{ return static_cast<bool>(element_); }
//! The bound element
const Element& element() const
{ return *element_; }
//! The global finite volume geometry we are a restriction of
const GridGeometry& gridGeometry() const
{ return *gridGeometryPtr_; }
......@@ -530,6 +550,7 @@ private:
}
const GridGeometry* gridGeometryPtr_;
std::optional<Element> element_;
// local storage after binding an element
std::array<GridIndexType, 1> scvIndices_;
......
......@@ -26,6 +26,7 @@
#ifndef DUMUX_DISCRETIZATION_CCTPFA_FV_ELEMENT_GEOMETRY_HH
#define DUMUX_DISCRETIZATION_CCTPFA_FV_ELEMENT_GEOMETRY_HH
#include <optional>
#include <algorithm>
#include <array>
#include <vector>
......@@ -151,10 +152,18 @@ public:
//! Bind only element-local
void bindElement(const Element& element)
{
elementPtr_ = &element;
scvIndices_[0] = gridGeometry().elementMapper().index(*elementPtr_);
element_ = element;
scvIndices_[0] = gridGeometry().elementMapper().index(*element_);
}
//! Returns true if bind/bindElement has already been called
bool isBound() const
{ return static_cast<bool>(element_); }
//! The bound element
const Element& element() const
{ return *element_; }
//! The global finite volume geometry we are a restriction of
const GridGeometry& gridGeometry() const
{ return *gridGeometryPtr_; }
......@@ -165,7 +174,7 @@ public:
private:
const Element* elementPtr_;
std::optional<Element> element_;
std::array<GridIndexType, 1> scvIndices_;
const GridGeometry* gridGeometryPtr_;
};
......@@ -350,12 +359,20 @@ public:
void bindElement(const Element& element)
{
clear();
elementPtr_ = &element;
element_ = element;
scvfs_.reserve(element.subEntities(1));
scvfIndices_.reserve(element.subEntities(1));
makeElementGeometries(element);
}
//! Returns true if bind/bindElement has already been called
bool isBound() const
{ return static_cast<bool>(element_); }
//! The bound element
const Element& element() const
{ return *element_; }
//! The global finite volume geometry we are a restriction of
const GridGeometry& gridGeometry() const
{ return *gridGeometryPtr_; }
......@@ -479,7 +496,7 @@ private:
// only create subcontrol faces where the outside element is the bound element
if (dim == dimWorld)
{
if (scvfNeighborVolVarIndices[0] == gridGeometry().elementMapper().index(*elementPtr_))
if (scvfNeighborVolVarIndices[0] == gridGeometry().elementMapper().index(*element_))
{
ScvfGridIndexStorage scvIndices({eIdx, scvfNeighborVolVarIndices[0]});
neighborScvfs_.emplace_back(intersection,
......@@ -499,7 +516,7 @@ private:
{
for (unsigned outsideScvIdx = 0; outsideScvIdx < scvfNeighborVolVarIndices.size(); ++outsideScvIdx)
{
if (scvfNeighborVolVarIndices[outsideScvIdx] == gridGeometry().elementMapper().index(*elementPtr_))
if (scvfNeighborVolVarIndices[outsideScvIdx] == gridGeometry().elementMapper().index(*element_))
{
ScvfGridIndexStorage scvIndices;
scvIndices.resize(scvfNeighborVolVarIndices.size() + 1);
......@@ -560,7 +577,7 @@ private:
hasBoundaryScvf_ = false;
}
const Element* elementPtr_; //!< the element to which this fvgeometry is bound
std::optional<Element> element_; //!< the element to which this fvgeometry is bound
const GridGeometry* gridGeometryPtr_; //!< the grid fvgeometry
// local storage after binding an element
......
......@@ -62,6 +62,14 @@ public:
void bindElement(const Element& element)
{ bind(element); }
//! Returns true if bind/bindElement has already been called
bool isBound() const
{ return feBasisLocalView_.isBound(); }
//! The bound element
const Element& element() const
{ return feBasisLocalView_.element(); }
//! Return the finite element basis local view
const FEBasisLocalView& feBasisLocalView() const
{ return feBasisLocalView_; }
......
......@@ -24,6 +24,7 @@
#ifndef DUMUX_DISCRETIZATION_PNM_FV_ELEMENT_GEOMETRY_HH
#define DUMUX_DISCRETIZATION_PNM_FV_ELEMENT_GEOMETRY_HH
#include <optional>
#include <dumux/common/indextraits.hh>
#include <dumux/discretization/scvandscvfiterators.hh>
......@@ -103,7 +104,7 @@ public:
//! Get a local finite element basis
const FeLocalBasis& feLocalBasis() const
{
return gridGeometry().feCache().get(elementPtr_->geometry().type()).localBasis();
return gridGeometry().feCache().get(element_->type()).localBasis();
}
//! The total number of sub control volumes
......@@ -131,10 +132,18 @@ public:
//! For compatibility reasons with the FVGeometry cache being disabled
void bindElement(const Element& element)
{
elementPtr_ = &element;
element_ = element;
eIdx_ = gridGeometry().elementMapper().index(element);
}
//! Returns true if bind/bindElement has already been called
bool isBound() const
{ return static_cast<bool>(element_); }
//! The bound element
const Element& element() const
{ return *element_; }
//! The global finite volume geometry we are a restriction of
const GridGeometry& gridGeometry() const
{ return *gridGeometryPtr_; }
......@@ -144,7 +153,7 @@ public:
{ return gridGeometry().hasBoundaryScvf(eIdx_); }
private:
const Element* elementPtr_;
std::optional<Element> element_;
const GridGeometry* gridGeometryPtr_;
GridIndexType eIdx_;
......@@ -214,7 +223,7 @@ public:
//! Get a local finite element basis
const FeLocalBasis& feLocalBasis() const
{
return gridGeometry().feCache().get(elementPtr_->geometry().type()).localBasis();
return gridGeometry().feCache().get(element_->type()).localBasis();
}
//! The total number of sub control volumes
......@@ -242,11 +251,19 @@ public:
//! For compatibility reasons with the FVGeometry cache being disabled
void bindElement(const Element& element)
{
elementPtr_ = &element;
element_ = element;
eIdx_ = gridGeometry().elementMapper().index(element);
makeElementGeometries(element);
}
//! Returns true if bind/bindElement has already been called
bool isBound() const
{ return static_cast<bool>(element_); }
//! The bound element
const Element& element() const
{ return *element_; }
//! The global finite volume geometry we are a restriction of
const GridGeometry& gridGeometry() const
{ return *gridGeometryPtr_; }
......@@ -299,7 +316,7 @@ private:
}
//! The bound element
const Element* elementPtr_;
std::optional<Element> element_;
GridIndexType eIdx_;
//! The global geometry this is a restriction of
......
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