Changeset 5921
- Timestamp:
- 09/21/10 14:02:29 (15 years ago)
- Location:
- issm/trunk/src/c/objects/Elements
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/objects/Elements/Penta.cpp
r5917 r5921 2984 2984 void Penta::CreatePVectorAdjointMacAyeal(Vec p_g){ 2985 2985 2986 int i; 2987 Tria* tria=NULL; 2988 2989 /*If on water, skip: */ 2990 if(IsOnWater()) return; 2991 2992 /*Bail out if this element if: 2993 * -> Non MacAyeal and not on the surface 2994 * -> MacAyeal(2d model) and not on bed) */ 2995 if (!IsOnBed()){ 2996 return; 2997 } 2998 else{ 2999 3000 /*This element should be collapsed into a tria element at its base. Create this tria element, 3001 * and compute pe_g*/ 3002 tria=(Tria*)SpawnTria(0,1,2); //grids 0, 1 and 2 make the new tria (lower face). 3003 tria->CreatePVectorAdjointHoriz(p_g); 3004 delete tria->matice; delete tria; 3005 return; 3006 } 2986 if (!IsOnBed() || IsOnWater()) return; 2987 2988 /*Call Tria function*/ 2989 Tria* tria=(Tria*)SpawnTria(0,1,2); //grids 0, 1 and 2 make the new tria. 2990 ElementVector* pe=tria->CreatePVectorAdjointHoriz(); 2991 delete tria->matice; delete tria; 2992 pe->AddToGlobal(p_g,NULL); 2993 delete pe; 2994 2995 /*clean up and return*/ 2996 return; 3007 2997 } 3008 2998 /*}}}*/ … … 3010 3000 void Penta::CreatePVectorAdjointPattyn(Vec p_g){ 3011 3001 3012 int i; 3013 Tria* tria=NULL; 3014 3015 /*If on water, skip: */ 3016 if(IsOnWater()) return; 3017 3018 /*Bail out if this element if: 3019 * -> Non MacAyeal and not on the surface 3020 * -> MacAyeal(2d model) and not on bed) */ 3021 if (!IsOnSurface()){ 3022 return; 3023 } 3024 else{ 3025 3026 tria=(Tria*)SpawnTria(3,4,5); //grids 3, 4 and 5 make the new tria (upper face). 3027 tria->CreatePVectorAdjointHoriz(p_g); 3028 delete tria->matice; delete tria; 3029 return; 3030 } 3002 if (!IsOnSurface() || IsOnWater()) return; 3003 3004 /*Call Tria function*/ 3005 Tria* tria=(Tria*)SpawnTria(3,4,5); //grids 3, 4 and 5 make the new tria (upper face). 3006 ElementVector* pe=tria->CreatePVectorAdjointHoriz(); 3007 delete tria->matice; delete tria; 3008 pe->AddToGlobal(p_g,NULL); 3009 delete pe; 3010 3011 /*clean up and return*/ 3012 return; 3031 3013 } 3032 3014 /*}}}*/ … … 3371 3353 void Penta::CreatePVectorDiagnosticMacAyeal(Vec pg){ 3372 3354 3373 /*Spawning: */ 3374 Tria* tria=NULL; 3375 3376 /*If on water, skip load: */ 3377 if(IsOnWater())return; 3378 3379 /*Figure out if this pentaelem is Macayeal. If so, then bailout, except if it is at the 3355 /*Figure out if this penta is collapsed. If so, then bailout, except if it is at the 3380 3356 bedrock, in which case we spawn a tria element using the 3 first grids, and use it to build 3381 the load vector. */ 3382 3383 if (!IsOnBed()){ 3384 /*This element should be collapsed, but this element is not on the bedrock, therefore all its 3385 * dofs have already been frozen! Do nothing: */ 3386 return; 3387 } 3388 else{ 3389 3390 /*This element should be collapsed into a tria element at its base. Create this tria element, 3391 *and use its CreatePVector functionality to return an elementary load vector: */ 3392 tria=(Tria*)SpawnTria(0,1,2); //grids 0, 1 and 2 make the new tria. 3393 tria->CreatePVector(pg,NULL); 3394 delete tria->matice; delete tria; 3395 return; 3396 } 3357 the stiffness matrix. */ 3358 if (!IsOnBed() || IsOnWater()) return; 3359 3360 /*Call Tria function*/ 3361 Tria* tria=(Tria*)SpawnTria(0,1,2); //grids 0, 1 and 2 make the new tria. 3362 ElementVector* pe=tria->CreatePVectorDiagnosticMacAyeal(); 3363 delete tria->matice; delete tria; 3364 pe->AddToGlobal(pg,NULL); 3365 delete pe; 3366 3367 /*clean up and return*/ 3368 return; 3397 3369 } 3398 3370 /*}}}*/ -
issm/trunk/src/c/objects/Elements/Tria.cpp
r5917 r5921 751 751 switch(analysis_type){ 752 752 case DiagnosticHorizAnalysisEnum: 753 CreatePVectorDiagnosticMacAyeal( pg,pf); 753 pe=CreatePVectorDiagnosticMacAyeal(); 754 pe->AddToGlobal(pg,pf); 755 delete pe; 754 756 break; 755 757 case AdjointHorizAnalysisEnum: 756 CreatePVectorAdjointHoriz( pg); 758 pe=CreatePVectorAdjointHoriz(); 759 pe->AddToGlobal(pg,pf); 760 delete pe; 757 761 break; 758 762 case DiagnosticHutterAnalysisEnum: … … 3666 3670 /*}}}*/ 3667 3671 /*FUNCTION Tria::CreatePVectorDiagnosticMacAyeal {{{1*/ 3668 void Tria::CreatePVectorDiagnosticMacAyeal( Vec pg, Vec pf){3672 ElementVector* Tria::CreatePVectorDiagnosticMacAyeal(){ 3669 3673 3670 3674 /*Constants*/ … … 3678 3682 double slope[2]; 3679 3683 double l1l2l3[3]; 3680 double pe_g[numdof]={0.0};3681 3684 double pe_g_gaussian[numdof]; 3682 3685 GaussTria* gauss=NULL; 3683 ElementVector* pe=NULL; 3684 3685 /*First, if we are on water, return empty vector: */ 3686 if(IsOnWater()) return; 3687 3688 /*Retrieve all Inputs and parameters: */ 3686 3687 /*Initialize Element vector and return if necessary*/ 3688 if(IsOnWater()) return NULL; 3689 ElementVector* pe=NewElementVector(nodes,NUMVERTICES,this->parameters); 3690 3691 /*Retrieve all inputs and parameters*/ 3692 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 3689 3693 inputs->GetParameterValue(&drag_type,DragTypeEnum); 3690 3694 Input* thickness_input=inputs->GetInput(ThicknessEnum); ISSMASSERT(thickness_input); 3691 3695 Input* surface_input=inputs->GetInput(SurfaceEnum); ISSMASSERT(surface_input); 3692 3696 Input* drag_input=inputs->GetInput(DragCoefficientEnum);ISSMASSERT(drag_input); 3693 3694 /*Get node coordinates and dof list: */3695 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES);3696 3697 3697 3698 /* Start looping on the number of gaussian points: */ … … 3728 3729 } 3729 3730 } 3730 3731 for( i=0; i<numdof; i++)pe_g[i]+=pe_g_gaussian[i]; 3732 } 3733 3734 pe=NewElementVector(nodes,NUMVERTICES,this->parameters,MacAyealApproximationEnum); 3735 pe->AddValues(&pe_g[0]); 3736 pe->AddToGlobal(pg,pf); 3737 3738 /*Free ressources:*/ 3739 delete pe; 3731 for(i=0;i<numdof;i++) pe->values[i]+=pe_g_gaussian[i]; 3732 } 3733 3734 /*Clean up and return*/ 3740 3735 delete gauss; 3741 3742 3736 return pe; 3743 3737 } 3744 3738 /*}}}*/ … … 3798 3792 /*}}}*/ 3799 3793 /*FUNCTION Tria::CreatePVectorAdjointHoriz{{{1*/ 3800 void Tria::CreatePVectorAdjointHoriz(Vec p_g){ 3801 3802 int i; 3803 3804 /* node data: */ 3805 const int numdof=2*NUMVERTICES; 3794 ElementVector* Tria::CreatePVectorAdjointHoriz(void){ 3795 3796 /*Constants*/ 3797 const int numdof=NDOF2*NUMVERTICES; 3806 3798 double xyz_list[NUMVERTICES][3]; 3807 int* doflist=NULL;3808 3809 /* grid data: */3810 3799 double vx_list[NUMVERTICES]; 3811 3800 double vy_list[NUMVERTICES]; … … 3815 3804 double duy_list[NUMVERTICES]; 3816 3805 double weights_list[NUMVERTICES]; 3817 3818 /* gaussian points: */ 3806 int i; 3819 3807 int ig; 3820 3808 GaussTria* gauss=NULL; 3821 3822 /* parameters: */3823 3809 double obs_velocity_mag,velocity_mag; 3824 3810 double dux,duy; 3825 3811 double meanvel, epsvel; 3826 3827 /*element vector : */3828 double pe_g[numdof]={0.0};3829 3812 double pe_g_gaussian[numdof]; 3830 3831 /* Jacobian: */3832 3813 double Jdet; 3833 3834 /*nodal functions: */3835 3814 double l1l2l3[3]; 3836 3837 /*relative and algorithmic fitting: */3838 3815 double scalex=0; 3839 3816 double scaley=0; … … 3842 3819 int response; 3843 3820 3844 /*retrieve some parameters: */ 3821 /*Initialize Element vector and return if necessary*/ 3822 if(IsOnWater()) return NULL; 3823 ElementVector* pe=NewElementVector(nodes,NUMVERTICES,this->parameters); 3824 3825 /*Retrieve all inputs and parameters*/ 3826 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 3845 3827 this->parameters->FindParam(&meanvel,MeanVelEnum); 3846 3828 this->parameters->FindParam(&epsvel,EpsVelEnum); 3847 3848 /* Get node coordinates and dof list: */3849 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES);3850 GetDofList(&doflist,NoneApproximationEnum,GsetEnum);3851 3852 /* Recover input data: */3853 3829 GetParameterListOnVertices(&obs_vx_list[0],VxObsEnum); 3854 3830 GetParameterListOnVertices(&obs_vy_list[0],VyObsEnum); … … 3856 3832 GetParameterListOnVertices(&vy_list[0],VyEnum); 3857 3833 GetParameterListOnVertices(&weights_list[0],WeightsEnum); 3858 3859 3834 inputs->GetParameterValue(&response,CmResponseEnum); 3860 3835 if(response==SurfaceAverageVelMisfitEnum){ … … 3986 3961 gauss->GaussPoint(ig); 3987 3962 3988 /* Get Jacobian determinant: */3989 3963 GetJacobianDeterminant2d(&Jdet, &xyz_list[0][0],gauss); 3990 3991 /* Get nodal functions value at gaussian point:*/3992 3964 GetNodalFunctions(l1l2l3, gauss); 3993 3965 3994 /*Build due_g_gaussian vector: we have three cases here, according to which type of misfit we are using. */3995 3996 /*Compute absolute(x/y) at gaussian point: */3997 3966 TriaRef::GetParameterValue(&dux, &dux_list[0],gauss); 3998 3967 TriaRef::GetParameterValue(&duy, &duy_list[0],gauss); 3999 3968 4000 /*compute Du*/4001 3969 for (i=0;i<NUMVERTICES;i++){ 4002 3970 pe_g_gaussian[i*NDOF2+0]=dux*Jdet*gauss->weight*l1l2l3[i]; … … 4004 3972 } 4005 3973 4006 /*Add pe_g_gaussian vector to pe_g: */ 4007 for( i=0; i<numdof; i++){ 4008 pe_g[i]+=pe_g_gaussian[i]; 4009 } 4010 } 4011 4012 /*Add pe_g to global vector p_g: */ 4013 VecSetValues(p_g,numdof,doflist,(const double*)pe_g,ADD_VALUES); 3974 for(i=0;i<numdof;i++) pe->values[i]+=pe_g_gaussian[i]; 3975 } 4014 3976 4015 3977 /*Clean up and return*/ 4016 3978 delete gauss; 4017 xfree((void**)&doflist);3979 return pe; 4018 3980 } 4019 3981 /*}}}*/ -
issm/trunk/src/c/objects/Elements/Tria.h
r5916 r5921 143 143 void CreatePVectorBalancedvelocities(Vec pg); 144 144 void CreatePVectorDiagnosticBaseVert(Vec pg); 145 void CreatePVectorDiagnosticMacAyeal(Vec pg,Vec pf);146 void CreatePVectorAdjointHoriz(Vec pg);145 ElementVector* CreatePVectorDiagnosticMacAyeal(void); 146 ElementVector* CreatePVectorAdjointHoriz(void); 147 147 void CreatePVectorAdjointStokes(Vec pg); 148 148 void CreatePVectorAdjointBalancedthickness(Vec pg);
Note:
See TracChangeset
for help on using the changeset viewer.