stdveflc.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 for the visco elastic materials (FLAC 
00004    implementation).
00005 %a Joao Luiz Elias Campos.
00006 %d September 16th, 2000.
00007 %r $Id: stdveflc.c,v 1.1 2004/06/22 05:29:59 joaoluiz Exp $
00008 %w (C) COPYRIGHT 1997-2000, 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 StandardVEFlacAnalysis, que passa a retornar  
00019 *    un valor int.         
00020 * 
00021 *  Modified: 23-Fev-2006    Juan Pablo Ibanez
00022 *    Modificada a funcao StandardVEFlacPrintResult, 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 
00045 
00046 /*
00047 ** ------------------------------------------------------------------------
00048 ** Local variables and symbols:
00049 */
00050 
00051 /*
00052 ** ------------------------------------------------------------------------
00053 ** Local functions:
00054 */
00055 static void StandardVEFlacNew        ( sDriver ** );
00056 static void StandardVEFlacFree       ( sDriver * );
00057 static int  StandardVEFlacAnalysis   (UI_State *);
00058 static int  StandardVEFlacPrintResult( int, double *, double * );
00059 
00060 
00061 /*
00062 %F
00063 */
00064 static void StandardVEFlacNew( sDriver **drv )
00065 {
00066 /* Get memory for the driver descriptor
00067  */
00068  (*drv) = (sDriver *)calloc(1, sizeof(sDriver));
00069 
00070 /* Fill up driver descriptor
00071  */
00072  (*drv)->type = STANDARD_VE_FLAC;
00073 
00074 } /* End of StandardVEFlacNew */
00075 
00076 
00077 /*
00078 %F
00079 */
00080 static void StandardVEFlacFree( sDriver *drv )
00081 {
00082 /* Reset driver data
00083  */
00084  drv->data = 0L;
00085 
00086 } /* End of StandardVEFlacFree */
00087 
00088 
00089 /*
00090 %F This function process the probleam analysis using a dynamic relax 
00091    algorithm.
00092 */
00093 static int StandardVEFlacAnalysis(UI_State *R)
00094 {
00095  int     i;
00096  double *FVector = 0L;
00097  double *UVector = 0L;
00098  double *VVector = 0L;
00099  double *MVector = 0L;
00100  
00101 /* Get memory for the vectors used during the analysis
00102  */
00103  FVector = (double *)calloc( NDof*NumNodes, sizeof(double) );
00104  UVector = (double *)calloc( NDof*NumNodes, sizeof(double) );
00105  VVector = (double *)calloc( NDof*NumNodes, sizeof(double) );
00106  MVector = (double *)calloc( NDof*NumNodes, sizeof(double) );
00107 
00108 /* Apply prescribed values
00109  */
00110  PrescribedValues( );
00111 
00112 /* Start graphic module
00113  */
00114  XGPBegin( );
00115 
00116 /* Print feedback message
00117  */
00118  printf( "\tSolve problem........................:\n" );
00119  fflush( stdout );
00120 
00121 /* Call the dynamic relaxation algorithm
00122  */
00123  if( !DRSolver(R, FVector, UVector, VVector, MVector, 0) ) return 0;
00124 
00125 /* Write results on a temporary file
00126  */
00127  if( !IoStartSave( ) ) return 0;
00128 
00129  fwrite( UVector, sizeof(double), NDof*NumNodes, ndlr );
00130  fflush( ndlr );
00131 
00132  for( i = 0; i < NumElements; i++ )
00133   ElmWriteStress( ElmList[i], elmr, UVector, VVector );
00134  fflush( elmr );
00135 
00136 /* Finish graphic module
00137  */
00138  XGPEnd( );
00139 
00140 /* Release memory
00141  */
00142  free( FVector );
00143  free( UVector );
00144  free( VVector );
00145  free( MVector );
00146 
00147  return 1;
00148 
00149 } /* End of StandardVEFlacAnalysis */
00150 
00151 
00152 /*
00153 %F
00154 */
00155 static int StandardVEFlacPrintResult( int iteration, double *U, double *V )
00156 {
00157  int i;
00158 
00159 /* Check to see if this step must be processed
00160  */
00161  if( !Config.print_step || ((iteration != 1) && (iteration%Config.print_step)) )
00162   return 0;
00163 
00164 /* Update number of result steps
00165  */
00166  Config.num_step++;
00167 
00168 /* Process output
00169  */
00170  IoStartSave( );
00171 
00172  fwrite( U, sizeof(double), NDof*NumNodes, ndlr );
00173  fflush( ndlr );
00174 
00175  for( i = 0; i < NumElements; i++ )
00176   ElmWriteStress( ElmList[i], elmr, U, V );
00177  fflush( elmr );
00178 
00179  return 1;
00180 } /* End of StandardVEFlacPrintResult */
00181 
00182 
00183 /*
00184 ** ------------------------------------------------------------------------
00185 ** Public functions:
00186 */
00187 
00188 /*
00189 %F This function initializes the sub-class STANDARD.
00190 */
00191 void StandardVEFlacInit( void );
00192 void StandardVEFlacInit( void )
00193 {
00194 /* Initialize STANDARD_VE_FLAC driver sub-class
00195  */
00196  DrvClass[STANDARD_VE_FLAC].new      = StandardVEFlacNew;
00197  DrvClass[STANDARD_VE_FLAC].free     = StandardVEFlacFree;
00198  DrvClass[STANDARD_VE_FLAC].analysis = StandardVEFlacAnalysis;
00199  DrvClass[STANDARD_VE_FLAC].printres = StandardVEFlacPrintResult;
00200 
00201 } /* End of StandardVEFlacInit */
00202 
00203 
00204 /* =======================================================  End of File  */
00205 

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