49 mDomainDepth = 0.5*sqrt(3)*numNodesAlongDepth*depthScaleFactor;
58 assert(widthScaleFactor > 0.0);
59 assert(depthScaleFactor > 0.0);
62 std::stringstream pid;
72 unsigned num_nodes = num_nodes_along_width*num_nodes_along_depth;
73 unsigned num_elem_along_width = num_nodes_along_width-1;
74 unsigned num_elem_along_depth = num_nodes_along_depth-1;
75 unsigned num_elem = 2*num_elem_along_width*num_elem_along_depth;
76 unsigned num_edges = 3*num_elem_along_width*num_elem_along_depth + num_elem_along_width + num_elem_along_depth;
83 (*p_node_file) << std::scientific;
85 (*p_node_file) << num_nodes <<
"\t2\t0\t1" << std::endl;
88 for (
unsigned i=0; i<num_nodes_along_depth; i++)
90 for (
unsigned j=0; j<num_nodes_along_width; j++)
92 unsigned boundary = 0;
93 if ((i==0) || (i==num_nodes_along_depth-1))
98 const double adjustment = i % 2 != 0 ? 0.5 : 0.0;
99 double x = x0 + horizontal_spacing*((
double)j + adjustment);
100 double y = y0 + vertical_spacing*(
double)i;
103 if ((y<0.0) && (y>-1e-12))
111 (*p_node_file) << node++ <<
"\t" << x <<
"\t" << y <<
"\t" << boundary << std::endl;
114 p_node_file->close();
118 (*p_elem_file) << std::scientific;
121 (*p_node_file) << std::scientific;
123 (*p_elem_file) << num_elem <<
"\t3\t0" << std::endl;
124 (*p_edge_file) << num_edges <<
"\t1" << std::endl;
128 for (
unsigned i=0; i<num_elem_along_depth; i++)
130 for (
unsigned j=0; j < num_elem_along_width; j++)
132 unsigned node0 = i*num_nodes_along_width + j;
133 unsigned node1 = i*num_nodes_along_width + j+1;
134 unsigned node2 = (i+1)*num_nodes_along_width + j;
141 (*p_elem_file) << elem++ <<
"\t" << node0 <<
"\t" << node1 <<
"\t" << node2 << std::endl;
143 unsigned horizontal_edge_is_boundary_edge = 0;
144 unsigned vertical_edge_is_boundary_edge = 0;
147 horizontal_edge_is_boundary_edge = 1;
150 (*p_edge_file) << edge++ <<
"\t" << node0 <<
"\t" << node1 <<
"\t" << horizontal_edge_is_boundary_edge << std::endl;
151 (*p_edge_file) << edge++ <<
"\t" << node1 <<
"\t" << node2 <<
"\t" << 0 << std::endl;
152 (*p_edge_file) << edge++ <<
"\t" << node2 <<
"\t" << node0 <<
"\t" << vertical_edge_is_boundary_edge << std::endl;
154 node0 = i*num_nodes_along_width + j + 1;
160 node1 = (i+1)*num_nodes_along_width + j+1;
161 node2 = (i+1)*num_nodes_along_width + j;
163 (*p_elem_file) << elem++ <<
"\t" << node0 <<
"\t" << node1 <<
"\t" << node2 << std::endl;
167 for (
unsigned i=0; i<num_elem_along_depth; i++)
169 unsigned node0, node1;
173 node0 = (i+1)*num_nodes_along_width - 1;
174 node1 = (i+2)*num_nodes_along_width - 1;
178 node0 = (i+1)*num_nodes_along_width;
179 node1 = (i)*num_nodes_along_width;
181 (*p_edge_file) << edge++ <<
"\t" << node0 <<
"\t" << node1 <<
"\t" << 1 << std::endl;
184 for (
unsigned j=0; j<num_elem_along_width; j++)
186 unsigned node0 = num_nodes_along_width*(num_nodes_along_depth-1) + j;
187 unsigned node1 = num_nodes_along_width*(num_nodes_along_depth-1) + j+1;
188 (*p_edge_file) << edge++ <<
"\t" << node1 <<
"\t" << node0 <<
"\t" << 1 << std::endl;
191 p_elem_file->close();
192 p_edge_file->close();
199 mpMesh->ConstructFromMeshReader(mesh_reader);
209 mpMesh->SetMeshHasChangedSinceLoading();