MoCSI API Reference
Loading...
Searching...
No Matches
GridFactory.h
Go to the documentation of this file.
1#ifndef GRID_FACTORY_H
2#define GRID_FACTORY_H
3
4#include <memory>
5#include <stdexcept>
6#include <string>
7#include <valarray>
8#include <vector>
9
10#include "CoreEnums.h"
11#include "GridBase.h"
12#include "GridOneDim.h"
13#include "ShapeBase.h"
14#include "SimulationClassBase.h"
15
19template <typename T>
21{
22 private:
23 Dimension m_dimension;
24 std::shared_ptr<GridBase<T>> m_simulation_grid{};
25 std::shared_ptr<ShapeBase<T>> m_simulation_shape{};
26
27 void loadGrid()
28 {
29 std::cerr << "[GridFactory]: Not implemented currently.\n";
30 throw std::runtime_error(
31 static_cast<std::string>("[GridFactory]: Not implemented currently."));
32 }
33 void create(SimulationClassBase<T>* sim);
34
35 public:
36 GridFactory(SimulationClassBase<T>* sim, std::shared_ptr<ShapeBase<T>> m_simulation_shape,
37 const std::string& dimension);
38
39 std::shared_ptr<GridBase<T>> getGridPtr() { return m_simulation_grid; }
40};
41
46template <typename T>
48 std::shared_ptr<ShapeBase<T>> simulation_shape,
49 const std::string& dimension)
50 : m_dimension(setDimension(dimension)), m_simulation_shape{simulation_shape}
51{
52 create(sim);
53}
54
59template <typename T>
61{
62 switch (m_dimension)
63 {
64 case Dimension::OneD:
65 m_simulation_grid = std::make_shared<GridOneDim<T>>(sim, m_simulation_shape);
66 break;
67 // TwoD and ThreeD are not yet supported
68 default:
69 std::cerr << "[GridFactory]: Creation of 2D and 3D grids is not yet supported!\n";
70 throw std::runtime_error(static_cast<std::string>(
71 "[GridFactory]: Creation of 2D and 3D grids is not yet supported!"));
72 }
73}
74
75#endif
Dimension
Definition CoreEnums.h:8
constexpr Dimension setDimension(const std::string &dimension)
Definition CoreEnums.h:14
Concrete implementation of a matrix class representing a Compressed Sparse Rows (CSR) matrix....
Definition CsrMatrix.h:37
Class that manages the creation of the GridBase object.
Definition GridFactory.h:21
GridFactory(SimulationClassBase< T > *sim, std::shared_ptr< ShapeBase< T > > m_simulation_shape, const std::string &dimension)
Constructor for the GridFactory class. Structurally identical to the ShapeFactory class.
Definition GridFactory.h:47
std::shared_ptr< GridBase< T > > getGridPtr()
Definition GridFactory.h:39