loadstep.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 
00021 /*
00022 ** ------------------------------------------------------------------------
00023 ** Global variables and symbols:
00024 */
00025 #include <stdio.h>
00026 #include <stdlib.h>
00027 #include <string.h>
00028 
00029 #include "drv.h"
00030 #include "fem.h"
00031 #include "load.h"
00032 #include "elm.h"
00033 #include "node.h"
00034 #include "alg.h"
00035 #include "rio.h"
00036 #include "nfi.h"
00037 #include "load.h"
00038 #include "xgplib.h"
00039 
00040 
00041 /*
00042 ** ------------------------------------------------------------------------
00043 ** Local variables and symbols:
00044 */
00045 
00046 /*
00047 ** ------------------------------------------------------------------------
00048 ** Local functions:
00049 */
00050 static void LoadStepNew        ( sDriver ** );
00051 static void LoadStepFree       ( sDriver * );
00052 static int  LoadStepAnalysis   ( UI_State * );
00053 static int  LoadStepPrintResult( int, double *, double * );
00054 
00055 
00056 /*
00057 %F
00058 */
00059 static void LoadStepNew( sDriver **drv )
00060 {
00061 /* Get memory for the driver descriptor
00062  */
00063  (*drv) = (sDriver *)calloc(1, sizeof(sDriver));
00064 
00065 /* Fill up driver descriptor
00066  */
00067  (*drv)->type = LOAD_STEP;
00068 
00069 } /* End of LoadStepNew */
00070 
00071 
00072 /*
00073 %F
00074 */
00075 static void LoadStepFree( sDriver *drv )
00076 {
00077 /* Reset driver data
00078  */
00079  drv->data = 0L;
00080 
00081 } /* End of LoadStepFree */
00082 
00083 
00084 /*
00085 %F This function process the probleam analysis using a dynamic relax 
00086    algorithm.
00087 */
00088 static int LoadStepAnalysis(UI_State *R)
00089 {
00090  int     i, lstep = 0;
00091  double *FVector = 0L;
00092  double *UVector = 0L;
00093  double *VVector = 0L;
00094  double *MVector = 0L;
00095  
00096 /* Get memory for the vectors used during the analysis
00097  */
00098  FVector = (double *)calloc( NDof*NumNodes, sizeof(double) );
00099  UVector = (double *)calloc( NDof*NumNodes, sizeof(double) );
00100  VVector = (double *)calloc( NDof*NumNodes, sizeof(double) );
00101  MVector = (double *)calloc( NDof*NumNodes, sizeof(double) );
00102 
00103 /* Start graphic module
00104  */
00105  XGPBegin( );
00106 
00107 /* Solve the problem
00108  */
00109  while( lstep < Config.num_load_step )
00110  {
00111  /* Print feedback message
00112   */
00113   printf( "\tProcess load step..................: %d\n", lstep+1 );
00114   fflush( stdout );
00115 
00116  /* Process load step
00117   */
00118   PrescribedValues( );
00119 
00120  /* Call the solver algorithm for each load step step
00121   */
00122 
00123   switch( Config.algtype )
00124   {
00125     case 0:
00126       if( !DRSolver(R, FVector, UVector, VVector, MVector, lstep ) ) return 0;
00127       break;
00128       
00129     case 1:
00130       if( !IMPLINEARSolver(R, FVector, UVector, VVector, MVector, lstep ) ) return 0;
00131       break;
00132       
00133     case 2:
00134       if( !IMPNRMSolver(R, FVector, UVector, VVector, MVector, lstep ) ) return 0;
00135       break;
00136       
00137     case 3:
00138       if( !IMPBFGSSolver(R, FVector, UVector, VVector, MVector, lstep ) ) return 0;
00139       break;
00140       
00141     case 4:
00142       if( !HYBRIDSolver(R, FVector, UVector, VVector, MVector, lstep ) ) return 0;
00143       break;
00144       
00145     default:
00146       return 0;
00147   }
00148    
00149  /* Write results on a temporary file
00150   */
00151   if( !IoStartSave( ) ) return 0;
00152 
00153   fwrite( UVector, sizeof(double), NDof*NumNodes, ndlr );
00154   fflush( ndlr );
00155 
00156   for( i = 0; i < NumElements; i++ )
00157    ElmWriteStress( ElmList[i], elmr, UVector, VVector );
00158   fflush( elmr );
00159 
00160  /* Increase the load step
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 LoadStepAnalysis */
00179 
00180 
00181 /*
00182 %F
00183 */
00184 static int LoadStepPrintResult( int iteration, double *U, double *V )
00185 {
00186  return 1;
00187 } /* End of LoadStepPrintResult */
00188 
00189 
00190 /*
00191 ** ------------------------------------------------------------------------
00192 ** Public functions:
00193 */
00194 
00195 /*
00196 %F This function initializes the sub-class LOAD_STEP.
00197 */
00198 void LoadStepInit( void );
00199 void LoadStepInit( void )
00200 {
00201 /* Initialize LOAD_STEP driver sub-class
00202  */
00203  DrvClass[LOAD_STEP].new      = LoadStepNew;
00204  DrvClass[LOAD_STEP].free     = LoadStepFree;
00205  DrvClass[LOAD_STEP].analysis = LoadStepAnalysis;
00206  DrvClass[LOAD_STEP].printres = LoadStepPrintResult;
00207 
00208 } /* End of LoadStepInit */
00209 
00210 
00211 /* =======================================================  End of File  */
00212 

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