41 unsigned numElementsUp,
42 double cellRearrangementThreshold,
46 assert(numElementsAcross > 1);
47 assert(numElementsUp > 1);
48 assert(numElementsAcross%2 == 0);
49 assert(numElementsUp%2 == 0);
51 assert(cellRearrangementThreshold > 0.0);
52 assert(t2Threshold > 0.0);
54 std::vector<Node<2>*> nodes;
55 std::vector<VertexElement<2,2>*> elements;
57 unsigned node_index = 0;
58 unsigned node_indices[6];
59 unsigned element_index;
62 for (
unsigned j=0; j<2*numElementsUp; j++)
64 for (
unsigned i=0; i<numElementsAcross; i++)
66 double x_coord = ((j%4 == 0)||(j%4 == 3)) ? i+0.5 : i;
67 double y_coord = (1.5*j - 0.5*(j%2))*0.5/sqrt(3.0);
69 Node<2>* p_node =
new Node<2>(node_index,
false , x_coord, y_coord);
70 nodes.push_back(p_node);
79 for (
unsigned j=0; j<numElementsUp; j++)
81 for (
unsigned i=0; i<numElementsAcross; i++)
83 element_index = j*numElementsAcross + i;
85 node_indices[0] = 2*j*numElementsAcross + i + 1*(j%2==1);
86 node_indices[1] = node_indices[0] + numElementsAcross + 1*(j%2==0);
87 node_indices[2] = node_indices[0] + 2*numElementsAcross + 1*(j%2==0);
88 node_indices[3] = node_indices[0] + 3*numElementsAcross;
89 node_indices[4] = node_indices[0] + 2*numElementsAcross - 1*(j%2==1);
90 node_indices[5] = node_indices[0] + numElementsAcross - 1*(j%2==1);
92 if (i == numElementsAcross-1)
94 node_indices[0] -= numElementsAcross*(j%2==1);
95 node_indices[1] -= numElementsAcross;
96 node_indices[2] -= numElementsAcross;
97 node_indices[3] -= numElementsAcross*(j%2==1);
99 if (j == numElementsUp-1)
101 node_indices[2] -= 2*numElementsAcross*numElementsUp;
102 node_indices[3] -= 2*numElementsAcross*numElementsUp;
103 node_indices[4] -= 2*numElementsAcross*numElementsUp;
106 std::vector<Node<2>*> element_nodes;
107 for (
unsigned k=0; k<6; k++)
109 element_nodes.push_back(nodes[node_indices[k]]);
112 elements.push_back(p_element);
116 double mesh_width = numElementsAcross;
117 double mesh_height = 1.5*numElementsUp/sqrt(3.0);
119 mpMesh = boost::make_shared<Toroidal2dVertexMesh>(mesh_width, mesh_height, nodes, elements, cellRearrangementThreshold, t2Threshold);