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

begining of 2d connectivity

parent 681984aa
No related branches found
No related tags found
No related merge requests found
#ifndef CONNECTIVITY_2D_HPP
#define CONNECTIVITY_2D_HPP
#include <Kokkos_Core.hpp>
#include <TinyVector.hpp>
class Connectivity2D
{
public:
static constexpr size_t dimension = 2;
private:
const size_t m_number_of_cells;
size_t m_number_of_faces;
size_t m_number_of_nodes;
const Kokkos::View<const unsigned int**> m_cell_nodes;
Kokkos::View<unsigned int**> m_cell_faces;
Kokkos::View<unsigned short*> m_cell_nb_nodes;
Kokkos::View<double*> m_inv_cell_nb_nodes;
Kokkos::View<unsigned short*> m_cell_nb_faces;
Kokkos::View<unsigned short*> m_node_nb_cells;
Kokkos::View<unsigned short*> m_face_nb_cells;
Kokkos::View<unsigned int**> m_node_cells;
Kokkos::View<unsigned int**> m_face_cells;
Kokkos::View<unsigned short**> m_node_cell_local_node;
Kokkos::View<unsigned short**> m_face_cell_local_face;
size_t m_max_nb_node_per_cell;
public:
const size_t& numberOfNodes() const
{
return m_number_of_nodes;
}
const size_t& numberOfFaces() const
{
return m_number_of_faces;
}
const size_t& numberOfCells() const
{
return m_number_of_cells;
}
const size_t& maxNbNodePerCell() const
{
return m_max_nb_node_per_cell;
}
const Kokkos::View<const unsigned int**> cellNodes() const
{
return m_cell_nodes;
}
const Kokkos::View<const unsigned int**> cellFaces() const
{
return m_cell_faces;
}
const Kokkos::View<const unsigned short*> nodeNbCells() const
{
return m_node_nb_cells;
}
const Kokkos::View<const unsigned short*> cellNbNodes() const
{
return m_cell_nb_nodes;
}
const Kokkos::View<const double*> invCellNbNodes() const
{
return m_inv_cell_nb_nodes;
}
const Kokkos::View<const unsigned short*> cellNbFaces() const
{
return m_cell_nb_faces;
}
const Kokkos::View<const unsigned short*> faceNbCells() const
{
return m_face_nb_cells;
}
const Kokkos::View<const unsigned int**> nodeCells() const
{
return m_node_cells;
}
const Kokkos::View<const unsigned int**> faceCells() const
{
return m_face_cells;
}
const Kokkos::View<const unsigned short**> nodeCellLocalNode() const
{
return m_node_cell_local_node;
}
const Kokkos::View<const unsigned short**> faceCellLocalFace() const
{
return m_face_cell_local_face;
}
Connectivity2D(const Connectivity2D&) = delete;
Connectivity2D(const Kokkos::View<const unsigned int**> cell_nodes)
: m_number_of_cells (cell_nodes.dimension_0()),
m_cell_nodes (cell_nodes)
{
assert(m_number_of_cells>0);
std::cout << __PRETTY_FUNCTION__<< ": Number of cells = " << m_number_of_cells << '\n';
}
~Connectivity2D()
{
;
}
};
#endif // CONNECTIVITY_2D_HPP
......@@ -5,6 +5,9 @@
#include <set>
#include <rang.hpp>
#include <Connectivity2D.hpp>
#include <Mesh.hpp>
template<typename T>
inline std::string stringify(const T & t)
{
......@@ -728,7 +731,33 @@ GmshReader::__proceedData()
std::cerr << "*** using a 3d mesh (NIY)\n";
std::exit(0);
} else if ((dimension2_mask, elementNumber)>0) {
std::cerr << "*** using a 2d mesh (NIY)\n";
if (__quadrangles.dimension_0()>0) {
std::cerr << "quadrangles NYI\n";
std::exit(0);
}
Kokkos::View<unsigned int**> cell_nodes("cell_nodes", __triangles.dimension_0(), 3);
Connectivity2D connectivity(cell_nodes);
typedef Mesh<Connectivity2D> MeshType;
typedef TinyVector<2, double> Rd;
Kokkos::View<Rd*> xr("xr", __vertices.dimension_0());
for (size_t i=0; i<__vertices.dimension_0(); ++i) {
xr[i][0] = __vertices[i][0];
xr[i][1] = __vertices[i][1];
}
MeshType mesh(connectivity, xr);
std::ofstream gnuplot("mesh.gnu");
for (int j=0; j<mesh.numberOfCells(); ++j) {
for (int r=0; r<3; ++r) {
const Rd& x = mesh.xr()[mesh.connectivity().cellNodes()(j,r)];
gnuplot << x[0] << ' ' << x[1] << '\n';
}
const Rd& x = mesh.xr()[mesh.connectivity().cellNodes()(j,0)];
gnuplot << x[0] << ' ' << x[1] << "\n\n";
}
std::exit(0);
} else if ((dimension1_mask, elementNumber)>0) {
std::cerr << "*** using a 1d mesh (NIY)\n";
......
......@@ -48,12 +48,24 @@ public:
: m_connectivity(connectivity),
m_xr("xr", connectivity.numberOfNodes())
{
static_assert (Connectivity::dimension ==1,"no automatic calculation of vertices in dim>1");
const double delta_x = 1./connectivity.numberOfCells();
Kokkos::parallel_for(connectivity.numberOfNodes(), KOKKOS_LAMBDA(const int& r){
m_xr[r][0] = r*delta_x;
});
}
KOKKOS_INLINE_FUNCTION
Mesh(const Connectivity& connectivity,
Kokkos::View<Rd*>& xr)
: m_connectivity(connectivity),
m_xr(xr)
{
;
}
Mesh() = delete;
~Mesh()
{
;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment