Changeset 23880
- Timestamp:
- 04/22/19 10:18:19 (6 years ago)
- Location:
- issm/trunk-jpl/src/c
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/classes/Elements/Tria.cpp
r23804 r23880 2600 2600 IssmDouble mass_flux=0.; 2601 2601 IssmDouble xyz_list[NUMVERTICES][3]; 2602 IssmDouble normal[2]; 2603 IssmDouble length,rho_ice; 2604 IssmDouble h1,h2; 2605 IssmDouble vx1,vx2,vy1,vy2; 2606 GaussTria* gauss_1=NULL; 2607 GaussTria* gauss_2=NULL; 2602 IssmDouble vx1,vx2,vy1,vy2,h1,h2; 2608 2603 2609 2604 /*Get material parameters :*/ 2610 rho_ice=FindParam(MaterialsRhoIceEnum);2605 IssmDouble rho_ice=FindParam(MaterialsRhoIceEnum); 2611 2606 2612 2607 /*First off, check that this segment belongs to this element: */ … … 2617 2612 2618 2613 /*get area coordinates of 0 and 1 locations: */ 2619 gauss_1=new GaussTria();2614 GaussTria* gauss_1=new GaussTria(); 2620 2615 gauss_1->GaussFromCoords(x1,y1,&xyz_list[0][0]); 2621 gauss_2=new GaussTria();2616 GaussTria* gauss_2=new GaussTria(); 2622 2617 gauss_2->GaussFromCoords(x2,y2,&xyz_list[0][0]); 2623 2618 2624 normal[0]=cos(atan2(x1-x2,y2-y1)); 2625 normal[1]=sin(atan2(x1-x2,y2-y1)); 2626 2627 length=sqrt(pow(x2-x1,2)+pow(y2-y1,2)); 2628 2619 /*Get segment length and normal (needs to be properly oriented)*/ 2620 IssmDouble nx=cos(atan2(x1-x2,y2-y1)); 2621 IssmDouble ny=sin(atan2(x1-x2,y2-y1)); 2622 IssmDouble length=sqrt(pow(x2-x1,2)+pow(y2-y1,2)); 2623 2624 /*Get velocity and thickness*/ 2625 this->parameters->FindParam(&domaintype,DomainTypeEnum); 2629 2626 Input* thickness_input=inputs->GetInput(ThicknessEnum); _assert_(thickness_input); 2630 this->parameters->FindParam(&domaintype,DomainTypeEnum);2631 2627 Input* vx_input=NULL; 2632 2628 Input* vy_input=NULL; … … 2648 2644 2649 2645 mass_flux= rho_ice*length*( 2650 ( ONETHIRD*(h1-h2)*(vx1-vx2)+0.5*h2*(vx1-vx2)+0.5*(h1-h2)*vx2+h2*vx2)*normal[0]+2651 ( ONETHIRD*(h1-h2)*(vy1-vy2)+0.5*h2*(vy1-vy2)+0.5*(h1-h2)*vy2+h2*vy2)*normal[1]2646 (1./3.*(h1-h2)*(vx1-vx2)+0.5*h2*(vx1-vx2)+0.5*(h1-h2)*vx2+h2*vx2)*nx+ 2647 (1./3.*(h1-h2)*(vy1-vy2)+0.5*h2*(vy1-vy2)+0.5*(h1-h2)*vy2+h2*vy2)*ny 2652 2648 ); 2653 2649 … … 2659 2655 /*}}}*/ 2660 2656 IssmDouble Tria::MassFlux(IssmDouble* segment){/*{{{*/ 2661 2662 int domaintype; 2663 IssmDouble mass_flux=0.; 2664 IssmDouble xyz_list[NUMVERTICES][3]; 2665 IssmDouble normal[2]; 2666 IssmDouble length,rho_ice; 2667 IssmDouble x1,y1,x2,y2,h1,h2; 2668 IssmDouble vx1,vx2,vy1,vy2; 2669 GaussTria* gauss_1=NULL; 2670 GaussTria* gauss_2=NULL; 2671 2672 /*Get material parameters :*/ 2673 rho_ice=FindParam(MaterialsRhoIceEnum); 2674 2675 /*First off, check that this segment belongs to this element: */ 2676 if (reCast<int>(*(segment+4))!=this->id)_error_("error message: segment with id " << reCast<int>(*(segment+4)) << " does not belong to element with id:" << this->id); 2677 2678 /*Recover segment node locations: */ 2679 x1=*(segment+0); y1=*(segment+1); x2=*(segment+2); y2=*(segment+3); 2680 2681 /*Get xyz list: */ 2682 ::GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); 2683 2684 /*get area coordinates of 0 and 1 locations: */ 2685 gauss_1=new GaussTria(); 2686 gauss_1->GaussFromCoords(x1,y1,&xyz_list[0][0]); 2687 gauss_2=new GaussTria(); 2688 gauss_2->GaussFromCoords(x2,y2,&xyz_list[0][0]); 2689 2690 normal[0]=cos(atan2(x1-x2,y2-y1)); 2691 normal[1]=sin(atan2(x1-x2,y2-y1)); 2692 2693 length=sqrt(pow(x2-x1,2)+pow(y2-y1,2)); 2694 2695 Input* thickness_input=inputs->GetInput(ThicknessEnum); _assert_(thickness_input); 2696 this->parameters->FindParam(&domaintype,DomainTypeEnum); 2697 Input* vx_input=NULL; 2698 Input* vy_input=NULL; 2699 if(domaintype==Domain2DhorizontalEnum){ 2700 vx_input=inputs->GetInput(VxEnum); _assert_(vx_input); 2701 vy_input=inputs->GetInput(VyEnum); _assert_(vy_input); 2702 } 2703 else{ 2704 vx_input=inputs->GetInput(VxAverageEnum); _assert_(vx_input); 2705 vy_input=inputs->GetInput(VyAverageEnum); _assert_(vy_input); 2706 } 2707 2708 thickness_input->GetInputValue(&h1, gauss_1); 2709 thickness_input->GetInputValue(&h2, gauss_2); 2710 vx_input->GetInputValue(&vx1,gauss_1); 2711 vx_input->GetInputValue(&vx2,gauss_2); 2712 vy_input->GetInputValue(&vy1,gauss_1); 2713 vy_input->GetInputValue(&vy2,gauss_2); 2714 2715 mass_flux= rho_ice*length*( 2716 (ONETHIRD*(h1-h2)*(vx1-vx2)+0.5*h2*(vx1-vx2)+0.5*(h1-h2)*vx2+h2*vx2)*normal[0]+ 2717 (ONETHIRD*(h1-h2)*(vy1-vy2)+0.5*h2*(vy1-vy2)+0.5*(h1-h2)*vy2+h2*vy2)*normal[1] 2718 ); 2719 2720 /*clean up and return:*/ 2721 delete gauss_1; 2722 delete gauss_2; 2723 return mass_flux; 2657 return this->MassFlux(segment[0],segment[1],segment[2],segment[3],reCast<int>(segment[4])); 2724 2658 } 2725 2659 /*}}}*/ -
issm/trunk-jpl/src/c/shared/Numerics/constants.h
r20405 r23880 7 7 8 8 #define UNDEF -9999 9 #define ONETHIRD 0.33333333333333333333333333333333333333333333333333333333333310 9 #define SQRT2 1.414213562373095048801688724209698078569671875376948073176679738 11 10 #define SQRT3 1.732050807568877293527446341505872366942805253810380628055806979
Note:
See TracChangeset
for help on using the changeset viewer.