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

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