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
RevLine 
[18296]1Index: ../trunk-jpl/src/c/classes/Elements/Element.cpp
2===================================================================
3--- ../trunk-jpl/src/c/classes/Elements/Element.cpp (revision 18174)
4+++ ../trunk-jpl/src/c/classes/Elements/Element.cpp (revision 18175)
5@@ -186,18 +186,23 @@
6 /*Compute element divergence*/
7
8 /*Intermediaries*/
9+ int dim;
10 IssmDouble Jdet;
11 IssmDouble divergence=0.;
12 IssmDouble dvx[3],dvy[3],dvz[3];
13 IssmDouble *xyz_list = NULL;
14
15 /*Get inputs and parameters*/
16- Input* vx_input = this->GetInput(VxEnum); _assert_(vx_input);
17- Input* vy_input = this->GetInput(VyEnum); _assert_(vy_input);
18- Input* vz_input = this->GetInput(VzEnum); _assert_(vz_input);
19+ this->FindParam(&dim,DomainDimensionEnum);
20+ Input* vx_input = this->GetInput(VxEnum); _assert_(vx_input);
21+ Input* vy_input = this->GetInput(VyEnum); _assert_(vy_input);
22+ Input* vz_input = NULL;
23+ if(dim==3){
24+ vz_input = this->GetInput(VzEnum); _assert_(vz_input);
25+ }
26 this->GetVerticesCoordinates(&xyz_list);
27
28- Gauss* gauss=this->NewGaussBase(5);
29+ Gauss* gauss=this->NewGauss(5);
30 for(int ig=gauss->begin();ig<gauss->end();ig++){
31 gauss->GaussPoint(ig);
32 this->JacobianDeterminant(&Jdet,xyz_list,gauss);
33@@ -205,9 +210,14 @@
34 /*Get strain rate assuming that epsilon has been allocated*/
35 vx_input->GetInputDerivativeValue(&dvx[0],xyz_list,gauss);
36 vy_input->GetInputDerivativeValue(&dvy[0],xyz_list,gauss);
37- vz_input->GetInputDerivativeValue(&dvz[0],xyz_list,gauss);
38+ if(dim==2){
39+ divergence += (dvx[0]+dvy[1])*gauss->weight*Jdet;
40+ }
41+ else{
42+ vz_input->GetInputDerivativeValue(&dvz[0],xyz_list,gauss);
43+ divergence += (dvx[0]+dvy[1]+dvz[2])*gauss->weight*Jdet;
44+ }
45
46- divergence += (dvx[0]+dvy[1]+dvz[2])*gauss->weight*Jdet;
47 }
48
49 /*Clean up and return*/
Note: See TracBrowser for help on using the repository browser.