1 /*****************************************************************************
2  *
3  *  Elmer, A Finite Element Software for Multiphysical Problems
4  *
5  *  Copyright 1st April 1995 - , CSC - IT Center for Science Ltd., Finland
6  *
7  *  This program is free software; you can redistribute it and/or
8  *  modify it under the terms of the GNU General Public License
9  *  as published by the Free Software Foundation; either version 2
10  *  of the License, or (at your option) any later version.
11  *
12  *  This program is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *  GNU General Public License for more details.
16  *
17  *  You should have received a copy of the GNU General Public License
18  *  along with this program (in file fem/GPL-2); if not, write to the
19  *  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  *  Boston, MA 02110-1301, USA.
21  *
22  *****************************************************************************/
23 
24 /*******************************************************************************
25  *
26  *  Element model type definitions etc.
27  *
28  *******************************************************************************
29  *
30  *                     Author:       Juha Ruokolainen
31  *
32  *                    Address: CSC - IT Center for Science Ltd.
33  *                                Keilaranta 14, P.O. BOX 405
34  *                                  02101 Espoo, Finland
35  *                                  Tel. +358 0 457 2723
36  *                                Telefax: +358 0 457 2302
37  *                              EMail: Juha.Ruokolainen@csc.fi
38  *
39  *                       Date: 20 Sep 1995
40  *
41  * Modification history:
42  *
43  * 28 Sep 1995, modified element_defs_t and element_type_t structures to hold
44  *              list of element_types instead of an array
45  * Juha R
46  *
47  *******************************************************************************/
48 
49 #if !defined(ELEMENTS_H)
50 
51 #define ELEMENTS_H
52 
53 #define TRUE  1
54 #define FALSE 0
55 
56 #ifdef MODULE_ELEMENTS
57 #define ELM_EXT
58 #else
59 #define ELM_EXT extern
60 #endif
61 
62 #define AEPS 1.0E-12
63 
64 #define ELM_NULL_ELEMENT          -1
65 
66 #define ELM_MAX_ELEMENT_TYPES    100
67 #define ELM_MAX_ELEMENT_CODE     999
68 
69 #define ELM_MAX_ELEMENT_NODES 27  /* TODO:  FIX THIS WHEN YOU'VE GOT MORE... */
70 
71 #define MAX_GROUP_IDS 8
72 
73 typedef struct element_s
74 {
75    struct element_type_s *ElementType;
76    signed char DisplayFlag;
77    int *Topology;
78    signed char GroupIds[MAX_GROUP_IDS];
79 } element_t;
80 
81 typedef struct element_model_s
82 {
83    double *NodeArray;
84    element_t *Elements;
85 
86    group_t *Groups;
87 
88    int NofNodes, NofElements, NofTimesteps;
89 } element_model_t;
90 
91 ELM_EXT element_model_t ElementModel;
92 ELM_EXT element_t *Elements;
93 
94 typedef struct element_type_s
95 {
96     struct element_type_s *Next;
97 
98     char *ElementName;     /* One line description of the element */
99     int   ElementCode;     /* Numeric code for the element        */
100 
101     double *NodeU;         /* node u coordinates */
102     double *NodeV;         /* node v coordinates */
103     double *NodeW;         /* node w coordinates */
104 
105     int NumberOfNodes;     /* number of nodes */
106 
107     /*
108      * function to give value of a variable (f), given coordinates (u,v,w)
109      */
110     double (*FunctionValue)( double *f,double u,double v,double w );
111 
112     /*
113      * function to give value of first partial derivate in (u) of a variable (f),
114      * given coordinates (u,v,w)
115      */
116     double (*PartialU)( double *f,double u,double v,double w );
117 
118     /*
119      * function to give value of first partial derivate in (v) of a variable (f),
120      * given coordinates (u,v,w)
121      */
122     double (*PartialV)( double *f,double u,double v,double w );
123 
124     /*
125      * function to give value of first partial derivate in (w) of a variable (f),
126      * given coordinates (u,v,w)
127      */
128     double (*PartialW)( double *f,double u,double v,double w );
129 
130     /*
131      * function to give value of second partial derivates of a variable (f),
132      * given coordinates (u,v,w)
133      */
134     double (*SecondPartials)( double *f,double u,double v,double w,double *Values );
135 
136     /*
137      * Trianglulate the element given node coordinates. Return value is 1 for
138      * success, 0 for failure.
139      */
140     int (*Triangulate)( geometry_t *,element_t *,element_t * );
141 
142     /*
143      * Check if a point is inside element boundaries, and return element coordinates
144      * of the point if it is.
145      */
146     int (*PointInside)
147          (
148                        double *nodex, double *nodey, double *nodez,
149                 double x, double y, double z, double *u,double *v,double *w
150          );
151 
152     /*
153      * Isoline extraction for an element.
154      */
155     int (*IsoLine)
156         (
157            double K, double *F, double *C, double *nx, double *ny, double *nz, line_t *line
158         );
159 
160     /*
161      * Isosurface extraction for element.
162      */
163     int (*IsoSurface)
164          (
165                double K, double *F, double *C, double *nx, double *ny,double *nz,
166                       double *nu,double *nv,double *nw,polygon_t *poly
167          );
168 
169 } element_type_t;
170 
171 /*
172  *  Element type definitions
173  */
174 typedef struct element_defs_s
175 {
176     element_type_t *ElementTypes;
177     int NumberOfTypes;
178 } element_defs_t;
179 
180 ELM_EXT element_defs_t ElementDefs;
181 
182 #ifdef MODULE_ELEMENTS
183 
184 int ElmBrickFace[6][9] =
185 {
186     { 0,1,2,3, 8, 9,10,11,20 },
187     { 4,5,6,7,16,17,18,19,21 },
188     { 0,1,5,4, 8,13,16,12,22 },
189     { 3,2,6,7,10,14,18,15,24 },
190     { 0,3,7,4,11,15,19,12,25 },
191     { 1,2,6,5, 9,14,17,13,23 }
192 };
193 
194 int ElmWedgeFace[5][8] =
195 {
196     { 0, 1, 4, 3,  6, 13,  9, 12 },
197     { 0, 2, 5, 3,  8, 14, 11, 12 },
198     { 1, 2, 5, 4,  7, 14, 10, 13 },
199     { 0, 1, 2, 6,  7,  8,  0,  0 },
200     { 3, 4, 5, 9, 10, 11,  0,  0 }
201 };
202 
203 int ElmTetraFace[4][7] =
204 {
205     { 0, 1, 2, 4, 5, 6, 10 },
206     { 0, 1, 3, 4, 8, 7, 11 },
207     { 1, 2, 3, 5, 9, 8, 12 },
208     { 0, 2, 3, 6, 9, 7, 13 }
209 };
210 
211 int ElmTetraFaceCubic[4][10] =
212 {
213     { 0, 1, 2, 4, 5, 6, 7, 8, 9,16 },
214     { 0, 1, 3, 4, 5,11,14,13,10,17 },
215     { 1, 2, 3, 6, 7,12,15,14,11,18 },
216     { 0, 2, 3, 9, 8,12,15,13,10,19 }
217 };
218 
219 #else
220 
221 extern int ElmBrickFace[6][9];
222 extern int ElmWedgeFace[5][8];
223 extern int ElmTetraFace[4][7];
224 extern int ElmTetraFaceCubic[4][10];
225 
226 #endif
227 
228 void lu_mtrinv( double *, int );
229 int elm_initialize_element_types();
230 #endif
231