Changeset 23574


Ignore:
Timestamp:
12/27/18 20:17:59 (6 years ago)
Author:
Mathieu Morlighem
Message:

CHG: fixing marshall and copy for dakota

Location:
issm/trunk-jpl/src/c/classes
Files:
2 edited

Legend:

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

    r23573 r23574  
    4646
    4747/*Numerics*/
     48Nodes* Nodes::Copy() {/*{{{*/
     49
     50        int num_proc = IssmComm::GetSize();
     51
     52        /*Copy dataset*/
     53        Nodes* output=new Nodes();
     54        output->sorted=this->sorted;
     55        output->numsorted=this->numsorted;
     56        output->presorted=this->presorted;
     57        for(vector<Object*>::iterator obj=this->objects.begin() ; obj < this->objects.end(); obj++ ){
     58                output->AddObject((*obj)->copy());
     59        }
     60
     61        /*Build id_offsets and sorted_ids*/
     62        int objsize = this->numsorted;
     63        if(this->sorted && objsize>0 && this->id_offsets){     
     64                /*Allocate new ids*/
     65                output->id_offsets=xNew<int>(objsize);
     66                xMemCpy<int>(output->id_offsets,this->id_offsets,objsize);
     67        }
     68        else output->id_offsets=NULL;
     69        if(this->sorted && objsize>0 && this->sorted_ids){
     70                /*Allocate new ids*/
     71                output->sorted_ids=xNew<int>(objsize);
     72                xMemCpy<int>(output->sorted_ids,this->sorted_ids,objsize);
     73        }
     74        else output->sorted_ids=NULL;
     75
     76
     77        if(this->common_recv){
     78                output->common_recv=xNew<int>(num_proc);
     79                for(int i=0;i<num_proc;i++) output->common_recv[i]=this->common_recv[i];
     80        }
     81        if(this->common_send){
     82                output->common_send=xNew<int>(num_proc);
     83                for(int i=0;i<num_proc;i++) output->common_send[i]=this->common_send[i];
     84        }
     85        if(this->common_recv_ids){
     86                output->common_recv_ids = xNew<int*>(num_proc);
     87                for(int i=0;i<num_proc;i++){
     88                        output->common_recv_ids[i]=xNew<int>(this->common_recv[i]);
     89                        for(int j=0;j<this->common_recv[i];j++) output->common_recv_ids[i][j]=this->common_recv_ids[i][j];
     90                }
     91        }
     92        if(this->common_send_ids){
     93                output->common_send_ids = xNew<int*>(num_proc);
     94                for(int i=0;i<num_proc;i++){
     95                        output->common_send_ids[i]=xNew<int>(this->common_send[i]);
     96                        for(int j=0;j<this->common_send[i];j++) output->common_send_ids[i][j]=this->common_send_ids[i][j];
     97                }
     98        }
     99
     100        return output;
     101}
     102/*}}}*/
     103void Nodes::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
     104
     105        int num_procs=IssmComm::GetSize();
     106        int test = num_procs;
     107        MARSHALLING_ENUM(NodesEnum);
     108        MARSHALLING(test);
     109        if(test!=num_procs) _error_("number of cores is not the same as before");
     110        MARSHALLING_DYNAMIC(this->common_recv,int,num_procs);
     111        MARSHALLING_DYNAMIC(this->common_send,int,num_procs);
     112        if(marshall_direction == MARSHALLING_BACKWARD){
     113                this->common_recv_ids = xNew<int*>(num_procs);
     114                this->common_send_ids = xNew<int*>(num_procs);
     115        }
     116        for(int i=0;i<num_procs;i++){
     117                MARSHALLING_DYNAMIC(this->common_recv_ids[i],int,this->common_recv[i]);
     118                MARSHALLING_DYNAMIC(this->common_send_ids[i],int,this->common_send[i]);
     119        }
     120        DataSet::Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
     121}
     122/*}}}*/
    48123void  Nodes::DistributeDofs(int analysis_type,int setenum){/*{{{*/
    49124
  • issm/trunk-jpl/src/c/classes/Nodes.h

    r23573 r23574  
    2828                ~Nodes();
    2929
     30                /*Objects virtual functions*/
     31                Nodes* Copy();
     32                void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
     33
    3034                /*numerics*/
    3135                void  DistributeDofs(int analysis_type,int SETENUM);
Note: See TracChangeset for help on using the changeset viewer.