Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ElmerCSC
GitHub Repository: ElmerCSC/elmerfem
Path: blob/devel/post/src/elements/4node_bar.c
3203 views
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
* Definition of 4 node bar element.
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: [email protected]
38
*
39
* Date: 20 Sep 1995
40
*
41
*
42
* Modification history:
43
*
44
* 28 Sep 1995, changed call to elm_triangle_normal to geo_triangle normal
45
* routine elm_... doesn't exist anymore
46
*
47
******************************************************************************/
48
49
#include "../elmerpost.h"
50
#include <elements.h>
51
52
/*
53
* Two node 1D element
54
*
55
* o---o---o---o u
56
* 0 0.5 1
57
*
58
*/
59
60
61
static double NodeU[] = { 0.0, 1.0, 1.0/3.0, 2.0/3.0 };
62
63
static double N[4][4],A[4][4];
64
65
/*******************************************************************************
66
*
67
* Name: elm_4node_bar_shape_functions( )
68
*
69
* Purpose: Initialize element shape function array. Internal only.
70
*
71
* Parameters:
72
*
73
* Input: Global (filewise) variables NodeU,NodeV,NodeW
74
*
75
* Output: Global (filewise) variable N[4][4], will contain
76
* shape function coefficients
77
*
78
* Return value: void
79
*
80
******************************************************************************/
81
static void elm_4node_bar_shape_functions()
82
{
83
double u,v;
84
85
int i,j;
86
87
for( i=0; i<4; i++ )
88
{
89
u = NodeU[i];
90
91
A[i][0] = 1;
92
A[i][1] = u;
93
A[i][2] = u*u;
94
A[i][3] = u*u*u;
95
}
96
97
lu_mtrinv( (double *)A,4 );
98
99
for( i=0; i<4; i++ )
100
for( j=0; j<4; j++ ) N[i][j] = A[j][i];
101
}
102
103
104
/*******************************************************************************
105
*
106
* Name: elm_4node_bar_triangulate( geometry_t *,element_t * )
107
*
108
* Purpose: Triangulate an element. The process also builds up an edge
109
* table and adds new nodes to node table. The triangulation
110
* and edge table is stored in geometry_t *geom-structure.
111
*
112
* Parameters:
113
*
114
* Input: (geometry_t *) pointer to structure holding triangulation
115
* (element_t *) element to triangulate
116
*
117
* Output: (geometry_t *) structure is modified
118
*
119
* Return value: FALSE if malloc() fails, TRUE otherwise
120
*
121
******************************************************************************/
122
int elm_4node_bar_triangulate( geometry_t *geom, element_t *Elm, element_t *Parent)
123
{
124
int geo_add_edge();
125
geo_add_edge( geom, Elm->Topology[0],Elm->Topology[2],Parent );
126
geo_add_edge( geom, Elm->Topology[2],Elm->Topology[3],Parent );
127
return geo_add_edge( geom, Elm->Topology[3],Elm->Topology[1],Parent );
128
}
129
130
131
/*******************************************************************************
132
*
133
* Name: elm_4node_bar_fvalue( double *,double,double )
134
*
135
* Purpose: return value of a quantity given on nodes at point (u,v)
136
*
137
*
138
* Parameters:
139
*
140
* Input: (double *) quantity values at nodes
141
* (double u,double v) point where value is evaluated
142
*
143
* Output: none
144
*
145
* Return value: quantity value
146
*
147
******************************************************************************/
148
static double elm_4node_bar_fvalue( double *F,double u)
149
{
150
double R=0.0;
151
int i;
152
153
for( i=0; i<4; i++ )
154
{
155
R += F[i]*( N[i][0] +
156
N[i][1]*u +
157
N[i][2]*u*u +
158
N[i][3]*u*u*u );
159
}
160
161
return R;
162
}
163
164
/*******************************************************************************
165
*
166
* Name: elm_4node_bar_dndu_fvalue( double *,double,double )
167
*
168
* Purpose: return value of a first partial derivate in (u) of a
169
* quantity given on nodes at point (u,v)
170
*
171
*
172
* Parameters:
173
*
174
* Input: (double *) quantity values at nodes
175
* (double u,double v) point where value is evaluated
176
*
177
* Output: none
178
*
179
* Return value: quantity value
180
*
181
******************************************************************************/
182
static double elm_4node_bar_dndu_fvalue(double *F,double u)
183
{
184
double R=0.0;
185
int i;
186
187
for( i=0; i<4; i++ )
188
{
189
R += F[i]*( N[i][1] + 2*N[i][2]*u + 3*N[i][3]*u*u );
190
}
191
192
return R;
193
}
194
195
/*******************************************************************************
196
*
197
* Name: elm_4node_bar_initialize()
198
*
199
* Purpose: Register the element type
200
*
201
* Parameters:
202
*
203
* Input: (char *) description of the element
204
* (int) numeric code for the element
205
*
206
* Output: Global list of element types is modified
207
*
208
* Return value: malloc() success
209
*
210
******************************************************************************/
211
int elm_4node_bar_initialize()
212
{
213
static char *Name = "ELM_4NODE_LINE";
214
215
element_type_t ElementDef;
216
int elm_add_element_type();
217
218
elm_4node_bar_shape_functions();
219
220
ElementDef.ElementName = Name;
221
ElementDef.ElementCode = 204;
222
223
ElementDef.NumberOfNodes = 4;
224
225
ElementDef.NodeU = NodeU;
226
ElementDef.NodeV = NULL;
227
ElementDef.NodeW = NULL;
228
229
ElementDef.PartialU = (double (*)())elm_4node_bar_dndu_fvalue;
230
ElementDef.PartialV = (double (*)())NULL;
231
ElementDef.PartialW = (double (*)())NULL;
232
233
ElementDef.FunctionValue = (double (*)())elm_4node_bar_fvalue;
234
ElementDef.Triangulate = (int (*)())elm_4node_bar_triangulate;
235
ElementDef.IsoLine = (int (*)())NULL;
236
ElementDef.PointInside = (int (*)())NULL;
237
ElementDef.IsoSurface = (int (*)())NULL;
238
239
return elm_add_element_type( &ElementDef ) ;
240
}
241
242