Commit 905895ee authored by Kilian Weishaupt's avatar Kilian Weishaupt
Browse files

[fvGridGeometry] Add numDofs() for convenience

* specialized for box/cc
parent f110b8ca
......@@ -88,6 +88,10 @@ public:
std::size_t numBoundaryScvf() const
{ return numBoundaryScvf_; }
//! The total number of degrees of freedom
std::size_t numDofs()
{ return this->gridView().size(dim); }
//! update all fvElementGeometries (do this again after grid adaption)
void update()
{
......@@ -100,7 +104,7 @@ public:
scvs_.resize(numElements);
scvfs_.resize(numElements);
boundaryDofIndices_.resize(this->gridView().size(dim), false);
boundaryDofIndices_.resize(numDofs(), false);
numScv_ = 0;
numScvf_ = 0;
......@@ -268,12 +272,16 @@ public:
std::size_t numBoundaryScvf() const
{ return numBoundaryScvf_; }
//! The total number of degrees of freedom
std::size_t numDofs() const
{ return this->gridView().size(dim); }
//! update all fvElementGeometries (do this again after grid adaption)
void update()
{
ParentType::update();
boundaryDofIndices_.resize(this->gridView().size(dim), false);
boundaryDofIndices_.resize(numDofs(), false);
// save global data on the grid's scvs and scvfs
// TODO do we need those information?
......
......@@ -102,6 +102,13 @@ public:
std::size_t numBoundaryScvf() const
{ return numBoundaryScvf_; }
/*!
* \brief Returns the total number of degrees of freedom.
*/
std::size_t numDofs() const
{ return this->gridView().size(0); }
/*!
* \brief Gets an element from a sub control volume contained in it.
*/
......@@ -164,7 +171,7 @@ public:
// determine the number of geometric entities
const auto numVert = this->gridView().size(dim);
const auto numScvs = this->gridView().size(0);
const auto numScvs = numDofs();
std::size_t numScvf = MpfaHelper::estimateNumScvf(this->gridView());
// resize containers
......@@ -475,6 +482,12 @@ public:
std::size_t numBoundaryScvf() const
{ return numBoundaryScvf_; }
/*!
* \brief Returns the total number of degrees of freedom.
*/
std::size_t numDofs() const
{ return this->gridView().size(0); }
/*!
* \brief Gets an element from a sub control volume contained in it.
*/
......@@ -548,7 +561,7 @@ public:
elementMap_.clear();
// resize containers
numScvs_ = this->gridView().size(0);
numScvs_ = numDofs();
scvfIndicesOfScv_.resize(numScvs_);
neighborVolVarIndices_.resize(numScvs_);
elementMap_.resize(numScvs_);
......
......@@ -93,6 +93,10 @@ public:
std::size_t numBoundaryScvf() const
{ return numBoundaryScvf_; }
//! The total number of degrees of freedom
std::size_t numDofs() const
{ return this->gridView().size(0); }
// Get an element from a sub control volume contained in it
Element element(const SubControlVolume& scv) const
{ return elementMap_.element(scv.elementIndex()); }
......@@ -120,7 +124,7 @@ public:
scvfs_.clear();
// reserve memory
IndexType numScvs = gridView_.size(0);
IndexType numScvs = numDofs();
scvs_.resize(numScvs);
scvfs_.reserve(getNumScvf_());
scvfIndicesOfScv_.resize(numScvs);
......
......@@ -95,6 +95,10 @@ public:
return numBoundaryScvf_;
}
//! The total number of degrees of freedom
std::size_t numDofs() const
{ return this->gridView().size(0); }
// Get an element from a sub control volume contained in it
Element element(const SubControlVolume& scv) const
{ return elementMap_.element(scv.elementIndex()); }
......@@ -116,7 +120,7 @@ public:
elementMap_.clear();
// determine size of containers
IndexType numScvs = this->gridView().size(0);
IndexType numScvs = numDofs();
IndexType numScvf = 0;
for (const auto& element : elements(this->gridView()))
numScvf += element.subEntities(1);
......@@ -343,6 +347,10 @@ public:
return numBoundaryScvf_;
}
//! The total number of degrees of freedom
std::size_t numDofs() const
{ return this->gridView().size(0); }
// Get an element from a sub control volume contained in it
Element element(const SubControlVolume& scv) const
{ return elementMap_.element(scv.elementIndex()); }
......@@ -362,7 +370,7 @@ public:
neighborVolVarIndices_.clear();
// reserve memory or resize the containers
numScvs_ = this->gridView().size(0);
numScvs_ = numDofs();
numScvf_ = 0;
numBoundaryScvf_ = 0;
elementMap_.resize(numScvs_);
......
......@@ -87,7 +87,7 @@ int main(int argc, char** argv) try
// the solution vector
using GridView = typename GET_PROP_TYPE(TypeTag, GridView);
using SolutionVector = typename GET_PROP_TYPE(TypeTag, SolutionVector);
SolutionVector x(leafGridView.size(GridView::dimension));
SolutionVector x(fvGridGeometry->numDofs());
// the grid variables
using GridVariables = typename GET_PROP_TYPE(TypeTag, GridVariables);
......
......@@ -86,7 +86,7 @@ int main(int argc, char** argv) try
// the solution vector
using SolutionVector = typename GET_PROP_TYPE(TypeTag, SolutionVector);
SolutionVector x(leafGridView.size(0));
SolutionVector x(fvGridGeometry->numDofs());
// the grid variables
using GridVariables = typename GET_PROP_TYPE(TypeTag, GridVariables);
......
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