intf.c

Go to the documentation of this file.
00001 /*
00002 %M This modules contains the INTERFACE element sub-class methods and 
00003    definitions
00004 %a Joao Luiz Elias Campos.
00005 %d September 2nd, 1998.
00006 %r $Id: intf.c,v 1.4 2004/06/24 18:32:35 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 *  Modified:  23-Fev-06  Juan Pablo Ibañez
00014 *    Modificada a funcão INTERFACEReadInitStress que passa a retornar 
00015 *    um valor int.
00016 *
00017 *  Modified:  07-06 André Luis Muller
00018 *    Modificação na função INTERFACEWriteGaussResults para possibilitar
00019 *    a escolha das respostas a serem escritas no arquivo de resultados.
00020 *  
00021 */
00022 
00023 /*
00024 ** ------------------------------------------------------------------------
00025 ** Global variables and symbols:
00026 */
00027 #include <stdio.h>
00028 #include <stdlib.h>
00029 #include <math.h>
00030 #include <string.h>
00031 
00032 #include "rio.h"
00033 #include "load.h"
00034 #include "elm.h"
00035 #include "node.h"
00036 #include "material.h"
00037 #include "alg.h"
00038 
00039 /*
00040 ** ------------------------------------------------------------------------
00041 ** Local variables and symbols:
00042 */
00043 
00044 /*
00045 %T INTERFACE element data definition
00046 */
00047 typedef struct _itfelm {
00048  int      matid;                /* Material identification          */
00049  int      tckid;                /* Element thickness identification */
00050  int      NumNodes;             /* Number of element nodes          */
00051  int      NumTensComp;          /* Number of tension components     */
00052  int      inc[4];               /* Element incidence                */
00053  double   istr[4];              /* Element initial stress           */
00054  double   effdef;               /* Effective deformation            */
00055  sTensor *iPress;               /* Element internal pressure        */
00056 } sItfData;
00057 
00058 
00059 /*
00060 ** ------------------------------------------------------------------------
00061 ** Local functions:
00062 */
00063 static void   _INTERFACEGetCoord       ( sElement *, sCoord [] );
00064 static double _INTERFACEArea           ( sCoord [] );
00065 static void   _INTERFACEBMatrix        ( sElement *, double [2][8] );
00066 static void   _INTERFACEGetDisplacement( sElement *, double *, double [] );
00067 
00068 
00069 /*
00070 %F
00071 */
00072 static void _INTERFACEBMatrix( sElement *elm, double bm[2][8] )
00073 {
00074  sCoord coord[2];
00075  double ct, st, l;
00076 
00077 /* Get element coordinate
00078  */
00079  _INTERFACEGetCoord( elm, coord );
00080 
00081 /* Compute element lenght
00082  */
00083  l = _INTERFACEArea( coord );
00084 
00085 /* Compute derivatives
00086  */
00087  ct = (coord[1].x - coord[0].x) / l;
00088  st = (coord[1].y - coord[0].y) / l;
00089 
00090 /* Mount B matrix
00091  */
00092  bm[0][0] = bm[0][2] = bm[1][1] = bm[1][3] = -ct / 2.0;
00093  bm[0][1] = bm[0][3] = bm[1][4] = bm[1][6] = -st / 2.0;
00094  bm[0][4] = bm[0][6] = bm[1][5] = bm[1][7] =  ct / 2.0;
00095  bm[0][5] = bm[0][7] = bm[1][0] = bm[1][2] =  st / 2.0;
00096 
00097 } /* End of _INTERFACEBMatrix */
00098 
00099 
00100 /*
00101 %F
00102 */
00103 static void _INTERFACEGetDisplacement( sElement *elm, double *U, double ue[4] )
00104 {
00105  sItfData *data = 0L;
00106  int       i;
00107 
00108 /* Get element descriptor
00109  */
00110  data = (sItfData *)elm->data;
00111 
00112 /* Fill element displacement vector
00113  */
00114  for( i = 0; i < data->NumNodes; i++ ) {
00115   ue[2*i]   = U[2*(data->inc[i]-1)];
00116   ue[2*i+1] = U[2*(data->inc[i]-1)+1];
00117  }
00118 
00119 } /* End of _INTERFACEGetDisplacement */
00120 
00121 
00122 /*
00123 %F This function gets the element coordinates.
00124 %i Element descriptor.
00125 %o Element coordinares.
00126 */
00127 static void _INTERFACEGetCoord( sElement *elm, sCoord coord[2] )
00128 {
00129  sItfData *data = 0L;
00130  int      i;
00131 
00132 /* Element element data
00133  */
00134  data = (sItfData *)elm->data;
00135 
00136 /* Get element coordinates
00137  */
00138  for( i = 0; i < 2; i++ ) {
00139   coord[i].x = elm->nodes[data->inc[i]-1].coord.x;
00140   coord[i].y = elm->nodes[data->inc[i]-1].coord.y;
00141   coord[i].z = 0.0;
00142  }
00143 
00144 } /* End of _INTERFACEGetCoord */
00145 
00146 
00147 /*
00148 %F This function computes the element area
00149 %i Element coordinates.
00150 %o Element area.
00151 */
00152 static double _INTERFACEArea( sCoord coord[2] )
00153 {
00154  double area = 0.0;
00155 
00156 /* Computes element area
00157  */
00158  area = sqrt((coord[1].x - coord[0].x) * (coord[1].x - coord[0].x) +
00159              (coord[1].y - coord[0].y) * (coord[1].y - coord[0].y));
00160 
00161  return( area );
00162 
00163 } /* End of _INTERFACEArea */
00164 
00165 
00166 /*
00167 ** ------------------------------------------------------------------------
00168 ** Subclass methods:
00169 */
00170 static void   INTERFACENew( int, int, int, int, sElement **, sElement **, sNode * );
00171 static void   INTERFACEFree                  ( sElement * );
00172 static void   INTERFACERead                  ( sElement * );
00173 static int    INTERFACEReadInitStress        ( sElement * );
00174 static void   INTERFACEMassMatrix            ( sElement *, double * );
00175 static double INTERFACERigidCoeff            ( sElement * );
00176 static void   INTERFACEConnect               ( sElement *, int * );
00177 static void   INTERFACENumNodes              ( sElement *, int * );
00178 static void   INTERFACEAssVector             ( sElement *, double *, double * );
00179 static void   INTERFACEStressStrain          ( sElement *, double, double *,
00180                                                double *, sTensor *, sTensor * );
00181 static void   INTERFACEInterForce            ( sElement *, sTensor *, 
00182                                                            double * );
00183 static void   INTERFACEWriteGaussResult      ( sElement *, FILE *, FILE * );
00184 static void   INTERFACEWriteGaussVectorResult( sElement *, int, FILE *, FILE * );
00185 static void   INTERFACEWriteNodalResult      ( sElement *, FILE *, FILE * );
00186 static void   INTERFACEWriteStress           ( sElement *, FILE *, double *, 
00187                                                                    double * );
00188 static void   INTERFACESetPressure           ( sElement *, double );
00189 static void   INTERFACESetInitStress         ( sElement *, sTensor * );
00190 
00191 
00192 /*
00193 %F This method allocates memory for a INTERFACE element and fills its data 
00194    with the specific data.
00195 %i Element label (number)
00196 %o Element descriptor.
00197 */
00198 static void INTERFACENew( int label, int matid, int intord, int tckid, 
00199                           sElement **elm, sElement **elist, sNode *nodes )
00200 {
00201  sItfData *data = 0L;
00202 
00203 /* Get memory for the element descriptor
00204  */
00205  (*elm) = (sElement *)calloc(1, sizeof(sElement));
00206 
00207 /* Get memory for the INTERFACE element data
00208  */
00209  data = (sItfData *)calloc(1, sizeof(sItfData));
00210 
00211 /* Fill INTERFACE element data
00212  */
00213  data->matid       = matid;
00214  data->tckid       = tckid;
00215  data->NumNodes    = 4;
00216  data->NumTensComp = 2;
00217  data->effdef      = 0.0;
00218  data->iPress      = 0L;
00219 
00220 /* Fill element descriptor
00221  */
00222  (*elm)->type    = INTERFACE;
00223  (*elm)->rezone  = NONE;
00224  (*elm)->display = DSP_NO;
00225  (*elm)->curve   = 0;
00226  (*elm)->label   = label;
00227  (*elm)->data    = (void *)data;
00228  (*elm)->nodes   = nodes;
00229 
00230 /* Add to the element list
00231  */
00232  elist[label-1] = (*elm);
00233 
00234 } /* End of INTERFACENew */
00235 
00236 
00237 /*
00238 %F This method frees the INTERFACE element data for a given element.
00239 %i Element descriptor.
00240 */
00241 static void INTERFACEFree( sElement *elm )
00242 {
00243  sItfData *data = 0L;
00244 
00245 /* Get INTERFACE element data
00246  */
00247  data = (sItfData *)elm->data;
00248 
00249 /* Release internal pressure
00250  */
00251  if( data->iPress != 0L )
00252   free( data->iPress );
00253 
00254 /* Release allocated memory
00255  */
00256  free( data );
00257 
00258 /* Reset element data
00259  */
00260  elm->data = 0L;
00261 
00262 } /* End of INTERFACEFree */
00263 
00264 
00265 /*
00266 %F This method reads the INTERFACE element information.
00267 %i Element descriptor.
00268 */
00269 static void INTERFACERead( sElement *elm )
00270 {
00271  sItfData *data = 0L;
00272  int      i1, i2, i3, i4;
00273 
00274 /* Get the element data
00275  */
00276  data = (sItfData *)elm->data;
00277 
00278 /* Read the element incidence
00279  */
00280  fscanf( nf, "%d %d %d %d %*d %*d", &i1, &i2, &i3, &i4 );
00281 
00282 /* Fill element information
00283  */
00284  data->inc[0] = i1;
00285  data->inc[1] = i2;
00286  data->inc[2] = i3;
00287  data->inc[3] = i4;
00288 
00289 } /* End of INTERFACERead */
00290 
00291 
00292 /*
00293 %F This method reads the INTERFACE initial stress
00294 */
00295 static int INTERFACEReadInitStress( sElement *elm )
00296 {
00297  int       numpg;
00298  double    sxx, syy, sxy;
00299  sItfData *data = 0L;
00300 
00301 /* Get element data
00302  */
00303  data = (sItfData *)elm->data;
00304 
00305 /* Read the number of integration points and check to see if is compatible
00306  * whith the element type.
00307  */
00308  fscanf( nf, "%d", &numpg );
00309  if( numpg != 1 ) {
00310   printf( "\n\nNumber of gauss points must be equal to one.\n\n" );
00311   return 0;
00312  }
00313 
00314 /* Read the initial stress information
00315  */
00316  fscanf( nf, "%lf %lf %lf", &sxx, &syy, &sxy );
00317  data->istr[0] = sxx;
00318  data->istr[1] = syy;
00319  data->istr[2] = sxy;
00320 
00321  return 1;
00322 
00323 } /* End of INTERFACEReadInitStress */
00324 
00325 
00326 /*
00327 %F This method computes the mass matrix for the INTERFACE element.
00328 %i Element descriptor.
00329 %o Element mass matrix.
00330 */
00331 static void INTERFACEMassMatrix( sElement *elm, double *mass )
00332 {
00333  int i;
00334 
00335 /* Compute the mass matrix
00336  */
00337  for( i = 0; i < 8; i++ )
00338   mass[i] = 0.0;
00339  
00340 } /* End of INTERFACEMassMatrix */
00341 
00342 
00343 /*
00344 %F This functions computes the element rigidity coefficient.
00345 %i Element descriptor.
00346 %o Element rigidity coefficient.
00347 */
00348 static double INTERFACERigidCoeff( sElement *elm )
00349 {
00350  sCoord coord[2];
00351  double area = 0.0;
00352 
00353 /* Get element coordinates
00354  */
00355  _INTERFACEGetCoord( elm, coord );
00356 
00357 /* Compute element area
00358  */
00359  area = _INTERFACEArea( coord );
00360 
00361  return( area );
00362 
00363 } /* End of INTERFACERigidCoeff */
00364 
00365 
00366 /*
00367 %F
00368 */
00369 static void INTERFACEConnect( sElement *elm, int *conn )
00370 {
00371  int       i;
00372  sItfData *data = 0L;
00373 
00374  data = (sItfData *)elm->data;
00375 
00376  for( i = 0; i < data->NumNodes; i++ )
00377   conn[i] = data->inc[i];
00378 
00379 } /* End of INTERFACEConnect */
00380 
00381 
00382 /*
00383 %F
00384 */
00385 static void INTERFACENumNodes( sElement *elm, int *nnodes )
00386 {
00387  sItfData *data = (sItfData *)elm->data;
00388 
00389  (*nnodes) = data->NumNodes;
00390 
00391 } /* End of INTERFACENumNodes */
00392 
00393 
00394 /*
00395 %F
00396 */
00397 static void INTERFACEAssVector( sElement *elm, double *Gvec, double *vec )
00398 {
00399  int       i;
00400  int       conn[4];
00401  sItfData *data;
00402 
00403 /* Get the element data
00404  */
00405  data = (sItfData *)elm->data;
00406 
00407 /* Get element connectivity
00408  */
00409  ElmConnect( elm, conn );
00410 
00411 /* Assemble matrix
00412  */
00413  for( i = 0; i < data->NumNodes; i++ ) {
00414   Gvec[2*(conn[i]-1)]   += vec[2*i];
00415   Gvec[2*(conn[i]-1)+1] += vec[2*i+1];
00416  }
00417 
00418 } /* End of INTERFACEAssVector */
00419 
00420 
00421 /*
00422 %F
00423 */
00424 static void INTERFACEStressStrain( sElement *elm, double dt, double *U,
00425                                                   double *yield, sTensor *stre,
00426                                                   sTensor *stra )
00427 {
00428  sItfData  *data = 0L;
00429  sMaterial *mat  = 0L;
00430  double     cm[6][6];
00431  double     bm[2][8];
00432  double     ue[8];
00433  double     defe[2], str[3];
00434  double     pf = 1.0;
00435  int        i, j;
00436 
00437 /* Get element descriptor
00438  */
00439  data = (sItfData *)elm->data;
00440 
00441 /* Get Material object
00442  */
00443  if( data->matid-1 >= 0 ){
00444   mat = MatList[data->matid-1];
00445 
00446  /* Update the material parameter
00447   */
00448   MatUpdateParameter( mat, data->effdef );
00449  
00450  /* Get material constitutive matrix
00451   */
00452   MatConstitutiveMatrix( mat, cm );
00453  
00454  /* Get element stress x strain matrix
00455   */
00456   _INTERFACEBMatrix( elm, bm );
00457  
00458  /* Get element displacement
00459   */
00460   _INTERFACEGetDisplacement( elm, U, ue );
00461  
00462  /* Compute the deformations
00463   */
00464   for( i = 0; i < 2; i++ ) {
00465    defe[i] = 0.0;
00466    for( j = 0; j < (2*data->NumNodes); j++ )
00467     defe[i] += bm[i][j] * ue[j];
00468   }
00469 
00470  /* Compute the element stress
00471   */
00472   for( i = 0; i < 2; i++ ) {
00473    str[i] = 0.0;
00474    for( j = 0; j < 2; j++ )
00475     str[i] += cm[i][j] * defe[j];
00476   }
00477   str[2] = 0.0;
00478 
00479  /* Correct stress based on the material model
00480   */
00481   MatUpdateStress( mat, dt, &pf, &data->effdef, str, defe );
00482 
00483  /* Set stress values 
00484   */
00485   stre->xx = str[0];
00486   stre->yy = str[1];
00487  
00488  /* Set stress values 
00489   */
00490   if( stra != 0L ) {
00491    stra->xx = defe[0];
00492    stra->yy = defe[1];
00493   }
00494  }
00495  else {
00496   pf = 0.0;
00497  /* Set yield parameter
00498  */
00499   if( yield != 0L )
00500    (*yield) = (pf > 0.0) ? 0.0 : 1.0;
00501 
00502   stre->xx = stre->yy = stre->xy = 0.0;
00503   stra->xx = stra->yy = stra->xy = 0.0;
00504  }
00505  
00506 } /* End of INTERFACEStressStrain */
00507 
00508 
00509 /*
00510 %F This function computes the internal forces for the INTERFACE element
00511 */
00512 static void INTERFACEInterForce( sElement *elm, sTensor *stress, 
00513                                                  double *intforce )
00514 {
00515  int       i, j;
00516  double    coeff = 0.0;
00517  double    bm[2][8];
00518  double    str[2];
00519  sItfData *data = 0L;
00520 
00521 /* Get element descriptor
00522  */
00523  data = (sItfData *)elm->data;
00524 
00525 /* Compute element rigidity coefficient
00526  */
00527  coeff = ElmRigidCoeff( elm );
00528 
00529 /* Compute element B matrix
00530  */
00531  _INTERFACEBMatrix( elm, bm );
00532 
00533 /* Check for the initial stress
00534  */
00535  if( stress == 0L ) {
00536   for( i = 0; i < (2*data->NumNodes); i++ )
00537    intforce[i] = 0.0;
00538   return;
00539  }
00540 
00541 /* Get element stresses
00542  */
00543  str[0] = stress->xx;
00544  str[1] = stress->yy;
00545 
00546 /* Compute element internal forces
00547  */
00548  for( i = 0; i < (2*data->NumNodes); i++ ) {
00549   intforce[i] = 0.0;
00550   for( j = 0; j < 2; j++ )
00551    intforce[i] += bm[j][i] * str[j];
00552   intforce[i] *= coeff;
00553  }
00554  for( i = 0; i < (2*data->NumNodes); i++ )
00555   intforce[i] *= -1.0;
00556 
00557 /* Compute element internal pressure
00558  */
00559  if( data->iPress != 0L ) {
00560   for( i = 0; i < (2*data->NumNodes); i++ ) {
00561    intforce[i] += coeff * bm[0][i] * data->iPress->xx;
00562    intforce[i] += coeff * bm[1][i] * data->iPress->yy;
00563   }
00564  }
00565 
00566 } /* End of INTERFACEInterForce */
00567 
00568 
00569 /*
00570 %F
00571 */
00572 static void INTERFACEWriteStress( sElement *elm, FILE *out, double *U, 
00573                                                             double *V )
00574 {
00575  sTensor stress;
00576  sTensor strain;
00577  sTensor strd;
00578  double  yield;
00579 
00580 /* Check to see if the element was rezoned
00581  */
00582  if( elm->rezone == DONE ) {
00583   stress.xx = stress.xy = stress.xz =
00584               stress.yy = stress.yz =
00585                           stress.zz = 0.0;
00586   strd.xx = strd.xy = strd.xz =
00587             strd.yy = strd.yz =
00588                       strd.zz = 0.0;
00589   strain.xx = strain.xy = strain.xz =
00590               strain.yy = strain.yz =
00591                           strain.zz = 0.0;
00592   yield = 0.0;
00593  }
00594  else {
00595  /* Compute the element stress and strain
00596   */
00597   INTERFACEStressStrain( elm, 0.0, U, &yield, &stress, &strain );
00598  }
00599 
00600 /* Write element stress and strain
00601  */
00602  fwrite( &stress, sizeof(sTensor), 1, out );
00603  fwrite( &strain, sizeof(sTensor), 1, out );
00604  fwrite( &strd, sizeof(sTensor), 1, out );
00605  fwrite( &yield, sizeof(double), 1, out );
00606 
00607 } /* End of INTERFACEWriteStress */
00608 
00609 
00610 /*
00611 %F
00612 */
00613 static void INTERFACEWriteNodalResult( sElement *elm, FILE *out, FILE *tmp )
00614 {
00615  sTensor stress;
00616  sTensor strain;
00617  sTensor strd;
00618  double  yield;
00619  int     i;
00620 
00621 /* Read results from temporary file
00622  */
00623  fread( &stress, sizeof(sTensor), 1, tmp );
00624  fread( &strain, sizeof(sTensor), 1, tmp );
00625  fread( &strd, sizeof(sTensor), 1, tmp );
00626  fread( &yield, sizeof(double), 1, tmp );
00627 
00628 /* Write results on output file
00629  */
00630  fprintf( out, "%d\n", elm->label );
00631  for( i = 0; i < 6; i++ ) {
00632   fprintf( out, "%+10.5e\t%+10.5e\t%+10.5e\t%+10.5e\t", stress.xx,
00633                                                         stress.yy,
00634                                                         stress.zz,
00635                                                         0.0 );
00636   fprintf( out, "%+10.5e\t%+10.5e\t%+10.5e\t", 0.0,
00637                                                0.0,
00638                                                0.0 );
00639   fprintf( out, "%+10.5e\t%+10.5e\t%+10.5e\t", 0.0,
00640                                                0.0,
00641                                                0.0 );
00642   fprintf( out, "%+10.5e\t%+10.5e\t%+10.5e\t", 0.0,
00643                                                0.0,
00644                                                0.0 );
00645   fprintf( out, "%+10.5e\t%+10.5e\t%+10.5e\t", 0.0,
00646                                                0.0,
00647                                                0.0 );
00648   fprintf( out, "%+10.5e\n", yield );
00649  }
00650 
00651 } /* End of INTERFACEWriteNodalResult */
00652 
00653 
00654 /*
00655 %F
00656 */
00657 static void INTERFACEWriteGaussResult( sElement *elm, FILE *out, FILE *tmp )
00658 {
00659  sTensor stress;
00660  sTensor strain;
00661  sTensor strd;
00662  double  yield;
00663  int     j;
00664 
00665 /* Read results from temporary file
00666  */
00667  fread( &stress, sizeof(sTensor), 1, tmp );
00668  fread( &strain, sizeof(sTensor), 1, tmp );
00669  fread( &strd, sizeof(sTensor), 1, tmp );
00670  fread( &yield, sizeof(double), 1, tmp );
00671 
00672 /* Write results on output file
00673  */
00674  fprintf( out, "%d\t%d\n", elm->label, 1 );
00675  
00676  for( j = 0; j < Config.numgaussresults; j++){
00677    if((strcmp( Config.gaussresults[j], "Yield" ) == 0))
00678     fprintf( out, "%+10.5e\t", yield );
00679    else if((strcmp( Config.gaussresults[j], "Rf" ) == 0))
00680     fprintf( out, "%+10.5e\t", 0.0 );
00681    else if((strcmp( Config.gaussresults[j], "Sxx" ) == 0))
00682     fprintf( out, "%+10.5e\t", stress.xx );
00683    else if((strcmp( Config.gaussresults[j], "Syy" ) == 0))
00684     fprintf( out, "%+10.5e\t", stress.yy );
00685    else if((strcmp( Config.gaussresults[j], "Sxy" ) == 0))
00686     fprintf( out, "%+10.5e\t", stress.xy );
00687    else if((strcmp( Config.gaussresults[j], "Pf" ) == 0))
00688     fprintf( out, "%+10.5e\t", 0.0 );
00689    else if((strcmp( Config.gaussresults[j], "SExx" ) == 0))
00690     fprintf( out, "%+10.5e\t", 0.0 );
00691    else if((strcmp( Config.gaussresults[j], "SEyy" ) == 0))
00692     fprintf( out, "%+10.5e\t", 0.0 );
00693    else if((strcmp( Config.gaussresults[j], "Siso" ) == 0))
00694     fprintf( out, "%+10.5e\t", 0.0 );
00695    else if((strcmp( Config.gaussresults[j], "SDxx" ) == 0))
00696     fprintf( out, "%+10.5e\t", 0.0 );
00697    else if((strcmp( Config.gaussresults[j], "SDyy" ) == 0))
00698     fprintf( out, "%+10.5e\t", 0.0 );
00699    else if((strcmp( Config.gaussresults[j], "S1" ) == 0))
00700     fprintf( out, "%+10.5e\t", 0.0 );
00701    else if((strcmp( Config.gaussresults[j], "S3" ) == 0))
00702     fprintf( out, "%+10.5e\t", 0.0 );
00703    else if((strcmp( Config.gaussresults[j], "SE1" ) == 0))
00704     fprintf( out, "%+10.5e\t", 0.0 );
00705    else if((strcmp( Config.gaussresults[j], "SE3" ) == 0))
00706     fprintf( out, "%+10.5e\t", 0.0 );
00707    else if((strcmp( Config.gaussresults[j], "SD1" ) == 0))
00708     fprintf( out, "%+10.5e\t", 0.0 );
00709    else if((strcmp( Config.gaussresults[j], "SD3" ) == 0))
00710     fprintf( out, "%+10.5e\t", 0.0 );
00711    else if((strcmp( Config.gaussresults[j], "Exx" ) == 0))
00712     fprintf( out, "%+10.5e\t", 0.0 );
00713    else if((strcmp( Config.gaussresults[j], "Eyy" ) == 0))
00714     fprintf( out, "%+10.5e\t", 0.0 );
00715    else if((strcmp( Config.gaussresults[j], "Exy" ) == 0))
00716     fprintf( out, "%+10.5e\t", 0.0 );
00717    else if((strcmp( Config.gaussresults[j], "E1" ) == 0))
00718     fprintf( out, "%+10.5e\t", 0.0 );
00719    else if((strcmp( Config.gaussresults[j], "E3" ) == 0))
00720     fprintf( out, "%+10.5e\t", 0.0 );
00721    else if((strcmp( Config.gaussresults[j], "Ev" ) == 0))
00722     fprintf( out, "%+10.5e\t", 0.0 );
00723    else if((strcmp( Config.gaussresults[j], "K0" ) == 0))
00724     fprintf( out, "%+10.5e\t", 0.0 );
00725  }                                                    
00726 
00727 } /* End of INTERFACEWriteGaussResult */
00728 
00729 
00730 /*
00731 %F
00732 */
00733 static void INTERFACEWriteGaussVectorResult( sElement *elm, int version,
00734                                              FILE *out, FILE *tmp )
00735 {
00736  sTensor stress;
00737  sTensor strain;
00738  double  yield;
00739 
00740 /* Read results from temporary file
00741  */
00742  fread( &stress, sizeof(sTensor), 1, tmp );
00743  fread( &strain, sizeof(sTensor), 1, tmp );
00744  fread( &yield, sizeof(double), 1, tmp );
00745 
00746 /* Write results on output file
00747  */
00748  fprintf( out, "%d\t%d\n", elm->label, 1 );
00749 
00750  if( version > 1 ) {
00751   fprintf( out, "%e\t%e\n", 0.0, 0.0 );
00752   fprintf( out, "%e\t%e\n", 0.0, 0.0 );
00753   fprintf( out, "%e\t%e\n", 0.0, 0.0 );
00754   fprintf( out, "%e\t%e\n", 0.0, 0.0 );
00755   fprintf( out, "%e\t%e\n", 0.0, 0.0 );
00756   fprintf( out, "%e\t%e\n", 0.0, 0.0 );
00757   fprintf( out, "%e\t%e\n", 0.0, 0.0 );
00758   fprintf( out, "%e\t%e\n", 0.0, 0.0 );
00759   fprintf( out, "%e\t%e\n", 0.0, 0.0 );
00760   fprintf( out, "%e\t%e\n", 0.0, 0.0 );
00761   fprintf( out, "%e\t%e\n", 0.0, 0.0 );
00762   fprintf( out, "%e\t%e\n", 0.0, 0.0 );
00763  }
00764  else {
00765   fprintf( out, "%e\t%e\t%e\t", 0.0, 0.0, 0.0 );
00766   fprintf( out, "%e\t%e\t%e\t", 0.0, 0.0, 0.0 );
00767   fprintf( out, "%e\t%e\t%e\t", 0.0, 0.0, 0.0 );
00768   fprintf( out, "%e\t%e\t%e\n", 0.0, 0.0, 0.0 );
00769  }
00770 
00771 } /* End of INTERFACEWriteGaussVectorResult */
00772 
00773 
00774 /*
00775 %F
00776 */
00777 static void INTERFACESetPressure( sElement *elm, double pot )
00778 {
00779  sCoord    coord[2];
00780  sItfData *data = 0L;
00781  double    elev;
00782 
00783 /* Get element coordinates
00784  */
00785  _INTERFACEGetCoord( elm, coord );
00786 
00787 /* Compute element CG elevation
00788  */
00789  elev = 0.5 * (coord[0].y + coord[1].y);
00790 
00791 /* Get element data
00792  */
00793  data = (sItfData *)elm->data;
00794 
00795 /* Compute and set the pressure for the element CG
00796  */
00797  data->iPress = (sTensor *)calloc(1, sizeof(sTensor));
00798  ElementInitTensor( data->iPress );
00799  data->iPress->xx =
00800  data->iPress->yy = pot - elev;
00801 
00802 } /* End of INTERFACESetPressure */
00803 
00804 /*
00805 %F
00806 */
00807 static void INTERFACESetInitStress( sElement *elm, sTensor *istress )
00808 {
00809  sItfData *data = 0L;
00810 
00811 /* Get element data
00812  */
00813  data = (sItfData *)elm->data;
00814 
00815 /* Set initial stress
00816  */
00817  data->istr[0] = istress->xx;
00818  data->istr[1] = istress->yy;
00819  data->istr[2] = istress->xy;
00820 
00821 } /* End of INTERFACESetInitStress */
00822 
00823 /*
00824 %F
00825 */
00826 static void INTERFACEViscoForce( sElement *elm, double timeStep,
00827                                  sTensor *stress, double *vforce )
00828 {
00829  sItfData  *data = 0L;
00830  sMaterial *mat  = 0L;
00831  double     cm[6][6];
00832  double     bm[2][8];
00833  double     stav[2], strv[3];
00834  double     coeff;
00835  sTensor    vsta;
00836  int        i, j;
00837 
00838 /* Get element descriptor
00839  */
00840  data = (sItfData *)elm->data;
00841 
00842 /* Get Material object
00843  */
00844  mat = MatList[data->matid-1];
00845 
00846 /* Initialize element visco forces vector
00847  */
00848  for( i = 0; i < (2*data->NumNodes); i++ )
00849   vforce[i] = 0.0;
00850 
00851 /* Check to see if the material is a visco one
00852  */
00853  if( !MaterialIsVisco( mat ) )
00854   return;
00855 
00856 /* Compute element rigidity coefficient
00857  */
00858  coeff = ElmRigidCoeff( elm );
00859 
00860 /* Get material constitutive matrix
00861  */
00862  MatConstitutiveMatrix( mat, cm );
00863 
00864 /* Get element stress x strain matrix
00865  */
00866  _INTERFACEBMatrix( elm, bm );
00867 
00868 /* Compute visco stress
00869  */
00870  MatViscoStrain( mat, timeStep, stress, &vsta );
00871 
00872 /* Get viscos strain components
00873  */
00874  stav[0] = vsta.xx;
00875  stav[1] = vsta.yy;
00876 
00877 /* Compute viscos stress
00878  */
00879  for( i = 0; i < 2; i++ ) {
00880   strv[i] = 0.0;
00881   for( j = 0; j < 2; j++ )
00882    strv[i] += cm[i][j] * stav[j];
00883  }
00884  strv[3] = 0.0;
00885 
00886 /* Compute element visco forces
00887  */
00888  for( i = 0; i < (2*data->NumNodes); i++ ) {
00889   vforce[i] = 0.0;
00890   for( j = 0; j < 2; j++ )
00891    vforce[i] += bm[j][i] * strv[j];
00892   vforce[i] *= coeff;
00893  }
00894 
00895 } /* End of INTERFACEViscoForce */
00896 
00897 /*
00898 ** ------------------------------------------------------------------------
00899 ** Public functions:
00900 */
00901 
00902 /*
00903 %F This function initializes the sub-class "INTERFACE".
00904 */
00905 void INTERFACEInit( void );
00906 void INTERFACEInit( void )
00907 {
00908 /* Initialize INTERFACE element sub-class
00909  */
00910  ElmClass[INTERFACE].new               = INTERFACENew;
00911  ElmClass[INTERFACE].free              = INTERFACEFree;
00912  ElmClass[INTERFACE].read              = INTERFACERead;
00913  ElmClass[INTERFACE].readinitstr       = INTERFACEReadInitStress;
00914  ElmClass[INTERFACE].mass              = INTERFACEMassMatrix;
00915  ElmClass[INTERFACE].rigidcoeff        = INTERFACERigidCoeff;
00916  ElmClass[INTERFACE].load              = 0L;
00917  ElmClass[INTERFACE].connect           = INTERFACEConnect;
00918  ElmClass[INTERFACE].numnodes          = INTERFACENumNodes;
00919  ElmClass[INTERFACE].gravity           = 0L;
00920  ElmClass[INTERFACE].assvector         = INTERFACEAssVector;
00921  ElmClass[INTERFACE].strstrain         = INTERFACEStressStrain;
00922  ElmClass[INTERFACE].timestep          = 0L;
00923  ElmClass[INTERFACE].intforce          = INTERFACEInterForce;
00924  ElmClass[INTERFACE].writestr          = INTERFACEWriteStress;
00925  ElmClass[INTERFACE].writendlresult    = INTERFACEWriteNodalResult;
00926  ElmClass[INTERFACE].writegauresult    = INTERFACEWriteGaussResult;
00927  ElmClass[INTERFACE].writegauvecresult = INTERFACEWriteGaussVectorResult;
00928  ElmClass[INTERFACE].updatestress      = 0L;
00929  ElmClass[INTERFACE].percforce         = 0L;
00930  ElmClass[INTERFACE].setpressure       = INTERFACESetPressure;
00931  ElmClass[INTERFACE].setinitstress     = INTERFACESetInitStress;
00932  ElmClass[INTERFACE].viscoforce        = INTERFACEViscoForce;
00933  ElmClass[INTERFACE].jacobian          = 0L;
00934  ElmClass[INTERFACE].volume            = 0L;
00935  ElmClass[INTERFACE].KMatrix           = 0L;
00936  ElmClass[INTERFACE].GetDof            = 0L;
00937 
00938 } /* End of INTERFACEInit */
00939 
00940 
00941 /* =======================================================  End of File  */
00942 

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