Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ElmerCSC
GitHub Repository: ElmerCSC/elmerfem
Path: blob/devel/post/src/elements/2node_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 two node bar 1D 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 u
56
* 0 1
57
*
58
*/
59
60
static double NodeU[2] = { 0.0, 1.0 };
61
62
/*******************************************************************************
63
*
64
* Name: elm_2node_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_2node_bar_triangulate( geometry_t *geom, element_t *Elm, element_t *Parent)
81
{
82
83
int geo_add_edge();
84
return geo_add_edge( geom, Elm->Topology[0],Elm->Topology[1],Parent );
85
}
86
87
/*******************************************************************************
88
*
89
* Name: elm_2node_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_2node_bar_fvalue(double *F,double u)
105
{
106
return F[0]*(1-u) + F[1]*u;
107
}
108
109
/*******************************************************************************
110
*
111
* Name: elm_2node_bar_dndu_fvalue( double *,double,double )
112
*
113
* Purpose: return value of a first partial derivate in (u) of a
114
* quantity given on nodes at point (u)
115
*
116
*
117
* Parameters:
118
*
119
* Input: (double *) quantity values at nodes
120
* (double u) point where value is evaluated
121
*
122
* Output: none
123
*
124
* Return value: quantity value
125
*
126
******************************************************************************/
127
static double elm_2node_bar_dndu_fvalue(double *F,double u)
128
{
129
return -F[0] + F[1];
130
}
131
132
/*******************************************************************************
133
*
134
* Name: elm_2node_bar_initialize()
135
*
136
* Purpose: Register the element type
137
*
138
* Parameters:
139
*
140
* Input: (char *) description of the element
141
* (int) numeric code for the element
142
*
143
* Output: Global list of element types is modified
144
*
145
* Return value: malloc() success
146
*
147
******************************************************************************/
148
int elm_2node_bar_initialize()
149
{
150
static char *Name = "ELM_2NODE_LINE";
151
152
element_type_t ElementDef;
153
int elm_add_element_type();
154
155
ElementDef.ElementName = Name;
156
ElementDef.ElementCode = 202;
157
158
ElementDef.NumberOfNodes = 2;
159
160
ElementDef.NodeU = NodeU;
161
ElementDef.NodeV = NULL;
162
ElementDef.NodeW = NULL;
163
164
ElementDef.PartialU = (double (*)())elm_2node_bar_dndu_fvalue;
165
ElementDef.PartialV = (double (*)())NULL;
166
ElementDef.PartialW = (double (*)())NULL;
167
168
ElementDef.FunctionValue = (double (*)())elm_2node_bar_fvalue;
169
ElementDef.Triangulate = (int (*)())elm_2node_bar_triangulate;
170
ElementDef.IsoLine = (int (*)())NULL;
171
ElementDef.PointInside = (int (*)())NULL;
172
ElementDef.IsoSurface = (int (*)())NULL;
173
174
return elm_add_element_type( &ElementDef ) ;
175
}
176
177