Changeset 25580


Ignore:
Timestamp:
09/17/20 15:44:24 (5 years ago)
Author:
Mathieu Morlighem
Message:

CHG: no need to look at type anymore for dependents

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

Legend:

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

    r25524 r25580  
    1616DependentObject::DependentObject(){/*{{{*/
    1717        this->name=NULL;
    18         this->type=0;
    1918        this->index=-1;
    2019        this->response_value=0.;
    2120}
    2221/*}}}*/
    23 DependentObject::DependentObject(char* in_name, int in_type,int in_index){/*{{{*/
     22DependentObject::DependentObject(char* in_name,int in_index){/*{{{*/
    2423
    2524        this->name=xNew<char>(strlen(in_name)+1); xMemCpy<char>(this->name,in_name,strlen(in_name)+1);
    26         this->type=in_type;
    2725        this->index=in_index;
    28         if(in_type!=0 && in_type!=1)_error_("cannot create an DependentObject of type " << in_type);
    29         if(in_type==1)_error_("not implemented yet!");
    3026        this->response_value=0.;
    3127
    32 }
    33 /*}}}*/
    34 DependentObject::DependentObject(char* in_name, int in_type,int in_index,IssmDouble in_response){/*{{{*/
     28}/*}}}*/
     29DependentObject::DependentObject(char* in_name,int in_index,IssmDouble in_response){/*{{{*/
    3530
    3631        this->name=xNew<char>(strlen(in_name)+1); xMemCpy<char>(this->name,in_name,strlen(in_name)+1);
    37         this->type=in_type;
    3832        this->index=in_index;
    39         if(in_type!=0 && in_type!=1)_error_("cannot create an DependentObject of type " << in_type);
    40         if(in_type==1)_error_("not implemented yet!");
    4133        this->response_value=in_response;
    4234
    43 }
    44 /*}}}*/
     35}/*}}}*/
    4536DependentObject::~DependentObject(){ //destructor/*{{{*/
    4637        xDelete<char>(this->name);
    47 }
    48 /*}}}*/
     38}/*}}}*/
    4939
    5040/*Object virtual functions definitions:*/
    5141Object* DependentObject::copy(void) { /*{{{*/
    52         return new DependentObject(name,type,index,response_value);
     42        return new DependentObject(name,index,response_value);
    5343} /*}}}*/
    5444void DependentObject::DeepEcho(void){/*{{{*/
     
    6050        _printf_("DependentObject:\n");
    6151        _printf_("   name: " << this->name << "\n");
    62         if(this->type==0)
    63                 _printf_("   type: scalar\n");
    64         else if(this->type==1)
    65                 _printf_("   type: vertex\n");
    66         else
    67                 _error_(" unknown type: " << this->type);
    6852        if(this->index>=0) _printf_("   index: " << this->index << "\n");
     53        _printf_("   value: " << this->value << "\n");
    6954}
    7055/*}}}*/
    71 int    DependentObject::Id(void){ return -1; }/*{{{*/
     56int  DependentObject::Id(void){ return -1; }/*{{{*/
    7257/*}}}*/
    73 int DependentObject::ObjectEnum(void){/*{{{*/
     58int  DependentObject::ObjectEnum(void){/*{{{*/
    7459
    7560        return DependentObjectEnum;
     
    7762}
    7863/*}}}*/
    79 void    DependentObject::Marshall(MarshallHandle* marshallhandle){/*{{{*/
     64void DependentObject::Marshall(MarshallHandle* marshallhandle){/*{{{*/
    8065
    8166        int object_enum = DependentObjectEnum;
     
    8570        marshallhandle->call(this->name);
    8671
    87         marshallhandle->call(this->type);
    8872        marshallhandle->call(this->index);
    8973        marshallhandle->call(this->response_value);
    90 }
    91 /*}}}*/
     74}/*}}}*/
    9275
    9376/*DependentObject methods: */
    94 int  DependentObject::NumDependents(void){/*{{{*/
    95 
    96         /*Branch according to the type of variable: */
    97         if(type==0){ /*scalar:*/
    98                 return 1;
    99         }
    100         else if(type==1){ /* vector:*/
    101                 _error_("not implemented yet!");
    102         }
    103         else _error_("should not have a type of " << type);
    104 }
    105 /*}}}*/
    10677void  DependentObject::Responsex(IssmDouble* poutput_value,FemModel* femmodel){/*{{{*/
    10778
  • issm/trunk-jpl/src/c/classes/DependentObject.h

    r25524 r25580  
    1818
    1919                char* name;
    20                 int type;  /*0: scalar, 1: vertex*/
    21                 int index;  /*0: scalar, 1: vertex*/
     20                int   index;  /*0: scalar, 1: vertex*/
    2221                IssmDouble response_value;
    2322
    2423                /*DependentObject constructors, destructors */
    2524                DependentObject();
    26                 DependentObject(char* name, int type,int index);
    27                 DependentObject(char* name, int type,int index,IssmDouble in_response);
     25                DependentObject(char* name,int index);
     26                DependentObject(char* name,int index,IssmDouble in_response);
    2827                ~DependentObject();
    2928
    3029                /*Object virtual functions definitions*/
    31                 Object* copy(void);
    32                 void  DeepEcho();
    33                 void  Echo();
    34                 int   Id();
    35                 int   ObjectEnum();
    36                 void  Marshall(MarshallHandle* marshallhandle);
     30                Object *copy(void);
     31                void    DeepEcho();
     32                void    Echo();
     33                int     Id();
     34                int     ObjectEnum();
     35                void    Marshall(MarshallHandle  *marshallhandle);
    3736
    3837                /*DependentObject methods: */
    39                 int  NumDependents(void);
    40                 void Responsex(IssmDouble* poutput_value,FemModel* femmodel);
     38                void       Responsex(IssmDouble *poutput_value,FemModel*femmodel);
    4139                IssmDouble GetValue(void);
    42                 void AddValue(IssmDouble in_value);
    43                 void ResetResponseValue(void);
     40                void       AddValue(IssmDouble in_value);
     41                void       ResetResponseValue(void);
    4442
    4543};
  • issm/trunk-jpl/src/c/modules/ModelProcessorx/Autodiff/CreateParametersAutodiff.cpp

    r23267 r25580  
    1515        int         num_dep=0;
    1616        char**      names=NULL;
    17         int*        types=NULL;
    1817        int         dummy;
    1918        char*       autodiff_driver=NULL;
     
    152151                if(num_dependent_objects){
    153152                        iomodel->FindConstant(&names,&dummy,"md.autodiff.dependent_object_names");
    154                         iomodel->FetchData(&types,&dummy,&dummy,"md.autodiff.dependent_object_types");
    155153                        iomodel->FetchData(&indices,&dummy,&dummy,"md.autodiff.dependent_object_indices");
    156154
    157155                        for(i=0;i<num_dependent_objects;i++){
    158                                 DependentObject* dep=new DependentObject(names[i],types[i],indices[i]);
     156                                DependentObject* dep=new DependentObject(names[i],indices[i]);
    159157                                dependent_objects->AddObject(dep);
    160                                 num_dep+=dep->NumDependents();
     158                                num_dep++;
    161159                        }
    162160
     
    166164                        }
    167165                        xDelete<char*>(names);
    168                         xDelete<int>(types);
    169166                        xDelete<int>(indices);
    170167                }
Note: See TracChangeset for help on using the changeset viewer.