## root/src/elemChecker.c

/* [<][>][^][v][top][bottom][index][help] */

## DEFINITIONS

This source file includes following definitions.
```   1
2 #include <unistd.h>
3 #include <stdio.h>
4 #include <math.h>
5 #include <stdlib.h>
7 #include "CalculiX.h"
8
9 /* ----------------------------------------------------------------  */
10 /* elemChecker korrigiert falsch orientierte elemente 24.06.97 wi    */
11 /* ACHTUNG! liefert jetzt einen pointer auf ein ITG-feld:            */
12 /* sum_korrelems,elemnr(1),elemnr(2)...                              */
13 /* ----------------------------------------------------------------  */
14
16
17 ITG elemChecker(ITG sum_e, Nodes *node, Elements *elem)
18 {
19   ITG i, j;
20   double v12[3], v13[3], v15[3], v15n[3], vn[3];
21   double bv15, bvn, bv15n, bgrenz;
22   ITG epuf[27];
23   ITG e_korr=0;
24
25   for (i=0; i<sum_e; i++)
26   {
27     if( (elem[i].type == 1)||(elem[i].type == 4) )   /* HEXA */
28     {
29       v_result( &node[elem[i].nod[0]].nx, &node[elem[i].nod[1]].nx, v12);
30       v_result( &node[elem[i].nod[0]].nx, &node[elem[i].nod[3]].nx, v13);
31       v_result( &node[elem[i].nod[0]].nx, &node[elem[i].nod[4]].nx, v15);
32       v_prod(v12,v13,vn);
33       v_result(v15,vn,v15n);
34       bvn=v_betrag(vn);
35       bv15=v_betrag(v15);
36       bgrenz=sqrt(bvn*bvn+bv15*bv15);
37       bv15n=v_betrag(v15n);
38
39       /* printf ("elemcheck:%" ITGFORMAT " vn x=%e y=%e z=%e\n",elem[i].nr,vn[0],vn[1],vn[2]); */
40       if (bv15n > bgrenz)
41         {
42         /* printf ("elem %" ITGFORMAT " wrong defined, v15n=%e vgrenz=%e\n", elem[i].nr,bv15n,bgrenz);  */
43         for (j=0; j<8; j++)
44           {
45           epuf[j] = elem[i].nod[j];
46           }
47         elem[i].nod[0] = epuf[4];
48         elem[i].nod[1] = epuf[5];
49         elem[i].nod[2] = epuf[6];
50         elem[i].nod[3] = epuf[7];
51         elem[i].nod[4] = epuf[0];
52         elem[i].nod[5] = epuf[1];
53         elem[i].nod[6] = epuf[2];
54         elem[i].nod[7] = epuf[3];
55         e_korr++;
56         if (elem[i].type == 4)
57         {
58           for (j=0; j<4; j++)
59           {
60             epuf[j] = elem[i].nod[j+8];
61             epuf[j+4] = elem[i].nod[j+16];
62           }
63           elem[i].nod[8] = epuf[4];
64           elem[i].nod[9] = epuf[5];
65           elem[i].nod[10] = epuf[6];
66           elem[i].nod[11] = epuf[7];
67           elem[i].nod[16] = epuf[0];
68           elem[i].nod[17] = epuf[1];
69           elem[i].nod[18] = epuf[2];
70           elem[i].nod[19] = epuf[3];
71         }
72
73       }
74     }
75
76     else if( (elem[i].type == 2)||(elem[i].type == 5) )   /* PENTA */
77     {
78       v_result( &node[elem[i].nod[0]].nx, &node[elem[i].nod[1]].nx, v12);
79       v_result( &node[elem[i].nod[0]].nx, &node[elem[i].nod[2]].nx, v13);
80       v_result( &node[elem[i].nod[0]].nx, &node[elem[i].nod[3]].nx, v15);
81       v_prod(v12,v13,vn);
82       v_result(v15,vn,v15n);
83       bvn=v_betrag(vn);
84       bv15=v_betrag(v15);
85       bgrenz=sqrt(bvn*bvn+bv15*bv15);
86       bv15n=v_betrag(v15n);
87
88       /* printf ("elemcheck:%" ITGFORMAT " vn x=%e y=%e z=%e\n",elem[i].nr,vn[0],vn[1],vn[2]); */
89       if (bv15n > bgrenz)
90         {
91         /* printf ("elem %" ITGFORMAT " wrong defined, v15n=%e vgrenz=%e\n", elem[i].nr,bv15n,bgrenz);  */
92         for (j=0; j<6; j++)
93           {
94           epuf[j] = elem[i].nod[j];
95           }
96         elem[i].nod[0] = epuf[3];
97         elem[i].nod[1] = epuf[4];
98         elem[i].nod[2] = epuf[5];
99         elem[i].nod[3] = epuf[0];
100         elem[i].nod[4] = epuf[1];
101         elem[i].nod[5] = epuf[2];
102         e_korr++;
103         if (elem[i].type == 5)
104         {
105           for (j=0; j<3; j++)
106           {
107             epuf[j] = elem[i].nod[j+6];
108             epuf[j+3] = elem[i].nod[j+12];
109           }
110           elem[i].nod[6] = epuf[3];
111           elem[i].nod[7] = epuf[4];
112           elem[i].nod[8] = epuf[5];
113           elem[i].nod[12] = epuf[0];
114           elem[i].nod[13] = epuf[1];
115           elem[i].nod[14] = epuf[2];
116         }
117
118       }
119     }
120
121     else if( (elem[i].type == 3)||(elem[i].type == 6) )   /* TET */
122     {
123       v_result( &node[elem[i].nod[0]].nx, &node[elem[i].nod[1]].nx, v12);
124       v_result( &node[elem[i].nod[0]].nx, &node[elem[i].nod[2]].nx, v13);
125       v_result( &node[elem[i].nod[0]].nx, &node[elem[i].nod[3]].nx, v15);
126       v_prod(v12,v13,vn);
127       v_result(v15,vn,v15n);
128       bvn=v_betrag(vn);
129       bv15=v_betrag(v15);
130       bgrenz=sqrt(bvn*bvn+bv15*bv15);
131       bv15n=v_betrag(v15n);
132
133       /* printf ("elemcheck:%" ITGFORMAT " vn x=%e y=%e z=%e\n",elem[i].nr,vn[0],vn[1],vn[2]); */
134       if (bv15n > bgrenz)
135       {
136         /* printf ("elem %" ITGFORMAT " wrong defined, v15n=%e vgrenz=%e\n", elem[i].nr,bv15n,bgrenz);  */
137         for (j=0; j<4; j++) epuf[j] = elem[i].nod[j];
138         elem[i].nod[0] = epuf[1];
139         elem[i].nod[1] = epuf[2];
140         elem[i].nod[2] = epuf[3];
141         elem[i].nod[3] = epuf[0];
142         e_korr++;
143         if (elem[i].type == 6)
144         {
145           for (j=4; j<10; j++) epuf[j] = elem[i].nod[j];
146           elem[i].nod[4] = epuf[5];
147           elem[i].nod[5] = epuf[9];
148           elem[i].nod[6] = epuf[8];
149           elem[i].nod[7] = epuf[4];
150           elem[i].nod[8] = epuf[6];
151           elem[i].nod[9] = epuf[7];
152         }
153
154       }
155     }
156
157   }
158   return (e_korr);
159 }
160
```

/* [<][>][^][v][top][bottom][index][help] */