Skip to content
Snippets Groups Projects
Commit acfbb01d authored by Timo Koch's avatar Timo Koch
Browse files

Merge branch 'feature/box-scvf-num-outside-scvs' into 'master'

Feature/box scvf num outside scvs

See merge request !2469
parents 76f29dcd 9f311e41
Branches
Tags
1 merge request!2469Feature/box scvf num outside scvs
...@@ -172,7 +172,7 @@ public: ...@@ -172,7 +172,7 @@ public:
return area_; return area_;
} }
//! returns bolean if the sub control volume face is on the boundary //! returns true if the sub control volume face is on the boundary
bool boundary() const bool boundary() const
{ {
return boundary_; return boundary_;
...@@ -183,20 +183,26 @@ public: ...@@ -183,20 +183,26 @@ public:
return unitOuterNormal_; return unitOuterNormal_;
} }
//! index of the inside sub control volume for spatial param evaluation //! index of the inside sub control volume
LocalIndexType insideScvIdx() const LocalIndexType insideScvIdx() const
{ {
return scvIndices_[0]; return scvIndices_[0];
} }
//! index of the outside sub control volume for spatial param evaluation //! Index of the i-th outside sub control volume or boundary scv index.
// This results in undefined behaviour if boundary is true // Results in undefined behaviour if i >= numOutsideScvs()
LocalIndexType outsideScvIdx() const LocalIndexType outsideScvIdx(int i = 0) const
{ {
assert(!boundary()); assert(!boundary());
return scvIndices_[1]; return scvIndices_[1];
} }
//! The number of scvs on the outside of this face
std::size_t numOutsideScvs() const
{
return static_cast<std::size_t>(!boundary());
}
//! The local index of this sub control volume face //! The local index of this sub control volume face
GridIndexType index() const GridIndexType index() const
{ {
......
...@@ -155,7 +155,7 @@ public: ...@@ -155,7 +155,7 @@ public:
Scalar area() const Scalar area() const
{ return area_; } { return area_; }
//! returns bolean if the sub control volume face is on the domain boundary //! returns true if the sub control volume face is on the domain boundary
bool boundary() const bool boundary() const
{ return boundary_; } { return boundary_; }
...@@ -175,12 +175,12 @@ public: ...@@ -175,12 +175,12 @@ public:
GridIndexType insideScvIdx() const GridIndexType insideScvIdx() const
{ return insideScvIdx_; } { return insideScvIdx_; }
//! The number of outside scvs connection via this scv face //! The number of scvs on the outside of this scv face
std::size_t numOutsideScvs() const std::size_t numOutsideScvs() const
{ return outsideScvIndices_.size(); } { return outsideScvIndices_.size(); }
//! index of the outside sub control volume or boundary scv index //! Index of the i-th outside sub control volume or boundary scv index.
//! returns undefined behaviour if index exceeds numOutsideScvs // Results in undefined behaviour if i >= numOutsideScvs()
GridIndexType outsideScvIdx(int i = 0) const GridIndexType outsideScvIdx(int i = 0) const
{ return outsideScvIndices_[i]; } { return outsideScvIndices_[i]; }
......
...@@ -155,7 +155,7 @@ public: ...@@ -155,7 +155,7 @@ public:
return area_; return area_;
} }
//! returns bolean if the sub control volume face is on the boundary //! returns true if the sub control volume face is on the boundary
bool boundary() const bool boundary() const
{ {
return boundary_; return boundary_;
...@@ -167,20 +167,20 @@ public: ...@@ -167,20 +167,20 @@ public:
return unitOuterNormal_; return unitOuterNormal_;
} }
//! index of the inside sub control volume for spatial param evaluation //! index of the inside sub control volume
GridIndexType insideScvIdx() const GridIndexType insideScvIdx() const
{ {
return scvIndices_[0]; return scvIndices_[0];
} }
//! index of the outside sub control volume for spatial param evaluation //! Index of the i-th outside sub control volume or boundary scv index.
// This results in undefined behaviour if boundary is true // Results in undefined behaviour if i >= numOutsideScvs()
GridIndexType outsideScvIdx(int i = 0) const GridIndexType outsideScvIdx(int i = 0) const
{ {
return scvIndices_[i+1]; return scvIndices_[i+1];
} }
//! The number of outside scvs connection via this scv face //! The number of scvs on the outside of this face
std::size_t numOutsideScvs() const std::size_t numOutsideScvs() const
{ {
return scvIndices_.size()-1; return scvIndices_.size()-1;
......
...@@ -131,11 +131,11 @@ public: ...@@ -131,11 +131,11 @@ public:
Scalar area() const Scalar area() const
{ return area_; } { return area_; }
//! returns bolean if the sub control volume face is on the boundary //! returns true if the sub control volume face is on the boundary
bool boundary() const bool boundary() const
{ return boundary_; } { return boundary_; }
//! returns bolean if the sub control volume face is on an interior boundary //! returns true if the sub control volume face is on an interior boundary
bool interiorBoundary() const bool interiorBoundary() const
{ return interiorBoundary_; } { return interiorBoundary_; }
...@@ -144,7 +144,7 @@ public: ...@@ -144,7 +144,7 @@ public:
const GlobalPosition& unitOuterNormal() const const GlobalPosition& unitOuterNormal() const
{ return unitOuterNormal_; } { return unitOuterNormal_; }
//! index of the inside sub control volume for spatial param evaluation //! index of the inside sub control volume
LocalIndexType insideScvIdx() const LocalIndexType insideScvIdx() const
{ return scvIndices_[0]; } { return scvIndices_[0]; }
...@@ -152,14 +152,20 @@ public: ...@@ -152,14 +152,20 @@ public:
GridIndexType index() const GridIndexType index() const
{ return scvfIndex_; } { return scvfIndex_; }
//! index of the outside sub control volume for spatial param evaluation //! Index of the i-th outside sub control volume or boundary scv index.
//! This results in undefined behaviour if boundary is true // Results in undefined behaviour if i >= numOutsideScvs()
LocalIndexType outsideScvIdx() const LocalIndexType outsideScvIdx(int i = 0) const
{ {
assert(!boundary()); assert(!boundary() && !interiorBoundary());
return scvIndices_[1]; return scvIndices_[1];
} }
//! The number of scvs on the outside of this face
std::size_t numOutsideScvs() const
{
return static_cast<std::size_t>(!(boundary() || interiorBoundary()));
}
//! returns the element-local index of the facet this scvf is embedded in. //! returns the element-local index of the facet this scvf is embedded in.
//! This is only valid to be called for scvfs on domain/interior boundaries. //! This is only valid to be called for scvfs on domain/interior boundaries.
LocalIndexType facetIndexInElement() const LocalIndexType facetIndexInElement() const
......
...@@ -210,7 +210,7 @@ public: ...@@ -210,7 +210,7 @@ public:
Scalar area() const Scalar area() const
{ return area_; } { return area_; }
//! returns bolean if the sub control volume face is on the boundary //! returns true if the sub control volume face is on the boundary
bool boundary() const bool boundary() const
{ return boundary_; } { return boundary_; }
...@@ -234,18 +234,25 @@ public: ...@@ -234,18 +234,25 @@ public:
typename BoundaryFlag::value_type boundaryFlag() const typename BoundaryFlag::value_type boundaryFlag() const
{ return boundaryFlag_.get(); } { return boundaryFlag_.get(); }
//! Index of the inside sub control volume for spatial param evaluation //! index of the inside sub control volume
LocalIndexType insideScvIdx() const LocalIndexType insideScvIdx() const
{ return scvIndices_[0]; } { return scvIndices_[0]; }
//! Index of the outside sub control volume for spatial param evaluation //! Index of the i-th outside sub control volume or boundary scv index.
// This results in undefined behaviour if boundary is true // Results in undefined behaviour if i >= numOutsideScvs()
LocalIndexType outsideScvIdx() const LocalIndexType outsideScvIdx(int i = 0) const
{ {
assert(!boundary()); assert(!boundary());
return scvIndices_[1]; return scvIndices_[1];
} }
//! The number of scvs on the outside of this face
std::size_t numOutsideScvs() const
{
return static_cast<std::size_t>(!boundary());
}
//! Returns a corner of the sub control volume face
const GlobalPosition& corner(unsigned int localIdx) const const GlobalPosition& corner(unsigned int localIdx) const
{ {
assert(localIdx < corners_.size() && "provided index exceeds the number of corners"); assert(localIdx < corners_.size() && "provided index exceeds the number of corners");
......
...@@ -107,6 +107,15 @@ int main (int argc, char *argv[]) ...@@ -107,6 +107,15 @@ int main (int argc, char *argv[])
++boundaryCount; ++boundaryCount;
std::cout << " (on boundary)."; std::cout << " (on boundary).";
} }
// verify that boundary faces have no neighbor
if (scvf.boundary() && scvf.numOutsideScvs() != 0)
DUNE_THROW(Dune::Exception, "Boundary face states that it has a neighbor");
// verify that non-boundary faces have a single neighbor
if (!scvf.boundary() && scvf.numOutsideScvs() != 1)
DUNE_THROW(Dune::Exception, "Expected non-boundary face to have a single neighbor");
std::cout << std::endl; std::cout << std::endl;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment