56 assert(scaleFactor > 0.0);
59 std::stringstream pid;
67 double vertical_spacing = (sqrt(3.0)/2)*horizontal_spacing;
73 num_nodes_along_length += 2*ghosts;
75 unsigned num_nodes = num_nodes_along_width*num_nodes_along_length;
76 unsigned num_elem_along_width = num_nodes_along_width-1;
77 unsigned num_elem_along_length = num_nodes_along_length-1;
78 unsigned num_elem = 2*num_elem_along_width*num_elem_along_length;
79 unsigned num_edges = 3*num_elem_along_width*num_elem_along_length + num_elem_along_width + num_elem_along_length;
82 double y0 = -vertical_spacing*ghosts;
84 mBottom = -vertical_spacing*ghosts;
85 mTop =
mBottom + vertical_spacing*(num_nodes_along_length-1);
89 (*p_node_file) << std::scientific;
91 (*p_node_file) << num_nodes <<
"\t2\t0\t1" << std::endl;
94 for (
unsigned i=0; i<num_nodes_along_length; i++)
96 for (
unsigned j=0; j<num_nodes_along_width; j++)
102 unsigned boundary = 0;
103 if ((i==0) || (i==num_nodes_along_length-1))
108 const double adjustment = i % 2 != 0 ? 0.5 : 0.0;
109 double x = x0 + horizontal_spacing*((
double)j + adjustment);
110 double y = y0 + vertical_spacing*(
double)i;
113 if ((y<0.0) && (y>-1e-12))
121 (*p_node_file) << node++ <<
"\t" << x <<
"\t" << y <<
"\t" << boundary << std::endl;
124 p_node_file->close();
128 (*p_elem_file) << std::scientific;
131 (*p_node_file) << std::scientific;
133 (*p_elem_file) << num_elem <<
"\t3\t0" << std::endl;
134 (*p_edge_file) << num_edges <<
"\t1" << std::endl;
138 for (
unsigned i=0; i<num_elem_along_length; i++)
140 for (
unsigned j=0; j < num_elem_along_width; j++)
142 unsigned node0 = i*num_nodes_along_width + j;
143 unsigned node1 = i*num_nodes_along_width + j+1;
144 unsigned node2 = (i+1)*num_nodes_along_width + j;
151 (*p_elem_file) << elem++ <<
"\t" << node0 <<
"\t" << node1 <<
"\t" << node2 << std::endl;
153 unsigned horizontal_edge_is_boundary_edge = 0;
154 unsigned vertical_edge_is_boundary_edge = 0;
157 horizontal_edge_is_boundary_edge = 1;
160 (*p_edge_file) << edge++ <<
"\t" << node0 <<
"\t" << node1 <<
"\t" << horizontal_edge_is_boundary_edge << std::endl;
161 (*p_edge_file) << edge++ <<
"\t" << node1 <<
"\t" << node2 <<
"\t" << 0 << std::endl;
162 (*p_edge_file) << edge++ <<
"\t" << node2 <<
"\t" << node0 <<
"\t" << vertical_edge_is_boundary_edge << std::endl;
164 node0 = i*num_nodes_along_width + j + 1;
170 node1 = (i+1)*num_nodes_along_width + j+1;
171 node2 = (i+1)*num_nodes_along_width + j;
173 (*p_elem_file) << elem++ <<
"\t" << node0 <<
"\t" << node1 <<
"\t" << node2 << std::endl;
177 for (
unsigned i=0; i<num_elem_along_length; i++)
179 unsigned node0, node1;
183 node0 = (i+1)*num_nodes_along_width - 1;
184 node1 = (i+2)*num_nodes_along_width - 1;
188 node0 = (i+1)*num_nodes_along_width;
189 node1 = (i)*num_nodes_along_width;
191 (*p_edge_file) << edge++ <<
"\t" << node0 <<
"\t" << node1 <<
"\t" << 1 << std::endl;
194 for (
unsigned j=0; j<num_elem_along_width; j++)
196 unsigned node0 = num_nodes_along_width*(num_nodes_along_length-1) + j;
197 unsigned node1 = num_nodes_along_width*(num_nodes_along_length-1) + j+1;
198 (*p_edge_file) << edge++ <<
"\t" << node1 <<
"\t" << node0 <<
"\t" << 1 << std::endl;
201 p_elem_file->close();
202 p_edge_file->close();
209 mpMesh->ConstructFromMeshReader(mesh_reader);
219 mpMesh->SetMeshHasChangedSinceLoading();