maxwell.c

Go to the documentation of this file.
00001 /*
00002 %M This modules contains the MAXWELL material sub-class methods and 
00003    definitions
00004 %a Joao Luiz Elias Campos.
00005 %d September 2nd, 1998.
00006 %r $Id: maxwell.c,v 1.1 2004/06/22 05:29:59 joaoluiz Exp $
00007 %w (C) COPYRIGHT 1995-1996, Eduardo Nobre Lages.
00008    (C) COPYRIGHT 1997-1999, Joao Luiz Elias Campos.
00009    All Rights Reserved
00010    Duplication of this program or any part thereof without the express
00011    written consent of the author is prohibited.
00012 
00013    Modificacao: 28/04/2005    Alexandre A. Del Savio
00014      Foram substituídas todas as alocações dinâmicas feitas com malloc 
00015      por calloc.
00016 
00017 */
00018 
00019 /*
00020 ** ------------------------------------------------------------------------
00021 ** Global variables and symbols:
00022 */
00023 #include <stdio.h>
00024 #include <stdlib.h>
00025 
00026 #include "load.h"
00027 #include "elm.h"
00028 #include "material.h"
00029 #include "node.h"
00030 #include "rio.h"
00031 
00032 
00033 /* Parent methods
00034  */
00035 void MaterialTimeStep( sMaterial *, double * );
00036 void MaterialDensity ( sMaterial *, double * );
00037 
00038 
00039 /*
00040 ** ------------------------------------------------------------------------
00041 ** Local variables and symbols:
00042 */
00043 
00044 /*
00045 %T MAXWELL material data definition
00046 */
00047 typedef struct _isodata
00048 {
00049  double E;             /* Young modulos       */
00050  double Nu;            /* Poisson coefficient */
00051  double N;             /* Viscosity parameter */
00052 } sMaxwellData;
00053 
00054 
00055 /*
00056 ** ------------------------------------------------------------------------
00057 ** Local functions:
00058 */
00059 
00060 
00061 /*
00062 ** ------------------------------------------------------------------------
00063 ** Subclass methods:
00064 */
00065 static void MaxwellNew         ( int, sMaterial ** );
00066 static void MaxwellFree        ( sMaterial * );
00067 static void MaxwellRead        ( sMaterial * );
00068 static void MaxwellEParameter  ( sMaterial *, double * );
00069 static void MaxwellNuParameter ( sMaterial *, double * );
00070 static void MaxwellCMatrix     ( sMaterial *, double [6][6] );
00071 static void MaxwellViscoStrain ( sMaterial *, double, sTensor *, sTensor * );
00072 static void MaxwellUpdateStress( sMaterial *, double, double *, double *,
00073                                               double *, double * );
00074 
00075 
00076 /*
00077 %F This method allocates memory for a MAXWELL material and fills its 
00078    data with the specific values.
00079 %i Material label (number)
00080 %o Material descriptor.
00081 */
00082 static void MaxwellNew( int label, sMaterial **mat )
00083 {
00084  sMaxwellData *data = 0L;
00085 
00086 /* Get memory for the material descriptor
00087  */
00088  (*mat) = (sMaterial *)calloc(1, sizeof(sMaterial));
00089 
00090 /* Get memory for the MAXWELL material data
00091  */
00092  data = (sMaxwellData *)calloc(1, sizeof(sMaxwellData));
00093 
00094 /* Fill MAXWELL material data
00095  */
00096  data->E  = 0.0;
00097  data->Nu = 0.0;
00098  data->N  = 0.0;
00099 
00100 /* Fill material descriptor
00101  */
00102  (*mat)->type  = MAXWELL;
00103  (*mat)->label = label;
00104  (*mat)->Gamma = 0.0;
00105  (*mat)->data  = (void *)data;
00106 
00107 /* Add to the material list
00108  */
00109  MatList[label-1] = (*mat);
00110 
00111 } /* End of MaxwellNew */
00112 
00113 
00114 /*
00115 %F This method frees the MAXWELL material data for a given material.
00116 %i Material descriptor.
00117 */
00118 static void MaxwellFree( sMaterial *mat )
00119 {
00120  sMaxwellData *data = 0L;
00121 
00122 /* Get MAXWELL material data
00123  */
00124  data = (sMaxwellData *)mat->data;
00125 
00126 /* Release allocated memory
00127  */
00128  free( data );
00129 
00130 /* Reset material data
00131  */
00132  mat->data = 0L;
00133 
00134 } /* End of MaxwellFree */
00135 
00136 
00137 /*
00138 %F This method reads the MAXWELL material information.
00139 %i Material descriptor.
00140 */
00141 static void MaxwellRead( sMaterial *mat )
00142 {
00143  sMaxwellData *data = 0L;
00144  double        e, nu, n;
00145 
00146 /* Get the material data
00147  */
00148  data = (sMaxwellData *)mat->data;
00149 
00150 /* Read the material parameters
00151  */
00152  fscanf( nf, "%lf %lf %lf", &e, &nu, &n );
00153 
00154 /* Fill material information
00155  */
00156  data->E  = e;
00157  data->Nu = nu;
00158  data->N  = n;
00159 
00160 } /* End of MaxwellRead */
00161 
00162 
00163 /*
00164 %F
00165 */
00166 static void MaxwellEParameter( sMaterial *mat, double *e )
00167 {
00168  sMaxwellData *data = 0L;
00169 
00170 /* Get material descriptor
00171  */ 
00172  data = (sMaxwellData *)mat->data;
00173 
00174 /* Get Young modules parameters
00175  */
00176  (*e) = data->E;
00177 
00178 } /* End of MaxwellEParameter */
00179 
00180 
00181 /*
00182 %F
00183 */
00184 static void MaxwellNuParameter( sMaterial *mat, double *nu )
00185 {
00186  sMaxwellData *data = 0L;
00187 
00188 /* Get material descriptor
00189  */ 
00190  data = (sMaxwellData *)mat->data;
00191 
00192 /* Get Poisson coefficient parameters
00193  */
00194  (*nu) = data->Nu;
00195 
00196 } /* End of MaxwellNuParameter */
00197 
00198 
00199 /*
00200 %F This function computes the material constitutive matrix
00201 */
00202 static void MaxwellCMatrix( sMaterial *mat, double cm[6][6] )
00203 {
00204  int           i, j;
00205  sMaxwellData *data = 0L;
00206  double        e, nu;
00207 
00208 /* Intialize matrix
00209  */
00210  for( i = 0; i < 6; i++ )
00211   for( j = 0; j < 6; j++ )
00212    cm[i][j] = 0.0;
00213 
00214 /* Get material descriptor
00215  */
00216  data = (sMaxwellData *)mat->data;
00217 
00218 /* Get element parameters
00219  */
00220  e  = data->E;
00221  nu = data->Nu;
00222 
00223 /* Compute matrix elements
00224  */
00225  if( NDof == 3 )
00226  {
00227   cm[0][0] =
00228   cm[1][1] =
00229   cm[2][2] =  e*(nu*nu-1.0) / (nu*(nu+nu*nu)+nu*(nu*nu+nu)+nu*nu-1.0);
00230   cm[1][0] =
00231   cm[2][0] =
00232   cm[0][1] =
00233   cm[2][1] =
00234   cm[0][2] =
00235   cm[1][2] = -e*(nu*nu+nu) / (nu*(nu+nu*nu)+nu*(nu*nu+nu)+nu*nu-1.0);
00236   cm[3][3] =
00237   cm[4][4] =
00238   cm[5][5] = (e * e) / (e + e * (1.0 + 2.0 * nu));
00239  }
00240  else
00241  {
00242   cm[0][0] = cm[1][1] = (e * (1.0 - nu)) / ((1.0 + nu) * (1.0 - (2.0 * nu)));
00243   cm[0][1] = cm[1][0] = (e * nu) / ((1.0 + nu) * (1.0 - (2.0 * nu)));
00244   cm[2][2] = e / (2.0 * (1.0 + nu));
00245  }
00246  
00247 } /* End of MaxwellCMatrix */
00248 
00249 /*
00250 %F
00251 */
00252 static void MaxwellViscoStrain( sMaterial *mat, double timeStep, sTensor *str,
00253                                 sTensor *stav )
00254 {
00255  double        sm, n;
00256  sMaxwellData *data = 0L;
00257 
00258 /* Get material data
00259  */
00260  data = (sMaxwellData *)mat->data;
00261 
00262 /* Get material viscos parameter
00263  */
00264  n = data->N;
00265  
00266 /* Compute mean stress
00267  */ 
00268  sm = (str->xx + str->yy + str->zz) / 3.0;
00269  
00270 /* Compute visco strain
00271  */
00272  stav->xx = 0.5 * n * (str->xx - sm) / timeStep;
00273  stav->yy = 0.5 * n * (str->yy - sm) / timeStep;
00274  stav->zz = 0.5 * n * (str->zz - sm) / timeStep;
00275  stav->xy = 0.5 * n * str->xy / timeStep;
00276  stav->xz = 0.5 * n * str->xz / timeStep;
00277  stav->yz = 0.5 * n * str->yz / timeStep;
00278  
00279 } /* End of MaxwellViscoStrain */
00280 
00283 static void MaxwellUpdateStress( sMaterial *mat, double dtime,
00284                                                  double *yield,
00285                                                  double *effdef,
00286                                                  double *str,
00287                                                  double *def )
00288 {
00289  sMaxwellData *data = 0L;
00290  double        n, ni;
00291  double        cm[6][6];
00292  double        C1, C2;
00293  sTensor       stre, stra, stred, strad, upstrd;
00294  sPTensor      pstr;
00295 
00296 /* Get material data
00297  */
00298  data = (sMaxwellData *)mat->data;
00299 
00300 /* Get material contitutive matrix
00301  */
00302  MaxwellCMatrix( mat, cm );
00303  
00304 /* Get material poisson coef.
00305  */
00306  MaxwellNuParameter( mat, &ni );
00307 
00308 /* Get material viscous property and elasticity property
00309  */ 
00310  n = data->N;
00311 
00312 /* Compute constants
00313  */
00314  C1 = 1.0 - ((cm[2][2] * dtime)/(2.0 * n));
00315  C2 = 1.0 / (1.0 + ((cm[2][2] * dtime)/(2.0 * n)));
00316 
00317 /* Compute the desviatory stress and strain
00318  */
00319  stre.xx = str[0];
00320  stre.yy = str[1];
00321  stre.xy = str[2];
00322  PrincipalTensor( &stre, &pstr );
00323 
00324  stred.xx = stre.xx - ((pstr.dir1 + pstr.dir3 + pstr.dir2)/3.0);
00325  stred.yy = stre.yy - ((pstr.dir1 + pstr.dir3 + pstr.dir2)/3.0);
00326 
00327  stra.xx = def[0];
00328  stra.yy = def[1];
00329  stra.xy = def[2];
00330  PrincipalTensor( &stra, &pstr );
00331 
00332  strad.xx = stra.xx - ((pstr.dir1 + pstr.dir3 + pstr.dir2)/3.0);
00333  strad.yy = stra.yy - ((pstr.dir1 + pstr.dir3 + pstr.dir2)/3.0);
00334 
00335 /* Compute updated desviatory stress
00336  */
00337  upstrd.xx = C2 * ((C1 * stred.xx) + (2.0 * cm[2][2] * strad.xx));
00338  upstrd.yy = C2 * ((C1 * stred.yy) + (2.0 * cm[2][2] * strad.yy));
00339 
00340 } /* End of MaxwellUpdateStress */
00341 
00342 
00343 /*
00344 ** ------------------------------------------------------------------------
00345 ** Public functions:
00346 */
00347 
00348 /*
00349 %F This function initializes the sub-class "MAXWELL".
00350 */
00351 void MaxwellInit( void );
00352 void MaxwellInit( void )
00353 {
00354 /* Initialize MAXWELL material sub-class
00355  */
00356  MatClass[MAXWELL].new       = MaxwellNew;
00357  MatClass[MAXWELL].free      = MaxwellFree;
00358  MatClass[MAXWELL].read      = MaxwellRead;
00359  MatClass[MAXWELL].epar      = MaxwellEParameter;
00360  MatClass[MAXWELL].nupar     = MaxwellNuParameter;
00361  MatClass[MAXWELL].cmatrix   = MaxwellCMatrix;
00362  MatClass[MAXWELL].updatestr = 0L;
00363  MatClass[MAXWELL].updatepar = 0L;
00364  MatClass[MAXWELL].timestep  = MaterialTimeStep;
00365  MatClass[MAXWELL].density   = MaterialDensity;
00366  MatClass[MAXWELL].vstrain   = MaxwellViscoStrain;
00367 
00368 } /* End of MaxwellInit */
00369 
00370 
00371 /* =======================================================  End of File  */
00372 

Generated on Tue Oct 23 11:23:29 2007 for Relax by  doxygen 1.5.3