5#ifndef DUNE_GRID_YASPGRID_COORDINATES_HH
6#define DUNE_GRID_YASPGRID_COORDINATES_HH
12#include <dune/common/fvector.hh>
27 template<
class ct,
int dim>
48 for (
int i=0; i<dim; i++)
49 _h[i] = upperRight[i] / _s[i];
56 inline ct
meshsize(
int d, [[maybe_unused]]
int i)
const
73 inline int size(
int d)
const
87 std::array<int,dim> news;
88 Dune::FieldVector<ct,dim> newUpperRight;
90 for (
int i=0; i<dim; i++)
101 newUpperRight[i] = (_h[i] / ct(2.)) * news[i];
109 s <<
"Printing equidistant coordinate information:" << std::endl;
110 s <<
"Meshsize: " << _h << std::endl <<
"Size: " << _s << std::endl;
114 Dune::FieldVector<ct,dim> _h;
115 std::array<int,dim> _s;
118 template<
class ct,
int dim>
129 template<
class ct,
int dim>
150 : _origin(lowerLeft), _s(s)
152 for (
int i=0; i<dim; i++)
153 _h[i] = (upperRight[i] - lowerLeft[i]) / s[i];
160 inline ct
meshsize(
int d, [[maybe_unused]]
int i)
const
171 return _origin[d] + i*_h[d];
199 std::array<int,dim> news;
200 Dune::FieldVector<ct,dim> newUpperRight;
202 for (
int i=0; i<dim; i++)
213 newUpperRight[i] = _origin[i] + (_h[i] / ct(2.)) * news[i];
221 s <<
"Printing equidistant coordinate information:" << std::endl;
222 s <<
"Meshsize: " << _h << std::endl <<
"Size: " << _s << std::endl;
223 s <<
"Offset to origin: " << _origin << std::endl;
227 Dune::FieldVector<ct,dim> _origin;
228 Dune::FieldVector<ct,dim> _h;
229 std::array<int,dim> _s;
232 template<
class ct,
int dim>
243 template<
class ct,
int dim>
262 : _c(c),_offset(offset)
271 return _c[d][i+1-_offset[d]] - _c[d][i-_offset[d]];
280 return _c[d][i-_offset[d]];
288 return _c[d].size() - 1;
299 std::array<std::vector<ct>,dim> newcoords;
300 std::array<int,dim> newoffset(_offset);
301 for (
int i=0; i<dim; i++)
306 int newsize = 2 * _c[i].size() - 1;
317 newcoords[i].resize(newsize);
319 typename std::vector<ct>::const_iterator it = _c[i].begin();
320 typename std::vector<ct>::const_iterator end = _c[i].end()-1;
321 typename std::vector<ct>::iterator iit = newcoords[i].begin() - 1;
328 *(++iit) = (*it + *(++it)) / ct(2.);
337 *(++iit) = (*it + *(++it)) / ct(2.);
340 if (++iit != newcoords[i].end())
349 s <<
"Printing TensorProduct Coordinate information:" << std::endl;
350 for (
int i=0; i<dim; i++)
352 s <<
"Direction " << i <<
": " << _c[i].size() <<
" coordinates" << std::endl;
353 for (std::size_t j=0; j<_c[i].size(); j++)
354 s << _c[i][j] << std::endl;
359 std::array<std::vector<ct>,dim> _c;
360 std::array<int,dim> _offset;
363 template<
class ct,
int dim>
371 template<
class ctype, std::
size_t dim>
374 for (std::size_t i=0; i<dim; i++)
376 if (coords[i].size() <= 1)
378 for (std::size_t j=1; j<coords[i].size(); j++)
379 if (coords[i][j] < coords[i][j-1])
std::ostream & operator<<(std::ostream &out, const PartitionType &type)
write a PartitionType to a stream
Definition: gridenums.hh:72
Include standard header files.
Definition: agrid.hh:60
constexpr Overlap overlap
PartitionSet for the overlap partition.
Definition: partitionset.hh:278
bool checkIfMonotonous(const std::array< std::vector< ctype >, dim > &coords)
Definition: coordinates.hh:372
Container for equidistant coordinates in a YaspGrid.
Definition: coordinates.hh:29
ct coordinate(int d, int i) const
Definition: coordinates.hh:65
int size(int d) const
Definition: coordinates.hh:73
static const int dimension
export dimension
Definition: coordinates.hh:34
void print(std::ostream &s) const
print information on this container
Definition: coordinates.hh:107
EquidistantCoordinates()
default constructor
Definition: coordinates.hh:37
EquidistantCoordinates< ct, dim > refine(std::bitset< dim > ovlp_low, std::bitset< dim > ovlp_up, int overlap, bool keep_ovlp) const
Definition: coordinates.hh:84
ct ctype
export the coordinate type
Definition: coordinates.hh:32
EquidistantCoordinates(const Dune::FieldVector< ct, dim > &upperRight, const std::array< int, dim > &s)
construct a container with all necessary information
Definition: coordinates.hh:45
ct meshsize(int d, int i) const
Definition: coordinates.hh:56
Container for equidistant coordinates in a YaspGrid with non-trivial origin.
Definition: coordinates.hh:131
EquidistantOffsetCoordinates()
default constructor
Definition: coordinates.hh:139
EquidistantOffsetCoordinates(const Dune::FieldVector< ct, dim > &lowerLeft, const Dune::FieldVector< ct, dim > &upperRight, const std::array< int, dim > &s)
construct a container with all necessary information
Definition: coordinates.hh:149
EquidistantOffsetCoordinates< ct, dim > refine(std::bitset< dim > ovlp_low, std::bitset< dim > ovlp_up, int overlap, bool keep_ovlp) const
Definition: coordinates.hh:196
void print(std::ostream &s) const
print information on this container
Definition: coordinates.hh:219
ct meshsize(int d, int i) const
Definition: coordinates.hh:160
ct origin(int d) const
Definition: coordinates.hh:185
int size(int d) const
Definition: coordinates.hh:177
ct ctype
export the coordinate type
Definition: coordinates.hh:134
static const int dimension
export dimension
Definition: coordinates.hh:136
ct coordinate(int d, int i) const
Definition: coordinates.hh:169
Coordinate container for a tensor product YaspGrid.
Definition: coordinates.hh:245
void print(std::ostream &s) const
print information on this container
Definition: coordinates.hh:347
ct meshsize(int d, int i) const
Definition: coordinates.hh:269
ct coordinate(int d, int i) const
Definition: coordinates.hh:278
static const int dimension
export dimension
Definition: coordinates.hh:250
TensorProductCoordinates< ct, dim > refine(std::bitset< dim > ovlp_low, std::bitset< dim > ovlp_up, int overlap, bool keep_ovlp) const
Definition: coordinates.hh:297
TensorProductCoordinates(const std::array< std::vector< ct >, dim > &c, const std::array< int, dim > &offset)
construct a container with all necessary information
Definition: coordinates.hh:261
TensorProductCoordinates()
the default constructor
Definition: coordinates.hh:253
ct ctype
export the coordinate type
Definition: coordinates.hh:248
int size(int d) const
Definition: coordinates.hh:286