/usr/include/dune/grid/yaspgrid/structuredyaspgridfactory.hh is in libdune-grid-dev 2.5.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#ifndef DUNE_GRID_YASPGRID_STRUCTUREDYASPGRIDFACTORY_HH
#define DUNE_GRID_YASPGRID_STRUCTUREDYASPGRIDFACTORY_HH
#include <memory>
#include <dune/grid/utility/structuredgridfactory.hh>
/** \file
* \brief Specialization of the StructuredGridFactory class for YaspGrid
*/
namespace Dune
{
/** \brief Specialization of the StructuredGridFactory for YaspGrid
This allows a YaspGrid to be constructed using the
StructuredGridFactory just like the unstructured Grids. There are two
limitations:
\li YaspGrid does not support simplices
\li If the lower left corner should not be at the origin, the second template parameter
of Yaspgrid has to be chosen as Dune::EquidistantOffsetCoordinates<ctype,dim>.
*/
template<class ctype, int dim>
class StructuredGridFactory<YaspGrid<dim, EquidistantCoordinates<ctype,dim> > >
{
typedef YaspGrid<dim, EquidistantCoordinates<ctype,dim> > GridType;
static const int dimworld = GridType::dimensionworld;
public:
/** \brief Create a structured cube grid
\param lowerLeft Lower left corner of the grid
\param upperRight Upper right corner of the grid
\param elements Number of elements in each coordinate direction
\note The default variant of YaspGrid only supports lowerLeft at the origin.
Use YaspGrid<dim, EquidistantOffsetCoordinates<ctype,dim> > instead
for non-trivial origin.
*/
static std::shared_ptr<GridType>
createCubeGrid(const FieldVector<ctype,dimworld>& lowerLeft,
const FieldVector<ctype,dimworld>& upperRight,
const std::array<unsigned int,dim>& elements)
{
using std::abs;
for(int d = 0; d < dimworld; ++d)
if(abs(lowerLeft[d]) > abs(upperRight[d])*1e-10)
DUNE_THROW(GridError, className<StructuredGridFactory>()
<< "::createCubeGrid(): You have to use Yaspgrid<dim"
", EquidistantOffsetCoordinates<ctype,dim> > as your"
"grid type for non-trivial origin." );
// construct array of ints instead of unsigned ints
std::array<int, dim> elem;
std::copy(elements.begin(), elements.end(), elem.begin());
return std::shared_ptr<GridType>
(new GridType(upperRight, elem,
std::bitset<dim>(), 0)); // default constructor of bitset sets to zero
}
/** \brief Create a structured simplex grid
\note Simplices are not supported in YaspGrid, so this functions
unconditionally throws a GridError.
*/
static std::shared_ptr<GridType>
createSimplexGrid(const FieldVector<ctype,dimworld>& lowerLeft,
const FieldVector<ctype,dimworld>& upperRight,
const std::array<unsigned int,dim>& elements)
{
DUNE_THROW(GridError, className<StructuredGridFactory>()
<< "::createSimplexGrid(): Simplices are not supported "
"by YaspGrid.");
}
};
/** \brief Specialization of the StructuredGridFactory for YaspGrid<EquidistantOffsetCoordinates>
This allows a YaspGrid to be constructed using the
StructuredGridFactory just like the unstructured Grids. Only limitation:
limitations:
\li YaspGrid does not support simplices
*/
template<class ctype, int dim>
class StructuredGridFactory<YaspGrid<dim, EquidistantOffsetCoordinates<ctype,dim> > > {
typedef YaspGrid<dim, EquidistantOffsetCoordinates<ctype,dim> > GridType;
static const int dimworld = GridType::dimensionworld;
public:
/** \brief Create a structured cube grid
\param lowerLeft Lower left corner of the grid
\param upperRight Upper right corner of the grid
\param elements Number of elements in each coordinate direction
*/
static std::shared_ptr<GridType>
createCubeGrid(const FieldVector<ctype,dimworld>& lowerLeft,
const FieldVector<ctype,dimworld>& upperRight,
const std::array<unsigned int,dim>& elements)
{
// construct array of ints instead of unsigned ints
std::array<int, dim> elem;
std::copy(elements.begin(), elements.end(), elem.begin());
return std::shared_ptr<GridType>
(new GridType(lowerLeft, upperRight, elem,
std::bitset<dim>(), 0)); // default constructor of bitset sets to zero
}
/** \brief Create a structured simplex grid
\note Simplices are not supported in YaspGrid, so this functions
unconditionally throws a GridError.
*/
static std::shared_ptr<GridType>
createSimplexGrid(const FieldVector<ctype,dimworld>& lowerLeft,
const FieldVector<ctype,dimworld>& upperRight,
const std::array<unsigned int,dim>& elements)
{
DUNE_THROW(GridError, className<StructuredGridFactory>()
<< "::createSimplexGrid(): Simplices are not supported "
"by YaspGrid.");
}
};
} // namespace Dune
#endif
|