Skip to content
Snippets Groups Projects
Commit 11229352 authored by Oliver Sander's avatar Oliver Sander
Browse files

Simplify UGGridGeometry::corner using constexpr if

The UGGrid code dates to before constexpr if existed, and uses
particular "pointless" casts to achieve a similar effect.
Replace some of these casts by constexpr if, which is much easier
to read.

The code is simplified further because UGGrid has recently started
to use FieldVector for point coordinates.  Therefore, componentwise
copying is not necessary anymore.
parent 0041b332
No related branches found
No related tags found
1 merge request!750Speed up `UGGridGeometry`
......@@ -62,13 +62,8 @@ FieldVector<typename GridImp::ctype, coorddim> UGGridGeometry<mydim,coorddim,Gri
corner(int i) const
{
// This geometry is a vertex
if (mydim==0) {
FieldVector<typename GridImp::ctype, coorddim> result;
for (size_t j=0; j<coorddim; j++)
// The cast is here to make the code compile even when target_ is not a node
result[j] = ((typename UG_NS<coorddim>::Node*)target_)->myvertex->iv.x[j];
return result;
}
if constexpr (mydim==0)
return target_->myvertex->iv.x;
// ////////////////////////////////
// This geometry is an element
......@@ -77,11 +72,8 @@ corner(int i) const
i = UGGridRenumberer<mydim>::verticesDUNEtoUG(i,type());
FieldVector<typename GridImp::ctype, coorddim> result;
for (size_t j=0; j<coorddim; j++)
// The cast is here to make the code compile even when target_ is not an element
result[j] = UG_NS<coorddim>::Corner(((typename UG_NS<coorddim>::Element*)target_),i)->myvertex->iv.x[j];
return result;
if constexpr (mydim==coorddim)
return UG_NS<coorddim>::Corner(target_,i)->myvertex->iv.x;
}
template< int mydim, int coorddim, class GridImp>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment