Changeset 19240


Ignore:
Timestamp:
04/01/15 19:04:37 (10 years ago)
Author:
schlegel
Message:

CHG: revert some file for marshalling

Location:
issm/trunk-jpl/src/c
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/classes/FemModel.cpp

    r19239 r19240  
    624624        /*Create buffer to hold marshalled femmodel: */
    625625        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: */
    627629        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";
    633630       
    634631        /*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;
    638636
    639637        /*write buffer: */
     
    664662        restartfid=pfopen(restartfilename,"r",false);
    665663
    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.
    670665
    671666        /*Figure out size of buffer to be read: */
     
    678673
    679674        /*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!");
    681676        femmodel_buffer_ini=femmodel_buffer; //keep track of the initial position, so as to free later.
    682677
    683678        /*Create new FemModel by demarshalling the buffer: */
    684679        this->Marshall(&femmodel_buffer,NULL,MARSHALLING_BACKWARD);
    685 
    686         /*Reset position of buffer: */
    687         femmodel_buffer=femmodel_buffer_ini;
    688680
    689681        /*Done, close file :*/
     
    698690void FemModel::Marshall(char** pmarshalled_data, int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
    699691
    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;
    705694                delete elements; elements=new Elements();
    706695                delete nodes; nodes=new Nodes();
     
    714703        }
    715704
    716         char ** ptemp=pmarshalled_data;
    717 
    718705        MARSHALLING_ENUM(FemModelEnum);
    719706
    720707        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         }
    725708        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);
    730716        loads->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
    731717        materials->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
    732718        parameters->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
    733         constraints->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
    734719        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         }*/
    755720
    756721}
  • issm/trunk-jpl/src/c/datastructures/DataSet.cpp

    r19239 r19240  
    9090       
    9191        vector<Object*>::iterator obj;
    92         int obj_size=0;
    9392        int obj_enum;
    9493        int i;
    9594
    9695        if(marshall_direction==MARSHALLING_FORWARD || marshall_direction==MARSHALLING_SIZE){
    97                 obj_size=objects.size();
    98         }
    99         else{
    100                 clear();
     96                numsorted=objects.size();
    10197        }
    10298
     
    106102        MARSHALLING(presorted);
    107103        MARSHALLING(numsorted);
     104        MARSHALLING_DYNAMIC(sorted_ids,int,numsorted);
     105        MARSHALLING_DYNAMIC(id_offsets,int,numsorted);
    108106
    109107        /*Now branch according to direction of marshalling: */
    110108        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 
    119109                /*Go through our objects, and marshall them into the buffer: */
    120110                for ( obj=this->objects.begin() ; obj < this->objects.end(); obj++ ){
     
    123113        }
    124114        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 
    135115                /*This is the heart of the demashalling method. We have a buffer coming
    136116                 in, and we are supposed to create a dataset out of it. No such thing
    137117                 as class orientation for buffers, we need to key off the enum of each
    138118                 object stored in the buffer. */
    139                 for(i=0;i<obj_size;i++){
     119                for(i=0;i<this->numsorted;i++){
    140120
    141121                        /*Recover enum of object first: */
     
    147127                         *stored in the buffer: */
    148128                        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);
    154133                        }
    155134                        else if(obj_enum==VertexEnum){
     
    174153                                break;
    175154                        }
    176                         else _error_("could not recognize enum type: " << obj_enum << ": " << EnumToStringx(obj_enum) );
     155                        else _error_("could not recognize enum type: " << obj_enum);
    177156                }
    178157        }
  • issm/trunk-jpl/src/c/shared/io/Marshalling/Marshalling.h

    r19239 r19240  
    5959
    6060
    61 #define MARSHALLING_DYNAMIC(FIELDD,TYPE,SIZE) \
     61#define MARSHALLING_DYNAMIC(FIELD,TYPE,SIZE) \
    6262        \
    6363        {\
    6464                bool field_null=true;\
    65                 if (FIELDD)field_null=false;\
     65                if (FIELD)field_null=false;\
    6666                MARSHALLING(field_null);\
    6767                \
    6868                if(!field_null){\
    6969                        if(marshall_direction==MARSHALLING_FORWARD){\
    70                                         memcpy(*pmarshalled_data,FIELDD,SIZE*sizeof(TYPE));\
     70                                        memcpy(*pmarshalled_data,FIELD,SIZE*sizeof(TYPE));\
    7171                                        *pmarshalled_data+=SIZE*sizeof(TYPE);\
    7272                        }\
     
    7575                        }\
    7676                        else if(marshall_direction==MARSHALLING_BACKWARD){\
    77                                 FIELDD=xNew<TYPE>(SIZE);\
    78                                 memcpy(FIELDD,*pmarshalled_data,SIZE*sizeof(TYPE));\
     77                                FIELD=xNew<TYPE>(SIZE);\
     78                                memcpy(FIELD,*pmarshalled_data,SIZE*sizeof(TYPE));\
    7979                                *pmarshalled_data+=SIZE*sizeof(TYPE);\
    8080                        }\
Note: See TracChangeset for help on using the changeset viewer.