00001 /* 00002 %M This modules contains the node functions and definitions 00003 %a Joao Luiz Elias Campos. 00004 %d September 2nd, 1998. 00005 %r $Id: node.c,v 1.1 2004/06/22 05:29:59 joaoluiz Exp $ 00006 %w (C) COPYRIGHT 1995-1996, Eduardo Nobre Lages. 00007 (C) COPYRIGHT 1997-1998, Joao Luiz Elias Campos. 00008 All Rights Reserved 00009 Duplication of this program or any part thereof without the express 00010 written consent of the author is prohibited. 00011 */ 00012 00013 /* Modified: 26-04-06 Juan Pablo Ibaņez 00014 * Modificada a funcão NodeApplyDisplacement, onde tipo DISPLACEMENT 00015 * passa a ser setado no dof sem o controle de tolerancia. 00016 * 00017 */ 00018 00019 /* 00020 ** ------------------------------------------------------------------------ 00021 ** Global variables and symbols: 00022 */ 00023 #include <stdio.h> 00024 #include <stdlib.h> 00025 #include <math.h> 00026 00027 #include "load.h" 00028 #include "elm.h" 00029 #include "node.h" 00030 00031 /* 00032 %V Element vector, node number and number of degrees of freedown per node 00033 */ 00034 sNode *NodeVector = 0L; 00035 int NumNodes = 0; 00036 int NDof = 2; 00037 00038 00039 /* 00040 ** ------------------------------------------------------------------------ 00041 ** Local variables and symbols: 00042 */ 00043 00044 /* 00045 %K Zero definition 00046 */ 00047 #ifndef ZERO 00048 #define ZERO 0.000001 00049 #endif 00050 00051 00052 /* 00053 ** ------------------------------------------------------------------------ 00054 ** Local functions: 00055 */ 00056 00057 /* 00058 ** ------------------------------------------------------------------------ 00059 ** Public functions: 00060 */ 00061 00062 /* 00063 %F This function initializes the prescribeds values 00064 */ 00065 void NodeInitPrescValues( void ) 00066 { 00067 int i; 00068 00069 /* Initialize prescribed values 00070 */ 00071 for( i = 0; i < NumNodes; i++ ) 00072 { 00073 NodeVector[i].dof.vpx = 0.0; 00074 NodeVector[i].dof.vpy = 0.0; 00075 NodeVector[i].dof.vpz = 0.0; 00076 } 00077 00078 } /* End of NodeInitPrescValues */ 00079 00080 00081 /* 00082 %F This function release memory used by node vector 00083 */ 00084 void NodeFree( void ) 00085 { 00086 /* Releases node vector 00087 */ 00088 free( NodeVector ); 00089 00090 } /* End of NodeFree */ 00091 00092 00093 /* 00094 %F This function apply the nodal forces. 00095 */ 00096 void NodeApplyForce( int node, double fx, double fy, double fz ) 00097 { 00098 /* Check to see if the node is not rezoned 00099 */ 00100 if( NodeVector[node-1].rezone != NONE ) 00101 return; 00102 00103 /* Check first degree of freedown 00104 */ 00105 if( fabs(fx) > ZERO ) 00106 { 00107 NodeVector[node-1].dof.x = FORCE; 00108 NodeVector[node-1].dof.vpx = fx; 00109 } 00110 /* Check second degree of freedown 00111 */ 00112 if( fabs(fy) > ZERO ) 00113 { 00114 NodeVector[node-1].dof.y = FORCE; 00115 NodeVector[node-1].dof.vpy = fy; 00116 } 00117 /* Check third degree of freedown 00118 */ 00119 if( fabs(fz) > ZERO ) 00120 { 00121 NodeVector[node-1].dof.z = FORCE; 00122 NodeVector[node-1].dof.vpz = fz; 00123 } 00124 00125 } /* End of NodeApplyForce */ 00126 00127 00128 /* 00129 %F This function apply the nodal displacements. 00130 */ 00131 void NodeApplyDisplacement( int node, double dx, double dy, double dz ) 00132 { 00133 /* Check to see if the node is not rezoned 00134 */ 00135 if( NodeVector[node-1].rezone != NONE ) 00136 return; 00137 00138 /* Check first degree of freedown 00139 */ 00140 NodeVector[node-1].dof.x = DISPLACEMENT; 00141 NodeVector[node-1].dof.vpx = dx; 00142 00143 /* Check second degree of freedown 00144 */ 00145 NodeVector[node-1].dof.y = DISPLACEMENT; 00146 NodeVector[node-1].dof.vpy = dy; 00147 00148 /* Check third degree of freedown 00149 */ 00150 NodeVector[node-1].dof.z = DISPLACEMENT; 00151 NodeVector[node-1].dof.vpz = dz; 00152 00153 } /* End of NodeApplyDisplacement */ 00154 00155 00156 /* 00157 %F This function apply the nodal velocities. 00158 */ 00159 void NodeApplyVelocity( int node, double vx, double vy, double vz ) 00160 { 00161 /* Check to see if the node is not rezoned 00162 */ 00163 if( NodeVector[node-1].rezone != NONE ) 00164 return; 00165 00166 /* Check first degree of freedown 00167 */ 00168 if( fabs(vx) > ZERO ) 00169 { 00170 NodeVector[node-1].dof.x = VELOCITY; 00171 NodeVector[node-1].dof.vpx = vx; 00172 } 00173 /* Check second degree of freedown 00174 */ 00175 if( fabs(vy) > ZERO ) 00176 { 00177 NodeVector[node-1].dof.y = VELOCITY; 00178 NodeVector[node-1].dof.vpy = vy; 00179 } 00180 /* Check third degree of freedown 00181 */ 00182 if( fabs(vz) > ZERO ) 00183 { 00184 NodeVector[node-1].dof.z = VELOCITY; 00185 NodeVector[node-1].dof.vpz = vz; 00186 } 00187 00188 } /* End of NodeApplyVelocity */ 00189 00190 00191 /* 00192 %F This function initialize the force vector. 00193 */ 00194 void NodeInitForceVector( double *FVector ) 00195 { 00196 int i; 00197 00198 /* Initialize force vector 00199 */ 00200 for( i = 0; i < NumNodes; i++ ) 00201 { 00202 if( NodeVector[i].dof.x == FORCE ) 00203 FVector[NDof*i] = NodeVector[i].dof.vpx; 00204 else 00205 FVector[NDof*i+1] = 0.0; 00206 00207 if( NodeVector[i].dof.y == FORCE ) 00208 FVector[NDof*i] = NodeVector[i].dof.vpy; 00209 else 00210 FVector[NDof*i+1] = 0.0; 00211 00212 if( NDof == 3 ) 00213 { 00214 if( NodeVector[i].dof.z == FORCE ) 00215 FVector[NDof*i] = NodeVector[i].dof.vpz; 00216 else 00217 FVector[NDof*i+2] = 0.0; 00218 } 00219 } 00220 00221 } /* End of NodeInitForceVector */ 00222 00223 00224 /* ======================================================= End of File */ 00225
1.5.1