00001 #include "backupsol.h"
00002 #include "hdbcontr.h"
00003 #include "galias.h"
00004 #include "global.h"
00005 #include "iotools.h"
00006 #include "node.h"
00007 #include "element.h"
00008
00009 #include <stdio.h>
00010 #include <stdlib.h>
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 void solver_save (double *r,double *fp,long ni,double time, double dt, timecontr *tc, long n)
00030 {
00031 switch (Mp->hdbcont.hdbfmts)
00032 {
00033 case text:
00034 solver_save_text(r, fp, ni, time, dt, tc, n);
00035 break;
00036 case binary:
00037 solver_save_binary(r, fp, ni, time, dt, tc, n);
00038 break;
00039 default:
00040 print_err("unknown type of backup file format is required", __FILE__, __LINE__, __func__);
00041 }
00042 }
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062 void solver_save_text (double *r,double *fp,long ni,double time, double dt, timecontr *tc, long n)
00063 {
00064 switch (Mp->hdbcont.hdbtype)
00065 {
00066 case hdbs_single:
00067 case hdbrs_single:
00068 solver_save_text_single(r, fp, ni, time, dt, tc, n);
00069 break;
00070 case hdbs_multiple:
00071 case hdbrs_multiple:
00072 solver_save_text_multiple(r, fp, ni, time, dt, tc, n);
00073 break;
00074 default:
00075 print_err("unknown type of backup is required", __FILE__, __LINE__, __func__);
00076 }
00077 }
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097 void solver_save_binary (double *r,double *fp,long ni,double time, double dt, timecontr *tc, long n)
00098 {
00099 switch (Mp->hdbcont.hdbtype)
00100 {
00101 case hdbs_single:
00102 case hdbrs_single:
00103 solver_save_binary_single(r, fp, ni, time, dt, tc, n);
00104 break;
00105 case hdbs_multiple:
00106 case hdbrs_multiple:
00107 solver_save_binary_multiple(r, fp, ni, time, dt, tc, n);
00108 break;
00109 default:
00110 print_err("unknown type of backup is required", __FILE__, __LINE__, __func__);
00111 }
00112 }
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132 void solver_save_text_single (double *r,double *fp,long ni,double time, double dt, timecontr *tc, long n)
00133 {
00134 long i, j, ndofn, ndofe;
00135 FILE *aux;
00136 char name[FNAMELEN+20];
00137 char emsg[FNAMELEN+100];
00138 int prec = (int)Mp->hdbcont.prec;
00139
00140 sprintf(name, "%s.%ld.bac",Mp->hdbcont.hdbnames, ni);
00141 aux = fopen(name,"wt");
00142 if (aux==NULL)
00143 {
00144 sprintf(emsg, "cannot open backup file %s", name);
00145 print_err(emsg, __FILE__, __LINE__, __func__);
00146 abort();
00147 }
00148 fprintf (aux,"\n\n\n\n");
00149
00150
00151 if (tc)
00152 tc->save_txt(aux, prec);
00153
00154 fprintf (aux,"%.*le\n",prec,time);
00155
00156 fprintf (aux,"%.*le\n",prec,dt);
00157
00158 fprintf (aux,"%ld\n",ni);
00159
00160 fprintf (aux,"%ld\n",n);
00161
00162
00163 for (i=0;i<n;i++){
00164 fprintf (aux,"%.*le\n",prec,r[i]);
00165 }
00166
00167 fprintf (aux,"\n");
00168
00169
00170 for (i=0;i<n;i++){
00171 fprintf (aux,"%.*le\n",prec,fp[i]);
00172 }
00173
00174
00175 fprintf (aux,"\n\n %ld\n",Mm->tnip);
00176
00177
00178 Mm->save_intpoints_txt (aux, Mp->hdbcont.selelems, Mp->hdbcont.selother_s);
00179
00180
00181 if (Mp->tprob == growing_mech_structure)
00182 {
00183 for (i=0;i<Mt->nn;i++)
00184 {
00185 if (Mt->nodedispl[i] == NULL)
00186 continue;
00187 ndofn=Mt->give_ndofn(i);
00188 for (j=0; j<ndofn; j++)
00189 fprintf(aux,"%.*le\n",prec,Mt->nodedispl[i][j]);
00190 }
00191 for (i=0;i<Mt->ne;i++)
00192 {
00193 ndofe=Mt->give_ndofe(i);
00194 for (j=0; j<ndofe; j++)
00195 fprintf(aux,"%.*le\n",prec,Mt->elements[i].initdispl[j]);
00196 }
00197 }
00198
00199 fclose (aux);
00200 if (Mp->hdbcont.rmold)
00201 {
00202 if (Mp->hdbcont.rmold_id>=0)
00203 {
00204 sprintf(name, "%s.%ld.bac",Mp->hdbcont.hdbnames,Mp->hdbcont.rmold_id);
00205 remove(name);
00206 }
00207 Mp->hdbcont.rmold_id = ni;
00208 }
00209 }
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241 void solver_save_text_multiple (double *r,double *fp,long ni,double time, double dt, timecontr *tc, long n)
00242 {
00243 long i, j, ndofn, ndofe;
00244 FILE *aux;
00245 char name[FNAMELEN+20];
00246 char emsg[FNAMELEN+100];
00247 int prec = (int)Mp->hdbcont.prec;
00248
00249 sprintf(name, "%s.%ld.solver.bac",Mp->hdbcont.hdbnames, ni);
00250 aux = fopen(name,"wt");
00251 if (aux==NULL)
00252 {
00253 sprintf(emsg, "cannot open backup file %s", name);
00254 print_err(emsg, __FILE__, __LINE__, __func__);
00255 abort();
00256 }
00257
00258
00259 if (tc)
00260 tc->save_txt(aux, prec);
00261
00262 fprintf (aux,"%.*le\n",prec,time);
00263
00264 fprintf (aux,"%.*le\n",prec,dt);
00265
00266 fprintf (aux,"%ld\n",ni);
00267
00268 fprintf (aux,"%ld\n",n);
00269
00270
00271 for (i=0;i<n;i++){
00272 fprintf (aux,"%.*le\n",prec,r[i]);
00273 }
00274
00275 fprintf (aux,"\n");
00276
00277
00278 for (i=0;i<n;i++){
00279 fprintf (aux,"%.*le\n",prec,fp[i]);
00280 }
00281
00282
00283 fprintf (aux,"\n\n %ld\n",Mm->tnip);
00284
00285 fclose (aux);
00286 if ((Mp->hdbcont.rmold) && (Mp->hdbcont.rmold_id>=0))
00287 {
00288 sprintf(name, "%s.%ld.solver.bac",Mp->hdbcont.hdbnames,Mp->hdbcont.rmold_id);
00289 remove(name);
00290 }
00291
00292
00293 Mm->save_intpoints_txt (ni, Mp->hdbcont.selelems, Mp->hdbcont.selother_s);
00294
00295
00296 if (Mp->tprob == growing_mech_structure)
00297 {
00298 sprintf(name, "%s.%ld.initdispl.bac",Mp->hdbcont.hdbnames, ni);
00299 aux = fopen(name,"wt");
00300 if (aux==NULL)
00301 {
00302 sprintf(emsg, "cannot open backup file %s", name);
00303 print_err(emsg, __FILE__, __LINE__, __func__);
00304 abort();
00305 }
00306 for (i=0;i<Mt->nn;i++)
00307 {
00308 if (Mt->nodedispl[i] == NULL)
00309 continue;
00310 ndofn=Mt->give_ndofn(i);
00311 for (j=0; j<ndofn; j++)
00312 fprintf(aux,"%.*le\n",prec,Mt->nodedispl[i][j]);
00313 }
00314 for (i=0;i<Mt->ne;i++)
00315 {
00316 ndofe=Mt->give_ndofe(i);
00317 for (j=0; j<ndofe; j++)
00318 fprintf(aux,"%.*le\n",prec,Mt->elements[i].initdispl[j]);
00319 }
00320 }
00321
00322 if (Mp->hdbcont.rmold)
00323 {
00324 if (Mp->hdbcont.rmold_id>=0)
00325 {
00326 sprintf(name, "%s.%ld.solver.bac",Mp->hdbcont.hdbnames,Mp->hdbcont.rmold_id);
00327 remove(name);
00328 sprintf(name, "%s.%ld.initdispl.bac",Mp->hdbcont.hdbnames,Mp->hdbcont.rmold_id);
00329 remove(name);
00330 sprintf(name, "%s.%ld.strain.bac",Mp->hdbcont.hdbnames,Mp->hdbcont.rmold_id);
00331 remove(name);
00332 sprintf(name, "%s.%ld.stress.bac",Mp->hdbcont.hdbnames,Mp->hdbcont.rmold_id);
00333 remove(name);
00334 sprintf(name, "%s.%ld.other.bac",Mp->hdbcont.hdbnames,Mp->hdbcont.rmold_id);
00335 remove(name);
00336 sprintf(name, "%s.%ld.trfquant.bac",Mp->hdbcont.hdbnames,Mp->hdbcont.rmold_id);
00337 remove(name);
00338 }
00339 Mp->hdbcont.rmold_id = ni;
00340 }
00341 }
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361 void solver_save_binary_single (double *r,double *fp,long ni,double time, double dt, timecontr *tc, long n)
00362 {
00363 long i, ndofn, ndofe;
00364 FILE *aux;
00365 char name[FNAMELEN+30];
00366 char emsg[FNAMELEN+100];
00367
00368 sprintf(name, "%s.%ld.bac",Mp->hdbcont.hdbnames, ni);
00369 aux = fopen(name,"wb");
00370 if (aux==NULL)
00371 {
00372 sprintf(emsg, "cannot open backup file %s", name);
00373 print_err(emsg, __FILE__, __LINE__, __func__);
00374 abort();
00375 }
00376
00377
00378 if (tc)
00379 tc->save_bin(aux);
00380
00381 fwrite (&time, sizeof(time), 1, aux);
00382
00383 fwrite (&dt, sizeof(dt), 1, aux);
00384
00385 fwrite (&ni, sizeof(ni), 1, aux);
00386
00387 fwrite (&n, sizeof(n), 1, aux);
00388
00389
00390 fwrite(r, sizeof(*r), n, aux);
00391
00392
00393 fwrite(fp, sizeof(*fp), n, aux);
00394
00395
00396 fwrite (&Mm->tnip, sizeof(Mm->tnip), 1, aux);
00397
00398
00399 Mm->save_intpoints_bin (aux, Mp->hdbcont.selelems, Mp->hdbcont.selother_s);
00400
00401
00402 if (Mp->tprob == growing_mech_structure)
00403 {
00404 for (i=0;i<Mt->nn;i++)
00405 {
00406 if (Mt->nodedispl[i] == NULL)
00407 continue;
00408 ndofn=Mt->give_ndofn(i);
00409 fwrite(Mt->nodedispl[i], sizeof(*Mt->nodedispl[i]), ndofn, aux);
00410 }
00411 for (i=0;i<Mt->ne;i++)
00412 {
00413 ndofe=Mt->give_ndofe(i);
00414 fwrite(Mt->elements[i].initdispl, sizeof(*Mt->elements[i].initdispl), ndofe, aux);
00415 }
00416 }
00417
00418 fclose (aux);
00419 if (Mp->hdbcont.rmold)
00420 {
00421 if (Mp->hdbcont.rmold_id>=0)
00422 {
00423 sprintf(name, "%s.%ld.bac",Mp->hdbcont.hdbnames,Mp->hdbcont.rmold_id);
00424 remove(name);
00425 }
00426 Mp->hdbcont.rmold_id = ni;
00427 }
00428 }
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459 void solver_save_binary_multiple (double *r,double *fp,long ni,double time, double dt, timecontr *tc, long n)
00460 {
00461 long i, ndofn, ndofe;
00462 FILE *aux;
00463 char name[FNAMELEN+30];
00464 char emsg[FNAMELEN+100];
00465
00466 sprintf(name, "%s.%ld.solver.bac",Mp->hdbcont.hdbnames, ni);
00467 aux = fopen(name,"wb");
00468 if (aux==NULL)
00469 {
00470 sprintf(emsg, "cannot open backup file %s", name);
00471 print_err(emsg, __FILE__, __LINE__, __func__);
00472 abort();
00473 }
00474
00475
00476 if (tc)
00477 tc->save_bin(aux);
00478
00479 fwrite (&time, sizeof(time), 1, aux);
00480
00481 fwrite (&dt, sizeof(dt), 1, aux);
00482
00483 fwrite (&ni, sizeof(ni), 1, aux);
00484
00485 fwrite (&n, sizeof(n), 1, aux);
00486
00487
00488 fwrite(r, sizeof(*r), n, aux);
00489
00490
00491 fwrite(fp, sizeof(*fp), n, aux);
00492
00493
00494 fwrite (&Mm->tnip, sizeof(Mm->tnip), 1, aux);
00495
00496 fclose (aux);
00497
00498 if ((Mp->hdbcont.rmold) && (Mp->hdbcont.rmold_id>=0))
00499 {
00500 sprintf(name, "%s.%ld.solver.bac",Mp->hdbcont.hdbnames,Mp->hdbcont.rmold_id);
00501 remove(name);
00502 }
00503
00504
00505 Mm->save_intpoints_bin (ni, Mp->hdbcont.selelems, Mp->hdbcont.selother_s);
00506
00507
00508 if (Mp->tprob == growing_mech_structure)
00509 {
00510 sprintf(name, "%s.%ld.initdispl.bac",Mp->hdbcont.hdbnames, ni);
00511 aux = fopen(name,"wb");
00512 if (aux==NULL)
00513 {
00514 sprintf(emsg, "cannot open backup file %s", name);
00515 print_err(emsg, __FILE__, __LINE__, __func__);
00516 abort();
00517 }
00518 for (i=0;i<Mt->nn;i++)
00519 {
00520 if (Mt->nodedispl[i] == NULL)
00521 continue;
00522 ndofn=Mt->give_ndofn(i);
00523 fwrite(Mt->nodedispl[i], sizeof(*Mt->nodedispl[i]), ndofn, aux);
00524 }
00525 for (i=0;i<Mt->ne;i++)
00526 {
00527 ndofe=Mt->give_ndofe(i);
00528 fwrite(Mt->elements[i].initdispl, sizeof(*Mt->elements[i].initdispl), ndofe, aux);
00529 }
00530 }
00531
00532 if (Mp->hdbcont.rmold)
00533 {
00534 if (Mp->hdbcont.rmold_id>=0)
00535 {
00536 sprintf(name, "%s.%ld.solver.bac",Mp->hdbcont.hdbnames,Mp->hdbcont.rmold_id);
00537 remove(name);
00538 sprintf(name, "%s.%ld.initdispl.bac",Mp->hdbcont.hdbnames,Mp->hdbcont.rmold_id);
00539 remove(name);
00540 sprintf(name, "%s.%ld.strain.bac",Mp->hdbcont.hdbnames,Mp->hdbcont.rmold_id);
00541 remove(name);
00542 sprintf(name, "%s.%ld.stress.bac",Mp->hdbcont.hdbnames,Mp->hdbcont.rmold_id);
00543 remove(name);
00544 sprintf(name, "%s.%ld.other.bac",Mp->hdbcont.hdbnames,Mp->hdbcont.rmold_id);
00545 remove(name);
00546 sprintf(name, "%s.%ld.trfquant.bac",Mp->hdbcont.hdbnames,Mp->hdbcont.rmold_id);
00547 remove(name);
00548 }
00549 Mp->hdbcont.rmold_id = ni;
00550 }
00551 }
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571 void solver_restore (double *r,double *fp,long &ni,double &time, double &dt, timecontr *tc, long &n)
00572 {
00573 switch (Mp->hdbcont.hdbfmtr)
00574 {
00575 case text:
00576 solver_restore_text(r, fp, ni, time, dt, tc, n);
00577 break;
00578 case binary:
00579 solver_restore_binary(r, fp, ni, time, dt, tc, n);
00580 break;
00581 default:
00582 print_err("unknown type of backup file format is required", __FILE__, __LINE__, __func__);
00583 }
00584 }
00585
00586
00587
00588
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604 void solver_restore_text (double *r,double *fp,long &ni,double &time, double &dt, timecontr *tc, long &n)
00605 {
00606 switch (Mp->hdbcont.hdbtype)
00607 {
00608 case hdbr_single:
00609 case hdbrs_single:
00610 solver_restore_text_single(r, fp, ni, time, dt, tc, n);
00611 break;
00612 case hdbr_multiple:
00613 case hdbrs_multiple:
00614 solver_restore_text_multiple(r, fp, ni, time, dt, tc, n);
00615 break;
00616 default:
00617 print_err("unknown type of backup is required", __FILE__, __LINE__, __func__);
00618 }
00619 }
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639 void solver_restore_binary (double *r,double *fp,long &ni,double &time, double &dt, timecontr *tc, long &n)
00640 {
00641 switch (Mp->hdbcont.hdbtype)
00642 {
00643 case hdbr_single:
00644 case hdbrs_single:
00645 solver_restore_binary_single(r, fp, ni, time, dt, tc, n);
00646 break;
00647 case hdbr_multiple:
00648 case hdbrs_multiple:
00649 solver_restore_binary_multiple(r, fp, ni, time, dt, tc, n);
00650 break;
00651 default:
00652 print_err("unknown type of backup is required", __FILE__, __LINE__, __func__);
00653 }
00654 }
00655
00656
00657
00658
00659
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670
00671
00672
00673
00674 void solver_restore_text_single (double *r, double *fp, long &ni, double &time, double &dt, timecontr *tc, long &n)
00675 {
00676 long i, j, ndofn, ndofe;
00677 FILE *aux;
00678 char emsg[FNAMELEN+100];
00679
00680 aux = fopen(Mp->hdbcont.hdbnamer,"rt");
00681 if (aux==NULL)
00682 {
00683 sprintf(emsg, "cannot open backup file %s", Mp->hdbcont.hdbnamer);
00684 print_err(emsg, __FILE__, __LINE__, __func__);
00685 abort();
00686 }
00687
00688
00689 if (tc)
00690 tc->restore_txt(aux);
00691
00692 fscanf (aux,"%le",&time);
00693
00694 fscanf (aux,"%le",&dt);
00695
00696 fscanf (aux,"%ld",&ni);
00697
00698 fscanf (aux,"%ld",&n);
00699
00700 if (n!=Ndofm){
00701 print_err("number of DOFs in backup file and in the actual problem is not same\n", __FILE__, __LINE__, __func__);
00702 abort();
00703 }
00704
00705
00706 for (i=0;i<n;i++){
00707 fscanf (aux,"%le",r+i);
00708 }
00709
00710 for (i=0;i<n;i++){
00711 fscanf (aux,"%le",fp+i);
00712 }
00713
00714
00715 fscanf (aux,"%ld",&i);
00716
00717 if (i!=Mm->tnip){
00718 print_err("number of integration points in backup file and in the actual problem is not same\n", __FILE__, __LINE__, __func__);
00719 abort();
00720 }
00721
00722
00723 Mm->restore_intpoints_txt (aux, Mp->hdbcont.selelemr, Mp->hdbcont.selother_r, Mp->hdbcont.selother_id);
00724
00725
00726 if (Mp->tprob == growing_mech_structure)
00727 {
00728 for (i=0;i<Mt->nn;i++)
00729 {
00730 if (Mt->nodedispl[i] == NULL)
00731 continue;
00732 ndofn = Mt->give_ndofn(i);
00733 for (j=0; j<ndofn; j++)
00734 fscanf(aux,"%le", Mt->nodedispl[i]+j);
00735 }
00736 for (i=0;i<Mt->ne;i++)
00737 {
00738 ndofe = Mt->give_ndofe(i);
00739 for (j=0; j<ndofe; j++)
00740 fscanf(aux,"%le", Mt->elements[i].initdispl+j);
00741 }
00742 }
00743
00744 fclose(aux);
00745 }
00746
00747
00748
00749
00750
00751
00752
00753
00754
00755
00756
00757
00758
00759
00760
00761
00762
00763
00764
00765
00766
00767
00768
00769
00770
00771
00772
00773
00774
00775
00776
00777 void solver_restore_text_multiple (double *r,double *fp,long &ni,double &time, double &dt, timecontr *tc, long &n)
00778 {
00779 long i, j, ndofn, ndofe;
00780 FILE *aux;
00781 char name[FNAMELEN+20];
00782 char emsg[FNAMELEN+100];
00783
00784 sprintf(name, "%s.solver.bac",Mp->hdbcont.hdbnamer);
00785 aux = fopen(name,"rt");
00786 if (aux==NULL)
00787 {
00788 sprintf(emsg, "cannot open backup file %s", name);
00789 print_err(emsg, __FILE__, __LINE__, __func__);
00790 abort();
00791 }
00792
00793
00794 if (tc)
00795 tc->restore_txt(aux);
00796
00797 fscanf (aux,"%le",&time);
00798
00799 fscanf (aux,"%le",&dt);
00800
00801 fscanf (aux,"%ld",&ni);
00802
00803 fscanf (aux,"%ld",&n);
00804
00805 if (n!=Ndofm){
00806 print_err("number of DOFs in backup file and in the actual problem is not same\n", __FILE__, __LINE__, __func__);
00807 abort();
00808 }
00809
00810
00811 for (i=0;i<n;i++){
00812 fscanf (aux,"%le",r+i);
00813 }
00814
00815 for (i=0;i<n;i++){
00816 fscanf (aux,"%le",fp+i);
00817 }
00818
00819
00820 fscanf (aux,"%ld",&i);
00821
00822 if (i!=Mm->tnip){
00823 print_err("number of integration points in backup file and in the actual problem is not same\n", __FILE__, __LINE__, __func__);
00824 abort();
00825 }
00826
00827 fclose(aux);
00828
00829
00830 Mm->restore_intpoints_txt (Mp->hdbcont.selelemr, Mp->hdbcont.selother_r, Mp->hdbcont.selother_id);
00831
00832
00833 if (Mp->tprob == growing_mech_structure)
00834 {
00835 sprintf(name, "%s.%ld.initdispl.bac",Mp->hdbcont.hdbnames, ni);
00836 aux = fopen(name,"rt");
00837 if (aux==NULL)
00838 {
00839 sprintf(emsg, "cannot open backup file %s", name);
00840 print_err(emsg, __FILE__, __LINE__, __func__);
00841 abort();
00842 }
00843 for (i=0;i<Mt->nn;i++)
00844 {
00845 if (Mt->nodedispl[i] == NULL)
00846 continue;
00847 ndofn = Mt->give_ndofn(i);
00848 for (j=0; j<ndofn; j++)
00849 fscanf(aux,"%le", Mt->nodedispl[i]+j);
00850 }
00851 for (i=0;i<Mt->ne;i++)
00852 {
00853 ndofe = Mt->give_ndofe(i);
00854 for (j=0; j<ndofe; j++)
00855 fscanf(aux,"%le", Mt->elements[i].initdispl+j);
00856 }
00857 }
00858 }
00859
00860
00861
00862
00863
00864
00865
00866
00867
00868
00869
00870
00871
00872
00873
00874
00875
00876
00877
00878 void solver_restore_binary_single (double *r,double *fp,long &ni,double &time, double &dt, timecontr *tc, long &n)
00879 {
00880 long i, ndofn, ndofe;
00881 FILE *aux;
00882 char emsg[FNAMELEN+100];
00883
00884 aux = fopen(Mp->hdbcont.hdbnamer,"rb");
00885 if (aux==NULL)
00886 {
00887 sprintf(emsg, "cannot open backup file %s", Mp->hdbcont.hdbnamer);
00888 print_err(emsg, __FILE__, __LINE__, __func__);
00889 abort();
00890 }
00891
00892
00893 if (tc)
00894 tc->restore_bin(aux);
00895
00896 fread (&time, sizeof(time), 1, aux);
00897
00898 fread (&dt, sizeof(dt), 1, aux);
00899
00900 fread (&ni, sizeof(ni), 1, aux);
00901
00902 fread (&n, sizeof(n), 1, aux);
00903
00904
00905 fread(r, sizeof(*r), n, aux);
00906
00907
00908 fread(fp, sizeof(*fp), n, aux);
00909
00910
00911
00912 fread (&i, sizeof(i), 1, aux);
00913
00914 if (i!=Mm->tnip){
00915 print_err("number of integration points in backup file and in the actual problem is not same\n", __FILE__, __LINE__, __func__);
00916 abort();
00917 }
00918
00919
00920 Mm->restore_intpoints_bin (aux, Mp->hdbcont.selelemr, Mp->hdbcont.selother_r, Mp->hdbcont.selother_id);
00921
00922
00923 if (Mp->tprob == growing_mech_structure)
00924 {
00925 for (i=0;i<Mt->nn;i++)
00926 {
00927 if (Mt->nodedispl[i] == NULL)
00928 continue;
00929 ndofn = Mt->give_ndofn(i);
00930 fread(Mt->nodedispl[i], sizeof(*Mt->nodedispl[i]), ndofn, aux);
00931 }
00932 for (i=0;i<Mt->ne;i++)
00933 {
00934 ndofe = Mt->give_ndofe(i);
00935 fread(Mt->elements[i].initdispl, sizeof(*Mt->elements[i].initdispl), ndofe, aux);
00936 }
00937 }
00938
00939 fclose (aux);
00940 }
00941
00942
00943
00944
00945
00946
00947
00948
00949
00950
00951
00952
00953
00954
00955
00956
00957
00958
00959
00960
00961
00962
00963
00964
00965
00966
00967
00968
00969
00970
00971
00972 void solver_restore_binary_multiple (double *r,double *fp,long &ni,double &time, double &dt, timecontr *tc, long &n)
00973 {
00974 long i, ndofn, ndofe;
00975 FILE *aux;
00976 char name[FNAMELEN+30];
00977 char emsg[FNAMELEN+100];
00978
00979 sprintf(name, "%s.solver.bac",Mp->hdbcont.hdbnamer);
00980 aux = fopen(name,"rb");
00981 if (aux==NULL)
00982 {
00983 sprintf(emsg, "cannot open backup file %s", name);
00984 print_err(emsg, __FILE__, __LINE__, __func__);
00985 abort();
00986 }
00987
00988
00989 if (tc)
00990 tc->restore_bin(aux);
00991
00992 fread (&time, sizeof(time), 1, aux);
00993
00994 fread (&dt, sizeof(dt), 1, aux);
00995
00996 fread (&ni, sizeof(ni), 1, aux);
00997
00998 fread (&n, sizeof(n), 1, aux);
00999
01000
01001 fread(r, sizeof(*r), n, aux);
01002
01003
01004 fread(fp, sizeof(*fp), n, aux);
01005
01006
01007
01008 fread (&i, sizeof(i), 1, aux);
01009
01010 if (i!=Mm->tnip){
01011 print_err("number of integration points in backup file and in the actual problem is not same\n", __FILE__, __LINE__, __func__);
01012 abort();
01013 }
01014
01015 fclose (aux);
01016
01017
01018 Mm->restore_intpoints_bin (Mp->hdbcont.selelemr, Mp->hdbcont.selother_r, Mp->hdbcont.selother_id);
01019
01020
01021 if (Mp->tprob == growing_mech_structure)
01022 {
01023 sprintf(name, "%s.%ld.initdispl.bac",Mp->hdbcont.hdbnames, ni);
01024 aux = fopen(name,"rb");
01025 if (aux==NULL)
01026 {
01027 sprintf(emsg, "cannot open backup file %s", name);
01028 print_err(emsg, __FILE__, __LINE__, __func__);
01029 abort();
01030 }
01031 for (i=0;i<Mt->nn;i++)
01032 {
01033 if (Mt->nodedispl[i] == NULL)
01034 continue;
01035 ndofn = Mt->give_ndofn(i);
01036 fread(Mt->nodedispl[i], sizeof(*Mt->nodedispl[i]), ndofn, aux);
01037 }
01038 for (i=0;i<Mt->ne;i++)
01039 {
01040 ndofe = Mt->give_ndofe(i);
01041 fread(Mt->elements[i].initdispl, sizeof(*Mt->elements[i].initdispl), ndofe, aux);
01042 }
01043 }
01044 }