28 using coord_t = Eigen::Vector3d;
34 const unsigned no_of_cells = nx * ny;
35 const unsigned no_of_edges = 2 * nx * ny;
36 const unsigned no_of_vertices = nx * ny;
38 if (no_of_cells == 0) {
45 if ((x_size <= 0.0) || (y_size <= 0.0)) {
50 const double hx = x_size / nx;
51 const double hy = y_size / ny;
56 auto theta = [r, hx](
double i) ->
double {
return (i * hx) / r; };
57 auto phi = [R, hy](
double j) ->
double {
return (j * hy) / R; };
61 "TorusMesh: {} cells, {} edges, {} vertices, mesh widths hx/hy = {}/{}",
62 no_of_cells, no_of_edges, no_of_vertices, hx, hy);
65 std::vector<size_type> v_idx(no_of_vertices);
69 for (
size_type i = 0; i < nx; ++i, ++node_cnt) {
72 node_coord << (R + r * std::cos(theta(i))) * std::cos(phi(j)),
73 (R + r * std::cos(theta(i))) * std::sin(phi(j)),
74 r * std::sin(theta(i));
76 SPDLOG_LOGGER_TRACE(
Logger(),
"Adding vertex {}: {}", node_cnt,
77 node_coord.transpose());
84 std::vector<size_type> t_idx(no_of_cells);
88 for (
size_type j = 0; j < ny; ++j, quad_cnt++) {
90 std::vector<size_type> vertex_index_list{
95 Eigen::Matrix<double, 3, 4> quad_geo;
96 quad_geo << (R + r * std::cos(theta(i))) * std::cos(phi(j)),
97 (R + r * std::cos(theta(i + 1))) * std::cos(phi(j)),
98 (R + r * std::cos(theta(i + 1))) * std::cos(phi(j + 1)),
99 (R + r * std::cos(theta(i))) * std::cos(phi(j + 1)),
100 (R + r * std::cos(theta(i))) * std::sin(phi(j)),
101 (R + r * std::cos(theta(i + 1))) * std::sin(phi(j)),
102 (R + r * std::cos(theta(i + 1))) * std::sin(phi(j + 1)),
103 (R + r * std::cos(theta(i))) * std::sin(phi(j + 1)),
104 r * std::sin(theta(i)), r * std::sin(theta(i + 1)),
105 r * std::sin(theta(i + 1)), r * std::sin(theta(i));
107 SPDLOG_LOGGER_TRACE(
Logger(),
"Adding quad {}:\n{}", quad_cnt, quad_geo);
113 std::make_unique<geometry::QuadO1>(quad_geo));