49 #define CUMUL_EDGES ( fe_edges ) 50 #define CUMUL_FACES ( fe_edges + fe_faces ) 51 #define CUMUL_QUADS ( fe_edges + fe_faces + fe_quads ) 52 #define CUMUL_TETRAS ( fe_edges + fe_faces + fe_quads + fe_tetras ) 53 #define CUMUL_HEXAS ( fe_edges + fe_faces + fe_quads + fe_tetras + fe_hexas ) 57 #define elem_type(ID) ( ( ( ID ) <= CUMUL_EDGES ) ? EDGE_ELEM : \ 58 ( ( ID ) <= CUMUL_FACES ) ? FACE_ELEM : \ 59 ( ( ID ) <= CUMUL_QUADS ) ? QUAD_ELEM : \ 60 ( ( ID ) <= CUMUL_TETRAS ) ? TETRA_ELEM : \ 61 ( ( ID ) <= CUMUL_HEXAS ) ? HEXA_ELEM : 0 ) 63 #define is_edge(ID) ( ( elem_type(ID) == EDGE_ELEM ) ? 1 : 0 ) 64 #define is_face(ID) ( ( elem_type(ID) == FACE_ELEM ) ? 1 : 0 ) 65 #define is_quad(ID) ( ( elem_type(ID) == QUAD_ELEM ) ? 1 : 0 ) 66 #define is_tetra(ID) ( ( elem_type(ID) == TETRA_ELEM ) ? 1 : 0 ) 67 #define is_hexa(ID) ( ( elem_type(ID) == HEXA_ELEM ) ? 1 : 0 ) 78 #define global_edge_id(ID) ( ( ID ) ) 79 #define global_face_id(ID) ( ( ID ) + CUMUL_EDGES ) 80 #define global_quad_id(ID) ( ( ID ) + CUMUL_FACES ) 81 #define global_tetra_id(ID) ( ( ID ) + CUMUL_QUADS ) 82 #define global_hexa_id(ID) ( ( ID ) + CUMUL_TETRAS ) 85 #define local_edge_id(ID) ( ( ID ) ) 86 #define local_face_id(ID) ( ( ID ) -CUMUL_EDGES ) 87 #define local_quad_id(ID) ( ( ID ) -CUMUL_FACES ) 88 #define local_tetra_id(ID) ( ( ID ) -CUMUL_QUADS ) 89 #define local_hexa_id(ID) ( ( ID ) -CUMUL_TETRAS ) 92 #define matrix_2d(ARRAY, U, V) ( ARRAY ) [ ( level + 2 ) * ( V ) + ( U ) ] 93 #define matrix_3d(ARRAY, U, V, W) ( ARRAY ) [ ( level + 2 ) * ( level + 2 ) * ( W ) + ( level + 2 ) * ( V ) + ( U ) ] 96 #define error_message(MSG) { OOFEM_LOG_RELEVANT( "refineMeshGlobally: %s\n", ( MSG ) ); return ( -1 ); } 121 int jj, kk = 0, j1, j2, j3, j4, type;
122 long node, elem, nd, pos = 0, p, number, size;
123 long i, j, k, m, n, node1, node2, node3, node4, elem1, elem2;
124 long refine_nodes, fine_node_id, refine_node_id;
125 long mesh_edge_id, fine_edge_id, fine_quad_id, fine_hexa_id;
126 long *tmp_array_start [ 4 ], *tmp_array_end [ 4 ];
127 long *tmp_array_cen [ 6 ], *tmp_array [ 12 ];
128 int swap [ 6 ], flag;
131 IntArray *connectivity = NULL, *boundary = NULL;
133 long fe_nodes = 0, fe_elems = 0;
134 long fe_edges = 0, fe_faces = 0, fe_quads = 0, fe_tetras = 0, fe_hexas = 0, fe_pyrams = 0, fe_wedges = 0;
135 long edge_id = 0, face_id = 0, quad_id = 0, tetra_id = 0, hexa_id = 0;
136 long mesh_edges = 0, mesh_faces = 0, mesh_quads = 0;
137 long fine_nodes = 0, fine_edges = 0, fine_quads = 0, fine_hexas = 0;
139 fe_node_rec *fe_node = NULL, *fe_node_array = NULL;
140 fe_edge_rec *fe_edge = NULL, *fe_edge_array = NULL;
141 fe_face_rec *fe_face = NULL, *fe_face_array = NULL;
142 fe_quad_rec *fe_quad = NULL, *fe_quad_array = NULL;
144 fe_hexa_rec *fe_hexa = NULL, *fe_hexa_array = NULL;
146 fe_node_rec *fine_node = NULL, *fine_node_array = NULL;
150 fe_node_rec *nd1 = NULL, *nd2 = NULL, *nd3 = NULL, *nd4 = NULL;
153 mesh_face_rec *mesh_face = NULL, *mesh_face_array = NULL, *mesh_fc [ 4 ];
154 mesh_quad_rec *mesh_quad = NULL, *mesh_quad_array = NULL, *mesh_qd [ 6 ];
156 #ifdef COMPLETE_DATA_STRUCTURE 157 tmp_face_rec *tmp_face = NULL, *tmp_face_array = NULL, *tmp_fc = NULL;
158 tmp_quad_rec *tmp_quad = NULL, *tmp_quad_array = NULL, *tmp_qd = NULL;
161 tmp_tetra_rec *tmp_tetra = NULL, *tmp_tetra_array = NULL, *tmp_tet = NULL;
162 tmp_hexa_rec *tmp_hexa = NULL, *tmp_hexa_array = NULL, *tmp_hx = NULL;
168 long *node_num_elems = NULL, *node_con_elems = NULL;
169 long *node_num_nodes = NULL, *node_con_nodes = NULL;
173 short face_ed_nd [ 3 ] [ 2 ] = { { 0, 1 }, { 1, 2 }, { 2, 0 } };
174 short quad_ed_nd [ 4 ] [ 2 ] = { { 0, 1 }, { 1, 2 }, { 2, 3 }, { 3, 0 } };
178 short tetra_fc_nd [ 4 ] [ 3 ] = { { 0, 1, 2 }, { 0, 1, 3 }, { 1, 2, 3 }, { 2, 0, 3 } };
182 short hexa_fc_nd [ 6 ] [ 4 ] = { { 0, 1, 2, 3 }, { 0, 1, 5, 4 }, { 1, 2, 6, 5 }, { 2, 3, 7, 6 }, { 3, 0, 4, 7 }, { 7, 6, 5, 4 } };
184 short quad_con_nd [ 4 ] [ 2 ] = { { 1, 3 }, { 2, 0 }, { 3, 1 }, { 0, 2 } };
185 short hexa_con_nd [ 8 ] [ 3 ] = { { 1, 3, 4 }, { 2, 0, 5 }, { 3, 1, 6 }, { 0, 2, 7 }, { 7, 5, 0 }, { 4, 6, 1 }, { 5, 7, 2 }, { 6, 4, 3 } };
190 for ( i = 0; i < fe_elems; i++ ) {
214 if ( fe_nodes == 0 ) {
218 if ( fe_nodes != 0 ) {
224 if ( fe_edges != 0 ) {
230 if ( fe_faces != 0 ) {
236 if ( fe_quads != 0 ) {
242 if ( fe_tetras != 0 ) {
248 if ( fe_hexas != 0 ) {
254 fe_node = fe_node_array;
255 for ( i = 0; i < fe_nodes; i++, fe_node++ ) {
259 edge_id = face_id = quad_id = tetra_id = hexa_id = 0;
260 for ( i = 0; i < fe_elems; i++ ) {
264 fe_edge = & ( fe_edge_array [ edge_id++ ] );
265 for ( j = 0; j < 2; j++ ) {
267 if ( nd <= 0 || nd > fe_nodes ) {
271 fe_edge->
node [ j ] = & ( fe_node_array [ nd - 1 ] );
276 fe_face = & ( fe_face_array [ face_id++ ] );
277 for ( j = 0; j < 3; j++ ) {
279 if ( nd <= 0 || nd > fe_nodes ) {
283 fe_face->
node [ j ] = & ( fe_node_array [ nd - 1 ] );
288 fe_quad = & ( fe_quad_array [ quad_id++ ] );
289 for ( j = 0; j < 4; j++ ) {
291 if ( nd <= 0 || nd > fe_nodes ) {
295 fe_quad->
node [ j ] = & ( fe_node_array [ nd - 1 ] );
300 fe_tetra = & ( fe_tetra_array [ tetra_id++ ] );
301 for ( j = 0; j < 4; j++ ) {
303 if ( nd <= 0 || nd > fe_nodes ) {
307 fe_tetra->
node [ j ] = & ( fe_node_array [ nd - 1 ] );
312 fe_hexa = & ( fe_hexa_array [ hexa_id++ ] );
313 for ( j = 0; j < 8; j++ ) {
315 if ( nd <= 0 || nd > fe_nodes ) {
319 fe_hexa->
node [ j ] = & ( fe_node_array [ nd - 1 ] );
331 if ( ( node_num_elems = (
long * ) calloc( fe_nodes + 1,
sizeof(
long ) ) ) == NULL ) {
335 fe_edge = fe_edge_array;
336 for ( i = 0; i < fe_edges; i++, fe_edge++ ) {
337 for ( j = 0; j < 2; j++ ) {
338 nd = fe_edge->
node [ j ]->
id;
339 node_num_elems [ nd - 1 ]++;
343 fe_face = fe_face_array;
344 for ( i = 0; i < fe_faces; i++, fe_face++ ) {
345 for ( j = 0; j < 3; j++ ) {
346 nd = fe_face->
node [ j ]->
id;
347 node_num_elems [ nd - 1 ]++;
351 fe_quad = fe_quad_array;
352 for ( i = 0; i < fe_quads; i++, fe_quad++ ) {
353 for ( j = 0; j < 4; j++ ) {
354 nd = fe_quad->
node [ j ]->
id;
355 node_num_elems [ nd - 1 ]++;
359 fe_tetra = fe_tetra_array;
360 for ( i = 0; i < fe_tetras; i++, fe_tetra++ ) {
361 for ( j = 0; j < 4; j++ ) {
362 nd = fe_tetra->
node [ j ]->
id;
363 node_num_elems [ nd - 1 ]++;
367 fe_hexa = fe_hexa_array;
368 for ( i = 0; i < fe_hexas; i++, fe_hexa++ ) {
369 for ( j = 0; j < 8; j++ ) {
370 nd = fe_hexa->
node [ j ]->
id;
371 node_num_elems [ nd - 1 ]++;
378 for ( i = 0; i < fe_nodes; i++ ) {
379 number = node_num_elems [ i ];
380 node_num_elems [ i ] = pos;
384 node_num_elems [ fe_nodes ] = size = pos;
385 if ( ( node_con_elems = (
long * ) calloc( size,
sizeof(
long ) ) ) == NULL ) {
391 fe_edge = fe_edge_array;
392 for ( i = 0; i < fe_edges; i++, fe_edge++ ) {
393 for ( j = 0; j < 2; j++ ) {
394 nd = fe_edge->
node [ j ]->
id;
395 node_con_elems [ node_num_elems [ nd - 1 ]++ ] = i + 1;
399 fe_face = fe_face_array;
400 for ( i = 0; i < fe_faces; i++, fe_face++ ) {
401 for ( j = 0; j < 3; j++ ) {
402 nd = fe_face->
node [ j ]->
id;
403 node_con_elems [ node_num_elems [ nd - 1 ]++ ] = i + 1 + fe_edges;
407 fe_quad = fe_quad_array;
408 for ( i = 0; i < fe_quads; i++, fe_quad++ ) {
409 for ( j = 0; j < 4; j++ ) {
410 nd = fe_quad->
node [ j ]->
id;
411 node_con_elems [ node_num_elems [ nd - 1 ]++ ] = i + 1 + fe_edges + fe_faces;
415 fe_tetra = fe_tetra_array;
416 for ( i = 0; i < fe_tetras; i++, fe_tetra++ ) {
417 for ( j = 0; j < 4; j++ ) {
418 nd = fe_tetra->
node [ j ]->
id;
419 node_con_elems [ node_num_elems [ nd - 1 ]++ ] = i + 1 + fe_edges + fe_faces + fe_quads;
423 fe_hexa = fe_hexa_array;
424 for ( i = 0; i < fe_hexas; i++, fe_hexa++ ) {
425 for ( j = 0; j < 8; j++ ) {
426 nd = fe_hexa->
node [ j ]->
id;
427 node_con_elems [ node_num_elems [ nd - 1 ]++ ] = i + 1 + fe_edges + fe_faces + fe_quads + fe_tetras;
434 for ( i = 0; i < fe_nodes; i++ ) {
435 number = node_num_elems [ i ] - pos;
436 node_num_elems [ i ] = pos;
441 for ( i = 0; i < fe_nodes; i++ ) {
442 OOFEM_LOG_DEBUG(
"node %ld: %ld:", i + 1, node_num_elems [ i + 1 ] - node_num_elems [ i ]);
443 for ( j = node_num_elems [ i ]; j < node_num_elems [ i + 1 ]; j++ ) {
444 switch (
elem_type(node_con_elems [ j ]) ) {
473 if ( ( node_num_nodes = (
long * ) calloc( fe_nodes + 1,
sizeof(
long ) ) ) == NULL ) {
477 fe_node = fe_node_array;
478 for ( i = 0; i < fe_nodes; i++, fe_node++ ) {
480 for ( j = node_num_elems [ i ]; j < node_num_elems [ node ]; j++ ) {
481 elem = node_con_elems [ j ];
486 fe_edge = & ( fe_edge_array [ elem - 1 ] );
487 for ( k = 0; k < 2; k++ ) {
488 nd = fe_edge->
node [ k ]->
id;
489 if ( nd != node && nd > 0 ) {
490 fe_edge->
node [ k ]->
id = -nd;
491 node_num_nodes [ i ]++;
498 fe_face = & ( fe_face_array [ elem - 1 ] );
499 for ( k = 0; k < 3; k++ ) {
500 nd = fe_face->
node [ k ]->
id;
501 if ( nd != node && nd > 0 ) {
502 fe_face->
node [ k ]->
id = -nd;
503 node_num_nodes [ i ]++;
510 fe_quad = & ( fe_quad_array [ elem - 1 ] );
511 for ( k = 0; k < 4; k++ ) {
512 if ( fe_node == fe_quad->
node [ k ] ) {
513 for ( m = 0; m < 2; m++ ) {
514 nd = fe_quad->
node [ quad_con_nd [ k ] [ m ] ]->
id;
516 fe_quad->
node [ quad_con_nd [ k ] [ m ] ]->
id = -nd;
517 node_num_nodes [ i ]++;
528 fe_tetra = & ( fe_tetra_array [ elem - 1 ] );
529 for ( k = 0; k < 4; k++ ) {
530 nd = fe_tetra->
node [ k ]->
id;
531 if ( nd != node && nd > 0 ) {
532 fe_tetra->
node [ k ]->
id = -nd;
533 node_num_nodes [ i ]++;
540 fe_hexa = & ( fe_hexa_array [ elem - 1 ] );
541 for ( k = 0; k < 8; k++ ) {
542 if ( fe_node == fe_hexa->
node [ k ] ) {
543 for ( m = 0; m < 3; m++ ) {
544 nd = fe_hexa->
node [ hexa_con_nd [ k ] [ m ] ]->
id;
546 fe_hexa->
node [ hexa_con_nd [ k ] [ m ] ]->
id = -nd;
547 node_num_nodes [ i ]++;
564 for ( j = node_num_elems [ i ]; j < node_num_elems [ node ]; j++ ) {
565 elem = node_con_elems [ j ];
570 fe_edge = & ( fe_edge_array [ elem - 1 ] );
571 for ( k = 0; k < 2; k++ ) {
578 fe_face = & ( fe_face_array [ elem - 1 ] );
579 for ( k = 0; k < 3; k++ ) {
586 fe_quad = & ( fe_quad_array [ elem - 1 ] );
587 for ( k = 0; k < 4; k++ ) {
594 fe_tetra = & ( fe_tetra_array [ elem - 1 ] );
595 for ( k = 0; k < 4; k++ ) {
596 fe_tetra->
node [ k ]->
id = abs(fe_tetra->
node [ k ]->
id);
602 fe_hexa = & ( fe_hexa_array [ elem - 1 ] );
603 for ( k = 0; k < 8; k++ ) {
618 for ( i = 0; i < fe_nodes; i++ ) {
619 number = node_num_nodes [ i ];
620 node_num_nodes [ i ] = pos;
624 node_num_nodes [ fe_nodes ] = size = pos;
625 if ( ( node_con_nodes = (
long * ) calloc( size,
sizeof(
long ) ) ) == NULL ) {
629 mesh_edges = size / 2;
633 fe_node = fe_node_array;
634 for ( i = 0; i < fe_nodes; i++, fe_node++ ) {
636 for ( j = node_num_elems [ i ]; j < node_num_elems [ node ]; j++ ) {
637 elem = node_con_elems [ j ];
642 fe_edge = & ( fe_edge_array [ elem - 1 ] );
643 for ( k = 0; k < 2; k++ ) {
644 nd = fe_edge->
node [ k ]->
id;
645 if ( nd != node && nd > 0 ) {
646 fe_edge->
node [ k ]->
id = -nd;
647 node_con_nodes [ node_num_nodes [ i ]++ ] = nd;
654 fe_face = & ( fe_face_array [ elem - 1 ] );
655 for ( k = 0; k < 3; k++ ) {
656 nd = fe_face->
node [ k ]->
id;
657 if ( nd != node && nd > 0 ) {
658 fe_face->
node [ k ]->
id = -nd;
659 node_con_nodes [ node_num_nodes [ i ]++ ] = nd;
666 fe_quad = & ( fe_quad_array [ elem - 1 ] );
667 for ( k = 0; k < 4; k++ ) {
668 if ( fe_node == fe_quad->
node [ k ] ) {
669 for ( m = 0; m < 2; m++ ) {
670 nd = fe_quad->
node [ quad_con_nd [ k ] [ m ] ]->
id;
672 fe_quad->
node [ quad_con_nd [ k ] [ m ] ]->
id = -nd;
673 node_con_nodes [ node_num_nodes [ i ]++ ] = nd;
684 fe_tetra = & ( fe_tetra_array [ elem - 1 ] );
685 for ( k = 0; k < 4; k++ ) {
686 nd = fe_tetra->
node [ k ]->
id;
687 if ( nd != node && nd > 0 ) {
688 fe_tetra->
node [ k ]->
id = -nd;
689 node_con_nodes [ node_num_nodes [ i ]++ ] = nd;
696 fe_hexa = & ( fe_hexa_array [ elem - 1 ] );
697 for ( k = 0; k < 8; k++ ) {
698 if ( fe_node == fe_hexa->
node [ k ] ) {
699 for ( m = 0; m < 3; m++ ) {
700 nd = fe_hexa->
node [ hexa_con_nd [ k ] [ m ] ]->
id;
702 fe_hexa->
node [ hexa_con_nd [ k ] [ m ] ]->
id = -nd;
703 node_con_nodes [ node_num_nodes [ i ]++ ] = nd;
720 for ( j = node_num_elems [ i ]; j < node_num_elems [ node ]; j++ ) {
721 elem = node_con_elems [ j ];
726 fe_edge = & ( fe_edge_array [ elem - 1 ] );
727 for ( k = 0; k < 2; k++ ) {
734 fe_face = & ( fe_face_array [ elem - 1 ] );
735 for ( k = 0; k < 3; k++ ) {
742 fe_quad = & ( fe_quad_array [ elem - 1 ] );
743 for ( k = 0; k < 4; k++ ) {
750 fe_tetra = & ( fe_tetra_array [ elem - 1 ] );
751 for ( k = 0; k < 4; k++ ) {
752 fe_tetra->
node [ k ]->
id = abs(fe_tetra->
node [ k ]->
id);
758 fe_hexa = & ( fe_hexa_array [ elem - 1 ] );
759 for ( k = 0; k < 8; k++ ) {
774 for ( i = 0; i < fe_nodes; i++ ) {
775 number = node_num_nodes [ i ] - pos;
776 node_num_nodes [ i ] = pos;
781 for ( i = 0; i < fe_nodes; i++ ) {
782 OOFEM_LOG_DEBUG(
"node %ld: %ld:", i + 1, node_num_nodes [ i + 1 ] - node_num_nodes [ i ]);
783 for ( j = node_num_nodes [ i ]; j < node_num_nodes [ i + 1 ]; j++ ) {
793 #ifdef COMPLETE_DATA_STRUCTURE 794 if ( fe_faces != 0 ) {
795 if ( ( tmp_face_array = ( tmp_face_rec * ) calloc( fe_faces,
sizeof( tmp_face_rec ) ) ) == NULL ) {
800 if ( fe_quads != 0 ) {
801 if ( ( tmp_quad_array = ( tmp_quad_rec * ) calloc( fe_quads,
sizeof( tmp_quad_rec ) ) ) == NULL ) {
808 if ( fe_tetras != 0 ) {
814 if ( fe_hexas != 0 ) {
820 #ifdef COMPLETE_DATA_STRUCTURE 824 fe_face = fe_face_array;
825 for ( i = 0; i < fe_faces; i++, fe_face++ ) {
827 for ( j = 0; j < 3; j++ ) {
828 j1 = face_ed_nd [ j ] [ 0 ];
829 j2 = face_ed_nd [ j ] [ 1 ];
830 node1 = fe_face->
node [ j1 ]->
id;
831 node2 = fe_face->
node [ j2 ]->
id;
832 for ( k = node_num_elems [ node1 - 1 ]; k < node_num_elems [ node1 ]; k++ ) {
833 elem2 = node_con_elems [ k ];
834 if ( elem2 == elem1 ) {
839 for ( m = node_num_elems [ node2 - 1 ]; m < node_num_elems [ node2 ]; m++ ) {
840 if ( elem2 == node_con_elems [ m ] ) {
844 if ( ( & ( tmp_face_array [ i ] ) )->ngb_elem_id [ j ] != 0 ) {
848 ( & ( tmp_face_array [ i ] ) )->ngb_elem_id [ j ] = elem2;
857 fe_quad = fe_quad_array;
858 for ( i = 0; i < fe_quads; i++, fe_quad++ ) {
860 for ( j = 0; j < 4; j++ ) {
861 j1 = quad_ed_nd [ j ] [ 0 ];
862 j2 = quad_ed_nd [ j ] [ 1 ];
863 node1 = fe_quad->
node [ j1 ]->
id;
864 node2 = fe_quad->
node [ j2 ]->
id;
865 for ( k = node_num_elems [ node1 - 1 ]; k < node_num_elems [ node1 ]; k++ ) {
866 elem2 = node_con_elems [ k ];
867 if ( elem2 == elem1 ) {
872 for ( m = node_num_elems [ node2 - 1 ]; m < node_num_elems [ node2 ]; m++ ) {
873 if ( elem2 == node_con_elems [ m ] ) {
877 if ( ( & ( tmp_quad_array [ i ] ) )->ngb_elem_id [ j ] != 0 ) {
881 ( & ( tmp_quad_array [ i ] ) )->ngb_elem_id [ j ] = elem2;
891 tmp_face = tmp_face_array;
892 for ( i = 0; i < fe_faces; i++, tmp_face++ ) {
894 for ( j = 0; j < 3; j++ ) {
895 switch (
elem_type(tmp_face->ngb_elem_id [ j ]) ) {
908 tmp_quad = tmp_quad_array;
909 for ( i = 0; i < fe_quads; i++, tmp_quad++ ) {
911 for ( j = 0; j < 4; j++ ) {
912 switch (
elem_type(tmp_quad->ngb_elem_id [ j ]) ) {
932 fe_tetra = fe_tetra_array;
933 for ( i = 0; i < fe_tetras; i++, fe_tetra++ ) {
936 for ( j = 0; j < 4; j++ ) {
937 j1 = tetra_fc_nd [ j ] [ 0 ];
938 j2 = tetra_fc_nd [ j ] [ 1 ];
939 j3 = tetra_fc_nd [ j ] [ 2 ];
940 node1 = fe_tetra->
node [ j1 ]->
id;
941 node2 = fe_tetra->
node [ j2 ]->
id;
942 node3 = fe_tetra->
node [ j3 ]->
id;
943 for ( k = node_num_elems [ node1 - 1 ]; k < node_num_elems [ node1 ]; k++ ) {
944 elem2 = node_con_elems [ k ];
945 if ( elem2 == elem1 ) {
953 for ( m = node_num_elems [ node2 - 1 ]; m < node_num_elems [ node2 ]; m++ ) {
954 if ( elem2 != node_con_elems [ m ] ) {
958 for ( n = node_num_elems [ node3 - 1 ]; n < node_num_elems [ node3 ]; n++ ) {
959 if ( elem2 == node_con_elems [ n ] ) {
960 ( & ( tmp_tetra_array [ i ] ) )->ngb_elem_id [ j ] = elem2;
961 if ( elem1 > elem2 ) {
965 k = node_num_elems [ node1 ];
966 m = node_num_elems [ node2 ];
975 fe_hexa = fe_hexa_array;
976 for ( i = 0; i < fe_hexas; i++, fe_hexa++ ) {
979 for ( j = 0; j < 6; j++ ) {
980 j1 = hexa_fc_nd [ j ] [ 0 ];
981 j2 = hexa_fc_nd [ j ] [ 1 ];
982 j3 = hexa_fc_nd [ j ] [ 2 ];
983 j4 = hexa_fc_nd [ j ] [ 3 ];
984 node1 = fe_hexa->
node [ j1 ]->
id;
985 node2 = fe_hexa->
node [ j2 ]->
id;
986 node3 = fe_hexa->
node [ j3 ]->
id;
987 node4 = fe_hexa->
node [ j4 ]->
id;
988 for ( k = node_num_elems [ node1 - 1 ]; k < node_num_elems [ node1 ]; k++ ) {
989 elem2 = node_con_elems [ k ];
990 if ( elem2 == elem1 ) {
998 for ( m = node_num_elems [ node2 - 1 ]; m < node_num_elems [ node2 ]; m++ ) {
999 if ( elem2 != node_con_elems [ m ] ) {
1003 for ( n = node_num_elems [ node3 - 1 ]; n < node_num_elems [ node3 ]; n++ ) {
1004 if ( elem2 != node_con_elems [ n ] ) {
1008 for ( p = node_num_elems [ node4 - 1 ]; p < node_num_elems [ node4 ]; p++ ) {
1009 if ( elem2 == node_con_elems [ p ] ) {
1010 ( & ( tmp_hexa_array [ i ] ) )->ngb_elem_id [ j ] = elem2;
1011 if ( elem1 > elem2 ) {
1015 k = node_num_elems [ node1 ];
1016 m = node_num_elems [ node2 ];
1017 n = node_num_elems [ node3 ];
1028 tmp_tetra = tmp_tetra_array;
1029 for ( i = 0; i < fe_tetras; i++, tmp_tetra++ ) {
1031 for ( j = 0; j < 4; j++ ) {
1042 tmp_hexa = tmp_hexa_array;
1043 for ( i = 0; i < fe_hexas; i++, tmp_hexa++ ) {
1045 for ( j = 0; j < 6; j++ ) {
1059 if ( mesh_edges != 0 ) {
1065 if ( mesh_faces != 0 ) {
1071 if ( mesh_quads != 0 ) {
1077 fine_nodes = mesh_edges + mesh_faces + mesh_quads + fe_faces + fe_quads + fe_tetras + fe_pyrams + fe_wedges + fe_hexas;
1079 fine_edges = fe_edges * 2;
1080 fine_quads = fe_faces * 3 + fe_quads * 4;
1081 fine_hexas = fe_tetras * 4 + fe_pyrams * 8 + fe_wedges * 8 + fe_hexas * 8;
1083 if ( fine_nodes != 0 ) {
1089 if ( fine_edges != 0 ) {
1095 if ( fine_quads != 0 ) {
1101 if ( fine_hexas != 0 ) {
1107 fine_node_id = fe_nodes;
1108 fine_node = fine_node_array;
1111 mesh_edge = mesh_edge_array;
1113 if ( fe_edges != 0 ) {
1116 fe_edge = fe_edge_array;
1117 for ( i = 0; i < fe_edges; i++, fe_edge++ ) {
1118 node1 = ( nd1 = fe_edge->
node [ 0 ] )->
id;
1119 node2 = ( nd2 = fe_edge->
node [ 1 ] )->
id;
1121 fine_node->
id = ++fine_node_id;
1125 mesh_edge->
node [ 0 ] = nd1;
1126 mesh_edge->
node [ 1 ] = nd2;
1131 for ( k = node_num_nodes [ node1 - 1 ]; k < node_num_nodes [ node1 ]; k++ ) {
1132 if ( node_con_nodes [ k ] == node2 ) {
1133 node_con_nodes [ k ] = -mesh_edge_id;
1138 for ( k = node_num_nodes [ node2 - 1 ]; k < node_num_nodes [ node2 ]; k++ ) {
1139 if ( node_con_nodes [ k ] == node1 ) {
1140 node_con_nodes [ k ] = -mesh_edge_id;
1149 #ifdef COMPLETE_DATA_STRUCTURE 1153 fe_face = fe_face_array;
1154 tmp_face = tmp_face_array;
1155 for ( i = 0; i < fe_faces; i++, fe_face++, tmp_face++ ) {
1157 for ( j = 0; j < 3; j++ ) {
1158 elem2 = tmp_face->ngb_elem_id [ j ];
1160 if ( elem2 == 0 || elem1 < elem2 ) {
1161 j1 = face_ed_nd [ j ] [ 0 ];
1162 j2 = face_ed_nd [ j ] [ 1 ];
1163 node1 = ( nd1 = fe_face->node [ j1 ] )->
id;
1164 node2 = ( nd2 = fe_face->node [ j2 ] )->
id;
1166 fine_node->
id = ++fine_node_id;
1170 if ( node1 < node2 ) {
1171 mesh_edge->
node [ 0 ] = nd1;
1172 mesh_edge->
node [ 1 ] = nd2;
1174 mesh_edge->
node [ 0 ] = nd2;
1175 mesh_edge->
node [ 1 ] = nd1;
1181 for ( k = node_num_nodes [ node1 - 1 ]; k < node_num_nodes [ node1 ]; k++ ) {
1182 node = node_con_nodes [ k ];
1183 if ( node == node2 ) {
1184 node_con_nodes [ k ] = -mesh_edge_id;
1189 for ( k = node_num_nodes [ node2 - 1 ]; k < node_num_nodes [ node2 ]; k++ ) {
1190 node = node_con_nodes [ k ];
1191 if ( node == node1 ) {
1192 node_con_nodes [ k ] = -mesh_edge_id;
1197 tmp_face->edge [ j ] = mesh_edge;
1202 tmp_fc = & ( tmp_face_array [ elem - 1 ] );
1203 for ( k = 0; k < 3; k++ ) {
1204 if ( tmp_fc->ngb_elem_id [ k ] == elem1 ) {
1205 tmp_fc->edge [ k ] = mesh_edge;
1213 tmp_qd = & ( tmp_quad_array [ elem - 1 ] );
1214 for ( k = 0; k < 4; k++ ) {
1215 if ( tmp_qd->ngb_elem_id [ k ] == elem1 ) {
1216 tmp_qd->edge [ k ] = mesh_edge;
1228 fe_quad = fe_quad_array;
1229 tmp_quad = tmp_quad_array;
1230 for ( i = 0; i < fe_quads; i++, fe_quad++, tmp_quad++ ) {
1232 for ( j = 0; j < 4; j++ ) {
1233 elem2 = tmp_quad->ngb_elem_id [ j ];
1235 if ( elem2 == 0 || elem1 < elem2 ) {
1236 j1 = quad_ed_nd [ j ] [ 0 ];
1237 j2 = quad_ed_nd [ j ] [ 1 ];
1238 node1 = ( nd1 = fe_quad->node [ j1 ] )->
id;
1239 node2 = ( nd2 = fe_quad->node [ j2 ] )->
id;
1241 fine_node->
id = ++fine_node_id;
1245 if ( node1 < node2 ) {
1246 mesh_edge->
node [ 0 ] = nd1;
1247 mesh_edge->
node [ 1 ] = nd2;
1249 mesh_edge->
node [ 0 ] = nd2;
1250 mesh_edge->
node [ 1 ] = nd1;
1256 for ( k = node_num_nodes [ node1 - 1 ]; k < node_num_nodes [ node1 ]; k++ ) {
1257 node = node_con_nodes [ k ];
1258 if ( node == node2 ) {
1259 node_con_nodes [ k ] = -mesh_edge_id;
1264 for ( k = node_num_nodes [ node2 - 1 ]; k < node_num_nodes [ node2 ]; k++ ) {
1265 node = node_con_nodes [ k ];
1266 if ( node == node1 ) {
1267 node_con_nodes [ k ] = -mesh_edge_id;
1272 tmp_quad->edge [ j ] = mesh_edge;
1277 tmp_fc = & ( tmp_face_array [ elem - 1 ] );
1278 for ( k = 0; k < 3; k++ ) {
1279 if ( tmp_fc->ngb_elem_id [ k ] == elem1 ) {
1280 tmp_fc->edge [ k ] = mesh_edge;
1288 tmp_qd = & ( tmp_quad_array [ elem - 1 ] );
1289 for ( k = 0; k < 4; k++ ) {
1290 if ( tmp_qd->ngb_elem_id [ k ] == elem1 ) {
1291 tmp_qd->edge [ k ] = mesh_edge;
1307 for ( i = 0; i < fe_nodes; i++ ) {
1309 for ( j = node_num_nodes [ i ]; j < node_num_nodes [ node ]; j++ ) {
1312 nd = node_con_nodes [ j ];
1314 node_con_nodes [ j ] = -nd;
1325 nd1 = & ( fe_node_array [ node - 1 ] );
1326 nd2 = & ( fe_node_array [ nd - 1 ] );
1328 fine_node->
id = ++fine_node_id;
1332 mesh_edge->
node [ 0 ] = nd1;
1333 mesh_edge->
node [ 1 ] = nd2;
1337 node_con_nodes [ j ] = ++mesh_edge_id;
1339 for ( k = node_num_nodes [ nd - 1 ]; k < node_num_nodes [ nd ]; k++ ) {
1340 if ( node_con_nodes [ k ] == node ) {
1341 node_con_nodes [ k ] = -mesh_edge_id;
1350 mesh_face = mesh_face_array;
1352 fe_tetra = fe_tetra_array;
1353 tmp_tetra = tmp_tetra_array;
1354 for ( i = 0; i < fe_tetras; i++, fe_tetra++, tmp_tetra++ ) {
1356 for ( j = 0; j < 4; j++ ) {
1359 if ( elem2 == 0 || elem1 < elem2 ) {
1360 j1 = tetra_fc_nd [ j ] [ 0 ];
1361 j2 = tetra_fc_nd [ j ] [ 1 ];
1362 j3 = tetra_fc_nd [ j ] [ 2 ];
1363 nd1 = fe_tetra->node [ j1 ];
1364 nd2 = fe_tetra->node [ j2 ];
1365 nd3 = fe_tetra->node [ j3 ];
1367 fine_node->
id = ++fine_node_id;
1369 mesh_face->
node [ 0 ] = nd1;
1370 mesh_face->
node [ 1 ] = nd2;
1371 mesh_face->
node [ 2 ] = nd3;
1374 tmp_tetra->
face [ j ] = mesh_face;
1378 tmp_tet = & ( tmp_tetra_array [ elem - 1 ] );
1379 for ( k = 0; k < 4; k++ ) {
1380 if ( tmp_tet->ngb_elem_id [ k ] == elem1 ) {
1381 tmp_tet->face [ k ] = mesh_face;
1394 mesh_quad = mesh_quad_array;
1396 fe_hexa = fe_hexa_array;
1397 tmp_hexa = tmp_hexa_array;
1398 for ( i = 0; i < fe_hexas; i++, fe_hexa++, tmp_hexa++ ) {
1400 for ( j = 0; j < 6; j++ ) {
1403 if ( elem2 == 0 || elem1 < elem2 ) {
1404 j1 = hexa_fc_nd [ j ] [ 0 ];
1405 j2 = hexa_fc_nd [ j ] [ 1 ];
1406 j3 = hexa_fc_nd [ j ] [ 2 ];
1407 j4 = hexa_fc_nd [ j ] [ 3 ];
1408 nd1 = fe_hexa->node [ j1 ];
1409 nd2 = fe_hexa->node [ j2 ];
1410 nd3 = fe_hexa->node [ j3 ];
1411 nd4 = fe_hexa->node [ j4 ];
1413 fine_node->
id = ++fine_node_id;
1415 mesh_quad->
node [ 0 ] = nd1;
1416 mesh_quad->
node [ 1 ] = nd2;
1417 mesh_quad->
node [ 2 ] = nd3;
1418 mesh_quad->
node [ 3 ] = nd4;
1421 tmp_hexa->
quad [ j ] = mesh_quad;
1425 tmp_hx = & ( tmp_hexa_array [ elem - 1 ] );
1426 for ( k = 0; k < 6; k++ ) {
1427 if ( tmp_hx->ngb_elem_id [ k ] == elem1 ) {
1428 tmp_hx->quad [ k ] = mesh_quad;
1440 refine_nodes += mesh_edges * level * 2;
1441 refine_nodes += mesh_faces * ( level * 3 + level * level * 3 );
1442 refine_nodes += mesh_quads * ( level * 4 + level * level * 4 );
1443 refine_nodes += fe_faces * ( level * 3 + level * level * 3 );
1444 refine_nodes += fe_quads * ( level * 4 + level * level * 4 );
1445 refine_nodes += fe_tetras * ( level * 4 + level * level * 6 + level * level * level * 4 );
1446 refine_nodes += fe_hexas * ( level * 6 + level * level * 12 + level * level * level * 8 );
1448 refine_node_id = fe_nodes + fine_nodes;
1452 mesh_edge = mesh_edge_array;
1453 for ( i = 0; i < mesh_edges; i++, mesh_edge++ ) {
1454 for ( j = 0; j < 2; j++ ) {
1455 if ( ( mesh_edge->
fine_id [ j ] = (
int * ) calloc( level + 2,
sizeof(
int ) ) ) == NULL ) {
1460 for ( k = 1; k < level + 1; k++ ) {
1461 mesh_edge->
fine_id [ j ] [ k ] = ++refine_node_id;
1480 for ( j = 0; j < 4; j++ ) {
1481 if ( ( tmp_array_start [ j ] = (
long * ) calloc( level + 2,
sizeof(
long ) ) ) == NULL ) {
1485 if ( ( tmp_array_end [ j ] = (
long * ) calloc( level + 2,
sizeof(
long ) ) ) == NULL ) {
1489 if ( ( tmp_array_cen [ j ] = (
long * ) calloc( level + 2,
sizeof(
long ) ) ) == NULL ) {
1496 mesh_face = mesh_face_array;
1497 for ( i = 0; i < mesh_faces; i++, mesh_face++ ) {
1498 for ( j = 0; j < 3; j++ ) {
1499 j1 = face_ed_nd [ j ] [ 0 ];
1500 j2 = face_ed_nd [ j ] [ 1 ];
1502 node1 = mesh_face->
node [ j1 ]->
id;
1503 node2 = mesh_face->
node [ j2 ]->
id;
1507 if ( node1 < node2 ) {
1508 for ( k = node_num_nodes [ node1 - 1 ]; k < node_num_nodes [ node1 ]; k++ ) {
1509 mesh_edge = & ( mesh_edge_array [ node_con_nodes [ k ] - 1 ] );
1510 if ( mesh_edge->
node [ 1 ]->
id == node2 ) {
1511 for ( m = 0; m < level + 2; m++ ) {
1512 tmp_array_start [ j ] [ m ] = mesh_edge->
fine_id [ 0 ] [ m ];
1513 tmp_array_end [ j ] [ m ] = mesh_edge->
fine_id [ 1 ] [ m ];
1520 for ( k = node_num_nodes [ node2 - 1 ]; k < node_num_nodes [ node2 ]; k++ ) {
1521 mesh_edge = & ( mesh_edge_array [ node_con_nodes [ k ] - 1 ] );
1522 if ( mesh_edge->
node [ 1 ]->
id == node1 ) {
1523 for ( m = 0; m < level + 2; m++ ) {
1524 tmp_array_start [ j ] [ m ] = mesh_edge->
fine_id [ 1 ] [ m ];
1525 tmp_array_end [ j ] [ m ] = mesh_edge->
fine_id [ 0 ] [ m ];
1533 tmp_array_cen [ j ] [ 0 ] = mesh_edge->
mid_node->
id;
1534 for ( m = 1; m < level + 1; m++ ) {
1535 tmp_array_cen [ j ] [ m ] = ++refine_node_id;
1538 tmp_array_cen [ j ] [ level + 1 ] = mesh_face->
mid_node->
id;
1541 for ( j = 0; j < 3; j++ ) {
1542 if ( ( mesh_face->
fine_id [ j ] = (
int * ) calloc( ( level + 2 ) * ( level + 2 ),
sizeof(
int ) ) ) == NULL ) {
1546 if ( ( jj = j - 1 ) < 0 ) {
1550 j1 = face_ed_nd [ jj ] [ 0 ];
1551 j2 = face_ed_nd [ jj ] [ 1 ];
1554 for ( k = 0; k < level + 2; k++ ) {
1555 mesh_face->
fine_id [ j ] [ pos++ ] = tmp_array_start [ j2 ] [ k ];
1558 for ( k = 1; k < level + 1; k++ ) {
1559 mesh_face->
fine_id [ j ] [ pos++ ] = tmp_array_end [ j1 ] [ k ];
1560 for ( m = 1; m < level + 1; m++ ) {
1561 mesh_face->
fine_id [ j ] [ pos++ ] = ++refine_node_id;
1564 mesh_face->
fine_id [ j ] [ pos++ ] = tmp_array_cen [ j2 ] [ k ];
1567 for ( k = 0; k < level + 2; k++ ) {
1568 mesh_face->
fine_id [ j ] [ pos++ ] = tmp_array_cen [ j1 ] [ k ];
1575 mesh_quad = mesh_quad_array;
1576 for ( i = 0; i < mesh_quads; i++, mesh_quad++ ) {
1577 for ( j = 0; j < 4; j++ ) {
1578 j1 = quad_ed_nd [ j ] [ 0 ];
1579 j2 = quad_ed_nd [ j ] [ 1 ];
1581 node1 = mesh_quad->
node [ j1 ]->
id;
1582 node2 = mesh_quad->
node [ j2 ]->
id;
1586 if ( node1 < node2 ) {
1587 for ( k = node_num_nodes [ node1 - 1 ]; k < node_num_nodes [ node1 ]; k++ ) {
1588 mesh_edge = & ( mesh_edge_array [ node_con_nodes [ k ] - 1 ] );
1589 if ( mesh_edge->
node [ 1 ]->
id == node2 ) {
1590 for ( m = 0; m < level + 2; m++ ) {
1591 tmp_array_start [ j ] [ m ] = mesh_edge->
fine_id [ 0 ] [ m ];
1592 tmp_array_end [ j ] [ m ] = mesh_edge->
fine_id [ 1 ] [ m ];
1599 for ( k = node_num_nodes [ node2 - 1 ]; k < node_num_nodes [ node2 ]; k++ ) {
1600 mesh_edge = & ( mesh_edge_array [ node_con_nodes [ k ] - 1 ] );
1601 if ( mesh_edge->
node [ 1 ]->
id == node1 ) {
1602 for ( m = 0; m < level + 2; m++ ) {
1603 tmp_array_start [ j ] [ m ] = mesh_edge->
fine_id [ 1 ] [ m ];
1604 tmp_array_end [ j ] [ m ] = mesh_edge->
fine_id [ 0 ] [ m ];
1612 tmp_array_cen [ j ] [ 0 ] = mesh_edge->
mid_node->
id;
1613 for ( m = 1; m < level + 1; m++ ) {
1614 tmp_array_cen [ j ] [ m ] = ++refine_node_id;
1617 tmp_array_cen [ j ] [ level + 1 ] = mesh_quad->
mid_node->
id;
1620 for ( j = 0; j < 4; j++ ) {
1621 if ( ( mesh_quad->
fine_id [ j ] = (
int * ) calloc( ( level + 2 ) * ( level + 2 ),
sizeof(
int ) ) ) == NULL ) {
1625 if ( ( jj = j - 1 ) < 0 ) {
1629 j1 = quad_ed_nd [ jj ] [ 0 ];
1630 j2 = quad_ed_nd [ jj ] [ 1 ];
1633 for ( k = 0; k < level + 2; k++ ) {
1634 mesh_quad->
fine_id [ j ] [ pos++ ] = tmp_array_start [ j2 ] [ k ];
1637 for ( k = 1; k < level + 1; k++ ) {
1638 mesh_quad->
fine_id [ j ] [ pos++ ] = tmp_array_end [ j1 ] [ k ];
1639 for ( m = 1; m < level + 1; m++ ) {
1640 mesh_quad->
fine_id [ j ] [ pos++ ] = ++refine_node_id;
1643 mesh_quad->
fine_id [ j ] [ pos++ ] = tmp_array_cen [ j2 ] [ k ];
1646 for ( k = 0; k < level + 2; k++ ) {
1647 mesh_quad->
fine_id [ j ] [ pos++ ] = tmp_array_cen [ j1 ] [ k ];
1652 #ifdef COMPLETE_DATA_STRUCTURE 1653 if ( node_num_nodes != NULL ) {
1654 free(node_num_nodes);
1657 if ( node_con_nodes != NULL ) {
1658 free(node_con_nodes);
1670 mesh_edge = mesh_edge_array;
1671 for ( i = 0; i < fe_edges; i++, mesh_edge++ ) {
1672 for ( j = 0; j < 2; j++ ) {
1673 fine_edge = & ( fine_edge_array [ fine_edge_id++ ] );
1674 if ( ( fine_edge->
fine_id = (
int * ) calloc( ( level + 2 ),
sizeof(
int ) ) ) == NULL ) {
1678 for ( k = 0; k < level + 2; k++ ) {
1688 fe_face = fe_face_array;
1689 for ( i = 0; i < fe_faces; i++, fe_face++, fine_node++ ) {
1690 fine_node->
id = ++fine_node_id;
1692 #ifdef COMPLETE_DATA_STRUCTURE 1693 tmp_face = & tmp_face_array [ i ];
1696 for ( j = 0; j < 3; j++ ) {
1697 j1 = face_ed_nd [ j ] [ 0 ];
1698 j2 = face_ed_nd [ j ] [ 1 ];
1700 node1 = fe_face->node [ j1 ]->id;
1701 node2 = fe_face->node [ j2 ]->id;
1703 #ifdef COMPLETE_DATA_STRUCTURE 1704 mesh_edge = tmp_face->edge [ j ];
1709 if ( node1 < node2 ) {
1710 #ifndef COMPLETE_DATA_STRUCTURE 1711 for ( k = node_num_nodes [ node1 - 1 ]; k < node_num_nodes [ node1 ]; k++ ) {
1712 mesh_edge = & ( mesh_edge_array [ node_con_nodes [ k ] - 1 ] );
1713 if ( mesh_edge->
node [ 1 ]->
id == node2 ) {
1720 for ( k = 0; k < level + 2; k++ ) {
1721 tmp_array_start [ j ] [ k ] = mesh_edge->
fine_id [ 0 ] [ k ];
1722 tmp_array_end [ j ] [ k ] = mesh_edge->
fine_id [ 1 ] [ k ];
1725 #ifndef COMPLETE_DATA_STRUCTURE 1726 for ( k = node_num_nodes [ node2 - 1 ]; k < node_num_nodes [ node2 ]; k++ ) {
1727 mesh_edge = & ( mesh_edge_array [ node_con_nodes [ k ] - 1 ] );
1728 if ( mesh_edge->
node [ 1 ]->
id == node1 ) {
1735 for ( k = 0; k < level + 2; k++ ) {
1736 tmp_array_start [ j ] [ k ] = mesh_edge->
fine_id [ 1 ] [ k ];
1737 tmp_array_end [ j ] [ k ] = mesh_edge->
fine_id [ 0 ] [ k ];
1741 tmp_array_cen [ j ] [ 0 ] = mesh_edge->
mid_node->
id;
1742 for ( k = 1; k < level + 1; k++ ) {
1743 tmp_array_cen [ j ] [ k ] = ++refine_node_id;
1746 tmp_array_cen [ j ] [ level + 1 ] = fine_node->
id;
1749 for ( j = 0; j < 3; j++ ) {
1750 fine_quad = & ( fine_quad_array [ fine_quad_id++ ] );
1751 if ( ( fine_quad->
fine_id = (
int * ) calloc( ( level + 2 ) * ( level + 2 ),
sizeof(
int ) ) ) == NULL ) {
1755 if ( ( jj = j - 1 ) < 0 ) {
1759 j1 = face_ed_nd [ jj ] [ 0 ];
1760 j2 = face_ed_nd [ jj ] [ 1 ];
1763 for ( k = 0; k < level + 2; k++ ) {
1764 fine_quad->
fine_id [ pos++ ] = tmp_array_start [ j2 ] [ k ];
1767 for ( k = 1; k < level + 1; k++ ) {
1768 fine_quad->
fine_id [ pos++ ] = tmp_array_end [ j1 ] [ k ];
1769 for ( m = 1; m < level + 1; m++ ) {
1770 fine_quad->
fine_id [ pos++ ] = ++refine_node_id;
1773 fine_quad->
fine_id [ pos++ ] = tmp_array_cen [ j2 ] [ k ];
1776 for ( k = 0; k < level + 2; k++ ) {
1777 fine_quad->
fine_id [ pos++ ] = tmp_array_cen [ j1 ] [ k ];
1782 fe_quad = fe_quad_array;
1783 for ( i = 0; i < fe_quads; i++, fe_quad++, fine_node++ ) {
1784 fine_node->
id = ++fine_node_id;
1786 #ifdef COMPLETE_DATA_STRUCTURE 1787 tmp_quad = & ( tmp_quad_array [ i ] );
1790 for ( j = 0; j < 4; j++ ) {
1791 j1 = quad_ed_nd [ j ] [ 0 ];
1792 j2 = quad_ed_nd [ j ] [ 1 ];
1794 node1 = fe_quad->node [ j1 ]->id;
1795 node2 = fe_quad->node [ j2 ]->id;
1797 #ifdef COMPLETE_DATA_STRUCTURE 1798 mesh_edge = tmp_quad->edge [ j ];
1803 if ( node1 < node2 ) {
1804 #ifndef COMPLETE_DATA_STRUCTURE 1805 for ( k = node_num_nodes [ node1 - 1 ]; k < node_num_nodes [ node1 ]; k++ ) {
1806 mesh_edge = & ( mesh_edge_array [ node_con_nodes [ k ] - 1 ] );
1807 if ( mesh_edge->
node [ 1 ]->
id == node2 ) {
1814 for ( k = 0; k < level + 2; k++ ) {
1815 tmp_array_start [ j ] [ k ] = mesh_edge->
fine_id [ 0 ] [ k ];
1816 tmp_array_end [ j ] [ k ] = mesh_edge->
fine_id [ 1 ] [ k ];
1819 #ifndef COMPLETE_DATA_STRUCTURE 1820 for ( k = node_num_nodes [ node2 - 1 ]; k < node_num_nodes [ node2 ]; k++ ) {
1821 mesh_edge = & ( mesh_edge_array [ node_con_nodes [ k ] - 1 ] );
1822 if ( mesh_edge->
node [ 1 ]->
id == node1 ) {
1829 for ( k = 0; k < level + 2; k++ ) {
1830 tmp_array_start [ j ] [ k ] = mesh_edge->
fine_id [ 1 ] [ k ];
1831 tmp_array_end [ j ] [ k ] = mesh_edge->
fine_id [ 0 ] [ k ];
1835 tmp_array_cen [ j ] [ 0 ] = mesh_edge->
mid_node->
id;
1836 for ( k = 1; k < level + 1; k++ ) {
1837 tmp_array_cen [ j ] [ k ] = ++refine_node_id;
1840 tmp_array_cen [ j ] [ level + 1 ] = fine_node->
id;
1843 for ( j = 0; j < 4; j++ ) {
1844 fine_quad = & ( fine_quad_array [ fine_quad_id++ ] );
1845 if ( ( fine_quad->
fine_id = (
int * ) calloc( ( level + 2 ) * ( level + 2 ),
sizeof(
int ) ) ) == NULL ) {
1849 if ( ( jj = j - 1 ) < 0 ) {
1853 j1 = quad_ed_nd [ jj ] [ 0 ];
1854 j2 = quad_ed_nd [ jj ] [ 1 ];
1857 for ( k = 0; k < level + 2; k++ ) {
1858 fine_quad->
fine_id [ pos++ ] = tmp_array_start [ j2 ] [ k ];
1861 for ( k = 1; k < level + 1; k++ ) {
1862 fine_quad->
fine_id [ pos++ ] = tmp_array_end [ j1 ] [ k ];
1863 for ( m = 1; m < level + 1; m++ ) {
1864 fine_quad->
fine_id [ pos++ ] = ++refine_node_id;
1867 fine_quad->
fine_id [ pos++ ] = tmp_array_cen [ j2 ] [ k ];
1870 for ( k = 0; k < level + 2; k++ ) {
1871 fine_quad->
fine_id [ pos++ ] = tmp_array_cen [ j1 ] [ k ];
1876 for ( j = 0; j < 4; j++ ) {
1877 free(tmp_array_start [ j ]);
1878 free(tmp_array_end [ j ]);
1879 free(tmp_array_cen [ j ]);
1882 #ifdef COMPLETE_DATA_STRUCTURE 1883 if ( tmp_face_array != NULL ) {
1884 free(tmp_face_array);
1887 if ( tmp_quad_array != NULL ) {
1888 free(tmp_quad_array);
1892 if ( node_num_nodes != NULL ) {
1893 free(node_num_nodes);
1896 if ( node_con_nodes != NULL ) {
1897 free(node_con_nodes);
1902 mesh_edge = mesh_edge_array;
1903 for ( i = 0; i < mesh_edges; i++, mesh_edge++ ) {
1904 for ( j = 0; j < 2; j++ ) {
1905 if ( mesh_edge->
fine_id [ j ] != NULL ) {
1906 free(mesh_edge->
fine_id [ j ]);
1911 if ( mesh_edge_array != NULL ) {
1912 free(mesh_edge_array);
1917 for ( j = 0; j < 6; j++ ) {
1918 if ( ( tmp_array_cen [ j ] = (
long * ) calloc( level + 2,
sizeof(
long ) ) ) == NULL ) {
1923 for ( j = 0; j < 12; j++ ) {
1924 if ( ( tmp_array [ j ] = (
long * ) calloc( ( level + 2 ) * ( level + 2 ),
sizeof(
long ) ) ) == NULL ) {
1931 fe_tetra = fe_tetra_array;
1932 tmp_tetra = tmp_tetra_array;
1933 for ( i = 0; i < fe_tetras; i++, fe_tetra++, tmp_tetra++, fine_node++ ) {
1934 fine_node->
id = ++fine_node_id;
1936 for ( j = 0; j < 4; j++ ) {
1937 tmp_array_cen [ j ] [ 0 ] = tmp_tetra->face [ j ]->mid_node->id;
1938 for ( k = 1; k < level + 1; k++ ) {
1939 tmp_array_cen [ j ] [ k ] = ++refine_node_id;
1942 tmp_array_cen [ j ] [ level + 1 ] = fine_node->
id;
1949 for ( j = 0; j < 4; j++ ) {
1950 mesh_face = mesh_fc [ j ] = tmp_tetra->face [ j ];
1951 for ( k = 0; k < 3; k++ ) {
1952 if ( mesh_face->
node [ k ] == fe_tetra->node [ tetra_fc_nd [ j ] [ 0 ] ] ) {
1953 if ( ( kk = k + 1 ) == 3 ) {
1957 if ( mesh_face->
node [ kk ] == fe_tetra->node [ tetra_fc_nd [ j ] [ 1 ] ] ) {
1972 for ( j = 0; j < 3; j++ ) {
1975 p = ( level + 2 ) * ( level + 1 );
1976 mesh_face = mesh_fc [ 0 ];
1977 for ( k = 0; k < 3; k++ ) {
1978 if ( mesh_face->
node [ k ] == fe_tetra->node [ j ] ) {
1979 if ( swap [ 0 ] == 1 ) {
1982 if ( ( kk = k + 1 ) == 3 ) {
1991 for ( m = 0; m < level + 2; m++ ) {
1992 tmp_array [ j ] [ pos++ ] = mesh_face->
fine_id [ kk ] [ p++ ];
1996 p = ( level + 2 ) * ( level + 1 );
1997 mesh_face = mesh_fc [ j + 1 ];
1998 for ( k = 0; k < 3; k++ ) {
1999 if ( mesh_face->
node [ k ] == fe_tetra->node [ j ] ) {
2000 if ( swap [ j + 1 ] == 1 ) {
2003 if ( ( kk = k + 1 ) == 3 ) {
2012 for ( n = 1; n < level + 1; n++ ) {
2013 tmp_array [ j ] [ pos++ ] = mesh_face->
fine_id [ kk ] [ ++p ];
2014 for ( m = 0; m < level; m++ ) {
2015 tmp_array [ j ] [ pos++ ] = ++refine_node_id;
2018 tmp_array [ j ] [ pos++ ] = tmp_array_cen [ 0 ] [ n ];
2022 for ( m = 0; m < level + 2; m++ ) {
2023 tmp_array [ j ] [ pos++ ] = tmp_array_cen [ j + 1 ] [ m ];
2030 for ( j = 0; j < 3; j++ ) {
2031 j1 = face_ed_nd [ j ] [ 0 ];
2032 j2 = face_ed_nd [ j ] [ 1 ];
2036 p = ( level + 2 ) * ( level + 1 );
2037 mesh_face = mesh_fc [ j + 1 ];
2038 for ( k = 0; k < 3; k++ ) {
2039 if ( mesh_face->
node [ k ] == fe_tetra->node [ 3 ] ) {
2040 if ( swap [ j + 1 ] == 1 ) {
2043 if ( ( kk = k + 1 ) == 3 ) {
2052 for ( m = 0; m < level + 2; m++ ) {
2053 tmp_array [ j + 3 ] [ pos++ ] = mesh_face->
fine_id [ kk ] [ p++ ];
2056 if ( ( jj = j ) == 0 ) {
2061 p = ( level + 2 ) * ( level + 1 );
2062 mesh_face = mesh_fc [ jj ];
2063 for ( k = 0; k < 3; k++ ) {
2064 if ( mesh_face->
node [ k ] == fe_tetra->node [ j ] ) {
2065 if ( swap [ jj ] == 1 ) {
2068 if ( ( kk = k + 1 ) == 3 ) {
2077 for ( n = 1; n < level + 1; n++ ) {
2078 tmp_array [ j + 3 ] [ pos++ ] = mesh_face->
fine_id [ kk ] [ ++p ];
2079 for ( m = 0; m < level; m++ ) {
2080 tmp_array [ j + 3 ] [ pos++ ] = ++refine_node_id;
2083 tmp_array [ j + 3 ] [ pos++ ] = tmp_array_cen [ j + 1 ] [ n ];
2087 for ( m = 0; m < level + 2; m++ ) {
2088 tmp_array [ j + 3 ] [ pos++ ] = tmp_array_cen [ jj ] [ m ];
2105 for ( j = 0; j < 3; j++ ) {
2106 fine_hexa = & ( fine_hexa_array [ fine_hexa_id++ ] );
2107 if ( ( fine_hexa->
fine_id = (
int * ) calloc( ( level + 2 ) * ( level + 2 ) * ( level + 2 ),
sizeof(
int ) ) ) == NULL ) {
2111 mesh_face = mesh_fc [ 0 ];
2112 for ( k = 0; k < 3; k++ ) {
2113 if ( mesh_face->
node [ k ] == fe_tetra->node [ j ] ) {
2118 if ( swap [ 0 ] == 1 ) {
2119 for ( pos = 0, n = 0; n < level + 2; n++ ) {
2120 for ( m = 0; m < level + 2; m++, pos++ ) {
2125 for ( pos = 0, n = 0; n < level + 2; n++ ) {
2126 for ( m = 0; m < level + 2; m++, pos++ ) {
2132 mesh_face = mesh_fc [ j + 1 ];
2133 for ( k = 0; k < 3; k++ ) {
2134 if ( mesh_face->
node [ k ] == fe_tetra->node [ j ] ) {
2139 if ( swap [ j + 1 ] == 1 ) {
2140 for ( pos = 0, n = 0; n < level + 2; n++ ) {
2141 for ( m = 0; m < level + 2; m++, pos++ ) {
2146 for ( pos = 0, n = 0; n < level + 2; n++ ) {
2147 for ( m = 0; m < level + 2; m++, pos++ ) {
2153 if ( ( jj = j ) == 0 ) {
2157 mesh_face = mesh_fc [ jj ];
2158 for ( k = 0; k < 3; k++ ) {
2159 if ( mesh_face->
node [ k ] == fe_tetra->node [ j ] ) {
2164 if ( swap [ jj ] == 1 ) {
2165 for ( pos = 0, n = 0; n < level + 2; n++ ) {
2166 for ( m = 0; m < level + 2; m++, pos++ ) {
2171 for ( pos = 0, n = 0; n < level + 2; n++ ) {
2172 for ( m = 0; m < level + 2; m++, pos++ ) {
2178 for ( pos = 0, n = 0; n < level + 2; n++ ) {
2179 for ( m = 0; m < level + 2; m++, pos++ ) {
2181 matrix_3d(fine_hexa->
fine_id, m, level + 1, n) = tmp_array [ jj - 1 ] [ pos ];
2182 matrix_3d(fine_hexa->
fine_id, m, n, level + 1) = tmp_array [ j + 3 ] [ pos ];
2187 for ( k = 1; k < level + 1; k++ ) {
2188 for ( n = 1; n < level + 1; n++ ) {
2189 for ( m = 1; m < level + 1; m++ ) {
2199 fine_hexa = & ( fine_hexa_array [ fine_hexa_id++ ] );
2200 if ( ( fine_hexa->
fine_id = (
int * ) calloc( ( level + 2 ) * ( level + 2 ) * ( level + 2 ),
sizeof(
int ) ) ) == NULL ) {
2204 mesh_face = mesh_fc [ 1 ];
2205 for ( k = 0; k < 3; k++ ) {
2206 if ( mesh_face->
node [ k ] == fe_tetra->node [ 3 ] ) {
2211 if ( swap [ 1 ] == 1 ) {
2212 for ( pos = 0, n = 0; n < level + 2; n++ ) {
2213 for ( m = 0; m < level + 2; m++, pos++ ) {
2218 for ( pos = 0, n = 0; n < level + 2; n++ ) {
2219 for ( m = 0; m < level + 2; m++, pos++ ) {
2225 mesh_face = mesh_fc [ 2 ];
2226 for ( k = 0; k < 3; k++ ) {
2227 if ( mesh_face->
node [ k ] == fe_tetra->node [ 3 ] ) {
2232 if ( swap [ 2 ] == 1 ) {
2233 for ( pos = 0, n = 0; n < level + 2; n++ ) {
2234 for ( m = 0; m < level + 2; m++, pos++ ) {
2239 for ( pos = 0, n = 0; n < level + 2; n++ ) {
2240 for ( m = 0; m < level + 2; m++, pos++ ) {
2246 mesh_face = mesh_fc [ 3 ];
2247 for ( k = 0; k < 3; k++ ) {
2248 if ( mesh_face->
node [ k ] == fe_tetra->node [ 3 ] ) {
2253 if ( swap [ 3 ] == 1 ) {
2254 for ( pos = 0, n = 0; n < level + 2; n++ ) {
2255 for ( m = 0; m < level + 2; m++, pos++ ) {
2260 for ( pos = 0, n = 0; n < level + 2; n++ ) {
2261 for ( m = 0; m < level + 2; m++, pos++ ) {
2267 for ( pos = 0, n = 0; n < level + 2; n++ ) {
2268 for ( m = 0; m < level + 2; m++, pos++ ) {
2269 matrix_3d(fine_hexa->
fine_id, level + 1, n, m) = tmp_array [ 0 + 3 ] [ pos ];
2270 matrix_3d(fine_hexa->
fine_id, m, level + 1, n) = tmp_array [ 2 + 3 ] [ pos ];
2271 matrix_3d(fine_hexa->
fine_id, n, m, level + 1) = tmp_array [ 1 + 3 ] [ pos ];
2276 for ( k = 1; k < level + 1; k++ ) {
2277 for ( n = 1; n < level + 1; n++ ) {
2278 for ( m = 1; m < level + 1; m++ ) {
2286 fe_hexa = fe_hexa_array;
2287 tmp_hexa = tmp_hexa_array;
2288 for ( i = 0; i < fe_hexas; i++, fe_hexa++, tmp_hexa++, fine_node++ ) {
2289 fine_node->
id = ++fine_node_id;
2291 for ( j = 0; j < 6; j++ ) {
2292 tmp_array_cen [ j ] [ 0 ] = tmp_hexa->quad [ j ]->mid_node->id;
2293 for ( k = 1; k < level + 1; k++ ) {
2294 tmp_array_cen [ j ] [ k ] = ++refine_node_id;
2297 tmp_array_cen [ j ] [ level + 1 ] = fine_node->
id;
2304 for ( j = 0; j < 6; j++ ) {
2305 mesh_quad = mesh_qd [ j ] = tmp_hexa->quad [ j ];
2306 for ( k = 0; k < 4; k++ ) {
2307 if ( mesh_quad->
node [ k ] == fe_hexa->node [ hexa_fc_nd [ j ] [ 0 ] ] ) {
2308 if ( ( kk = k + 1 ) == 4 ) {
2312 if ( mesh_quad->
node [ kk ] == fe_hexa->node [ hexa_fc_nd [ j ] [ 1 ] ] ) {
2327 for ( j = 0; j < 4; j++ ) {
2330 p = ( level + 2 ) * ( level + 1 );
2331 mesh_quad = mesh_qd [ 0 ];
2332 for ( k = 0; k < 4; k++ ) {
2333 if ( mesh_quad->
node [ k ] == fe_hexa->node [ j ] ) {
2334 if ( swap [ 0 ] == 1 ) {
2337 if ( ( kk = k + 1 ) == 4 ) {
2346 for ( m = 0; m < level + 2; m++ ) {
2347 tmp_array [ j ] [ pos++ ] = mesh_quad->
fine_id [ kk ] [ p++ ];
2351 p = ( level + 2 ) * ( level + 1 );
2352 mesh_quad = mesh_qd [ j + 1 ];
2353 for ( k = 0; k < 4; k++ ) {
2354 if ( mesh_quad->
node [ k ] == fe_hexa->node [ j ] ) {
2355 if ( swap [ j + 1 ] == 1 ) {
2358 if ( ( kk = k + 1 ) == 4 ) {
2367 for ( n = 1; n < level + 1; n++ ) {
2368 tmp_array [ j ] [ pos++ ] = mesh_quad->
fine_id [ kk ] [ ++p ];
2369 for ( m = 0; m < level; m++ ) {
2370 tmp_array [ j ] [ pos++ ] = ++refine_node_id;
2373 tmp_array [ j ] [ pos++ ] = tmp_array_cen [ 0 ] [ n ];
2377 for ( m = 0; m < level + 2; m++ ) {
2378 tmp_array [ j ] [ pos++ ] = tmp_array_cen [ j + 1 ] [ m ];
2386 for ( j = 0; j < 4; j++ ) {
2389 p = ( level + 2 ) * ( level + 1 );
2390 mesh_quad = mesh_qd [ 5 ];
2391 for ( k = 0; k < 4; k++ ) {
2392 if ( mesh_quad->
node [ k ] == fe_hexa->node [ j + 4 ] ) {
2393 if ( swap [ 5 ] == 0 ) {
2396 if ( ( kk = k + 1 ) == 4 ) {
2405 for ( m = 0; m < level + 2; m++ ) {
2406 tmp_array [ j + 4 ] [ pos++ ] = mesh_quad->
fine_id [ kk ] [ p++ ];
2410 p = ( level + 2 ) * ( level + 1 );
2411 mesh_quad = mesh_qd [ j + 1 ];
2412 for ( k = 0; k < 4; k++ ) {
2413 if ( mesh_quad->
node [ k ] == fe_hexa->node [ j + 4 ] ) {
2414 if ( swap [ j + 1 ] == 0 ) {
2417 if ( ( kk = k + 1 ) == 4 ) {
2426 for ( n = 1; n < level + 1; n++ ) {
2427 tmp_array [ j + 4 ] [ pos++ ] = mesh_quad->
fine_id [ kk ] [ ++p ];
2428 for ( m = 0; m < level; m++ ) {
2429 tmp_array [ j + 4 ] [ pos++ ] = ++refine_node_id;
2432 tmp_array [ j + 4 ] [ pos++ ] = tmp_array_cen [ 5 ] [ n ];
2436 for ( m = 0; m < level + 2; m++ ) {
2437 tmp_array [ j + 4 ] [ pos++ ] = tmp_array_cen [ j + 1 ] [ m ];
2444 for ( j = 0; j < 4; j++ ) {
2447 p = ( level + 2 ) * ( level + 1 );
2448 mesh_quad = mesh_qd [ j + 1 ];
2449 for ( k = 0; k < 4; k++ ) {
2450 if ( mesh_quad->
node [ k ] == fe_hexa->node [ j + 4 ] ) {
2451 if ( swap [ j + 1 ] == 1 ) {
2454 if ( ( kk = k + 1 ) == 4 ) {
2463 for ( m = 0; m < level + 2; m++ ) {
2464 tmp_array [ j + 8 ] [ pos++ ] = mesh_quad->
fine_id [ kk ] [ p++ ];
2467 if ( ( jj = j ) == 0 ) {
2472 p = ( level + 2 ) * ( level + 1 );
2473 mesh_quad = mesh_qd [ jj ];
2474 for ( k = 0; k < 4; k++ ) {
2475 if ( mesh_quad->
node [ k ] == fe_hexa->node [ j ] ) {
2476 if ( swap [ jj ] == 1 ) {
2479 if ( ( kk = k + 1 ) == 4 ) {
2488 for ( n = 1; n < level + 1; n++ ) {
2489 tmp_array [ j + 8 ] [ pos++ ] = mesh_quad->
fine_id [ kk ] [ ++p ];
2490 for ( m = 0; m < level; m++ ) {
2491 tmp_array [ j + 8 ] [ pos++ ] = ++refine_node_id;
2494 tmp_array [ j + 8 ] [ pos++ ] = tmp_array_cen [ j + 1 ] [ n ];
2498 for ( m = 0; m < level + 2; m++ ) {
2499 tmp_array [ j + 8 ] [ pos++ ] = tmp_array_cen [ jj ] [ m ];
2516 for ( j = 0; j < 4; j++ ) {
2517 fine_hexa = & ( fine_hexa_array [ fine_hexa_id++ ] );
2518 if ( ( fine_hexa->
fine_id = (
int * ) calloc( ( level + 2 ) * ( level + 2 ) * ( level + 2 ),
sizeof(
int ) ) ) == NULL ) {
2522 mesh_quad = mesh_qd [ 0 ];
2523 for ( k = 0; k < 4; k++ ) {
2524 if ( mesh_quad->
node [ k ] == fe_hexa->node [ j ] ) {
2529 if ( swap [ 0 ] == 1 ) {
2530 for ( pos = 0, n = 0; n < level + 2; n++ ) {
2531 for ( m = 0; m < level + 2; m++, pos++ ) {
2536 for ( pos = 0, n = 0; n < level + 2; n++ ) {
2537 for ( m = 0; m < level + 2; m++, pos++ ) {
2543 mesh_quad = mesh_qd [ j + 1 ];
2544 for ( k = 0; k < 4; k++ ) {
2545 if ( mesh_quad->
node [ k ] == fe_hexa->node [ j ] ) {
2550 if ( swap [ j + 1 ] == 1 ) {
2551 for ( pos = 0, n = 0; n < level + 2; n++ ) {
2552 for ( m = 0; m < level + 2; m++, pos++ ) {
2557 for ( pos = 0, n = 0; n < level + 2; n++ ) {
2558 for ( m = 0; m < level + 2; m++, pos++ ) {
2564 if ( ( jj = j ) == 0 ) {
2568 mesh_quad = mesh_qd [ jj ];
2569 for ( k = 0; k < 4; k++ ) {
2570 if ( mesh_quad->
node [ k ] == fe_hexa->node [ j ] ) {
2575 if ( swap [ jj ] == 1 ) {
2576 for ( pos = 0, n = 0; n < level + 2; n++ ) {
2577 for ( m = 0; m < level + 2; m++, pos++ ) {
2582 for ( pos = 0, n = 0; n < level + 2; n++ ) {
2583 for ( m = 0; m < level + 2; m++, pos++ ) {
2589 for ( pos = 0, n = 0; n < level + 2; n++ ) {
2590 for ( m = 0; m < level + 2; m++, pos++ ) {
2592 matrix_3d(fine_hexa->
fine_id, m, level + 1, n) = tmp_array [ jj - 1 ] [ pos ];
2593 matrix_3d(fine_hexa->
fine_id, m, n, level + 1) = tmp_array [ j + 8 ] [ pos ];
2598 for ( k = 1; k < level + 1; k++ ) {
2599 for ( n = 1; n < level + 1; n++ ) {
2600 for ( m = 1; m < level + 1; m++ ) {
2610 for ( j = 0; j < 4; j++ ) {
2611 fine_hexa = & ( fine_hexa_array [ fine_hexa_id++ ] );
2612 if ( ( fine_hexa->
fine_id = (
int * ) calloc( ( level + 2 ) * ( level + 2 ) * ( level + 2 ),
sizeof(
int ) ) ) == NULL ) {
2616 mesh_quad = mesh_qd [ 5 ];
2617 for ( k = 0; k < 4; k++ ) {
2618 if ( mesh_quad->
node [ k ] == fe_hexa->node [ j + 4 ] ) {
2623 if ( swap [ 5 ] == 1 ) {
2624 for ( pos = 0, n = 0; n < level + 2; n++ ) {
2625 for ( m = 0; m < level + 2; m++, pos++ ) {
2630 for ( pos = 0, n = 0; n < level + 2; n++ ) {
2631 for ( m = 0; m < level + 2; m++, pos++ ) {
2637 mesh_quad = mesh_qd [ j + 1 ];
2638 for ( k = 0; k < 4; k++ ) {
2639 if ( mesh_quad->
node [ k ] == fe_hexa->node [ j + 4 ] ) {
2644 if ( swap [ j + 1 ] == 1 ) {
2645 for ( pos = 0, n = 0; n < level + 2; n++ ) {
2646 for ( m = 0; m < level + 2; m++, pos++ ) {
2651 for ( pos = 0, n = 0; n < level + 2; n++ ) {
2652 for ( m = 0; m < level + 2; m++, pos++ ) {
2658 if ( ( jj = j ) == 0 ) {
2662 mesh_quad = mesh_qd [ jj ];
2663 for ( k = 0; k < 4; k++ ) {
2664 if ( mesh_quad->
node [ k ] == fe_hexa->node [ j + 4 ] ) {
2669 if ( swap [ jj ] == 1 ) {
2670 for ( pos = 0, n = 0; n < level + 2; n++ ) {
2671 for ( m = 0; m < level + 2; m++, pos++ ) {
2676 for ( pos = 0, n = 0; n < level + 2; n++ ) {
2677 for ( m = 0; m < level + 2; m++, pos++ ) {
2683 for ( pos = 0, n = 0; n < level + 2; n++ ) {
2684 for ( m = 0; m < level + 2; m++, pos++ ) {
2685 matrix_3d(fine_hexa->
fine_id, level + 1, m, n) = tmp_array [ jj - 1 + 4 ] [ pos ];
2686 matrix_3d(fine_hexa->
fine_id, m, level + 1, n) = tmp_array [ j + 4 ] [ pos ];
2687 matrix_3d(fine_hexa->
fine_id, n, m, level + 1) = tmp_array [ j + 8 ] [ pos ];
2692 for ( k = 1; k < level + 1; k++ ) {
2693 for ( n = 1; n < level + 1; n++ ) {
2694 for ( m = 1; m < level + 1; m++ ) {
2703 for ( j = 0; j < 6; j++ ) {
2704 free(tmp_array_cen [ j ]);
2705 free(tmp_array [ j ]);
2706 free(tmp_array [ j + 6 ]);
2709 if ( fe_node_array != NULL ) {
2710 free(fe_node_array);
2713 if ( fe_edge_array != NULL ) {
2714 free(fe_edge_array);
2717 if ( fe_face_array != NULL ) {
2718 free(fe_face_array);
2721 if ( fe_quad_array != NULL ) {
2722 free(fe_quad_array);
2725 if ( fe_tetra_array != NULL ) {
2726 free(fe_tetra_array);
2729 if ( fe_hexa_array != NULL ) {
2730 free(fe_hexa_array);
2733 mesh_face = mesh_face_array;
2734 for ( i = 0; i < mesh_faces; i++, mesh_face++ ) {
2735 for ( j = 0; j < 3; j++ ) {
2736 if ( mesh_face->
fine_id [ j ] != NULL ) {
2737 free(mesh_face->
fine_id [ j ]);
2742 mesh_quad = mesh_quad_array;
2743 for ( i = 0; i < mesh_quads; i++, mesh_quad++ ) {
2744 for ( j = 0; j < 4; j++ ) {
2745 if ( mesh_quad->
fine_id [ j ] != NULL ) {
2746 free(mesh_quad->
fine_id [ j ]);
2751 if ( mesh_face_array != NULL ) {
2752 free(mesh_face_array);
2755 if ( mesh_quad_array != NULL ) {
2756 free(mesh_quad_array);
2808 if ( fine_node_array != NULL ) {
2809 free(fine_node_array);
2816 edge_id = face_id = quad_id = tetra_id = hexa_id = 0;
2817 for ( i = 0; i < fe_elems; i++ ) {
2825 fine_edge = & ( fine_edge_array [ pos ] );
2826 for ( j = 0; j < 2; j++, fine_edge++ ) {
2828 connectivity->
resize(level + 2);
2829 for ( k = 0; k < level + 2; k++ ) {
2830 connectivity->
at(k + 1) = fine_edge->
fine_id [ k ];
2834 for ( j = 0; j < 2; j++ ) {
2840 node = ( & ( fine_edge_array [ pos + j ] ) )->fine_id [ 0 ];
2841 if ( node_num_elems [ node ] - node_num_elems [ node - 1 ] == 1 ) {
2842 boundary->at(j + 1) = 1;
2844 boundary->at(j + 1) = 0;
2851 case EGT_triangle_1:
2853 fine_quad = & ( fine_quad_array [ pos ] );
2854 for ( j = 0; j < 3; j++, fine_quad++ ) {
2856 connectivity->
resize( ( level + 2 ) * ( level + 2 ) );
2857 for ( k = 0; k < ( level + 2 ) * ( level + 2 ); k++ ) {
2858 connectivity->
at(k + 1) = fine_quad->
fine_id [ k ];
2866 for ( j = 0; j < 3; j++ ) {
2867 boundary->at(j + 1) = 1;
2869 j1 = face_ed_nd [ j ] [ 0 ];
2870 j2 = face_ed_nd [ j ] [ 1 ];
2878 node1 = ( & ( fine_quad_array [ pos + j1 ] ) )->fine_id [ 0 ];
2879 node2 = ( & ( fine_quad_array [ pos + j2 ] ) )->fine_id [ 0 ];
2882 for ( k = node_num_elems [ node1 - 1 ]; k < node_num_elems [ node1 ]; k++ ) {
2883 elem2 = node_con_elems [ k ];
2884 if ( elem2 == elem1 ) {
2889 for ( m = node_num_elems [ node2 - 1 ]; m < node_num_elems [ node2 ]; m++ ) {
2890 if ( elem2 == node_con_elems [ m ] ) {
2891 boundary->at(j + 1) = flag = 0;
2907 pos = fe_faces * 3 + quad_id * 4;
2908 fine_quad = & ( fine_quad_array [ pos ] );
2909 for ( j = 0; j < 4; j++, fine_quad++ ) {
2911 connectivity->
resize( ( level + 2 ) * ( level + 2 ) );
2912 for ( k = 0; k < ( level + 2 ) * ( level + 2 ); k++ ) {
2913 connectivity->
at(k + 1) = fine_quad->
fine_id [ k ];
2921 for ( j = 0; j < 4; j++ ) {
2922 boundary->at(j + 1) = 1;
2924 j1 = quad_ed_nd [ j ] [ 0 ];
2925 j2 = quad_ed_nd [ j ] [ 1 ];
2933 node1 = ( & ( fine_quad_array [ pos + j1 ] ) )->fine_id [ 0 ];
2934 node2 = ( & ( fine_quad_array [ pos + j2 ] ) )->fine_id [ 0 ];
2937 for ( k = node_num_elems [ node1 - 1 ]; k < node_num_elems [ node1 ]; k++ ) {
2938 elem2 = node_con_elems [ k ];
2939 if ( elem2 == elem1 ) {
2944 for ( m = node_num_elems [ node2 - 1 ]; m < node_num_elems [ node2 ]; m++ ) {
2945 if ( elem2 == node_con_elems [ m ] ) {
2946 boundary->at(j + 1) = flag = 0;
2963 fine_hexa = & ( fine_hexa_array [ pos ] );
2964 for ( j = 0; j < 4; j++, fine_hexa++ ) {
2966 connectivity->
resize( ( level + 2 ) * ( level + 2 ) * ( level + 2 ) );
2967 for ( k = 0; k < ( level + 2 ) * ( level + 2 ) * ( level + 2 ); k++ ) {
2968 connectivity->
at(k + 1) = fine_hexa->
fine_id [ k ];
2972 tmp_tetra = & ( tmp_tetra_array [ tetra_id ] );
2973 for ( j = 0; j < 4; j++ ) {
2974 if ( tmp_tetra->ngb_elem_id [ j ] != 0 ) {
2975 boundary->at(j + 1) = 0;
2977 boundary->at(j + 1) = 1;
2985 pos = fe_tetras * 4 + hexa_id * 8;
2986 fine_hexa = & ( fine_hexa_array [ pos ] );
2987 for ( j = 0; j < 8; j++, fine_hexa++ ) {
2989 connectivity->
resize( ( level + 2 ) * ( level + 2 ) * ( level + 2 ) );
2990 for ( k = 0; k < ( level + 2 ) * ( level + 2 ) * ( level + 2 ); k++ ) {
2991 connectivity->
at(k + 1) = fine_hexa->
fine_id [ k ];
2995 tmp_hexa = & ( tmp_hexa_array [ hexa_id ] );
2996 for ( j = 0; j < 6; j++ ) {
2997 if ( tmp_hexa->ngb_elem_id [ j ] != 0 ) {
2998 boundary->at(j + 1) = 0;
3000 boundary->at(j + 1) = 1;
3015 if ( node_num_elems != NULL ) {
3016 free(node_num_elems);
3019 if ( node_con_elems != NULL ) {
3020 free(node_con_elems);
3023 if ( tmp_tetra_array != NULL ) {
3024 free(tmp_tetra_array);
3027 if ( tmp_hexa_array != NULL ) {
3028 free(tmp_hexa_array);
3031 fine_edge = fine_edge_array;
3032 for ( i = 0; i < fine_edges; i++, fine_edge++ ) {
3033 if ( fine_edge->
fine_id != NULL ) {
3038 fine_quad = fine_quad_array;
3039 for ( i = 0; i < fine_quads; i++, fine_quad++ ) {
3040 if ( fine_quad->
fine_id != NULL ) {
3045 fine_hexa = fine_hexa_array;
3046 for ( i = 0; i < fine_hexas; i++, fine_hexa++ ) {
3047 if ( fine_hexa->
fine_id != NULL ) {
3052 if ( fine_edge_array != NULL ) {
3053 free(fine_edge_array);
3056 if ( fine_quad_array != NULL ) {
3057 free(fine_quad_array);
3060 if ( fine_hexa_array != NULL ) {
3061 free(fine_hexa_array);
3064 this->
nodes = fe_nodes + fine_nodes + refine_nodes;
3065 this->
edges = fine_edges * ( level + 1 );
3066 this->
quads = fine_quads * ( level + 1 ) * ( level + 1 );
3067 this->
hexas = fine_hexas * ( level + 1 ) * ( level + 1 ) * ( level + 1 );
#define local_quad_id(ID)
int giveNumberOfDofManagers() const
Returns number of dof managers in domain.
#define matrix_3d(ARRAY, U, V, W)
#define global_quad_id(ID)
#define global_face_id(ID)
IntArray * giveFineNodeArray(int node)
Abstract base class for all finite elements.
int giveNumberOfElements() const
Returns number of elements in domain.
#define OOFEM_LOG_DEBUG(...)
Class implementing an array of integers.
int & at(int i)
Coefficient access function.
#define local_edge_id(ID)
#define local_face_id(ID)
Element * giveElement(int n)
Service for accessing particular domain fe element.
int refineMeshGlobally(Domain *d, int level, std::vector< RefinedElement > &refinedElementList)
#define local_tetra_id(ID)
void resize(int n)
Checks size of receiver towards requested bounds.
#define global_hexa_id(ID)
#define local_hexa_id(ID)
virtual Element_Geometry_Type giveGeometryType() const
Returns the element geometry type.
the oofem namespace is to define a context or scope in which all oofem names are defined.
Node * giveNode(int i) const
Returns reference to the i-th node of element.
#define error_message(MSG)
IntArray * giveBoundaryFlagArray(void)
#define global_tetra_id(ID)