source: issm/oecreview/Archive/17984-18295/ISSM-18174-18175.diff@ 18296

Last change on this file since 18296 was 18296, checked in by Mathieu Morlighem, 11 years ago

Added 17984-18295

File size: 1.8 KB
  • ../trunk-jpl/src/c/classes/Elements/Element.cpp

     
    186186        /*Compute element divergence*/
    187187
    188188        /*Intermediaries*/
     189        int        dim;
    189190        IssmDouble Jdet;
    190191        IssmDouble divergence=0.;
    191192        IssmDouble dvx[3],dvy[3],dvz[3];
    192193        IssmDouble *xyz_list = NULL;
    193194
    194195        /*Get inputs and parameters*/
    195         Input* vx_input        = this->GetInput(VxEnum); _assert_(vx_input);
    196         Input* vy_input        = this->GetInput(VyEnum); _assert_(vy_input);
    197         Input* vz_input        = this->GetInput(VzEnum); _assert_(vz_input);
     196        this->FindParam(&dim,DomainDimensionEnum);
     197        Input* vx_input = this->GetInput(VxEnum); _assert_(vx_input);
     198        Input* vy_input = this->GetInput(VyEnum); _assert_(vy_input);
     199        Input* vz_input = NULL;
     200        if(dim==3){
     201                vz_input = this->GetInput(VzEnum); _assert_(vz_input);
     202        }
    198203        this->GetVerticesCoordinates(&xyz_list);
    199204
    200         Gauss* gauss=this->NewGaussBase(5);
     205        Gauss* gauss=this->NewGauss(5);
    201206        for(int ig=gauss->begin();ig<gauss->end();ig++){
    202207                gauss->GaussPoint(ig);
    203208                this->JacobianDeterminant(&Jdet,xyz_list,gauss);
     
    205210                /*Get strain rate assuming that epsilon has been allocated*/
    206211                vx_input->GetInputDerivativeValue(&dvx[0],xyz_list,gauss);
    207212                vy_input->GetInputDerivativeValue(&dvy[0],xyz_list,gauss);
    208                 vz_input->GetInputDerivativeValue(&dvz[0],xyz_list,gauss);
     213                if(dim==2){
     214                        divergence += (dvx[0]+dvy[1])*gauss->weight*Jdet;
     215                }
     216                else{
     217                        vz_input->GetInputDerivativeValue(&dvz[0],xyz_list,gauss);
     218                        divergence += (dvx[0]+dvy[1]+dvz[2])*gauss->weight*Jdet;
     219                }
    209220
    210                 divergence += (dvx[0]+dvy[1]+dvz[2])*gauss->weight*Jdet;
    211221        }
    212222
    213223        /*Clean up and return*/
Note: See TracBrowser for help on using the repository browser.