[Dune-devel] cleanup in uggrid

Oliver Sander sander at igpm.rwth-aachen.de
Fri Nov 28 16:45:55 CET 2014


Am 28.11.2014 um 16:40 schrieb Carsten Gräser:
> Hi Oliver,
> find attached some minor warning fixes for uggrid. Some deal with
> signed/unsigned comparison warnings some with the removal of
> runtime-sized arrays (this is not standard c++). I don't want to
> mess up the ug internals so please have a look before.
> 
> All patches where generated against dune-grid 50a9946a.
> test-ug still runs through.
> 

Thanks, looking good, except:


diff --git a/dune/grid/uggrid/uggridgeometry.cc b/dune/grid/uggrid/uggridgeometry.cc
index e2f4cd7..a7622d6 100644
--- a/dune/grid/uggrid/uggridgeometry.cc
+++ b/dune/grid/uggrid/uggridgeometry.cc
@@ -87,8 +87,10 @@ global(const FieldVector<UGCtype, mydim>& local) const
 {
   FieldVector<UGCtype, coorddim> globalCoord(0.0);

+
   // we are an actual element in UG
-  UGCtype* cornerCoords[corners()];
+  // coorddim*coorddim is an upper bound for the number of vertices
+  UGCtype* cornerCoords[coorddim*coorddim];
   UG_NS<coorddim>::Corner_Coordinates(target_, cornerCoords);

Please remove the extra whitespace change

and



-    const typename UG_NS<dimworld>::Node* vertices[elementTypes_[i]];
+    std::unique_ptr<const typename UG_NS<dimworld>::Node*[]> vertices = Std::make_unique<const typename UG_NS<dimworld>::Node*[]>(elementTypes_[i]);
     for (size_t j=0; j<elementTypes_[i]; j++)
       vertices[j] = nodePointers[isBoundaryNode[elementVertices_[idx++]]];

-    if (InsertElement(grid_->multigrid_->grids[0], elementTypes_[i],const_cast<typename UG_NS<dimworld>::Node**>(vertices),NULL,NULL,NULL)==NULL)
+    if (InsertElement(grid_->multigrid_->grids[0], elementTypes_[i],const_cast<typename UG_NS<dimworld>::Node**>(vertices.get()),NULL,NULL,NULL)==NULL)
       DUNE_THROW(GridError, "Inserting element into UGGrid failed!");
   }


Why not use a std::vector here instead?

Best,
Oliver



-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: OpenPGP digital signature
URL: <https://lists.dune-project.org/pipermail/dune-devel/attachments/20141128/86743577/attachment.sig>


More information about the Dune-devel mailing list