36 #include "CylindricalHoneycombVertexMeshGenerator.hpp"
39 unsigned numElementsUp,
41 double cellRearrangementThreshold,
46 assert(numElementsAcross > 1);
47 assert(numElementsAcross%2 == 0);
49 assert(numElementsUp > 0);
50 assert(cellRearrangementThreshold > 0.0);
51 assert(t2Threshold > 0.0);
53 std::vector<Node<2>*> nodes;
54 std::vector<VertexElement<2,2>*> elements;
56 unsigned node_index = 0;
57 unsigned node_indices[6];
58 unsigned element_index;
61 for (
unsigned j=0; j<=2*numElementsUp+1; j++)
63 if (isFlatBottom && (j==1))
66 for (
unsigned i=0; i<=numElementsAcross-1; i++)
69 nodes.push_back(p_node);
79 for (
unsigned i=0; i<=numElementsAcross-1; i++)
81 double x_coord = ((j%4 == 0)||(j%4 == 3)) ? i+0.5 : i;
82 double y_coord = (1.5*j - 0.5*(j%2))*0.5/sqrt(3.0);
83 bool is_boundary_node = (j==0 || j==1 || j==2*numElementsUp || j==2*numElementsUp+1) ?
true :
false;
85 Node<2>* p_node =
new Node<2>(node_index, is_boundary_node , x_coord, y_coord);
86 nodes.push_back(p_node);
96 for (
unsigned j=0; j<numElementsUp; j++)
98 for (
unsigned i=0; i<numElementsAcross; i++)
100 element_index = j*numElementsAcross + i;
102 node_indices[0] = 2*j*numElementsAcross + i + 1*(j%2==1);
103 node_indices[1] = node_indices[0] + numElementsAcross + 1*(j%2==0);
104 node_indices[2] = node_indices[0] + 2*numElementsAcross + 1*(j%2==0);
105 node_indices[3] = node_indices[0] + 3*numElementsAcross;
106 node_indices[4] = node_indices[0] + 2*numElementsAcross - 1*(j%2==1);
107 node_indices[5] = node_indices[0] + numElementsAcross - 1*(j%2==1);
109 if (i==numElementsAcross-1)
111 node_indices[0] -= numElementsAcross*(j%2==1);
112 node_indices[1] -= numElementsAcross;
113 node_indices[2] -= numElementsAcross;
114 node_indices[3] -= numElementsAcross*(j%2==1);
117 std::vector<Node<2>*> element_nodes;
118 for (
unsigned k=0; k<6; k++)
120 element_nodes.push_back(nodes[node_indices[k]]);
123 elements.push_back(p_element);
130 for (
unsigned i=0; i<numElementsAcross; i++)
132 nodes[i]->SetPoint(nodes[i+numElementsAcross]->GetPoint());
140 EXCEPTION(
"A cylindrical mesh was created but a normal mesh is being requested.");
Cylindrical2dVertexMesh * GetCylindricalMesh()
#define EXCEPTION(message)
MutableVertexMesh< 2, 2 > * mpMesh
MutableVertexMesh< 2, 2 > * GetMesh()
CylindricalHoneycombVertexMeshGenerator(unsigned numElementsAcross, unsigned numElementsUp, bool isFlatBottom=false, double cellRearrangementThreshold=0.01, double t2Threshold=0.001)