26 #ifndef OOMPH_SIMPLE_RECTANGULAR_QUADMESH_TEMPLATE_CC
27 #define OOMPH_SIMPLE_RECTANGULAR_QUADMESH_TEMPLATE_CC
29 #include "../generic/Qelements.h"
50 template<
class ELEMENT>
56 TimeStepper* time_stepper_pt)
59 MeshChecker::assert_geometric_element<QElementGeometricBase, ELEMENT>(2);
69 Element_pt.resize(Nx * Ny);
72 Element_pt[0] =
new ELEMENT;
75 unsigned n_p =
dynamic_cast<ELEMENT*
>(finite_element_pt(0))->nnode_1d();
78 Node_pt.resize((1 + (n_p - 1) * Nx) * (1 + (n_p - 1) * Ny));
83 unsigned long node_count = 0;
84 double xinit = 0.0, yinit = 0.0;
91 double el_length_x = Lx / double(Nx);
92 double el_length_y = Ly / double(Ny);
95 Vector<double> s_fraction;
110 Node_pt[node_count] =
111 finite_element_pt(0)->construct_boundary_node(0, time_stepper_pt);
114 finite_element_pt(0)->node_pt(0) = Node_pt[node_count];
117 Node_pt[node_count]->x(0) = xinit;
118 Node_pt[node_count]->x(1) = yinit;
121 add_boundary_node(0, Node_pt[node_count]);
122 add_boundary_node(3, Node_pt[node_count]);
128 for (
unsigned l2 = 1; l2 < n_p; l2++)
131 Node_pt[node_count] =
132 finite_element_pt(0)->construct_boundary_node(l2, time_stepper_pt);
135 finite_element_pt(0)->node_pt(l2) = Node_pt[node_count];
138 finite_element_pt(0)->local_fraction_of_node(l2, s_fraction);
141 Node_pt[node_count]->x(0) = xinit + el_length_x * s_fraction[0];
142 Node_pt[node_count]->x(1) = yinit;
145 add_boundary_node(0, Node_pt[node_count]);
152 for (
unsigned l1 = 1; l1 < n_p; l1++)
155 Node_pt[node_count] = finite_element_pt(0)->construct_boundary_node(
156 l1 * n_p, time_stepper_pt);
159 finite_element_pt(0)->node_pt(l1 * n_p) = Node_pt[node_count];
162 finite_element_pt(0)->local_fraction_of_node(l1 * n_p, s_fraction);
165 Node_pt[node_count]->x(0) = xinit;
166 Node_pt[node_count]->x(1) = yinit + el_length_y * s_fraction[1];
169 add_boundary_node(3, Node_pt[node_count]);
175 for (
unsigned l2 = 1; l2 < n_p; l2++)
178 Node_pt[node_count] =
179 finite_element_pt(0)->construct_node(l1 * n_p + l2, time_stepper_pt);
182 finite_element_pt(0)->node_pt(l1 * n_p + l2) = Node_pt[node_count];
185 finite_element_pt(0)->local_fraction_of_node(l1 * n_p + l2, s_fraction);
188 Node_pt[node_count]->x(0) = xinit + el_length_x * s_fraction[0];
189 Node_pt[node_count]->x(1) = yinit + el_length_y * s_fraction[1];
200 for (
unsigned j = 1; j < (Nx - 1); j++)
203 Element_pt[j] =
new ELEMENT;
208 finite_element_pt(j)->node_pt(0) =
209 finite_element_pt(j - 1)->node_pt((n_p - 1));
212 for (
unsigned l2 = 1; l2 < n_p; l2++)
215 Node_pt[node_count] =
216 finite_element_pt(j)->construct_boundary_node(l2, time_stepper_pt);
219 finite_element_pt(j)->node_pt(l2) = Node_pt[node_count];
222 finite_element_pt(j)->local_fraction_of_node(l2, s_fraction);
225 Node_pt[node_count]->x(0) = xinit + el_length_x * (j + s_fraction[0]);
226 Node_pt[node_count]->x(1) = yinit;
229 add_boundary_node(0, Node_pt[node_count]);
236 for (
unsigned l1 = 1; l1 < n_p; l1++)
239 finite_element_pt(j)->node_pt(l1 * n_p) =
240 finite_element_pt(j - 1)->node_pt(l1 * n_p + (n_p - 1));
243 for (
unsigned l2 = 1; l2 < n_p; l2++)
246 Node_pt[node_count] = finite_element_pt(j)->construct_node(
247 l1 * n_p + l2, time_stepper_pt);
250 finite_element_pt(j)->node_pt(l1 * n_p + l2) = Node_pt[node_count];
253 finite_element_pt(j)->local_fraction_of_node(l1 * n_p + l2,
257 Node_pt[node_count]->x(0) = xinit + el_length_x * (j + s_fraction[0]);
258 Node_pt[node_count]->x(1) = yinit + el_length_y * s_fraction[1];
271 Element_pt[Nx - 1] =
new ELEMENT;
273 finite_element_pt(Nx - 1)->node_pt(0) =
274 finite_element_pt(Nx - 2)->node_pt(n_p - 1);
277 for (
unsigned l2 = 1; l2 < (n_p - 1); l2++)
280 Node_pt[node_count] =
281 finite_element_pt(Nx - 1)->construct_boundary_node(l2, time_stepper_pt);
284 finite_element_pt(Nx - 1)->node_pt(l2) = Node_pt[node_count];
287 finite_element_pt(Nx - 1)->local_fraction_of_node(l2, s_fraction);
290 Node_pt[node_count]->x(0) =
291 xinit + el_length_x * (Nx - 1 + s_fraction[0]);
292 Node_pt[node_count]->x(1) = yinit;
295 add_boundary_node(0, Node_pt[node_count]);
304 Node_pt[node_count] = finite_element_pt(Nx - 1)->construct_boundary_node(
305 n_p - 1, time_stepper_pt);
308 finite_element_pt(Nx - 1)->node_pt(n_p - 1) = Node_pt[node_count];
311 finite_element_pt(Nx - 1)->local_fraction_of_node(n_p - 1, s_fraction);
314 Node_pt[node_count]->x(0) = xinit + el_length_x * (Nx - 1 + s_fraction[0]);
315 Node_pt[node_count]->x(1) = yinit;
318 add_boundary_node(0, Node_pt[node_count]);
319 add_boundary_node(1, Node_pt[node_count]);
325 for (
unsigned l1 = 1; l1 < n_p; l1++)
328 finite_element_pt(Nx - 1)->node_pt(l1 * n_p) =
329 finite_element_pt(Nx - 2)->node_pt(l1 * n_p + (n_p - 1));
332 for (
unsigned l2 = 1; l2 < (n_p - 1); l2++)
335 Node_pt[node_count] = finite_element_pt(Nx - 1)->construct_node(
336 l1 * n_p + l2, time_stepper_pt);
339 finite_element_pt(Nx - 1)->node_pt(l1 * n_p + l2) = Node_pt[node_count];
342 finite_element_pt(Nx - 1)->local_fraction_of_node(l1 * n_p + l2,
346 Node_pt[node_count]->x(0) =
347 xinit + el_length_x * (Nx - 1 + s_fraction[0]);
348 Node_pt[node_count]->x(1) = yinit + el_length_y * s_fraction[1];
357 Node_pt[node_count] = finite_element_pt(Nx - 1)->construct_boundary_node(
358 l1 * n_p + (n_p - 1), time_stepper_pt);
361 finite_element_pt(Nx - 1)->node_pt(l1 * n_p + (n_p - 1)) =
365 finite_element_pt(Nx - 1)->local_fraction_of_node(l1 * n_p + (n_p - 1),
369 Node_pt[node_count]->x(0) =
370 xinit + el_length_x * (Nx - 1 + s_fraction[0]);
371 Node_pt[node_count]->x(1) = yinit + el_length_y * s_fraction[1];
374 add_boundary_node(1, Node_pt[node_count]);
385 for (
unsigned i = 1; i < (Ny - 1); i++)
390 Element_pt[Nx * i] =
new ELEMENT;
393 for (
unsigned l2 = 0; l2 < n_p; l2++)
395 finite_element_pt(Nx * i)->node_pt(l2) =
396 finite_element_pt(Nx * (i - 1))->node_pt((n_p - 1) * n_p + l2);
400 for (
unsigned l1 = 1; l1 < n_p; l1++)
405 Node_pt[node_count] =
406 finite_element_pt(Nx * i)->construct_boundary_node(l1 * n_p,
410 finite_element_pt(Nx * i)->node_pt(l1 * n_p) = Node_pt[node_count];
413 finite_element_pt(Nx * i)->local_fraction_of_node(l1 * n_p, s_fraction);
416 Node_pt[node_count]->x(0) = xinit;
417 Node_pt[node_count]->x(1) = yinit + el_length_y * (i + s_fraction[1]);
420 add_boundary_node(3, Node_pt[node_count]);
426 for (
unsigned l2 = 1; l2 < n_p; l2++)
429 Node_pt[node_count] = finite_element_pt(Nx * i)->construct_node(
430 l1 * n_p + l2, time_stepper_pt);
433 finite_element_pt(Nx * i)->node_pt(l1 * n_p + l2) =
437 finite_element_pt(Nx * i)->local_fraction_of_node(l1 * n_p + l2,
441 Node_pt[node_count]->x(0) = xinit + el_length_x * s_fraction[0];
442 Node_pt[node_count]->x(1) = yinit + el_length_y * (i + s_fraction[1]);
450 for (
unsigned j = 1; j < (Nx - 1); j++)
453 Element_pt[Nx * i + j] =
new ELEMENT;
456 for (
unsigned l2 = 0; l2 < n_p; l2++)
458 finite_element_pt(Nx * i + j)->node_pt(l2) =
459 finite_element_pt(Nx * (i - 1) + j)->node_pt((n_p - 1) * n_p + l2);
462 for (
unsigned l1 = 1; l1 < n_p; l1++)
465 finite_element_pt(Nx * i + j)->node_pt(l1 * n_p) =
466 finite_element_pt(Nx * i + (j - 1))->node_pt(l1 * n_p + (n_p - 1));
469 for (
unsigned l2 = 1; l2 < n_p; l2++)
472 Node_pt[node_count] =
473 finite_element_pt(Nx * i + j)
474 ->construct_node(l1 * n_p + l2, time_stepper_pt);
477 finite_element_pt(Nx * i + j)->node_pt(l1 * n_p + l2) =
481 finite_element_pt(Nx * i + j)
482 ->local_fraction_of_node(l1 * n_p + l2, s_fraction);
485 Node_pt[node_count]->x(0) =
486 xinit + el_length_x * (j + s_fraction[0]);
487 Node_pt[node_count]->x(1) =
488 yinit + el_length_y * (i + s_fraction[1]);
499 Element_pt[Nx * i + Nx - 1] =
new ELEMENT;
502 for (
unsigned l2 = 0; l2 < n_p; l2++)
504 finite_element_pt(Nx * i + Nx - 1)->node_pt(l2) =
505 finite_element_pt(Nx * (i - 1) + Nx - 1)
506 ->node_pt((n_p - 1) * n_p + l2);
509 for (
unsigned l1 = 1; l1 < n_p; l1++)
512 finite_element_pt(Nx * i + Nx - 1)->node_pt(l1 * n_p) =
513 finite_element_pt(Nx * i + Nx - 2)->node_pt(l1 * n_p + (n_p - 1));
516 for (
unsigned l2 = 1; l2 < (n_p - 1); l2++)
519 Node_pt[node_count] =
520 finite_element_pt(Nx * i + Nx - 1)
521 ->construct_node(l1 * n_p + l2, time_stepper_pt);
524 finite_element_pt(Nx * i + Nx - 1)->node_pt(l1 * n_p + l2) =
528 finite_element_pt(Nx * i + Nx - 1)
529 ->local_fraction_of_node(l1 * n_p + l2, s_fraction);
532 Node_pt[node_count]->x(0) =
533 xinit + el_length_x * (Nx - 1 + s_fraction[0]);
534 Node_pt[node_count]->x(1) = yinit + el_length_y * (i + s_fraction[1]);
543 Node_pt[node_count] =
544 finite_element_pt(Nx * i + Nx - 1)
545 ->construct_boundary_node(l1 * n_p + (n_p - 1), time_stepper_pt);
548 finite_element_pt(Nx * i + Nx - 1)->node_pt(l1 * n_p + (n_p - 1)) =
552 finite_element_pt(Nx * i + Nx - 1)
553 ->local_fraction_of_node(l1 * n_p + (n_p - 1), s_fraction);
556 Node_pt[node_count]->x(0) =
557 xinit + el_length_x * (Nx - 1 + s_fraction[0]);
558 Node_pt[node_count]->x(1) = yinit + el_length_y * (i + s_fraction[1]);
561 add_boundary_node(1, Node_pt[node_count]);
578 Element_pt[Nx * (Ny - 1)] =
new ELEMENT;
581 for (
unsigned l2 = 0; l2 < n_p; l2++)
583 finite_element_pt(Nx * (Ny - 1))->node_pt(l2) =
584 finite_element_pt(Nx * (Ny - 2))->node_pt((n_p - 1) * n_p + l2);
589 for (
unsigned l1 = 1; l1 < (n_p - 1); l1++)
592 Node_pt[node_count] =
593 finite_element_pt(Nx * (Ny - 1))
594 ->construct_boundary_node(n_p * l1, time_stepper_pt);
597 finite_element_pt(Nx * (Ny - 1))->node_pt(n_p * l1) = Node_pt[node_count];
600 finite_element_pt(Nx * (Ny - 1))
601 ->local_fraction_of_node(n_p * l1, s_fraction);
604 Node_pt[node_count]->x(0) = xinit;
605 Node_pt[node_count]->x(1) =
606 yinit + el_length_y * (Ny - 1 + s_fraction[1]);
609 add_boundary_node(3, Node_pt[node_count]);
615 for (
unsigned l2 = 1; l2 < n_p; l2++)
618 Node_pt[node_count] =
619 finite_element_pt(Nx * (Ny - 1))
620 ->construct_node(n_p * l1 + l2, time_stepper_pt);
623 finite_element_pt(Nx * (Ny - 1))->node_pt(n_p * l1 + l2) =
627 finite_element_pt(Nx * (Ny - 1))
628 ->local_fraction_of_node(n_p * l1 + l2, s_fraction);
631 Node_pt[node_count]->x(0) = xinit + el_length_x * s_fraction[0];
632 Node_pt[node_count]->x(1) =
633 yinit + el_length_y * (Ny - 1 + s_fraction[1]);
645 Node_pt[node_count] =
646 finite_element_pt(Nx * (Ny - 1))
647 ->construct_boundary_node(n_p * (n_p - 1), time_stepper_pt);
649 finite_element_pt(Nx * (Ny - 1))->node_pt(n_p * (n_p - 1)) =
653 finite_element_pt(Nx * (Ny - 1))
654 ->local_fraction_of_node(n_p * (n_p - 1), s_fraction);
657 Node_pt[node_count]->x(0) = xinit;
658 Node_pt[node_count]->x(1) = yinit + el_length_y * Ny;
661 add_boundary_node(2, Node_pt[node_count]);
662 add_boundary_node(3, Node_pt[node_count]);
668 for (
unsigned l2 = 1; l2 < n_p; l2++)
671 Node_pt[node_count] =
672 finite_element_pt(Nx * (Ny - 1))
673 ->construct_boundary_node(n_p * (n_p - 1) + l2, time_stepper_pt);
676 finite_element_pt(Nx * (Ny - 1))->node_pt(n_p * (n_p - 1) + l2) =
680 finite_element_pt(Nx * (Ny - 1))
681 ->local_fraction_of_node(n_p * (n_p - 1) + l2, s_fraction);
685 Node_pt[node_count]->x(0) = xinit + el_length_x * s_fraction[0];
686 Node_pt[node_count]->x(1) = yinit + el_length_y * Ny;
689 add_boundary_node(2, Node_pt[node_count]);
696 for (
unsigned j = 1; j < (Nx - 1); j++)
699 Element_pt[Nx * (Ny - 1) + j] =
new ELEMENT;
701 for (
unsigned l2 = 0; l2 < n_p; l2++)
703 finite_element_pt(Nx * (Ny - 1) + j)->node_pt(l2) =
704 finite_element_pt(Nx * (Ny - 2) + j)->node_pt((n_p - 1) * n_p + l2);
708 for (
unsigned l1 = 1; l1 < (n_p - 1); l1++)
711 finite_element_pt(Nx * (Ny - 1) + j)->node_pt(n_p * l1) =
712 finite_element_pt(Nx * (Ny - 1) + (j - 1))
713 ->node_pt(n_p * l1 + (n_p - 1));
716 for (
unsigned l2 = 1; l2 < n_p; l2++)
719 Node_pt[node_count] =
720 finite_element_pt(Nx * (Ny - 1) + j)
721 ->construct_node(n_p * l1 + l2, time_stepper_pt);
723 finite_element_pt(Nx * (Ny - 1) + j)->node_pt(n_p * l1 + l2) =
727 finite_element_pt(Nx * (Ny - 1) + j)
728 ->local_fraction_of_node(n_p * l1 + l2, s_fraction);
731 Node_pt[node_count]->x(0) = xinit + el_length_x * (j + s_fraction[0]);
732 Node_pt[node_count]->x(1) =
733 yinit + el_length_y * (Ny - 1 + s_fraction[1]);
742 finite_element_pt(Nx * (Ny - 1) + j)->node_pt(n_p * (n_p - 1)) =
743 finite_element_pt(Nx * (Ny - 1) + (j - 1))
744 ->node_pt(n_p * (n_p - 1) + (n_p - 1));
746 for (
unsigned l2 = 1; l2 < n_p; l2++)
749 Node_pt[node_count] =
750 finite_element_pt(Nx * (Ny - 1) + j)
751 ->construct_boundary_node(n_p * (n_p - 1) + l2, time_stepper_pt);
753 finite_element_pt(Nx * (Ny - 1) + j)->node_pt(n_p * (n_p - 1) + l2) =
757 finite_element_pt(Nx * (Ny - 1) + j)
758 ->local_fraction_of_node(n_p * (n_p - 1) + l2, s_fraction);
761 Node_pt[node_count]->x(0) = xinit + el_length_x * (j + s_fraction[0]);
762 Node_pt[node_count]->x(1) = yinit + el_length_y * Ny;
765 add_boundary_node(2, Node_pt[node_count]);
777 Element_pt[Nx * (Ny - 1) + Nx - 1] =
new ELEMENT;
779 for (
unsigned l2 = 0; l2 < n_p; l2++)
781 finite_element_pt(Nx * (Ny - 1) + Nx - 1)->node_pt(l2) =
782 finite_element_pt(Nx * (Ny - 2) + Nx - 1)
783 ->node_pt((n_p - 1) * n_p + l2);
787 for (
unsigned l1 = 1; l1 < (n_p - 1); l1++)
790 finite_element_pt(Nx * (Ny - 1) + Nx - 1)->node_pt(n_p * l1) =
791 finite_element_pt(Nx * (Ny - 1) + Nx - 2)
792 ->node_pt(n_p * l1 + (n_p - 1));
795 for (
unsigned l2 = 1; l2 < (n_p - 1); l2++)
798 Node_pt[node_count] =
799 finite_element_pt(Nx * (Ny - 1) + Nx - 1)
800 ->construct_node(n_p * l1 + l2, time_stepper_pt);
802 finite_element_pt(Nx * (Ny - 1) + Nx - 1)->node_pt(n_p * l1 + l2) =
806 finite_element_pt(Nx * (Ny - 1) + Nx - 1)
807 ->local_fraction_of_node(n_p * l1 + l2, s_fraction);
810 Node_pt[node_count]->x(0) =
811 xinit + el_length_x * (Nx - 1 + s_fraction[0]);
812 Node_pt[node_count]->x(1) =
813 yinit + el_length_y * (Ny - 1 + s_fraction[1]);
822 Node_pt[node_count] =
823 finite_element_pt(Nx * (Ny - 1) + Nx - 1)
824 ->construct_boundary_node(n_p * l1 + (n_p - 1), time_stepper_pt);
826 finite_element_pt(Nx * (Ny - 1) + Nx - 1)->node_pt(n_p * l1 + (n_p - 1)) =
830 finite_element_pt(Nx * (Ny - 1) + Nx - 1)
831 ->local_fraction_of_node(n_p * l1 + (n_p - 1), s_fraction);
834 Node_pt[node_count]->x(0) = xinit + el_length_x * Nx;
835 Node_pt[node_count]->x(1) =
836 yinit + el_length_y * (Ny - 1 + s_fraction[1]);
839 add_boundary_node(1, Node_pt[node_count]);
848 finite_element_pt(Nx * (Ny - 1) + Nx - 1)->node_pt(n_p * (n_p - 1)) =
849 finite_element_pt(Nx * (Ny - 1) + Nx - 2)
850 ->node_pt(n_p * (n_p - 1) + (n_p - 1));
853 for (
unsigned l2 = 1; l2 < (n_p - 1); l2++)
856 Node_pt[node_count] =
857 finite_element_pt(Nx * (Ny - 1) + Nx - 1)
858 ->construct_boundary_node(n_p * (n_p - 1) + l2, time_stepper_pt);
860 finite_element_pt(Nx * (Ny - 1) + Nx - 1)->node_pt(n_p * (n_p - 1) + l2) =
864 finite_element_pt(Nx * (Ny - 1) + Nx - 1)
865 ->local_fraction_of_node(n_p * (n_p - 1) + l2, s_fraction);
868 Node_pt[node_count]->x(0) =
869 xinit + el_length_x * (Nx - 1 + s_fraction[0]);
871 Node_pt[node_count]->x(1) = yinit + el_length_y * Ny;
874 add_boundary_node(2, Node_pt[node_count]);
883 Node_pt[node_count] =
884 finite_element_pt(Nx * (Ny - 1) + Nx - 1)
885 ->construct_boundary_node(n_p * (n_p - 1) + (n_p - 1), time_stepper_pt);
887 finite_element_pt(Nx * (Ny - 1) + Nx - 1)
888 ->node_pt(n_p * (n_p - 1) + (n_p - 1)) = Node_pt[node_count];
891 finite_element_pt(Nx * (Ny - 1) + Nx - 1)
892 ->local_fraction_of_node(n_p * (n_p - 1) + (n_p - 1), s_fraction);
895 Node_pt[node_count]->x(0) = xinit + el_length_x * Nx;
896 Node_pt[node_count]->x(1) = yinit + el_length_y * Ny;
899 add_boundary_node(1, Node_pt[node_count]);
900 add_boundary_node(2, Node_pt[node_count]);
907 setup_boundary_element_info();
SimpleRectangularQuadMesh(const unsigned &Nx, const unsigned &Ny, const double &Lx, const double &Ly, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Constructor: Pass number of elements in the horizontal and vertical directions, and the corresponding...
////////////////////////////////////////////////////////////////////// //////////////////////////////...