diff --git a/dumux/discretization/staggered/stencils.hh b/dumux/discretization/staggered/stencils.hh index a51d5bf075a52c75f506fc9f21eeb95ff885cbeb..a5a38759f1ce62590f04624ffc814cce5f444a77 100644 --- a/dumux/discretization/staggered/stencils.hh +++ b/dumux/discretization/staggered/stencils.hh @@ -194,23 +194,24 @@ public: return faceStencils_[scvFace.dofIndexSelf() - numElements]; } + /*! + * \brief Returns the size of a complete face dof stencil + */ size_t completeFaceDofStencilSize(const int idx) const { // const IndexType numElements = problemPtr_->gridView().size(0); + assert(fullFaceDofStencils_ && "fullFaceDofStencils_ has already been called and deleted!"); return fullFaceDofStencils_.get()[0][idx/*-numElements*/].size(); // TODO: why does this not work? } - void getFullFaceDofStencils(std::unique_ptr<std::vector<Stencil>>& ptr) + /*! + * \brief Returns a unique pointer to the complete face dof stencils which is used once for setting up the global matrix and deleted afterwards + */ + auto getFullFaceDofStencilsPtr() { - std::cout << "before move: "; - if(fullFaceDofStencils_) - std::cout << "object still there" << std::endl; - ptr = std::move(fullFaceDofStencils_); - - std::cout << "after move: "; - if(fullFaceDofStencils_) - std::cout << "object still there" << std::endl; + assert(fullFaceDofStencils_ && "fullFaceDofStencils_ has already been used and deleted!"); + return std::move(fullFaceDofStencils_); } diff --git a/dumux/freeflow/staggered/model.hh b/dumux/freeflow/staggered/model.hh index bb18ce217f37ab60c85ac975e0d9a13d9aef4279..8ac092872474dd11ab0d9d7ea27be0b149df06f0 100644 --- a/dumux/freeflow/staggered/model.hh +++ b/dumux/freeflow/staggered/model.hh @@ -144,16 +144,20 @@ public: return this->gridView_().size(0) + this->gridView_().size(1);; } - size_t completeFaceDofStencilSize(const int idx) + /*! + * \brief Returns the size of a complete face dof stencil + */ + size_t completeFaceDofStencilSize(const int idx) const { return this->stencilsVector_.completeFaceDofStencilSize(idx); } - template<class Stencil> - void getFullFaceDofStencils(std::unique_ptr<std::vector<Stencil>>& ptr) + /*! + * \brief Returns a unique pointer to the complete face dof stencils which is used once for setting up the global matrix and deleted afterwards + */ + auto getFullFaceDofStencilsPtr() { - this->stencilsVector_.getFullFaceDofStencils(ptr); - // TODO: find better way to do this + return this->stencilsVector_.getFullFaceDofStencilsPtr(); } }; diff --git a/dumux/implicit/staggered/assembler.hh b/dumux/implicit/staggered/assembler.hh index 4d36f5390e07b98e3453f1c4c8e8116bdb26a5bf..af0a097e5f5ab0c7e7a344038dc7d290dba51154 100644 --- a/dumux/implicit/staggered/assembler.hh +++ b/dumux/implicit/staggered/assembler.hh @@ -77,16 +77,12 @@ class StaggeredAssembler : public ImplicitAssembler<TypeTag> this->matrix().addindex(globalI, globalJ); } - // TODO: this is a mess. find a better way for the pointer handling! - using Stencil = std::vector<IndexType>; - std::unique_ptr<std::vector<Stencil>> ptr; - - this->model_().getFullFaceDofStencils(ptr); + auto ptr = this->model_().getFullFaceDofStencilsPtr(); if(ptr) std::cout << "success!!!" << std::endl; - auto& fullFaceDofStencils = ptr.get()[0]; + const auto& fullFaceDofStencils = ptr.get()[0]; int globalI = this->gridView_().size(0); for(const auto& stencil : fullFaceDofStencils)