TBTK
SpacePartition.h
Go to the documentation of this file.
1 /* Copyright 2017 Kristofer Bj√∂rnson
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
23 #ifndef COM_DAFER45_TBTK_SPACE_PARTITION
24 #define COM_DAFER45_TBTK_SPACE_PARTITION
25 
26 #include "TBTK/Index.h"
27 #include "TBTK/Vector3d.h"
28 
29 #include <initializer_list>
30 #include <vector>
31 
32 namespace TBTK{
33 
37 public:
46  enum class MeshType {Nodal, Interior};
47 
50  std::initializer_list<std::initializer_list<double>> basisVectors,
51  MeshType meshType
52  );
53 
56  const std::vector<std::vector<double>> &basisVectors,
57  MeshType meshType
58  );
59 
61  virtual ~SpacePartition();
62 
64  unsigned int getNumDimensions() const;
65 
69  std::initializer_list<double> coordinate
70  ) const;
71 
74  virtual Index getMajorCellIndex(
75  const std::vector<double> &coordinate
76  ) const = 0;
77 
82  std::initializer_list<double> coordinate,
83  std::initializer_list<unsigned int> numMeshPoints
84  ) const;
85 
90  const std::vector<double> &coordinate,
91  std::initializer_list<unsigned int> numMeshPoints
92  ) const;
93 
98  std::initializer_list<double> coordinate,
99  const std::vector<unsigned int> &numMeshPoints
100  ) const;
101 
105  virtual Index getMinorCellIndex(
106  const std::vector<double> &coordinate,
107  const std::vector<unsigned int> &numMeshPoints
108  ) const = 0;
109 
112  std::vector<std::vector<double>> getMajorMesh(
113  std::initializer_list<unsigned int> numMeshPoints
114  );
115 
118  virtual std::vector<std::vector<double>> getMajorMesh(
119  const std::vector<unsigned int> &numMeshPoints
120  ) const = 0;
121 
124  std::vector<std::vector<double>> getMinorMesh(
125  std::initializer_list<unsigned int> numMeshPoints
126  );
127 
130  virtual std::vector<std::vector<double>> getMinorMesh(
131  const std::vector<unsigned int> &numMeshPoints
132  ) const = 0;
133 protected:
135  const std::vector<Vector3d>& getBasisVectors() const;
136 
138  MeshType getMeshType() const;
139 private:
141  unsigned dimensions;
142 
147  std::vector<Vector3d> basisVectors;
148 
150  MeshType meshType;
151 };
152 
153 inline unsigned int SpacePartition::getNumDimensions() const{
154  return dimensions;
155 }
156 
158  std::initializer_list<double> coordinate
159 ) const{
160  return getMajorCellIndex(std::vector<double>(coordinate));
161 }
162 
164  std::initializer_list<double> coordinate,
165  std::initializer_list<unsigned int> numMeshPoints
166 ) const{
167  return getMinorCellIndex(
168  std::vector<double>(coordinate),
169  std::vector<unsigned int>(numMeshPoints)
170  );
171 }
172 
174  const std::vector<double> &coordinate,
175  std::initializer_list<unsigned int> numMeshPoints
176 ) const{
177  return getMinorCellIndex(
178  coordinate,
179  std::vector<unsigned int>(numMeshPoints)
180  );
181 }
182 
184  const std::initializer_list<double> coordinate,
185  const std::vector<unsigned int> &numMeshPoints
186 ) const{
187  return getMinorCellIndex(
188  std::vector<double>(coordinate),
189  numMeshPoints
190  );
191 }
192 
193 inline std::vector<std::vector<double>> SpacePartition::getMajorMesh(
194  std::initializer_list<unsigned int> numMeshPoints
195 ){
196  return getMajorMesh(std::vector<unsigned int>(numMeshPoints));
197 }
198 
199 inline std::vector<std::vector<double>> SpacePartition::getMinorMesh(
200  std::initializer_list<unsigned int> numMeshPoints
201 ){
202  return getMinorMesh(std::vector<unsigned int>(numMeshPoints));
203 }
204 
205 inline const std::vector<Vector3d>& SpacePartition::getBasisVectors() const{
206  return basisVectors;
207 }
208 
210  return meshType;
211 }
212 
213 }; //End namespace TBTK
214 
215 #endif
Index getMinorCellIndex(std::initializer_list< double > coordinate, std::initializer_list< unsigned int > numMeshPoints) const
Definition: SpacePartition.h:163
const std::vector< Vector3d > & getBasisVectors() const
Definition: SpacePartition.h:205
Flexible physical index.
std::vector< std::vector< double > > getMinorMesh(std::initializer_list< unsigned int > numMeshPoints)
Definition: SpacePartition.h:199
SpacePartition(std::initializer_list< std::initializer_list< double >> basisVectors, MeshType meshType)
Three-dimensional vector with components of double type.
unsigned int getNumDimensions() const
Definition: SpacePartition.h:153
Definition: SpacePartition.h:36
MeshType
Definition: SpacePartition.h:46
Index getMajorCellIndex(std::initializer_list< double > coordinate) const
Definition: SpacePartition.h:157
Flexible physical index.
Definition: Index.h:70
Definition: ModelFactory.h:35
std::vector< std::vector< double > > getMajorMesh(std::initializer_list< unsigned int > numMeshPoints)
Definition: SpacePartition.h:193
virtual ~SpacePartition()
MeshType getMeshType() const
Definition: SpacePartition.h:209