Skip to content
Snippets Groups Projects
Commit 369a2957 authored by Bernd Flemisch's avatar Bernd Flemisch
Browse files

[patches] introduce patch for dune-grid 2.3.1

The patch allows using the multidomain models together with a UG library
that has been compiled for parallel usage. Most likely, the patch will
make its way to dune-grid and should not be needed anymore from
dune-grid 2.4.

Approved by natalies.



git-svn-id: svn://svn.iws.uni-stuttgart.de/DUMUX/dumux/trunk@13501 2fb0f335-1f38-0410-981e-8018bf24f1b0
parent 8448dff9
No related branches found
No related tags found
No related merge requests found
......@@ -3,3 +3,13 @@
patch istl-2.3.0.patch in your directory containing
DUNE-ISTL 2.3.0, e.g.:
patch -p1 <../dumux/patches/istl-2.3.0.patch
- If UG has been installed for parallel usage, and you want to run a Dumux
multidomain model, you have to patch dune-grid. The patch will introduce
geometries for edges and faces in UG, which need to be present, otherwise the
compiler will complain. Apply the patch grid-2.3.1.patch in your directory
containing dune-grid 2.3.1 by, e.g.:
patch -p1 <../dumux/patches/grid-2.3.1.patch
If you want to use Dune 2.4, it is most likely that the missing functionality
will be included in dune-grid by 10/2014, so the patch will not be needed.
diff --git a/dune/grid/uggrid/uggridentity.hh b/dune/grid/uggrid/uggridentity.hh
index 4e71316..acadd5d 100644
--- a/dune/grid/uggrid/uggridentity.hh
+++ b/dune/grid/uggrid/uggridentity.hh
@@ -223,6 +223,8 @@ namespace Dune {
friend class UGGridEntitySeed<codim, GridImp>;
typedef typename GridImp::ctype UGCtype;
+ typedef typename GridImp::Traits::template Codim<codim>::GeometryImpl GeometryImpl;
+
public:
typedef typename GridImp::template Codim<codim>::Geometry Geometry;
@@ -271,6 +273,9 @@ namespace Dune {
//!< Default codim 1 Faces and codim == dim Vertices
template<int cc> int count () const;
+ //! geometry of this entity
+ Geometry geometry () const { return Geometry( *geo_ ); }
+
/** \brief Get the seed corresponding to this entity */
EntitySeed seed () const { return EntitySeed( *this ); }
@@ -290,6 +295,20 @@ namespace Dune {
/** \brief Set edge object to a UG edge object */
void setToTarget(typename UG_NS<dim>::template Entity<codim>::T* target, const GridImp* gridImp) {
target_ = target;
+
+ // obtain the corner coordinates from UG
+ UGCtype* cornerCoords[2*dim];
+ UG_NS<dim>::Corner_Coordinates(target_, cornerCoords);
+
+ // convert to the type required by MultiLinearGeometry
+ std::vector<FieldVector<UGCtype, dim> > geometryCoords(2);
+ for(size_t i = 0; i < 2; i++)
+ for (size_t j = 0; j < dim; j++)
+ geometryCoords[i][j] = cornerCoords[i][j];
+
+ geo_ = Dune::make_shared<GeometryImpl>(type(), geometryCoords);
+
+ gridImp_ = gridImp;
}
public:
/** \brief Set edge object to a UG edge object using the center element and the side number
@@ -305,7 +324,14 @@ namespace Dune {
}
protected:
+ Dune::shared_ptr<GeometryImpl> geo_;
+
typename UG_NS<dim>::template Entity<codim>::T* target_;
+
+ /** \brief gridImp Not actually used, only the codim-0 specialization needs it
+ * But code is simpler if we just keep it everywhere.
+ */
+ const GridImp* gridImp_;
};
/*! \brief Specialization for edge in 2D
@@ -332,9 +358,14 @@ namespace Dune {
class UGFaceEntity
{
enum {codim = 1};
+ typedef typename GridImp::ctype UGCtype;
+
+ typedef typename GridImp::Traits::template Codim<codim>::GeometryImpl GeometryImpl;
public:
+ typedef typename GridImp::template Codim<codim>::Geometry Geometry;
+
/** \brief Return the entity type identifier */
GeometryType type() const
{
@@ -403,12 +434,30 @@ namespace Dune {
}
#endif
+ //! geometry of this entity
+ Geometry geometry () const { return Geometry( *geo_ ); }
+
/** \brief Set to a UG side vector object
\param target The UG side vector to point to
\param gridImp Dummy argument, only for consistency with codim-0 entities
*/
void setToTarget(typename UG_NS<dim>::template Entity<codim>::T* target, const GridImp* gridImp) {
target_ = target;
+
+ // obtain the corner coordinates from UG
+ UGCtype* cornerCoords[4*dim];
+ UG_NS<dim>::Corner_Coordinates(target_, cornerCoords);
+
+ // convert to the type required by MultiLinearGeometry
+ size_t numCorners = type().isTriangle() ? 3 : 4;
+ std::vector<FieldVector<UGCtype, dim> > geometryCoords(numCorners);
+ for(size_t i = 0; i < numCorners; i++)
+ for (size_t j = 0; j < dim; j++)
+ geometryCoords[i][j] = cornerCoords[i][j];
+
+ geo_ = Dune::make_shared<GeometryImpl>(type(), geometryCoords);
+
+ gridImp_ = gridImp;
}
typename UG_NS<dim>::template Entity<codim>::T* getTarget() const
@@ -416,9 +465,16 @@ namespace Dune {
return target_;
}
+protected:
+ Dune::shared_ptr<GeometryImpl> geo_;
+
/** \brief The UG object (a side vector) that represents this face */
typename UG_NS<dim>::template Entity<codim>::T* target_;
+ /** \brief gridImp Not actually used, only the codim-0 specialization needs it
+ * But code is simpler if we just keep it everywhere.
+ */
+ const GridImp* gridImp_;
};
/*! \brief Specialization for faces in 3D
diff --git a/dune/grid/uggrid/uggridgeometry.hh b/dune/grid/uggrid/uggridgeometry.hh
index 26a2f88..079906d 100644
--- a/dune/grid/uggrid/uggridgeometry.hh
+++ b/dune/grid/uggrid/uggridgeometry.hh
@@ -159,6 +159,26 @@ namespace Dune {
/****************************************************************/
/* */
+ /* Specialization for edges in 3d */
+ /* */
+ /****************************************************************/
+
+ template<class GridImp>
+ class UGGridGeometry<1, 3, GridImp> :
+ public CachedMultiLinearGeometry<typename GridImp::ctype, 1, 3>
+ {
+ public:
+
+ /** \brief Constructor from a given geometry type and a vector of corner coordinates */
+ UGGridGeometry(const GeometryType& type, const std::vector<FieldVector<typename GridImp::ctype,3> >& coordinates)
+ : CachedMultiLinearGeometry<typename GridImp::ctype, 1, 3>(type, coordinates)
+ {}
+
+ };
+
+
+ /****************************************************************/
+ /* */
/* Specialization for faces in 2d */
/* */
/****************************************************************/
diff --git a/dune/grid/uggrid/ugwrapper.hh b/dune/grid/uggrid/ugwrapper.hh
index ac6fd06..57202f1 100644
--- a/dune/grid/uggrid/ugwrapper.hh
+++ b/dune/grid/uggrid/ugwrapper.hh
@@ -393,7 +393,7 @@ namespace Dune {
return FIRSTELEMENT(grid);
}
- /** \brief Returns pointers to the coordinate arrays of an UG element */
+ /** \brief Returns pointers to the coordinate arrays of a UG element */
static void Corner_Coordinates(const UG_NS< UG_DIM >::Element* theElement, double* x[]) {
using UG_NAMESPACE ::NODE;
using UG_NAMESPACE ::TRIANGLE;
@@ -407,11 +407,29 @@ namespace Dune {
CORNER_COORDINATES(theElement, n, x);
}
- /** \brief Returns pointers to the coordinate arrays of an UG node */
+ /** \brief Returns pointers to the coordinate arrays of a UG node */
static void Corner_Coordinates(const UG_NS< UG_DIM >::Node* theNode, double* x[]) {
x[0] = theNode->myvertex->iv.x;
}
+ /** \brief Returns pointers to the coordinate arrays of a UG edge */
+ static void Corner_Coordinates(const UG_NS< UG_DIM >::Edge* theEdge, double* x[]) {
+ x[0] = theEdge->links[0].nbnode->myvertex->iv.x;
+ x[1] = theEdge->links[1].nbnode->myvertex->iv.x;
+ }
+
+ /** \brief Returns pointers to the coordinate arrays of a UG vector */
+ static void Corner_Coordinates(const UG_NS< UG_DIM >::Vector* theVector, double* x[]) {
+ typename UG_NS< UG_DIM >::Element* center;
+ unsigned int side;
+ UG_NS< UG_DIM >::GetElementAndSideFromSideVector(theVector, center, side);
+ for (unsigned i = 0; i < Corners_Of_Side(center, side); i++)
+ {
+ unsigned idxInElem = Corner_Of_Side(center, side, i);
+ x[i] = Corner(center, idxInElem)->myvertex->iv.x;
+ }
+ }
+
static int GlobalToLocal(int n, const double** cornerCoords,
const double* EvalPoint, double* localCoord) {
if (UG_DIM==2)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment