Changeset 22264
- Timestamp:
- 11/16/17 14:05:37 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/analyses/Balancethickness2Analysis.cpp
r22178 r22264 71 71 72 72 /*Intermediaries */ 73 int n=3;74 IssmDouble Jdet, omega,ds[2],slope;73 IssmDouble yts = 365*24*3600.; 74 IssmDouble Jdet,vx,vy,vel; 75 75 IssmDouble* xyz_list = NULL; 76 76 … … 84 84 /*Retrieve all inputs and parameters*/ 85 85 element->GetVerticesCoordinates(&xyz_list); 86 Input* omega_input = element->GetInput(BalancethicknessOmegaEnum); _assert_(omega_input); 87 Input* surfaceslopex_input = element->GetInput(SurfaceSlopeXEnum); _assert_(surfaceslopex_input); 88 Input* surfaceslopey_input = element->GetInput(SurfaceSlopeYEnum); _assert_(surfaceslopey_input); 89 IssmDouble rhog = element->GetMaterialParameter(MaterialsRhoIceEnum)*element->GetMaterialParameter(ConstantsGEnum); 86 Input* vx_input = element->GetInput(SurfaceSlopeXEnum); _assert_(vx_input); 87 Input* vy_input = element->GetInput(SurfaceSlopeYEnum); _assert_(vy_input); 88 89 /*make sure are diffusivisty is large enough*/ 90 vel = sqrt(vx*vx+vy*vy); 91 if(sqrt(vx*vx+vy*vy)==0.){ 92 vx = 0.1/yts; 93 vy = 0.1/yts; 94 } 95 else if(vel<0.1/yts){ 96 vx = vx/vel*0.1; 97 vy = vy/vel*0.1; 98 99 } 90 100 91 101 /* Start looping on the number of gaussian points: */ … … 95 105 element->NodalFunctionsDerivatives(dbasis,xyz_list,gauss); 96 106 element->JacobianDeterminant(&Jdet,xyz_list,gauss); 97 omega_input->GetInputValue(&omega,gauss); 98 surfaceslopex_input->GetInputValue(&ds[0],gauss); 99 surfaceslopey_input->GetInputValue(&ds[1],gauss); 100 101 slope = sqrt(ds[0]*ds[0] + ds[1]*ds[1]); 107 vx_input->GetInputValue(&vx,gauss); 108 vy_input->GetInputValue(&vy,gauss); 102 109 103 110 for(int i=0;i<numnodes;i++){ 104 111 for(int j=0;j<numnodes;j++){ 105 Ke->values[i*numnodes+j] += pow(rhog,n)*exp(omega)*pow(slope,n-1)*gauss->weight*Jdet*(dbasis[0*numnodes+i]*dbasis[0*numnodes+j] +dbasis[1*numnodes+i]*dbasis[1*numnodes+j]);112 Ke->values[i*numnodes+j] += gauss->weight*Jdet*(vx*dbasis[0*numnodes+i]*dbasis[0*numnodes+j] + vy*dbasis[1*numnodes+i]*dbasis[1*numnodes+j]); 106 113 } 107 114 } … … 117 124 118 125 /*Intermediaries */ 119 IssmDouble dhdt ,mb,ms,Jdet;126 IssmDouble dhdt[2],mb[2],ms[2],Jdet; 120 127 IssmDouble* xyz_list = NULL; 121 128 … … 141 148 element->NodalFunctions(basis,gauss); 142 149 143 ms_input->GetInputValue(&ms,gauss); 144 mb_input->GetInputValue(&mb,gauss); 145 dhdt_input->GetInputValue(&dhdt,gauss); 150 ms_input->GetInputDerivativeValue(&ms[0],xyz_list,gauss); 151 152 ms_input->GetInputDerivativeValue(&ms[0],xyz_list,gauss); 153 mb_input->GetInputDerivativeValue(&mb[0],xyz_list,gauss); 154 dhdt_input->GetInputDerivativeValue(&dhdt[0],xyz_list,gauss); 146 155 147 156 for(int i=0;i<numnodes;i++) pe->values[i]+=Jdet*gauss->weight*( 148 (ms -mb-dhdt)*basis[i]157 (ms[0]+ms[1]-mb[0]-mb[1]-dhdt[0]-dhdt[1])*basis[i] 149 158 ); 150 159 } … … 157 166 }/*}}}*/ 158 167 void Balancethickness2Analysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/ 159 element->GetSolutionFromInputsOneDof(solution, SurfaceEnum);168 element->GetSolutionFromInputsOneDof(solution,ThicknessEnum); 160 169 }/*}}}*/ 161 170 void Balancethickness2Analysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/ … … 164 173 void Balancethickness2Analysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/ 165 174 166 /*Intermediaries*/ 167 IssmDouble ds[2],s,b,D; 168 IssmDouble* xyz_list = NULL; 175 element->InputUpdateFromSolutionOneDof(solution,ThicknessEnum); 169 176 170 //element->InputUpdateFromSolutionOneDof(solution,ThicknessEnum);171 element->InputUpdateFromSolutionOneDof(solution,SurfaceEnum);172 173 /*Fetch number of vertices and allocate velocity vectors*/174 int numvertices = element->GetNumberOfVertices();175 IssmDouble* vel_list = xNew<IssmDouble>(numvertices);176 IssmDouble* vx_list = xNew<IssmDouble>(numvertices);177 IssmDouble* vy_list = xNew<IssmDouble>(numvertices);178 179 /*Retrieve all inputs and parameters*/180 element->GetVerticesCoordinates(&xyz_list);181 Input* D_input = element->GetInput(BalancethicknessDiffusionCoefficientEnum);182 Input* H_input = element->GetInput(ThicknessEnum); _assert_(H_input);183 Input* s_input = element->GetInput(SurfaceEnum); _assert_(s_input);184 Input* b_input = element->GetInput(BaseEnum); _assert_(b_input);185 186 /*Calculate velocities*/187 Gauss* gauss=element->NewGauss();188 for(int iv=0;iv<numvertices;iv++){189 gauss->GaussVertex(iv);190 191 if(D_input){192 D_input->GetInputValue(&D,gauss);193 }194 else{195 D = 0.;196 }197 b_input->GetInputValue(&b,gauss);198 s_input->GetInputValue(&s,gauss);199 s_input->GetInputDerivativeValue(&ds[0],xyz_list,gauss);200 201 vx_list[iv] = -1./(s-b)*D*ds[0];202 vy_list[iv] = -1./(s-b)*D*ds[1];203 vel_list[iv] = sqrt(pow(vx_list[iv],2) + pow(vy_list[iv],2));204 }205 206 /*Add vx and vy as inputs to the tria element: */207 element->AddInput(VxEnum,vx_list,P1Enum);208 element->AddInput(VyEnum,vy_list,P1Enum);209 element->AddInput(VelEnum,vel_list,P1Enum);210 211 /*Free ressources:*/212 delete gauss;213 xDelete<IssmDouble>(vy_list);214 xDelete<IssmDouble>(vx_list);215 xDelete<IssmDouble>(vel_list);216 xDelete<IssmDouble>(xyz_list);217 177 }/*}}}*/ 218 178 void Balancethickness2Analysis::UpdateConstraints(FemModel* femmodel){/*{{{*/
Note:
See TracChangeset
for help on using the changeset viewer.