Skip to content
Snippets Groups Projects
Commit 679bc4ba authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Add Cartesian 1D, 2D and 3D meshes to the MeshDataBaseForTests

These mesh can be accessed using
```
MeshDataBaseForTests::instance().cartesianMesh<Dimension>();
```
where Dimension parameter is a constexpr integer.

The result is a `const Mesh<Connectivity<Dimension>>&`
parent 65dd63a7
Branches
Tags
1 merge request!61Feature/mesh based ci
#include <MeshDataBaseForTests.hpp>
#include <utils/PugsAssert.hpp>
#include <mesh/CartesianMeshBuilder.hpp>
#include <mesh/Connectivity.hpp>
#include <utils/PugsAssert.hpp>
const MeshDataBaseForTests* MeshDataBaseForTests::m_instance = nullptr;
MeshDataBaseForTests::MeshDataBaseForTests()
{
std::make_shared<CartesianMeshBuilder>(TinyVector<3>{0, 1, 0}, TinyVector<3>{2, -1, 3},
TinyVector<3, size_t>{6, 7, 3});
m_cartesian_1d_mesh = CartesianMeshBuilder{TinyVector<1>{-1}, TinyVector<1>{3}, TinyVector<1, size_t>{23}}.mesh();
m_cartesian_2d_mesh =
CartesianMeshBuilder{TinyVector<2>{0, -1}, TinyVector<2>{3, 2}, TinyVector<2, size_t>{6, 7}}.mesh();
m_cartesian_3d_mesh =
CartesianMeshBuilder{TinyVector<3>{0, 1, 0}, TinyVector<3>{2, -1, 3}, TinyVector<3, size_t>{6, 7, 4}}.mesh();
}
const MeshDataBaseForTests&
......@@ -31,3 +36,20 @@ MeshDataBaseForTests::destroy()
delete m_instance;
m_instance = nullptr;
}
template <size_t Dimension>
const Mesh<Connectivity<Dimension>>&
MeshDataBaseForTests::cartesianMesh() const
{
if constexpr (Dimension == 1) {
return dynamic_cast<const Mesh<Connectivity<Dimension>>&>(*m_cartesian_1d_mesh);
} else if constexpr (Dimension == 2) {
return dynamic_cast<const Mesh<Connectivity<Dimension>>&>(*m_cartesian_2d_mesh);
} else if constexpr (Dimension == 3) {
return dynamic_cast<const Mesh<Connectivity<Dimension>>&>(*m_cartesian_3d_mesh);
}
}
template const Mesh<Connectivity<1>>& MeshDataBaseForTests::cartesianMesh<1>() const;
template const Mesh<Connectivity<2>>& MeshDataBaseForTests::cartesianMesh<2>() const;
template const Mesh<Connectivity<3>>& MeshDataBaseForTests::cartesianMesh<3>() const;
......@@ -3,6 +3,12 @@
#include <mesh/IMesh.hpp>
template <size_t Dimension>
class Connectivity;
template <typename ConnectivityT>
class Mesh;
#include <memory>
class MeshDataBaseForTests
......@@ -12,7 +18,14 @@ class MeshDataBaseForTests
static const MeshDataBaseForTests* m_instance;
std::shared_ptr<const IMesh> m_cartesian_1d_mesh;
std::shared_ptr<const IMesh> m_cartesian_2d_mesh;
std::shared_ptr<const IMesh> m_cartesian_3d_mesh;
public:
template <size_t Dimension>
const Mesh<Connectivity<Dimension>>& cartesianMesh() const;
static const MeshDataBaseForTests& get();
static void create();
static void destroy();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment