simple_cubic_mesh.template.cc
Go to the documentation of this file.
1// LIC// ====================================================================
2// LIC// This file forms part of oomph-lib, the object-oriented,
3// LIC// multi-physics finite-element library, available
4// LIC// at http://www.oomph-lib.org.
5// LIC//
6// LIC// Copyright (C) 2006-2025 Matthias Heil and Andrew Hazel
7// LIC//
8// LIC// This library is free software; you can redistribute it and/or
9// LIC// modify it under the terms of the GNU Lesser General Public
10// LIC// License as published by the Free Software Foundation; either
11// LIC// version 2.1 of the License, or (at your option) any later version.
12// LIC//
13// LIC// This library is distributed in the hope that it will be useful,
14// LIC// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// LIC// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16// LIC// Lesser General Public License for more details.
17// LIC//
18// LIC// You should have received a copy of the GNU Lesser General Public
19// LIC// License along with this library; if not, write to the Free Software
20// LIC// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21// LIC// 02110-1301 USA.
22// LIC//
23// LIC// The authors may be contacted at oomph-lib@maths.man.ac.uk.
24// LIC//
25// LIC//====================================================================
26#ifndef OOMPH_SIMPLE_CUBIC_MESH_TEMPLATE_HEADER
27#define OOMPH_SIMPLE_CUBIC_MESH_TEMPLATE_HEADER
28
29#ifndef OOMPH_SIMPLE_CUBIC_MESH_HEADER
30#error __FILE__ should only be included from simple_cubic_mesh.h.
31#endif // OOMPH_SIMPLE_CUBIC_MESH_HEADER
32
33// OOMPH-LIB Header
34
35namespace oomph
36{
37 //=========================================================================
38 /// Generic mesh construction. This function contains all the details of
39 /// the mesh generation process, including all the tedious loops, counting
40 /// spacing and boundary functions.
41 //========================================================================
42 template<class ELEMENT>
44 {
45 // Mesh can only be built with 3D Qelements.
46 MeshChecker::assert_geometric_element<QElementGeometricBase, ELEMENT>(3);
47
48 if ((Nx == 1) || (Ny == 1) || (Nz == 1))
49 {
50 std::ostringstream error_message;
51 error_message << "SimpleCubicMesh needs at least two elements in each,\n"
52 << "coordinate direction. You have specified \n"
53 << "Nx=" << Nx << "; Ny=" << Ny << "; Nz=" << Nz
54 << std::endl;
55 throw OomphLibError(
57 }
58
59 // Set the number of boundaries
60 set_nboundary(6);
61
62 // Allocate the store for the elements
63 Element_pt.resize(Nx * Ny * Nz);
64 // Create first element
65 unsigned element_num = 0;
66 Element_pt[element_num] = new ELEMENT;
67
68 // Read out the number of linear points in the element
69 unsigned n_p = dynamic_cast<ELEMENT*>(finite_element_pt(0))->nnode_1d();
70
71 // Can now allocate the store for the nodes
72 Node_pt.resize((1 + (n_p - 1) * Nx) * (1 + (n_p - 1) * Ny) *
73 (1 + (n_p - 1) * Nz));
74
75 // Set up geometrical data
76 //------------------------
77
78 unsigned long node_count = 0;
79
80 // Set the length of the elments
81 double el_length[3] = {(Xmax - Xmin) / double(Nx),
82 (Ymax - Ymin) / double(Ny),
83 (Zmax - Zmin) / double(Nz)};
84
85 // Storage for local coordinate in element
87
88 // Now assign the topology
89 // Boundaries are numbered:
90 // 0 is at the bottom
91 // 1 2 3 4 from the front proceeding anticlockwise
92 // 5 is at the top
93 // Pinned value are denoted by an integer value 1
94 // Thus if a node is on two boundaries, ORing the values of the
95 // boundary conditions will give the most restrictive case (pinning)
96
97 // FIRST ELEMENT (lower left corner at z = 0 plane )
98 //----------------------------------
99
100 // Set the corner node
101 // Storage for the local node number
102 unsigned local_node_num = 0;
103 // Allocate memory for the node
105 finite_element_pt(element_num)
106 ->construct_boundary_node(local_node_num, time_stepper_pt);
107 // Set the pointer from the element
108 finite_element_pt(element_num)->node_pt(local_node_num) =
110
111 // Set the position of the node
112 Node_pt[node_count]->x(0) = Xmin;
113 Node_pt[node_count]->x(1) = Ymin;
114 Node_pt[node_count]->x(2) = Zmin;
115
116 // Add the node to boundaries 0,1 and 4
117 add_boundary_node(0, Node_pt[node_count]);
118 add_boundary_node(1, Node_pt[node_count]);
119 add_boundary_node(4, Node_pt[node_count]);
120 // Increment the node number
121 node_count++;
122
123 // Loop over the other nodes in the first row in the x direction in
124 // the z=0 plane
125 for (unsigned l2 = 1; l2 < n_p; l2++)
126 {
127 // Set the local node number
129
130 // Allocate memory for the nodes
132 finite_element_pt(element_num)
133 ->construct_boundary_node(local_node_num, time_stepper_pt);
134 // Set the pointer from the element
135 finite_element_pt(element_num)->node_pt(local_node_num) =
137
138 // Get the local fraction of the node
139 finite_element_pt(element_num)
140 ->local_fraction_of_node(local_node_num, s_fraction);
141
142 // Set the position of the node
143 Node_pt[node_count]->x(0) = Xmin + el_length[0] * s_fraction[0];
144 Node_pt[node_count]->x(1) = Ymin;
145 Node_pt[node_count]->x(2) = Zmin;
146
147 // Add the node to the boundary 0 and 1
148 add_boundary_node(0, Node_pt[node_count]);
149 add_boundary_node(1, Node_pt[node_count]);
150 // Increment the node number
151 node_count++;
152 }
153
154 // Loop over the other node columns in the z = 0 plane
155 for (unsigned l1 = 1; l1 < n_p; l1++)
156 {
157 // Set the local node number
159
160 // Allocate memory for the nodes
162 finite_element_pt(element_num)
163 ->construct_boundary_node(local_node_num, time_stepper_pt);
164 // Set the pointer from the element
165 finite_element_pt(element_num)->node_pt(local_node_num) =
167
168 // Get the fractional position
169 finite_element_pt(element_num)
170 ->local_fraction_of_node(local_node_num, s_fraction);
171
172 // Set the position of the first node of the row
173 //(with boundaries with 0 and 4)
174 Node_pt[node_count]->x(0) = Xmin;
175 Node_pt[node_count]->x(1) = Ymin + el_length[1] * s_fraction[1];
176 Node_pt[node_count]->x(2) = Zmin;
177
178 // Add the node to the boundaries 0 and 4
179 add_boundary_node(4, Node_pt[node_count]);
180 add_boundary_node(0, Node_pt[node_count]);
181 // Increment the node number
182 node_count++;
183
184 // Loop over the other nodes in the row
185 for (unsigned l2 = 1; l2 < n_p; l2++)
186 {
187 // Set the local node number
188 local_node_num = l1 * n_p + l2;
189
190 // Allocate the memory for the node
192 finite_element_pt(element_num)
193 ->construct_boundary_node(local_node_num, time_stepper_pt);
194 // Set the pointer from the element
195 finite_element_pt(element_num)->node_pt(local_node_num) =
197
198 // Get the fractional position
199 finite_element_pt(element_num)
200 ->local_fraction_of_node(local_node_num, s_fraction);
201
202 // Set the position of the node
203 Node_pt[node_count]->x(0) = Xmin + el_length[0] * s_fraction[0];
204 Node_pt[node_count]->x(1) = Ymin + el_length[1] * s_fraction[1];
205 Node_pt[node_count]->x(2) = Zmin;
206
207 // Add the node to the boundary 0
208 add_boundary_node(0, Node_pt[node_count]);
209 // Increment the node number
210 node_count++;
211 }
212 }
213
214 //---------------------------------------------------------------------
215
216 // Loop over the other node columns in the z direction
217 for (unsigned l3 = 1; l3 < n_p; l3++)
218 {
219 // Set the local node number
220 local_node_num = n_p * n_p * l3;
221
222 // Allocate memory for the node
224 finite_element_pt(element_num)
225 ->construct_boundary_node(local_node_num, time_stepper_pt);
226 // Set the pointer from the element
227 finite_element_pt(element_num)->node_pt(local_node_num) =
229
230 // Get the fractional position of the node
231 finite_element_pt(element_num)
232 ->local_fraction_of_node(local_node_num, s_fraction);
233
234 // Set the position of the node
235 Node_pt[node_count]->x(0) = Xmin;
236 Node_pt[node_count]->x(1) = Ymin;
237 Node_pt[node_count]->x(2) = Zmin + el_length[2] * s_fraction[2];
238
239 // Add the node to boundaries 1 and 4
240 add_boundary_node(1, Node_pt[node_count]);
241 add_boundary_node(4, Node_pt[node_count]);
242 // Increment the node number
243 node_count++;
244
245 // Loop over the other nodes in the first row in the x direction
246 for (unsigned l2 = 1; l2 < n_p; l2++)
247 {
248 // Set the local node number
249 local_node_num = l2 + n_p * n_p * l3;
250
251 // Allocate memory for the nodes
253 finite_element_pt(element_num)
254 ->construct_boundary_node(local_node_num, time_stepper_pt);
255 // Set the pointer from the element
256 finite_element_pt(element_num)->node_pt(local_node_num) =
258
259 // Get the fractional position of the node
260 finite_element_pt(element_num)
261 ->local_fraction_of_node(local_node_num, s_fraction);
262
263 // Set the position of the node
264 Node_pt[node_count]->x(0) = Xmin + el_length[0] * s_fraction[0];
265 Node_pt[node_count]->x(1) = Ymin;
266 Node_pt[node_count]->x(2) = Zmin + el_length[2] * s_fraction[2];
267
268 // Add the node to the boundary 1
269 add_boundary_node(1, Node_pt[node_count]);
270 // Increment the node number
271 node_count++;
272 }
273
274 // Loop over the other node columns
275 for (unsigned l1 = 1; l1 < n_p; l1++)
276 {
277 // Set the local node number
278 local_node_num = l1 * n_p + n_p * n_p * l3;
279
280 // Allocate memory for the nodes
282 finite_element_pt(element_num)
283 ->construct_boundary_node(local_node_num, time_stepper_pt);
284 // Set the pointer from the element
285 finite_element_pt(element_num)->node_pt(local_node_num) =
287
288 // Get the fractional position of the node
289 finite_element_pt(element_num)
290 ->local_fraction_of_node(local_node_num, s_fraction);
291
292 // Set the position of the first node of the row (with boundary 4)
293 Node_pt[node_count]->x(0) = Xmin;
294 Node_pt[node_count]->x(1) = Ymin + el_length[1] * s_fraction[1];
295 Node_pt[node_count]->x(2) = Zmin + el_length[2] * s_fraction[2];
296
297 // Add the node to the boundary 4
298 add_boundary_node(4, Node_pt[node_count]);
299 // Increment the node number
300 node_count++;
301
302 // Loop over the other nodes in the row
303 for (unsigned l2 = 1; l2 < n_p; l2++)
304 {
305 // Set the local node number
306 local_node_num = l2 + l1 * n_p + n_p * n_p * l3;
307
308 // Allocate the memory for the node
310 finite_element_pt(element_num)
311 ->construct_node(local_node_num, time_stepper_pt);
312 // Set the pointer from the element
313 finite_element_pt(element_num)->node_pt(local_node_num) =
315
316 // Get the fractional position of the node
317 finite_element_pt(element_num)
318 ->local_fraction_of_node(local_node_num, s_fraction);
319
320 // Set the position of the node
321 Node_pt[node_count]->x(0) = Xmin + el_length[0] * s_fraction[0];
322 Node_pt[node_count]->x(1) = Ymin + el_length[1] * s_fraction[1];
323 Node_pt[node_count]->x(2) = Zmin + el_length[2] * s_fraction[2];
324
325 // No boundary
326
327 // Increment the node number
328 node_count++;
329 }
330 }
331 }
332
333 //----------------------------------------------------------------------
334
335 // CENTRE OF FIRST ROW OF ELEMENTS (PLANE Z = 0)
336 //--------------------------------
337
338 // Now loop over the first row of elements, apart from final element
339 for (unsigned j = 1; j < (Nx - 1); j++)
340 {
341 // Allocate memory for new element
342 element_num = j;
343 Element_pt[element_num] = new ELEMENT;
344
345 // We will begin with all the nodes at the plane z = 0
346
347 // Do first row of nodes
348
349 // First column of nodes is same as neighbouring element
350 finite_element_pt(element_num)->node_pt(0) =
351 finite_element_pt(element_num - 1)->node_pt((n_p - 1));
352
353 // New nodes for other columns
354 for (unsigned l2 = 1; l2 < n_p; l2++)
355 {
356 // Set the local node number
358
359 // Allocate memory for the nodes
361 finite_element_pt(element_num)
362 ->construct_boundary_node(local_node_num, time_stepper_pt);
363 // Set the pointer from the element
364 finite_element_pt(element_num)->node_pt(local_node_num) =
366
367 // Get the fractional position of the node
368 finite_element_pt(element_num)
369 ->local_fraction_of_node(local_node_num, s_fraction);
370
371 // Set the position of the node
372 Node_pt[node_count]->x(0) = Xmin + el_length[0] * (j + s_fraction[0]);
373 Node_pt[node_count]->x(1) = Ymin;
374 Node_pt[node_count]->x(2) = Zmin;
375
376 // Add the node to the boundaries 0 an 1
377 add_boundary_node(0, Node_pt[node_count]);
378 add_boundary_node(1, Node_pt[node_count]);
379 // Increment the node number
380 node_count++;
381 }
382
383 // Do the rest of the nodes at the plane z = 0
384 for (unsigned l1 = 1; l1 < n_p; l1++)
385 {
386 // First column of nodes is same as neighbouring element
387 finite_element_pt(element_num)->node_pt(l1 * n_p) =
388 finite_element_pt(element_num - 1)->node_pt(l1 * n_p + (n_p - 1));
389
390 // New nodes for other columns
391 for (unsigned l2 = 1; l2 < n_p; l2++)
392 {
393 // Set the local node number
394 local_node_num = l2 + l1 * n_p;
395
396 // Allocate memory for the nodes
398 finite_element_pt(element_num)
399 ->construct_boundary_node(local_node_num, time_stepper_pt);
400 // Set the pointer from the element
401 finite_element_pt(element_num)->node_pt(local_node_num) =
403
404 // Get the fractional position of the node
405 finite_element_pt(element_num)
406 ->local_fraction_of_node(local_node_num, s_fraction);
407
408 // Set the position of the node
409 Node_pt[node_count]->x(0) = Xmin + el_length[0] * (j + s_fraction[0]);
410 Node_pt[node_count]->x(1) = Ymin + el_length[1] * s_fraction[1];
411 Node_pt[node_count]->x(2) = Zmin;
412
413 // Add the node to the Boundary
414 add_boundary_node(0, Node_pt[node_count]);
415 // Increment the node number
416 node_count++;
417 }
418 }
419
420 // Loop over the other node columns in the z direction
421 for (unsigned l3 = 1; l3 < n_p; l3++)
422 {
423 // First column of nodes is same as neighbouring element
424 finite_element_pt(j)->node_pt(l3 * n_p * n_p) =
425 finite_element_pt(j - 1)->node_pt(l3 * n_p * n_p + (n_p - 1));
426
427 // New nodes for other columns
428 for (unsigned l2 = 1; l2 < n_p; l2++)
429 {
430 // Set the local node number
431 local_node_num = l2 + l3 * n_p * n_p;
432
433 // Allocate memory for the nodes
435 finite_element_pt(element_num)
436 ->construct_boundary_node(local_node_num, time_stepper_pt);
437 // Set the pointer from the element
438 finite_element_pt(element_num)->node_pt(local_node_num) =
440
441 // Get the fractional position of the node
442 finite_element_pt(element_num)
443 ->local_fraction_of_node(local_node_num, s_fraction);
444
445 // Set the position of the node
446 Node_pt[node_count]->x(0) = Xmin + el_length[0] * (j + s_fraction[0]);
447 Node_pt[node_count]->x(1) = Ymin;
448 Node_pt[node_count]->x(2) = Zmin + el_length[2] * s_fraction[2];
449
450 // Add the node to the boundary 1
451 add_boundary_node(1, Node_pt[node_count]);
452 // Increment the node number
453 node_count++;
454 }
455
456 // Do the rest of the nodes
457 for (unsigned l1 = 1; l1 < n_p; l1++)
458 {
459 // First column of nodes is same as neighbouring element
460 finite_element_pt(j)->node_pt(l1 * n_p + l3 * n_p * n_p) =
461 finite_element_pt(j - 1)->node_pt(l1 * n_p + (n_p - 1) +
462 l3 * n_p * n_p);
463
464 // New nodes for other columns
465 for (unsigned l2 = 1; l2 < n_p; l2++)
466 {
467 // Set the local node number
468 local_node_num = l2 + l1 * n_p + l3 * n_p * n_p;
469
470 // Allocate memory for the nodes
472 finite_element_pt(element_num)
473 ->construct_node(local_node_num, time_stepper_pt);
474 // Set the pointer from the element
475 finite_element_pt(element_num)->node_pt(local_node_num) =
477
478 // Get the fractional position of the node
479 finite_element_pt(element_num)
480 ->local_fraction_of_node(local_node_num, s_fraction);
481
482 // Set the position of the node
483 Node_pt[node_count]->x(0) =
484 Xmin + el_length[0] * (j + s_fraction[0]);
485 Node_pt[node_count]->x(1) = Ymin + el_length[1] * s_fraction[1];
486 Node_pt[node_count]->x(2) = Zmin + el_length[2] * s_fraction[2];
487
488 // No boundaries
489
490 // Increment the node number
491 node_count++;
492 }
493 }
494 }
495 }
496
497 // MY FINAL ELEMENT IN FIRST ROW (lower right corner)
498 //-----------------------------------------------
499
500 // Allocate memory for new element
501 element_num = Nx - 1;
502 Element_pt[element_num] = new ELEMENT;
503
504 // We will begin with all the nodes at the plane z = 0
505
506 // Do first row of nodes
507
508 // First node is same as neighbouring element
509 finite_element_pt(element_num)->node_pt(0) =
510 finite_element_pt(element_num - 1)->node_pt((n_p - 1));
511
512 // New nodes for other columns
513 for (unsigned l2 = 1; l2 < (n_p - 1); l2++)
514 {
515 // Set the local node number
517
518 // Allocate memory for the nodes
520 finite_element_pt(element_num)
521 ->construct_boundary_node(local_node_num, time_stepper_pt);
522 // Set the pointer from the element
523 finite_element_pt(element_num)->node_pt(local_node_num) =
525
526 // Get the fractional position of the node
527 finite_element_pt(element_num)
528 ->local_fraction_of_node(local_node_num, s_fraction);
529
530 // Set the position of the node
531 Node_pt[node_count]->x(0) =
532 Xmin + el_length[0] * (Nx - 1 + s_fraction[0]);
533 Node_pt[node_count]->x(1) = Ymin;
534 Node_pt[node_count]->x(2) = Zmin;
535
536 // Add the node to the boundaries 0 an 1
537 add_boundary_node(0, Node_pt[node_count]);
538 add_boundary_node(1, Node_pt[node_count]);
539 // Increment the node number
540 node_count++;
541 }
542
543 // Last node (corner)
544 // Set the local node number
545 local_node_num = n_p - 1;
546
547 // Allocate memory for the node
549 finite_element_pt(element_num)
550 ->construct_boundary_node(local_node_num, time_stepper_pt);
551 // Set the pointer from the element
552 finite_element_pt(element_num)->node_pt(local_node_num) =
554
555 // Get the fractional position of the node
556 finite_element_pt(element_num)
557 ->local_fraction_of_node(local_node_num, s_fraction);
558
559 // Set the position of the node
560 Node_pt[node_count]->x(0) = Xmax;
561 Node_pt[node_count]->x(1) = Ymin;
562 Node_pt[node_count]->x(2) = Zmin;
563
564 // Add the node to the boundaries
565 add_boundary_node(0, Node_pt[node_count]);
566 add_boundary_node(1, Node_pt[node_count]);
567 add_boundary_node(2, Node_pt[node_count]);
568 // Increment the node number
569 node_count++;
570
571 // Do the middle nodes at the plane z = 0
572 for (unsigned l1 = 1; l1 < n_p; l1++)
573 {
574 // First column of nodes is same as neighbouring element
575 finite_element_pt(element_num)->node_pt(l1 * n_p) =
576 finite_element_pt(element_num - 1)->node_pt(l1 * n_p + (n_p - 1));
577
578 // New nodes for other columns
579 for (unsigned l2 = 1; l2 < (n_p - 1); l2++)
580 {
581 // Set the local node number
582 local_node_num = l2 + l1 * n_p;
583
584 // Allocate memory for the nodes
586 finite_element_pt(element_num)
587 ->construct_boundary_node(local_node_num, time_stepper_pt);
588 // Set the pointer from the element
589 finite_element_pt(element_num)->node_pt(local_node_num) =
591
592 // Get the fractional position of the node
593 finite_element_pt(element_num)
594 ->local_fraction_of_node(local_node_num, s_fraction);
595
596 // Set the position of the node
597 Node_pt[node_count]->x(0) =
598 Xmin + el_length[0] * (Nx - 1 + s_fraction[0]);
599 Node_pt[node_count]->x(1) = Ymin + el_length[1] * s_fraction[1];
600 Node_pt[node_count]->x(2) = Zmin;
601
602 // Add the node to the boundary 0
603 add_boundary_node(0, Node_pt[node_count]);
604 // Increment the node number
605 node_count++;
606 }
607
608 // New node for final column
609 // Set the local node number
610 local_node_num = l1 * n_p + (n_p - 1);
611
612 // Allocate memory for node
614 finite_element_pt(element_num)
615 ->construct_boundary_node(local_node_num, time_stepper_pt);
616 // Set the pointer from the element
617 finite_element_pt(element_num)->node_pt(local_node_num) =
619
620 // Get the fractional position of the node
621 finite_element_pt(element_num)
622 ->local_fraction_of_node(local_node_num, s_fraction);
623
624 // Set the position of the node
625 Node_pt[node_count]->x(0) = Xmax;
626 Node_pt[node_count]->x(1) = Ymin + el_length[1] * s_fraction[1];
627 Node_pt[node_count]->x(2) = Zmin;
628
629 // Add the node to the boundaries 0 and 2
630 add_boundary_node(2, Node_pt[node_count]);
631 add_boundary_node(0, Node_pt[node_count]);
632 // Increment the node number
633 node_count++;
634 }
635
636 // Loop over the other node columns in the z direction
637 for (unsigned l3 = 1; l3 < n_p; l3++)
638 {
639 // First column of nodes is same as neighbouring element
640 finite_element_pt(element_num)->node_pt(l3 * n_p * n_p) =
641 finite_element_pt(element_num - 1)->node_pt(l3 * n_p * n_p + (n_p - 1));
642
643 // New nodes for other rows (y=0)
644 for (unsigned l2 = 1; l2 < (n_p - 1); l2++)
645 {
646 // Set the local node number
647 local_node_num = l2 + l3 * n_p * n_p;
648
649 // Allocate memory for the nodes
651 finite_element_pt(element_num)
652 ->construct_boundary_node(local_node_num, time_stepper_pt);
653 // Set the pointer from the element
654 finite_element_pt(element_num)->node_pt(local_node_num) =
656
657 // Get the fractional position of the node
658 finite_element_pt(element_num)
659 ->local_fraction_of_node(local_node_num, s_fraction);
660
661 // Set the position of the node
662 Node_pt[node_count]->x(0) =
663 Xmin + el_length[0] * (Nx - 1 + s_fraction[0]);
664 Node_pt[node_count]->x(1) = Ymin;
665 Node_pt[node_count]->x(2) = Zmin + el_length[2] * s_fraction[2];
666
667 // Add the node to the boundary 1
668 add_boundary_node(1, Node_pt[node_count]);
669 // Increment the node number
670 node_count++;
671 }
672
673 // Last node of the row (y=0)
674 // Set the local node number
675 local_node_num = n_p - 1 + l3 * n_p * n_p;
676
677 // Allocate memory for the nodes
679 finite_element_pt(element_num)
680 ->construct_boundary_node(local_node_num, time_stepper_pt);
681 // Set the pointer from the element
682 finite_element_pt(element_num)->node_pt(local_node_num) =
684
685 // Get the fractional position of the node
686 finite_element_pt(element_num)
687 ->local_fraction_of_node(local_node_num, s_fraction);
688
689 // Set the position of the node
690 Node_pt[node_count]->x(0) = Xmax;
691 Node_pt[node_count]->x(1) = Ymin;
692 Node_pt[node_count]->x(2) = Zmin + el_length[2] * s_fraction[2];
693
694 // Add the node to the boundary 1 and 2
695 add_boundary_node(1, Node_pt[node_count]);
696 add_boundary_node(2, Node_pt[node_count]);
697 // Increment the node number
698 node_count++;
699
700 // Do the rest of the nodes
701 for (unsigned l1 = 1; l1 < n_p; l1++)
702 {
703 // First column of nodes is same as neighbouring element
704 finite_element_pt(element_num)->node_pt(l1 * n_p + l3 * n_p * n_p) =
705 finite_element_pt(element_num - 1)
706 ->node_pt(l1 * n_p + (n_p - 1) + l3 * n_p * n_p);
707
708 // New nodes for other columns
709 for (unsigned l2 = 1; l2 < (n_p - 1); l2++)
710 {
711 // Set the local node number
712 local_node_num = l2 + l1 * n_p + l3 * n_p * n_p;
713
714 // Allocate memory for the nodes
716 finite_element_pt(element_num)
717 ->construct_node(local_node_num, time_stepper_pt);
718 // Set the pointer from the element
719 finite_element_pt(element_num)->node_pt(local_node_num) =
721
722 // Get the fractional position of the node
723 finite_element_pt(element_num)
724 ->local_fraction_of_node(local_node_num, s_fraction);
725
726 // Set the position of the node
727 Node_pt[node_count]->x(0) =
728 Xmin + el_length[0] * (Nx - 1 + s_fraction[0]);
729 Node_pt[node_count]->x(1) = Ymin + el_length[1] * s_fraction[1];
730 Node_pt[node_count]->x(2) = Zmin + el_length[2] * s_fraction[2];
731
732 // No boundaries
733
734 // Increment the node number
735 node_count++;
736 }
737
738 // Last nodes (at the surface x = Lx)
739 // Set the local nod number
740 local_node_num = l1 * n_p + (n_p - 1) + l3 * n_p * n_p;
741 // Allocate memory for the nodes
743 finite_element_pt(element_num)
744 ->construct_boundary_node(local_node_num, time_stepper_pt);
745 // Set the pointer from the element
746 finite_element_pt(element_num)->node_pt(local_node_num) =
748
749 // Get the fractional position of the node
750 finite_element_pt(element_num)
751 ->local_fraction_of_node(local_node_num, s_fraction);
752
753 // Set the position of the node
754 Node_pt[node_count]->x(0) = Xmax;
755 Node_pt[node_count]->x(1) = Ymin + el_length[1] * s_fraction[1];
756 Node_pt[node_count]->x(2) = Zmin + el_length[2] * s_fraction[2];
757
758 // Add the node to the boundary 2
759 add_boundary_node(2, Node_pt[node_count]);
760 // Increment the node number
761 node_count++;
762 }
763 }
764
765 // ALL CENTRAL ELEMENT ROWS (WE ARE STILL IN THE LAYER z=0)
766 //------------------------
767
768 // Loop over remaining element rows
769 for (unsigned i = 1; i < (Ny - 1); i++)
770 {
771 // Set the first element in the row
772
773 // Allocate memory for element (z = 0) (x =0)
774 element_num = Nx * i;
775 Element_pt[element_num] = new ELEMENT;
776
777 // The first row of nodes is copied from the element below (at z=0)
778 for (unsigned l2 = 0; l2 < n_p; l2++)
779 {
780 finite_element_pt(element_num)->node_pt(l2) =
781 finite_element_pt(element_num - Nx)->node_pt((n_p - 1) * n_p + l2);
782 }
783
784 // Other rows are new nodes
785 for (unsigned l1 = 1; l1 < n_p; l1++)
786 {
787 // First column of nodes
788 // Set the local node number
790
791 // Allocate memory for the fist node in the x direction (x=0)
793 finite_element_pt(element_num)
794 ->construct_boundary_node(local_node_num, time_stepper_pt);
795 // Set the pointer from the element
796 finite_element_pt(element_num)->node_pt(local_node_num) =
798
799 // Get the fractional position of the node
800 finite_element_pt(element_num)
801 ->local_fraction_of_node(local_node_num, s_fraction);
802
803 // Set the position of the node
804 Node_pt[node_count]->x(0) = Xmin;
805 Node_pt[node_count]->x(1) = Ymin + el_length[1] * (i + s_fraction[1]);
806 Node_pt[node_count]->x(2) = Zmin;
807
808 // Add the node to the boundaries 4 and 0
809 add_boundary_node(0, Node_pt[node_count]);
810 add_boundary_node(4, Node_pt[node_count]);
811 // Increment the node number
812 node_count++;
813
814 // Now do the other columns
815 for (unsigned l2 = 1; l2 < n_p; l2++)
816 {
817 // Set the local node number
818 local_node_num = l2 + l1 * n_p;
819
820 // Allocate memory for node
822 finite_element_pt(element_num)
823 ->construct_boundary_node(local_node_num, time_stepper_pt);
824 // Set the pointer from the element
825 finite_element_pt(element_num)->node_pt(local_node_num) =
827
828 // Get the fractional position of the node
829 finite_element_pt(element_num)
830 ->local_fraction_of_node(local_node_num, s_fraction);
831
832 // Set the position of the node
833 Node_pt[node_count]->x(0) = Xmin + el_length[0] * s_fraction[0];
834 Node_pt[node_count]->x(1) = Ymin + el_length[1] * (i + s_fraction[1]);
835 Node_pt[node_count]->x(2) = Zmin;
836
837 // Add the node to the boundary and 0
838 add_boundary_node(0, Node_pt[node_count]);
839 // Increment the node number
840 node_count++;
841 }
842 }
843
844 // As always we extend now this element to the third direction
845 for (unsigned l3 = 1; l3 < n_p; l3++)
846 {
847 // The first row of nodes is copied from the element below (at z=0)
848 for (unsigned l2 = 0; l2 < n_p; l2++)
849 {
850 finite_element_pt(element_num)->node_pt(l2 + l3 * n_p * n_p) =
851 finite_element_pt(element_num - Nx)
852 ->node_pt((n_p - 1) * n_p + l2 + l3 * n_p * n_p);
853 }
854
855 // Other rows are new nodes (first the nodes for which x=0)
856 for (unsigned l1 = 1; l1 < n_p; l1++)
857 {
858 // First column of nodes
859 // Set the local node number
860 local_node_num = l1 * n_p + l3 * n_p * n_p;
861
862 // Allocate memory for node
864 finite_element_pt(element_num)
865 ->construct_boundary_node(local_node_num, time_stepper_pt);
866 // Set the pointer from the element
867 finite_element_pt(element_num)->node_pt(local_node_num) =
869
870 // Get the fractional position of the node
871 finite_element_pt(element_num)
872 ->local_fraction_of_node(local_node_num, s_fraction);
873
874 // Set the position of the node
875 Node_pt[node_count]->x(0) = Xmin;
876 Node_pt[node_count]->x(1) = Ymin + el_length[1] * (i + s_fraction[1]);
877 Node_pt[node_count]->x(2) = Zmin + el_length[2] * s_fraction[2];
878
879 // Add the node to the boundary 4
880 add_boundary_node(4, Node_pt[node_count]);
881
882 // Increment the node number
883 node_count++;
884
885 // Now do the other columns (we extend to the rest of the nodes)
886 for (unsigned l2 = 1; l2 < n_p; l2++)
887 {
888 // Set the local node number
889 local_node_num = l2 + l1 * n_p + n_p * n_p * l3;
890
891 // Allocate memory for node
893 finite_element_pt(element_num)
894 ->construct_node(local_node_num, time_stepper_pt);
895 // Set the pointer from the element
896 finite_element_pt(element_num)->node_pt(local_node_num) =
898
899 // Get the fractional position of the node
900 finite_element_pt(element_num)
901 ->local_fraction_of_node(local_node_num, s_fraction);
902
903 // Set the position of the node
904 Node_pt[node_count]->x(0) = Xmin + el_length[0] * s_fraction[0];
905 Node_pt[node_count]->x(1) =
906 Ymin + el_length[1] * (i + s_fraction[1]);
907 Node_pt[node_count]->x(2) = Zmin + el_length[2] * s_fraction[2];
908
909 // No boundaries
910
911 // Increment the node number
912 node_count++;
913 }
914 }
915 }
916
917 // Now loop over the rest of the elements in the row, apart from the last
918 for (unsigned j = 1; j < (Nx - 1); j++)
919 {
920 // Allocate memory for new element
921 element_num = Nx * i + j;
922 Element_pt[element_num] = new ELEMENT;
923
924 // The first row is copied from the lower element
925 for (unsigned l2 = 0; l2 < n_p; l2++)
926 {
927 finite_element_pt(element_num)->node_pt(l2) =
928 finite_element_pt(element_num - Nx)->node_pt((n_p - 1) * n_p + l2);
929 }
930
931 for (unsigned l1 = 1; l1 < n_p; l1++)
932 {
933 // First column is same as neighbouring element
934 finite_element_pt(element_num)->node_pt(l1 * n_p) =
935 finite_element_pt(element_num - 1)->node_pt(l1 * n_p + (n_p - 1));
936
937 // New nodes for other columns
938 for (unsigned l2 = 1; l2 < n_p; l2++)
939 {
940 // Set local node number
941 local_node_num = l1 * n_p + l2;
942
943 // Allocate memory for the nodes
945 finite_element_pt(element_num)
946 ->construct_boundary_node(local_node_num, time_stepper_pt);
947 // Set the pointer
948 finite_element_pt(element_num)->node_pt(local_node_num) =
950
951 // Get the fractional position of the node
952 finite_element_pt(element_num)
953 ->local_fraction_of_node(local_node_num, s_fraction);
954
955 // Set the position of the node
956 Node_pt[node_count]->x(0) =
957 Xmin + el_length[0] * (j + s_fraction[0]);
958 Node_pt[node_count]->x(1) =
959 Ymin + el_length[1] * (i + s_fraction[1]);
960 Node_pt[node_count]->x(2) = Zmin;
961
962 // Add the node to the boundary and 0
963 add_boundary_node(0, Node_pt[node_count]);
964 // Increment the node number
965 node_count++;
966 }
967 }
968
969 // We extend to the third dimension
970 for (unsigned l3 = 1; l3 < n_p; l3++)
971 {
972 // The first row is copied from the lower element
973
974 for (unsigned l2 = 0; l2 < n_p; l2++)
975 {
976 finite_element_pt(element_num)->node_pt(l2 + l3 * n_p * n_p) =
977 finite_element_pt(element_num - Nx)
978 ->node_pt((n_p - 1) * n_p + l2 + l3 * n_p * n_p);
979 }
980
981 for (unsigned l1 = 1; l1 < n_p; l1++)
982 {
983 // First column is same as neighbouring element
984 finite_element_pt(element_num)->node_pt(l1 * n_p + l3 * n_p * n_p) =
985 finite_element_pt(element_num - 1)
986 ->node_pt(l1 * n_p + l3 * n_p * n_p + (n_p - 1));
987
988 // New nodes for other columns
989 for (unsigned l2 = 1; l2 < n_p; l2++)
990 {
991 // Set the local node number
992 local_node_num = l1 * n_p + l2 + l3 * n_p * n_p;
993
994 // Allocate memory for the nodes
996 finite_element_pt(element_num)
997 ->construct_node(local_node_num, time_stepper_pt);
998 // Set the pointer
999 finite_element_pt(element_num)->node_pt(local_node_num) =
1001
1002 // Get the fractional position of the node
1003 finite_element_pt(element_num)
1004 ->local_fraction_of_node(local_node_num, s_fraction);
1005
1006 // Set the position of the node
1007 Node_pt[node_count]->x(0) =
1008 Xmin + el_length[0] * (j + s_fraction[0]);
1009 Node_pt[node_count]->x(1) =
1010 Ymin + el_length[1] * (i + s_fraction[1]);
1011 Node_pt[node_count]->x(2) = Zmin + el_length[2] * s_fraction[2];
1012
1013 // No boundaries
1014
1015 // Increment the node number
1016 node_count++;
1017 }
1018 }
1019 }
1020
1021 } // End of loop over elements in row
1022
1023 // Do final element in row
1024
1025 // Allocate memory for element
1026 element_num = Nx * i + Nx - 1;
1027 Element_pt[element_num] = new ELEMENT;
1028
1029 // We begin with z =0
1030 // The first row is copied from the lower element
1031 for (unsigned l2 = 0; l2 < n_p; l2++)
1032 {
1033 finite_element_pt(element_num)->node_pt(l2) =
1034 finite_element_pt(element_num - Nx)->node_pt((n_p - 1) * n_p + l2);
1035 }
1036
1037 for (unsigned l1 = 1; l1 < n_p; l1++)
1038 {
1039 // First column is same as neighbouring element
1040 finite_element_pt(element_num)->node_pt(l1 * n_p) =
1041 finite_element_pt(element_num - 1)->node_pt(l1 * n_p + (n_p - 1));
1042
1043 // Middle nodes
1044 for (unsigned l2 = 1; l2 < (n_p - 1); l2++)
1045 {
1046 // Set local node number
1047 local_node_num = l1 * n_p + l2;
1048
1049 // Allocate memory for node
1051 finite_element_pt(element_num)
1052 ->construct_boundary_node(local_node_num, time_stepper_pt);
1053 // Set the pointer
1054 finite_element_pt(element_num)->node_pt(local_node_num) =
1056
1057 // Get the fractional position of the node
1058 finite_element_pt(element_num)
1059 ->local_fraction_of_node(local_node_num, s_fraction);
1060
1061 // Set the position of the node
1062 Node_pt[node_count]->x(0) =
1063 Xmin + el_length[0] * (Nx - 1 + s_fraction[0]);
1064 Node_pt[node_count]->x(1) = Ymin + el_length[1] * (i + s_fraction[1]);
1065 Node_pt[node_count]->x(2) = Zmin;
1066
1067 // Add the node to the boundary and 0
1068 add_boundary_node(0, Node_pt[node_count]);
1069
1070 // Increment the node number
1071 node_count++;
1072 }
1073
1074 // Final node
1075
1076 // Set the local node number
1077 local_node_num = l1 * n_p + (n_p - 1);
1078
1079 // Allocate memory for node
1081 finite_element_pt(element_num)
1082 ->construct_boundary_node(local_node_num, time_stepper_pt);
1083 // Set the pointer
1084 finite_element_pt(element_num)->node_pt(local_node_num) =
1086
1087 // Get the fractional position of the node
1088 finite_element_pt(element_num)
1089 ->local_fraction_of_node(local_node_num, s_fraction);
1090
1091 // Set the position of the node
1092 Node_pt[node_count]->x(0) = Xmax;
1093 Node_pt[node_count]->x(1) = Ymin + el_length[1] * (i + s_fraction[1]);
1094 Node_pt[node_count]->x(2) = Zmin;
1095
1096 // Add the node to the boundaries - and 1
1097 add_boundary_node(0, Node_pt[node_count]);
1098 add_boundary_node(2, Node_pt[node_count]);
1099
1100 // Increment the node number
1101 node_count++;
1102
1103 } // End of loop over rows of nodes in the element
1104
1105 // We go to the third dimension
1106 for (unsigned l3 = 1; l3 < n_p; l3++)
1107 {
1108 // The first row is copied from the lower element
1109 for (unsigned l2 = 0; l2 < n_p; l2++)
1110 {
1111 finite_element_pt(element_num)->node_pt(l2 + l3 * n_p * n_p) =
1112 finite_element_pt(element_num - Nx)
1113 ->node_pt((n_p - 1) * n_p + l2 + l3 * n_p * n_p);
1114 }
1115
1116 for (unsigned l1 = 1; l1 < n_p; l1++)
1117 {
1118 // First column is same as neighbouring element
1119 finite_element_pt(element_num)->node_pt(l1 * n_p + l3 * n_p * n_p) =
1120 finite_element_pt(element_num - 1)
1121 ->node_pt(l1 * n_p + (n_p - 1) + l3 * n_p * n_p);
1122
1123 // Middle nodes
1124 for (unsigned l2 = 1; l2 < (n_p - 1); l2++)
1125 {
1126 // Set the local node number
1127 local_node_num = l1 * n_p + l2 + l3 * n_p * n_p;
1128
1129 // Allocate memory for node
1131 finite_element_pt(element_num)
1132 ->construct_node(local_node_num, time_stepper_pt);
1133 // Set the pointer
1134 finite_element_pt(element_num)->node_pt(local_node_num) =
1136
1137 // Get the fractional position of the node
1138 finite_element_pt(element_num)
1139 ->local_fraction_of_node(local_node_num, s_fraction);
1140
1141 // Set the position of the node
1142 Node_pt[node_count]->x(0) =
1143 Xmin + el_length[0] * (Nx - 1 + s_fraction[0]);
1144 Node_pt[node_count]->x(1) =
1145 Ymin + el_length[1] * (i + s_fraction[1]);
1146 Node_pt[node_count]->x(2) = Zmin + el_length[2] * s_fraction[2];
1147
1148 // No boundaries
1149
1150 // Increment the node number
1151 node_count++;
1152 }
1153
1154 // Final node
1155 // Set the local node number
1156 local_node_num = l1 * n_p + (n_p - 1) + l3 * n_p * n_p;
1157
1158 // Allocate memory for node
1160 finite_element_pt(element_num)
1161 ->construct_boundary_node(local_node_num, time_stepper_pt);
1162 // Set the pointer
1163 finite_element_pt(element_num)->node_pt(local_node_num) =
1165
1166 // Get the fractional position of the node
1167 finite_element_pt(element_num)
1168 ->local_fraction_of_node(local_node_num, s_fraction);
1169
1170 // Set the position of the node
1171 Node_pt[node_count]->x(0) = Xmax;
1172 Node_pt[node_count]->x(1) = Ymin + el_length[1] * (i + s_fraction[1]);
1173 Node_pt[node_count]->x(2) = Zmin + el_length[2] * s_fraction[2];
1174
1175 // Add the node to the boundary 2
1176 add_boundary_node(2, Node_pt[node_count]);
1177 // Increment the node number
1178 node_count++;
1179 } // End of loop over rows of nodes in the element
1180
1181 } // End of the 3dimension loop
1182
1183 } // End of loop over rows of elements
1184
1185 // FINAL ELEMENT ROW (IN THE z=0 LAYER)
1186 //=================
1187
1188 // FIRST ELEMENT IN UPPER ROW (upper left corner)
1189 //----------------------------------------------
1190
1191 // Allocate memory for element
1192 element_num = Nx * (Ny - 1);
1193 Element_pt[element_num] = new ELEMENT;
1194 // We begin with all the nodes for which z=0
1195 // The first row of nodes is copied from the element below
1196 for (unsigned l2 = 0; l2 < n_p; l2++)
1197 {
1198 finite_element_pt(element_num)->node_pt(l2) =
1199 finite_element_pt(element_num - Nx)->node_pt((n_p - 1) * n_p + l2);
1200 }
1201
1202 // Second row of nodes
1203 // First column of nodes
1204 for (unsigned l1 = 1; l1 < (n_p - 1); l1++)
1205 {
1206 // Set the local node number
1207 local_node_num = n_p * l1;
1208
1209 // Allocate memory for node
1211 finite_element_pt(element_num)
1212 ->construct_boundary_node(local_node_num, time_stepper_pt);
1213 // Set the pointer from the element
1214 finite_element_pt(element_num)->node_pt(local_node_num) =
1216
1217 // Get the fractional position of the node
1218 finite_element_pt(element_num)
1219 ->local_fraction_of_node(local_node_num, s_fraction);
1220
1221 // Set the position of the node
1222 Node_pt[node_count]->x(0) = Xmin;
1223 Node_pt[node_count]->x(1) =
1224 Ymin + el_length[1] * (Ny - 1 + s_fraction[1]);
1225 Node_pt[node_count]->x(2) = Zmin;
1226
1227 // Add the node to the boundaries 4 and 0
1228 add_boundary_node(0, Node_pt[node_count]);
1229 add_boundary_node(4, Node_pt[node_count]);
1230 // Increment the node number
1231 node_count++;
1232
1233 // Now do the other columns
1234 for (unsigned l2 = 1; l2 < n_p; l2++)
1235 {
1236 // Set the local node number
1237 local_node_num = n_p * l1 + l2;
1238
1239 // Allocate memory for node
1241 finite_element_pt(element_num)
1242 ->construct_boundary_node(local_node_num, time_stepper_pt);
1243 // Set the pointer from the element
1244 finite_element_pt(element_num)->node_pt(local_node_num) =
1246
1247 // Get the fractional position of the node
1248 finite_element_pt(element_num)
1249 ->local_fraction_of_node(local_node_num, s_fraction);
1250
1251 // Set the position of the node
1252 Node_pt[node_count]->x(0) = Xmin + el_length[0] * s_fraction[0];
1253 Node_pt[node_count]->x(1) =
1254 Ymin + el_length[1] * (Ny - 1 + s_fraction[1]);
1255 Node_pt[node_count]->x(2) = Zmin;
1256
1257 // Add the node to the boundary 0
1258 add_boundary_node(0, Node_pt[node_count]);
1259 // Increment the node number
1260 node_count++;
1261 }
1262 }
1263
1264 // Final row of nodes
1265 // First column of nodes
1266 // Top left node
1267 // Set local node number
1268 local_node_num = n_p * (n_p - 1);
1269 // Allocate memory for node
1271 finite_element_pt(element_num)
1272 ->construct_boundary_node(local_node_num, time_stepper_pt);
1273 // Set the pointer from the element
1274 finite_element_pt(element_num)->node_pt(local_node_num) =
1276
1277 // Get the fractional position of the node
1278 finite_element_pt(element_num)
1279 ->local_fraction_of_node(local_node_num, s_fraction);
1280
1281 // Set the position of the node
1282 Node_pt[node_count]->x(0) = Xmin;
1283 Node_pt[node_count]->x(1) = Ymax;
1284 Node_pt[node_count]->x(2) = Zmin;
1285
1286 // Add the node to the boundaries 0,3 and 4
1287 add_boundary_node(0, Node_pt[node_count]);
1288 add_boundary_node(3, Node_pt[node_count]);
1289 add_boundary_node(4, Node_pt[node_count]);
1290
1291 // Increment the node number
1292 node_count++;
1293
1294 // Now do the other columns
1295 for (unsigned l2 = 1; l2 < n_p; l2++)
1296 {
1297 // Set the local node number
1298 local_node_num = n_p * (n_p - 1) + l2;
1299 // Allocate memory for the node
1301 finite_element_pt(element_num)
1302 ->construct_boundary_node(local_node_num, time_stepper_pt);
1303 // Set the pointer from the element
1304 finite_element_pt(element_num)->node_pt(local_node_num) =
1306
1307 // Get the fractional position of the node
1308 finite_element_pt(element_num)
1309 ->local_fraction_of_node(local_node_num, s_fraction);
1310
1311 // Set the position of the node
1312 Node_pt[node_count]->x(0) = Xmin + el_length[0] * s_fraction[0];
1313 Node_pt[node_count]->x(1) = Ymax;
1314 Node_pt[node_count]->x(2) = Zmin;
1315
1316 // Add the node to the boundaries
1317 add_boundary_node(0, Node_pt[node_count]);
1318 add_boundary_node(3, Node_pt[node_count]);
1319 // Increment the node number
1320 node_count++;
1321 }
1322
1323 // We jump to the third dimension
1324 for (unsigned l3 = 1; l3 < n_p; l3++)
1325 {
1326 // The first row of nodes is copied from the element below
1327 for (unsigned l2 = 0; l2 < n_p; l2++)
1328 {
1329 finite_element_pt(element_num)->node_pt(l2 + l3 * n_p * n_p) =
1330 finite_element_pt(element_num - Nx)
1331 ->node_pt((n_p - 1) * n_p + l2 + l3 * n_p * n_p);
1332 }
1333
1334 // Second row of nodes
1335 // First column of nodes
1336 for (unsigned l1 = 1; l1 < (n_p - 1); l1++)
1337 {
1338 // Set the local node number
1339 local_node_num = n_p * l1 + l3 * n_p * n_p;
1340
1341 // Allocate memory for node
1343 finite_element_pt(element_num)
1344 ->construct_boundary_node(local_node_num, time_stepper_pt);
1345 // Set the pointer from the element
1346 finite_element_pt(element_num)->node_pt(local_node_num) =
1348
1349 // Get the fractional position of the node
1350 finite_element_pt(element_num)
1351 ->local_fraction_of_node(local_node_num, s_fraction);
1352
1353 // Set the position of the node
1354 Node_pt[node_count]->x(0) = Xmin;
1355 Node_pt[node_count]->x(1) =
1356 Ymin + el_length[1] * (Ny - 1 + s_fraction[1]);
1357 Node_pt[node_count]->x(2) = Zmin + el_length[2] * s_fraction[2];
1358
1359 // Add the node to the boundary 4
1360 add_boundary_node(4, Node_pt[node_count]);
1361 // Increment the node number
1362 node_count++;
1363
1364 // Now do the other columns
1365 for (unsigned l2 = 1; l2 < n_p; l2++)
1366 {
1367 // Set local node number
1368 local_node_num = n_p * l1 + l2 + l3 * n_p * n_p;
1369
1370 // Allocate memory for node
1372 finite_element_pt(element_num)
1373 ->construct_node(local_node_num, time_stepper_pt);
1374 // Set the pointer from the element
1375 finite_element_pt(element_num)->node_pt(local_node_num) =
1377
1378 // Get the fractional position of the node
1379 finite_element_pt(element_num)
1380 ->local_fraction_of_node(local_node_num, s_fraction);
1381
1382 // Set the position of the node
1383 Node_pt[node_count]->x(0) = Xmin + el_length[0] * s_fraction[0];
1384 Node_pt[node_count]->x(1) =
1385 Ymin + el_length[1] * (Ny - 1 + s_fraction[1]);
1386 Node_pt[node_count]->x(2) = Zmin + el_length[2] * s_fraction[2];
1387
1388 // No boundaries
1389
1390 // Increment the node number
1391 node_count++;
1392 }
1393 }
1394
1395 // Final row of nodes
1396 // First column of nodes
1397 // Top left node
1398 local_node_num = n_p * (n_p - 1) + l3 * n_p * n_p;
1399 // Allocate memory for node
1401 finite_element_pt(element_num)
1402 ->construct_boundary_node(local_node_num, time_stepper_pt);
1403 // Set the pointer from the element
1404 finite_element_pt(element_num)->node_pt(local_node_num) =
1406
1407 // Get the fractional position of the node
1408 finite_element_pt(element_num)
1409 ->local_fraction_of_node(local_node_num, s_fraction);
1410
1411 // Set the position of the node
1412 Node_pt[node_count]->x(0) = Xmin;
1413 Node_pt[node_count]->x(1) = Ymax;
1414 Node_pt[node_count]->x(2) = Zmin + el_length[2] * s_fraction[2];
1415
1416 // Add the node to the boundaries
1417 add_boundary_node(3, Node_pt[node_count]);
1418 add_boundary_node(4, Node_pt[node_count]);
1419
1420 // Increment the node number
1421 node_count++;
1422
1423 // Now do the other columns
1424 for (unsigned l2 = 1; l2 < n_p; l2++)
1425 {
1426 local_node_num = n_p * (n_p - 1) + l2 + l3 * n_p * n_p;
1427 // Allocate memory for the node
1429 finite_element_pt(element_num)
1430 ->construct_boundary_node(local_node_num, time_stepper_pt);
1431 // Set the pointer from the element
1432 finite_element_pt(element_num)->node_pt(local_node_num) =
1434
1435 // Get the fractional position of the node
1436 finite_element_pt(element_num)
1437 ->local_fraction_of_node(local_node_num, s_fraction);
1438
1439 // Set the position of the node
1440 Node_pt[node_count]->x(0) = Xmin + el_length[0] * s_fraction[0];
1441 Node_pt[node_count]->x(1) = Ymax;
1442 Node_pt[node_count]->x(2) = Zmin + el_length[2] * s_fraction[2];
1443
1444 // Add the node to the boundary 3
1445 add_boundary_node(3, Node_pt[node_count]);
1446
1447 // Increment the node number
1448 node_count++;
1449 }
1450 }
1451
1452 // Now loop over the rest of the elements in the row, apart from the last
1453 // (first plane z = 0)
1454 for (unsigned j = 1; j < (Nx - 1); j++)
1455 {
1456 // Allocate memory for element
1457 element_num = Nx * (Ny - 1) + j;
1458 Element_pt[element_num] = new ELEMENT;
1459 // The first row is copied from the lower element
1460 for (unsigned l2 = 0; l2 < n_p; l2++)
1461 {
1462 finite_element_pt(element_num)->node_pt(l2) =
1463 finite_element_pt(element_num - Nx)->node_pt((n_p - 1) * n_p + l2);
1464 }
1465
1466 // Second rows
1467 for (unsigned l1 = 1; l1 < (n_p - 1); l1++)
1468 {
1469 // First column is same as neighbouring element
1470 finite_element_pt(element_num)->node_pt(n_p * l1) =
1471 finite_element_pt(element_num - 1)->node_pt(n_p * l1 + (n_p - 1));
1472
1473 // New nodes for other columns
1474 for (unsigned l2 = 1; l2 < n_p; l2++)
1475 {
1476 local_node_num = n_p * l1 + l2;
1477 // Allocate memory for the node
1479 finite_element_pt(element_num)
1480 ->construct_boundary_node(local_node_num, time_stepper_pt);
1481
1482 // Set the pointer
1483 finite_element_pt(element_num)->node_pt(local_node_num) =
1485
1486 // Get the fractional position of the node
1487 finite_element_pt(element_num)
1488 ->local_fraction_of_node(local_node_num, s_fraction);
1489
1490 // Set the position of the node
1491 Node_pt[node_count]->x(0) = Xmin + el_length[0] * (j + s_fraction[0]);
1492 Node_pt[node_count]->x(1) =
1493 Ymin + el_length[1] * (Ny - 1 + s_fraction[1]);
1494 Node_pt[node_count]->x(2) = Zmin;
1495
1496 // Add the node to the boundary
1497 add_boundary_node(0, Node_pt[node_count]);
1498
1499 // Increment the node number
1500 node_count++;
1501 }
1502 }
1503
1504 // Top row
1505 // First column is same as neighbouring element
1506 finite_element_pt(element_num)->node_pt(n_p * (n_p - 1)) =
1507 finite_element_pt(element_num - 1)
1508 ->node_pt(n_p * (n_p - 1) + (n_p - 1));
1509 // New nodes for other columns
1510 for (unsigned l2 = 1; l2 < n_p; l2++)
1511 {
1512 local_node_num = n_p * (n_p - 1) + l2;
1513 // Allocate memory for node
1515 finite_element_pt(element_num)
1516 ->construct_boundary_node(local_node_num, time_stepper_pt);
1517 // Set the pointer
1518 finite_element_pt(element_num)->node_pt(local_node_num) =
1520
1521 // Get the fractional position of the node
1522 finite_element_pt(element_num)
1523 ->local_fraction_of_node(local_node_num, s_fraction);
1524
1525 // Set the position of the node
1526 Node_pt[node_count]->x(0) = Xmin + el_length[0] * (j + s_fraction[0]);
1527 Node_pt[node_count]->x(1) = Ymax;
1528 Node_pt[node_count]->x(2) = Zmin;
1529
1530 // Add the node to the boundary
1531 add_boundary_node(3, Node_pt[node_count]);
1532 add_boundary_node(0, Node_pt[node_count]);
1533
1534 // Increment the node number
1535 node_count++;
1536 }
1537
1538 // Jump in the third dimension
1539
1540 for (unsigned l3 = 1; l3 < n_p; l3++)
1541 {
1542 // The first row is copied from the lower element
1543 for (unsigned l2 = 0; l2 < n_p; l2++)
1544 {
1545 finite_element_pt(element_num)->node_pt(l2 + l3 * n_p * n_p) =
1546 finite_element_pt(element_num - Nx)
1547 ->node_pt((n_p - 1) * n_p + l2 + l3 * n_p * n_p);
1548 }
1549
1550 // Second rows
1551 for (unsigned l1 = 1; l1 < (n_p - 1); l1++)
1552 {
1553 // First column is same as neighbouring element
1554 finite_element_pt(element_num)->node_pt(n_p * l1 + l3 * n_p * n_p) =
1555 finite_element_pt(element_num - 1)
1556 ->node_pt(n_p * l1 + (n_p - 1) + l3 * n_p * n_p);
1557
1558 // New nodes for other columns
1559 for (unsigned l2 = 1; l2 < n_p; l2++)
1560 {
1561 local_node_num = n_p * l1 + l2 + l3 * n_p * n_p;
1562 // Allocate memory for the node
1564 finite_element_pt(element_num)
1565 ->construct_node(local_node_num, time_stepper_pt);
1566
1567 // Set the pointer
1568 finite_element_pt(element_num)->node_pt(local_node_num) =
1570
1571 // Get the fractional position of the node
1572 finite_element_pt(element_num)
1573 ->local_fraction_of_node(local_node_num, s_fraction);
1574
1575 // Set the position of the node
1576 Node_pt[node_count]->x(0) =
1577 Xmin + el_length[0] * (j + s_fraction[0]);
1578 Node_pt[node_count]->x(1) =
1579 Ymin + el_length[1] * (Ny - 1 + s_fraction[1]);
1580 Node_pt[node_count]->x(2) = Zmin + el_length[2] * s_fraction[2];
1581
1582 // No boundaries
1583
1584 // Increment the node number
1585 // add_boundary_node(0,Node_pt[node_count]);
1586 node_count++;
1587 }
1588 }
1589
1590 // Top row
1591 // First column is same as neighbouring element
1592 finite_element_pt(element_num)
1593 ->node_pt(n_p * (n_p - 1) + l3 * n_p * n_p) =
1594 finite_element_pt(element_num - 1)
1595 ->node_pt(n_p * (n_p - 1) + (n_p - 1) + l3 * n_p * n_p);
1596 // New nodes for other columns
1597 for (unsigned l2 = 1; l2 < n_p; l2++)
1598 {
1599 local_node_num = n_p * (n_p - 1) + l2 + l3 * n_p * n_p;
1600 // Allocate memory for node
1602 finite_element_pt(element_num)
1603 ->construct_boundary_node(local_node_num, time_stepper_pt);
1604 // Set the pointer
1605 finite_element_pt(element_num)->node_pt(local_node_num) =
1607
1608 // Get the fractional position of the node
1609 finite_element_pt(element_num)
1610 ->local_fraction_of_node(local_node_num, s_fraction);
1611
1612 // Set the position of the node
1613 Node_pt[node_count]->x(0) = Xmin + el_length[0] * (j + s_fraction[0]);
1614 Node_pt[node_count]->x(1) = Ymax;
1615 Node_pt[node_count]->x(2) = Zmin + el_length[2] * s_fraction[2];
1616
1617 // Add the node to the boundary
1618 add_boundary_node(3, Node_pt[node_count]);
1619
1620 // Increment the node number
1621 node_count++;
1622 }
1623 }
1624
1625 } // End of loop over central elements in row
1626
1627 // FINAL ELEMENT IN ROW (upper right corner) IN LAYER z = 0
1628 //--------------------------------------------------------
1629
1630 // Allocate memory for element
1631 element_num = Nx * (Ny - 1) + Nx - 1;
1632 Element_pt[element_num] = new ELEMENT;
1633
1634 // We work first in the plane z =0
1635 // The first row is copied from the lower element
1636 for (unsigned l2 = 0; l2 < n_p; l2++)
1637 {
1638 finite_element_pt(element_num)->node_pt(l2) =
1639 finite_element_pt(element_num - Nx)->node_pt((n_p - 1) * n_p + l2);
1640 }
1641
1642 // Second rows
1643 for (unsigned l1 = 1; l1 < (n_p - 1); l1++)
1644 {
1645 // First column is same as neighbouring element
1646 finite_element_pt(element_num)->node_pt(n_p * l1) =
1647 finite_element_pt(element_num - 1)->node_pt(n_p * l1 + (n_p - 1));
1648
1649 // Middle nodes
1650 for (unsigned l2 = 1; l2 < (n_p - 1); l2++)
1651 {
1652 local_node_num = n_p * l1 + l2;
1653 // Allocate memory for node
1655 finite_element_pt(element_num)
1656 ->construct_boundary_node(local_node_num, time_stepper_pt);
1657 // Set the pointer
1658 finite_element_pt(element_num)->node_pt(local_node_num) =
1660
1661 // Get the fractional position of the node
1662 finite_element_pt(element_num)
1663 ->local_fraction_of_node(local_node_num, s_fraction);
1664
1665 // Set the position of the node
1666 Node_pt[node_count]->x(0) =
1667 Xmin + el_length[0] * (Nx - 1 + s_fraction[0]);
1668 Node_pt[node_count]->x(1) =
1669 Ymin + el_length[1] * (Ny - 1 + s_fraction[1]);
1670 Node_pt[node_count]->x(2) = Zmin;
1671
1672 // Add the node to the boundary
1673 add_boundary_node(0, Node_pt[node_count]);
1674
1675 // Increment the node number
1676 node_count++;
1677 }
1678
1679 // Final node
1680 local_node_num = n_p * l1 + (n_p - 1);
1681 // Allocate memory for node
1683 finite_element_pt(element_num)
1684 ->construct_boundary_node(local_node_num, time_stepper_pt);
1685 // Set the pointer
1686 finite_element_pt(element_num)->node_pt(local_node_num) =
1688
1689 // Get the fractional position of the node
1690 finite_element_pt(element_num)
1691 ->local_fraction_of_node(local_node_num, s_fraction);
1692
1693 // Set the position of the node
1694 Node_pt[node_count]->x(0) = Xmax;
1695 Node_pt[node_count]->x(1) =
1696 Ymin + el_length[1] * (Ny - 1 + s_fraction[1]);
1697 Node_pt[node_count]->x(2) = Zmin;
1698
1699 // Add the node to the boundaries 0 and 2
1700 add_boundary_node(0, Node_pt[node_count]);
1701 add_boundary_node(2, Node_pt[node_count]);
1702
1703 // Increment the node number
1704 node_count++;
1705
1706 } // End of loop over middle rows
1707
1708 // Final row
1709 // First column is same as neighbouring element
1710 finite_element_pt(element_num)->node_pt(n_p * (n_p - 1)) =
1711 finite_element_pt(element_num - 1)->node_pt(n_p * (n_p - 1) + (n_p - 1));
1712
1713 // Middle nodes
1714 for (unsigned l2 = 1; l2 < (n_p - 1); l2++)
1715 {
1716 local_node_num = n_p * (n_p - 1) + l2;
1717 // Allocate memory for node
1719 finite_element_pt(element_num)
1720 ->construct_boundary_node(local_node_num, time_stepper_pt);
1721 // Set the pointer
1722 finite_element_pt(element_num)->node_pt(local_node_num) =
1724
1725 // Get the fractional position of the node
1726 finite_element_pt(element_num)
1727 ->local_fraction_of_node(local_node_num, s_fraction);
1728
1729 // Set the position of the node
1730 Node_pt[node_count]->x(0) =
1731 Xmin + el_length[0] * (Nx - 1 + s_fraction[0]);
1732 Node_pt[node_count]->x(1) = Ymax;
1733 Node_pt[node_count]->x(2) = Zmin;
1734
1735 // Add the node to the boundaries 0 nd 3
1736 add_boundary_node(0, Node_pt[node_count]);
1737 add_boundary_node(3, Node_pt[node_count]);
1738
1739 // Increment the node number
1740 node_count++;
1741 }
1742
1743 // Final node
1744 // Determine number of values
1745 local_node_num = n_p * (n_p - 1) + (n_p - 1);
1746 // Allocate memory for node
1748 finite_element_pt(element_num)
1749 ->construct_boundary_node(local_node_num, time_stepper_pt);
1750 // Set the pointer
1751 finite_element_pt(element_num)->node_pt(local_node_num) =
1753
1754 // Get the fractional position of the node
1755 finite_element_pt(element_num)
1756 ->local_fraction_of_node(local_node_num, s_fraction);
1757
1758 // Set the position of the node
1759 Node_pt[node_count]->x(0) = Xmax;
1760 Node_pt[node_count]->x(1) = Ymax;
1761 Node_pt[node_count]->x(2) = Zmin;
1762
1763 // Add the node to the boundaries 0,2 and 3
1764 add_boundary_node(0, Node_pt[node_count]);
1765 add_boundary_node(2, Node_pt[node_count]);
1766 add_boundary_node(3, Node_pt[node_count]);
1767
1768 // Increment the node number
1769 node_count++;
1770
1771 // We jump to the third dimension
1772
1773 for (unsigned l3 = 1; l3 < n_p; l3++)
1774 {
1775 // The first row is copied from the lower element
1776 for (unsigned l2 = 0; l2 < n_p; l2++)
1777 {
1778 finite_element_pt(element_num)->node_pt(l2 + l3 * n_p * n_p) =
1779 finite_element_pt(element_num - Nx)
1780 ->node_pt((n_p - 1) * n_p + l2 + l3 * n_p * n_p);
1781 }
1782
1783 // Second rows
1784 for (unsigned l1 = 1; l1 < (n_p - 1); l1++)
1785 {
1786 // First column is same as neighbouring element
1787 finite_element_pt(element_num)->node_pt(n_p * l1 + l3 * n_p * n_p) =
1788 finite_element_pt(element_num - 1)
1789 ->node_pt(n_p * l1 + (n_p - 1) + l3 * n_p * n_p);
1790
1791 // Middle nodes
1792 for (unsigned l2 = 1; l2 < (n_p - 1); l2++)
1793 {
1794 // Determine number of values
1795 local_node_num = n_p * l1 + l2 + l3 * n_p * n_p;
1796 // Allocate memory for node
1798 finite_element_pt(element_num)
1799 ->construct_node(local_node_num, time_stepper_pt);
1800 // Set the pointer
1801 finite_element_pt(element_num)->node_pt(local_node_num) =
1803
1804 // Get the fractional position of the node
1805 finite_element_pt(element_num)
1806 ->local_fraction_of_node(local_node_num, s_fraction);
1807
1808 // Set the position of the node
1809 Node_pt[node_count]->x(0) =
1810 Xmin + el_length[0] * (Nx - 1 + s_fraction[0]);
1811 Node_pt[node_count]->x(1) =
1812 Ymin + el_length[1] * (Ny - 1 + s_fraction[1]);
1813 Node_pt[node_count]->x(2) = Zmin + el_length[2] * s_fraction[2];
1814
1815 // No boundaries
1816
1817 // Increment the node number
1818 node_count++;
1819 }
1820
1821 // Final node
1822 // Determine number of values
1823 local_node_num = n_p * l1 + (n_p - 1) + l3 * n_p * n_p;
1824 // Allocate memory for node
1826 finite_element_pt(element_num)
1827 ->construct_boundary_node(local_node_num, time_stepper_pt);
1828 // Set the pointer
1829 finite_element_pt(element_num)->node_pt(local_node_num) =
1831
1832 // Get the fractional position of the node
1833 finite_element_pt(element_num)
1834 ->local_fraction_of_node(local_node_num, s_fraction);
1835
1836 // Set the position of the node
1837 Node_pt[node_count]->x(0) = Xmax;
1838 Node_pt[node_count]->x(1) =
1839 Ymin + el_length[1] * (Ny - 1 + s_fraction[1]);
1840 Node_pt[node_count]->x(2) = Zmin + el_length[2] * s_fraction[2];
1841
1842 // Add the node to the boundary 2
1843 add_boundary_node(2, Node_pt[node_count]);
1844 // Increment the node number
1845 node_count++;
1846
1847 } // End of loop over middle rows
1848
1849 // Final row
1850 // First column is same as neighbouring element
1851 finite_element_pt(element_num)
1852 ->node_pt(n_p * (n_p - 1) + l3 * n_p * n_p) =
1853 finite_element_pt(element_num - 1)
1854 ->node_pt(n_p * (n_p - 1) + (n_p - 1) + l3 * n_p * n_p);
1855
1856 // Middle nodes
1857 for (unsigned l2 = 1; l2 < (n_p - 1); l2++)
1858 {
1859 // Determine number of values
1860 local_node_num = n_p * (n_p - 1) + l2 + l3 * n_p * n_p;
1861 // Allocate memory for node
1863 finite_element_pt(element_num)
1864 ->construct_boundary_node(local_node_num, time_stepper_pt);
1865 // Set the pointer
1866 finite_element_pt(element_num)->node_pt(local_node_num) =
1868
1869 // Get the fractional position of the node
1870 finite_element_pt(element_num)
1871 ->local_fraction_of_node(local_node_num, s_fraction);
1872
1873 // Set the position of the node
1874 Node_pt[node_count]->x(0) =
1875 Xmin + el_length[0] * (Nx - 1 + s_fraction[0]);
1876 Node_pt[node_count]->x(1) = Ymax;
1877 Node_pt[node_count]->x(2) = Zmin + el_length[2] * s_fraction[2];
1878
1879 // Add the node to the boundary 3
1880 add_boundary_node(3, Node_pt[node_count]);
1881 // Increment the node number
1882 node_count++;
1883 }
1884
1885 // Final node
1886 // Determine number of values
1887 local_node_num = n_p * (n_p - 1) + (n_p - 1) + l3 * n_p * n_p;
1888 // Allocate memory for node
1890 finite_element_pt(element_num)
1891 ->construct_boundary_node(local_node_num, time_stepper_pt);
1892 // Set the pointer
1893 finite_element_pt(element_num)->node_pt(local_node_num) =
1895
1896 // Get the fractional position of the node
1897 finite_element_pt(element_num)
1898 ->local_fraction_of_node(local_node_num, s_fraction);
1899
1900 // Set the position of the node
1901 Node_pt[node_count]->x(0) = Xmax;
1902 Node_pt[node_count]->x(1) = Ymax;
1903 Node_pt[node_count]->x(2) = Zmin + el_length[2] * s_fraction[2];
1904
1905 // Add the node to the boundaries 2 and 3
1906 add_boundary_node(2, Node_pt[node_count]);
1907 add_boundary_node(3, Node_pt[node_count]);
1908
1909 // Increment the node number
1910 node_count++;
1911 }
1912
1913 // END OF THE FIRST LAYER
1914
1915 //----------------------------------------------------------------------------------------------------------------------------
1916 // ***************************************NOW WE MAKE ALL THE INTREMEDIATE
1917 // LAYERS**********************************************
1918 //----------------------------------------------------------------------------------------------------------------------------
1919
1920 for (unsigned k = 1; k < (Nz - 1); k++) // good loop for the diferent layers
1921 // for(unsigned k=1;k<Nz;k++) // bad loop for testing the hole mesh but the
1922 // last layer
1923 {
1924 // FIRST ELEMENT OF THE LAYER
1925 //----------------------------------
1926
1927 element_num = k * Nx * Ny;
1928 Element_pt[element_num] = new ELEMENT;
1929
1930 // The lowest nodes are copied from the lower element
1931 for (unsigned l1 = 0; l1 < n_p; l1++)
1932 {
1933 for (unsigned l2 = 0; l2 < n_p; l2++)
1934 {
1935 finite_element_pt(element_num)->node_pt(l2 + n_p * l1) =
1936 finite_element_pt(element_num - Nx * Ny)
1937 ->node_pt(l2 + n_p * l1 + n_p * n_p * (n_p - 1));
1938 }
1939 }
1940
1941 // Loop over the other node columns in the z direction
1942
1943 for (unsigned l3 = 1; l3 < n_p; l3++)
1944 {
1945 // Set the corner node
1946 // Determine number of values at this node
1947 local_node_num = n_p * n_p * l3;
1948
1949 // Allocate memory for the node
1951 finite_element_pt(element_num)
1952 ->construct_boundary_node(local_node_num, time_stepper_pt);
1953
1954 // Set the pointer from the element
1955 finite_element_pt(element_num)->node_pt(local_node_num) =
1957
1958 // Get the fractional position of the node
1959 finite_element_pt(element_num)
1960 ->local_fraction_of_node(local_node_num, s_fraction);
1961
1962 // Set the position of the node
1963 Node_pt[node_count]->x(0) = Xmin;
1964 Node_pt[node_count]->x(1) = Ymin;
1965 Node_pt[node_count]->x(2) = Zmin + el_length[2] * (k + s_fraction[2]);
1966
1967 // Add the node to boundaries 1 and 4
1968 add_boundary_node(1, Node_pt[node_count]);
1969 add_boundary_node(4, Node_pt[node_count]);
1970
1971 // Increment the node number
1972 node_count++;
1973
1974 // Loop over the other nodes in the first row in the x direction
1975 for (unsigned l2 = 1; l2 < n_p; l2++)
1976 {
1977 // Determine the number of values at this node
1978 local_node_num = l2 + n_p * n_p * l3;
1979
1980 // Allocate memory for the nodes
1982 finite_element_pt(element_num)
1983 ->construct_boundary_node(local_node_num, time_stepper_pt);
1984 // Set the pointer from the element
1985 finite_element_pt(element_num)->node_pt(local_node_num) =
1987
1988 // Get the fractional position of the node
1989 finite_element_pt(element_num)
1990 ->local_fraction_of_node(local_node_num, s_fraction);
1991
1992 // Set the position of the node
1993 Node_pt[node_count]->x(0) = Xmin + el_length[0] * s_fraction[0];
1994 Node_pt[node_count]->x(1) = Ymin;
1995 Node_pt[node_count]->x(2) = Zmin + el_length[2] * (k + s_fraction[2]);
1996
1997 // Add the node to the boundary 1
1998 add_boundary_node(1, Node_pt[node_count]);
1999 // Increment the node number
2000 node_count++;
2001 }
2002
2003 // Loop over the other node columns
2004 for (unsigned l1 = 1; l1 < n_p; l1++)
2005 {
2006 // Determine the number of values
2007 local_node_num = l1 * n_p + n_p * n_p * l3;
2008
2009 // Allocate memory for the nodes
2011 finite_element_pt(element_num)
2012 ->construct_boundary_node(local_node_num, time_stepper_pt);
2013 // Set the pointer from the element
2014 finite_element_pt(element_num)->node_pt(local_node_num) =
2016
2017 // Get the fractional position of the node
2018 finite_element_pt(element_num)
2019 ->local_fraction_of_node(local_node_num, s_fraction);
2020
2021 // Set the position of the first node of the row (with boundary 4)
2022 Node_pt[node_count]->x(0) = Xmin;
2023 Node_pt[node_count]->x(1) = Ymin + el_length[1] * s_fraction[1];
2024 Node_pt[node_count]->x(2) = Zmin + el_length[2] * (k + s_fraction[2]);
2025
2026 // Add the node to the boundary 4
2027 add_boundary_node(4, Node_pt[node_count]);
2028 // Increment the node number
2029 node_count++;
2030
2031 // Loop over the other nodes in the row
2032 for (unsigned l2 = 1; l2 < n_p; l2++)
2033 {
2034 // Set the number of values
2035 local_node_num = l1 * n_p + l2 + n_p * n_p * l3;
2036
2037 // Allocate the memory for the node
2039 finite_element_pt(element_num)
2040 ->construct_node(local_node_num, time_stepper_pt);
2041 // Set the pointer from the element
2042 finite_element_pt(element_num)->node_pt(local_node_num) =
2044
2045 // Get the fractional position of the node
2046 finite_element_pt(element_num)
2047 ->local_fraction_of_node(local_node_num, s_fraction);
2048
2049 // Set the position of the node
2050 Node_pt[node_count]->x(0) = Xmin + el_length[0] * s_fraction[0];
2051 Node_pt[node_count]->x(1) = Ymin + el_length[1] * s_fraction[1];
2052 Node_pt[node_count]->x(2) =
2053 Zmin + el_length[2] * (k + s_fraction[2]);
2054
2055 // No boundary
2056
2057 // Increment the node number
2058 node_count++;
2059 }
2060 }
2061 }
2062
2063 //----------------------------------------------------------------------
2064
2065 // CENTRE OF FIRST ROW OF ELEMENTS
2066 //--------------------------------
2067
2068 // Now loop over the first row of elements, apart from final element
2069 for (unsigned j = 1; j < (Nx - 1); j++)
2070 {
2071 // Allocate memory for new element
2072 element_num = j + k * Nx * Ny;
2073 Element_pt[element_num] = new ELEMENT;
2074
2075 // The lowest nodes are copied from the lower element
2076 for (unsigned l1 = 0; l1 < n_p; l1++)
2077 {
2078 for (unsigned l2 = 0; l2 < n_p; l2++)
2079 {
2080 finite_element_pt(j + k * Nx * Ny)->node_pt(l2 + n_p * l1) =
2081 finite_element_pt(j + (k - 1) * Nx * Ny)
2082 ->node_pt(l2 + n_p * l1 + (n_p - 1) * n_p * n_p);
2083 }
2084 }
2085
2086 // Loop over the other node columns in the z direction
2087 for (unsigned l3 = 1; l3 < n_p; l3++)
2088 {
2089 // First column of nodes is same as neighbouring element
2090 finite_element_pt(j + k * Nx * Ny)->node_pt(l3 * n_p * n_p) =
2091 finite_element_pt(j - 1 + k * Nx * Ny)
2092 ->node_pt(l3 * n_p * n_p + (n_p - 1));
2093
2094 // New nodes for other columns
2095 for (unsigned l2 = 1; l2 < n_p; l2++)
2096 {
2097 // Determine number of values
2098 local_node_num = l2 + l3 * n_p * n_p;
2099
2100 // Allocate memory for the nodes
2102 finite_element_pt(element_num)
2103 ->construct_boundary_node(local_node_num, time_stepper_pt);
2104 // Set the pointer from the element
2105 finite_element_pt(element_num)->node_pt(local_node_num) =
2107
2108 // Get the fractional position of the node
2109 finite_element_pt(element_num)
2110 ->local_fraction_of_node(local_node_num, s_fraction);
2111
2112 // Set the position of the node
2113 Node_pt[node_count]->x(0) =
2114 Xmin + el_length[0] * (j + s_fraction[0]);
2115 Node_pt[node_count]->x(1) = Ymin;
2116 Node_pt[node_count]->x(2) =
2117 Zmin + el_length[2] * (k + s_fraction[2]);
2118
2119 // Add the node to the boundary 1
2120 add_boundary_node(1, Node_pt[node_count]);
2121 // Increment the node number
2122 node_count++;
2123 }
2124
2125 // Do the rest of the nodes
2126 for (unsigned l1 = 1; l1 < n_p; l1++)
2127 {
2128 // First column of nodes is same as neighbouring element
2129 finite_element_pt(j + k * Nx * Ny)
2130 ->node_pt(l1 * n_p + l3 * n_p * n_p) =
2131 finite_element_pt(j - 1 + k * Nx * Ny)
2132 ->node_pt(l1 * n_p + (n_p - 1) + l3 * n_p * n_p);
2133
2134 // New nodes for other columns
2135 for (unsigned l2 = 1; l2 < n_p; l2++)
2136 {
2137 // Determine number of values
2138 local_node_num = l1 * n_p + l2 + l3 * n_p * n_p;
2139
2140 // Allocate memory for the nodes
2142 finite_element_pt(element_num)
2143 ->construct_node(local_node_num, time_stepper_pt);
2144 // Set the pointer from the element
2145 finite_element_pt(element_num)->node_pt(local_node_num) =
2147
2148 // Get the fractional position of the node
2149 finite_element_pt(element_num)
2150 ->local_fraction_of_node(local_node_num, s_fraction);
2151
2152 // Set the position of the node
2153 Node_pt[node_count]->x(0) =
2154 Xmin + el_length[0] * (j + s_fraction[0]);
2155 Node_pt[node_count]->x(1) = Ymin + el_length[1] * s_fraction[1];
2156 Node_pt[node_count]->x(2) =
2157 Zmin + el_length[2] * (k + s_fraction[2]);
2158
2159 // No boundaries
2160
2161 // Increment the node number
2162 node_count++;
2163 }
2164 }
2165 }
2166 }
2167
2168 // MY FINAL ELEMENT IN FIRST ROW (right corner)
2169 //-----------------------------------------------
2170
2171 // Allocate memory for new element
2172 element_num = Nx - 1 + k * Nx * Ny;
2173 Element_pt[element_num] = new ELEMENT;
2174
2175 // The lowest nodes are copied from the lower element
2176 for (unsigned l1 = 0; l1 < n_p; l1++)
2177 {
2178 for (unsigned l2 = 0; l2 < n_p; l2++)
2179 {
2180 finite_element_pt(Nx - 1 + k * Nx * Ny)->node_pt(l2 + n_p * l1) =
2181 finite_element_pt(Nx - 1 + (k - 1) * Nx * Ny)
2182 ->node_pt(l2 + n_p * l1 + (n_p - 1) * n_p * n_p);
2183 }
2184 }
2185
2186 // Loop over the other node columns in the z direction
2187 for (unsigned l3 = 1; l3 < n_p; l3++)
2188 {
2189 // First column of nodes is same as neighbouring element
2190 finite_element_pt(Nx - 1 + k * Nx * Ny)->node_pt(l3 * n_p * n_p) =
2191 finite_element_pt(Nx - 2 + k * Nx * Ny)
2192 ->node_pt(l3 * n_p * n_p + (n_p - 1));
2193
2194 // New nodes for other rows (y=0)
2195 for (unsigned l2 = 1; l2 < (n_p - 1); l2++)
2196 {
2197 // Determine number of values
2198 local_node_num = l2 + l3 * n_p * n_p;
2199
2200 // Allocate memory for the nodes
2202 finite_element_pt(element_num)
2203 ->construct_boundary_node(local_node_num, time_stepper_pt);
2204 // Set the pointer from the element
2205 finite_element_pt(element_num)->node_pt(local_node_num) =
2207
2208 // Get the fractional position of the node
2209 finite_element_pt(element_num)
2210 ->local_fraction_of_node(local_node_num, s_fraction);
2211
2212 // Set the position of the node
2213 Node_pt[node_count]->x(0) =
2214 Xmin + el_length[0] * (Nx - 1 + s_fraction[0]);
2215 Node_pt[node_count]->x(1) = Ymin;
2216 Node_pt[node_count]->x(2) = Zmin + el_length[2] * (k + s_fraction[2]);
2217
2218 // Add the node to the boundary 1
2219 add_boundary_node(1, Node_pt[node_count]);
2220 // Increment the node number
2221 node_count++;
2222 }
2223
2224 // Last node of the row (y=0)
2225
2226 // Determine number of values
2227 local_node_num = (n_p - 1) + l3 * n_p * n_p;
2228
2229 // Allocate memory for the nodes
2231 finite_element_pt(element_num)
2232 ->construct_boundary_node(local_node_num, time_stepper_pt);
2233 // Set the pointer from the element
2234 finite_element_pt(element_num)->node_pt(local_node_num) =
2236
2237 // Get the fractional position of the node
2238 finite_element_pt(element_num)
2239 ->local_fraction_of_node(local_node_num, s_fraction);
2240
2241 // Set the position of the node
2242 Node_pt[node_count]->x(0) = Xmax;
2243 Node_pt[node_count]->x(1) = Ymin;
2244 Node_pt[node_count]->x(2) = Zmin + el_length[2] * (k + s_fraction[2]);
2245
2246 // Add the node to the boundary 1 and 2
2247 add_boundary_node(1, Node_pt[node_count]);
2248 add_boundary_node(2, Node_pt[node_count]);
2249 // Increment the node number
2250 node_count++;
2251
2252 // Do the rest of the nodes
2253 for (unsigned l1 = 1; l1 < n_p; l1++)
2254 {
2255 // First column of nodes is same as neighbouring element
2256 finite_element_pt(Nx - 1 + k * Nx * Ny)
2257 ->node_pt(l1 * n_p + l3 * n_p * n_p) =
2258 finite_element_pt(Nx - 2 + k * Nx * Ny)
2259 ->node_pt(l1 * n_p + (n_p - 1) + l3 * n_p * n_p);
2260
2261 // New nodes for other columns
2262 for (unsigned l2 = 1; l2 < (n_p - 1); l2++)
2263 {
2264 // Determine number of values
2265 local_node_num = l1 * n_p + l2 + l3 * n_p * n_p;
2266
2267 // Allocate memory for the nodes
2269 finite_element_pt(element_num)
2270 ->construct_node(local_node_num, time_stepper_pt);
2271 // Set the pointer from the element
2272 finite_element_pt(element_num)->node_pt(local_node_num) =
2274
2275 // Get the fractional position of the node
2276 finite_element_pt(element_num)
2277 ->local_fraction_of_node(local_node_num, s_fraction);
2278
2279 // Set the position of the node
2280 Node_pt[node_count]->x(0) =
2281 Xmin + el_length[0] * (Nx - 1 + s_fraction[0]);
2282 Node_pt[node_count]->x(1) = Ymin + el_length[1] * s_fraction[1];
2283 Node_pt[node_count]->x(2) =
2284 Zmin + el_length[2] * (k + s_fraction[2]);
2285
2286 // No boundaries
2287
2288 // Increment the node number
2289 node_count++;
2290 }
2291
2292 // Last nodes (at the surface x = Lx)
2293 // Determine number of values
2294 local_node_num = l1 * n_p + (n_p - 1) + l3 * n_p * n_p;
2295 // Allocate memory for the nodes
2297 finite_element_pt(element_num)
2298 ->construct_boundary_node(local_node_num, time_stepper_pt);
2299 // Set the pointer from the element
2300 finite_element_pt(element_num)->node_pt(local_node_num) =
2302
2303 // Get the fractional position of the node
2304 finite_element_pt(element_num)
2305 ->local_fraction_of_node(local_node_num, s_fraction);
2306
2307 // Set the position of the node
2308 Node_pt[node_count]->x(0) = Xmax;
2309 Node_pt[node_count]->x(1) = Ymin + el_length[1] * s_fraction[1];
2310 Node_pt[node_count]->x(2) = Zmin + el_length[2] * (k + s_fraction[2]);
2311
2312 // Add the node to the boundary 2
2313 add_boundary_node(2, Node_pt[node_count]);
2314
2315 // Increment the node number
2316 node_count++;
2317 }
2318 }
2319
2320 // ALL CENTRAL ELEMENT ROWS
2321 //------------------------
2322
2323 // Loop over remaining element rows
2324 for (unsigned i = 1; i < (Ny - 1); i++)
2325 {
2326 // Set the first element in the row
2327
2328 // Allocate memory for element (x =0)
2329 element_num = Nx * i + Nx * Ny * k;
2330 Element_pt[element_num] = new ELEMENT;
2331
2332 // The lowest nodes are copied from the lower element
2333 for (unsigned l1 = 0; l1 < n_p; l1++)
2334 {
2335 for (unsigned l2 = 0; l2 < n_p; l2++)
2336 {
2337 finite_element_pt(Nx * i + k * Nx * Ny)->node_pt(l2 + n_p * l1) =
2338 finite_element_pt(Nx * i + (k - 1) * Nx * Ny)
2339 ->node_pt(l2 + n_p * l1 + (n_p - 1) * n_p * n_p);
2340 }
2341 }
2342
2343 // We extend now this element to the third direction
2344
2345 for (unsigned l3 = 1; l3 < n_p; l3++)
2346 {
2347 // The first row of nodes is copied from the element below (at z=0)
2348 for (unsigned l2 = 0; l2 < n_p; l2++)
2349 {
2350 finite_element_pt(Nx * i + k * Nx * Ny)
2351 ->node_pt(l2 + l3 * n_p * n_p) =
2352 finite_element_pt(Nx * (i - 1) + k * Nx * Ny)
2353 ->node_pt((n_p - 1) * n_p + l2 + l3 * n_p * n_p);
2354 }
2355
2356 // Other rows are new nodes (first the nodes for which x=0)
2357 for (unsigned l1 = 1; l1 < n_p; l1++)
2358 {
2359 // First column of nodes
2360
2361 // Determine number of values
2362 local_node_num = l1 * n_p + l3 * n_p * n_p;
2363
2364 // Allocate memory for node
2366 finite_element_pt(element_num)
2367 ->construct_boundary_node(local_node_num, time_stepper_pt);
2368 // Set the pointer from the element
2369 finite_element_pt(element_num)->node_pt(local_node_num) =
2371
2372 // Get the fractional position of the node
2373 finite_element_pt(element_num)
2374 ->local_fraction_of_node(local_node_num, s_fraction);
2375
2376 // Set the position of the node
2377 Node_pt[node_count]->x(0) = Xmin;
2378 Node_pt[node_count]->x(1) =
2379 Ymin + el_length[1] * (i + s_fraction[1]);
2380 Node_pt[node_count]->x(2) =
2381 Zmin + el_length[2] * (k + s_fraction[2]);
2382
2383 // Add the node to the boundary 4
2384 add_boundary_node(4, Node_pt[node_count]);
2385
2386 // Increment the node number
2387 node_count++;
2388
2389 // Now do the other columns (we extend to the rest of the nodes)
2390 for (unsigned l2 = 1; l2 < n_p; l2++)
2391 {
2392 // Determine number of values
2393 local_node_num = l1 * n_p + l2 + n_p * n_p * l3;
2394
2395 // Allocate memory for node
2397 finite_element_pt(element_num)
2398 ->construct_node(local_node_num, time_stepper_pt);
2399 // Set the pointer from the element
2400 finite_element_pt(element_num)->node_pt(local_node_num) =
2402
2403 // Get the fractional position of the node
2404 finite_element_pt(element_num)
2405 ->local_fraction_of_node(local_node_num, s_fraction);
2406
2407 // Set the position of the node
2408 Node_pt[node_count]->x(0) = Xmin + el_length[0] * s_fraction[0];
2409 Node_pt[node_count]->x(1) =
2410 Ymin + el_length[1] * (i + s_fraction[1]);
2411 Node_pt[node_count]->x(2) =
2412 Zmin + el_length[2] * (k + s_fraction[2]);
2413
2414 // No boundaries
2415
2416 // Increment the node number
2417 node_count++;
2418 }
2419 }
2420 }
2421
2422 // Now loop over the rest of the elements in the row, apart from the
2423 // last
2424 for (unsigned j = 1; j < (Nx - 1); j++)
2425 {
2426 // Allocate memory for new element
2427 element_num = Nx * i + j + k * Nx * Ny;
2428 Element_pt[element_num] = new ELEMENT;
2429
2430 // The lowest nodes are copied from the lower element
2431 for (unsigned l1 = 0; l1 < n_p; l1++)
2432 {
2433 for (unsigned l2 = 0; l2 < n_p; l2++)
2434 {
2435 finite_element_pt(Nx * i + j + k * Nx * Ny)
2436 ->node_pt(l2 + n_p * l1) =
2437 finite_element_pt(Nx * i + j + (k - 1) * Nx * Ny)
2438 ->node_pt(l2 + n_p * l1 + (n_p - 1) * n_p * n_p);
2439 }
2440 }
2441
2442 // We extend to the third dimension
2443
2444 for (unsigned l3 = 1; l3 < n_p; l3++)
2445 {
2446 // The first row is copied from the lower element
2447
2448 for (unsigned l2 = 0; l2 < n_p; l2++)
2449 {
2450 finite_element_pt(Nx * i + j + k * Nx * Ny)
2451 ->node_pt(l2 + l3 * n_p * n_p) =
2452 finite_element_pt(Nx * (i - 1) + j + k * Nx * Ny)
2453 ->node_pt((n_p - 1) * n_p + l2 + l3 * n_p * n_p);
2454 }
2455
2456 for (unsigned l1 = 1; l1 < n_p; l1++)
2457 {
2458 // First column is same as neighbouring element
2459 finite_element_pt(Nx * i + j + k * Nx * Ny)
2460 ->node_pt(l1 * n_p + l3 * n_p * n_p) =
2461 finite_element_pt(Nx * i + (j - 1) + k * Nx * Ny)
2462 ->node_pt(l1 * n_p + l3 * n_p * n_p + (n_p - 1));
2463
2464 // New nodes for other columns
2465 for (unsigned l2 = 1; l2 < n_p; l2++)
2466 {
2467 // Determine number of values
2468 local_node_num = l1 * n_p + l2 + l3 * n_p * n_p;
2469
2470 // Allocate memory for the nodes
2472 finite_element_pt(element_num)
2473 ->construct_node(local_node_num, time_stepper_pt);
2474 // Set the pointer
2475 finite_element_pt(element_num)->node_pt(local_node_num) =
2477 // Get the fractional position of the node
2478 finite_element_pt(element_num)
2479 ->local_fraction_of_node(local_node_num, s_fraction);
2480
2481 // Set the position of the node
2482 Node_pt[node_count]->x(0) =
2483 Xmin + el_length[0] * (j + s_fraction[0]);
2484 Node_pt[node_count]->x(1) =
2485 Ymin + el_length[1] * (i + s_fraction[1]);
2486 Node_pt[node_count]->x(2) =
2487 Zmin + el_length[2] * (k + s_fraction[2]);
2488
2489 // No boundaries
2490 // Increment the node number
2491 node_count++;
2492 }
2493 }
2494 }
2495
2496 } // End of loop over elements in row
2497
2498 // Do final element in row
2499
2500 // Allocate memory for element
2501 element_num = Nx * i + Nx - 1 + k * Nx * Ny;
2502 Element_pt[element_num] = new ELEMENT;
2503
2504 // The lowest nodes are copied from the lower element
2505 for (unsigned l1 = 0; l1 < n_p; l1++)
2506 {
2507 for (unsigned l2 = 0; l2 < n_p; l2++)
2508 {
2509 finite_element_pt(Nx * i + Nx - 1 + k * Nx * Ny)
2510 ->node_pt(l2 + n_p * l1) =
2511 finite_element_pt(Nx * i + Nx - 1 + (k - 1) * Nx * Ny)
2512 ->node_pt(l2 + n_p * l1 + (n_p - 1) * n_p * n_p);
2513 }
2514 }
2515
2516 // We go to the third dimension
2517 for (unsigned l3 = 1; l3 < n_p; l3++)
2518 {
2519 // The first row is copied from the lower element
2520 for (unsigned l2 = 0; l2 < n_p; l2++)
2521 {
2522 finite_element_pt(Nx * i + Nx - 1 + k * Nx * Ny)
2523 ->node_pt(l2 + l3 * n_p * n_p) =
2524 finite_element_pt(Nx * (i - 1) + Nx - 1 + k * Nx * Ny)
2525 ->node_pt((n_p - 1) * n_p + l2 + l3 * n_p * n_p);
2526 }
2527
2528 for (unsigned l1 = 1; l1 < n_p; l1++)
2529 {
2530 // First column is same as neighbouring element
2531 finite_element_pt(Nx * i + Nx - 1 + k * Nx * Ny)
2532 ->node_pt(l1 * n_p + l3 * n_p * n_p) =
2533 finite_element_pt(Nx * i + Nx - 2 + k * Nx * Ny)
2534 ->node_pt(l1 * n_p + (n_p - 1) + l3 * n_p * n_p);
2535
2536 // Middle nodes
2537 for (unsigned l2 = 1; l2 < (n_p - 1); l2++)
2538 {
2539 // Determine number of values
2540 local_node_num = l1 * n_p + l2 + l3 * n_p * n_p;
2541
2542 // Allocate memory for node
2544 finite_element_pt(element_num)
2545 ->construct_node(local_node_num, time_stepper_pt);
2546 // Set the pointer
2547 finite_element_pt(element_num)->node_pt(local_node_num) =
2549
2550 // Get the fractional position of the node
2551 finite_element_pt(element_num)
2552 ->local_fraction_of_node(local_node_num, s_fraction);
2553
2554 // Set the position of the node
2555 Node_pt[node_count]->x(0) =
2556 Xmin + el_length[0] * (Nx - 1 + s_fraction[0]);
2557 Node_pt[node_count]->x(1) =
2558 Ymin + el_length[1] * (i + s_fraction[1]);
2559 Node_pt[node_count]->x(2) =
2560 Zmin + el_length[2] * (k + s_fraction[2]);
2561
2562 // No boundaries
2563
2564 // Increment the node number
2565 node_count++;
2566 }
2567
2568 // Final node
2569
2570 // Determine number of values
2571 local_node_num = l1 * n_p + (n_p - 1) + l3 * n_p * n_p;
2572
2573 // Allocate memory for node
2575 finite_element_pt(element_num)
2576 ->construct_boundary_node(local_node_num, time_stepper_pt);
2577 // Set the pointer
2578 finite_element_pt(element_num)->node_pt(local_node_num) =
2580
2581 // Get the fractional position of the node
2582 finite_element_pt(element_num)
2583 ->local_fraction_of_node(local_node_num, s_fraction);
2584
2585 // Set the position of the node
2586 Node_pt[node_count]->x(0) = Xmax;
2587 Node_pt[node_count]->x(1) =
2588 Ymin + el_length[1] * (i + s_fraction[1]);
2589 Node_pt[node_count]->x(2) =
2590 Zmin + el_length[2] * (k + s_fraction[2]);
2591
2592 // Add the node to the boundary 2
2593 add_boundary_node(2, Node_pt[node_count]);
2594
2595 // Increment the node number
2596 node_count++;
2597 } // End of loop over rows of nodes in the element
2598
2599 } // End of the 3dimension loop
2600
2601 } // End of loop over rows of elements
2602
2603 // FINAL ELEMENT ROW (IN INTERMIDIATE LAYERS)
2604 //=================
2605
2606 // FIRST ELEMENT IN UPPER ROW (upper left corner)
2607 //----------------------------------------------
2608
2609 // Allocate memory for element
2610 element_num = Nx * (Ny - 1) + k * Nx * Ny;
2611 Element_pt[element_num] = new ELEMENT;
2612
2613 // The lowest nodes are copied from the lower element
2614 for (unsigned l1 = 0; l1 < n_p; l1++)
2615 {
2616 for (unsigned l2 = 0; l2 < n_p; l2++)
2617 {
2618 finite_element_pt(Nx * (Ny - 1) + k * Nx * Ny)
2619 ->node_pt(l2 + n_p * l1) =
2620 finite_element_pt(Nx * (Ny - 1) + (k - 1) * Nx * Ny)
2621 ->node_pt(l2 + n_p * l1 + (n_p - 1) * n_p * n_p);
2622 }
2623 }
2624
2625 // We jump to the third dimension
2626 for (unsigned l3 = 1; l3 < n_p; l3++)
2627 {
2628 // The first row of nodes is copied from the element below
2629 for (unsigned l2 = 0; l2 < n_p; l2++)
2630 {
2631 finite_element_pt(Nx * (Ny - 1) + k * Nx * Ny)
2632 ->node_pt(l2 + l3 * n_p * n_p) =
2633 finite_element_pt(Nx * (Ny - 2) + k * Nx * Ny)
2634 ->node_pt((n_p - 1) * n_p + l2 + l3 * n_p * n_p);
2635 }
2636
2637 // Second row of nodes
2638 // First column of nodes
2639 for (unsigned l1 = 1; l1 < (n_p - 1); l1++)
2640 {
2641 // Determine number of values
2642 local_node_num = n_p * l1 + l3 * n_p * n_p;
2643
2644 // Allocate memory for node
2646 finite_element_pt(element_num)
2647 ->construct_boundary_node(local_node_num, time_stepper_pt);
2648 // Set the pointer from the element
2649 finite_element_pt(element_num)->node_pt(local_node_num) =
2651
2652 // Get the fractional position of the node
2653 finite_element_pt(element_num)
2654 ->local_fraction_of_node(local_node_num, s_fraction);
2655
2656 // Set the position of the node
2657 Node_pt[node_count]->x(0) = Xmin;
2658 Node_pt[node_count]->x(1) =
2659 Ymin + el_length[1] * (Ny - 1 + s_fraction[1]);
2660 Node_pt[node_count]->x(2) = Zmin + el_length[2] * (k + s_fraction[2]);
2661
2662 // Add the node to the boundary 4
2663 add_boundary_node(4, Node_pt[node_count]);
2664
2665 // Increment the node number
2666 node_count++;
2667
2668 // Now do the other columns
2669 for (unsigned l2 = 1; l2 < n_p; l2++)
2670 {
2671 // Determine number of values
2672 local_node_num = n_p * l1 + l2 + l3 * n_p * n_p;
2673
2674 // Allocate memory for node
2676 finite_element_pt(element_num)
2677 ->construct_node(local_node_num, time_stepper_pt);
2678 // Set the pointer from the element
2679 finite_element_pt(element_num)->node_pt(local_node_num) =
2681
2682 // Get the fractional position of the node
2683 finite_element_pt(element_num)
2684 ->local_fraction_of_node(local_node_num, s_fraction);
2685
2686 // Set the position of the node
2687 Node_pt[node_count]->x(0) = Xmin + el_length[0] * s_fraction[0];
2688 Node_pt[node_count]->x(1) =
2689 Ymin + el_length[1] * (Ny - 1 + s_fraction[1]);
2690 Node_pt[node_count]->x(2) =
2691 Zmin + el_length[2] * (k + s_fraction[2]);
2692
2693 // No boundaries
2694
2695 // Increment the node number
2696 node_count++;
2697 }
2698 }
2699
2700 // Final row of nodes
2701 // First column of nodes
2702 // Top left node
2703 // Determine number of values
2704 local_node_num = n_p * (n_p - 1) + l3 * n_p * n_p;
2705 // Allocate memory for node
2707 finite_element_pt(element_num)
2708 ->construct_boundary_node(local_node_num, time_stepper_pt);
2709 // Set the pointer from the element
2710 finite_element_pt(element_num)->node_pt(local_node_num) =
2712
2713 // Get the fractional position of the node
2714 finite_element_pt(element_num)
2715 ->local_fraction_of_node(local_node_num, s_fraction);
2716
2717 // Set the position of the node
2718 Node_pt[node_count]->x(0) = Xmin;
2719 Node_pt[node_count]->x(1) = Ymax;
2720 Node_pt[node_count]->x(2) = Zmin + el_length[2] * (k + s_fraction[2]);
2721
2722 // Add the node to the boundaries
2723 add_boundary_node(3, Node_pt[node_count]);
2724 add_boundary_node(4, Node_pt[node_count]);
2725
2726 // Increment the node number
2727 node_count++;
2728
2729 // Now do the other columns
2730 for (unsigned l2 = 1; l2 < n_p; l2++)
2731 {
2732 // Determine number of values
2733 local_node_num = n_p * (n_p - 1) + l2 + l3 * n_p * n_p;
2734 // Allocate memory for the node
2736 finite_element_pt(element_num)
2737 ->construct_boundary_node(local_node_num, time_stepper_pt);
2738 // Set the pointer from the element
2739 finite_element_pt(element_num)->node_pt(local_node_num) =
2741
2742 // Get the fractional position of the node
2743 finite_element_pt(element_num)
2744 ->local_fraction_of_node(local_node_num, s_fraction);
2745
2746 // Set the position of the node
2747 Node_pt[node_count]->x(0) = Xmin + el_length[0] * s_fraction[0];
2748 Node_pt[node_count]->x(1) = Ymax;
2749 Node_pt[node_count]->x(2) = Zmin + el_length[2] * (k + s_fraction[2]);
2750
2751 // Add the node to the boundary 3
2752 add_boundary_node(3, Node_pt[node_count]);
2753
2754 // Increment the node number
2755 node_count++;
2756 }
2757 }
2758
2759 // Now loop over the rest of the elements in the row, apart from the last
2760 for (unsigned j = 1; j < (Nx - 1); j++)
2761 {
2762 // Allocate memory for element
2763 element_num = Nx * (Ny - 1) + j + k * Nx * Ny;
2764 Element_pt[element_num] = new ELEMENT;
2765
2766 // The lowest nodes are copied from the lower element
2767 for (unsigned l1 = 0; l1 < n_p; l1++)
2768 {
2769 for (unsigned l2 = 0; l2 < n_p; l2++)
2770 {
2771 finite_element_pt(Nx * (Ny - 1) + j + k * Nx * Ny)
2772 ->node_pt(l2 + n_p * l1) =
2773 finite_element_pt(Nx * (Ny - 1) + j + (k - 1) * Nx * Ny)
2774 ->node_pt(l2 + n_p * l1 + (n_p - 1) * n_p * n_p);
2775 }
2776 }
2777
2778 // Jump in the third dimension
2779
2780 for (unsigned l3 = 1; l3 < n_p; l3++)
2781 {
2782 // The first row is copied from the lower element
2783 for (unsigned l2 = 0; l2 < n_p; l2++)
2784 {
2785 finite_element_pt(Nx * (Ny - 1) + j + k * Nx * Ny)
2786 ->node_pt(l2 + l3 * n_p * n_p) =
2787 finite_element_pt(Nx * (Ny - 2) + j + k * Nx * Ny)
2788 ->node_pt((n_p - 1) * n_p + l2 + l3 * n_p * n_p);
2789 }
2790
2791 // Second rows
2792 for (unsigned l1 = 1; l1 < (n_p - 1); l1++)
2793 {
2794 // First column is same as neighbouring element
2795 finite_element_pt(Nx * (Ny - 1) + j + k * Nx * Ny)
2796 ->node_pt(n_p * l1 + l3 * n_p * n_p) =
2797 finite_element_pt(Nx * (Ny - 1) + (j - 1) + k * Nx * Ny)
2798 ->node_pt(n_p * l1 + (n_p - 1) + l3 * n_p * n_p);
2799
2800 // New nodes for other columns
2801 for (unsigned l2 = 1; l2 < n_p; l2++)
2802 {
2803 // Determine number of values
2804 local_node_num = n_p * l1 + l2 + l3 * n_p * n_p;
2805 // Allocate memory for the node
2807 finite_element_pt(element_num)
2808 ->construct_node(local_node_num, time_stepper_pt);
2809
2810 // Set the pointer
2811 finite_element_pt(element_num)->node_pt(local_node_num) =
2813
2814 // Get the fractional position of the node
2815 finite_element_pt(element_num)
2816 ->local_fraction_of_node(local_node_num, s_fraction);
2817
2818 // Set the position of the node
2819 Node_pt[node_count]->x(0) =
2820 Xmin + el_length[0] * (j + s_fraction[0]);
2821 Node_pt[node_count]->x(1) =
2822 Ymin + el_length[1] * (Ny - 1 + s_fraction[1]);
2823 Node_pt[node_count]->x(2) =
2824 Zmin + el_length[2] * (k + s_fraction[2]);
2825
2826 // No boundaries
2827
2828 // Increment the node number
2829 // add_boundary_node(0,Node_pt[node_count]);
2830 node_count++;
2831 }
2832 }
2833
2834 // Top row
2835 // First column is same as neighbouring element
2836 finite_element_pt(Nx * (Ny - 1) + j + k * Nx * Ny)
2837 ->node_pt(n_p * (n_p - 1) + l3 * n_p * n_p) =
2838 finite_element_pt(Nx * (Ny - 1) + (j - 1) + k * Nx * Ny)
2839 ->node_pt(n_p * (n_p - 1) + (n_p - 1) + l3 * n_p * n_p);
2840 // New nodes for other columns
2841 for (unsigned l2 = 1; l2 < n_p; l2++)
2842 {
2843 // Determine number of values
2844 local_node_num = n_p * (n_p - 1) + l2 + l3 * n_p * n_p;
2845 // Allocate memory for node
2847 finite_element_pt(element_num)
2848 ->construct_boundary_node(local_node_num, time_stepper_pt);
2849 // Set the pointer
2850 finite_element_pt(element_num)->node_pt(local_node_num) =
2852
2853 // Get the fractional position of the node
2854 finite_element_pt(element_num)
2855 ->local_fraction_of_node(local_node_num, s_fraction);
2856
2857 // Set the position of the node
2858 Node_pt[node_count]->x(0) =
2859 Xmin + el_length[0] * (j + s_fraction[0]);
2860 Node_pt[node_count]->x(1) = Ymax;
2861 Node_pt[node_count]->x(2) =
2862 Zmin + el_length[2] * (k + s_fraction[2]);
2863
2864 // Add the node to the boundary
2865 add_boundary_node(3, Node_pt[node_count]);
2866
2867 // Increment the node number
2868 node_count++;
2869 }
2870 }
2871
2872 } // End of loop over central elements in row
2873
2874 // FINAL ELEMENT IN ROW (upper right corner)
2875 //-----------------------------------------
2876
2877 // Allocate memory for element
2878 element_num = Nx * (Ny - 1) + Nx - 1 + k * Nx * Ny;
2879 Element_pt[element_num] = new ELEMENT;
2880
2881 // The lowest nodes are copied from the lower element
2882 for (unsigned l1 = 0; l1 < n_p; l1++)
2883 {
2884 for (unsigned l2 = 0; l2 < n_p; l2++)
2885 {
2886 finite_element_pt(Nx * (Ny - 1) + Nx - 1 + k * Nx * Ny)
2887 ->node_pt(l2 + n_p * l1) =
2888 finite_element_pt(Nx * (Ny - 1) + Nx - 1 + (k - 1) * Nx * Ny)
2889 ->node_pt(l2 + n_p * l1 + (n_p - 1) * n_p * n_p);
2890 }
2891 }
2892
2893 // We jump to the third dimension
2894
2895 for (unsigned l3 = 1; l3 < n_p; l3++)
2896 {
2897 // The first row is copied from the lower element
2898 for (unsigned l2 = 0; l2 < n_p; l2++)
2899 {
2900 finite_element_pt(Nx * (Ny - 1) + Nx - 1 + k * Nx * Ny)
2901 ->node_pt(l2 + l3 * n_p * n_p) =
2902 finite_element_pt(Nx * (Ny - 2) + Nx - 1 + k * Nx * Ny)
2903 ->node_pt((n_p - 1) * n_p + l2 + l3 * n_p * n_p);
2904 }
2905
2906 // Second rows
2907 for (unsigned l1 = 1; l1 < (n_p - 1); l1++)
2908 {
2909 // First column is same as neighbouring element
2910 finite_element_pt(Nx * (Ny - 1) + Nx - 1 + k * Nx * Ny)
2911 ->node_pt(n_p * l1 + l3 * n_p * n_p) =
2912 finite_element_pt(Nx * (Ny - 1) + Nx - 2 + k * Nx * Ny)
2913 ->node_pt(n_p * l1 + (n_p - 1) + l3 * n_p * n_p);
2914
2915 // Middle nodes
2916 for (unsigned l2 = 1; l2 < (n_p - 1); l2++)
2917 {
2918 // Determine number of values
2919 local_node_num = n_p * l1 + l2 + l3 * n_p * n_p;
2920 // Allocate memory for node
2922 finite_element_pt(element_num)
2923 ->construct_node(local_node_num, time_stepper_pt);
2924 // Set the pointer
2925 finite_element_pt(element_num)->node_pt(local_node_num) =
2927 // Get the fractional position of the node
2928 finite_element_pt(element_num)
2929 ->local_fraction_of_node(local_node_num, s_fraction);
2930
2931 // Set the position of the node
2932 Node_pt[node_count]->x(0) =
2933 Xmin + el_length[0] * (Nx - 1 + s_fraction[0]);
2934 Node_pt[node_count]->x(1) =
2935 Ymin + el_length[1] * (Ny - 1 + s_fraction[1]);
2936 Node_pt[node_count]->x(2) =
2937 Zmin + el_length[2] * (k + s_fraction[2]);
2938
2939 // No boundaries
2940
2941 // Increment the node number
2942 node_count++;
2943 }
2944
2945 // Final node
2946 // Determine number of values
2947 local_node_num = n_p * l1 + (n_p - 1) + l3 * n_p * n_p;
2948 // Allocate memory for node
2950 finite_element_pt(element_num)
2951 ->construct_boundary_node(local_node_num, time_stepper_pt);
2952 // Set the pointer
2953 finite_element_pt(element_num)->node_pt(local_node_num) =
2955
2956 // Get the fractional position of the node
2957 finite_element_pt(element_num)
2958 ->local_fraction_of_node(local_node_num, s_fraction);
2959
2960 // Set the position of the node
2961 Node_pt[node_count]->x(0) = Xmax;
2962 Node_pt[node_count]->x(1) =
2963 Ymin + el_length[1] * (Ny - 1 + s_fraction[1]);
2964 Node_pt[node_count]->x(2) = Zmin + el_length[2] * (k + s_fraction[2]);
2965
2966 // Add the node to the boundary 2
2967 add_boundary_node(2, Node_pt[node_count]);
2968
2969 // Increment the node number
2970 node_count++;
2971
2972 } // End of loop over middle rows
2973
2974 // Final row
2975 // First column is same as neighbouring element
2976 finite_element_pt(Nx * (Ny - 1) + Nx - 1 + k * Nx * Ny)
2977 ->node_pt(n_p * (n_p - 1) + l3 * n_p * n_p) =
2978 finite_element_pt(Nx * (Ny - 1) + Nx - 2 + k * Nx * Ny)
2979 ->node_pt(n_p * (n_p - 1) + (n_p - 1) + l3 * n_p * n_p);
2980
2981 // Middle nodes
2982 for (unsigned l2 = 1; l2 < (n_p - 1); l2++)
2983 {
2984 // Determine number of values
2985 local_node_num = n_p * (n_p - 1) + l2 + l3 * n_p * n_p;
2986 // Allocate memory for node
2988 finite_element_pt(element_num)
2989 ->construct_boundary_node(local_node_num, time_stepper_pt);
2990 // Set the pointer
2991 finite_element_pt(element_num)->node_pt(local_node_num) =
2993
2994 // Get the fractional position of the node
2995 finite_element_pt(element_num)
2996 ->local_fraction_of_node(local_node_num, s_fraction);
2997
2998 // Set the position of the node
2999 Node_pt[node_count]->x(0) =
3000 Xmin + el_length[0] * (Nx - 1 + s_fraction[0]);
3001 Node_pt[node_count]->x(1) = Ymax;
3002 Node_pt[node_count]->x(2) = Zmin + el_length[2] * (k + s_fraction[2]);
3003
3004 // Add the node to the boundary 3
3005 add_boundary_node(3, Node_pt[node_count]);
3006
3007 // Increment the node number
3008 node_count++;
3009 }
3010
3011 // Final node
3012 // Determine number of values
3013 local_node_num = n_p * (n_p - 1) + (n_p - 1) + l3 * n_p * n_p;
3014 // Allocate memory for node
3016 finite_element_pt(element_num)
3017 ->construct_boundary_node(local_node_num, time_stepper_pt);
3018 // Set the pointer
3019 finite_element_pt(element_num)->node_pt(local_node_num) =
3021
3022 // Get the fractional position of the node
3023 finite_element_pt(element_num)
3024 ->local_fraction_of_node(local_node_num, s_fraction);
3025
3026 // Set the position of the node
3027 Node_pt[node_count]->x(0) = Xmax;
3028 Node_pt[node_count]->x(1) = Ymax;
3029 Node_pt[node_count]->x(2) = Zmin + el_length[2] * (k + s_fraction[2]);
3030
3031 // Add the node to the boundaries 2 and 3
3032 add_boundary_node(2, Node_pt[node_count]);
3033 add_boundary_node(3, Node_pt[node_count]);
3034
3035 // Increment the node number
3036 node_count++;
3037 }
3038
3039 } // End loop of the elements layer
3040
3041 // END OF THE INTERMEDIATE LAYERS
3042
3043 // ----------------------------------------------------------------------------------
3044 // ****************BEGINNING OF THE LAST
3045 // LAYER**************************************
3046 // ----------------------------------------------------------------------------------
3047
3048 // FIRST ELEMENT OF THE UPPER LAYER
3049 //----------------------------------
3050
3051 element_num = (Nz - 1) * Nx * Ny;
3052 Element_pt[element_num] = new ELEMENT;
3053
3054 // The lowest nodes are copied from the lower element
3055 for (unsigned l1 = 0; l1 < n_p; l1++)
3056 {
3057 for (unsigned l2 = 0; l2 < n_p; l2++)
3058 {
3059 finite_element_pt((Nz - 1) * Nx * Ny)->node_pt(l2 + n_p * l1) =
3060 finite_element_pt((Nz - 2) * Nx * Ny)
3061 ->node_pt(l2 + n_p * l1 + n_p * n_p * (n_p - 1));
3062 }
3063 }
3064
3065 // Loop over the other node columns in the z direction but the last
3066
3067 for (unsigned l3 = 1; l3 < (n_p - 1); l3++)
3068 {
3069 // Set the corner nodes
3070 // Determine number of values at this node
3071 local_node_num = n_p * n_p * l3;
3072
3073 // Allocate memory for the node
3075 finite_element_pt(element_num)
3076 ->construct_boundary_node(local_node_num, time_stepper_pt);
3077
3078 // Set the pointer from the element
3079 finite_element_pt(element_num)->node_pt(local_node_num) =
3081 // Get the fractional position of the node
3082 finite_element_pt(element_num)
3083 ->local_fraction_of_node(local_node_num, s_fraction);
3084
3085 // Set the position of the node
3086 Node_pt[node_count]->x(0) = Xmin;
3087 Node_pt[node_count]->x(1) = Ymin;
3088 Node_pt[node_count]->x(2) =
3089 Zmin + el_length[2] * (Nz - 1 + s_fraction[2]);
3090
3091 // Add the node to boundaries 1 and 4
3092 add_boundary_node(1, Node_pt[node_count]);
3093 add_boundary_node(4, Node_pt[node_count]);
3094
3095 // Increment the node number
3096 node_count++;
3097
3098 // Loop over the other nodes in the first row in the x direction
3099 for (unsigned l2 = 1; l2 < n_p; l2++)
3100 {
3101 // Determine the number of values at this node
3102 local_node_num = l2 + n_p * n_p * l3;
3103
3104 // Allocate memory for the nodes
3106 finite_element_pt(element_num)
3107 ->construct_boundary_node(local_node_num, time_stepper_pt);
3108 // Set the pointer from the element
3109 finite_element_pt(element_num)->node_pt(local_node_num) =
3111 // Get the fractional position of the node
3112 finite_element_pt(element_num)
3113 ->local_fraction_of_node(local_node_num, s_fraction);
3114
3115 // Set the position of the node
3116 Node_pt[node_count]->x(0) = Xmin + el_length[0] * s_fraction[0];
3117 Node_pt[node_count]->x(1) = Ymin;
3118 Node_pt[node_count]->x(2) =
3119 Zmin + el_length[2] * (Nz - 1 + s_fraction[2]);
3120
3121 // Add the node to the boundary 1
3122 add_boundary_node(1, Node_pt[node_count]);
3123 // Increment the node number
3124 node_count++;
3125 }
3126
3127 // Loop over the other node columns
3128 for (unsigned l1 = 1; l1 < n_p; l1++)
3129 {
3130 // Determine the number of values
3131 local_node_num = l1 * n_p + n_p * n_p * l3;
3132
3133 // Allocate memory for the nodes
3135 finite_element_pt(element_num)
3136 ->construct_boundary_node(local_node_num, time_stepper_pt);
3137 // Set the pointer from the element
3138 finite_element_pt(element_num)->node_pt(local_node_num) =
3140
3141 // Get the fractional position of the node
3142 finite_element_pt(element_num)
3143 ->local_fraction_of_node(local_node_num, s_fraction);
3144
3145 // Set the position of the first node of the row (with boundary 4)
3146 Node_pt[node_count]->x(0) = Xmin;
3147 Node_pt[node_count]->x(1) = Ymin + el_length[1] * s_fraction[1];
3148 Node_pt[node_count]->x(2) =
3149 Zmin + el_length[2] * (Nz - 1 + s_fraction[2]);
3150
3151 // Add the node to the boundary 4
3152 add_boundary_node(4, Node_pt[node_count]);
3153 // Increment the node number
3154 node_count++;
3155
3156 // Loop over the other nodes in the row
3157 for (unsigned l2 = 1; l2 < n_p; l2++)
3158 {
3159 // Set the number of values
3160 local_node_num = l1 * n_p + l2 + n_p * n_p * l3;
3161
3162 // Allocate the memory for the node
3164 finite_element_pt(element_num)
3165 ->construct_node(local_node_num, time_stepper_pt);
3166 // Set the pointer from the element
3167 finite_element_pt(element_num)->node_pt(local_node_num) =
3169
3170 // Get the fractional position of the node
3171 finite_element_pt(element_num)
3172 ->local_fraction_of_node(local_node_num, s_fraction);
3173
3174 // Set the position of the node
3175 Node_pt[node_count]->x(0) = Xmin + el_length[0] * s_fraction[0];
3176 Node_pt[node_count]->x(1) = Ymin + el_length[1] * s_fraction[1];
3177 Node_pt[node_count]->x(2) =
3178 Zmin + el_length[2] * (Nz - 1 + s_fraction[2]);
3179
3180 // No boundary
3181
3182 // Increment the node number
3183 node_count++;
3184 }
3185 }
3186 }
3187
3188 // Make the top nodes
3189
3190 // Set the corner nodes
3191 // Determine number of values at this node
3192 local_node_num = n_p * n_p * (n_p - 1);
3193
3194 // Allocate memory for the node
3196 finite_element_pt(element_num)
3197 ->construct_boundary_node(local_node_num, time_stepper_pt);
3198
3199 // Set the pointer from the element
3200 finite_element_pt(element_num)->node_pt(local_node_num) =
3202
3203 // Get the fractional position of the node
3204 finite_element_pt(element_num)
3205 ->local_fraction_of_node(local_node_num, s_fraction);
3206
3207 // Set the position of the node
3208 Node_pt[node_count]->x(0) = Xmin;
3209 Node_pt[node_count]->x(1) = Ymin;
3210 Node_pt[node_count]->x(2) = Zmax;
3211
3212 // Add the node to boundaries 1, 4 and 5
3213 add_boundary_node(1, Node_pt[node_count]);
3214 add_boundary_node(4, Node_pt[node_count]);
3215 add_boundary_node(5, Node_pt[node_count]);
3216
3217 // Increment the node number
3218 node_count++;
3219
3220 // Loop over the other nodes in the first row in the x direction
3221 for (unsigned l2 = 1; l2 < n_p; l2++)
3222 {
3223 // Determine the number of values at this node
3224 local_node_num = l2 + n_p * n_p * (n_p - 1);
3225
3226 // Allocate memory for the nodes
3228 finite_element_pt(element_num)
3229 ->construct_boundary_node(local_node_num, time_stepper_pt);
3230 // Set the pointer from the element
3231 finite_element_pt(element_num)->node_pt(local_node_num) =
3233
3234 // Get the fractional position of the node
3235 finite_element_pt(element_num)
3236 ->local_fraction_of_node(local_node_num, s_fraction);
3237
3238 // Set the position of the node
3239 Node_pt[node_count]->x(0) = Xmin + el_length[0] * s_fraction[0];
3240 Node_pt[node_count]->x(1) = Ymin;
3241 Node_pt[node_count]->x(2) = Zmax;
3242
3243 // Add the node to the boundaries 1 and 5
3244 add_boundary_node(1, Node_pt[node_count]);
3245 add_boundary_node(5, Node_pt[node_count]);
3246 // Increment the node number
3247 node_count++;
3248 }
3249
3250 // Loop over the other node columns
3251 for (unsigned l1 = 1; l1 < n_p; l1++)
3252 {
3253 // Determine the number of values
3254 local_node_num = l1 * n_p + n_p * n_p * (n_p - 1);
3255
3256 // Allocate memory for the nodes
3258 finite_element_pt(element_num)
3259 ->construct_boundary_node(local_node_num, time_stepper_pt);
3260 // Set the pointer from the element
3261 finite_element_pt(element_num)->node_pt(local_node_num) =
3263
3264 // Get the fractional position of the node
3265 finite_element_pt(element_num)
3266 ->local_fraction_of_node(local_node_num, s_fraction);
3267
3268 // Set the position of the first node of the row (with boundary 4)
3269 Node_pt[node_count]->x(0) = Xmin;
3270 Node_pt[node_count]->x(1) = Ymin + el_length[1] * s_fraction[1];
3271 Node_pt[node_count]->x(2) = Zmax;
3272
3273 // Add the node to the boundary 4
3274 add_boundary_node(4, Node_pt[node_count]);
3275 add_boundary_node(5, Node_pt[node_count]);
3276 // Increment the node number
3277 node_count++;
3278
3279 // Loop over the other nodes in the row
3280 for (unsigned l2 = 1; l2 < n_p; l2++)
3281 {
3282 // Set the number of values
3283 local_node_num = l1 * n_p + l2 + n_p * n_p * (n_p - 1);
3284
3285 // Allocate the memory for the node
3287 finite_element_pt(element_num)
3288 ->construct_boundary_node(local_node_num, time_stepper_pt);
3289 // Set the pointer from the element
3290 finite_element_pt(element_num)->node_pt(local_node_num) =
3292
3293 // Get the fractional position of the node
3294 finite_element_pt(element_num)
3295 ->local_fraction_of_node(local_node_num, s_fraction);
3296
3297 // Set the position of the node
3298 Node_pt[node_count]->x(0) = Xmin + el_length[0] * s_fraction[0];
3299 Node_pt[node_count]->x(1) = Ymin + el_length[1] * s_fraction[1];
3300 Node_pt[node_count]->x(2) = Zmax;
3301
3302 // Add the node to the boundary 5
3303 add_boundary_node(5, Node_pt[node_count]);
3304
3305 // Increment the node number
3306 node_count++;
3307 }
3308 }
3309
3310 //----------------------------------------------------------------------
3311
3312 // CENTRE OF FIRST ROW OF ELEMENTS OF THE UPPER LAYER
3313 //--------------------------------------------------
3314
3315 // Now loop over the first row of elements, apart from final element
3316 for (unsigned j = 1; j < (Nx - 1); j++)
3317 {
3318 // Allocate memory for new element
3319 element_num = j + (Nz - 1) * Nx * Ny;
3320 Element_pt[element_num] = new ELEMENT;
3321
3322 // The lowest nodes are copied from the lower element
3323 for (unsigned l1 = 0; l1 < n_p; l1++)
3324 {
3325 for (unsigned l2 = 0; l2 < n_p; l2++)
3326 {
3327 finite_element_pt(j + (Nz - 1) * Nx * Ny)->node_pt(l2 + n_p * l1) =
3328 finite_element_pt(j + (Nz - 2) * Nx * Ny)
3329 ->node_pt(l2 + n_p * l1 + (n_p - 1) * n_p * n_p);
3330 }
3331 }
3332
3333 // Loop over the other node columns in the z direction but the last
3334 for (unsigned l3 = 1; l3 < (n_p - 1); l3++)
3335 {
3336 // First column of nodes is same as neighbouring element
3337 finite_element_pt(j + (Nz - 1) * Nx * Ny)->node_pt(l3 * n_p * n_p) =
3338 finite_element_pt(j - 1 + (Nz - 1) * Nx * Ny)
3339 ->node_pt(l3 * n_p * n_p + (n_p - 1));
3340
3341 // New nodes for other columns
3342 for (unsigned l2 = 1; l2 < n_p; l2++)
3343 {
3344 // Determine number of values
3345 local_node_num = l2 + l3 * n_p * n_p;
3346
3347 // Allocate memory for the nodes
3349 finite_element_pt(element_num)
3350 ->construct_boundary_node(local_node_num, time_stepper_pt);
3351 // Set the pointer from the element
3352 finite_element_pt(element_num)->node_pt(local_node_num) =
3354
3355 // Get the fractional position of the node
3356 finite_element_pt(element_num)
3357 ->local_fraction_of_node(local_node_num, s_fraction);
3358
3359 // Set the position of the node
3360 Node_pt[node_count]->x(0) = Xmin + el_length[0] * (j + s_fraction[0]);
3361 Node_pt[node_count]->x(1) = Ymin;
3362 Node_pt[node_count]->x(2) =
3363 Zmin + el_length[2] * (Nz - 1 + s_fraction[2]);
3364
3365 // Add the node to the boundary 1
3366 add_boundary_node(1, Node_pt[node_count]);
3367 // Increment the node number
3368 node_count++;
3369 }
3370
3371 // Do the rest of the nodes
3372 for (unsigned l1 = 1; l1 < n_p; l1++)
3373 {
3374 // First column of nodes is same as neighbouring element
3375 finite_element_pt(j + (Nz - 1) * Nx * Ny)
3376 ->node_pt(l1 * n_p + l3 * n_p * n_p) =
3377 finite_element_pt(j - 1 + (Nz - 1) * Nx * Ny)
3378 ->node_pt(l1 * n_p + (n_p - 1) + l3 * n_p * n_p);
3379
3380 // New nodes for other columns
3381 for (unsigned l2 = 1; l2 < n_p; l2++)
3382 {
3383 // Determine number of values
3384 local_node_num = l1 * n_p + l2 + l3 * n_p * n_p;
3385
3386 // Allocate memory for the nodes
3388 finite_element_pt(element_num)
3389 ->construct_node(local_node_num, time_stepper_pt);
3390 // Set the pointer from the element
3391 finite_element_pt(element_num)->node_pt(local_node_num) =
3393
3394 // Get the fractional position of the node
3395 finite_element_pt(element_num)
3396 ->local_fraction_of_node(local_node_num, s_fraction);
3397
3398 // Set the position of the node
3399 Node_pt[node_count]->x(0) =
3400 Xmin + el_length[0] * (j + s_fraction[0]);
3401 Node_pt[node_count]->x(1) = Ymin + el_length[1] * s_fraction[1];
3402 Node_pt[node_count]->x(2) =
3403 Zmin + el_length[2] * (Nz - 1 + s_fraction[2]);
3404
3405 // No boundaries
3406
3407 // Increment the node number
3408 node_count++;
3409 }
3410 }
3411 }
3412
3413 // Top nodes
3414
3415 // First node is same as neighbouring element
3416 finite_element_pt(j + (Nz - 1) * Nx * Ny)
3417 ->node_pt((n_p - 1) * n_p * n_p) =
3418 finite_element_pt(j - 1 + (Nz - 1) * Nx * Ny)
3419 ->node_pt((n_p - 1) * n_p * n_p + (n_p - 1));
3420
3421 // New nodes for other columns
3422 for (unsigned l2 = 1; l2 < n_p; l2++)
3423 {
3424 // Determine number of values
3425 local_node_num = l2 + (n_p - 1) * n_p * n_p;
3426
3427 // Allocate memory for the nodes
3429 finite_element_pt(element_num)
3430 ->construct_boundary_node(local_node_num, time_stepper_pt);
3431 // Set the pointer from the element
3432 finite_element_pt(element_num)->node_pt(local_node_num) =
3434
3435 // Get the fractional position of the node
3436 finite_element_pt(element_num)
3437 ->local_fraction_of_node(local_node_num, s_fraction);
3438
3439 // Set the position of the node
3440 Node_pt[node_count]->x(0) = Xmin + el_length[0] * (j + s_fraction[0]);
3441 Node_pt[node_count]->x(1) = Ymin;
3442 Node_pt[node_count]->x(2) = Zmax;
3443
3444 // Add the node to the boundaries 1 and 5
3445 add_boundary_node(1, Node_pt[node_count]);
3446 add_boundary_node(5, Node_pt[node_count]);
3447 // Increment the node number
3448 node_count++;
3449 }
3450
3451 // Do the rest of the nodes
3452 for (unsigned l1 = 1; l1 < n_p; l1++)
3453 {
3454 // First column of nodes is same as neighbouring element
3455 finite_element_pt(j + (Nz - 1) * Nx * Ny)
3456 ->node_pt(l1 * n_p + (n_p - 1) * n_p * n_p) =
3457 finite_element_pt(j - 1 + (Nz - 1) * Nx * Ny)
3458 ->node_pt(l1 * n_p + (n_p - 1) + (n_p - 1) * n_p * n_p);
3459
3460 // New nodes for other columns
3461 for (unsigned l2 = 1; l2 < n_p; l2++)
3462 {
3463 // Determine number of values
3464 local_node_num = l1 * n_p + l2 + (n_p - 1) * n_p * n_p;
3465
3466 // Allocate memory for the nodes
3468 finite_element_pt(element_num)
3469 ->construct_boundary_node(local_node_num, time_stepper_pt);
3470 // Set the pointer from the element
3471 finite_element_pt(element_num)->node_pt(local_node_num) =
3473
3474 // Get the fractional position of the node
3475 finite_element_pt(element_num)
3476 ->local_fraction_of_node(local_node_num, s_fraction);
3477
3478 // Set the position of the node
3479 Node_pt[node_count]->x(0) = Xmin + el_length[0] * (j + s_fraction[0]);
3480 Node_pt[node_count]->x(1) = Ymin + el_length[1] * s_fraction[1];
3481 Node_pt[node_count]->x(2) = Zmax;
3482
3483 // Add to the boundary 5
3484 add_boundary_node(5, Node_pt[node_count]);
3485
3486 // Increment the node number
3487 node_count++;
3488 }
3489 }
3490 } // End loop of first row of elements
3491
3492 // MY FINAL ELEMENT IN THE FIRST ROW OF THE UPPER LAYER (right corner)
3493 //--------------------------------------------------------------------
3494
3495 // Allocate memory for new element
3496 element_num = Nx - 1 + (Nz - 1) * Nx * Ny;
3497 Element_pt[element_num] = new ELEMENT;
3498
3499 // The lowest nodes are copied from the lower element
3500 for (unsigned l1 = 0; l1 < n_p; l1++)
3501 {
3502 for (unsigned l2 = 0; l2 < n_p; l2++)
3503 {
3504 finite_element_pt(Nx - 1 + (Nz - 1) * Nx * Ny)->node_pt(l2 + n_p * l1) =
3505 finite_element_pt(Nx - 1 + (Nz - 2) * Nx * Ny)
3506 ->node_pt(l2 + n_p * l1 + (n_p - 1) * n_p * n_p);
3507 }
3508 }
3509
3510 // Loop over the other node columns in the z direction but the last
3511 for (unsigned l3 = 1; l3 < (n_p - 1); l3++)
3512 {
3513 // First column of nodes is same as neighbouring element
3514 finite_element_pt(Nx - 1 + (Nz - 1) * Nx * Ny)->node_pt(l3 * n_p * n_p) =
3515 finite_element_pt(Nx - 2 + (Nz - 1) * Nx * Ny)
3516 ->node_pt(l3 * n_p * n_p + (n_p - 1));
3517
3518 // New nodes for other rows (y=0)
3519 for (unsigned l2 = 1; l2 < (n_p - 1); l2++)
3520 {
3521 // Determine number of values
3522 local_node_num = l2 + l3 * n_p * n_p;
3523
3524 // Allocate memory for the nodes
3526 finite_element_pt(element_num)
3527 ->construct_boundary_node(local_node_num, time_stepper_pt);
3528 // Set the pointer from the element
3529 finite_element_pt(element_num)->node_pt(local_node_num) =
3531
3532 // Get the fractional position of the node
3533 finite_element_pt(element_num)
3534 ->local_fraction_of_node(local_node_num, s_fraction);
3535
3536 // Set the position of the node
3537 Node_pt[node_count]->x(0) =
3538 Xmin + el_length[0] * (Nx - 1 + s_fraction[0]);
3539 Node_pt[node_count]->x(1) = Ymin;
3540 Node_pt[node_count]->x(2) =
3541 Zmin + el_length[2] * (Nz - 1 + s_fraction[2]);
3542
3543 // Add the node to the boundary 1
3544 add_boundary_node(1, Node_pt[node_count]);
3545 // Increment the node number
3546 node_count++;
3547 }
3548
3549 // Last node of the row (y=0)
3550
3551 // Determine number of values
3552 local_node_num = (n_p - 1) + l3 * n_p * n_p;
3553
3554 // Allocate memory for the nodes
3556 finite_element_pt(element_num)
3557 ->construct_boundary_node(local_node_num, time_stepper_pt);
3558 // Set the pointer from the element
3559 finite_element_pt(element_num)->node_pt(local_node_num) =
3561
3562 // Get the fractional position of the node
3563 finite_element_pt(element_num)
3564 ->local_fraction_of_node(local_node_num, s_fraction);
3565
3566 // Set the position of the node
3567 Node_pt[node_count]->x(0) = Xmax;
3568 Node_pt[node_count]->x(1) = Ymin;
3569 Node_pt[node_count]->x(2) =
3570 Zmin + el_length[2] * (Nz - 1 + s_fraction[2]);
3571
3572 // Add the node to the boundary 1 and 2
3573 add_boundary_node(1, Node_pt[node_count]);
3574 add_boundary_node(2, Node_pt[node_count]);
3575 // Increment the node number
3576 node_count++;
3577
3578 // Do the rest of the nodes
3579 for (unsigned l1 = 1; l1 < n_p; l1++)
3580 {
3581 // First column of nodes is same as neighbouring element
3582 finite_element_pt(Nx - 1 + (Nz - 1) * Nx * Ny)
3583 ->node_pt(l1 * n_p + l3 * n_p * n_p) =
3584 finite_element_pt(Nx - 2 + (Nz - 1) * Nx * Ny)
3585 ->node_pt(l1 * n_p + (n_p - 1) + l3 * n_p * n_p);
3586
3587 // New nodes for other columns
3588 for (unsigned l2 = 1; l2 < (n_p - 1); l2++)
3589 {
3590 // Determine number of values
3591 local_node_num = l1 * n_p + l2 + l3 * n_p * n_p;
3592
3593 // Allocate memory for the nodes
3595 finite_element_pt(element_num)
3596 ->construct_node(local_node_num, time_stepper_pt);
3597 // Set the pointer from the element
3598 finite_element_pt(element_num)->node_pt(local_node_num) =
3600
3601 // Get the fractional position of the node
3602 finite_element_pt(element_num)
3603 ->local_fraction_of_node(local_node_num, s_fraction);
3604
3605 // Set the position of the node
3606 Node_pt[node_count]->x(0) =
3607 Xmin + el_length[0] * (Nx - 1 + s_fraction[0]);
3608 Node_pt[node_count]->x(1) = Ymin + el_length[1] * s_fraction[1];
3609 Node_pt[node_count]->x(2) =
3610 Zmin + el_length[2] * (Nz - 1 + s_fraction[2]);
3611
3612 // No boundaries
3613
3614 // Increment the node number
3615 node_count++;
3616 }
3617
3618 // Last nodes (at the surface x = Lx)
3619 // Determine number of values
3620 local_node_num = l1 * n_p + (n_p - 1) + l3 * n_p * n_p;
3621 // Allocate memory for the nodes
3623 finite_element_pt(element_num)
3624 ->construct_boundary_node(local_node_num, time_stepper_pt);
3625 // Set the pointer from the element
3626 finite_element_pt(element_num)->node_pt(local_node_num) =
3628
3629 // Set the position of the node
3630 Node_pt[node_count]->x(0) = Xmax;
3631 Node_pt[node_count]->x(1) = Ymin + el_length[1] * s_fraction[1];
3632 Node_pt[node_count]->x(2) =
3633 Zmin + el_length[2] * (Nz - 1 + s_fraction[2]);
3634
3635 // Add the node to the boundary 2
3636 add_boundary_node(2, Node_pt[node_count]);
3637
3638 // Increment the node number
3639 node_count++;
3640 }
3641 }
3642
3643 // We make the top nodes
3644 // First node is same as neighbouring element
3645 finite_element_pt(Nx - 1 + (Nz - 1) * Nx * Ny)
3646 ->node_pt((n_p - 1) * n_p * n_p) =
3647 finite_element_pt(Nx - 2 + (Nz - 1) * Nx * Ny)
3648 ->node_pt((n_p - 1) * n_p * n_p + (n_p - 1));
3649
3650 // New nodes for other rows (y=0)
3651 for (unsigned l2 = 1; l2 < (n_p - 1); l2++)
3652 {
3653 // Determine number of values
3654 local_node_num = l2 + (n_p - 1) * n_p * n_p;
3655
3656 // Allocate memory for the nodes
3658 finite_element_pt(element_num)
3659 ->construct_boundary_node(local_node_num, time_stepper_pt);
3660 // Set the pointer from the element
3661 finite_element_pt(element_num)->node_pt(local_node_num) =
3663
3664 // Get the fractional position of the node
3665 finite_element_pt(element_num)
3666 ->local_fraction_of_node(local_node_num, s_fraction);
3667
3668 // Set the position of the node
3669 Node_pt[node_count]->x(0) =
3670 Xmin + el_length[0] * (Nx - 1 + s_fraction[0]);
3671 Node_pt[node_count]->x(1) = Ymin;
3672 Node_pt[node_count]->x(2) = Zmax;
3673
3674 // Add the node to the boundaries 1 and 5
3675 add_boundary_node(1, Node_pt[node_count]);
3676 add_boundary_node(5, Node_pt[node_count]);
3677
3678 // Increment the node number
3679 node_count++;
3680 }
3681
3682 // Last node of the row (y=0)
3683
3684 // Determine number of values
3685 local_node_num = (n_p - 1) + (n_p - 1) * n_p * n_p;
3686
3687 // Allocate memory for the nodes
3689 finite_element_pt(element_num)
3690 ->construct_boundary_node(local_node_num, time_stepper_pt);
3691 // Set the pointer from the element
3692 finite_element_pt(element_num)->node_pt(local_node_num) =
3694
3695 // Get the fractional position of the node
3696 finite_element_pt(element_num)
3697 ->local_fraction_of_node(local_node_num, s_fraction);
3698
3699 // Set the position of the node
3700 Node_pt[node_count]->x(0) = Xmax;
3701 Node_pt[node_count]->x(1) = Ymin;
3702 Node_pt[node_count]->x(2) = Zmax;
3703
3704 // Add the node to the boundary 1 and 2
3705 add_boundary_node(1, Node_pt[node_count]);
3706 add_boundary_node(2, Node_pt[node_count]);
3707 add_boundary_node(5, Node_pt[node_count]);
3708 // Increment the node number
3709 node_count++;
3710
3711 // Do the rest of the nodes
3712 for (unsigned l1 = 1; l1 < n_p; l1++)
3713 {
3714 // First column of nodes is same as neighbouring element
3715 finite_element_pt(Nx - 1 + (Nz - 1) * Nx * Ny)
3716 ->node_pt(l1 * n_p + (n_p - 1) * n_p * n_p) =
3717 finite_element_pt(Nx - 2 + (Nz - 1) * Nx * Ny)
3718 ->node_pt(l1 * n_p + (n_p - 1) + (n_p - 1) * n_p * n_p);
3719
3720 // New nodes for other columns
3721 for (unsigned l2 = 1; l2 < (n_p - 1); l2++)
3722 {
3723 // Determine number of values
3724 local_node_num = l1 * n_p + l2 + (n_p - 1) * n_p * n_p;
3725
3726 // Allocate memory for the nodes
3728 finite_element_pt(element_num)
3729 ->construct_boundary_node(local_node_num, time_stepper_pt);
3730 // Set the pointer from the element
3731 finite_element_pt(element_num)->node_pt(local_node_num) =
3733
3734 // Get the fractional position of the node
3735 finite_element_pt(element_num)
3736 ->local_fraction_of_node(local_node_num, s_fraction);
3737
3738 // Set the position of the node
3739 Node_pt[node_count]->x(0) =
3740 Xmin + el_length[0] * (Nx - 1 + s_fraction[0]);
3741 Node_pt[node_count]->x(1) = Ymin + el_length[1] * s_fraction[1];
3742 Node_pt[node_count]->x(2) = Zmax;
3743
3744 // Add node to the boundary 5
3745 add_boundary_node(5, Node_pt[node_count]);
3746
3747 // Increment the node number
3748 node_count++;
3749 }
3750
3751 // Last nodes (at the surface x = Lx)
3752 // Determine number of values
3753 local_node_num = l1 * n_p + (n_p - 1) + (n_p - 1) * n_p * n_p;
3754 // Allocate memory for the nodes
3756 finite_element_pt(element_num)
3757 ->construct_boundary_node(local_node_num, time_stepper_pt);
3758 // Set the pointer from the element
3759 finite_element_pt(element_num)->node_pt(local_node_num) =
3761
3762 // Get the fractional position of the node
3763 finite_element_pt(element_num)
3764 ->local_fraction_of_node(local_node_num, s_fraction);
3765
3766 // Set the position of the node
3767 Node_pt[node_count]->x(0) = Xmax;
3768 Node_pt[node_count]->x(1) = Ymin + el_length[1] * s_fraction[1];
3769 Node_pt[node_count]->x(2) = Zmax;
3770
3771 // Add the node to the boundaries 2 and 5
3772 add_boundary_node(2, Node_pt[node_count]);
3773 add_boundary_node(5, Node_pt[node_count]);
3774
3775 // Increment the node number
3776 node_count++;
3777 }
3778
3779 // ALL CENTRAL ELEMENT ROWS OF THE TOP LAYER
3780 //------------------------------------------
3781
3782 // Loop over remaining element rows
3783 for (unsigned i = 1; i < (Ny - 1); i++)
3784 {
3785 // Set the first element in the row
3786
3787 // Allocate memory for element (x =0)
3788 element_num = Nx * i + Nx * Ny * (Nz - 1);
3789 Element_pt[element_num] = new ELEMENT;
3790
3791 // The lowest nodes are copied from the lower element
3792 for (unsigned l1 = 0; l1 < n_p; l1++)
3793 {
3794 for (unsigned l2 = 0; l2 < n_p; l2++)
3795 {
3796 finite_element_pt(Nx * i + (Nz - 1) * Nx * Ny)
3797 ->node_pt(l2 + n_p * l1) =
3798 finite_element_pt(Nx * i + (Nz - 2) * Nx * Ny)
3799 ->node_pt(l2 + n_p * l1 + (n_p - 1) * n_p * n_p);
3800 }
3801 }
3802
3803 // We extend now this element to the third dimension
3804
3805 for (unsigned l3 = 1; l3 < (n_p - 1); l3++)
3806 {
3807 // The first row of nodes is copied from the element below (at z=0)
3808 for (unsigned l2 = 0; l2 < n_p; l2++)
3809 {
3810 finite_element_pt(Nx * i + (Nz - 1) * Nx * Ny)
3811 ->node_pt(l2 + l3 * n_p * n_p) =
3812 finite_element_pt(Nx * (i - 1) + (Nz - 1) * Nx * Ny)
3813 ->node_pt((n_p - 1) * n_p + l2 + l3 * n_p * n_p);
3814 }
3815
3816 // Other rows are new nodes (first the nodes for which x=0)
3817 for (unsigned l1 = 1; l1 < n_p; l1++)
3818 {
3819 // First column of nodes
3820
3821 // Determine number of values
3822 local_node_num = l1 * n_p + l3 * n_p * n_p;
3823
3824 // Allocate memory for node
3826 finite_element_pt(element_num)
3827 ->construct_boundary_node(local_node_num, time_stepper_pt);
3828 // Set the pointer from the element
3829 finite_element_pt(element_num)->node_pt(local_node_num) =
3831
3832 // Get the fractional position of the node
3833 finite_element_pt(element_num)
3834 ->local_fraction_of_node(local_node_num, s_fraction);
3835
3836 // Set the position of the node
3837 Node_pt[node_count]->x(0) = Xmin;
3838 Node_pt[node_count]->x(1) = Ymin + el_length[1] * (i + s_fraction[1]);
3839 Node_pt[node_count]->x(2) =
3840 Zmin + el_length[2] * (Nz - 1 + s_fraction[2]);
3841
3842 // Add the node to the boundary 4
3843 add_boundary_node(4, Node_pt[node_count]);
3844
3845 // Increment the node number
3846 node_count++;
3847
3848 // Now do the other columns (we extend to the rest of the nodes)
3849 for (unsigned l2 = 1; l2 < n_p; l2++)
3850 {
3851 // Determine number of values
3852 local_node_num = l1 * n_p + l2 + n_p * n_p * l3;
3853
3854 // Allocate memory for node
3856 finite_element_pt(element_num)
3857 ->construct_node(local_node_num, time_stepper_pt);
3858 // Set the pointer from the element
3859 finite_element_pt(element_num)->node_pt(local_node_num) =
3861
3862 // Get the fractional position of the node
3863 finite_element_pt(element_num)
3864 ->local_fraction_of_node(local_node_num, s_fraction);
3865
3866 // Set the position of the node
3867 Node_pt[node_count]->x(0) = Xmin + el_length[0] * s_fraction[0];
3868 Node_pt[node_count]->x(1) =
3869 Ymin + el_length[1] * (i + s_fraction[1]);
3870 Node_pt[node_count]->x(2) =
3871 Zmin + el_length[2] * (Nz - 1 + s_fraction[2]);
3872
3873 // No boundaries
3874
3875 // Increment the node number
3876 node_count++;
3877 }
3878 }
3879 }
3880
3881 // Now the top nodes
3882
3883 // The first row of nodes is copied from the element below (at z=0)
3884 for (unsigned l2 = 0; l2 < n_p; l2++)
3885 {
3886 finite_element_pt(Nx * i + (Nz - 1) * Nx * Ny)
3887 ->node_pt(l2 + (n_p - 1) * n_p * n_p) =
3888 finite_element_pt(Nx * (i - 1) + (Nz - 1) * Nx * Ny)
3889 ->node_pt((n_p - 1) * n_p + l2 + (n_p - 1) * n_p * n_p);
3890 }
3891
3892 // Other rows are new nodes (first the nodes for which x=0)
3893 for (unsigned l1 = 1; l1 < n_p; l1++)
3894 {
3895 // First column of nodes
3896
3897 // Determine number of values
3898 local_node_num = l1 * n_p + (n_p - 1) * n_p * n_p;
3899
3900 // Allocate memory for node
3902 finite_element_pt(element_num)
3903 ->construct_boundary_node(local_node_num, time_stepper_pt);
3904 // Set the pointer from the element
3905 finite_element_pt(element_num)->node_pt(local_node_num) =
3907
3908 // Get the fractional position of the node
3909 finite_element_pt(element_num)
3910 ->local_fraction_of_node(local_node_num, s_fraction);
3911
3912 // Set the position of the node
3913 Node_pt[node_count]->x(0) = Xmin;
3914 Node_pt[node_count]->x(1) = Ymin + el_length[1] * (i + s_fraction[1]);
3915 Node_pt[node_count]->x(2) = Zmax;
3916
3917 // Add the node to the boundaries 4 and 5
3918 add_boundary_node(4, Node_pt[node_count]);
3919 add_boundary_node(5, Node_pt[node_count]);
3920
3921 // Increment the node number
3922 node_count++;
3923
3924 // Now do the other columns (we extend to the rest of the nodes)
3925 for (unsigned l2 = 1; l2 < n_p; l2++)
3926 {
3927 // Determine number of values
3928 local_node_num = l1 * n_p + l2 + n_p * n_p * (n_p - 1);
3929
3930 // Allocate memory for node
3932 finite_element_pt(element_num)
3933 ->construct_boundary_node(local_node_num, time_stepper_pt);
3934 // Set the pointer from the element
3935 finite_element_pt(element_num)->node_pt(local_node_num) =
3937
3938 // Get the fractional position of the node
3939 finite_element_pt(element_num)
3940 ->local_fraction_of_node(local_node_num, s_fraction);
3941
3942 // Set the position of the node
3943 Node_pt[node_count]->x(0) = Xmin + el_length[0] * s_fraction[0];
3944 Node_pt[node_count]->x(1) = Ymin + el_length[1] * (i + s_fraction[1]);
3945 Node_pt[node_count]->x(2) = Zmax;
3946
3947 // Add the node to boundary 5
3948 add_boundary_node(5, Node_pt[node_count]);
3949
3950 // Increment the node number
3951 node_count++;
3952 }
3953 }
3954
3955 // Now loop over the rest of the elements in the row, apart from the last
3956 for (unsigned j = 1; j < (Nx - 1); j++)
3957 {
3958 // Allocate memory for new element
3959 element_num = Nx * i + j + (Nz - 1) * Nx * Ny;
3960 Element_pt[element_num] = new ELEMENT;
3961
3962 // The lowest nodes are copied from the lower element
3963 for (unsigned l1 = 0; l1 < n_p; l1++)
3964 {
3965 for (unsigned l2 = 0; l2 < n_p; l2++)
3966 {
3967 finite_element_pt(Nx * i + j + (Nz - 1) * Nx * Ny)
3968 ->node_pt(l2 + n_p * l1) =
3969 finite_element_pt(Nx * i + j + (Nz - 2) * Nx * Ny)
3970 ->node_pt(l2 + n_p * l1 + (n_p - 1) * n_p * n_p);
3971 }
3972 }
3973
3974 // We extend to the third dimension but the last layer of nodes
3975
3976 for (unsigned l3 = 1; l3 < (n_p - 1); l3++)
3977 {
3978 // The first row is copied from the lower element
3979
3980 for (unsigned l2 = 0; l2 < n_p; l2++)
3981 {
3982 finite_element_pt(Nx * i + j + (Nz - 1) * Nx * Ny)
3983 ->node_pt(l2 + l3 * n_p * n_p) =
3984 finite_element_pt(Nx * (i - 1) + j + (Nz - 1) * Nx * Ny)
3985 ->node_pt((n_p - 1) * n_p + l2 + l3 * n_p * n_p);
3986 }
3987
3988 for (unsigned l1 = 1; l1 < n_p; l1++)
3989 {
3990 // First column is same as neighbouring element
3991 finite_element_pt(Nx * i + j + (Nz - 1) * Nx * Ny)
3992 ->node_pt(l1 * n_p + l3 * n_p * n_p) =
3993 finite_element_pt(Nx * i + (j - 1) + (Nz - 1) * Nx * Ny)
3994 ->node_pt(l1 * n_p + l3 * n_p * n_p + (n_p - 1));
3995
3996 // New nodes for other columns
3997 for (unsigned l2 = 1; l2 < n_p; l2++)
3998 {
3999 // Determine number of values
4000 local_node_num = l1 * n_p + l2 + l3 * n_p * n_p;
4001
4002 // Allocate memory for the nodes
4004 finite_element_pt(element_num)
4005 ->construct_node(local_node_num, time_stepper_pt);
4006 // Set the pointer
4007 finite_element_pt(element_num)->node_pt(local_node_num) =
4009 // Get the fractional position of the node
4010 finite_element_pt(element_num)
4011 ->local_fraction_of_node(local_node_num, s_fraction);
4012
4013 // Set the position of the node
4014 Node_pt[node_count]->x(0) =
4015 Xmin + el_length[0] * (j + s_fraction[0]);
4016 Node_pt[node_count]->x(1) =
4017 Ymin + el_length[1] * (i + s_fraction[1]);
4018 Node_pt[node_count]->x(2) =
4019 Zmin + el_length[2] * (Nz - 1 + s_fraction[2]);
4020 // No boundaries
4021
4022 // Increment the node number
4023 node_count++;
4024 }
4025 }
4026 }
4027
4028 // Now the top nodes
4029
4030 // The first row is copied from the lower element
4031
4032 for (unsigned l2 = 0; l2 < n_p; l2++)
4033 {
4034 finite_element_pt(Nx * i + j + (Nz - 1) * Nx * Ny)
4035 ->node_pt(l2 + (n_p - 1) * n_p * n_p) =
4036 finite_element_pt(Nx * (i - 1) + j + (Nz - 1) * Nx * Ny)
4037 ->node_pt((n_p - 1) * n_p + l2 + (n_p - 1) * n_p * n_p);
4038 }
4039
4040 for (unsigned l1 = 1; l1 < n_p; l1++)
4041 {
4042 // First column is same as neighbouring element
4043 finite_element_pt(Nx * i + j + (Nz - 1) * Nx * Ny)
4044 ->node_pt(l1 * n_p + (n_p - 1) * n_p * n_p) =
4045 finite_element_pt(Nx * i + (j - 1) + (Nz - 1) * Nx * Ny)
4046 ->node_pt(l1 * n_p + (n_p - 1) * n_p * n_p + (n_p - 1));
4047
4048 // New nodes for other columns
4049 for (unsigned l2 = 1; l2 < n_p; l2++)
4050 {
4051 // Determine number of values
4052 local_node_num = l1 * n_p + l2 + (n_p - 1) * n_p * n_p;
4053
4054 // Allocate memory for the nodes
4056 finite_element_pt(element_num)
4057 ->construct_boundary_node(local_node_num, time_stepper_pt);
4058 // Set the pointer
4059 finite_element_pt(element_num)->node_pt(local_node_num) =
4061
4062 // Get the fractional position of the node
4063 finite_element_pt(element_num)
4064 ->local_fraction_of_node(local_node_num, s_fraction);
4065
4066 // Set the position of the node
4067 Node_pt[node_count]->x(0) =
4068 Xmin + el_length[0] * (j + s_fraction[0]);
4069 Node_pt[node_count]->x(1) =
4070 Ymin + el_length[1] * (i + s_fraction[1]);
4071 Node_pt[node_count]->x(2) = Zmax;
4072
4073 // Add to boundary 5
4074 add_boundary_node(5, Node_pt[node_count]);
4075
4076 // Increment the node number
4077 node_count++;
4078 }
4079 }
4080
4081 } // End of loop over elements in row
4082
4083 // Do final element in row
4084
4085 // Allocate memory for element
4086 element_num = Nx * i + Nx - 1 + (Nz - 1) * Nx * Ny;
4087 Element_pt[element_num] = new ELEMENT;
4088
4089 // The lowest nodes are copied from the lower element
4090 for (unsigned l1 = 0; l1 < n_p; l1++)
4091 {
4092 for (unsigned l2 = 0; l2 < n_p; l2++)
4093 {
4094 finite_element_pt(Nx * i + Nx - 1 + (Nz - 1) * Nx * Ny)
4095 ->node_pt(l2 + n_p * l1) =
4096 finite_element_pt(Nx * i + Nx - 1 + (Nz - 2) * Nx * Ny)
4097 ->node_pt(l2 + n_p * l1 + (n_p - 1) * n_p * n_p);
4098 }
4099 }
4100
4101 // We go to the third dimension but we do not reach the top
4102 for (unsigned l3 = 1; l3 < (n_p - 1); l3++)
4103 {
4104 // The first row is copied from the lower element
4105 for (unsigned l2 = 0; l2 < n_p; l2++)
4106 {
4107 finite_element_pt(Nx * i + Nx - 1 + (Nz - 1) * Nx * Ny)
4108 ->node_pt(l2 + l3 * n_p * n_p) =
4109 finite_element_pt(Nx * (i - 1) + Nx - 1 + (Nz - 1) * Nx * Ny)
4110 ->node_pt((n_p - 1) * n_p + l2 + l3 * n_p * n_p);
4111 }
4112
4113 for (unsigned l1 = 1; l1 < n_p; l1++)
4114 {
4115 // First column is same as neighbouring element
4116 finite_element_pt(Nx * i + Nx - 1 + (Nz - 1) * Nx * Ny)
4117 ->node_pt(l1 * n_p + l3 * n_p * n_p) =
4118 finite_element_pt(Nx * i + Nx - 2 + (Nz - 1) * Nx * Ny)
4119 ->node_pt(l1 * n_p + (n_p - 1) + l3 * n_p * n_p);
4120
4121 // Middle nodes
4122 for (unsigned l2 = 1; l2 < (n_p - 1); l2++)
4123 {
4124 // Determine number of values
4125 local_node_num = l1 * n_p + l2 + l3 * n_p * n_p;
4126
4127 // Allocate memory for node
4129 finite_element_pt(element_num)
4130 ->construct_node(local_node_num, time_stepper_pt);
4131 // Set the pointer
4132 finite_element_pt(element_num)->node_pt(local_node_num) =
4134
4135 // Get the fractional position of the node
4136 finite_element_pt(element_num)
4137 ->local_fraction_of_node(local_node_num, s_fraction);
4138
4139 // Set the position of the node
4140 Node_pt[node_count]->x(0) =
4141 Xmin + el_length[0] * (Nx - 1 + s_fraction[0]);
4142 Node_pt[node_count]->x(1) =
4143 Ymin + el_length[1] * (i + s_fraction[1]);
4144 Node_pt[node_count]->x(2) =
4145 Zmin + el_length[2] * (Nz - 1 + s_fraction[2]);
4146
4147 // No boundaries
4148
4149 // Increment the node number
4150 node_count++;
4151 }
4152
4153 // Final node
4154
4155 // Determine number of values
4156 local_node_num = l1 * n_p + (n_p - 1) + l3 * n_p * n_p;
4157
4158 // Allocate memory for node
4160 finite_element_pt(element_num)
4161 ->construct_boundary_node(local_node_num, time_stepper_pt);
4162 // Set the pointer
4163 finite_element_pt(element_num)->node_pt(local_node_num) =
4165
4166 // Get the fractional position of the node
4167 finite_element_pt(element_num)
4168 ->local_fraction_of_node(local_node_num, s_fraction);
4169
4170 // Set the position of the node
4171 Node_pt[node_count]->x(0) = Xmax;
4172 Node_pt[node_count]->x(1) = Ymin + el_length[1] * (i + s_fraction[1]);
4173 Node_pt[node_count]->x(2) =
4174 Zmin + el_length[2] * (Nz - 1 + s_fraction[2]);
4175
4176 // Add the node to the boundary 2
4177 add_boundary_node(2, Node_pt[node_count]);
4178
4179 // Increment the node number
4180 node_count++;
4181 } // End of loop over rows of nodes in the element
4182
4183 } // End of the 3dimension loop
4184
4185 // Now the top nodes
4186
4187 // The first row is copied from the lower element
4188 for (unsigned l2 = 0; l2 < n_p; l2++)
4189 {
4190 finite_element_pt(Nx * i + Nx - 1 + (Nz - 1) * Nx * Ny)
4191 ->node_pt(l2 + (n_p - 1) * n_p * n_p) =
4192 finite_element_pt(Nx * (i - 1) + Nx - 1 + (Nz - 1) * Nx * Ny)
4193 ->node_pt((n_p - 1) * n_p + l2 + (n_p - 1) * n_p * n_p);
4194 }
4195
4196 for (unsigned l1 = 1; l1 < n_p; l1++)
4197 {
4198 // First column is same as neighbouring element
4199 finite_element_pt(Nx * i + Nx - 1 + (Nz - 1) * Nx * Ny)
4200 ->node_pt(l1 * n_p + (n_p - 1) * n_p * n_p) =
4201 finite_element_pt(Nx * i + Nx - 2 + (Nz - 1) * Nx * Ny)
4202 ->node_pt(l1 * n_p + (n_p - 1) + (n_p - 1) * n_p * n_p);
4203
4204 // Middle nodes
4205 for (unsigned l2 = 1; l2 < (n_p - 1); l2++)
4206 {
4207 // Determine number of values
4208 local_node_num = l1 * n_p + l2 + (n_p - 1) * n_p * n_p;
4209
4210 // Allocate memory for node
4212 finite_element_pt(element_num)
4213 ->construct_boundary_node(local_node_num, time_stepper_pt);
4214 // Set the pointer
4215 finite_element_pt(element_num)->node_pt(local_node_num) =
4217
4218 // Get the fractional position of the node
4219 finite_element_pt(element_num)
4220 ->local_fraction_of_node(local_node_num, s_fraction);
4221
4222 // Set the position of the node
4223 Node_pt[node_count]->x(0) =
4224 Xmin + el_length[0] * (Nx - 1 + s_fraction[0]);
4225 Node_pt[node_count]->x(1) = Ymin + el_length[1] * (i + s_fraction[1]);
4226 Node_pt[node_count]->x(2) = Zmax;
4227
4228 // Add to boundary 5
4229 add_boundary_node(5, Node_pt[node_count]);
4230
4231 // Increment the node number
4232 node_count++;
4233 }
4234
4235 // Final node
4236
4237 // Determine number of values
4238 local_node_num = l1 * n_p + (n_p - 1) + (n_p - 1) * n_p * n_p;
4239
4240 // Allocate memory for node
4242 finite_element_pt(element_num)
4243 ->construct_boundary_node(local_node_num, time_stepper_pt);
4244 // Set the pointer
4245 finite_element_pt(element_num)->node_pt(local_node_num) =
4247
4248 // Get the fractional position of the node
4249 finite_element_pt(element_num)
4250 ->local_fraction_of_node(local_node_num, s_fraction);
4251
4252 // Set the position of the node
4253 Node_pt[node_count]->x(0) = Xmax;
4254 Node_pt[node_count]->x(1) = Ymin + el_length[1] * (i + s_fraction[1]);
4255 Node_pt[node_count]->x(2) = Zmax;
4256
4257 // Add the node to the boundaries 2 and 5
4258 add_boundary_node(2, Node_pt[node_count]);
4259 add_boundary_node(5, Node_pt[node_count]);
4260
4261 // Increment the node number
4262 node_count++;
4263 } // End of loop over rows of nodes in the element
4264
4265 } // End of loop over rows of elements
4266
4267 // FINAL ELEMENT ROW (IN TOP LAYER)
4268 //===========================================
4269
4270 // FIRST ELEMENT IN UPPER ROW (upper left corner)
4271 //----------------------------------------------
4272
4273 // Allocate memory for element
4274 element_num = Nx * (Ny - 1) + (Nz - 1) * Nx * Ny;
4275 Element_pt[element_num] = new ELEMENT;
4276
4277 // The lowest nodes are copied from the lower element
4278 for (unsigned l1 = 0; l1 < n_p; l1++)
4279 {
4280 for (unsigned l2 = 0; l2 < n_p; l2++)
4281 {
4282 finite_element_pt(Nx * (Ny - 1) + (Nz - 1) * Nx * Ny)
4283 ->node_pt(l2 + n_p * l1) =
4284 finite_element_pt(Nx * (Ny - 1) + (Nz - 2) * Nx * Ny)
4285 ->node_pt(l2 + n_p * l1 + (n_p - 1) * n_p * n_p);
4286 }
4287 }
4288
4289 // We jump to the third dimension but the last layer of nodes
4290 for (unsigned l3 = 1; l3 < (n_p - 1); l3++)
4291 {
4292 // The first row of nodes is copied from the element below
4293 for (unsigned l2 = 0; l2 < n_p; l2++)
4294 {
4295 finite_element_pt(Nx * (Ny - 1) + (Nz - 1) * Nx * Ny)
4296 ->node_pt(l2 + l3 * n_p * n_p) =
4297 finite_element_pt(Nx * (Ny - 2) + (Nz - 1) * Nx * Ny)
4298 ->node_pt((n_p - 1) * n_p + l2 + l3 * n_p * n_p);
4299 }
4300
4301 // Second row of nodes
4302 // First column of nodes
4303 for (unsigned l1 = 1; l1 < (n_p - 1); l1++)
4304 {
4305 // Determine number of values
4306 local_node_num = n_p * l1 + l3 * n_p * n_p;
4307
4308 // Allocate memory for node
4310 finite_element_pt(element_num)
4311 ->construct_boundary_node(local_node_num, time_stepper_pt);
4312 // Set the pointer from the element
4313 finite_element_pt(element_num)->node_pt(local_node_num) =
4315
4316 // Get the fractional position of the node
4317 finite_element_pt(element_num)
4318 ->local_fraction_of_node(local_node_num, s_fraction);
4319
4320 // Set the position of the node
4321 Node_pt[node_count]->x(0) = Xmin;
4322 Node_pt[node_count]->x(1) =
4323 Ymin + el_length[1] * (Ny - 1 + s_fraction[1]);
4324 Node_pt[node_count]->x(2) =
4325 Zmin + el_length[2] * (Nz - 1 + s_fraction[2]);
4326
4327 // Add the node to the boundary 4
4328 add_boundary_node(4, Node_pt[node_count]);
4329
4330 // Increment the node number
4331 node_count++;
4332
4333 // Now do the other columns
4334 for (unsigned l2 = 1; l2 < n_p; l2++)
4335 {
4336 // Determine number of values
4337 local_node_num = n_p * l1 + l2 + l3 * n_p * n_p;
4338
4339 // Allocate memory for node
4341 finite_element_pt(element_num)
4342 ->construct_node(local_node_num, time_stepper_pt);
4343 // Set the pointer from the element
4344 finite_element_pt(element_num)->node_pt(local_node_num) =
4346
4347 // Get the fractional position of the node
4348 finite_element_pt(element_num)
4349 ->local_fraction_of_node(local_node_num, s_fraction);
4350
4351 // Set the position of the node
4352 Node_pt[node_count]->x(0) = Xmin + el_length[0] * s_fraction[0];
4353 Node_pt[node_count]->x(1) =
4354 Ymin + el_length[1] * (Ny - 1 + s_fraction[1]);
4355 Node_pt[node_count]->x(2) =
4356 Zmin + el_length[2] * (Nz - 1 + s_fraction[2]);
4357
4358 // No boundaries
4359
4360 // Increment the node number
4361 node_count++;
4362 }
4363 }
4364
4365 // Final row of nodes
4366 // First column of nodes
4367 // Top left node
4368 // Determine number of values
4369 local_node_num = n_p * (n_p - 1) + l3 * n_p * n_p;
4370 // Allocate memory for node
4372 finite_element_pt(element_num)
4373 ->construct_boundary_node(local_node_num, time_stepper_pt);
4374 // Set the pointer from the element
4375 finite_element_pt(element_num)->node_pt(local_node_num) =
4377
4378 // Get the fractional position of the node
4379 finite_element_pt(element_num)
4380 ->local_fraction_of_node(local_node_num, s_fraction);
4381
4382 // Set the position of the node
4383 Node_pt[node_count]->x(0) = Xmin;
4384 Node_pt[node_count]->x(1) = Ymax;
4385 Node_pt[node_count]->x(2) =
4386 Zmin + el_length[2] * (Nz - 1 + s_fraction[2]);
4387
4388 // Add the node to the boundaries
4389 add_boundary_node(3, Node_pt[node_count]);
4390 add_boundary_node(4, Node_pt[node_count]);
4391
4392 // Increment the node number
4393 node_count++;
4394
4395 // Now do the other columns
4396 for (unsigned l2 = 1; l2 < n_p; l2++)
4397 {
4398 // Determine number of values
4399 local_node_num = n_p * (n_p - 1) + l2 + l3 * n_p * n_p;
4400 // Allocate memory for the node
4402 finite_element_pt(element_num)
4403 ->construct_boundary_node(local_node_num, time_stepper_pt);
4404 // Set the pointer from the element
4405 finite_element_pt(element_num)->node_pt(local_node_num) =
4407
4408 // Get the fractional position of the node
4409 finite_element_pt(element_num)
4410 ->local_fraction_of_node(local_node_num, s_fraction);
4411
4412 // Set the position of the node
4413 Node_pt[node_count]->x(0) = Xmin + el_length[0] * s_fraction[0];
4414 Node_pt[node_count]->x(1) = Ymax;
4415 Node_pt[node_count]->x(2) =
4416 Zmin + el_length[2] * (Nz - 1 + s_fraction[2]);
4417
4418 // Add the node to the boundary 3
4419 add_boundary_node(3, Node_pt[node_count]);
4420
4421 // Increment the node number
4422 node_count++;
4423 }
4424 }
4425 // Now the top nodes
4426
4427 // The first row of nodes is copied from the element below
4428 for (unsigned l2 = 0; l2 < n_p; l2++)
4429 {
4430 finite_element_pt(Nx * (Ny - 1) + (Nz - 1) * Nx * Ny)
4431 ->node_pt(l2 + (n_p - 1) * n_p * n_p) =
4432 finite_element_pt(Nx * (Ny - 2) + (Nz - 1) * Nx * Ny)
4433 ->node_pt((n_p - 1) * n_p + l2 + (n_p - 1) * n_p * n_p);
4434 }
4435
4436 // Second row of nodes
4437 // First column of nodes
4438 for (unsigned l1 = 1; l1 < (n_p - 1); l1++)
4439 {
4440 // Determine number of values
4441 local_node_num = n_p * l1 + (n_p - 1) * n_p * n_p;
4442
4443 // Allocate memory for node
4445 finite_element_pt(element_num)
4446 ->construct_boundary_node(local_node_num, time_stepper_pt);
4447 // Set the pointer from the element
4448 finite_element_pt(element_num)->node_pt(local_node_num) =
4450
4451 // Get the fractional position of the node
4452 finite_element_pt(element_num)
4453 ->local_fraction_of_node(local_node_num, s_fraction);
4454
4455 // Set the position of the node
4456 Node_pt[node_count]->x(0) = Xmin;
4457 Node_pt[node_count]->x(1) =
4458 Ymin + el_length[1] * (Ny - 1 + s_fraction[1]);
4459 Node_pt[node_count]->x(2) = Zmax;
4460
4461 // Add the node to the boundaries 4 and 5
4462 add_boundary_node(4, Node_pt[node_count]);
4463 add_boundary_node(5, Node_pt[node_count]);
4464
4465 // Increment the node number
4466 node_count++;
4467
4468 // Now do the other columns
4469 for (unsigned l2 = 1; l2 < n_p; l2++)
4470 {
4471 // Determine number of values
4472 local_node_num = n_p * l1 + l2 + (n_p - 1) * n_p * n_p;
4473
4474 // Allocate memory for node
4476 finite_element_pt(element_num)
4477 ->construct_boundary_node(local_node_num, time_stepper_pt);
4478 // Set the pointer from the element
4479 finite_element_pt(element_num)->node_pt(local_node_num) =
4481 // Get the fractional position of the node
4482 finite_element_pt(element_num)
4483 ->local_fraction_of_node(local_node_num, s_fraction);
4484
4485 // Set the position of the node
4486 Node_pt[node_count]->x(0) = Xmin + el_length[0] * s_fraction[0];
4487 Node_pt[node_count]->x(1) =
4488 Ymin + el_length[1] * (Ny - 1 + s_fraction[1]);
4489 Node_pt[node_count]->x(2) = Zmax;
4490
4491 // Add the node to the boundary 5
4492 add_boundary_node(5, Node_pt[node_count]);
4493
4494 // Increment the node number
4495 node_count++;
4496 }
4497 }
4498
4499 // Final row of nodes
4500 // First column of nodes
4501 // Top left node
4502 // Determine number of values
4503 local_node_num = n_p * (n_p - 1) + (n_p - 1) * n_p * n_p;
4504 // Allocate memory for node
4506 finite_element_pt(element_num)
4507 ->construct_boundary_node(local_node_num, time_stepper_pt);
4508 // Set the pointer from the element
4509 finite_element_pt(element_num)->node_pt(local_node_num) =
4511 // Get the fractional position of the node
4512 finite_element_pt(element_num)
4513 ->local_fraction_of_node(local_node_num, s_fraction);
4514
4515 // Set the position of the node
4516 Node_pt[node_count]->x(0) = Xmin;
4517 Node_pt[node_count]->x(1) = Ymax;
4518 Node_pt[node_count]->x(2) = Zmax;
4519
4520 // Add the node to the boundaries
4521 add_boundary_node(3, Node_pt[node_count]);
4522 add_boundary_node(4, Node_pt[node_count]);
4523 add_boundary_node(5, Node_pt[node_count]);
4524
4525 // Increment the node number
4526 node_count++;
4527
4528 // Now do the other columns
4529 for (unsigned l2 = 1; l2 < n_p; l2++)
4530 {
4531 // Determine number of values
4532 local_node_num = n_p * (n_p - 1) + l2 + (n_p - 1) * n_p * n_p;
4533 // Allocate memory for the node
4535 finite_element_pt(element_num)
4536 ->construct_boundary_node(local_node_num, time_stepper_pt);
4537 // Set the pointer from the element
4538 finite_element_pt(element_num)->node_pt(local_node_num) =
4540
4541 // Get the fractional position of the node
4542 finite_element_pt(element_num)
4543 ->local_fraction_of_node(local_node_num, s_fraction);
4544
4545 // Set the position of the node
4546 Node_pt[node_count]->x(0) = Xmin + el_length[0] * s_fraction[0];
4547 Node_pt[node_count]->x(1) = Ymax;
4548 Node_pt[node_count]->x(2) = Zmax;
4549
4550 // Add the node to the boundaries 3 and 5
4551 add_boundary_node(3, Node_pt[node_count]);
4552 add_boundary_node(5, Node_pt[node_count]);
4553
4554 // Increment the node number
4555 node_count++;
4556 }
4557
4558 // Now loop over the rest of the elements in the row, apart from the last
4559 for (unsigned j = 1; j < (Nx - 1); j++)
4560 {
4561 // Allocate memory for element
4562 element_num = Nx * (Ny - 1) + j + (Nz - 1) * Nx * Ny;
4563 Element_pt[element_num] = new ELEMENT;
4564
4565 // The lowest nodes are copied from the lower element
4566 for (unsigned l1 = 0; l1 < n_p; l1++)
4567 {
4568 for (unsigned l2 = 0; l2 < n_p; l2++)
4569 {
4570 finite_element_pt(Nx * (Ny - 1) + j + (Nz - 1) * Nx * Ny)
4571 ->node_pt(l2 + n_p * l1) =
4572 finite_element_pt(Nx * (Ny - 1) + j + (Nz - 2) * Nx * Ny)
4573 ->node_pt(l2 + n_p * l1 + (n_p - 1) * n_p * n_p);
4574 }
4575 }
4576
4577 // Jump in the third dimension but the top nodes
4578
4579 for (unsigned l3 = 1; l3 < (n_p - 1); l3++)
4580 {
4581 // The first row is copied from the lower element
4582 for (unsigned l2 = 0; l2 < n_p; l2++)
4583 {
4584 finite_element_pt(Nx * (Ny - 1) + j + (Nz - 1) * Nx * Ny)
4585 ->node_pt(l2 + l3 * n_p * n_p) =
4586 finite_element_pt(Nx * (Ny - 2) + j + (Nz - 1) * Nx * Ny)
4587 ->node_pt((n_p - 1) * n_p + l2 + l3 * n_p * n_p);
4588 }
4589
4590 // Second rows
4591 for (unsigned l1 = 1; l1 < (n_p - 1); l1++)
4592 {
4593 // First column is same as neighbouring element
4594 finite_element_pt(Nx * (Ny - 1) + j + (Nz - 1) * Nx * Ny)
4595 ->node_pt(n_p * l1 + l3 * n_p * n_p) =
4596 finite_element_pt(Nx * (Ny - 1) + (j - 1) + (Nz - 1) * Nx * Ny)
4597 ->node_pt(n_p * l1 + (n_p - 1) + l3 * n_p * n_p);
4598
4599 // New nodes for other columns
4600 for (unsigned l2 = 1; l2 < n_p; l2++)
4601 {
4602 // Determine number of values
4603 local_node_num = n_p * l1 + l2 + l3 * n_p * n_p;
4604 // Allocate memory for the node
4606 finite_element_pt(element_num)
4607 ->construct_node(local_node_num, time_stepper_pt);
4608
4609 // Set the pointer
4610 finite_element_pt(element_num)->node_pt(local_node_num) =
4612
4613 // Get the fractional position of the node
4614 finite_element_pt(element_num)
4615 ->local_fraction_of_node(local_node_num, s_fraction);
4616
4617 // Set the position of the node
4618 Node_pt[node_count]->x(0) =
4619 Xmin + el_length[0] * (j + s_fraction[0]);
4620 Node_pt[node_count]->x(1) =
4621 Ymin + el_length[1] * (Ny - 1 + s_fraction[1]);
4622 Node_pt[node_count]->x(2) =
4623 Zmin + el_length[2] * (Nz - 1 + s_fraction[2]);
4624
4625 // No boundaries
4626
4627 // Increment the node number
4628 // add_boundary_node(0,Node_pt[node_count]);
4629 node_count++;
4630 }
4631 }
4632
4633 // Top row
4634 // First column is same as neighbouring element
4635 finite_element_pt(Nx * (Ny - 1) + j + (Nz - 1) * Nx * Ny)
4636 ->node_pt(n_p * (n_p - 1) + l3 * n_p * n_p) =
4637 finite_element_pt(Nx * (Ny - 1) + (j - 1) + (Nz - 1) * Nx * Ny)
4638 ->node_pt(n_p * (n_p - 1) + (n_p - 1) + l3 * n_p * n_p);
4639 // New nodes for other columns
4640 for (unsigned l2 = 1; l2 < n_p; l2++)
4641 {
4642 // Determine number of values
4643 local_node_num = n_p * (n_p - 1) + l2 + l3 * n_p * n_p;
4644 // Allocate memory for node
4646 finite_element_pt(element_num)
4647 ->construct_boundary_node(local_node_num, time_stepper_pt);
4648 // Set the pointer
4649 finite_element_pt(element_num)->node_pt(local_node_num) =
4651
4652 // Get the fractional position of the node
4653 finite_element_pt(element_num)
4654 ->local_fraction_of_node(local_node_num, s_fraction);
4655
4656 // Set the position of the node
4657 Node_pt[node_count]->x(0) = Xmin + el_length[0] * (j + s_fraction[0]);
4658 Node_pt[node_count]->x(1) = Ymax;
4659 Node_pt[node_count]->x(2) =
4660 Zmin + el_length[2] * (Nz - 1 + s_fraction[2]);
4661
4662 // Add the node to the boundary
4663 add_boundary_node(3, Node_pt[node_count]);
4664
4665 // Increment the node number
4666 node_count++;
4667 }
4668 }
4669
4670 // Now the top nodes
4671
4672 // The first row is copied from the lower element
4673 for (unsigned l2 = 0; l2 < n_p; l2++)
4674 {
4675 finite_element_pt(Nx * (Ny - 1) + j + (Nz - 1) * Nx * Ny)
4676 ->node_pt(l2 + (n_p - 1) * n_p * n_p) =
4677 finite_element_pt(Nx * (Ny - 2) + j + (Nz - 1) * Nx * Ny)
4678 ->node_pt((n_p - 1) * n_p + l2 + (n_p - 1) * n_p * n_p);
4679 }
4680
4681 // Second rows
4682 for (unsigned l1 = 1; l1 < (n_p - 1); l1++)
4683 {
4684 // First column is same as neighbouring element
4685 finite_element_pt(Nx * (Ny - 1) + j + (Nz - 1) * Nx * Ny)
4686 ->node_pt(n_p * l1 + (n_p - 1) * n_p * n_p) =
4687 finite_element_pt(Nx * (Ny - 1) + (j - 1) + (Nz - 1) * Nx * Ny)
4688 ->node_pt(n_p * l1 + (n_p - 1) + (n_p - 1) * n_p * n_p);
4689
4690 // New nodes for other columns
4691 for (unsigned l2 = 1; l2 < n_p; l2++)
4692 {
4693 // Determine number of values
4694 local_node_num = n_p * l1 + l2 + (n_p - 1) * n_p * n_p;
4695 // Allocate memory for the node
4697 finite_element_pt(element_num)
4698 ->construct_boundary_node(local_node_num, time_stepper_pt);
4699
4700 // Set the pointer
4701 finite_element_pt(element_num)->node_pt(local_node_num) =
4703
4704 // Get the fractional position of the node
4705 finite_element_pt(element_num)
4706 ->local_fraction_of_node(local_node_num, s_fraction);
4707
4708 // Set the position of the node
4709 Node_pt[node_count]->x(0) = Xmin + el_length[0] * (j + s_fraction[0]);
4710 Node_pt[node_count]->x(1) =
4711 Ymin + el_length[1] * (Ny - 1 + s_fraction[1]);
4712 Node_pt[node_count]->x(2) = Zmax;
4713
4714 // Add the node to the boundary 5
4715 add_boundary_node(5, Node_pt[node_count]);
4716
4717 // Increment the node number add_boundary_node(0,Node_pt[node_count]);
4718 node_count++;
4719 }
4720 }
4721
4722 // Top row
4723 // First column is same as neighbouring element
4724 finite_element_pt(Nx * (Ny - 1) + j + (Nz - 1) * Nx * Ny)
4725 ->node_pt(n_p * (n_p - 1) + (n_p - 1) * n_p * n_p) =
4726 finite_element_pt(Nx * (Ny - 1) + (j - 1) + (Nz - 1) * Nx * Ny)
4727 ->node_pt(n_p * (n_p - 1) + (n_p - 1) + (n_p - 1) * n_p * n_p);
4728 // New nodes for other columns
4729 for (unsigned l2 = 1; l2 < n_p; l2++)
4730 {
4731 // Determine number of values
4732 local_node_num = n_p * (n_p - 1) + l2 + (n_p - 1) * n_p * n_p;
4733 // Allocate memory for node
4735 finite_element_pt(element_num)
4736 ->construct_boundary_node(local_node_num, time_stepper_pt);
4737 // Set the pointer
4738 finite_element_pt(element_num)->node_pt(local_node_num) =
4740
4741 // Get the fractional position of the node
4742 finite_element_pt(element_num)
4743 ->local_fraction_of_node(local_node_num, s_fraction);
4744
4745 // Set the position of the node
4746 Node_pt[node_count]->x(0) = Xmin + el_length[0] * (j + s_fraction[0]);
4747 Node_pt[node_count]->x(1) = Ymax;
4748 Node_pt[node_count]->x(2) = Zmax;
4749
4750 // Add the node to the boundaries 3 and 5
4751 add_boundary_node(3, Node_pt[node_count]);
4752 add_boundary_node(5, Node_pt[node_count]);
4753
4754 // Increment the node number
4755 node_count++;
4756 }
4757
4758 } // End of loop over central elements in row
4759
4760 // LAST ELEMENT (Really!!)
4761 //-----------------------------------------
4762
4763 // Allocate memory for element
4764 element_num = Nx * (Ny - 1) + Nx - 1 + (Nz - 1) * Nx * Ny;
4765 Element_pt[element_num] = new ELEMENT;
4766
4767 // The lowest nodes are copied from the lower element
4768 for (unsigned l1 = 0; l1 < n_p; l1++)
4769 {
4770 for (unsigned l2 = 0; l2 < n_p; l2++)
4771 {
4772 finite_element_pt(Nx * (Ny - 1) + Nx - 1 + (Nz - 1) * Nx * Ny)
4773 ->node_pt(l2 + n_p * l1) =
4774 finite_element_pt(Nx * (Ny - 1) + Nx - 1 + (Nz - 2) * Nx * Ny)
4775 ->node_pt(l2 + n_p * l1 + (n_p - 1) * n_p * n_p);
4776 }
4777 }
4778
4779 // We jump to the third dimension but the top nodes
4780
4781 for (unsigned l3 = 1; l3 < (n_p - 1); l3++)
4782 {
4783 // The first row is copied from the lower element
4784 for (unsigned l2 = 0; l2 < n_p; l2++)
4785 {
4786 finite_element_pt(Nx * (Ny - 1) + Nx - 1 + (Nz - 1) * Nx * Ny)
4787 ->node_pt(l2 + l3 * n_p * n_p) =
4788 finite_element_pt(Nx * (Ny - 2) + Nx - 1 + (Nz - 1) * Nx * Ny)
4789 ->node_pt((n_p - 1) * n_p + l2 + l3 * n_p * n_p);
4790 }
4791
4792 // Second rows
4793 for (unsigned l1 = 1; l1 < (n_p - 1); l1++)
4794 {
4795 // First column is same as neighbouring element
4796 finite_element_pt(Nx * (Ny - 1) + Nx - 1 + (Nz - 1) * Nx * Ny)
4797 ->node_pt(n_p * l1 + l3 * n_p * n_p) =
4798 finite_element_pt(Nx * (Ny - 1) + Nx - 2 + (Nz - 1) * Nx * Ny)
4799 ->node_pt(n_p * l1 + (n_p - 1) + l3 * n_p * n_p);
4800
4801 // Middle nodes
4802 for (unsigned l2 = 1; l2 < (n_p - 1); l2++)
4803 {
4804 // Determine number of values
4805 local_node_num = n_p * l1 + l2 + l3 * n_p * n_p;
4806 // Allocate memory for node
4808 finite_element_pt(element_num)
4809 ->construct_node(local_node_num, time_stepper_pt);
4810 // Set the pointer
4811 finite_element_pt(element_num)->node_pt(local_node_num) =
4813
4814 // Get the fractional position of the node
4815 finite_element_pt(element_num)
4816 ->local_fraction_of_node(local_node_num, s_fraction);
4817
4818 // Set the position of the node
4819 Node_pt[node_count]->x(0) =
4820 Xmin + el_length[0] * (Nx - 1 + s_fraction[0]);
4821 Node_pt[node_count]->x(1) =
4822 Ymin + el_length[1] * (Ny - 1 + s_fraction[1]);
4823 Node_pt[node_count]->x(2) =
4824 Zmin + el_length[2] * (Nz - 1 + s_fraction[2]);
4825
4826 // No boundaries
4827
4828 // Increment the node number
4829 node_count++;
4830 }
4831
4832 // Final node
4833 // Determine number of values
4834 local_node_num = n_p * l1 + (n_p - 1) + l3 * n_p * n_p;
4835 // Allocate memory for node
4837 finite_element_pt(element_num)
4838 ->construct_boundary_node(local_node_num, time_stepper_pt);
4839 // Set the pointer
4840 finite_element_pt(element_num)->node_pt(local_node_num) =
4842
4843 // Get the fractional position of the node
4844 finite_element_pt(element_num)
4845 ->local_fraction_of_node(local_node_num, s_fraction);
4846
4847 // Set the position of the node
4848 Node_pt[node_count]->x(0) = Xmax;
4849 Node_pt[node_count]->x(1) =
4850 Ymin + el_length[1] * (Ny - 1 + s_fraction[1]);
4851 Node_pt[node_count]->x(2) =
4852 Zmin + el_length[2] * (Nz - 1 + s_fraction[2]);
4853
4854 // Add the node to the boundary 2
4855 add_boundary_node(2, Node_pt[node_count]);
4856
4857 // Increment the node number
4858 node_count++;
4859
4860 } // End of loop over middle rows
4861
4862 // Final row
4863 // First column is same as neighbouring element
4864 finite_element_pt(Nx * (Ny - 1) + Nx - 1 + (Nz - 1) * Nx * Ny)
4865 ->node_pt(n_p * (n_p - 1) + l3 * n_p * n_p) =
4866 finite_element_pt(Nx * (Ny - 1) + Nx - 2 + (Nz - 1) * Nx * Ny)
4867 ->node_pt(n_p * (n_p - 1) + (n_p - 1) + l3 * n_p * n_p);
4868
4869 // Middle nodes
4870 for (unsigned l2 = 1; l2 < (n_p - 1); l2++)
4871 {
4872 // Determine number of values
4873 local_node_num = n_p * (n_p - 1) + l2 + l3 * n_p * n_p;
4874 // Allocate memory for node
4876 finite_element_pt(element_num)
4877 ->construct_boundary_node(local_node_num, time_stepper_pt);
4878 // Set the pointer
4879 finite_element_pt(element_num)->node_pt(local_node_num) =
4881
4882 // Get the fractional position of the node
4883 finite_element_pt(element_num)
4884 ->local_fraction_of_node(local_node_num, s_fraction);
4885
4886 // Set the position of the node
4887 Node_pt[node_count]->x(0) =
4888 Xmin + el_length[0] * (Nx - 1 + s_fraction[0]);
4889 Node_pt[node_count]->x(1) = Ymax;
4890 Node_pt[node_count]->x(2) =
4891 Zmin + el_length[2] * (Nz - 1 + s_fraction[2]);
4892
4893 // Add the node to the boundary 3
4894 add_boundary_node(3, Node_pt[node_count]);
4895
4896 // Increment the node number
4897 node_count++;
4898 }
4899
4900 // Final node
4901 // Determine number of values
4902 local_node_num = n_p * (n_p - 1) + (n_p - 1) + l3 * n_p * n_p;
4903 // Allocate memory for node
4905 finite_element_pt(element_num)
4906 ->construct_boundary_node(local_node_num, time_stepper_pt);
4907 // Set the pointer
4908 finite_element_pt(element_num)->node_pt(local_node_num) =
4910
4911 // Get the fractional position of the node
4912 finite_element_pt(element_num)
4913 ->local_fraction_of_node(local_node_num, s_fraction);
4914
4915 // Set the position of the node
4916 Node_pt[node_count]->x(0) = Xmax;
4917 // In fluid 2
4918 Node_pt[node_count]->x(1) = Ymax;
4919 Node_pt[node_count]->x(2) =
4920 Zmin + el_length[2] * (Nz - 1 + s_fraction[2]);
4921
4922 // Add the node to the boundaries 2 and 3
4923 add_boundary_node(2, Node_pt[node_count]);
4924 add_boundary_node(3, Node_pt[node_count]);
4925
4926 // Increment the node number
4927 node_count++;
4928 }
4929
4930 // Now the top nodes
4931
4932 // The first row is copied from the lower element
4933 for (unsigned l2 = 0; l2 < n_p; l2++)
4934 {
4935 finite_element_pt(Nx * (Ny - 1) + Nx - 1 + (Nz - 1) * Nx * Ny)
4936 ->node_pt(l2 + (n_p - 1) * n_p * n_p) =
4937 finite_element_pt(Nx * (Ny - 2) + Nx - 1 + (Nz - 1) * Nx * Ny)
4938 ->node_pt((n_p - 1) * n_p + l2 + (n_p - 1) * n_p * n_p);
4939 }
4940
4941 // Second rows
4942 for (unsigned l1 = 1; l1 < (n_p - 1); l1++)
4943 {
4944 // First column is same as neighbouring element
4945 finite_element_pt(Nx * (Ny - 1) + Nx - 1 + (Nz - 1) * Nx * Ny)
4946 ->node_pt(n_p * l1 + (n_p - 1) * n_p * n_p) =
4947 finite_element_pt(Nx * (Ny - 1) + Nx - 2 + (Nz - 1) * Nx * Ny)
4948 ->node_pt(n_p * l1 + (n_p - 1) + (n_p - 1) * n_p * n_p);
4949
4950 // Middle nodes
4951 for (unsigned l2 = 1; l2 < (n_p - 1); l2++)
4952 {
4953 // Determine number of values
4954 local_node_num = n_p * l1 + l2 + (n_p - 1) * n_p * n_p;
4955 // Allocate memory for node
4957 finite_element_pt(element_num)
4958 ->construct_boundary_node(local_node_num, time_stepper_pt);
4959 // Set the pointer
4960 finite_element_pt(element_num)->node_pt(local_node_num) =
4962
4963 // Get the fractional position of the node
4964 finite_element_pt(element_num)
4965 ->local_fraction_of_node(local_node_num, s_fraction);
4966
4967 // Set the position of the node
4968 Node_pt[node_count]->x(0) =
4969 Xmin + el_length[0] * (Nx - 1 + s_fraction[0]);
4970 Node_pt[node_count]->x(1) =
4971 Ymin + el_length[1] * (Ny - 1 + s_fraction[1]);
4972 Node_pt[node_count]->x(2) = Zmax;
4973
4974 // Add to boundary 5
4975 add_boundary_node(5, Node_pt[node_count]);
4976
4977 // Increment the node number
4978 node_count++;
4979 }
4980
4981 // Final node
4982 // Determine number of values
4983 local_node_num = n_p * l1 + (n_p - 1) + (n_p - 1) * n_p * n_p;
4984 // Allocate memory for node
4986 finite_element_pt(element_num)
4987 ->construct_boundary_node(local_node_num, time_stepper_pt);
4988 // Set the pointer
4989 finite_element_pt(element_num)->node_pt(local_node_num) =
4991
4992 // Set the position of the node
4993 Node_pt[node_count]->x(0) = Xmax;
4994 Node_pt[node_count]->x(1) =
4995 Ymin + el_length[1] * (Ny - 1 + s_fraction[1]);
4996 Node_pt[node_count]->x(2) = Zmax;
4997
4998 // Add the node to the boundaries 2 and 5
4999 add_boundary_node(2, Node_pt[node_count]);
5000 add_boundary_node(5, Node_pt[node_count]);
5001
5002 // Increment the node number
5003 node_count++;
5004
5005 } // End of loop over middle rows
5006
5007 // Final row
5008 // First node is same as neighbouring element
5009 finite_element_pt(Nx * (Ny - 1) + Nx - 1 + (Nz - 1) * Nx * Ny)
5010 ->node_pt(n_p * (n_p - 1) + (n_p - 1) * n_p * n_p) =
5011 finite_element_pt(Nx * (Ny - 1) + Nx - 2 + (Nz - 1) * Nx * Ny)
5012 ->node_pt(n_p * (n_p - 1) + (n_p - 1) + (n_p - 1) * n_p * n_p);
5013
5014 // Middle nodes
5015 for (unsigned l2 = 1; l2 < (n_p - 1); l2++)
5016 {
5017 // Determine number of values
5018 local_node_num = n_p * (n_p - 1) + l2 + (n_p - 1) * n_p * n_p;
5019 // Allocate memory for node
5021 finite_element_pt(element_num)
5022 ->construct_boundary_node(local_node_num, time_stepper_pt);
5023 // Set the pointer
5024 finite_element_pt(element_num)->node_pt(local_node_num) =
5026
5027 // Get the fractional position of the node
5028 finite_element_pt(element_num)
5029 ->local_fraction_of_node(local_node_num, s_fraction);
5030
5031 // Set the position of the node
5032 Node_pt[node_count]->x(0) =
5033 Xmin + el_length[0] * (Nx - 1 + s_fraction[0]);
5034 Node_pt[node_count]->x(1) = Ymax;
5035 Node_pt[node_count]->x(2) = Zmax;
5036
5037 // Add the node to the boundary 3
5038 add_boundary_node(3, Node_pt[node_count]);
5039 add_boundary_node(5, Node_pt[node_count]);
5040
5041 // Increment the node number
5042 node_count++;
5043 }
5044
5045 // Final node (really!!)
5046 // Determine number of values
5047 local_node_num = n_p * (n_p - 1) + (n_p - 1) + (n_p - 1) * n_p * n_p;
5048 // Allocate memory for node
5050 finite_element_pt(element_num)
5051 ->construct_boundary_node(local_node_num, time_stepper_pt);
5052 // Set the pointer
5053 finite_element_pt(element_num)->node_pt(local_node_num) =
5055
5056 // Get the fractional position of the node
5057 finite_element_pt(element_num)
5058 ->local_fraction_of_node(local_node_num, s_fraction);
5059
5060 // Set the position of the node
5061 Node_pt[node_count]->x(0) = Xmax;
5062 Node_pt[node_count]->x(1) = Ymax;
5063 Node_pt[node_count]->x(2) = Zmax;
5064
5065 // Add the node to the boundaries 2, 3 and 5
5066 add_boundary_node(2, Node_pt[node_count]);
5067 add_boundary_node(3, Node_pt[node_count]);
5068 add_boundary_node(5, Node_pt[node_count]);
5069
5070 // Increment the node number
5071 node_count++;
5072
5073 // Setup lookup scheme that establishes which elements are located
5074 // on the mesh boundaries
5075 setup_boundary_element_info();
5076 }
5077
5078} // namespace oomph
5079
5080#endif
cstr elem_len * i
Definition cfortran.h:603
Node ** Node_pt
Storage for pointers to the nodes in the element.
Definition elements.h:1323
Node *& node_pt(const unsigned &n)
Return a pointer to the local node n.
Definition elements.h:2179
virtual unsigned nnode_1d() const
Return the number of nodes along one edge of the element Default is to return zero — must be overload...
Definition elements.h:2222
TimeStepper *& time_stepper_pt()
Access function for pointer to time stepper: Null if object is not time-dependent.
double & x(const unsigned &i)
Return the i-th nodal coordinate.
Definition nodes.h:1060
void resize(const unsigned &n_value)
Resize the number of equations.
Definition nodes.cc:2167
An OomphLibError object which should be thrown when an run-time error is encountered....
void build_mesh(TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Generic mesh construction function: contains all the hard work.
TAdvectionDiffusionReactionElement<NREAGENT,DIM,NNODE_1D> elements are isoparametric triangular DIM-d...
TAdvectionDiffusionReactionElement()
Constructor: Call constructors for TElement and AdvectionDiffusionReaction equations.
Base class for time-stepping schemes. Timestepper provides an approximation of the temporal derivativ...
DRAIG: Change all instances of (SPATIAL_DIM) to (DIM-1).