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