48 mDomainDepth = 0.5*sqrt(3)*numNodesAlongDepth*depthScaleFactor;
57 assert(widthScaleFactor > 0.0);
58 assert(depthScaleFactor > 0.0);
61 std::stringstream pid;
71 unsigned num_nodes = num_nodes_along_width*num_nodes_along_depth;
72 unsigned num_elem_along_width = num_nodes_along_width-1;
73 unsigned num_elem_along_depth = num_nodes_along_depth-1;
74 unsigned num_elem = 2*num_elem_along_width*num_elem_along_depth;
75 unsigned num_edges = 3*num_elem_along_width*num_elem_along_depth + num_elem_along_width + num_elem_along_depth;
82 (*p_node_file) << std::scientific;
84 (*p_node_file) << num_nodes <<
"\t2\t0\t1" << std::endl;
87 for (
unsigned i=0; i<num_nodes_along_depth; i++)
89 for (
unsigned j=0; j<num_nodes_along_width; j++)
91 unsigned boundary = 0;
92 if ((i==0) || (i==num_nodes_along_depth-1))
97 const double adjustment = i % 2 != 0 ? 0.5 : 0.0;
98 double x = x0 + horizontal_spacing*((
double)j + adjustment);
99 double y = y0 + vertical_spacing*(
double)i;
102 if ((y<0.0) && (y>-1e-12))
110 (*p_node_file) << node++ <<
"\t" << x <<
"\t" << y <<
"\t" << boundary << std::endl;
113 p_node_file->close();
117 (*p_elem_file) << std::scientific;
120 (*p_node_file) << std::scientific;
122 (*p_elem_file) << num_elem <<
"\t3\t0" << std::endl;
123 (*p_edge_file) << num_edges <<
"\t1" << std::endl;
127 for (
unsigned i=0; i<num_elem_along_depth; i++)
129 for (
unsigned j=0; j < num_elem_along_width; j++)
131 unsigned node0 = i*num_nodes_along_width + j;
132 unsigned node1 = i*num_nodes_along_width + j+1;
133 unsigned node2 = (i+1)*num_nodes_along_width + j;
140 (*p_elem_file) << elem++ <<
"\t" << node0 <<
"\t" << node1 <<
"\t" << node2 << std::endl;
142 unsigned horizontal_edge_is_boundary_edge = 0;
143 unsigned vertical_edge_is_boundary_edge = 0;
146 horizontal_edge_is_boundary_edge = 1;
149 (*p_edge_file) << edge++ <<
"\t" << node0 <<
"\t" << node1 <<
"\t" << horizontal_edge_is_boundary_edge << std::endl;
150 (*p_edge_file) << edge++ <<
"\t" << node1 <<
"\t" << node2 <<
"\t" << 0 << std::endl;
151 (*p_edge_file) << edge++ <<
"\t" << node2 <<
"\t" << node0 <<
"\t" << vertical_edge_is_boundary_edge << std::endl;
153 node0 = i*num_nodes_along_width + j + 1;
159 node1 = (i+1)*num_nodes_along_width + j+1;
160 node2 = (i+1)*num_nodes_along_width + j;
162 (*p_elem_file) << elem++ <<
"\t" << node0 <<
"\t" << node1 <<
"\t" << node2 << std::endl;
166 for (
unsigned i=0; i<num_elem_along_depth; i++)
168 unsigned node0, node1;
172 node0 = (i+1)*num_nodes_along_width - 1;
173 node1 = (i+2)*num_nodes_along_width - 1;
177 node0 = (i+1)*num_nodes_along_width;
178 node1 = (i)*num_nodes_along_width;
180 (*p_edge_file) << edge++ <<
"\t" << node0 <<
"\t" << node1 <<
"\t" << 1 << std::endl;
183 for (
unsigned j=0; j<num_elem_along_width; j++)
185 unsigned node0 = num_nodes_along_width*(num_nodes_along_depth-1) + j;
186 unsigned node1 = num_nodes_along_width*(num_nodes_along_depth-1) + j+1;
187 (*p_edge_file) << edge++ <<
"\t" << node1 <<
"\t" << node0 <<
"\t" << 1 << std::endl;
190 p_elem_file->close();
191 p_edge_file->close();
198 mpMesh->ConstructFromMeshReader(mesh_reader);
208 mpMesh->SetMeshHasChangedSinceLoading();