loadcase.c

Go to the documentation of this file.
00001 /*
00002 %M This modules contains the driver methods to solve a problem using the 
00003    dynamic relax algorithm with load steps.
00004 %a Joao Luiz Elias Campos.
00005 %d July 27th, 1999.
00006 %r $Id: loadstep.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 *  Modified: 28-Apr-2005    Alexandre A. Del Savio
00014 *    Foram substituídas todas as alocações dinâmicas feitas com malloc 
00015 *    por calloc.
00016 *
00017 *  Modified: 23-Fev-2006    Juan Pablo Ibañez
00018 *    Modificada a funcão LoadStepAnalysis, que passa a retornar un valor int.
00019 *
00020 * Modificação: Modulo passa a se chamar loadcase
00021 *              pois será criado o módulo loadstep
00022 */
00023 
00024 /*
00025 ** ------------------------------------------------------------------------
00026 ** Global variables and symbols:
00027 */
00028 #include <stdio.h>
00029 #include <stdlib.h>
00030 #include <string.h>
00031 
00032 #include "drv.h"
00033 #include "fem.h"
00034 #include "load.h"
00035 #include "elm.h"
00036 #include "node.h"
00037 #include "alg.h"
00038 #include "rio.h"
00039 #include "nfi.h"
00040 #include "load.h"
00041 #include "xgplib.h"
00042 
00043 
00044 /*
00045 ** ------------------------------------------------------------------------
00046 ** Local variables and symbols:
00047 */
00048 
00049 /*
00050 ** ------------------------------------------------------------------------
00051 ** Local functions:
00052 */
00053 static void LoadCaseNew        ( sDriver ** );
00054 static void LoadCaseFree       ( sDriver * );
00055 static int  LoadCaseAnalysis   ( UI_State * );
00056 static int  LoadCasePrintResult( int, double *, double * );
00057 
00058 
00059 /*
00060 %F
00061 */
00062 static void LoadCaseNew( sDriver **drv )
00063 {
00064 /* Get memory for the driver descriptor
00065  */
00066  (*drv) = (sDriver *)calloc(1, sizeof(sDriver));
00067 
00068 /* Fill up driver descriptor
00069  */
00070  (*drv)->type = LOAD_CASE;
00071 
00072 } /* End of LoadCaseNew */
00073 
00074 
00075 /*
00076 %F
00077 */
00078 static void LoadCaseFree( sDriver *drv )
00079 {
00080 /* Reset driver data
00081  */
00082  drv->data = 0L;
00083 
00084 } /* End of LoadCaseFree */
00085 
00086 
00087 /*
00088 %F This function process the probleam analysis using a solver
00089 */
00090 static int LoadCaseAnalysis(UI_State *R)
00091 {
00092  int     i, lstep = 0;
00093  double *FVector = 0L;
00094  double *UVector = 0L;
00095  double *VVector = 0L;
00096  double *MVector = 0L;
00097  sTensor stress[8];
00098  sTensor strain[8];
00099  
00100 /* Get memory for the vectors used during the analysis
00101  */
00102  FVector = (double *)calloc( NDof*NumNodes, sizeof(double) );
00103  UVector = (double *)calloc( NDof*NumNodes, sizeof(double) );
00104  VVector = (double *)calloc( NDof*NumNodes, sizeof(double) );
00105  MVector = (double *)calloc( NDof*NumNodes, sizeof(double) );
00106 
00107 /* Start graphic module
00108  */
00109  XGPBegin( );
00110 
00111 /* Solve the problem
00112  */
00113  while( lstep < NumLoadCase )
00114  {
00115  /* Print feedback message
00116   */
00117   printf( "\tProcess load case..................: %d\n", lstep+1 );
00118   fflush( stdout );
00119 
00120  /* Set current load step
00121   */
00122   CurrLoadCase = lstep;
00123 
00124  /* Process load step
00125   */
00126   PrescribedValues( );
00127 
00128  /* Call the solver algorithm for each load step step
00129   */
00130   if(Config.algtype == 0)
00131    if( !DRSolver(R, FVector, UVector, VVector, MVector, 0 ) ) return 0;
00132   else if(Config.algtype == 1)
00133    if( !IMPLINEARSolver(R, FVector, UVector, VVector, MVector, 0 ) ) return 0;
00134   else if(Config.algtype == 2)
00135    if( !IMPNRMSolver(R, FVector, UVector, VVector, MVector, 0 ) ) return 0;
00136   else if(Config.algtype == 3)
00137    if( !IMPBFGSSolver(R, FVector, UVector, VVector, MVector, 0 ) ) return 0;
00138   else if(Config.algtype == 4)
00139    if( !HYBRIDSolver(R, FVector, UVector, VVector, MVector, 0 ) ) return 0;
00140 
00141  /* Write results on a temporary file
00142   */
00143   if( !IoStartSave( ) ) return 0;
00144 
00145   fwrite( UVector, sizeof(double), NDof*NumNodes, ndlr );
00146   fflush( ndlr );
00147 
00148   for( i = 0; i < NumElements; i++ )
00149    ElmWriteStress( ElmList[i], elmr, UVector, VVector );
00150   fflush( elmr );
00151 
00152   for( i = 0; i < NumElements; i++ )
00153   {
00154    ElmStressStrain( ElmList[i], 0.0, UVector, 0L, stress, strain );
00155    ElmSetInitStress( ElmList[i], stress );
00156   }
00157   UVector = (double *)memset( (void *)UVector, 0, sizeof(double) );
00158   VVector = (double *)memset( (void *)VVector, 0, sizeof(double) );
00159 
00160  /* Increase the load case
00161   */
00162   lstep++;
00163  }
00164 
00165 /* Finish graphic module
00166  */
00167  XGPEnd( );
00168 
00169 /* Release memory
00170  */
00171  free( FVector );
00172  free( UVector );
00173  free( VVector );
00174  free( MVector );
00175 
00176  return 1;
00177 
00178 } /* End of LoadCaseAnalysis */
00179 
00180 
00181 /*
00182 %F
00183 */
00184 static int LoadCasePrintResult( int iteration, double *U, double *V )
00185 {
00186  return 1;
00187 } /* End of LoadCasePrintResult */
00188 
00189 
00190 /*
00191 ** ------------------------------------------------------------------------
00192 ** Public functions:
00193 */
00194 
00195 /*
00196 %F This function initializes the sub-class LOAD_CASE.
00197 */
00198 void LoadCaseInit( void );
00199 void LoadCaseInit( void )
00200 {
00201 /* Initialize LOAD_STEP driver sub-class
00202  */
00203  DrvClass[LOAD_CASE].new      = LoadCaseNew;
00204  DrvClass[LOAD_CASE].free     = LoadCaseFree;
00205  DrvClass[LOAD_CASE].analysis = LoadCaseAnalysis;
00206  DrvClass[LOAD_CASE].printres = LoadCasePrintResult;
00207 
00208 } /* End of LoadCaseInit */
00209 
00210 
00211 /* =======================================================  End of File  */
00212 

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