Changeset 13081
- Timestamp:
- 08/17/12 13:42:31 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified issm/trunk-jpl/src/c/classes/objects/Elements/Tria.cpp ¶
r13073 r13081 370 370 if(stabilization==2){ 371 371 /*Streamline upwinding*/ 372 vel=sqrt( pow(vx,2.)+pow(vy,2.))+1.e-8;372 vel=sqrt(vx*vx+vy*vy)+1.e-8; 373 373 K[0][0]=h/(2*vel)*vx*vx; 374 374 K[1][0]=h/(2*vel)*vy*vx; … … 2328 2328 IssmDouble Tria::SurfaceArea(void){ 2329 2329 2330 int i;2331 2330 IssmDouble S; 2332 2331 IssmDouble normal[3]; … … 2339 2338 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 2340 2339 2341 for (i=0;i<3;i++){2340 for(int i=0;i<3;i++){ 2342 2341 v13[i]=xyz_list[0][i]-xyz_list[2][i]; 2343 2342 v23[i]=xyz_list[1][i]-xyz_list[2][i]; … … 2348 2347 normal[2]=v13[0]*v23[1]-v13[1]*v23[0]; 2349 2348 2350 S = 0.5 * sqrt( pow(normal[0],(IssmDouble)2)+pow(normal[1],(IssmDouble)2)+pow(normal[2],(IssmDouble)2));2349 S = 0.5 * sqrt(normal[0]*normal[0] + normal[1]*normal[1] + normal[2]*normal[2]); 2351 2350 2352 2351 /*Return: */ … … 2357 2356 void Tria::SurfaceNormal(IssmDouble* surface_normal, IssmDouble xyz_list[3][3]){ 2358 2357 2359 int i;2360 2358 IssmDouble v13[3],v23[3]; 2361 2359 IssmDouble normal[3]; 2362 2360 IssmDouble normal_norm; 2363 2361 2364 for (i=0;i<3;i++){2362 for(int i=0;i<3;i++){ 2365 2363 v13[i]=xyz_list[0][i]-xyz_list[2][i]; 2366 2364 v23[i]=xyz_list[1][i]-xyz_list[2][i]; … … 2371 2369 normal[2]=v13[0]*v23[1]-v13[1]*v23[0]; 2372 2370 2373 normal_norm=sqrt( pow(normal[0],(IssmDouble)2)+pow(normal[1],(IssmDouble)2)+pow(normal[2],(IssmDouble)2));2374 2375 *(surface_normal )=normal[0]/normal_norm;2376 *(surface_normal+1) =normal[1]/normal_norm;2377 *(surface_normal+2) =normal[2]/normal_norm;2371 normal_norm=sqrt( normal[0]*normal[0] + normal[1]*normal[1] + normal[2]*normal[2]); 2372 2373 *(surface_normal+0) = normal[0]/normal_norm; 2374 *(surface_normal+1) = normal[1]/normal_norm; 2375 *(surface_normal+2) = normal[2]/normal_norm; 2378 2376 } 2379 2377 /*}}}*/ … … 2608 2606 normal[1]=sin(atan2(x1-x2,y2-y1)); 2609 2607 2610 length=sqrt(pow(x2-x1,2 .0)+pow(y2-y1,2));2608 length=sqrt(pow(x2-x1,2)+pow(y2-y1,2)); 2611 2609 2612 2610 Input* thickness_input=inputs->GetInput(ThicknessEnum); _assert_(thickness_input); … … 2974 2972 //velocity should be = 0. To achieve this result, we set alpha2_list to a very high value: */ 2975 2973 surface_input->GetInputDerivativeValue(&slope[0],&xyz_list[0][0],gauss); 2976 slope_magnitude=sqrt( pow(slope[0],2)+pow(slope[1],2));2974 slope_magnitude=sqrt(slope[0]*slope[0]+slope[1]*slope[1]); 2977 2975 if(slope_magnitude>MAXSLOPE) alpha2=pow((IssmDouble)10,MOUNTAINKEXPONENT); 2978 2976 else friction->GetAlpha2(&alpha2, gauss,VxEnum,VyEnum,VzEnum); … … 3304 3302 /*Get Vz and compute vel*/ 3305 3303 GetInputListOnVertices(&vz[0],VzEnum,0); 3306 for(i=0;i<NUMVERTICES;i++) vel[i]= pow( pow(vx[i],2.0) + pow(vy[i],2.0) + pow(vz[i],2.0) , 0.5);3304 for(i=0;i<NUMVERTICES;i++) vel[i]=sqrt(vx[i]*vx[i] + vy[i]*vy[i] + vz[i]*vz[i]); 3307 3305 3308 3306 /*For pressure: we have not computed pressure in this analysis, for this element. We are in 2D, … … 3364 3362 /*Now Compute vel*/ 3365 3363 GetInputListOnVertices(&vz[0],VzEnum,0.0); //default is 0 3366 for(i=0;i<NUMVERTICES;i++) vel[i]= pow( pow(vx[i],2.0) + pow(vy[i],2.0) + pow(vz[i],2.0) , 0.5);3364 for(i=0;i<NUMVERTICES;i++) vel[i]=sqrt(vx[i]*vx[i] + vy[i]*vy[i] + vz[i]*vz[i]); 3367 3365 3368 3366 /*For pressure: we have not computed pressure in this analysis, for this element. We are in 2D, … … 3983 3981 * S obs obs 3984 3982 */ 3985 misfit=1/S* pow( pow(vx-vxobs,2.) + pow(vy-vyobs,2.) ,0.5);3983 misfit=1/S*sqrt( pow(vx-vxobs,2) + pow(vy-vyobs,2)); 3986 3984 3987 3985 if(process_units)UnitConversion(misfit,IuToExtEnum,SurfaceAverageVelMisfitEnum); … … 4046 4044 * obs 4047 4045 */ 4048 velocity_mag =sqrt(pow(vx, 2 .)+pow(vy, 2.))+epsvel;4049 obs_velocity_mag=sqrt(pow(vxobs,2 .)+pow(vyobs,2.))+epsvel;4050 misfit=4*pow(meanvel,2 .)*pow(log(velocity_mag/obs_velocity_mag),2.);4046 velocity_mag =sqrt(pow(vx, 2)+pow(vy, 2))+epsvel; 4047 obs_velocity_mag=sqrt(pow(vxobs,2)+pow(vyobs,2))+epsvel; 4048 misfit=4*pow(meanvel,2)*pow(log(velocity_mag/obs_velocity_mag),2); 4051 4049 4052 4050 if(process_units)UnitConversion(misfit,IuToExtEnum,SurfaceLogVelMisfitEnum); … … 4112 4110 * obs obs 4113 4111 */ 4114 misfit=0.5*pow(meanvel,2 .)*(4115 pow(log((fabs(vx)+epsvel)/(fabs(vxobs)+epsvel)),2 .) +4116 pow(log((fabs(vy)+epsvel)/(fabs(vyobs)+epsvel)),2 .) );4112 misfit=0.5*pow(meanvel,2)*( 4113 pow(log((fabs(vx)+epsvel)/(fabs(vxobs)+epsvel)),2) + 4114 pow(log((fabs(vy)+epsvel)/(fabs(vyobs)+epsvel)),2) ); 4117 4115 4118 4116 if(process_units)UnitConversion(misfit,IuToExtEnum,SurfaceLogVxVyMisfitEnum); … … 4175 4173 * 4176 4174 */ 4177 misfit=0.5*( pow(vx-vxobs,2 .) + pow(vy-vyobs,2.) );4175 misfit=0.5*( pow(vx-vxobs,2) + pow(vy-vyobs,2) ); 4178 4176 4179 4177 if(process_units)UnitConversion(misfit,IuToExtEnum,SurfaceAverageVelMisfitEnum); … … 4238 4236 * obs obs 4239 4237 */ 4240 scalex=pow(meanvel/(vxobs+epsvel),2 .); if(vxobs==0)scalex=0;4241 scaley=pow(meanvel/(vyobs+epsvel),2 .); if(vyobs==0)scaley=0;4242 misfit=0.5*(scalex*pow((vx-vxobs),2 .)+scaley*pow((vy-vyobs),2.));4238 scalex=pow(meanvel/(vxobs+epsvel),2); if(vxobs==0)scalex=0; 4239 scaley=pow(meanvel/(vyobs+epsvel),2); if(vyobs==0)scaley=0; 4240 misfit=0.5*(scalex*pow((vx-vxobs),2)+scaley*pow((vy-vyobs),2)); 4243 4241 if(process_units)UnitConversion(misfit,IuToExtEnum,SurfaceRelVelMisfitEnum); 4244 4242 … … 4288 4286 4289 4287 /*Tikhonov regularization: J = 1/2 ((dp/dx)^2 + (dp/dy)^2) */ 4290 Jelem+=weight*1/2*( pow(dp[0],2.)+pow(dp[1],2.))*Jdet*gauss->weight;4288 Jelem+=weight*1/2*(dp[0]*dp[0]+dp[1]*dp[1])*Jdet*gauss->weight; 4291 4289 } 4292 4290 … … 4437 4435 4438 4436 /*compute ThicknessAbsMisfit*/ 4439 Jelem+=0.5* pow(thickness-thicknessobs,2.0)*weight*Jdet*gauss->weight;4437 Jelem+=0.5*(thickness-thicknessobs)*(thickness-thicknessobs)*weight*Jdet*gauss->weight; 4440 4438 } 4441 4439 … … 4625 4623 */ 4626 4624 for (i=0;i<NUMVERTICES;i++){ 4627 scalex=pow(meanvel/(vxobs+epsvel),2 .); if(vxobs==0)scalex=0;4628 scaley=pow(meanvel/(vyobs+epsvel),2 .); if(vyobs==0)scaley=0;4625 scalex=pow(meanvel/(vxobs+epsvel),2); if(vxobs==0)scalex=0; 4626 scaley=pow(meanvel/(vyobs+epsvel),2); if(vyobs==0)scaley=0; 4629 4627 dux=scalex*(vxobs-vx); 4630 4628 duy=scaley*(vyobs-vy); … … 4646 4644 */ 4647 4645 for (i=0;i<NUMVERTICES;i++){ 4648 velocity_mag =sqrt(pow(vx, 2 .)+pow(vy, 2.))+epsvel;4649 obs_velocity_mag=sqrt(pow(vxobs,2 .)+pow(vyobs,2.))+epsvel;4650 scale=-8*pow(meanvel,2 .)/pow(velocity_mag,2.)*log(velocity_mag/obs_velocity_mag);4646 velocity_mag =sqrt(pow(vx, 2)+pow(vy, 2))+epsvel; 4647 obs_velocity_mag=sqrt(pow(vxobs,2)+pow(vyobs,2))+epsvel; 4648 scale=-8*pow(meanvel,2)/pow(velocity_mag,2)*log(velocity_mag/obs_velocity_mag); 4651 4649 dux=scale*vx; 4652 4650 duy=scale*vy; … … 4666 4664 */ 4667 4665 for (i=0;i<NUMVERTICES;i++){ 4668 scale=1./(S*2*sqrt(pow(vx-vxobs,2 .)+pow(vy-vyobs,2.))+epsvel);4666 scale=1./(S*2*sqrt(pow(vx-vxobs,2)+pow(vy-vyobs,2))+epsvel); 4669 4667 dux=scale*(vxobs-vx); 4670 4668 duy=scale*(vyobs-vy); … … 4684 4682 */ 4685 4683 for (i=0;i<NUMVERTICES;i++){ 4686 dux = - pow(meanvel,2.)* log((fabs(vx)+epsvel)/(fabs(vxobs)+epsvel)) / (vx+epsvel);4687 duy = - pow(meanvel,2.)* log((fabs(vy)+epsvel)/(fabs(vyobs)+epsvel)) / (vy+epsvel);4684 dux = - meanvel*meanvel * log((fabs(vx)+epsvel)/(fabs(vxobs)+epsvel)) / (vx+epsvel); 4685 duy = - meanvel*meanvel * log((fabs(vy)+epsvel)/(fabs(vyobs)+epsvel)) / (vy+epsvel); 4688 4686 pe->values[i*NDOF2+0]+=dux*weight*Jdet*gauss->weight*basis[i]; 4689 4687 pe->values[i*NDOF2+1]+=duy*weight*Jdet*gauss->weight*basis[i]; … … 4808 4806 */ 4809 4807 for (i=0;i<NUMVERTICES;i++){ 4810 scalex=pow(meanvel/(vxobs+epsvel),2 .); if(vxobs==0)scalex=0;4811 scaley=pow(meanvel/(vyobs+epsvel),2 .); if(vyobs==0)scaley=0;4808 scalex=pow(meanvel/(vxobs+epsvel),2); if(vxobs==0)scalex=0; 4809 scaley=pow(meanvel/(vyobs+epsvel),2); if(vyobs==0)scaley=0; 4812 4810 dux=scalex*(vxobs-vx); 4813 4811 duy=scaley*(vyobs-vy); … … 4829 4827 */ 4830 4828 for (i=0;i<NUMVERTICES;i++){ 4831 velocity_mag =sqrt(pow(vx, 2 .)+pow(vy, 2.))+epsvel;4832 obs_velocity_mag=sqrt(pow(vxobs,2 .)+pow(vyobs,2.))+epsvel;4833 scale=-8*pow(meanvel,2 .)/pow(velocity_mag,2.)*log(velocity_mag/obs_velocity_mag);4829 velocity_mag =sqrt(pow(vx, 2)+pow(vy, 2))+epsvel; 4830 obs_velocity_mag=sqrt(pow(vxobs,2)+pow(vyobs,2))+epsvel; 4831 scale=-8*pow(meanvel,2)/pow(velocity_mag,2)*log(velocity_mag/obs_velocity_mag); 4834 4832 dux=scale*vx; 4835 4833 duy=scale*vy; … … 4849 4847 */ 4850 4848 for (i=0;i<NUMVERTICES;i++){ 4851 scale=1./(S*2*sqrt(pow(vx-vxobs,2 .)+pow(vy-vyobs,2.))+epsvel);4849 scale=1./(S*2*sqrt(pow(vx-vxobs,2)+pow(vy-vyobs,2))+epsvel); 4852 4850 dux=scale*(vxobs-vx); 4853 4851 duy=scale*(vyobs-vy); … … 4867 4865 */ 4868 4866 for (i=0;i<NUMVERTICES;i++){ 4869 dux = - pow(meanvel,2.)* log((fabs(vx)+epsvel)/(fabs(vxobs)+epsvel)) / (vx+epsvel);4870 duy = - pow(meanvel,2.)* log((fabs(vy)+epsvel)/(fabs(vyobs)+epsvel)) / (vy+epsvel);4867 dux = - meanvel*meanvel * log((fabs(vx)+epsvel)/(fabs(vxobs)+epsvel)) / (vx+epsvel); 4868 duy = - meanvel*meanvel * log((fabs(vy)+epsvel)/(fabs(vyobs)+epsvel)) / (vy+epsvel); 4871 4869 pe->values[i*NDOF4+0]+=dux*weight*Jdet*gauss->weight*basis[i]; 4872 4870 pe->values[i*NDOF4+1]+=duy*weight*Jdet*gauss->weight*basis[i]; … … 4936 4934 4937 4935 /*Tikhonov regularization: J = 1/2 ((dp/dx)^2 + (dp/dy)^2) */ 4938 Jelem+=weight*1/2*( pow(dp[0],2.)+pow(dp[1],2.))*Jdet*gauss->weight;4936 Jelem+=weight*1/2*(dp[0]*dp[0]+dp[1]*dp[1])*Jdet*gauss->weight; 4939 4937 } 4940 4938 … … 5193 5191 5194 5192 /* compute VelocityFactor */ 5195 VelocityFactor= n_man* pow(CR,2)*rho_water*g/mu_water;5193 VelocityFactor= n_man*CR*CR*rho_water*g/mu_water; 5196 5194 5197 5195 gauss=new GaussTria(); … … 5205 5203 5206 5204 /* Water velocity x and y components */ 5207 // vx[iv]= - pow(w,2)/(12 * mu_water)*(rho_ice*g*dsdx+(rho_water-rho_ice)*g*dbdx); 5208 // vy[iv]= - pow(w,2)/(12 * mu_water)*(rho_ice*g*dsdy+(rho_water-rho_ice)*g*dbdy); 5209 5210 vx[iv]= - pow(w,2)/(VelocityFactor* mu_water)*(rho_ice*g*dsdx+(rho_water-rho_ice)*g*dbdx); 5211 vy[iv]= - pow(w,2)/(VelocityFactor* mu_water)*(rho_ice*g*dsdy+(rho_water-rho_ice)*g*dbdy); 5205 // vx[iv]= - w*w/(12 * mu_water)*(rho_ice*g*dsdx+(rho_water-rho_ice)*g*dbdx); 5206 // vy[iv]= - w*w/(12 * mu_water)*(rho_ice*g*dsdy+(rho_water-rho_ice)*g*dbdy); 5207 vx[iv]= - w*w/(VelocityFactor* mu_water)*(rho_ice*g*dsdx+(rho_water-rho_ice)*g*dbdx); 5208 vy[iv]= - w*w/(VelocityFactor* mu_water)*(rho_ice*g*dsdy+(rho_water-rho_ice)*g*dbdy); 5212 5209 } 5213 5210 … … 5304 5301 5305 5302 /*Artificial diffusivity*/ 5306 vel=sqrt( pow(vx,2.)+pow(vy,2.));5303 vel=sqrt(vx*vx+vy*vy); 5307 5304 K[0][0]=diffusivity*h/(2*vel)*vx*vx; 5308 5305 K[1][0]=diffusivity*h/(2*vel)*vy*vx; … … 5414 5411 5415 5412 /*Intermediaries*/ 5416 const int numdof = NDOF1*NUMVERTICES; 5417 5418 int i; 5419 int* doflist=NULL; 5420 IssmDouble values[numdof]; 5413 const int numdof = NDOF1 *NUMVERTICES; 5414 int *doflist = NULL; 5415 IssmDouble values[numdof]; 5421 5416 5422 5417 /*Get dof list: */ … … 5424 5419 5425 5420 /*Use the dof list to index into the solution vector: */ 5426 for(i =0;i<numdof;i++){5421 for(int i=0;i<numdof;i++){ 5427 5422 values[i]=solution[doflist[i]]; 5428 5423 if(xIsNan<IssmDouble>(values[i])) _error_("NaN found in solution vector"); 5429 if (values[i]<pow((IssmDouble)10,(IssmDouble)-10))values[i]=pow((IssmDouble)10,(IssmDouble)-10); //correcting the water column to positive values 5430 5424 if (values[i]<10e-10) values[i]=10e-10; //correcting the water column to positive values 5431 5425 } 5432 5426 … … 5679 5673 if(stabilization==1){ 5680 5674 /*Streamline upwinding*/ 5681 vel=sqrt( pow(vx,2.)+pow(vy,2.));5675 vel=sqrt(vx*vx+vy*vy); 5682 5676 K[0][0]=h/(2*vel)*vx*vx; 5683 5677 K[1][0]=h/(2*vel)*vy*vx;
Note:
See TracChangeset
for help on using the changeset viewer.