/*****************************************************************************1*2* Elmer, A Finite Element Software for Multiphysical Problems3*4* Copyright 1st April 1995 - , CSC - IT Center for Science Ltd., Finland5*6* This program is free software; you can redistribute it and/or7* modify it under the terms of the GNU General Public License8* as published by the Free Software Foundation; either version 29* of the License, or (at your option) any later version.10*11* This program is distributed in the hope that it will be useful,12* but WITHOUT ANY WARRANTY; without even the implied warranty of13* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the14* GNU General Public License for more details.15*16* You should have received a copy of the GNU General Public License17* along with this program (in file fem/GPL-2); if not, write to the18* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,19* Boston, MA 02110-1301, USA.20*21*****************************************************************************/2223/*******************************************************************************24*25* Definition of 4 node bar element.26*27*******************************************************************************28*29* Author: Juha Ruokolainen30*31* Address: CSC - IT Center for Science Ltd.32* Keilaranta 14, P.O. BOX 40533* 02101 Espoo, Finland34* Tel. +358 0 457 272335* Telefax: +358 0 457 230236* EMail: [email protected]37*38* Date: 20 Sep 199539*40*41* Modification history:42*43* 28 Sep 1995, changed call to elm_triangle_normal to geo_triangle normal44* routine elm_... doesn't exist anymore45*46******************************************************************************/4748#include "../elmerpost.h"49#include <elements.h>5051/*52* Two node 1D element53*54* o---o---o---o u55* 0 0.5 156*57*/585960static double NodeU[] = { 0.0, 1.0, 1.0/3.0, 2.0/3.0 };6162static double N[4][4],A[4][4];6364/*******************************************************************************65*66* Name: elm_4node_bar_shape_functions( )67*68* Purpose: Initialize element shape function array. Internal only.69*70* Parameters:71*72* Input: Global (filewise) variables NodeU,NodeV,NodeW73*74* Output: Global (filewise) variable N[4][4], will contain75* shape function coefficients76*77* Return value: void78*79******************************************************************************/80static void elm_4node_bar_shape_functions()81{82double u,v;8384int i,j;8586for( i=0; i<4; i++ )87{88u = NodeU[i];8990A[i][0] = 1;91A[i][1] = u;92A[i][2] = u*u;93A[i][3] = u*u*u;94}9596lu_mtrinv( (double *)A,4 );9798for( i=0; i<4; i++ )99for( j=0; j<4; j++ ) N[i][j] = A[j][i];100}101102103/*******************************************************************************104*105* Name: elm_4node_bar_triangulate( geometry_t *,element_t * )106*107* Purpose: Triangulate an element. The process also builds up an edge108* table and adds new nodes to node table. The triangulation109* and edge table is stored in geometry_t *geom-structure.110*111* Parameters:112*113* Input: (geometry_t *) pointer to structure holding triangulation114* (element_t *) element to triangulate115*116* Output: (geometry_t *) structure is modified117*118* Return value: FALSE if malloc() fails, TRUE otherwise119*120******************************************************************************/121int elm_4node_bar_triangulate( geometry_t *geom, element_t *Elm, element_t *Parent)122{123int geo_add_edge();124geo_add_edge( geom, Elm->Topology[0],Elm->Topology[2],Parent );125geo_add_edge( geom, Elm->Topology[2],Elm->Topology[3],Parent );126return geo_add_edge( geom, Elm->Topology[3],Elm->Topology[1],Parent );127}128129130/*******************************************************************************131*132* Name: elm_4node_bar_fvalue( double *,double,double )133*134* Purpose: return value of a quantity given on nodes at point (u,v)135*136*137* Parameters:138*139* Input: (double *) quantity values at nodes140* (double u,double v) point where value is evaluated141*142* Output: none143*144* Return value: quantity value145*146******************************************************************************/147static double elm_4node_bar_fvalue( double *F,double u)148{149double R=0.0;150int i;151152for( i=0; i<4; i++ )153{154R += F[i]*( N[i][0] +155N[i][1]*u +156N[i][2]*u*u +157N[i][3]*u*u*u );158}159160return R;161}162163/*******************************************************************************164*165* Name: elm_4node_bar_dndu_fvalue( double *,double,double )166*167* Purpose: return value of a first partial derivate in (u) of a168* quantity given on nodes at point (u,v)169*170*171* Parameters:172*173* Input: (double *) quantity values at nodes174* (double u,double v) point where value is evaluated175*176* Output: none177*178* Return value: quantity value179*180******************************************************************************/181static double elm_4node_bar_dndu_fvalue(double *F,double u)182{183double R=0.0;184int i;185186for( i=0; i<4; i++ )187{188R += F[i]*( N[i][1] + 2*N[i][2]*u + 3*N[i][3]*u*u );189}190191return R;192}193194/*******************************************************************************195*196* Name: elm_4node_bar_initialize()197*198* Purpose: Register the element type199*200* Parameters:201*202* Input: (char *) description of the element203* (int) numeric code for the element204*205* Output: Global list of element types is modified206*207* Return value: malloc() success208*209******************************************************************************/210int elm_4node_bar_initialize()211{212static char *Name = "ELM_4NODE_LINE";213214element_type_t ElementDef;215int elm_add_element_type();216217elm_4node_bar_shape_functions();218219ElementDef.ElementName = Name;220ElementDef.ElementCode = 204;221222ElementDef.NumberOfNodes = 4;223224ElementDef.NodeU = NodeU;225ElementDef.NodeV = NULL;226ElementDef.NodeW = NULL;227228ElementDef.PartialU = (double (*)())elm_4node_bar_dndu_fvalue;229ElementDef.PartialV = (double (*)())NULL;230ElementDef.PartialW = (double (*)())NULL;231232ElementDef.FunctionValue = (double (*)())elm_4node_bar_fvalue;233ElementDef.Triangulate = (int (*)())elm_4node_bar_triangulate;234ElementDef.IsoLine = (int (*)())NULL;235ElementDef.PointInside = (int (*)())NULL;236ElementDef.IsoSurface = (int (*)())NULL;237238return elm_add_element_type( &ElementDef ) ;239}240241242