Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ElmerCSC
GitHub Repository: ElmerCSC/elmerfem
Path: blob/devel/post/src/elements/3node_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 3 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 u
56
* 0 0.5 1
57
*
58
*/
59
60
static double NodeU[] = { 0.0, 1.0, 0.5 };
61
62
/*******************************************************************************
63
*
64
* Name: elm_3node_bar_triangulate( geometry_t *,element_t * )
65
*
66
* Purpose: Triangulate an element. The process also builds up an edge
67
* table and adds new nodes to node table. The triangulation
68
* and edge table is stored in geometry_t *geom-structure.
69
*
70
* Parameters:
71
*
72
* Input: (geometry_t *) pointer to structure holding triangulation
73
* (element_t *) element to triangulate
74
*
75
* Output: (geometry_t *) structure is modified
76
*
77
* Return value: FALSE if malloc() fails, TRUE otherwise
78
*
79
******************************************************************************/
80
int elm_3node_bar_triangulate( geometry_t *geom, element_t *Elm, element_t *Parent)
81
{
82
int geo_add_edge();
83
geo_add_edge( geom, Elm->Topology[0],Elm->Topology[2],Parent );
84
return geo_add_edge( geom, Elm->Topology[2],Elm->Topology[1],Parent );
85
}
86
87
/*******************************************************************************
88
*
89
* Name: elm_3node_bar_fvalue( double *,double,double )
90
*
91
* Purpose: return value of a quantity given on nodes at point (u)
92
*
93
*
94
* Parameters:
95
*
96
* Input: (double *) quantity values at nodes
97
* (double u) point where value is evaluated
98
*
99
* Output: none
100
*
101
* Return value: quantity value
102
*
103
******************************************************************************/
104
static double elm_3node_bar_fvalue(double *F,double u)
105
{
106
double u2=u*u;
107
108
return F[0]*(1-3*u-2*u2) + F[1]*(-4*u+2*u2) + F[2]*(4*u+4*u2);
109
}
110
111
/*******************************************************************************
112
*
113
* Name: elm_3node_bar_dndu_fvalue( double *,double,double )
114
*
115
* Purpose: return value of a first partial derivate in (u) of a
116
* quantity given on nodes at point (u)
117
*
118
*
119
* Parameters:
120
*
121
* Input: (double *) quantity values at nodes
122
* (double u) point where value is evaluated
123
*
124
* Output: none
125
*
126
* Return value: quantity value
127
*
128
******************************************************************************/
129
static double elm_3node_bar_dndu_fvalue(double *F,double u)
130
{
131
return F[0]*(-3-4*u) + F[1]*(-4+4*u) + F[2]*(4+8*u);
132
}
133
134
/*******************************************************************************
135
*
136
* Name: elm_3node_bar_initialize()
137
*
138
* Purpose: Register the element type
139
*
140
* Parameters:
141
*
142
* Input: (char *) description of the element
143
* (int) numeric code for the element
144
*
145
* Output: Global list of element types is modified
146
*
147
* Return value: malloc() success
148
*
149
******************************************************************************/
150
int elm_3node_bar_initialize()
151
{
152
static char *Name = "ELM_3NODE_LINE";
153
154
element_type_t ElementDef;
155
int elm_add_element_type();
156
157
ElementDef.ElementName = Name;
158
ElementDef.ElementCode = 203;
159
160
ElementDef.NumberOfNodes = 3;
161
162
ElementDef.NodeU = NodeU;
163
ElementDef.NodeV = NULL;
164
ElementDef.NodeW = NULL;
165
166
ElementDef.PartialU = (double (*)())elm_3node_bar_dndu_fvalue;
167
ElementDef.PartialV = (double (*)())NULL;
168
ElementDef.PartialW = (double (*)())NULL;
169
170
ElementDef.FunctionValue = (double (*)())elm_3node_bar_fvalue;
171
ElementDef.Triangulate = (int (*)())elm_3node_bar_triangulate;
172
ElementDef.IsoLine = (int (*)())NULL;
173
ElementDef.PointInside = (int (*)())NULL;
174
ElementDef.IsoSurface = (int (*)())NULL;
175
176
return elm_add_element_type( &ElementDef ) ;
177
}
178
179