26 #ifndef OOMPH_SIMPLE_CUBIC_TET_MESH_TEMPLATE_CC
27 #define OOMPH_SIMPLE_CUBIC_TET_MESH_TEMPLATE_CC
33 #include "../generic/map_matrix.h"
43 template<
class ELEMENT>
48 MeshChecker::assert_geometric_element<TElementGeometricBase, ELEMENT>(3);
51 unsigned nelem = Tmp_mesh_pt->nelement();
52 Element_pt.resize(nelem);
55 unsigned nnode_scaffold = Tmp_mesh_pt->nnode();
56 Node_pt.resize(nnode_scaffold);
59 unsigned nbound = Tmp_mesh_pt->nboundary();
60 set_nboundary(nbound);
63 for (
unsigned e = 0;
e < nelem;
e++)
65 Element_pt[
e] =
new ELEMENT;
69 unsigned nnod_el = Tmp_mesh_pt->finite_element_pt(0)->nnode();
71 for (
unsigned e = 0;
e < nelem;
e++)
74 for (
unsigned j = 0; j < nnod_el; j++)
78 finite_element_pt(
e)->construct_node(j, time_stepper_pt);
86 std::map<Node*, unsigned> global_number;
87 unsigned global_count = 0;
89 for (
unsigned e = 0;
e < nelem;
e++)
92 for (
unsigned j = 0; j < nnod_el; j++)
95 Node* scaffold_node_pt = Tmp_mesh_pt->finite_element_pt(
e)->node_pt(j);
99 unsigned j_global = global_number[scaffold_node_pt];
108 global_number[scaffold_node_pt] = global_count;
114 Node_pt[global_count - 1] = finite_element_pt(
e)->node_pt(j);
117 Node_pt[global_count - 1]->
x(0) = scaffold_node_pt->
x(0);
118 Node_pt[global_count - 1]->x(1) = scaffold_node_pt->
x(1);
119 Node_pt[global_count - 1]->x(2) = scaffold_node_pt->
x(2);
123 std::set<unsigned>* boundaries_pt;
128 if (boundaries_pt != 0)
130 this->convert_to_boundary_node(Node_pt[global_count - 1]);
131 for (std::set<unsigned>::iterator it = boundaries_pt->begin();
132 it != boundaries_pt->end();
135 add_boundary_node(*it, Node_pt[global_count - 1]);
143 delete finite_element_pt(
e)->node_pt(j);
148 finite_element_pt(
e)->node_pt(j) = Node_pt[j_global - 1];
165 unsigned nnode_1d = finite_element_pt(0)->nnode_1d();
168 if ((nnode_1d != 2) && (nnode_1d != 3))
170 std::ostringstream error_message;
171 error_message <<
"Mesh generation currently only works\n";
172 error_message <<
"for nnode_1d = 2 or 3. You're trying to use it\n";
173 error_message <<
"for nnode_1d=" << nnode_1d << std::endl;
176 error_message.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
180 unsigned dim = finite_element_pt(0)->dim();
186 unsigned nnode = finite_element_pt(0)->nnode();
189 for (
unsigned e = 0;
e < nelem;
e++)
192 for (
unsigned j = 4; j < nnode; j++)
196 finite_element_pt(
e)->construct_node(j, time_stepper_pt);
199 finite_element_pt(
e)->local_coordinate_of_node(j,
s);
203 for (
unsigned i = 0;
i < dim;
i++)
206 Tmp_mesh_pt->finite_element_pt(
e)->interpolated_x(
s,
i);
217 Node* edge_node1_pt = 0;
218 Node* edge_node2_pt = 0;
221 for (
unsigned e = 0;
e < nelem;
e++)
224 for (
unsigned j = 4; j < nnode; j++)
227 Node* node_pt = finite_element_pt(
e)->node_pt(j);
241 edge_node1_pt = finite_element_pt(
e)->node_pt(0);
242 edge_node2_pt = finite_element_pt(
e)->node_pt(1);
243 if (central_edge_node_pt(edge_node1_pt, edge_node2_pt) == 0)
246 central_edge_node_pt(edge_node1_pt, edge_node2_pt) = node_pt;
247 central_edge_node_pt(edge_node2_pt, edge_node1_pt) = node_pt;
255 edge_node1_pt = finite_element_pt(
e)->node_pt(0);
256 edge_node2_pt = finite_element_pt(
e)->node_pt(2);
257 if (central_edge_node_pt(edge_node1_pt, edge_node2_pt) == 0)
260 central_edge_node_pt(edge_node1_pt, edge_node2_pt) = node_pt;
261 central_edge_node_pt(edge_node2_pt, edge_node1_pt) = node_pt;
269 edge_node1_pt = finite_element_pt(
e)->node_pt(0);
270 edge_node2_pt = finite_element_pt(
e)->node_pt(3);
271 if (central_edge_node_pt(edge_node1_pt, edge_node2_pt) == 0)
274 central_edge_node_pt(edge_node1_pt, edge_node2_pt) = node_pt;
275 central_edge_node_pt(edge_node2_pt, edge_node1_pt) = node_pt;
283 edge_node1_pt = finite_element_pt(
e)->node_pt(1);
284 edge_node2_pt = finite_element_pt(
e)->node_pt(2);
285 if (central_edge_node_pt(edge_node1_pt, edge_node2_pt) == 0)
288 central_edge_node_pt(edge_node1_pt, edge_node2_pt) = node_pt;
289 central_edge_node_pt(edge_node2_pt, edge_node1_pt) = node_pt;
297 edge_node1_pt = finite_element_pt(
e)->node_pt(2);
298 edge_node2_pt = finite_element_pt(
e)->node_pt(3);
299 if (central_edge_node_pt(edge_node1_pt, edge_node2_pt) == 0)
302 central_edge_node_pt(edge_node1_pt, edge_node2_pt) = node_pt;
303 central_edge_node_pt(edge_node2_pt, edge_node1_pt) = node_pt;
311 edge_node1_pt = finite_element_pt(
e)->node_pt(1);
312 edge_node2_pt = finite_element_pt(
e)->node_pt(3);
313 if (central_edge_node_pt(edge_node1_pt, edge_node2_pt) == 0)
316 central_edge_node_pt(edge_node1_pt, edge_node2_pt) = node_pt;
317 central_edge_node_pt(edge_node2_pt, edge_node1_pt) = node_pt;
323 OOMPH_CURRENT_FUNCTION,
324 OOMPH_EXCEPTION_LOCATION);
330 Node_pt.push_back(node_pt);
335 delete finite_element_pt(
e)->node_pt(j);
338 finite_element_pt(
e)->node_pt(j) =
339 central_edge_node_pt(edge_node1_pt, edge_node2_pt);
358 for (
unsigned e = 0;
e < nelem;
e++)
360 orig_node_pt[
e].resize(nnode, 0);
363 for (
unsigned j = 4; j < nnode; j++)
366 orig_node_pt[
e][j] = finite_element_pt(
e)->node_pt(j);
372 for (
unsigned e = 0;
e < nelem;
e++)
375 for (
unsigned j = 4; j < nnode; j++)
378 for (
unsigned bo = 0; bo < nbound; bo++)
381 Node* loc_node_pt = finite_element_pt(
e)->node_pt(j);
384 Node* orig_loc_node_pt = orig_node_pt[
e][j];
387 bool bound_test = bound_node_done(orig_loc_node_pt, bo);
389 if (bound_test ==
false)
391 bound_node_done(orig_loc_node_pt, bo) =
true;
402 if (finite_element_pt(
e)->node_pt(0)->is_on_boundary(bo) &&
403 finite_element_pt(
e)->node_pt(1)->is_on_boundary(bo))
405 this->convert_to_boundary_node(loc_node_pt);
406 add_boundary_node(bo, loc_node_pt);
414 if (finite_element_pt(
e)->node_pt(0)->is_on_boundary(bo) &&
415 finite_element_pt(
e)->node_pt(2)->is_on_boundary(bo))
417 this->convert_to_boundary_node(loc_node_pt);
418 add_boundary_node(bo, loc_node_pt);
426 if (finite_element_pt(
e)->node_pt(0)->is_on_boundary(bo) &&
427 finite_element_pt(
e)->node_pt(3)->is_on_boundary(bo))
429 this->convert_to_boundary_node(loc_node_pt);
430 add_boundary_node(bo, loc_node_pt);
438 if (finite_element_pt(
e)->node_pt(1)->is_on_boundary(bo) &&
439 finite_element_pt(
e)->node_pt(2)->is_on_boundary(bo))
441 this->convert_to_boundary_node(loc_node_pt);
442 add_boundary_node(bo, loc_node_pt);
450 if (finite_element_pt(
e)->node_pt(2)->is_on_boundary(bo) &&
451 finite_element_pt(
e)->node_pt(3)->is_on_boundary(bo))
453 this->convert_to_boundary_node(loc_node_pt);
454 add_boundary_node(bo, loc_node_pt);
462 if (finite_element_pt(
e)->node_pt(1)->is_on_boundary(bo) &&
463 finite_element_pt(
e)->node_pt(3)->is_on_boundary(bo))
465 this->convert_to_boundary_node(loc_node_pt);
466 add_boundary_node(bo, loc_node_pt);
473 OOMPH_CURRENT_FUNCTION,
474 OOMPH_EXCEPTION_LOCATION);
MapMatrixMixed is a generalised, STL-map-based, sparse(ish) matrix class with mixed indices.
//////////////////////////////////////////////////////////////////// ////////////////////////////////...
Nodes are derived from Data, but, in addition, have a definite (Eulerian) position in a space of a gi...
double & x(const unsigned &i)
Return the i-th nodal coordinate.
virtual void get_boundaries_pt(std::set< unsigned > *&boundaries_pt)
Return a pointer to set of mesh boundaries that this node occupies; this will be overloaded by Bounda...
An OomphLibError object which should be thrown when an run-time error is encountered....
void build_from_scaffold(TimeStepper *time_stepper_pt)
Build mesh from scaffold mesh.
////////////////////////////////////////////////////////////////////// //////////////////////////////...
//////////////////////////////////////////////////////////////////// ////////////////////////////////...