26 #ifndef OOMPH_RECTANGULAR_QUADMESH_TEMPLATE_CC
27 #define OOMPH_RECTANGULAR_QUADMESH_TEMPLATE_CC
42 template<
class ELEMENT>
46 MeshChecker::assert_geometric_element<QElementGeometricBase, ELEMENT>(2);
52 Element_pt.resize(Nx * Ny);
54 Element_pt[0] =
new ELEMENT;
57 Np =
dynamic_cast<ELEMENT*
>(finite_element_pt(0))->nnode_1d();
60 Node_pt.resize((1 + (Np - 1) * Nx) * (1 + (Np - 1) * Ny));
63 unsigned long node_count = 0;
76 finite_element_pt(0)->construct_boundary_node(0, time_stepper_pt);
79 Node_pt[node_count]->x(0) = x_spacing_function(0, 0, 0, 0);
80 Node_pt[node_count]->x(1) = y_spacing_function(0, 0, 0, 0);
83 add_boundary_node(0, Node_pt[node_count]);
84 add_boundary_node(3, Node_pt[node_count]);
90 for (
unsigned l2 = 1; l2 < Np; l2++)
94 finite_element_pt(0)->construct_boundary_node(l2, time_stepper_pt);
97 Node_pt[node_count]->x(0) = x_spacing_function(0, l2, 0, 0);
98 Node_pt[node_count]->x(1) = y_spacing_function(0, l2, 0, 0);
101 add_boundary_node(0, Node_pt[node_count]);
104 if ((Nx == 1) && (l2 == (Np - 1)))
106 add_boundary_node(1, Node_pt[node_count]);
114 for (
unsigned l1 = 1; l1 < Np; l1++)
117 Node_pt[node_count] =
118 finite_element_pt(0)->construct_boundary_node(l1 * Np, time_stepper_pt);
121 Node_pt[node_count]->x(0) = x_spacing_function(0, 0, 0, l1);
122 Node_pt[node_count]->x(1) = y_spacing_function(0, 0, 0, l1);
125 add_boundary_node(3, Node_pt[node_count]);
128 if ((Ny == 1) && (l1 == (Np - 1)))
130 add_boundary_node(2, Node_pt[node_count]);
137 for (
unsigned l2 = 1; l2 < Np; l2++)
141 if (((Nx == 1) && (l2 == (Np - 1))) || ((Ny == 1) && (l1 == (Np - 1))))
143 Node_pt[node_count] = finite_element_pt(0)->construct_boundary_node(
144 l1 * Np + l2, time_stepper_pt);
149 Node_pt[node_count] =
150 finite_element_pt(0)->construct_node(l1 * Np + l2, time_stepper_pt);
154 Node_pt[node_count]->x(0) = x_spacing_function(0, l2, 0, l1);
155 Node_pt[node_count]->x(1) = y_spacing_function(0, l2, 0, l1);
158 if ((Nx == 1) && l2 == (Np - 1))
160 add_boundary_node(1, Node_pt[node_count]);
163 if ((Ny == 1) && (l1 == (Np - 1)))
165 add_boundary_node(2, Node_pt[node_count]);
176 for (
unsigned j = 1; j < (Nx - 1); j++)
179 Element_pt[j] =
new ELEMENT;
182 finite_element_pt(j)->node_pt(0) =
183 finite_element_pt(j - 1)->node_pt((Np - 1));
185 for (
unsigned l2 = 1; l2 < Np; l2++)
188 Node_pt[node_count] =
189 finite_element_pt(j)->construct_boundary_node(l2, time_stepper_pt);
192 Node_pt[node_count]->x(0) = x_spacing_function(j, l2, 0, 0);
193 Node_pt[node_count]->x(1) = y_spacing_function(j, l2, 0, 0);
196 add_boundary_node(0, Node_pt[node_count]);
203 for (
unsigned l1 = 1; l1 < Np; l1++)
206 finite_element_pt(j)->node_pt(l1 * Np) =
207 finite_element_pt(j - 1)->node_pt(l1 * Np + (Np - 1));
209 for (
unsigned l2 = 1; l2 < Np; l2++)
213 if ((Ny == 1) && (l1 == (Np - 1)))
215 Node_pt[node_count] = finite_element_pt(j)->construct_boundary_node(
216 l1 * Np + l2, time_stepper_pt);
221 Node_pt[node_count] = finite_element_pt(j)->construct_node(
222 l1 * Np + l2, time_stepper_pt);
226 Node_pt[node_count]->x(0) = x_spacing_function(j, l2, 0, l1);
227 Node_pt[node_count]->x(1) = y_spacing_function(j, l2, 0, l1);
230 if ((Ny == 1) && (l1 == (Np - 1)))
232 add_boundary_node(2, Node_pt[node_count]);
247 Element_pt[Nx - 1] =
new ELEMENT;
250 finite_element_pt(Nx - 1)->node_pt(0) =
251 finite_element_pt(Nx - 2)->node_pt(Np - 1);
254 for (
unsigned l2 = 1; l2 < (Np - 1); l2++)
257 Node_pt[node_count] =
258 finite_element_pt(Nx - 1)->construct_boundary_node(l2,
262 Node_pt[node_count]->x(0) = x_spacing_function(Nx - 1, l2, 0, 0);
263 Node_pt[node_count]->x(1) = y_spacing_function(Nx - 1, l2, 0, 0);
266 add_boundary_node(0, Node_pt[node_count]);
273 Node_pt[node_count] = finite_element_pt(Nx - 1)->construct_boundary_node(
274 Np - 1, time_stepper_pt);
277 if (Xperiodic ==
true)
279 Node_pt[node_count]->make_periodic(finite_element_pt(0)->node_pt(0));
283 Node_pt[node_count]->x(0) = x_spacing_function(Nx - 1, Np - 1, 0, 0);
284 Node_pt[node_count]->x(1) = y_spacing_function(Nx - 1, Np - 1, 0, 0);
287 add_boundary_node(0, Node_pt[node_count]);
288 add_boundary_node(1, Node_pt[node_count]);
294 for (
unsigned l1 = 1; l1 < Np; l1++)
297 finite_element_pt(Nx - 1)->node_pt(l1 * Np) =
298 finite_element_pt(Nx - 2)->node_pt(l1 * Np + (Np - 1));
301 for (
unsigned l2 = 1; l2 < (Np - 1); l2++)
305 if ((Ny == 1) && (l1 == (Np - 1)))
307 Node_pt[node_count] =
308 finite_element_pt(Nx - 1)->construct_boundary_node(
309 l1 * Np + l2, time_stepper_pt);
314 Node_pt[node_count] = finite_element_pt(Nx - 1)->construct_node(
315 l1 * Np + l2, time_stepper_pt);
319 Node_pt[node_count]->x(0) = x_spacing_function(Nx - 1, l2, 0, l1);
320 Node_pt[node_count]->x(1) = y_spacing_function(Nx - 1, l2, 0, l1);
323 if ((Ny == 1) && (l1 == (Np - 1)))
325 add_boundary_node(2, Node_pt[node_count]);
333 Node_pt[node_count] =
334 finite_element_pt(Nx - 1)->construct_boundary_node(l1 * Np + (Np - 1),
339 if (Xperiodic ==
true)
341 Node_pt[node_count]->make_periodic(
342 finite_element_pt(0)->node_pt(l1 * Np));
346 Node_pt[node_count]->x(0) = x_spacing_function(Nx - 1, Np - 1, 0, l1);
347 Node_pt[node_count]->x(1) = y_spacing_function(Nx - 1, Np - 1, 0, l1);
350 add_boundary_node(1, Node_pt[node_count]);
353 if ((Ny == 1) && (l1 == (Np - 1)))
355 add_boundary_node(2, Node_pt[node_count]);
366 for (
unsigned i = 1; i < (Ny - 1); i++)
370 Element_pt[Nx * i] =
new ELEMENT;
373 for (
unsigned l2 = 0; l2 < Np; l2++)
375 finite_element_pt(Nx * i)->node_pt(l2) =
376 finite_element_pt(Nx * (i - 1))->node_pt((Np - 1) * Np + l2);
380 for (
unsigned l1 = 1; l1 < Np; l1++)
384 Node_pt[node_count] =
385 finite_element_pt(Nx * i)->construct_boundary_node(l1 * Np,
389 Node_pt[node_count]->x(0) = x_spacing_function(0, 0, i, l1);
390 Node_pt[node_count]->x(1) = y_spacing_function(0, 0, i, l1);
393 add_boundary_node(3, Node_pt[node_count]);
399 for (
unsigned l2 = 1; l2 < Np; l2++)
403 if ((Nx == 1) && (l2 == (Np - 1)))
405 Node_pt[node_count] =
406 finite_element_pt(Nx * i)->construct_boundary_node(
407 l1 * Np + l2, time_stepper_pt);
411 Node_pt[node_count] = finite_element_pt(Nx * i)->construct_node(
412 l1 * Np + l2, time_stepper_pt);
416 Node_pt[node_count]->x(0) = x_spacing_function(0, l2, i, l1);
417 Node_pt[node_count]->x(1) = y_spacing_function(0, l2, i, l1);
421 if ((Nx == 1) && (l2 == (Np - 1)))
423 add_boundary_node(1, Node_pt[node_count]);
432 for (
unsigned j = 1; j < (Nx - 1); j++)
435 Element_pt[Nx * i + j] =
new ELEMENT;
437 for (
unsigned l2 = 0; l2 < Np; l2++)
439 finite_element_pt(Nx * i + j)->node_pt(l2) =
440 finite_element_pt(Nx * (i - 1) + j)->node_pt((Np - 1) * Np + l2);
443 for (
unsigned l1 = 1; l1 < Np; l1++)
446 finite_element_pt(Nx * i + j)->node_pt(l1 * Np) =
447 finite_element_pt(Nx * i + (j - 1))->node_pt(l1 * Np + (Np - 1));
449 for (
unsigned l2 = 1; l2 < Np; l2++)
452 Node_pt[node_count] =
453 finite_element_pt(Nx * i + j)
454 ->construct_node(l1 * Np + l2, time_stepper_pt);
457 Node_pt[node_count]->x(0) = x_spacing_function(j, l2, i, l1);
458 Node_pt[node_count]->x(1) = y_spacing_function(j, l2, i, l1);
471 Element_pt[Nx * i + Nx - 1] =
new ELEMENT;
473 for (
unsigned l2 = 0; l2 < Np; l2++)
475 finite_element_pt(Nx * i + Nx - 1)->node_pt(l2) =
476 finite_element_pt(Nx * (i - 1) + Nx - 1)
477 ->node_pt((Np - 1) * Np + l2);
480 for (
unsigned l1 = 1; l1 < Np; l1++)
483 finite_element_pt(Nx * i + Nx - 1)->node_pt(l1 * Np) =
484 finite_element_pt(Nx * i + Nx - 2)->node_pt(l1 * Np + (Np - 1));
487 for (
unsigned l2 = 1; l2 < (Np - 1); l2++)
490 Node_pt[node_count] =
491 finite_element_pt(Nx * i + Nx - 1)
492 ->construct_node(l1 * Np + l2, time_stepper_pt);
495 Node_pt[node_count]->x(0) = x_spacing_function(Nx - 1, l2, i, l1);
496 Node_pt[node_count]->x(1) = y_spacing_function(Nx - 1, l2, i, l1);
503 Node_pt[node_count] =
504 finite_element_pt(Nx * i + Nx - 1)
505 ->construct_boundary_node(l1 * Np + (Np - 1), time_stepper_pt);
509 if (Xperiodic ==
true)
511 Node_pt[node_count]->make_periodic(
512 finite_element_pt(Nx * i)->node_pt(l1 * Np));
516 Node_pt[node_count]->x(0) = x_spacing_function(Nx - 1, Np - 1, i, l1);
517 Node_pt[node_count]->x(1) = y_spacing_function(Nx - 1, Np - 1, i, l1);
520 add_boundary_node(1, Node_pt[node_count]);
536 Element_pt[Nx * (Ny - 1)] =
new ELEMENT;
538 for (
unsigned l2 = 0; l2 < Np; l2++)
540 finite_element_pt(Nx * (Ny - 1))->node_pt(l2) =
541 finite_element_pt(Nx * (Ny - 2))->node_pt((Np - 1) * Np + l2);
546 for (
unsigned l1 = 1; l1 < (Np - 1); l1++)
549 Node_pt[node_count] =
550 finite_element_pt(Nx * (Ny - 1))
551 ->construct_boundary_node(Np * l1, time_stepper_pt);
554 Node_pt[node_count]->x(0) = x_spacing_function(0, 0, Ny - 1, l1);
555 Node_pt[node_count]->x(1) = y_spacing_function(0, 0, Ny - 1, l1);
558 add_boundary_node(3, Node_pt[node_count]);
564 for (
unsigned l2 = 1; l2 < Np; l2++)
567 if ((Nx == 1) && (l2 == Np - 1))
569 Node_pt[node_count] =
570 finite_element_pt(Nx * (Ny - 1))
571 ->construct_boundary_node(Np * l1 + l2, time_stepper_pt);
575 Node_pt[node_count] =
576 finite_element_pt(Nx * (Ny - 1))
577 ->construct_node(Np * l1 + l2, time_stepper_pt);
581 Node_pt[node_count]->x(0) = x_spacing_function(0, l2, Ny - 1, l1);
582 Node_pt[node_count]->x(1) = y_spacing_function(0, l2, Ny - 1, l1);
585 if ((Nx == 1) && (l2 == Np - 1))
587 add_boundary_node(1, Node_pt[node_count]);
599 Node_pt[node_count] =
600 finite_element_pt(Nx * (Ny - 1))
601 ->construct_boundary_node(Np * (Np - 1), time_stepper_pt);
604 Node_pt[node_count]->x(0) = x_spacing_function(0, 0, Ny - 1, Np - 1);
605 Node_pt[node_count]->x(1) = y_spacing_function(0, 0, Ny - 1, Np - 1);
608 add_boundary_node(2, Node_pt[node_count]);
609 add_boundary_node(3, Node_pt[node_count]);
615 for (
unsigned l2 = 1; l2 < Np; l2++)
618 Node_pt[node_count] =
619 finite_element_pt(Nx * (Ny - 1))
620 ->construct_boundary_node(Np * (Np - 1) + l2, time_stepper_pt);
623 Node_pt[node_count]->x(0) = x_spacing_function(0, l2, Ny - 1, Np - 1);
624 Node_pt[node_count]->x(1) = y_spacing_function(0, l2, Ny - 1, Np - 1);
627 add_boundary_node(2, Node_pt[node_count]);
630 if ((Nx == 1) && (l2 == Np - 1))
632 add_boundary_node(1, Node_pt[node_count]);
640 for (
unsigned j = 1; j < (Nx - 1); j++)
643 Element_pt[Nx * (Ny - 1) + j] =
new ELEMENT;
645 for (
unsigned l2 = 0; l2 < Np; l2++)
647 finite_element_pt(Nx * (Ny - 1) + j)->node_pt(l2) =
648 finite_element_pt(Nx * (Ny - 2) + j)->node_pt((Np - 1) * Np + l2);
652 for (
unsigned l1 = 1; l1 < (Np - 1); l1++)
655 finite_element_pt(Nx * (Ny - 1) + j)->node_pt(Np * l1) =
656 finite_element_pt(Nx * (Ny - 1) + (j - 1))
657 ->node_pt(Np * l1 + (Np - 1));
660 for (
unsigned l2 = 1; l2 < Np; l2++)
663 Node_pt[node_count] =
664 finite_element_pt(Nx * (Ny - 1) + j)
665 ->construct_node(Np * l1 + l2, time_stepper_pt);
668 Node_pt[node_count]->x(0) = x_spacing_function(j, l2, Ny - 1, l1);
669 Node_pt[node_count]->x(1) = y_spacing_function(j, l2, Ny - 1, l1);
678 finite_element_pt(Nx * (Ny - 1) + j)->node_pt(Np * (Np - 1)) =
679 finite_element_pt(Nx * (Ny - 1) + (j - 1))
680 ->node_pt(Np * (Np - 1) + (Np - 1));
682 for (
unsigned l2 = 1; l2 < Np; l2++)
685 Node_pt[node_count] =
686 finite_element_pt(Nx * (Ny - 1) + j)
687 ->construct_boundary_node(Np * (Np - 1) + l2, time_stepper_pt);
690 Node_pt[node_count]->x(0) = x_spacing_function(j, l2, Ny - 1, Np - 1);
691 Node_pt[node_count]->x(1) = y_spacing_function(j, l2, Ny - 1, Np - 1);
694 add_boundary_node(2, Node_pt[node_count]);
706 Element_pt[Nx * (Ny - 1) + Nx - 1] =
new ELEMENT;
708 for (
unsigned l2 = 0; l2 < Np; l2++)
710 finite_element_pt(Nx * (Ny - 1) + Nx - 1)->node_pt(l2) =
711 finite_element_pt(Nx * (Ny - 2) + Nx - 1)
712 ->node_pt((Np - 1) * Np + l2);
716 for (
unsigned l1 = 1; l1 < (Np - 1); l1++)
719 finite_element_pt(Nx * (Ny - 1) + Nx - 1)->node_pt(Np * l1) =
720 finite_element_pt(Nx * (Ny - 1) + Nx - 2)
721 ->node_pt(Np * l1 + (Np - 1));
724 for (
unsigned l2 = 1; l2 < (Np - 1); l2++)
727 Node_pt[node_count] =
728 finite_element_pt(Nx * (Ny - 1) + Nx - 1)
729 ->construct_node(Np * l1 + l2, time_stepper_pt);
732 Node_pt[node_count]->x(0) =
733 x_spacing_function(Nx - 1, l2, Ny - 1, l1);
734 Node_pt[node_count]->x(1) =
735 y_spacing_function(Nx - 1, l2, Ny - 1, l1);
743 Node_pt[node_count] =
744 finite_element_pt(Nx * (Ny - 1) + Nx - 1)
745 ->construct_boundary_node(Np * l1 + (Np - 1), time_stepper_pt);
748 if (Xperiodic ==
true)
750 Node_pt[node_count]->make_periodic(
751 finite_element_pt(Nx * (Ny - 1))->node_pt(Np * l1));
755 Node_pt[node_count]->x(0) =
756 x_spacing_function(Nx - 1, Np - 1, Ny - 1, l1);
757 Node_pt[node_count]->x(1) =
758 y_spacing_function(Nx - 1, Np - 1, Ny - 1, l1);
761 add_boundary_node(1, Node_pt[node_count]);
770 finite_element_pt(Nx * (Ny - 1) + Nx - 1)->node_pt(Np * (Np - 1)) =
771 finite_element_pt(Nx * (Ny - 1) + Nx - 2)
772 ->node_pt(Np * (Np - 1) + (Np - 1));
775 for (
unsigned l2 = 1; l2 < (Np - 1); l2++)
778 Node_pt[node_count] =
779 finite_element_pt(Nx * (Ny - 1) + Nx - 1)
780 ->construct_boundary_node(Np * (Np - 1) + l2, time_stepper_pt);
783 Node_pt[node_count]->x(0) =
784 x_spacing_function(Nx - 1, l2, Ny - 1, Np - 1);
785 Node_pt[node_count]->x(1) =
786 y_spacing_function(Nx - 1, l2, Ny - 1, Np - 1);
789 add_boundary_node(2, Node_pt[node_count]);
797 Node_pt[node_count] = finite_element_pt(Nx * (Ny - 1) + Nx - 1)
798 ->construct_boundary_node(
799 Np * (Np - 1) + (Np - 1), time_stepper_pt);
802 if (Xperiodic ==
true)
804 Node_pt[node_count]->make_periodic(
805 finite_element_pt(Nx * (Ny - 1))->node_pt(Np * (Np - 1)));
809 Node_pt[node_count]->x(0) =
810 x_spacing_function(Nx - 1, Np - 1, Ny - 1, Np - 1);
811 Node_pt[node_count]->x(1) =
812 y_spacing_function(Nx - 1, Np - 1, Ny - 1, Np - 1);
815 add_boundary_node(1, Node_pt[node_count]);
816 add_boundary_node(2, Node_pt[node_count]);
825 setup_boundary_element_info();
833 template<
class ELEMENT>
837 unsigned long Nelement = nelement();
839 Vector<FiniteElement*> dummy;
842 for (
unsigned long j = 0; j < Nx; j++)
845 for (
unsigned long i = 0; i < Ny; i++)
848 dummy.push_back(finite_element_pt(Nx * i + j));
853 for (
unsigned long e = 0; e < Nelement; e++)
855 Element_pt[e] = dummy[e];
virtual void element_reorder()
Reorder the elements: By default they are ordered in "horizontal" layers (increasing in x,...
void build_mesh(TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Generic mesh construction function: contains all the hard work.
////////////////////////////////////////////////////////////////////// //////////////////////////////...