57 assert(scaleFactor > 0.0);
60 std::stringstream pid;
68 double vertical_spacing = (sqrt(3.0)/2)*horizontal_spacing;
74 num_nodes_along_length += 2*ghosts;
76 unsigned num_nodes = num_nodes_along_width*num_nodes_along_length;
77 unsigned num_elem_along_width = num_nodes_along_width-1;
78 unsigned num_elem_along_length = num_nodes_along_length-1;
79 unsigned num_elem = 2*num_elem_along_width*num_elem_along_length;
80 unsigned num_edges = 3*num_elem_along_width*num_elem_along_length + num_elem_along_width + num_elem_along_length;
83 double y0 = -vertical_spacing*ghosts;
85 mBottom = -vertical_spacing*ghosts;
86 mTop =
mBottom + vertical_spacing*(num_nodes_along_length-1);
90 (*p_node_file) << std::scientific;
92 (*p_node_file) << num_nodes <<
"\t2\t0\t1" << std::endl;
95 for (
unsigned i=0; i<num_nodes_along_length; i++)
97 for (
unsigned j=0; j<num_nodes_along_width; j++)
103 unsigned boundary = 0;
104 if ((i==0) || (i==num_nodes_along_length-1))
109 const double adjustment = i % 2 != 0 ? 0.5 : 0.0;
110 double x = x0 + horizontal_spacing*((
double)j + adjustment);
111 double y = y0 + vertical_spacing*(
double)i;
114 if ((y<0.0) && (y>-1e-12))
122 (*p_node_file) << node++ <<
"\t" << x <<
"\t" << y <<
"\t" << boundary << std::endl;
125 p_node_file->close();
129 (*p_elem_file) << std::scientific;
132 (*p_node_file) << std::scientific;
134 (*p_elem_file) << num_elem <<
"\t3\t0" << std::endl;
135 (*p_edge_file) << num_edges <<
"\t1" << std::endl;
139 for (
unsigned i=0; i<num_elem_along_length; i++)
141 for (
unsigned j=0; j < num_elem_along_width; j++)
143 unsigned node0 = i*num_nodes_along_width + j;
144 unsigned node1 = i*num_nodes_along_width + j+1;
145 unsigned node2 = (i+1)*num_nodes_along_width + j;
152 (*p_elem_file) << elem++ <<
"\t" << node0 <<
"\t" << node1 <<
"\t" << node2 << std::endl;
154 unsigned horizontal_edge_is_boundary_edge = 0;
155 unsigned vertical_edge_is_boundary_edge = 0;
158 horizontal_edge_is_boundary_edge = 1;
161 (*p_edge_file) << edge++ <<
"\t" << node0 <<
"\t" << node1 <<
"\t" << horizontal_edge_is_boundary_edge << std::endl;
162 (*p_edge_file) << edge++ <<
"\t" << node1 <<
"\t" << node2 <<
"\t" << 0 << std::endl;
163 (*p_edge_file) << edge++ <<
"\t" << node2 <<
"\t" << node0 <<
"\t" << vertical_edge_is_boundary_edge << std::endl;
165 node0 = i*num_nodes_along_width + j + 1;
171 node1 = (i+1)*num_nodes_along_width + j+1;
172 node2 = (i+1)*num_nodes_along_width + j;
174 (*p_elem_file) << elem++ <<
"\t" << node0 <<
"\t" << node1 <<
"\t" << node2 << std::endl;
178 for (
unsigned i=0; i<num_elem_along_length; i++)
180 unsigned node0, node1;
184 node0 = (i+1)*num_nodes_along_width - 1;
185 node1 = (i+2)*num_nodes_along_width - 1;
189 node0 = (i+1)*num_nodes_along_width;
190 node1 = (i)*num_nodes_along_width;
192 (*p_edge_file) << edge++ <<
"\t" << node0 <<
"\t" << node1 <<
"\t" << 1 << std::endl;
195 for (
unsigned j=0; j<num_elem_along_width; j++)
197 unsigned node0 = num_nodes_along_width*(num_nodes_along_length-1) + j;
198 unsigned node1 = num_nodes_along_width*(num_nodes_along_length-1) + j+1;
199 (*p_edge_file) << edge++ <<
"\t" << node1 <<
"\t" << node0 <<
"\t" << 1 << std::endl;
202 p_elem_file->close();
203 p_edge_file->close();
210 mpMesh->ConstructFromMeshReader(mesh_reader);
220 mpMesh->SetMeshHasChangedSinceLoading();