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() { throw std::runtime_error("Not implemented currently.\n"); }
28 void create(SimulationClassBase<T>* sim);
29
30 public:
31 GridFactory(SimulationClassBase<T>* sim, std::shared_ptr<ShapeBase<T>> m_simulation_shape,
32 const std::string& dimension);
33
34 std::shared_ptr<GridBase<T>> getGridPtr() { return m_simulation_grid; }
35};
36
41template <typename T>
43 std::shared_ptr<ShapeBase<T>> simulation_shape,
44 const std::string& dimension)
45 : m_dimension(setDimension(dimension)), m_simulation_shape{simulation_shape}
46{
47 create(sim);
48}
49
54template <typename T>
56{
57 switch (m_dimension)
58 {
59 case Dimension::OneD:
60 m_simulation_grid = std::make_shared<GridOneDim<T>>(sim, m_simulation_shape);
61 break;
62 // TwoD and ThreeD are not yet supported
63 default:
64 throw std::runtime_error("Creation of 2D and 3D grids is not yet supported!\n");
65 }
66}
67
68#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:35
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:42
std::shared_ptr< GridBase< T > > getGridPtr()
Definition GridFactory.h:34