Commit 6422d8a8 authored by Dennis Gläser's avatar Dennis Gläser
Browse files

[tpfa][scv, scvf] return position vectors by const ref

parent 26d58e67
......@@ -24,7 +24,7 @@
#define DUMUX_DISCRETIZATION_CC_SUBCONTROLVOLUME_HH
#include <dumux/discretization/subcontrolvolumebase.hh>
#include <dumux/common/optional.hh>
#include <dune/common/std/optional.hh>
namespace Dumux
{
......@@ -48,7 +48,11 @@ public:
// the contructor in the cc case
CCSubControlVolume(Geometry&& geometry,
GridIndexType elementIndex)
: ParentType(), geometry_(std::forward<Geometry>(geometry)), elementIndex_(elementIndex) {}
: ParentType()
, geometry_(std::move(geometry))
, center_(geometry_.value().center())
, elementIndex_(elementIndex)
{}
//! The copy constrcutor
CCSubControlVolume(const CCSubControlVolume& other) = default;
......@@ -62,28 +66,30 @@ public:
// We want to use the default copy/move assignment.
// But since geometry is not copy assignable :( we
// have to construct it again
geometry_.release();
geometry_.reset();
geometry_.emplace(other.geometry_.value());
center_ = other.center_;
elementIndex_ = other.elementIndex_;
return *this;
}
//! The move assignment operator
CCSubControlVolume& operator=(CCSubControlVolume&& other)
CCSubControlVolume& operator=(CCSubControlVolume&& other) noexcept
{
// We want to use the default copy/move assignment.
// But since geometry is not copy assignable :( we
// have to construct it again
geometry_.release();
geometry_.emplace(other.geometry_.value());
geometry_.reset();
geometry_.emplace(std::move(other.geometry_.value()));
center_ = std::move(other.center_);
elementIndex_ = std::move(other.elementIndex_);
return *this;
}
//! The center of the sub control volume
GlobalPosition center() const
const GlobalPosition& center() const
{
return geometry().center();
return center_;
}
//! The volume of the sub control volume
......@@ -113,9 +119,9 @@ public:
}
// The position of the dof this scv is embedded in
GlobalPosition dofPosition() const
const GlobalPosition& dofPosition() const
{
return geometry().center();
return center_;
}
//! The global index of the element this scv is embedded in
......@@ -133,7 +139,8 @@ public:
private:
// Work around the fact that geometry is not default constructible
Optional<Geometry> geometry_;
Dune::Std::optional<Geometry> geometry_;
GlobalPosition center_;
GridIndexType elementIndex_;
};
......
......@@ -81,13 +81,13 @@ public:
}
//! The center of the sub control volume face
GlobalPosition center() const
const GlobalPosition& center() const
{
return center_;
}
//! The integration point for flux evaluations in global coordinates
GlobalPosition ipGlobal() const
const GlobalPosition& ipGlobal() const
{
// Return center for now
return center_;
......@@ -106,7 +106,7 @@ public:
}
//! The unit outer normal of the sub control volume face
GlobalPosition unitOuterNormal() const
const GlobalPosition& unitOuterNormal() const
{
return unitOuterNormal_;
}
......@@ -136,10 +136,11 @@ public:
return scvfIndex_;
}
GlobalPosition corner(unsigned int localIdx) const
//! return the i-th corner of this sub control volume face
const GlobalPosition& corner(int i) const
{
assert(localIdx < corners_.size() && "provided index exceeds the number of corners");
return corners_[localIdx];
assert(i < corners_.size() && "provided index exceeds the number of corners");
return corners_[i];
}
//! The geometry of the sub control volume face
......
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