WaveBlocksND
shape_extended.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "../../types.hpp"
4 
5 #include "shape_hypercubic.hpp"
6 
7 
8 namespace waveblocks {
9  namespace wavepackets {
10  namespace shapes {
24  template<dim_t D, class S>
26  {
27  private:
28  S shape_;
29 
30  public:
31  ExtendedShape(S shape)
32  : shape_(shape)
33  { }
34 
35  int bbox(dim_t axis) const
36  {
37  return shape_.bbox(axis)+1;
38  }
39 
40  template<class MultiIndex>
41  int limit(const MultiIndex &index, dim_t axis) const
42  {
43  int value = shape_.limit(index, axis);
44 
45  //extend only when there actually are some nodes
46  if (value >= 0)
47  value += 1;
48 
49  for (dim_t d = 0; d < D; d++) {
50  if (d != axis && index[d] != 0) {
51  //backward neighbour index
52  MultiIndex prev_index = index; prev_index[d] -= 1;
53 
54  value = std::max(value, shape_.limit(prev_index, axis) );
55  }
56  }
57 
58  return value;
59  }
60 
61  std::string description() const
62  {
63  std::stringstream out;
64  out << "ExtendedShape<?>[" << shape_.description() << "]";
65  return out.str();
66  }
67  };
68 
69  template<dim_t D>
71  {
72  private:
74 
75  public:
77  : expansion_(shape)
78  {
79  std::array<int,D> limits2;
80  for (dim_t d = 0; d < D; d++)
81  limits2[d] = shape.bbox(d)+2;
82  expansion_ = HyperCubicShape<D>(limits2);
83  }
84 
85  int bbox(dim_t axis) const
86  {
87  return expansion_.bbox(axis);
88  }
89 
90  template<class MultiIndex>
91  int limit(const MultiIndex &index, dim_t axis) const
92  {
93  return expansion_.template limit< MultiIndex >(index, axis);
94  }
95 
96  std::string description() const
97  {
98  return expansion_.description();
99  }
100  };
101  }
102  }
103 }
This class implements the hypercubic basis shape.
Definition: shape_hypercubic.hpp:30
std::string description() const
Definition: shape_extended.hpp:96
Definition: coefficients_file_parser.cpp:10
S shape_
Definition: shape_extended.hpp:28
int limit(const MultiIndex &index, dim_t axis) const
Definition: shape_extended.hpp:91
int bbox(dim_t axis) const
Definition: shape_extended.hpp:35
Defines the extension of a shape: For each lattice point add all its neighbours.
Definition: shape_extended.hpp:25
ExtendedShape(S shape)
Definition: shape_extended.hpp:31
int bbox(dim_t axis) const
Definition: shape_extended.hpp:85
ExtendedShape(HyperCubicShape< D > shape)
Definition: shape_extended.hpp:76
std::string description() const
Definition: shape_extended.hpp:61
HyperCubicShape< D > expansion_
Definition: shape_extended.hpp:73
virtual int bbox(dim_t axis) const override
Retrieves the length of the minimum bounding box in one direction.
Definition: shape_hypercubic.hpp:91
int dim_t
Definition: types.hpp:16
int limit(const MultiIndex &index, dim_t axis) const
Definition: shape_extended.hpp:41