dune-grid  2.5.0
structuredyaspgridfactory.hh
Go to the documentation of this file.
1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=4 sw=2 sts=2:
3 #ifndef DUNE_GRID_YASPGRID_STRUCTUREDYASPGRIDFACTORY_HH
4 #define DUNE_GRID_YASPGRID_STRUCTUREDYASPGRIDFACTORY_HH
5 
6 #include <memory>
7 
9 
14 namespace Dune
15 {
25  template<class ctype, int dim>
27  {
29  static const int dimworld = GridType::dimensionworld;
30 
31  public:
42  static std::shared_ptr<GridType>
43  createCubeGrid(const FieldVector<ctype,dimworld>& lowerLeft,
44  const FieldVector<ctype,dimworld>& upperRight,
45  const std::array<unsigned int,dim>& elements)
46  {
47  using std::abs;
48  for(int d = 0; d < dimworld; ++d)
49  if(abs(lowerLeft[d]) > abs(upperRight[d])*1e-10)
50  DUNE_THROW(GridError, className<StructuredGridFactory>()
51  << "::createCubeGrid(): You have to use Yaspgrid<dim"
52  ", EquidistantOffsetCoordinates<ctype,dim> > as your"
53  "grid type for non-trivial origin." );
54 
55  // construct array of ints instead of unsigned ints
56  std::array<int, dim> elem;
57  std::copy(elements.begin(), elements.end(), elem.begin());
58 
59  return std::shared_ptr<GridType>
60  (new GridType(upperRight, elem,
61  std::bitset<dim>(), 0)); // default constructor of bitset sets to zero
62  }
63 
69  static std::shared_ptr<GridType>
70  createSimplexGrid(const FieldVector<ctype,dimworld>& lowerLeft,
71  const FieldVector<ctype,dimworld>& upperRight,
72  const std::array<unsigned int,dim>& elements)
73  {
74  DUNE_THROW(GridError, className<StructuredGridFactory>()
75  << "::createSimplexGrid(): Simplices are not supported "
76  "by YaspGrid.");
77  }
78 
79  };
80 
88  template<class ctype, int dim>
91  static const int dimworld = GridType::dimensionworld;
92 
93  public:
100  static std::shared_ptr<GridType>
101  createCubeGrid(const FieldVector<ctype,dimworld>& lowerLeft,
102  const FieldVector<ctype,dimworld>& upperRight,
103  const std::array<unsigned int,dim>& elements)
104  {
105  // construct array of ints instead of unsigned ints
106  std::array<int, dim> elem;
107  std::copy(elements.begin(), elements.end(), elem.begin());
108 
109  return std::shared_ptr<GridType>
110  (new GridType(lowerLeft, upperRight, elem,
111  std::bitset<dim>(), 0)); // default constructor of bitset sets to zero
112  }
113 
119  static std::shared_ptr<GridType>
120  createSimplexGrid(const FieldVector<ctype,dimworld>& lowerLeft,
121  const FieldVector<ctype,dimworld>& upperRight,
122  const std::array<unsigned int,dim>& elements)
123  {
124  DUNE_THROW(GridError, className<StructuredGridFactory>()
125  << "::createSimplexGrid(): Simplices are not supported "
126  "by YaspGrid.");
127  }
128 
129  };
130 
131 } // namespace Dune
132 #endif
Base class for exceptions in Dune grid modules.
Definition: exceptions.hh:16
Construct structured cube and simplex grids in unstructured grid managers.
Definition: structuredgridfactory.hh:29
void abs(const DofVectorPointer< int > &dofVector)
Definition: dofvector.hh:326
static std::shared_ptr< GridType > createSimplexGrid(const FieldVector< ctype, dimworld > &lowerLeft, const FieldVector< ctype, dimworld > &upperRight, const std::array< unsigned int, dim > &elements)
Create a structured simplex grid.
Definition: structuredyaspgridfactory.hh:120
static std::shared_ptr< GridType > createCubeGrid(const FieldVector< ctype, dimworld > &lowerLeft, const FieldVector< ctype, dimworld > &upperRight, const std::array< unsigned int, dim > &elements)
Create a structured cube grid.
Definition: structuredyaspgridfactory.hh:43
static std::shared_ptr< GridType > createCubeGrid(const FieldVector< ctype, dimworld > &lowerLeft, const FieldVector< ctype, dimworld > &upperRight, const std::array< unsigned int, dim > &elements)
Create a structured cube grid.
Definition: structuredyaspgridfactory.hh:101
A class to construct structured cube and simplex grids using the grid factory.
Container for equidistant coordinates in a YaspGrid with non-trivial origin.
Definition: coordinates.hh:124
Include standard header files.
Definition: agrid.hh:59
[ provides Dune::Grid ]
Definition: yaspgrid.hh:56
Container for equidistant coordinates in a YaspGrid.
Definition: coordinates.hh:26
static std::shared_ptr< GridType > createSimplexGrid(const FieldVector< ctype, dimworld > &lowerLeft, const FieldVector< ctype, dimworld > &upperRight, const std::array< unsigned int, dim > &elements)
Create a structured simplex grid.
Definition: structuredyaspgridfactory.hh:70