Changeset 19239


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

CHG: The constructor creates new Profiler variables

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

Legend:

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

    r19223 r19239  
    624624        /*Create buffer to hold marshalled femmodel: */
    625625        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";
    627630
    628631        /*Keep track of initial position of femmodel_buffer: */
    629         femmodel_buffer_ini=femmodel_buffer;
     632        //std::cout << "Buffer_ini: " << femmodel_buffer_ini << "\n";
    630633       
    631634        /*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";
    636638
    637639        /*write buffer: */
     
    662664        restartfid=pfopen(restartfilename,"r",false);
    663665
    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        }
    665670
    666671        /*Figure out size of buffer to be read: */
     
    673678
    674679        /*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!");
    676681        femmodel_buffer_ini=femmodel_buffer; //keep track of the initial position, so as to free later.
    677682
    678683        /*Create new FemModel by demarshalling the buffer: */
    679684        this->Marshall(&femmodel_buffer,NULL,MARSHALLING_BACKWARD);
     685
     686        /*Reset position of buffer: */
     687        femmodel_buffer=femmodel_buffer_ini;
    680688
    681689        /*Done, close file :*/
     
    690698void FemModel::Marshall(char** pmarshalled_data, int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
    691699
    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();
    694705                delete elements; elements=new Elements();
    695706                delete nodes; nodes=new Nodes();
     
    703714        }
    704715
     716        char ** ptemp=pmarshalled_data;
     717
    705718        MARSHALLING_ENUM(FemModelEnum);
    706719
    707720        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        }
    708725        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);
    716730        loads->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
    717731        materials->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
    718732        parameters->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
     733        constraints->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
    719734        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        }*/
    720755
    721756}
  • issm/trunk-jpl/src/c/classes/Profiler.cpp

    r19215 r19239  
    7474        MARSHALLING_ENUM(ProfilerEnum);
    7575
    76         if(marshall_direction==MARSHALLING_BACKWARD){
    77                 this->time=new Parameters();
    78                 this->flops=new Parameters();
    79                 this->memory=new Parameters();
    80         }
    81        
    8276        time->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
    8377        flops->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
    8478        memory->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
    85 
    8679
    8780}
  • issm/trunk-jpl/src/c/datastructures/DataSet.cpp

    r19220 r19239  
    9090       
    9191        vector<Object*>::iterator obj;
     92        int obj_size=0;
    9293        int obj_enum;
    9394        int i;
    9495
    9596        if(marshall_direction==MARSHALLING_FORWARD || marshall_direction==MARSHALLING_SIZE){
    96                 numsorted=objects.size();
     97                obj_size=objects.size();
     98        }
     99        else{
     100                clear();
    97101        }
    98102
     
    102106        MARSHALLING(presorted);
    103107        MARSHALLING(numsorted);
    104         MARSHALLING_DYNAMIC(sorted_ids,int,numsorted);
    105         MARSHALLING_DYNAMIC(id_offsets,int,numsorted);
    106108
    107109        /*Now branch according to direction of marshalling: */
    108110        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
    109119                /*Go through our objects, and marshall them into the buffer: */
    110120                for ( obj=this->objects.begin() ; obj < this->objects.end(); obj++ ){
     
    113123        }
    114124        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
    115135                /*This is the heart of the demashalling method. We have a buffer coming
    116136                 in, and we are supposed to create a dataset out of it. No such thing
    117137                 as class orientation for buffers, we need to key off the enum of each
    118138                 object stored in the buffer. */
    119                 for(i=0;i<this->numsorted;i++){
     139                for(i=0;i<obj_size;i++){
    120140
    121141                        /*Recover enum of object first: */
     
    127147                         *stored in the buffer: */
    128148                        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;
    133154                        }
    134155                        else if(obj_enum==VertexEnum){
     
    153174                                break;
    154175                        }
    155                         else _error_("could not recognize enum type: " << obj_enum);
     176                        else _error_("could not recognize enum type: " << obj_enum << ": " << EnumToStringx(obj_enum) );
    156177                }
    157178        }
  • issm/trunk-jpl/src/c/shared/io/Marshalling/Marshalling.h

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