From 6143de85e8867e85d80985bdc5af7d8f62b81c94 Mon Sep 17 00:00:00 2001
From: Timo Koch <timo.koch@iws.uni-stuttgart.de>
Date: Wed, 23 Oct 2019 15:34:47 +0200
Subject: [PATCH] [entity] Use geometry array constructor as we only support
 simplices

---
 dune/foamgrid/foamgrid/foamgridentity.hh | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/dune/foamgrid/foamgrid/foamgridentity.hh b/dune/foamgrid/foamgrid/foamgridentity.hh
index b56d7a7..53ef4a9 100644
--- a/dune/foamgrid/foamgrid/foamgridentity.hh
+++ b/dune/foamgrid/foamgrid/foamgridentity.hh
@@ -8,6 +8,7 @@
 */
 
 #include <memory>
+#include <array>
 
 #include <dune/common/version.hh>
 
@@ -132,7 +133,9 @@ class FoamGridEntity :
         //! geometry of this entity
         Geometry geometry () const
         {
-            std::vector<FieldVector<ctype, dimworld> > coordinates(target_->corners());
+            // we currently only support simplices
+            std::array<FieldVector<ctype, dimworld>, dimgrid-codim+1> coordinates;
+            assert(dimgrid-codim+1 == target_->corners() && "Target entity is not a simplex!");
             for (int i=0; i<target_->corners(); i++)
                 coordinates[i] = target_->corner(i);
 
@@ -256,7 +259,9 @@ class FoamGridEntity<0, 2, GridImp> :
         //! Geometry of this entity
         Geometry geometry () const
         {
-            std::vector<FieldVector<ctype, dimworld> > coordinates(target_->corners());
+            // we currently only support simplices
+            std::array<FieldVector<ctype, dimworld>, dimgrid+1> coordinates;
+            assert(dimgrid+1 == target_->corners() && "Target entity is not a simplex!");
             for (int i=0; i<target_->corners(); i++)
                 coordinates[i] = target_->vertex_[i]->pos_;
 
@@ -426,8 +431,7 @@ class FoamGridEntity<0, 2, GridImp> :
                     { {0.5,0.0}, {0.5,0.5}, {0.0,0.5} }
                 };
 
-                std::vector<FieldVector<ctype, dimgrid> >
-                    coordinates(3);
+                std::array<FieldVector<ctype, dimgrid>, 3> coordinates;
 
                 for(int corner=0; corner <3; ++corner)
                     for(int entry=0; entry <2; ++entry)
@@ -578,7 +582,9 @@ class FoamGridEntity<0, 1, GridImp> :
         //! Geometry of this entity
         Geometry geometry () const
         {
-            std::vector<FieldVector<ctype, dimworld> > coordinates(target_->corners());
+            // we currently only support simplices
+            std::array<FieldVector<ctype, dimworld>, dimgrid+1> coordinates;
+            assert(dimgrid+1 == target_->corners() && "Target entity is not a simplex!");
             for (int i=0; i<target_->corners(); i++)
                 coordinates[i] = target_->corner(i);
 
@@ -732,7 +738,7 @@ class FoamGridEntity<0, 1, GridImp> :
                 // of the father.
                 ctype mapping[2][2] = {{0.0, 0.5}, {0.5, 1.0}};
 
-                std::vector<FieldVector<ctype, dimgrid> > coordinates(2);
+                std::array<FieldVector<ctype, dimgrid>, 2> coordinates;
 
                 for(int corner=0; corner <2; ++corner)
                     coordinates[corner][0] = mapping[target_->refinementIndex_][corner];
-- 
GitLab