diff --git a/dumux/discretization/cellcentered/tpfa/fvelementgeometry.hh b/dumux/discretization/cellcentered/tpfa/fvelementgeometry.hh index 12837c09b265a23fdba0819608df3a9daac31aeb..4167cf059e8ad794b2a59ded60b76b132a750b62 100644 --- a/dumux/discretization/cellcentered/tpfa/fvelementgeometry.hh +++ b/dumux/discretization/cellcentered/tpfa/fvelementgeometry.hh @@ -66,7 +66,7 @@ class CCTpfaFVElementGeometry<TypeTag, true> using Element = typename GridView::template Codim<0>::Entity; using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); - using ScvIterator = Dumux::ScvIterator<SubControlVolume, std::vector<IndexType>, ThisType>; + using ScvIterator = Dumux::ScvIterator<SubControlVolume, std::array<IndexType, 1>, ThisType>; using ScvfIterator = Dumux::ScvfIterator<SubControlVolumeFace, std::vector<IndexType>, ThisType>; public: @@ -143,7 +143,7 @@ public: void bindElement(const Element& element) { elementPtr_ = &element; - scvIndices_ = std::vector<IndexType>({fvGridGeometry().elementMapper().index(*elementPtr_)}); + scvIndices_[0] = fvGridGeometry().elementMapper().index(*elementPtr_); } //! The global finite volume geometry we are a restriction of @@ -153,7 +153,7 @@ public: private: const Element* elementPtr_; - std::vector<IndexType> scvIndices_; + std::array<IndexType, 1> scvIndices_; const FVGridGeometry* fvGridGeometryPtr_; }; @@ -176,9 +176,6 @@ class CCTpfaFVElementGeometry<TypeTag, false> static const int dim = GridView::dimension; static const int dimWorld = GridView::dimensionworld; - using ScvIterator = Dumux::ScvIterator<SubControlVolume, std::vector<IndexType>, ThisType>; - using ScvfIterator = Dumux::ScvfIterator<SubControlVolumeFace, std::vector<IndexType>, ThisType>; - public: //! Constructor CCTpfaFVElementGeometry(const FVGridGeometry& fvGridGeometry) @@ -231,11 +228,11 @@ public: //! This is a free function found by means of ADL //! To iterate over all sub control volumes of this FVElementGeometry use //! for (auto&& scv : scvs(fvGeometry)) - friend inline Dune::IteratorRange<typename std::vector<SubControlVolume>::const_iterator> + friend inline Dune::IteratorRange<typename std::array<SubControlVolume, 1>::const_iterator> scvs(const ThisType& g) { - using Iter = typename std::vector<SubControlVolume>::const_iterator; - return Dune::IteratorRange<Iter>(g.scvs_.begin(), g.scvs_.end()); + using IteratorType = typename std::array<SubControlVolume, 1>::const_iterator; + return Dune::IteratorRange<IteratorType>(g.scvs_.begin(), g.scvs_.end()); } //! iterator range for sub control volumes faces. Iterates over @@ -246,8 +243,8 @@ public: friend inline Dune::IteratorRange<typename std::vector<SubControlVolumeFace>::const_iterator> scvfs(const ThisType& g) { - using Iter = typename std::vector<SubControlVolumeFace>::const_iterator; - return Dune::IteratorRange<Iter>(g.scvfs_.begin(), g.scvfs_.end()); + using IteratorType = typename std::vector<SubControlVolumeFace>::const_iterator; + return Dune::IteratorRange<IteratorType>(g.scvfs_.begin(), g.scvfs_.end()); } //! number of sub control volumes in this fv element geometry @@ -384,8 +381,8 @@ private: void makeElementGeometries(const Element& element) { const auto eIdx = fvGridGeometry().elementMapper().index(element); - scvs_.emplace_back(element.geometry(), eIdx); - scvIndices_.emplace_back(eIdx); + scvs_[0] = SubControlVolume(element.geometry(), eIdx); + scvIndices_[0] = eIdx; const auto& scvFaceIndices = fvGridGeometry().scvfIndicesOfScv(eIdx); const auto& neighborVolVarIndices = fvGridGeometry().neighborVolVarIndices(eIdx); @@ -523,9 +520,7 @@ private: //! Clear all local data void clear() { - scvIndices_.clear(); scvfIndices_.clear(); - scvs_.clear(); scvfs_.clear(); flippedScvfIndices_.clear(); @@ -536,21 +531,21 @@ private: flippedNeighborScvfIndices_.clear(); } - //! the bound element - const Element* elementPtr_; - - const FVGridGeometry* fvGridGeometryPtr_; + const Element* elementPtr_; //!< the element to which this fvgeometry is bound + const FVGridGeometry* fvGridGeometryPtr_; //!< the grid fvgeometry // local storage after binding an element - std::vector<IndexType> scvIndices_; + std::array<IndexType, 1> scvIndices_; + std::array<SubControlVolume, 1> scvs_; + std::vector<IndexType> scvfIndices_; - std::vector<SubControlVolume> scvs_; std::vector<SubControlVolumeFace> scvfs_; std::vector<std::vector<IndexType>> flippedScvfIndices_; std::vector<IndexType> neighborScvIndices_; - std::vector<IndexType> neighborScvfIndices_; std::vector<SubControlVolume> neighborScvs_; + + std::vector<IndexType> neighborScvfIndices_; std::vector<SubControlVolumeFace> neighborScvfs_; std::vector<std::vector<IndexType>> flippedNeighborScvfIndices_; };