00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054 #include <stdio.h>
00055 #include <stdlib.h>
00056 #include <string.h>
00057 #include <math.h>
00058 #include <time.h>
00059
00060 #include "load.h"
00061 #include "elm.h"
00062 #include "node.h"
00063 #include "fem.h"
00064 #include "alg.h"
00065 #include "nfi.h"
00066 #include "rio.h"
00067 #include "drv.h"
00068 #include "damp.h"
00069 #include "constrain.h"
00070 #include "csr.h"
00071
00072
00073
00074
00075
00076 #ifndef MAX
00077 #define MAX(a,b) (((a) > (b)) ? (a) : (b))
00078 #endif
00079
00080 #ifndef MIN
00081 #define MIN(a,b) (((a) < (b)) ? (a) : (b))
00082 #endif
00083
00084
00085
00086
00087 sConfig Config = { 0, 0, 0, 1, 0, 0, 0.0, 0, 0.0, 0.0, 0.0, 0 };
00088
00089
00090
00091
00092
00093 eCoupState State = UNCOUPLED;
00094
00095
00096
00097
00098
00099
00100
00101 #ifndef PI
00102 #define PI 3.141592654
00103 #endif
00104
00105
00106 double *vetError;
00107 double delta = 0.0;
00108
00109
00110
00111
00112
00113 static double _TimeIncrement ( void );
00114 static void _UpdateGeometry( double, double * );
00115 static int _ConvergeError ( );
00116 static double InitialError( double, double *, double *, double *, double *);
00117
00118
00119
00120 static double _TimeIncrement( void )
00121 {
00122 double dt = 1.0e6;
00123 double edt = 1.0e6;
00124 int i;
00125
00126
00127
00128 for( i = 0; i < NumElements; i++ )
00129 {
00130
00131
00132 if( ElmList[i]->rezone != NONE )
00133 continue;
00134
00135
00136
00137 ElmTimeStep( ElmList[i], &edt );
00138
00139
00140
00141 if( edt < dt )
00142 dt = edt;
00143 }
00144
00145 return( dt );
00146
00147 }
00148
00149
00150 static int _ConvergeError ( )
00151 {
00152 int i;
00153 int flag = 1;
00154 int dimVetError = Config.numsteptol;
00155
00156 for(i = 0; i < dimVetError; i++)
00157 {
00158 if(vetError[i] >= Config.tolerance)
00159 flag = 0;
00160 }
00161
00162 return( flag );
00163
00164 }
00165
00166
00167
00168
00169
00170 static void _UpdateGeometry( double dtime, double *VVector )
00171 {
00172 int i;
00173
00174
00175
00176 for( i = 0; i < NumNodes; i++ )
00177 {
00178 NodeVector[i].coord.x += dtime * VVector[NDof*i];
00179 NodeVector[i].coord.y += dtime * VVector[NDof*i+1];
00180 if( NDof == 3 )
00181 NodeVector[i].coord.z += dtime * VVector[NDof*i+2];
00182 }
00183
00184 }
00185
00186
00187 static double InitialError( double dtime, double *F, double *U, double *V, double *U0)
00188 {
00189 int i, j;
00190 double error;
00191 double vp[3];
00192 eRestType dof[3];
00193
00194 for( i = 0; i < NumNodes; i++ ) {
00195 dof[0] = NodeVector[i].dof.x;
00196 dof[1] = NodeVector[i].dof.y;
00197 dof[2] = NodeVector[i].dof.z;
00198 vp[0] = NodeVector[i].dof.vpx;
00199 vp[1] = NodeVector[i].dof.vpy;
00200 vp[2] = NodeVector[i].dof.vpz;
00201 for( j = 0; j < NDof; j++ ) {
00202
00203
00204 if(dof[j] == DISPLACEMENT){
00205 U[NDof*i+j] = vp[j] * Config.loadfactor;
00206 }
00207 }
00208 }
00209
00210
00211
00212 InternalForces( dtime, F, U, V );
00213
00214
00215
00216 error = 0.0;
00217
00218
00219
00220 for( i = 0; i < NumNodes; i++ )
00221 {
00222
00223
00224 if( NodeVector[i].rezone != NONE )
00225 continue;
00226
00227
00228
00229 for( j = 0; j < NDof; j++ )
00230 {
00231
00232
00233 error += fabs(F[NDof*i+j]);
00234 }
00235 }
00236
00237 for( i = 0; i < NumNodes; i++ ) {
00238 for( j = 0; j < NDof; j++ ) {
00239 U[NDof*i+j] = U0[NDof*i+j];
00240 }
00241 }
00242
00243 return (error);
00244 }
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255 double ComputeError( double *FVector, double *UVector, double error0 )
00256 {
00257 int i, j;
00258 double err;
00259
00260
00261
00262 err = 0.0;
00263
00264
00265
00266 for( i = 0; i < NumNodes; i++ )
00267 {
00268
00269
00270 if( NodeVector[i].rezone != NONE )
00271 continue;
00272
00273
00274
00275 for( j = 0; j < NDof; j++ )
00276 {
00277
00278
00279 err += fabs(FVector[NDof*i+j] * UVector[NDof*i+j]);
00280 }
00281 }
00282
00283 return( err/error0 );
00284
00285 }
00286
00287
00288
00289
00290 void _dUVector( double *UVector, double *UVector0, double *dUVector )
00291 {
00292 int i, j;
00293
00294
00295
00296 for( i = 0; i < NumNodes; i++ )
00297 {
00298
00299
00300 if( NodeVector[i].rezone != NONE )
00301 continue;
00302
00303
00304
00305 for( j = 0; j < NDof; j++ )
00306 {
00307
00308
00309 dUVector[NDof*i+j] = UVector[NDof*i+j] - UVector0[NDof*i+j];
00310 UVector0[NDof*i+j] = UVector[NDof*i+j];
00311 }
00312 }
00313
00314 }
00315
00316
00317
00318
00319 int NeedIteration( double *error, int *iteration, int stop )
00320 {
00321 int i;
00322 int flag;
00323 int dimVetError = Config.numsteptol;
00324
00325
00326 if ( (*iteration < dimVetError) && (stop == 0) )
00327 {
00328 vetError[*iteration] = *error;
00329 flag = 1;
00330 (*iteration)++;
00331 return( flag );
00332 }
00333
00334
00335 for(i = 0; i < dimVetError-1; i++)
00336 {
00337 vetError[i] = vetError[i+1];
00338 }
00339 vetError[dimVetError-1] = *error;
00340
00341
00342 if( (_ConvergeError( ) != 0) || ((*iteration + 1) > Config.max_iter) ||
00343 (stop == 1))
00344 {
00345 flag = 0;
00346 }
00347 else
00348 {
00349 flag = 1;
00350 (*iteration)++;
00351 }
00352
00353 return( flag );
00354
00355 }
00356
00357
00358
00359
00360 int DRSolver(UI_State *R, double *FVector, double *UVector, double *VVector,
00361 double *MVector, int loadstep)
00362 {
00363 int iteration, needite;
00364 double dtime, alpha, CinEng, error;
00365 double *dUVector, *UVector0;
00366 double error0;
00367 int stop = 0;
00368 unsigned long int i_time = time( NULL );
00369
00370
00371
00372 iteration = 0;
00373 needite = 0;
00374 dtime = 0.0;
00375 alpha = 0.0;
00376 error = 0.0;
00377 CinEng = 0.0;
00378 error0 = 1.0;
00379
00380 dUVector = (double *)calloc( NDof*NumNodes, sizeof(double) );
00381 UVector0 = (double *)calloc( NDof*NumNodes, sizeof(double) );
00382
00383 if(R)
00384 UISetDisplacement(R, NDof, UVector);
00385
00386
00387
00388 dtime = Config.dtfrac * _TimeIncrement();
00389
00390
00391
00392 MassVector( MVector );
00393
00394
00395 vetError = (double*)malloc(Config.numsteptol*sizeof(double));
00396
00397
00398
00399
00400 iteration = 0;
00401
00402 Config.loadfactor = (loadstep + 1.0) / Config.num_load_step;
00403
00404
00405
00406 error0 = InitialError(dtime, FVector, UVector, VVector, UVector0);
00407
00408
00409
00410 do {
00411
00412
00413
00414 DampCalcCoeff(DampObj,iteration,dtime,MVector,VVector,&alpha,&CinEng);
00415
00416
00417
00418 if( !DisplacementVelocity( iteration, alpha, dtime,
00419 FVector, VVector, UVector, MVector ) )
00420 return 0;
00421
00422
00423 if( R && (iteration%Config.draw_step) )
00424 UIDraw(R);
00425
00426
00427
00428 if( IsGeomNonLinear )
00429 _UpdateGeometry( dtime, VVector );
00430
00431
00432
00433 if( IsCoupled )
00434 PercolationForces( FVector );
00435
00436
00437
00438 InternalForces( dtime, FVector, UVector, VVector );
00439
00440
00441
00442 _dUVector(UVector, UVector0, dUVector);
00443
00444
00445
00446 error = ComputeError( FVector , dUVector, error0);
00447
00448
00449
00450
00451 if( IsGeomNonLinear ) {
00452 if( error > 1.0 ) {
00453 dtime = Config.dtfrac * _TimeIncrement();
00454 MassVector( MVector );
00455 }
00456 }
00457
00458 if( _count_it != NULL )
00459 (*_count_it) ( iteration, error, loadstep);
00460
00461 if( _fstop != NULL )
00462 (*_fstop) ( &stop );
00463
00464
00465
00466 needite = NeedIteration( &error, &iteration, stop );
00467
00468 fprintf( stdout, "\tStep: %d\tError: %3.3e\r", iteration+1, error);
00469
00470 fflush( stdout );
00471
00472 if(Config.num_load_step == 1){
00473
00474
00475 DrvPrintResult( DrvObj, iteration, UVector, VVector );
00476 }
00477 } while( needite );
00478
00479 if(Config.num_load_step > 1){
00480
00481
00482 DrvPrintResult( DrvObj, loadstep, UVector, VVector );
00483 }
00484
00485
00486
00487 free ( vetError );
00488
00489 fprintf( stdout, "\n\tTotal solver time....................: %lu segs\n\n", (time(NULL)-i_time) );
00490
00491 free( dUVector );
00492 free( UVector0 );
00493
00494 return( 1 );
00495
00496 }
00497
00498
00499
00500
00501 int IMPLINEARSolver(UI_State *R, double *FVector, double *UVector, double *VVector,
00502 double *MVector, int loadstep)
00503 {
00504 int iteration, needite;
00505 double dtime, alpha, CinEng, error;
00506 double *dUVector, *UVector0;
00507 double error0;
00508 int stop = 0;
00509 unsigned long int i_time = time( NULL );
00510 int i;
00511 int *ia;
00512 int *ja = NULL;
00513 double *avector;
00514 int nna = 0;
00515 int nnu = 0;
00516 CsrNode *node_list = 0L;
00517
00518
00519
00520 iteration = 0;
00521 needite = 0;
00522 dtime = 0.0;
00523 alpha = 0.0;
00524 error = 0.0;
00525 CinEng = 0.0;
00526 error0 = 1.0;
00527 Config.numsteptol = 1;
00528
00529 dUVector = (double *)calloc( NDof*NumNodes, sizeof(double) );
00530 UVector0 = (double *)calloc( NDof*NumNodes, sizeof(double) );
00531
00532 nnu = NDof*NumNodes;
00533
00534
00535
00536 node_list = (CsrNode*) calloc(NumNodes + 1, sizeof(CsrNode));
00537
00538
00539
00540 BuildNodeList(node_list);
00541
00542
00543
00544 BuildNodeList(node_list);
00545
00546
00547 ia = (int*)calloc( nnu + 1, sizeof(int) );
00548
00549
00550 BuildIaVec( node_list, ia, nnu, &nna );
00551
00552
00553 avector = (double*)calloc( nna, sizeof(double) );
00554
00555
00556 ja = (int*)calloc( nna, sizeof(int) );
00557
00558
00559 BuildJaVec( node_list, ja );
00560
00561
00562
00563 FreeNodeList(node_list);
00564
00565
00566 BuildAVector( ia, ja, avector );
00567
00568 if(Config.solver == 1){
00569
00570
00571
00572 for( i = 0; i < nnu+1; i++ ) {
00573 ia[i] += 1;
00574 }
00575 for( i = 0; i < nna; i++ ) {
00576 ja[i] += 1;
00577 }
00578
00579 }
00580
00581 if(R)
00582 UISetDisplacement(R, NDof, UVector);
00583
00584
00585
00586 dtime = Config.dtfrac * _TimeIncrement();
00587
00588
00589
00590 MassVector( MVector );
00591
00592
00593 vetError = (double*)malloc(Config.numsteptol*sizeof(double));
00594
00595
00596
00597
00598 iteration = 0;
00599
00600 Config.loadfactor = (loadstep + 1.0) / Config.num_load_step;
00601
00602
00603
00604 error0 = InitialError(dtime, FVector, UVector, VVector, UVector0);
00605
00606 do {
00607
00608 LINEAR( dtime, FVector, UVector, VVector, &iteration, &error, error0, loadstep, nna, nnu, ia, ja, avector );
00609
00610 if( _count_it != NULL )
00611 (*_count_it) ( iteration, error, loadstep);
00612
00613 if( _fstop != NULL )
00614 (*_fstop) ( &stop );
00615
00616 needite = 0;
00617
00618 fprintf( stdout, "\tStep: %d Error: %3.3e\r", iteration+1, error );
00619 fflush( stdout );
00620
00621 if(Config.num_load_step == 1){
00622
00623
00624 DrvPrintResult( DrvObj, iteration, UVector, VVector );
00625 }
00626 } while( needite );
00627
00628 if(Config.num_load_step > 1){
00629
00630
00631 DrvPrintResult( DrvObj, loadstep, UVector, VVector );
00632 }
00633
00634
00635
00636 free ( vetError );
00637
00638 fprintf( stdout, "\n\tTotal solver time....................: %lu segs\n\n", (time(NULL)-i_time) );
00639
00640 free( dUVector );
00641 free( UVector0 );
00642 free( ia );
00643 free( ja );
00644 free( avector );
00645
00646 return( 1 );
00647
00648 }
00649
00650
00651
00652
00653 int IMPBFGSSolver(UI_State *R, double *FVector, double *UVector, double *VVector,
00654 double *MVector, int loadstep)
00655 {
00656 int iteration, needite;
00657 double dtime, alpha, CinEng, error;
00658 double *dUVector, *UVector0;
00659 double error0;
00660 int stop = 0;
00661 unsigned long int i_time = time( NULL );
00662 int i;
00663 int *ia;
00664 int *ja;
00665 double *avector;
00666 int nna = 0;
00667 int nnu = 0;
00668 CsrNode *node_list = 0L;
00669
00670
00671
00672 iteration = 0;
00673 needite = 0;
00674 dtime = 0.0;
00675 alpha = 0.0;
00676 error = 0.0;
00677 CinEng = 0.0;
00678 error0 = 1.0;
00679 Config.numsteptol = 1;
00680
00681 dUVector = (double *)calloc( NDof*NumNodes, sizeof(double) );
00682 UVector0 = (double *)calloc( NDof*NumNodes, sizeof(double) );
00683
00684 nnu = NDof*NumNodes;
00685
00686
00687
00688 node_list = (CsrNode*) calloc(NumNodes + 1, sizeof(CsrNode));
00689
00690
00691
00692 BuildNodeList(node_list);
00693
00694
00695
00696 BuildNodeList(node_list);
00697
00698
00699 ia = (int*)calloc( nnu + 1, sizeof(int) );
00700
00701
00702 BuildIaVec( node_list, ia, nnu, &nna );
00703
00704
00705 ja = (int*)calloc( nna, sizeof(int) );
00706
00707
00708 BuildJaVec( node_list, ja );
00709
00710
00711
00712 FreeNodeList(node_list);
00713
00714
00715 avector = (double*)calloc( nna, sizeof(double) );
00716
00717
00718 BuildAVector( ia, ja, avector );
00719
00720 if(Config.solver == 1){
00721
00722
00723
00724 for( i = 0; i < nnu+1; i++ ) {
00725 ia[i] += 1;
00726 }
00727 for( i = 0; i < nna; i++ ) {
00728 ja[i] += 1;
00729 }
00730
00731 }
00732
00733 if(R)
00734 UISetDisplacement(R, NDof, UVector);
00735
00736
00737
00738 dtime = Config.dtfrac * _TimeIncrement();
00739
00740
00741
00742 MassVector( MVector );
00743
00744
00745 vetError = (double*)malloc(Config.numsteptol*sizeof(double));
00746
00747
00748
00749
00750 iteration = 0;
00751
00752 Config.loadfactor = (loadstep + 1.0) / Config.num_load_step;
00753
00754
00755
00756 error0 = InitialError(dtime, FVector, UVector, VVector, UVector0);
00757
00758 do {
00759
00760 BFGS( dtime, FVector, UVector, VVector, &iteration, &error, error0, loadstep, nna, nnu, ia, ja, avector );
00761
00762 if( _count_it != NULL )
00763 (*_count_it) ( iteration, error, loadstep);
00764
00765 if( _fstop != NULL )
00766 (*_fstop) ( &stop );
00767
00768
00769
00770 needite = NeedIteration( &error, &iteration, stop );
00771
00772 if(Config.num_load_step == 1){
00773
00774
00775 DrvPrintResult( DrvObj, iteration, UVector, VVector );
00776 }
00777 } while( needite );
00778
00779 if(Config.num_load_step > 1){
00780
00781
00782 DrvPrintResult( DrvObj, loadstep, UVector, VVector );
00783 }
00784
00785
00786 free ( vetError );
00787
00788 fprintf( stdout, "\n\tTotal solver time....................: %lu segs\n\n", (time(NULL)-i_time) );
00789
00790 printf( "\n" );
00791
00792 free( dUVector );
00793 free( UVector0 );
00794 free( ia );
00795 free( ja );
00796 free( avector );
00797
00798 return( 1 );
00799
00800 }
00801
00802
00803
00804
00805 int IMPNRMSolver(UI_State *R, double *FVector, double *UVector, double *VVector,
00806 double *MVector, int loadstep)
00807 {
00808 int iteration, needite;
00809 double dtime, alpha, CinEng, error;
00810 double *dUVector, *UVector0;
00811 double error0;
00812 int stop = 0;
00813 unsigned long int i_time = time( NULL );
00814 int i;
00815 int *ia;
00816 int *ja;
00817 double *avector;
00818 int nna = 0;
00819 int nnu = 0;
00820 CsrNode *node_list = 0L;
00821
00822
00823
00824 iteration = 0;
00825 needite = 0;
00826 dtime = 0.0;
00827 alpha = 0.0;
00828 error = 0.0;
00829 CinEng = 0.0;
00830 error0 = 1.0;
00831 Config.numsteptol = 1;
00832
00833 dUVector = (double *)calloc( NDof*NumNodes, sizeof(double) );
00834 UVector0 = (double *)calloc( NDof*NumNodes, sizeof(double) );
00835
00836 nnu = NDof*NumNodes;
00837
00838
00839
00840 node_list = (CsrNode*) calloc(NumNodes + 1, sizeof(CsrNode));
00841
00842
00843
00844 BuildNodeList(node_list);
00845
00846
00847
00848 BuildNodeList(node_list);
00849
00850
00851 ia = (int*)calloc( nnu + 1, sizeof(int) );
00852
00853
00854 BuildIaVec( node_list, ia, nnu, &nna );
00855
00856
00857 ja = (int*)calloc( nna, sizeof(int) );
00858
00859
00860 BuildJaVec( node_list, ja );
00861
00862
00863
00864 FreeNodeList(node_list);
00865
00866
00867 avector = (double*)calloc( nna, sizeof(double) );
00868
00869
00870 BuildAVector( ia, ja, avector );
00871
00872 if(Config.solver == 1){
00873
00874
00875
00876 for( i = 0; i < nnu+1; i++ ) {
00877 ia[i] += 1;
00878 }
00879 for( i = 0; i < nna; i++ ) {
00880 ja[i] += 1;
00881 }
00882
00883 }
00884
00885 if(R)
00886 UISetDisplacement(R, NDof, UVector);
00887
00888
00889
00890 dtime = Config.dtfrac * _TimeIncrement();
00891
00892
00893
00894 MassVector( MVector );
00895
00896
00897 vetError = (double*)malloc(Config.numsteptol*sizeof(double));
00898
00899
00900
00901
00902 iteration = 0;
00903
00904 Config.loadfactor = (loadstep + 1.0) / Config.num_load_step;
00905
00906
00907
00908 error0 = InitialError(dtime, FVector, UVector, VVector, UVector0);
00909
00910 do {
00911
00912 NRM( dtime, FVector, UVector, VVector, &iteration, &error, error0, loadstep, nna, nnu, ia, ja, avector );
00913
00914 if( _count_it != NULL )
00915 (*_count_it) ( iteration, error, loadstep);
00916
00917 if( _fstop != NULL )
00918 (*_fstop) ( &stop );
00919
00920
00921
00922 needite = NeedIteration( &error, &iteration, stop );
00923
00924 if(Config.num_load_step == 1){
00925
00926
00927 DrvPrintResult( DrvObj, iteration, UVector, VVector );
00928 }
00929 } while( needite );
00930
00931 if(Config.num_load_step > 1){
00932
00933
00934 DrvPrintResult( DrvObj, loadstep, UVector, VVector );
00935 }
00936
00937
00938 free ( vetError );
00939
00940 fprintf( stdout, "\n\tTotal solver time....................: %lu segs\n\n", (time(NULL)-i_time) );
00941
00942 printf( "\n" );
00943
00944 free( dUVector );
00945 free( UVector0 );
00946 free( ia );
00947 free( ja );
00948 free( avector );
00949
00950 return( 1 );
00951
00952 }
00953
00954
00955
00956
00957 int HYBRIDSolver(UI_State *R, double *FVector, double *UVector, double *VVector,
00958 double *MVector, int loadstep)
00959 {
00960 int iteration, needite;
00961 double dtime, alpha, CinEng, error;
00962 double *dUVector, *UVector0;
00963 double error0;
00964 int stop = 0;
00965 int hs = 1;
00966 unsigned long int i_time = time( NULL );
00967 int i;
00968 int *ia;
00969 int *ja;
00970 double *avector;
00971 int nna = 0;
00972 int nnu = 0;
00973 CsrNode *node_list = 0L;
00974
00975
00976
00977 iteration = 0;
00978 needite = 0;
00979 dtime = 0.0;
00980 alpha = 0.0;
00981 error = 0.0;
00982 CinEng = 0.0;
00983 error0 = 1.0;
00984 Config.max_iter = 20;
00985 Config.numsteptol = 1;
00986
00987 dUVector = (double *)calloc( NDof*NumNodes, sizeof(double) );
00988 UVector0 = (double *)calloc( NDof*NumNodes, sizeof(double) );
00989
00990 nnu = NDof*NumNodes;
00991
00992
00993
00994 node_list = (CsrNode*) calloc(NumNodes + 1, sizeof(CsrNode));
00995
00996
00997
00998 BuildNodeList(node_list);
00999
01000
01001
01002 BuildNodeList(node_list);
01003
01004
01005 ia = (int*)calloc( nnu + 1, sizeof(int) );
01006
01007
01008 BuildIaVec( node_list, ia, nnu, &nna );
01009
01010
01011 ja = (int*)calloc( nna, sizeof(int) );
01012
01013
01014 BuildJaVec( node_list, ja );
01015
01016
01017
01018 FreeNodeList(node_list);
01019
01020
01021 avector = (double*)calloc( nna, sizeof(double) );
01022
01023
01024 BuildAVector( ia, ja, avector );
01025
01026 if(Config.solver == 1){
01027
01028
01029
01030 for( i = 0; i < nnu+1; i++ ) {
01031 ia[i] += 1;
01032 }
01033 for( i = 0; i < nna; i++ ) {
01034 ja[i] += 1;
01035 }
01036
01037 }
01038
01039
01040 if(R)
01041 UISetDisplacement(R, NDof, UVector);
01042
01043
01044
01045 dtime = Config.dtfrac * _TimeIncrement();
01046
01047
01048
01049 MassVector( MVector );
01050
01051
01052 vetError = (double*)malloc(Config.numsteptol*sizeof(double));
01053
01054
01055
01056
01057 iteration = 0;
01058
01059 Config.loadfactor = (loadstep + 1.0) / Config.num_load_step;
01060
01061
01062
01063 error0 = InitialError(dtime, FVector, UVector, VVector, UVector0);
01064
01065 do {
01066
01067 if(hs){
01068 BFGS( dtime, FVector, UVector, VVector, &iteration, &error, error0, loadstep, nna, nnu, ia, ja, avector );
01069 if(error >= Config.tolerance ){
01070
01071 hs = 0;
01072 Config.max_iter = 10000;
01073 Config.numsteptol = 50;
01074 iteration = 0;
01075 free ( vetError );
01076
01077 vetError = (double*)malloc(Config.numsteptol*sizeof(double));
01078 }
01079 }
01080 if(!hs){
01081
01082
01083
01084 DampCalcCoeff(DampObj,iteration,dtime,MVector,VVector,&alpha,&CinEng);
01085
01086
01087
01088 if( !DisplacementVelocity( iteration, alpha, dtime,
01089 FVector, VVector, UVector, MVector ) )
01090 return 0;
01091
01092
01093 if( R && (iteration%Config.draw_step) )
01094 UIDraw(R);
01095
01096
01097
01098 if( IsGeomNonLinear )
01099 _UpdateGeometry( dtime, VVector );
01100
01101
01102
01103 if( IsCoupled )
01104 PercolationForces( FVector );
01105
01106
01107
01108 InternalForces( dtime, FVector, UVector, VVector );
01109
01110
01111
01112 _dUVector(UVector, UVector0, dUVector);
01113
01114
01115
01116 error = ComputeError( FVector , dUVector, error0);
01117
01118
01119
01120
01121 if( IsGeomNonLinear ) {
01122 if( error > 1.0 ) {
01123 dtime = Config.dtfrac * _TimeIncrement();
01124 MassVector( MVector );
01125 }
01126 }
01127
01128 if( _count_it != NULL )
01129 (*_count_it) ( iteration, error, loadstep);
01130
01131 if( _fstop != NULL )
01132 (*_fstop) ( &stop );
01133
01134
01135
01136 needite = NeedIteration( &error, &iteration, stop );
01137
01138 fprintf( stdout, "\tStep: %d Error: %3.3e\r", iteration+1, error );
01139 fflush( stdout );
01140
01141 if(Config.num_load_step == 1){
01142
01143
01144 DrvPrintResult( DrvObj, iteration, UVector, VVector );
01145 }
01146 }
01147 } while( needite );
01148
01149 if(Config.num_load_step > 1){
01150
01151
01152 DrvPrintResult( DrvObj, loadstep, UVector, VVector );
01153 }
01154
01155
01156 free ( vetError );
01157
01158 fprintf( stdout, "\n\tTotal solver time....................: %lu segs\n\n", (time(NULL)-i_time) );
01159
01160 printf( "\n" );
01161
01162 free( dUVector );
01163 free( UVector0 );
01164 free( ia );
01165 free( ja );
01166 free( avector );
01167
01168 return( 1 );
01169
01170 }
01171
01172
01173
01174
01175
01176 void AlgReset( void )
01177 {
01178 Config.max_iter = 0;
01179 Config.nonlinear = 0;
01180 Config.print_step = 0;
01181 Config.draw_step = 1;
01182 Config.num_step = 0;
01183 Config.num_time_step = 0;
01184 Config.tolerance = 0.0;
01185 Config.numsteptol = 50;
01186 Config.dtfrac = 0.0;
01187 Config.totalTime = 0.0;
01188 Config.timeStep = 0.0;
01189 Config.num_load_step = 1;
01190 Config.loadfactor = 1;
01191 Config.algtype = 0;
01192 Config.numgaussresults =-1;
01193 Config.gaussresults = NULL;
01194 Config.solver = 0;
01195
01196 }
01197
01198
01199
01200