1 /*--------------------------------------------------------------------------*/
2 /* ALBERTA: an Adaptive multi Level finite element toolbox using */
3 /* Bisectioning refinement and Error control by Residual */
4 /* Techniques for scientific Applications */
5 /* */
6 /* file: macro_1d.c */
7 /* */
8 /* */
9 /* description: dimension dependent part of reading/writing macro */
10 /* triangulations for 1d */
11 /* */
12 /*--------------------------------------------------------------------------*/
13 /* */
14 /* authors: Alfred Schmidt */
15 /* Zentrum fuer Technomathematik */
16 /* Fachbereich 3 Mathematik/Informatik */
17 /* Universitaet Bremen */
18 /* Bibliothekstr. 2 */
19 /* D-28359 Bremen, Germany */
20 /* */
21 /* Kunibert G. Siebert */
22 /* Institut fuer Mathematik */
23 /* Universitaet Augsburg */
24 /* Universitaetsstr. 14 */
25 /* D-86159 Augsburg, Germany */
26 /* */
27 /* Daniel Koester */
28 /* Institut fuer Mathematik */
29 /* Albert-Ludwigs-Universitaet Freiburg */
30 /* Hermann-Herder-Str. 10 */
31 /* D-79104 Freiburg */
32 /* */
33 /* http://www.mathematik.uni-freiburg.de/IAM/ALBERTA */
34 /* */
35 /* (c) by A. Schmidt and K.G. Siebert (1996-2003) */
36 /* */
37 /*--------------------------------------------------------------------------*/
38
39 /*--------------------------------------------------------------------------*/
40 /* read data->bound into mel[].bound[] */
41 /* WARNING: Please note the index mapping used here! */
42 /*--------------------------------------------------------------------------*/
43
44 static void
fill_bound_info_1d(MESH * mesh,const int * mel_vertices,int nv,int ne)45 fill_bound_info_1d(MESH *mesh, const int *mel_vertices, int nv, int ne)
46 {
47 return;
48 }
49
50 #if 0
51 static void fill_mel_orientation_1d(MACRO_EL *first, int n_mels)
52 {
53 FUNCNAME("_AI_fill_mel_orientation_1d");
54 MACRO_EL *mel, *mel_n;
55
56 for (mel = first; mel < first + n_mels; ++mel) {
57 mel->orientation = 0;
58 for (n = 0; n < N_NEIGH_1D; n++) {
59 mel_n = mel->neigh[n];
60 if (mel_n && mel->coord[1-n] == mel_n->coord[1-n]) {
61 mel->orientation |= (1 << n);
62 }
63 }
64 }
65 }
66 #endif
67
68 /*--------------------------------------------------------------------------*/
69 /* orientation_1d(): checks and corrects whether the element is oriented */
70 /* from left to right. */
71 /*--------------------------------------------------------------------------*/
72
73 #if DIM_OF_WORLD == 1
orientation_1d(MACRO_DATA * data)74 static U_CHAR orientation_1d(MACRO_DATA *data)
75 {
76 int i, vert_buffer, neigh_buffer;
77 BNDRY_TYPE bound_buffer;
78 U_CHAR result = false;
79
80 for(i = 0; i < data->n_macro_elements; i++) {
81 if(data->coords[data->mel_vertices[VERT_IND(1,i,0)]][0] >
82 data->coords[data->mel_vertices[VERT_IND(1,i,1)]][0]) {
83 result = true;
84
85 vert_buffer = data->mel_vertices[VERT_IND(1,i,0)];
86 data->mel_vertices[VERT_IND(1,i,0)] =
87 data->mel_vertices[VERT_IND(1,i,1)];
88 data->mel_vertices[VERT_IND(1,i,1)] = vert_buffer;
89
90 neigh_buffer = data->neigh[NEIGH_IND(1,i,0)];
91 data->neigh[NEIGH_IND(1,i,0)] = data->neigh[NEIGH_IND(1,i,1)];
92 data->neigh[NEIGH_IND(1,i,1)] = neigh_buffer;
93
94 bound_buffer = data->boundary[NEIGH_IND(1,i,0)];
95 data->boundary[NEIGH_IND(1,i,0)] = data->boundary[NEIGH_IND(1,i,1)];
96 data->boundary[NEIGH_IND(1,i,1)] = bound_buffer;
97 }
98 }
99
100 return(result);
101 }
102 #endif
103
104 /*--------------------------------------------------------------------------*/
105 /* macro_test(): In 1D only element orientation is checked (and corrected). */
106 /*--------------------------------------------------------------------------*/
107
macro_test_1d(MACRO_DATA * data,const char * new_name)108 static void macro_test_1d(MACRO_DATA *data, const char *new_name)
109 {
110 FUNCNAME("macro_test");
111
112 U_CHAR error_found = false;
113
114 #if DIM_OF_WORLD == 1
115 if(orientation_1d(data)) {
116 error_found = true;
117 WARNING("Element orientation was corrected for some elements.\n");
118 }
119 #endif
120
121 if (error_found && new_name) {
122 MSG("Attempting to write corrected macro data to file %s...\n", new_name);
123 write_macro_data(data, new_name);
124 }
125
126 return;
127 }
128