4 #ifndef NIHU_LIB_MESH_HPP_INCLUDED
5 #define NIHU_LIB_MESH_HPP_INCLUDED
7 #include "../core/mesh.hpp"
30 template <
class ElemTag = NiHu::line_1_tag>
36 ElemTag tag = ElemTag())
38 using namespace boost::math::double_constants;
40 typedef ElemTag tag_t;
43 static size_t const M = elem_t::num_nodes;
46 size_t nNodes = (M-1) * nElem;
48 Eigen::Matrix<double, Eigen::Dynamic, 2> nodes(nNodes, 2);
49 for (
size_t i = 0; i < nNodes; ++i) {
50 double phi = i*two_pi/nNodes;
51 nodes.row(i) << r * cos(phi), r * sin(phi);
55 Eigen::Matrix<unsigned, Eigen::Dynamic, M+1> elements(nElem, M + 1);
56 for (
size_t i = 0; i < nElem; ++i) {
57 elements(i,0) = elem_t::id;
58 for (
size_t j = 0; j < M; ++j)
60 elements(i,j+1) = (i * (M-1) + j) % nNodes;
62 elements(i,M - j) = (i * (M-1) + j) % nNodes;
80 template <
class ElemTag = NiHu::line_1_tag>
86 ElemTag tag = ElemTag())
88 typedef ElemTag tag_t;
91 static size_t const M = elem_t::num_nodes;
93 size_t nElem = 2 * (nx + ny);
95 size_t nNodes = (M - 1) * nElem;
96 Eigen::Matrix<double, Eigen::Dynamic, 2> nodes(nNodes, 2);
100 for (
size_t i = 0; i < nx * (M - 1); ++i)
101 nodes.row(k++) << Lx / (nx * (M - 1)) * i, 0.0;
102 for (
size_t i = 0; i < ny * (M - 1); ++i)
103 nodes.row(k++) << Lx, Ly / (ny * (M - 1)) * i;
104 for (
size_t i = 0; i < nx * (M - 1); ++i)
105 nodes.row(k++) << Lx - Lx / (nx * (M - 1)) * i, Ly;
106 for (
size_t i = 0; i < ny * (M - 1); ++i)
107 nodes.row(k++) << 0.0, Ly - Ly / (ny * (M - 1)) * i;
110 Eigen::Matrix<unsigned, Eigen::Dynamic, M + 1> elements(nElem, M + 1);
111 for (
size_t i = 0; i < nElem; ++i) {
112 elements(i, 0) = elem_t::id;
113 for (
size_t j = 0; j < M; ++j)
115 elements(i, j + 1) = (i * (M-1) + j) % nNodes;
117 elements(i, M - j) = (i * (M-1) + j) % nNodes;
126 #endif // NIHU_LIB_MESH_HPP_INCLUDED