Changeset 19239
- Timestamp:
- 04/01/15 19:01:25 (10 years ago)
- Location:
- issm/trunk-jpl/src/c
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/classes/FemModel.cpp
r19223 r19239 624 624 /*Create buffer to hold marshalled femmodel: */ 625 625 this->Marshall(NULL,&femmodel_size,MARSHALLING_SIZE); 626 femmodel_buffer=xNew<char>(femmodel_size); 626 femmodel_buffer=xNew<char>(femmodel_size+1); 627 femmodel_buffer_ini=femmodel_buffer; 628 std::cout << "Model size: " << femmodel_size << "\n"; 629 std::cout << "Buffer: " << &femmodel_buffer << "\n"; 627 630 628 631 /*Keep track of initial position of femmodel_buffer: */ 629 femmodel_buffer_ini=femmodel_buffer;632 //std::cout << "Buffer_ini: " << femmodel_buffer_ini << "\n"; 630 633 631 634 /*Marshall:*/ 632 this->Marshall(&femmodel_buffer,NULL,MARSHALLING_FORWARD); 633 634 /*Reset position of buffer: */ 635 femmodel_buffer=femmodel_buffer_ini; 635 this->Marshall(&femmodel_buffer_ini,NULL,MARSHALLING_FORWARD); 636 637 std::cout << "Buffer_new: " << &femmodel_buffer << "\n"; 636 638 637 639 /*write buffer: */ … … 662 664 restartfid=pfopen(restartfilename,"r",false); 663 665 664 if(restartfid==NULL)return; //could not find the file, so no restart possible. 666 if(restartfid==NULL){ 667 xDelete<char>(restartfilename); 668 return; //could not find the file, so no restart possible. 669 } 665 670 666 671 /*Figure out size of buffer to be read: */ … … 673 678 674 679 /*Read buffer from file: */ 675 fread_return=fread(femmodel_buffer,femmodel_size, 1,restartfid); if(fread_return!=1)_error_("error reading the buffer from marshalled file!");680 fread_return=fread(femmodel_buffer,femmodel_size,sizeof(char),restartfid); if(fread_return!=1)_error_("error reading the buffer from marshalled file!"); 676 681 femmodel_buffer_ini=femmodel_buffer; //keep track of the initial position, so as to free later. 677 682 678 683 /*Create new FemModel by demarshalling the buffer: */ 679 684 this->Marshall(&femmodel_buffer,NULL,MARSHALLING_BACKWARD); 685 686 /*Reset position of buffer: */ 687 femmodel_buffer=femmodel_buffer_ini; 680 688 681 689 /*Done, close file :*/ … … 690 698 void FemModel::Marshall(char** pmarshalled_data, int* pmarshalled_data_size, int marshall_direction){ /*{{{*/ 691 699 692 if(marshall_direction==MARSHALLING_BACKWARD){ 693 delete profiler; profiler=new Profiler; 700 int i; 701 int analysis_type; 702 703 if(false && marshall_direction==MARSHALLING_BACKWARD){ 704 delete profiler; profiler=new Profiler(); 694 705 delete elements; elements=new Elements(); 695 706 delete nodes; nodes=new Nodes(); … … 703 714 } 704 715 716 char ** ptemp=pmarshalled_data; 717 705 718 MARSHALLING_ENUM(FemModelEnum); 706 719 707 720 MARSHALLING(solution_type); 721 if(marshall_direction!=MARSHALLING_SIZE){ 722 std::cout << "Buffer_2: " << pmarshalled_data << "\n"; 723 std::cout << "Buffer_old: " << ptemp << "\n"; 724 } 708 725 MARSHALLING(analysis_counter); 709 MARSHALLING_DYNAMIC(analysis_type_list,int,analysis_counter); 710 711 profiler->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction); 712 elements->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction); 713 nodes->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction); 714 vertices->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction); 715 constraints->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction); 726 MARSHALLING(nummodels); 727 MARSHALLING_DYNAMIC(analysis_type_list,int,nummodels); 728 729 /* profiler->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction); 716 730 loads->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction); 717 731 materials->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction); 718 732 parameters->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction); 733 constraints->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction); 719 734 results->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction); 735 nodes->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction); 736 vertices->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction); 737 elements->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction); 738 739 if(marshall_direction==MARSHALLING_BACKWARD){ 740 //reset hooks for elements, loads and nodes: 741 elements->ResetHooks(); 742 loads->ResetHooks(); 743 materials->ResetHooks(); 744 745 //do the post-processing of the datasets to get an FemModel that can actually run analyses: 746 for(i=0;i<nummodels;i++){ 747 analysis_type=analysis_type_list[i]; 748 SetCurrentConfiguration(analysis_type); 749 if(i==0) VerticesDofx(vertices,parameters); //only call once, we only have one set of vertices 750 SpcNodesx(nodes,constraints,parameters,analysis_type); 751 NodesDofx(nodes,parameters,analysis_type); 752 ConfigureObjectsx(elements,loads,nodes,vertices,materials,parameters); 753 } 754 }*/ 720 755 721 756 } -
issm/trunk-jpl/src/c/classes/Profiler.cpp
r19215 r19239 74 74 MARSHALLING_ENUM(ProfilerEnum); 75 75 76 if(marshall_direction==MARSHALLING_BACKWARD){77 this->time=new Parameters();78 this->flops=new Parameters();79 this->memory=new Parameters();80 }81 82 76 time->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction); 83 77 flops->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction); 84 78 memory->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction); 85 86 79 87 80 } -
issm/trunk-jpl/src/c/datastructures/DataSet.cpp
r19220 r19239 90 90 91 91 vector<Object*>::iterator obj; 92 int obj_size=0; 92 93 int obj_enum; 93 94 int i; 94 95 95 96 if(marshall_direction==MARSHALLING_FORWARD || marshall_direction==MARSHALLING_SIZE){ 96 numsorted=objects.size(); 97 obj_size=objects.size(); 98 } 99 else{ 100 clear(); 97 101 } 98 102 … … 102 106 MARSHALLING(presorted); 103 107 MARSHALLING(numsorted); 104 MARSHALLING_DYNAMIC(sorted_ids,int,numsorted);105 MARSHALLING_DYNAMIC(id_offsets,int,numsorted);106 108 107 109 /*Now branch according to direction of marshalling: */ 108 110 if(marshall_direction==MARSHALLING_FORWARD || marshall_direction==MARSHALLING_SIZE){ 111 if(!(this->sorted && numsorted>0 && this->id_offsets)){ 112 sorted_ids=NULL; 113 id_offsets=NULL; 114 } 115 MARSHALLING_DYNAMIC(sorted_ids,int,numsorted); 116 MARSHALLING_DYNAMIC(id_offsets,int,numsorted); 117 MARSHALLING(obj_size); 118 109 119 /*Go through our objects, and marshall them into the buffer: */ 110 120 for ( obj=this->objects.begin() ; obj < this->objects.end(); obj++ ){ … … 113 123 } 114 124 else{ 125 126 MARSHALLING_DYNAMIC(sorted_ids,int,numsorted); 127 MARSHALLING_DYNAMIC(id_offsets,int,numsorted); 128 if (!(this->sorted && numsorted>0)){ 129 sorted_ids=NULL; 130 sorted_ids=NULL; 131 } 132 133 MARSHALLING(obj_size); 134 115 135 /*This is the heart of the demashalling method. We have a buffer coming 116 136 in, and we are supposed to create a dataset out of it. No such thing 117 137 as class orientation for buffers, we need to key off the enum of each 118 138 object stored in the buffer. */ 119 for(i=0;i< this->numsorted;i++){139 for(i=0;i<obj_size;i++){ 120 140 121 141 /*Recover enum of object first: */ … … 127 147 *stored in the buffer: */ 128 148 if(obj_enum==NodeEnum){ 129 Node* node=NULL; 130 node=new Node(); 131 node->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction); 132 this->AddObject(node); 149 Node* node=NULL; 150 node=new Node(); 151 node->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction); 152 this->AddObject(node); 153 break; 133 154 } 134 155 else if(obj_enum==VertexEnum){ … … 153 174 break; 154 175 } 155 else _error_("could not recognize enum type: " << obj_enum );176 else _error_("could not recognize enum type: " << obj_enum << ": " << EnumToStringx(obj_enum) ); 156 177 } 157 178 } -
issm/trunk-jpl/src/c/shared/io/Marshalling/Marshalling.h
r19219 r19239 59 59 60 60 61 #define MARSHALLING_DYNAMIC(FIELD ,TYPE,SIZE) \61 #define MARSHALLING_DYNAMIC(FIELDD,TYPE,SIZE) \ 62 62 \ 63 63 {\ 64 64 bool field_null=true;\ 65 if (FIELD )field_null=false;\65 if (FIELDD)field_null=false;\ 66 66 MARSHALLING(field_null);\ 67 67 \ 68 68 if(!field_null){\ 69 69 if(marshall_direction==MARSHALLING_FORWARD){\ 70 memcpy(*pmarshalled_data,FIELD ,SIZE*sizeof(TYPE));\70 memcpy(*pmarshalled_data,FIELDD,SIZE*sizeof(TYPE));\ 71 71 *pmarshalled_data+=SIZE*sizeof(TYPE);\ 72 72 }\ … … 75 75 }\ 76 76 else if(marshall_direction==MARSHALLING_BACKWARD){\ 77 FIELD =xNew<TYPE>(SIZE);\78 memcpy(FIELD ,*pmarshalled_data,SIZE*sizeof(TYPE));\77 FIELDD=xNew<TYPE>(SIZE);\ 78 memcpy(FIELDD,*pmarshalled_data,SIZE*sizeof(TYPE));\ 79 79 *pmarshalled_data+=SIZE*sizeof(TYPE);\ 80 80 }\
Note:
See TracChangeset
for help on using the changeset viewer.