Ignore:
Timestamp:
05/05/20 06:20:58 (5 years ago)
Author:
bdef
Message:

NEW: adding several averaging methods to pass from substep to main step

File:
1 edited

Legend:

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

    r24360 r24790  
    142142
    143143        _assert_(this);
    144         _assert_(row>=0); 
    145         _assert_(row<this->M); 
     144        _assert_(row>=0);
     145        _assert_(row<this->M);
    146146        _assert_(this->N==1);
    147147
     
    157157                for(int i=0;i<numindices;i++){
    158158                        int row = indices[i];
    159                         _assert_(row>=0); 
    160                         _assert_(row<this->M); 
     159                        _assert_(row>=0);
     160                        _assert_(row<this->M);
    161161                        this->values[row] = values_in[i];
    162162                }
     
    166166                for(int i=0;i<numindices;i++){
    167167                        int row = indices[i];
    168                         _assert_(row>=0); 
    169                         _assert_(row<this->M); 
     168                        _assert_(row>=0);
     169                        _assert_(row<this->M);
    170170                        this->values[row] = values_in[i];
    171171                }
     
    175175                for(int i=0;i<numindices;i++){
    176176                        int row = indices[i];
    177                         _assert_(row>=0); 
    178                         _assert_(row<this->M); 
     177                        _assert_(row>=0);
     178                        _assert_(row<this->M);
    179179                        this->values[row] = values_in[i];
    180180                }
     
    207207        for(int i=0;i<numindices;i++){
    208208                int row = indices[i];
    209                 _assert_(row>=0); 
    210                 _assert_(row<this->M); 
     209                _assert_(row>=0);
     210                _assert_(row<this->M);
    211211                this->element_values[i] = this->values[row];
    212212        }
     
    364364}
    365365/*}}}*/
     366void TriaInput2::Pow(IssmDouble alpha){/*{{{*/
     367
     368        for(int i=0;i<this->M*this->N;i++) this->values[i] = pow(this->values[i],alpha);
     369        for(int i=0;i<TriaRef::NumberofNodes(this->interpolation);i++) this->element_values[i] = pow(this->element_values[i],alpha);
     370}
     371/*}}}*/
    366372void TriaInput2::AXPY(Input2* xinput,IssmDouble alpha){/*{{{*/
    367373
     
    376382}
    377383/*}}}*/
     384void TriaInput2::PointWiseMult(Input2* xinput){/*{{{*/
     385
     386        /*xinput is of the same type, so cast it: */
     387        if(xinput->ObjectEnum()!=TriaInput2Enum) _error_("Operation not permitted because xinput is of type " << EnumToStringx(xinput->ObjectEnum()));
     388        TriaInput2* xtriainput=xDynamicCast<TriaInput2*>(xinput);
     389        if(xtriainput->GetInterpolation()!=this->interpolation) _error_("Operation not permitted because xinput is of type " << EnumToStringx(xinput->ObjectEnum()));
     390
     391        /* we need to check that the vector sizes are identical*/
     392        if(xtriainput->M!=this->M||xtriainput->N!=this->N) _error_("Operation not permitted because the inputs have different sizes");
     393
     394        /*Carry out the AXPY operation depending on type:*/
     395        for(int i=0;i<this->M*this->N;i++) this->values[i] = xtriainput->values[i] * this->values[i];
     396        for(int i=0;i<TriaRef::NumberofNodes(this->interpolation);i++) this->element_values[i] = xtriainput->element_values[i] * this->element_values[i];
     397}
     398/*}}}*/
    378399
    379400/*Object functions*/
Note: See TracChangeset for help on using the changeset viewer.