impNRM.c

Go to the documentation of this file.
00001 /*
00002 %M This modules contains the driver methods to solve a problem using the 
00003    NRM algorithm.
00004 *  André Luis Muller:  06/2007
00005 */
00006 
00007 /*
00008 ** ------------------------------------------------------------------------
00009 ** Global variables and symbols:
00010 */
00011 #include <stdio.h>
00012 #include <stdlib.h>
00013 #include <string.h>
00014 
00015 #include "drv.h"
00016 #include "fem.h"
00017 #include "load.h"
00018 #include "elm.h"
00019 #include "node.h"
00020 #include "alg.h"
00021 #include "rio.h"
00022 #include "nfi.h"
00023 #include "load.h"
00024 #include "xgplib.h"
00025 #include "rui.h"
00026 
00027 
00028 /*
00029 ** ------------------------------------------------------------------------
00030 ** Local variables and symbols:
00031 */
00032 
00033 /*
00034 ** ------------------------------------------------------------------------
00035 ** Local functions:
00036 */
00037 static void ImpNRMNew(sDriver **);
00038 static void ImpNRMFree(sDriver *);
00039 static int  ImpNRMAnalysis(UI_State *);
00040 static int  ImpNRMPrintResult(int, double *, double *);
00041 
00042 
00043 /*
00044 %F
00045 */
00046 static void ImpNRMNew( sDriver **drv )
00047 {
00048 /* Get memory for the driver descriptor
00049  */
00050  (*drv) = (sDriver *)calloc(1, sizeof(sDriver));
00051 
00052 /* Fill up driver descriptor
00053  */
00054  (*drv)->type = IMPNRM;
00055 
00056 } /* End of ImpNRMNew */
00057 
00058 
00059 /*
00060 %F
00061 */
00062 static void ImpNRMFree( sDriver *drv )
00063 {
00064 /* Reset driver data
00065  */
00066  drv->data = 0L;
00067 
00068 } /* End of ImpNRMFree */
00069 
00070 
00071 /*
00072 %F This function process the probleam analysis using a ImpNRM 
00073    algorithm.
00074 */
00075 static int ImpNRMAnalysis(UI_State *R)
00076 {
00077  int     i;
00078  double *FVector = 0L;
00079  double *UVector = 0L;
00080  double *VVector = 0L;
00081  double *MVector = 0L;
00082  
00083 /* Get memory for the vectors used during the analysis
00084  */
00085  FVector = (double *)calloc(NDof*NumNodes, sizeof(double));
00086  UVector = (double *)calloc(NDof*NumNodes, sizeof(double));
00087  VVector = (double *)calloc(NDof*NumNodes, sizeof(double));
00088  MVector = (double *)calloc(NDof*NumNodes, sizeof(double));
00089 
00090 /* Apply prescribed values
00091  */
00092  PrescribedValues();
00093 
00094 /* Start graphic module
00095  */
00096  XGPBegin();
00097 
00098 /* Print feedback message
00099  */
00100  printf("\tSolve problem........................:\n");
00101  fflush(stdout);
00102 
00103 /* Call the dynamic NRM algorithm
00104  */
00105  if( !IMPNRMSolver(R, FVector, UVector, VVector, MVector, 0) ) return 0;
00106 
00107 /* Write results on a temporary file
00108  */
00109  if( !IoStartSave() ) return 0;
00110 
00111  fwrite(UVector, sizeof(double), NDof*NumNodes, ndlr);
00112  fflush(ndlr);
00113 
00114  for( i = 0; i < NumElements; i++ )
00115   ElmWriteStress(ElmList[i], elmr, UVector, VVector);
00116  fflush(elmr);
00117 
00118 /* Finish graphic module
00119  */
00120  XGPEnd();
00121 
00122 /* Release memory
00123  */
00124  free(FVector);
00125  free(UVector);
00126  free(VVector);
00127  free(MVector);
00128 
00129  return 1;
00130 
00131 } /* End of ImpNRMAnalysis */
00132 
00133 
00134 /*
00135 %F
00136 */
00137 static int ImpNRMPrintResult( int iteration, double *U, double *V )
00138 {
00139  int i;
00140 
00141 /* Check to see if this step must be processed
00142  */
00143  if( !Config.print_step || ((iteration != 1) && (iteration%Config.print_step)) )
00144   return 1;
00145 
00146 /* Update number of result steps
00147  */
00148  Config.num_step++;
00149 
00150 /* Process output
00151  */
00152  if( !IoStartSave( ) ) return 0;
00153 
00154  fwrite( U, sizeof(double), NDof*NumNodes, ndlr );
00155  fflush( ndlr );
00156 
00157  for( i = 0; i < NumElements; i++ )
00158   ElmWriteStress( ElmList[i], elmr, U, V );
00159  fflush( elmr );
00160 
00161  return 1;
00162 
00163 } /* End of ImpNRMPrintResult */
00164 
00165 
00166 /*
00167 ** ------------------------------------------------------------------------
00168 ** Public functions:
00169 */
00170 
00171 /*
00172 %F This function initializes the sub-class IMPNRM.
00173 */
00174 void ImpNRMInit( void );
00175 void ImpNRMInit( void )
00176 {
00177 /* Initialize IMPNRM driver sub-class
00178  */
00179  DrvClass[IMPNRM].new      = ImpNRMNew;
00180  DrvClass[IMPNRM].free     = ImpNRMFree;
00181  DrvClass[IMPNRM].analysis = ImpNRMAnalysis;
00182  DrvClass[IMPNRM].printres = ImpNRMPrintResult;
00183 
00184 } /* End of ImpNRMInit */
00185 
00186 
00187 /* =======================================================  End of File  */
00188 

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