36 #include "HoneycombVertexMeshGenerator.hpp" 39 unsigned numElementsUp,
41 double cellRearrangementThreshold,
45 assert(numElementsAcross > 0);
46 assert(numElementsUp > 0);
47 assert(cellRearrangementThreshold > 0.0);
48 assert(t2Threshold > 0.0);
49 assert(elementArea > 0.0);
51 std::vector<Node<2>*> nodes;
52 std::vector<VertexElement<2,2>*> elements;
54 unsigned node_index = 0;
55 unsigned node_indices[6];
56 unsigned element_index;
61 for (
unsigned i=0; i<numElementsAcross; i++)
64 nodes.push_back(p_node);
73 for (
unsigned j=1; j<2*numElementsUp+1; j++)
75 for (
unsigned i=0; i<=numElementsAcross; i++)
77 double x_coord = ((j%4 == 0)||(j%4 == 3)) ? i+0.5 : i;
78 double y_coord = (1.5*j - 0.5*(j%2))*0.5/sqrt(3.0);
79 bool is_boundary_node = (j==1 || j==2*numElementsUp || i==0 || i==numElementsAcross) ?
true :
false;
81 Node<2>* p_node =
new Node<2>(node_index, is_boundary_node, x_coord, y_coord);
82 nodes.push_back(p_node);
90 double y_coord = (1.5*(2*numElementsUp+1) - 0.5*((2*numElementsUp+1)%2))*0.5/sqrt(3.0);
91 if (((2*numElementsUp+1)%4 == 0)||((2*numElementsUp+1)%4 == 3))
94 nodes.push_back(p_node);
97 for (
unsigned i=1; i<numElementsAcross; i++)
99 double x_coord = (((2*numElementsUp+1)%4 == 0)||((2*numElementsUp+1)%4 == 3)) ? i+0.5 : i;
101 Node<2>* p_node =
new Node<2>(node_index,
true, x_coord, y_coord);
102 nodes.push_back(p_node);
105 if (((2*numElementsUp+1)%4 == 1)||((2*numElementsUp+1)%4 == 2))
107 Node<2>* p_node =
new Node<2>(node_index,
true, numElementsAcross, y_coord);
108 nodes.push_back(p_node);
116 for (
unsigned j=0; j<numElementsUp; j++)
118 for (
unsigned i=0; i<numElementsAcross; i++)
126 node_indices[0] = 2*j*(numElementsAcross+1) - 1*(j%2==0) + i;
128 node_indices[1] = node_indices[0] + numElementsAcross + 1 + 1*(j%2==0 && j>0);
129 node_indices[2] = node_indices[1] + numElementsAcross + 1;
130 node_indices[3] = node_indices[2] + numElementsAcross + 1*(j%2==1 && j<numElementsUp-1);
131 node_indices[4] = node_indices[2] - 1;
132 node_indices[5] = node_indices[1] - 1;
134 std::vector<Node<2>*> element_nodes;
135 for (
unsigned k=0; k<6; k++)
137 element_nodes.push_back(nodes[node_indices[k]]);
140 element_index = j*numElementsAcross + i;
142 elements.push_back(p_element);
149 mpMesh->
Scale(sqrt(elementArea*2.0/sqrt(3.0)), sqrt(elementArea*2.0/sqrt(3.0)));
HoneycombVertexMeshGenerator()
MutableVertexMesh< 2, 2 > * mpMesh
virtual MutableVertexMesh< 2, 2 > * GetMesh()
virtual void Scale(const double xFactor=1.0, const double yFactor=1.0, const double zFactor=1.0)
virtual ~HoneycombVertexMeshGenerator()