Commit 74662853 authored by Peter Bastian's avatar Peter Bastian

a class that creates a unit cube for all available grids

[[Imported from SVN: r8]]
parent fa99e265
# $Id$
noinst_PROGRAMS = gettingstarted traversal integration
noinst_PROGRAMS = gettingstarted traversal integration othergrids
gettingstarted_SOURCES = gettingstarted.cc
gettingstarted_CXXFLAGS = $(MPI_CPPFLAGS) $(ALL_PKG_CPPFLAGS)
......@@ -15,6 +15,10 @@ integration_SOURCES = integration.cc
integration_CXXFLAGS = $(MPI_CPPFLAGS) $(ALL_PKG_CPPFLAGS)
integration_LDADD = $(MPI_LDFLAGS) $(DUNE_LDFLAGS) $(DUNE_LIBS) $(ALL_PKG_LDFLAGS) $(ALL_PKG_LIBS)
othergrids_SOURCES = othergrids.cc
othergrids_CXXFLAGS = $(MPI_CPPFLAGS) $(ALL_PKG_CPPFLAGS)
othergrids_LDADD = $(MPI_LDFLAGS) $(DUNE_LDFLAGS) $(DUNE_LIBS) $(ALL_PKG_LDFLAGS) $(ALL_PKG_LIBS)
# don't follow the full GNU-standard
# we need automake 1.5
AUTOMAKE_OPTIONS = foreign 1.5
......@@ -360,7 +360,14 @@ there are/is 4 element(s) on level 1
\chapter{The DUNE grid interface}
\section{Prerequisites}
The description of the interface assumes familarity with the concepts
of the Standard Template Library (STL) such as containers, iterators, value
types, etc. On the other hand, the \Dune\ grid interface is not fully
compatible with the STL, i.~e.~if a certain class is said to be of
forward iterator type this does not imply that it has exactly the same
members as a STL forward iterator.
\section{Grid}
......@@ -508,10 +515,17 @@ with the values
\end{quote}
is used in parametrizing the communication between processes.
\subsection{Notation}
\begin{description}
\item[{\tt G}:] A type that is a model of Grid.
\item[\texttt{d},\texttt{c}:] Integer constants denoting
dimension and codimension.
\item[\texttt{p}:] A constant of type \lstinline!PartitionIteratorType!.
\end{description}
\subsection{Constants}
Let \lstinline!G! denote a type that implements the grid
interface. Each such type exports the following constants.
\minisec{\tt G::dimension\index{dimension@{\tt dimension}}}
The dimensionality $d$ of the elements of the grid. Note that all elements
......@@ -520,12 +534,10 @@ have elements of different dimension in one grid. Entities with a
dimension $d^\prime<d$ only occur as faces of a $d$-dimensional element.
\minisec{\tt G::dimensionworld\index{dimensionworld@{\tt dimensionworld}}}
The dimension $w$ of the domain $\Omega$ that is discretized by the grid.
The dimension $w\geq d$ of the domain $\Omega$ that is discretized by the grid.
\subsection{Associated Types}
Let \lstinline!G! denote a type that implements the grid
interface. Each such type provides access to the following types.
\minisec{\tt G::ctype\index{ctype@{\tt ctype}}}
The type used for representing coordinates in the grid.
......@@ -612,8 +624,6 @@ and it is not necessarily consecutive.
\subsection{Notation}
\subsection{Definitions}
\subsection{Valid Expressions}
......@@ -624,7 +634,7 @@ and it is not necessarily consecutive.
\subsection{Invariants}
\subsection{Implementations}
\subsection{Implementation details}
\subsection{Notes}
......@@ -633,8 +643,11 @@ and it is not necessarily consecutive.
\section{Entity}
\section{Geometry Type}
\section{Geometry}
\section{Collective communication}
\chapter{Using different grids}
......
DIM: 2
DIM_OF_WORLD: 2
number of elements: 2
number of vertices: 4
vertex coordinates:
0.0 0.0
1.0 0.0
1.0 1.0
0.0 1.0
element vertices:
2 0 1
0 2 3
element boundaries:
1 1 0
1 1 0
DIM: 3
DIM_OF_WORLD: 3
number of vertices: 8
number of elements: 6
vertex coordinates:
0.0 0.0 0.0
1.0 0.0 0.0
0.0 0.0 1.0
1.0 0.0 1.0
1.0 1.0 0.0
1.0 1.0 1.0
0.0 1.0 0.0
0.0 1.0 1.0
element vertices:
0 5 4 1
0 5 3 1
0 5 3 2
0 5 4 6
0 5 7 6
0 5 7 2
element boundaries:
1 1 0 0
1 1 0 0
1 1 0 0
1 1 0 0
1 1 0 0
1 1 0 0
element neighbours:
-1 -1 1 3
-1 -1 0 2
-1 -1 5 1
-1 -1 4 0
-1 -1 3 5
-1 -1 2 4
!Hexaeder
8
0.000000 0.000000 0.000000
1.000000 0.000000 0.000000
1.000000 1.000000 0.000000
0.000000 1.000000 0.000000
0.000000 0.000000 1.000000
1.000000 0.000000 1.000000
1.000000 1.000000 1.000000
0.000000 1.000000 1.000000
1
0 1 2 3 4 5 6 7
6
-2 4 0 3 7 4
-3 4 1 5 6 2
-1 4 0 4 5 1
-1 4 3 2 6 7
-1 4 0 1 2 3
-1 4 5 4 7 6
0 -1
1 -1
2 -1
3 -1
4 -1
5 -1
6 -1
7 -1
!Tetraeder
8
0.000000 0.000000 0.000000
1.000000 0.000000 0.000000
0.000000 1.000000 1.000000
0.000000 0.000000 1.000000
0.000000 1.000000 0.000000
1.000000 0.000000 1.000000
1.000000 1.000000 0.000000
1.000000 1.000000 1.000000
6
0 1 2 3
0 2 1 4
1 5 2 3
1 6 4 2
1 6 2 7
1 7 2 5
12
-2 3 3 2 0
-2 3 1 3 0
-1 3 4 1 0
-2 3 2 4 0
-1 3 2 3 5
-2 3 5 3 1
-2 3 4 2 6
-1 3 4 6 1
-2 3 2 7 6
-2 3 6 7 1
-1 3 2 5 7
-2 3 7 5 1
0 -1
1 -1
2 -1
3 -1
4 -1
5 -1
6 -1
7 -1
# edited by PB 23 Sep 2005
nNodes 4
define Quadrilaterals 1
Parameters {
Materials {
Substrat1 {
Color 0.8 0.1 0.1
}
Substrat2 {
Color 0.1 0.1 0.8
}
}
ContentType "HxTriangularGrid",
CreateMagnitude 1
}
Nodes { float[2] Coordinates } @1
Quadrilaterals { int[4] Nodes } @2
Quadrilaterals { byte Materials } @3
# Data section follows
@1
0.0 0.0
1.0 0.0
0.0 1.0
1.0 1.0
@2
1 2 4 3
@3
1
nNodes 4
nTriangles 2
Parameters {
Materials {
Substrat1 {
Color 0.8 0.1 0.1
}
Substrat2 {
Color 0.1 0.1 0.8
}
}
ContentType "HxTriangularGrid",
CreateMagnitude 1
}
Nodes { float[2] Coordinates } @1
TriangleData { int[3] Nodes } @2
TriangleData { byte Materials } @3
# Data section follows
@1
0.0 0.0
1.0 0.0
0.0 1.0
1.0 1.0
@2
1 2 3
3 2 4
@3
1
2
nNodes 8
define Hexahedra 1
Parameters {
Materials {
Mortar {
}
NonMortar {
}
}
Parts 0 0 0 0 1 0 3 3 3 3 3 2
}
Nodes { float[3] Coordinates } @1
Hexahedra { int[8] Nodes } @2
Hexahedra { byte Materials } @3
# Data section follows
@1
0 0 0
1 0 0
0 1 0
1 1 0
0 0 1
1 0 1
0 1 1
1 1 1
@2
1 2 4 3 5 6 8 7
@3
1
nNodes 8
nTetrahedra 6
Parameters {
Materials {
SoftTissue {
Id 1,
Color 0.93662 0.838517 0.778318,
PoissonsRatio 0.45,
YoungsModulus 250000
}
}
BoundaryIds {
Id0 {
Id 1,
Info "Neumann",
Type "Neumann",
Color 0.93662 0.838517 0.778318
}
Id1 {
Id 2,
Info "Neumann",
Type "Neumann",
Color 0.6 0.6 0.6
}
Id2 {
Color 0.6 0.6 0.6,
Id 3,
Info "Dirichlet",
Type "Dirichlet"
}
Id3 {
Id 4,
Color 0.6 0.6 0.6,
Info "Neumann",
Type "Neumann"
}
Id4 {
Color 0.6 0.6 0.6,
Id 5,
Info "Dirichlet",
Type "Dirichlet"
}
Id5 {
Id 6,
Color 0.6 0.6 0.6,
Info "Neumann",
Type "Neumann"
}
Name "BoundaryConditions"
}
UnitLength 0.01
}
Nodes { float[3] Coordinates } @1
Tetrahedra { int[4] Nodes } @2
# Data section follows
@1
0 0 0
0 1 0
1 1 0
1 0 0
0 0 1
0 1 1
1 1 1
1 0 1
@2
1 2 3 7
1 2 7 6
1 6 7 5
1 3 4 7
1 7 4 8
1 7 8 5
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#ifndef UNITCUBE_HH
#define UNITCUBE_HH
#include "dune/grid/common/grid.hh"
#include "dune/grid/onedgrid.hh"
#include "dune/grid/sgrid.hh"
#include "dune/grid/yaspgrid.hh"
#if HAVE_UG
#include "grid/uggrid.hh"
#include <io/file/amirameshreader.hh>
#endif
#if HAVE_ALUGRID
#include <dune/grid/alu3dgrid.hh>
#endif
#if HAVE_ALBERTA
#include "dune/grid/albertagrid.hh"
#endif
// default implementation for any template parameter
template<typename T, int variant>
class UnitCube
{
public:
// constructor throwing exception
UnitCube ()
{
DUNE_THROW(Dune::GridError,"no specialization for this grid available");
}
const T& grid ()
{
return grid_;
}
private:
// the constructed grid object
T grid_;
};
// OneDGrid specialization
template<>
class UnitCube<Dune::OneDGrid<1,1>,1>
{
public:
UnitCube () : grid_(1,0.0,1.0)
{}
const Dune::OneDGrid<1,1>& grid ()
{
return grid_;
}
private:
Dune::OneDGrid<1,1> grid_;
};
// SGrid specialization
template<int dim>
class UnitCube<Dune::SGrid<dim,dim>,1>
{
public:
const Dune::SGrid<dim,dim>& grid ()
{
return grid_;
}
private:
Dune::SGrid<dim,dim> grid_;
};
// YaspGrid specialization
template<int dim>
class UnitCube<Dune::YaspGrid<dim,dim>,1>
{
public:
UnitCube () : Len(1.0), s(1), p(false),
#if HAVE_MPI
grid_(MPI_COMM_WORLD,Len,s,p,0)
#else
grid_(Len,s,p,0)
#endif
{ }
const Dune::YaspGrid<dim,dim>& grid ()
{
return grid_;
}
private:
Dune::FieldVector<double,dim> Len;
Dune::FieldVector<int,dim> s;
Dune::FieldVector<bool,dim> p;
Dune::YaspGrid<dim,dim> grid_;
};
#if HAVE_UG
// UGGrid 3d, variant 1 (hexahedra) specialization
template<>
class UnitCube<Dune::UGGrid<3,3>,1>
{
public:
UnitCube () : grid_(800,10)
{
Dune::AmiraMeshReader<Dune::UGGrid<3,3> >::read(grid_,"grids/ug3dhexagrid.am");
}
const Dune::UGGrid<3,3>& grid ()
{
return grid_;
}
private:
Dune::UGGrid<3,3> grid_;
};
// UGGrid 3d, variant 2 (tetrahedra) specialization
template<>
class UnitCube<Dune::UGGrid<3,3>,2>
{
public:
UnitCube () : grid_(800,10)
{
Dune::AmiraMeshReader<Dune::UGGrid<3,3> >::read(grid_,"grids/ug3dtetragrid.am");
}
const Dune::UGGrid<3,3>& grid ()
{
return grid_;
}
private:
Dune::UGGrid<3,3> grid_;
};
// UGGrid 2d, variant 1 (quadrilaterals) specialization
template<>
class UnitCube<Dune::UGGrid<2,2>,1>
{
public:
UnitCube () : grid_(800,10)
{
Dune::AmiraMeshReader<Dune::UGGrid<2,2> >::read(grid_,"grids/quadgrid.am");
}
const Dune::UGGrid<2,2>& grid ()
{
return grid_;
}
private:
Dune::UGGrid<2,2> grid_;
};
// UGGrid 2d, variant 2 (triangles) specialization
template<>
class UnitCube<Dune::UGGrid<2,2>,2>
{
public:
UnitCube () : grid_(800,10)
{
Dune::AmiraMeshReader<Dune::UGGrid<2,2> >::read(grid_,"grids/trianggrid.am");
}
const Dune::UGGrid<2,2>& grid ()
{
return grid_;
}
private:
Dune::UGGrid<2,2> grid_;
};
#endif
#if HAVE_ALBERTA
// AlbertaGrid 2d, variant 1 (2 triangles) specialization
template<>
class UnitCube<Dune::AlbertaGrid<2,2>,1>
{
public:
UnitCube () : grid_("grids/2dgrid.al")
{}
const Dune::AlbertaGrid<2,2>& grid ()
{
return grid_;
}
private:
Dune::AlbertaGrid<2,2> grid_;
};
// AlbertaGrid 3d, variant 1 (6 tetrahedra) specialization
template<>
class UnitCube<Dune::AlbertaGrid<3,3>,1>
{
public:
UnitCube () : grid_("grids/3dgrid.al")
{}
const Dune::AlbertaGrid<3,3>& grid ()
{
return grid_;
}
private:
Dune::AlbertaGrid<3,3> grid_;
};
#endif
#if HAVE_ALUGRID
// ALU3dGrid tetrahedra specialization. Note: element type determined by type
template<>
class UnitCube<Dune::ALU3dGrid<3,3,Dune::tetra>,1>
{
public:
UnitCube () : filename("grids/cube.tetra"), grid_(filename.c_str())
{}
const Dune::ALU3dGrid<3,3,Dune::tetra>& grid ()
{
return grid_;
}
private:
std::string filename;
Dune::ALU3dGrid<3,3,Dune::tetra> grid_;
};
// ALU3dGrid hexahedra specialization. Note: element type determined by type
template<>
class UnitCube<Dune::ALU3dGrid<3,3,Dune::hexa>,1>
{
public:
UnitCube () : filename("grids/cube.hexa"), grid_(filename.c_str())
{}
const Dune::ALU3dGrid<3,3,Dune::hexa>& grid ()
{
return grid_;
}
private:
std::string filename;
Dune::ALU3dGrid<3,3,Dune::hexa> grid_;
};
#endif
#endif
Markdown is supported
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