26 #ifndef OOMPH_SIMPLE_RECTANGULAR_TRIMESH_TEMPLATE_CC
27 #define OOMPH_SIMPLE_RECTANGULAR_TRIMESH_TEMPLATE_CC
32 #include "../generic/Telements.h"
53 template<
class ELEMENT>
59 TimeStepper* time_stepper_pt)
60 : Nx(n_x), Ny(n_y), Lx(l_x), Ly(l_y)
62 using namespace MathematicalConstants;
65 MeshChecker::assert_geometric_element<TElementGeometricBase, ELEMENT>(2);
68 this->set_nboundary(4);
71 unsigned n_element = (
Nx) * (
Ny)*2;
72 Element_pt.resize(n_element, 0);
75 Element_pt[0] =
new ELEMENT;
78 if ((finite_element_pt(0)->nnode_1d() != 2) &&
79 (finite_element_pt(0)->nnode_1d() != 3) &&
80 (finite_element_pt(0)->nnode_1d() != 4))
83 "Currently this mesh only works for 3, 6 & 10-noded triangles",
84 OOMPH_CURRENT_FUNCTION,
85 OOMPH_EXCEPTION_LOCATION);
90 unsigned additional_nnode = 0;
93 if (finite_element_pt(0)->nnode_1d() == 2)
95 n_node = (
Nx + 1) * (
Ny + 1);
98 if (finite_element_pt(0)->nnode_1d() == 3)
100 additional_nnode = 3;
102 n_node = (2 *
Nx + 1) * (2 *
Ny + 1);
105 if (finite_element_pt(0)->nnode_1d() == 4)
107 additional_nnode = 7;
109 n_node = (3 *
Nx + 1) * (3 *
Ny + 1);
112 Node_pt.resize(n_node);
116 unsigned long node_count = 0;
117 unsigned long element_count = 0;
118 double xinit = 0.0, yinit = 0.0;
120 double xstep =
Lx / (
Nx);
121 double ystep =
Ly / (
Ny);
131 Node_pt[node_count] =
132 finite_element_pt(0)->construct_node(1, time_stepper_pt);
135 finite_element_pt(0)->node_pt(1) = Node_pt[node_count];
149 for (
unsigned j = 0; j <
Ny + 1; ++j)
151 for (
unsigned i = 0; i <
Nx + 1; ++i)
155 if (j <
Ny && i <
Nx)
159 if (element_count != 0)
161 Element_pt[element_count] =
new ELEMENT;
164 Element_pt[element_count + 1] =
new ELEMENT;
172 Node_pt[node_count +
Nx + 1] =
173 finite_element_pt(element_count)
174 ->construct_node(0, time_stepper_pt);
180 Node_pt[node_count + 1] = finite_element_pt(element_count)
181 ->construct_node(2, time_stepper_pt);
185 Node_pt[node_count +
Nx + 2] = finite_element_pt(element_count + 1)
186 ->construct_node(1, time_stepper_pt);
193 finite_element_pt(element_count)->node_pt(0) =
194 Node_pt[node_count +
Nx + 1];
195 finite_element_pt(element_count)->node_pt(1) = Node_pt[node_count];
196 finite_element_pt(element_count)->node_pt(2) =
197 Node_pt[node_count + 1];
198 finite_element_pt(element_count + 1)->node_pt(0) =
199 Node_pt[node_count + 1];
200 finite_element_pt(element_count + 1)->node_pt(1) =
201 Node_pt[node_count +
Nx + 2];
202 finite_element_pt(element_count + 1)->node_pt(2) =
203 Node_pt[node_count +
Nx + 1];
210 Node_pt[node_count]->x(0) = xinit + i * xstep;
211 Node_pt[node_count]->x(1) = yinit + j * ystep;
216 this->convert_to_boundary_node(Node_pt[node_count]);
217 add_boundary_node(0, Node_pt[node_count]);
221 this->convert_to_boundary_node(Node_pt[node_count]);
222 add_boundary_node(2, Node_pt[node_count]);
226 this->convert_to_boundary_node(Node_pt[node_count]);
227 add_boundary_node(3, Node_pt[node_count]);
231 this->convert_to_boundary_node(Node_pt[node_count]);
232 add_boundary_node(1, Node_pt[node_count]);
241 if (additional_nnode == 3)
247 for (
unsigned j = 0; j <
Ny + 1; ++j)
251 for (
unsigned i = 0; i <
Nx; ++i)
264 Node_pt[node_count] = finite_element_pt(element_count)
265 ->construct_node(4, time_stepper_pt);
270 Node_pt[node_count +
Nx] = finite_element_pt(element_count + 1)
271 ->construct_node(4, time_stepper_pt);
275 finite_element_pt(element_count)->node_pt(4) = Node_pt[node_count];
277 finite_element_pt(element_count + 1)->node_pt(4) =
278 Node_pt[node_count +
Nx];
286 Node_pt[node_count]->x(0) = xinit + double(i + 0.5) * xstep;
287 Node_pt[node_count]->x(1) = yinit + j * ystep;
293 this->convert_to_boundary_node(Node_pt[node_count]);
294 add_boundary_node(0, Node_pt[node_count]);
298 this->convert_to_boundary_node(Node_pt[node_count]);
299 add_boundary_node(2, Node_pt[node_count]);
314 for (
unsigned j = 0; j <
Ny; ++j)
316 for (
unsigned i = 0; i <
Nx + 1; ++i)
318 if (j <
Ny && i <
Nx)
324 Node_pt[node_count] = finite_element_pt(element_count)
325 ->construct_node(3, time_stepper_pt);
330 Node_pt[node_count + 1] = finite_element_pt(element_count + 1)
331 ->construct_node(3, time_stepper_pt);
334 finite_element_pt(element_count)->node_pt(3) = Node_pt[node_count];
335 finite_element_pt(element_count + 1)->node_pt(3) =
336 Node_pt[node_count + 1];
343 Node_pt[node_count]->x(0) = xinit + i * xstep;
344 Node_pt[node_count]->x(1) = yinit + double(j + 0.5) * ystep;
349 this->convert_to_boundary_node(Node_pt[node_count]);
350 add_boundary_node(3, Node_pt[node_count]);
354 this->convert_to_boundary_node(Node_pt[node_count]);
355 add_boundary_node(1, Node_pt[node_count]);
369 for (
unsigned j = 0; j <
Ny; ++j)
371 for (
unsigned i = 0; i <
Nx; ++i)
374 Node_pt[node_count] = finite_element_pt(element_count)
375 ->construct_node(5, time_stepper_pt);
378 finite_element_pt(element_count)->node_pt(5) = Node_pt[node_count];
379 finite_element_pt(element_count + 1)->node_pt(5) =
387 Node_pt[node_count]->x(0) = xinit + double(i + 0.5) * xstep;
388 Node_pt[node_count]->x(1) = yinit + double(j + 0.5) * ystep;
401 if (additional_nnode == 7)
407 for (
unsigned j = 0; j <
Ny + 1; ++j)
411 for (
unsigned i = 0; i <
Nx; ++i)
425 Node_pt[node_count] = finite_element_pt(element_count)
426 ->construct_node(5, time_stepper_pt);
431 Node_pt[node_count +
Nx] = finite_element_pt(element_count + 1)
432 ->construct_node(6, time_stepper_pt);
436 finite_element_pt(element_count)->node_pt(5) = Node_pt[node_count];
438 finite_element_pt(element_count + 1)->node_pt(6) =
439 Node_pt[node_count +
Nx];
447 Node_pt[node_count]->x(0) = xinit + double(i + 1.0 / 3.0) * xstep;
448 Node_pt[node_count]->x(1) = yinit + j * ystep;
453 this->convert_to_boundary_node(Node_pt[node_count]);
454 add_boundary_node(0, Node_pt[node_count]);
458 this->convert_to_boundary_node(Node_pt[node_count]);
459 add_boundary_node(2, Node_pt[node_count]);
472 for (
unsigned j = 0; j <
Ny + 1; ++j)
475 for (
unsigned i = 0; i <
Nx; ++i)
483 Node_pt[node_count] = finite_element_pt(element_count)
484 ->construct_node(6, time_stepper_pt);
489 Node_pt[node_count +
Nx] = finite_element_pt(element_count + 1)
490 ->construct_node(5, time_stepper_pt);
494 finite_element_pt(element_count)->node_pt(6) = Node_pt[node_count];
496 finite_element_pt(element_count + 1)->node_pt(5) =
497 Node_pt[node_count +
Nx];
505 Node_pt[node_count]->x(0) = xinit + double(i + 2.0 / 3.0) * xstep;
506 Node_pt[node_count]->x(1) = yinit + j * ystep;
511 this->convert_to_boundary_node(Node_pt[node_count]);
512 add_boundary_node(0, Node_pt[node_count]);
516 this->convert_to_boundary_node(Node_pt[node_count]);
517 add_boundary_node(2, Node_pt[node_count]);
532 for (
unsigned j = 0; j <
Ny; ++j)
534 for (
unsigned i = 0; i <
Nx + 1; ++i)
536 if (j <
Ny && i <
Nx)
542 Node_pt[node_count] = finite_element_pt(element_count)
543 ->construct_node(4, time_stepper_pt);
548 Node_pt[node_count + 1] = finite_element_pt(element_count + 1)
549 ->construct_node(3, time_stepper_pt);
552 finite_element_pt(element_count)->node_pt(4) = Node_pt[node_count];
553 finite_element_pt(element_count + 1)->node_pt(3) =
554 Node_pt[node_count + 1];
561 Node_pt[node_count]->x(0) = xinit + i * xstep;
562 Node_pt[node_count]->x(1) = yinit + double(j + 1.0 / 3.0) * ystep;
567 this->convert_to_boundary_node(Node_pt[node_count]);
568 add_boundary_node(3, Node_pt[node_count]);
572 this->convert_to_boundary_node(Node_pt[node_count]);
573 add_boundary_node(1, Node_pt[node_count]);
588 for (
unsigned j = 0; j <
Ny; ++j)
590 for (
unsigned i = 0; i <
Nx + 1; ++i)
592 if (j <
Ny && i <
Nx)
598 Node_pt[node_count] = finite_element_pt(element_count)
599 ->construct_node(3, time_stepper_pt);
604 Node_pt[node_count + 1] = finite_element_pt(element_count + 1)
605 ->construct_node(4, time_stepper_pt);
608 finite_element_pt(element_count)->node_pt(3) = Node_pt[node_count];
609 finite_element_pt(element_count + 1)->node_pt(4) =
610 Node_pt[node_count + 1];
617 Node_pt[node_count]->x(0) = xinit + i * xstep;
618 Node_pt[node_count]->x(1) = yinit + double(j + 2.0 / 3.0) * ystep;
623 this->convert_to_boundary_node(Node_pt[node_count]);
624 add_boundary_node(3, Node_pt[node_count]);
628 this->convert_to_boundary_node(Node_pt[node_count]);
629 add_boundary_node(1, Node_pt[node_count]);
641 for (
unsigned j = 0; j <
Ny; ++j)
643 for (
unsigned i = 0; i <
Nx; ++i)
646 Node_pt[node_count] = finite_element_pt(element_count)
647 ->construct_node(9, time_stepper_pt);
650 finite_element_pt(element_count)->node_pt(9) = Node_pt[node_count];
656 Node_pt[node_count]->x(0) = xinit + double(i + 1.0 / 3.0) * xstep;
657 Node_pt[node_count]->x(1) = yinit + double(j + 1.0 / 3.0) * ystep;
672 for (
unsigned j = 0; j <
Ny; ++j)
674 for (
unsigned i = 0; i <
Nx; ++i)
677 Node_pt[node_count] = finite_element_pt(element_count)
678 ->construct_node(7, time_stepper_pt);
681 finite_element_pt(element_count)->node_pt(7) = Node_pt[node_count];
682 finite_element_pt(element_count + 1)->node_pt(8) =
689 Node_pt[node_count]->x(0) = xinit + double(i + 2.0 / 3.0) * xstep;
690 Node_pt[node_count]->x(1) = yinit + double(j + 1.0 / 3.0) * ystep;
705 for (
unsigned j = 0; j <
Ny; ++j)
707 for (
unsigned i = 0; i <
Nx; ++i)
710 Node_pt[node_count] = finite_element_pt(element_count)
711 ->construct_node(8, time_stepper_pt);
714 finite_element_pt(element_count)->node_pt(8) = Node_pt[node_count];
715 finite_element_pt(element_count + 1)->node_pt(7) =
722 Node_pt[node_count]->x(0) = xinit + double(i + 1.0 / 3.0) * xstep;
723 Node_pt[node_count]->x(1) = yinit + double(j + 2.0 / 3.0) * ystep;
737 for (
unsigned j = 0; j <
Ny; ++j)
739 for (
unsigned i = 0; i <
Nx; ++i)
742 Node_pt[node_count] = finite_element_pt(element_count + 1)
743 ->construct_node(9, time_stepper_pt);
746 finite_element_pt(element_count + 1)->node_pt(9) =
753 Node_pt[node_count]->x(0) = xinit + double(i + 2.0 / 3.0) * xstep;
754 Node_pt[node_count]->x(1) = yinit + double(j + 2.0 / 3.0) * ystep;
SimpleRectangularTriMesh(const unsigned &n_x, const unsigned &n_y, const double &l_x, const double &l_y, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Constructor n_x : number of elements in the x direction; n_y : number of elements in the y direction;...
double Lx
Length of mesh in x-direction.
unsigned Ny
Number of elements in y directions.
unsigned Nx
Number of elements in x direction.
double Ly
Length of mesh in y-direction.
////////////////////////////////////////////////////////////////////// //////////////////////////////...