rezone.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 rezone steps.
00004 %a Joao Luiz Elias Campos.
00005 %d July 27th, 1999.
00006 %r $Id: rezone.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 RezoneAnalysis, que passa a retornar un valor int.   
00019 *   
00020 */
00021 
00022 /*
00023 ** ------------------------------------------------------------------------
00024 ** Global variables and symbols:
00025 */
00026 #include <stdio.h>
00027 #include <stdlib.h>
00028 #include <string.h>
00029 
00030 #include "drv.h"
00031 #include "fem.h"
00032 #include "load.h"
00033 #include "elm.h"
00034 #include "node.h"
00035 #include "alg.h"
00036 #include "rio.h"
00037 #include "nfi.h"
00038 #include "load.h"
00039 #include "xgplib.h"
00040 
00041 
00042 /*
00043 ** ------------------------------------------------------------------------
00044 ** Local variables and symbols:
00045 */
00046 
00047 /*
00048 ** ------------------------------------------------------------------------
00049 ** Local functions:
00050 */
00051 static void RezoneNew        ( sDriver ** );
00052 static void RezoneFree       ( sDriver * );
00053 static int  RezoneAnalysis   (UI_State *);
00054 static int  RezonePrintResult( int, double *, double * );
00055 
00056 
00057 /*
00058 %F
00059 */
00060 static void RezoneNew( sDriver **drv )
00061 {
00062 /* Get memory for the driver descriptor
00063  */
00064  (*drv) = (sDriver *)calloc(1, sizeof(sDriver));
00065 
00066 /* Fill up driver descriptor
00067  */
00068  (*drv)->type = REZONE;
00069 
00070 } /* End of RezoneNew */
00071 
00072 
00073 /*
00074 %F
00075 */
00076 static void RezoneFree( sDriver *drv )
00077 {
00078 /* Reset driver data
00079  */
00080  drv->data = 0L;
00081 
00082 } /* End of RezoneFree */
00083 
00084 
00085 /*
00086 %F This function process the probleam analysis using a dynamic relax 
00087    algorithm.
00088 */
00089 static int RezoneAnalysis(UI_State *R)
00090 {
00091  int     i, esc = 0;
00092  double *FVector = 0L;
00093  double *UVector = 0L;
00094  double *VVector = 0L;
00095  double *MVector = 0L;
00096  
00097 /* Get memory for the vectors used during the analysis
00098  */
00099  FVector = (double *)calloc( NDof*NumNodes, sizeof(double) );
00100  UVector = (double *)calloc( NDof*NumNodes, sizeof(double) );
00101  VVector = (double *)calloc( NDof*NumNodes, sizeof(double) );
00102  MVector = (double *)calloc( NDof*NumNodes, sizeof(double) );
00103 
00104 /* Apply prescribed values
00105  */
00106  PrescribedValues( );
00107 
00108 /* Start graphic module
00109  */
00110  XGPBegin( );
00111 
00112 /* Solve the problem
00113  */
00114  while( esc < (NumRezones + 1) )
00115  {
00116  /* Print feedback message
00117   */
00118   if( esc > 0 )
00119    printf( "\tProcess rezone step..................: %d\n", esc );
00120   else
00121    printf( "\tProcess first step without rezone....: %d\n", esc );
00122   fflush( stdout );
00123 
00124  /* Process rezoning
00125   */
00126   if( esc > 0 )
00127    DoRezone( esc, FVector );
00128 
00129  /* Call the dynamic relaxation algorithm for each rezone step
00130   */
00131   if( !DRSolver(R, FVector, UVector, VVector, MVector, 0) ) return 0;
00132 
00133  /* Write results on a temporary file
00134   */
00135   if( !IoStartSave( ) ) return 0;
00136 
00137   fwrite( UVector, sizeof(double), NDof*NumNodes, ndlr );
00138   fflush( ndlr );
00139 
00140   for( i = 0; i < NumElements; i++ )
00141    ElmWriteStress( ElmList[i], elmr, UVector, VVector );
00142   fflush( elmr );
00143 
00144  /* Increase the rezone step
00145   */
00146   esc++;
00147  }
00148 
00149 /* Finish graphic module
00150  */
00151  XGPEnd( );
00152 
00153 /* Release memory
00154  */
00155  free( FVector );
00156  free( UVector );
00157  free( VVector );
00158  free( MVector );
00159 
00160  return 1;
00161 
00162 } /* End of RezoneAnalysis */
00163 
00164 
00165 /*
00166 %F
00167 */
00168 static int RezonePrintResult( int iteration, double *U, double *V )
00169 {
00170  return 1;
00171 } /* End of RezonePrintResult */
00172 
00173 
00174 /*
00175 ** ------------------------------------------------------------------------
00176 ** Public functions:
00177 */
00178 
00179 /*
00180 %F This function initializes the sub-class REZONE.
00181 */
00182 void RezoneInit( void );
00183 void RezoneInit( void )
00184 {
00185 /* Initialize REZONE driver sub-class
00186  */
00187  DrvClass[REZONE].new      = RezoneNew;
00188  DrvClass[REZONE].free     = RezoneFree;
00189  DrvClass[REZONE].analysis = RezoneAnalysis;
00190  DrvClass[REZONE].printres = RezonePrintResult;
00191 
00192 } /* End of RezoneInit */
00193 
00194 
00195 /* =======================================================  End of File  */
00196 

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