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 
140  virtual std::vector<double> getMinorMeshPoint(
141  const std::vector<unsigned int> &meshPoint,
142  const std::vector<unsigned int> &numMeshPoints
143  ) const = 0;
144 protected:
146  const std::vector<Vector3d>& getBasisVectors() const;
147 
149  MeshType getMeshType() const;
150 private:
152  unsigned dimensions;
153 
158  std::vector<Vector3d> basisVectors;
159 
161  MeshType meshType;
162 };
163 
164 inline unsigned int SpacePartition::getNumDimensions() const{
165  return dimensions;
166 }
167 
169  std::initializer_list<double> coordinate
170 ) const{
171  return getMajorCellIndex(std::vector<double>(coordinate));
172 }
173 
175  std::initializer_list<double> coordinate,
176  std::initializer_list<unsigned int> numMeshPoints
177 ) const{
178  return getMinorCellIndex(
179  std::vector<double>(coordinate),
180  std::vector<unsigned int>(numMeshPoints)
181  );
182 }
183 
185  const std::vector<double> &coordinate,
186  std::initializer_list<unsigned int> numMeshPoints
187 ) const{
188  return getMinorCellIndex(
189  coordinate,
190  std::vector<unsigned int>(numMeshPoints)
191  );
192 }
193 
195  const std::initializer_list<double> coordinate,
196  const std::vector<unsigned int> &numMeshPoints
197 ) const{
198  return getMinorCellIndex(
199  std::vector<double>(coordinate),
200  numMeshPoints
201  );
202 }
203 
204 inline std::vector<std::vector<double>> SpacePartition::getMajorMesh(
205  std::initializer_list<unsigned int> numMeshPoints
206 ){
207  return getMajorMesh(std::vector<unsigned int>(numMeshPoints));
208 }
209 
210 inline std::vector<std::vector<double>> SpacePartition::getMinorMesh(
211  std::initializer_list<unsigned int> numMeshPoints
212 ){
213  return getMinorMesh(std::vector<unsigned int>(numMeshPoints));
214 }
215 
216 inline const std::vector<Vector3d>& SpacePartition::getBasisVectors() const{
217  return basisVectors;
218 }
219 
221  return meshType;
222 }
223 
224 }; //End namespace TBTK
225 
226 #endif
Index getMinorCellIndex(std::initializer_list< double > coordinate, std::initializer_list< unsigned int > numMeshPoints) const
Definition: SpacePartition.h:174
const std::vector< Vector3d > & getBasisVectors() const
Definition: SpacePartition.h:216
Flexible physical index.
std::vector< std::vector< double > > getMinorMesh(std::initializer_list< unsigned int > numMeshPoints)
Definition: SpacePartition.h:210
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:164
Definition: SpacePartition.h:36
MeshType
Definition: SpacePartition.h:46
Index getMajorCellIndex(std::initializer_list< double > coordinate) const
Definition: SpacePartition.h:168
Flexible physical index.
Definition: Index.h:69
Definition: ModelFactory.h:35
std::vector< std::vector< double > > getMajorMesh(std::initializer_list< unsigned int > numMeshPoints)
Definition: SpacePartition.h:204
virtual std::vector< double > getMinorMeshPoint(const std::vector< unsigned int > &meshPoint, const std::vector< unsigned int > &numMeshPoints) const =0
virtual ~SpacePartition()
MeshType getMeshType() const
Definition: SpacePartition.h:220