Changeset 16700
- Timestamp:
- 11/11/13 09:13:28 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/analyses/StressbalanceVerticalAnalysis.cpp
r16684 r16700 100 100 }/*}}}*/ 101 101 void StressbalanceVerticalAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/ 102 _error_("not implemented yet"); 103 }/*}}}*/ 102 103 int numnodes = element->GetNumberOfNodes(); 104 int numdof=numnodes*1; 105 106 int i; 107 int approximation; 108 int* doflist = NULL; 109 IssmDouble* xyz_list = NULL; 110 IssmDouble rho_ice,g; 111 112 IssmDouble* values = xNew<IssmDouble>(numdof); 113 IssmDouble* vx = xNew<IssmDouble>(numnodes); 114 IssmDouble* vy = xNew<IssmDouble>(numnodes); 115 IssmDouble* vz = xNew<IssmDouble>(numnodes); 116 IssmDouble* vzSSA = xNew<IssmDouble>(numnodes); 117 IssmDouble* vzHO = xNew<IssmDouble>(numnodes); 118 IssmDouble* vzFS = xNew<IssmDouble>(numnodes); 119 IssmDouble* vel = xNew<IssmDouble>(numnodes); 120 IssmDouble* pressure = xNew<IssmDouble>(numnodes); 121 IssmDouble* surface = xNew<IssmDouble>(numnodes); 122 123 /*Get the approximation and do nothing if the element in FS or None*/ 124 element->GetInputValue(&approximation,ApproximationEnum); 125 if(approximation==FSApproximationEnum || approximation==NoneApproximationEnum){ 126 return; 127 } 128 129 /*Get dof list and vertices coordinates: */ 130 element->GetVerticesCoordinates(&xyz_list); 131 element->GetDofList(&doflist,NoneApproximationEnum,GsetEnum); 132 133 /*Use the dof list to index into the solution vector vz: */ 134 for(i=0;i<numdof;i++) values[i]=solution[doflist[i]]; 135 for(i=0;i<numdof;i++){ 136 vz[i]=values[i*1+0]; 137 138 /*Check solution*/ 139 if(xIsNan<IssmDouble>(vz[i])) _error_("NaN found in solution vector"); 140 } 141 142 /*Get Vx and Vy*/ 143 element->GetInputListOnNodes(&vx[0],VxEnum,0.0); //default is 0 144 element->GetInputListOnNodes(&vy[0],VyEnum,0.0); //default is 0 145 146 /*Do some modifications if we actually have a HOFS or SSAFS element*/ 147 if(approximation==HOFSApproximationEnum){ 148 Input* vzFS_input=element->GetInput(VzFSEnum); 149 if (vzFS_input){ 150 if (vzFS_input->ObjectEnum()!=PentaInputEnum) _error_("Cannot compute Vel as VzFS is of type " << EnumToStringx(vzFS_input->ObjectEnum())); 151 element->GetInputListOnNodes(&vzFS[0],VzFSEnum,0.); 152 } 153 else _error_("Cannot compute Vz as VzFS in not present in HOFS element"); 154 for(i=0;i<numnodes;i++){ 155 vzHO[i]=vz[i]; 156 vz[i]=vzHO[i]+vzFS[i]; 157 } 158 } 159 else if(approximation==SSAFSApproximationEnum){ 160 Input* vzFS_input=element->GetInput(VzFSEnum); 161 if (vzFS_input){ 162 if (vzFS_input->ObjectEnum()!=PentaInputEnum) _error_("Cannot compute Vel as VzFS is of type " << EnumToStringx(vzFS_input->ObjectEnum())); 163 element->GetInputListOnNodes(&vzFS[0],VzFSEnum,0.); 164 } 165 else _error_("Cannot compute Vz as VzFS in not present in SSAFS element"); 166 for(i=0;i<numnodes;i++){ 167 vzSSA[i]=vz[i]; 168 vz[i]=vzSSA[i]+vzFS[i]; 169 } 170 } 171 172 /*Now Compute vel*/ 173 for(i=0;i<numnodes;i++) vel[i]=pow( pow(vx[i],2.0) + pow(vy[i],2.0) + pow(vz[i],2.0) , 0.5); 174 175 /*For pressure: we have not computed pressure in this analysis, for this element. We are in 3D, 176 *so the pressure is just the pressure at the z elevation: except it this is a HOFS element */ 177 if(approximation!=HOFSApproximationEnum && approximation!=SSAFSApproximationEnum){ 178 rho_ice = element->GetMaterialParameter(MaterialsRhoIceEnum); 179 g = element->GetMaterialParameter(ConstantsGEnum); 180 element->GetInputListOnNodes(&surface[0],SurfaceEnum,0.); 181 for(i=0;i<numnodes;i++) pressure[i]=rho_ice*g*(surface[i]-xyz_list[i*3+2]); 182 } 183 184 /*Now, we have to move the previous Vz inputs to old 185 * status, otherwise, we'll wipe them off and add the new inputs: */ 186 element->InputChangeName(VzEnum,VzPicardEnum); 187 188 if(approximation!=HOFSApproximationEnum && approximation!=SSAFSApproximationEnum){ 189 element->InputChangeName(PressureEnum,PressurePicardEnum); 190 element->AddInput(PressureEnum,pressure,P1Enum); 191 } 192 else if(approximation==HOFSApproximationEnum){ 193 element->AddInput(VzHOEnum,vzHO,P1Enum); 194 } 195 else if(approximation==SSAFSApproximationEnum){ 196 element->AddInput(VzSSAEnum,vzSSA,P1Enum); 197 } 198 element->AddInput(VzEnum,vz,P1Enum); 199 element->AddInput(VelEnum,vel,P1Enum); 200 201 /*Free ressources:*/ 202 xDelete<IssmDouble>(surface); 203 xDelete<IssmDouble>(pressure); 204 xDelete<IssmDouble>(vel); 205 xDelete<IssmDouble>(vz); 206 xDelete<IssmDouble>(vzSSA); 207 xDelete<IssmDouble>(vzHO); 208 xDelete<IssmDouble>(vzFS); 209 xDelete<IssmDouble>(vy); 210 xDelete<IssmDouble>(vx); 211 xDelete<IssmDouble>(values); 212 xDelete<IssmDouble>(xyz_list); 213 xDelete<int>(doflist); 214 }/*}}}*/
Note:
See TracChangeset
for help on using the changeset viewer.