Changeset 13622 for issm/trunk-jpl/src/c/classes/objects/Elements/Penta.cpp
- Timestamp:
- 10/11/12 11:23:47 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/classes/objects/Elements/Penta.cpp
r13528 r13622 82 82 this->inputs=new Inputs(); 83 83 this->results=new Results(); 84 84 85 85 /*initialize pointers:*/ 86 86 this->nodes=NULL; … … 186 186 GaussPenta* gauss=NULL; 187 187 188 189 188 /* Basal friction can only be found at the base of an ice sheet: */ 190 189 if (!IsOnBed() || IsFloating()){ … … 199 198 Input* vz_input=inputs->GetInput(VzEnum); _assert_(vz_input); 200 199 201 202 200 /*Build friction element, needed later: */ 203 201 friction=new Friction("3d",inputs,matpar,DiagnosticHorizAnalysisEnum); … … 216 214 count++; 217 215 } 218 216 219 217 /*Create PentaVertex input, which will hold the basal friction:*/ 220 218 this->inputs->AddInput(new PentaP1Input(BasalFrictionEnum,&basalfriction[0])); … … 257 255 /*retrieve some parameters: */ 258 256 this->parameters->FindParam(&stokesreconditioning,DiagnosticStokesreconditioningEnum); 259 257 260 258 if(!IsOnBed()){ 261 259 //put zero … … 364 362 sigma_yz[iv]=2*viscosity*epsilon[5]; 365 363 } 366 364 367 365 /*Add Stress tensor components into inputs*/ 368 366 this->inputs->AddInput(new PentaP1Input(StressTensorxxEnum,&sigma_xx[0])); … … 381 379 382 380 int analysis_counter; 383 381 384 382 /*go into parameters and get the analysis_counter: */ 385 383 parametersin->FindParam(&analysis_counter,AnalysisCounterEnum); … … 421 419 _assert_(this->nodes && this->material && this->matpar && this->verticalneighbors && this->parameters && this->inputs); 422 420 /*}}}*/ 423 421 424 422 /*Skip if water element*/ 425 423 if(IsOnWater()) return; … … 652 650 653 651 int i; 654 652 655 653 _printLine_("Penta:"); 656 654 _printLine_(" id: " << id); … … 1191 1189 /*FUNCTION Penta::Sid {{{*/ 1192 1190 int Penta::Sid(){ 1193 1191 1194 1192 return sid; 1195 1193 … … 1251 1249 /*Check that name is an element input*/ 1252 1250 if (!IsInput(name)) return; 1253 1251 1254 1252 if ((code==5) || (code==1)){ //boolean 1255 1253 this->inputs->AddInput(new BoolInput(name,reCast<bool,IssmDouble>(scalar))); … … 1873 1871 penta=penta->GetUpperElement(); _assert_(penta->Id()!=this->id); 1874 1872 } 1875 1873 1876 1874 /*Free ressources:*/ 1877 1875 xDelete<int>(doflist); … … 1897 1895 /*Add input to the element: */ 1898 1896 this->inputs->AddInput(new PentaP1Input(enum_type,values)); 1899 1897 1900 1898 /*Free ressources:*/ 1901 1899 xDelete<int>(doflist); … … 1937 1935 penta=penta->GetUpperElement(); _assert_(penta->Id()!=this->id); 1938 1936 } 1939 1937 1940 1938 /*Free ressources:*/ 1941 1939 xDelete<int>(doflist); … … 2170 2168 rho_ice=matpar->GetRhoIce(); 2171 2169 density=rho_ice/rho_water; 2172 2170 2173 2171 /*go through vertices, and update inputs, considering them to be PentaVertex type: */ 2174 2172 for(i=0;i<NUMVERTICES;i++){ … … 2211 2209 } 2212 2210 } 2213 2211 2214 2212 /*Add basal melting rate if element just ungrounded*/ 2215 2213 if(!this->IsFloating() && elementonshelf==true){ … … 2293 2291 /*recover pointer: */ 2294 2292 count=*pcount; 2295 2293 2296 2294 /*will be needed later: */ 2297 2295 for(i=0;i<6;i++) vertices_ids[i]=nodes[i]->GetVertexId(); //vertices id start at column 3 of the patch. … … 2502 2500 /*FUNCTION Penta::RequestedOutput{{{*/ 2503 2501 void Penta::RequestedOutput(int output_enum,int step,IssmDouble time){ 2504 2502 2505 2503 if(IsInput(output_enum)){ 2506 2504 /*just transfer this input to results, and we are done: */ … … 2677 2675 GetInputListOnVertices(&a_neg[0],SurfaceforcingsANegEnum); 2678 2676 GetInputListOnVertices(&b_neg[0],SurfaceforcingsBNegEnum); 2679 2677 2680 2678 /*Recover surface elevatio at vertices: */ 2681 2679 GetInputListOnVertices(&h[0],ThicknessEnum); … … 2685 2683 rho_ice=matpar->GetRhoIce(); 2686 2684 rho_water=matpar->GetRhoFreshwater(); 2687 2685 2688 2686 // loop over all vertices 2689 2687 for(i=0;i<NUMVERTICES;i++){ … … 2791 2789 minz=xyz_list[0][2]; 2792 2790 maxz=xyz_list[0][2]; 2793 2791 2794 2792 for(i=1;i<NUMVERTICES;i++){ 2795 2793 if (xyz_list[i][0]<minx)minx=xyz_list[i][0]; … … 2973 2971 if (reCast<bool,IssmDouble>(vertices_potentially_ungrounding[nodes[i]->Sid()])){ 2974 2972 vec_nodes_on_iceshelf->SetValue(nodes[i]->Sid(),1,INS_VAL); 2975 2973 2976 2974 /*If node was not on ice shelf, we flipped*/ 2977 2975 if(nodes_on_iceshelf[nodes[i]->Sid()]==0){ … … 3013 3011 for (int iv=0;iv<NUMVERTICES;iv++){ 3014 3012 gauss->GaussVertex(iv); 3015 3013 3016 3014 thickness_input->GetInputValue(&thickness,gauss); 3017 3015 … … 3019 3017 material->GetViscosity3dStokes(&viscosity,&epsilon[0]); 3020 3018 GetPhi(&phi, &epsilon[0], viscosity); 3021 3022 3019 3023 3020 viscousheating[iv]=phi*thickness; … … 3274 3271 3275 3272 if(IsOnWater() || !IsOnSurface()) return 0.; 3276 3273 3277 3274 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 3278 3275 … … 3286 3283 smb_input->GetInputAverage(&smb); 3287 3284 Total_Smb=rho_ice*base*smb;// smb on element in kg s-1 3288 3285 3289 3286 /*Process units: */ 3290 3287 Total_Smb=UnitConversion(Total_Smb,IuToExtEnum,TotalSmbEnum);// smb on element in GigaTon yr-1 3291 3288 3292 3289 /*Return: */ 3293 3290 return Total_Smb; … … 3299 3296 /*FUNCTION Penta::CreateKMatrixEnthalpy {{{*/ 3300 3297 ElementMatrix* Penta::CreateKMatrixEnthalpy(void){ 3301 3298 3302 3299 /*compute all stiffness matrices for this element*/ 3303 3300 ElementMatrix* Ke1=CreateKMatrixEnthalpyVolume(); 3304 3301 ElementMatrix* Ke2=CreateKMatrixEnthalpyShelf(); 3305 3302 ElementMatrix* Ke =new ElementMatrix(Ke1,Ke2); 3306 3303 3307 3304 /*clean-up and return*/ 3308 3305 delete Ke1; … … 3504 3501 3505 3502 gauss->GaussPoint(ig); 3506 3503 3507 3504 GetTriaJacobianDeterminant(&Jdet2d, &xyz_list_tria[0][0], gauss); 3508 3505 GetNodalFunctionsP1(&basis[0], gauss); 3509 3506 3510 3507 D_scalar=gauss->weight*Jdet2d*rho_water*mixed_layer_capacity*thermal_exchange_velocity/(rho_ice*heatcapacity); 3511 3508 if(reCast<bool,IssmDouble>(dt)) D_scalar=dt*D_scalar; … … 3516 3513 &Ke->values[0],1); 3517 3514 } 3518 3515 3519 3516 /*Clean up and return*/ 3520 3517 delete gauss; … … 3536 3533 /*FUNCTION Penta::CreateKMatrixThermal {{{*/ 3537 3534 ElementMatrix* Penta::CreateKMatrixThermal(void){ 3538 3535 3539 3536 /*compute all stiffness matrices for this element*/ 3540 3537 ElementMatrix* Ke1=CreateKMatrixThermalVolume(); 3541 3538 ElementMatrix* Ke2=CreateKMatrixThermalShelf(); 3542 3539 ElementMatrix* Ke =new ElementMatrix(Ke1,Ke2); 3543 3540 3544 3541 /*clean-up and return*/ 3545 3542 delete Ke1; … … 3703 3700 ElementMatrix* Penta::CreateKMatrixThermalShelf(void){ 3704 3701 3705 3706 3702 /*Constants*/ 3707 3703 const int numdof=NDOF1*NUMVERTICES; … … 3737 3733 3738 3734 gauss->GaussPoint(ig); 3739 3735 3740 3736 GetTriaJacobianDeterminant(&Jdet2d, &xyz_list_tria[0][0], gauss); 3741 3737 GetNodalFunctionsP1(&basis[0], gauss); 3742 3738 3743 3739 D_scalar=gauss->weight*Jdet2d*rho_water*mixed_layer_capacity*thermal_exchange_velocity/(heatcapacity*rho_ice); 3744 3740 if(reCast<bool,IssmDouble>(dt)) D_scalar=dt*D_scalar; … … 3749 3745 &Ke->values[0],1); 3750 3746 } 3751 3747 3752 3748 /*Clean up and return*/ 3753 3749 delete gauss; … … 4409 4405 GetInputListOnVertices(&pressure[0],PressureEnum); 4410 4406 Input* surface_input=inputs->GetInput(SurfaceEnum); _assert_(surface_input); 4411 4407 4412 4408 this->inputs->GetInputValue(&converged,ConvergedEnum); 4413 4409 if(converged){ … … 4418 4414 //if(waterfraction[i]>1) _error_("Water fraction >1 found in solution vector"); 4419 4415 } 4420 4416 4421 4417 this->inputs->AddInput(new PentaP1Input(EnthalpyEnum,values)); 4422 4418 this->inputs->AddInput(new PentaP1Input(WaterfractionEnum,waterfraction)); … … 4473 4469 input=(Input*)material->inputs->GetInput(MaterialsRheologyZEnum); 4474 4470 } 4475 4471 4476 4472 else{ 4477 4473 input=inputs->GetInput(enum_type); … … 5533 5529 new_input = new PentaP1Input(control_enum,values); 5534 5530 5535 5536 5531 if(control_enum==MaterialsRheologyBbarEnum){ 5537 5532 input=(Input*)material->inputs->GetInput(control_enum); _assert_(input); … … 5553 5548 /*FUNCTION Penta::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type);{{{*/ 5554 5549 void Penta::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){ 5555 5550 5556 5551 int i,j; 5557 5552 … … 5580 5575 IssmDouble surface[6]; 5581 5576 IssmDouble bed[6]; 5582 5577 5583 5578 /*retrieve inputs: */ 5584 5579 GetInputListOnVertices(&thickness_init[0],ThicknessEnum); … … 5665 5660 /*FUNCTION Penta::InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrows, int ncols, int name, int type);{{{*/ 5666 5661 void Penta::InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrows, int ncols, int name, int type){ 5667 5662 5668 5663 int i,j,t; 5669 5664 TransientInput* transientinput=NULL; … … 5679 5674 5680 5675 case VertexEnum: 5681 5676 5682 5677 /*Create transient input: */ 5683 5678 5684 5679 parameters->FindParam(&yts,ConstantsYtsEnum); 5685 5680 … … 5752 5747 /*FUNCTION Penta::CreateKMatrixCouplingMacAyealPattyn{{{*/ 5753 5748 ElementMatrix* Penta::CreateKMatrixCouplingMacAyealPattyn(void){ 5754 5749 5755 5750 /*compute all stiffness matrices for this element*/ 5756 5751 ElementMatrix* Ke1=CreateKMatrixCouplingMacAyealPattynViscous(); 5757 5752 ElementMatrix* Ke2=CreateKMatrixCouplingMacAyealPattynFriction(); 5758 5753 ElementMatrix* Ke=new ElementMatrix(Ke1,Ke2); 5759 5754 5760 5755 /*clean-up and return*/ 5761 5756 delete Ke1; … … 5864 5859 const int numdof = NDOF2 *NUMVERTICES; 5865 5860 const int numdoftotal = NDOF4 *NUMVERTICES; 5866 5861 5867 5862 /*Intermediaries */ 5868 5863 int i,j,ig,analysis_type; … … 5933 5928 DL_scalar=alpha2*gauss->weight*Jdet2d; 5934 5929 for (i=0;i<2;i++) DL[i][i]=DL_scalar; 5935 5930 5936 5931 /* Do the triple producte tL*D*L: */ 5937 5932 TripleMultiply( &L[0][0],2,numdof,1, … … 6165 6160 DLStokesMacAyeal[2][2]=-alpha2_gauss*gauss->weight*Jdet2d*bed_normal[0]*bed_normal[2]; 6166 6161 DLStokesMacAyeal[3][3]=-alpha2_gauss*gauss->weight*Jdet2d*bed_normal[1]*bed_normal[2]; 6167 6162 6168 6163 TripleMultiply( &LMacAyealStokes[0][0],8,numdof2dm,1, 6169 6164 &DLMacAyealStokes[0][0],8,8,0, … … 6700 6695 /*Constants*/ 6701 6696 const int numdof = NDOF2*NUMVERTICES; 6702 6697 6703 6698 /*Intermediaries */ 6704 6699 int i,j,ig; … … 6751 6746 alpha2=pow((IssmDouble)10,MOUNTAINKEXPONENT); 6752 6747 } 6753 6748 6754 6749 DL_scalar=alpha2*gauss->weight*Jdet; 6755 6750 for (i=0;i<2;i++) DL[i][i]=DL_scalar; 6756 6751 6757 6752 TripleMultiply( &L[0][0],2,numdof,1, 6758 6753 &DL[0][0],2,2,0, … … 6926 6921 /*DO NOT Transform Coordinate System: this stiffness matrix is already expressed in tangential coordinates*/ 6927 6922 //TransformStiffnessMatrixCoord(Ke,nodes,NUMVERTICES,XYZPEnum); 6928 6923 6929 6924 /*Clean up and return*/ 6930 6925 delete gauss; … … 6935 6930 /*FUNCTION Penta::CreateKMatrixDiagnosticVert {{{*/ 6936 6931 ElementMatrix* Penta::CreateKMatrixDiagnosticVert(void){ 6937 6932 6938 6933 /*compute all stiffness matrices for this element*/ 6939 6934 ElementMatrix* Ke1=CreateKMatrixDiagnosticVertVolume(); … … 7816 7811 ElementVector* Penta::CreatePVectorDiagnosticVertBase(void){ 7817 7812 7818 7819 7813 /*Constants*/ 7820 7814 const int numdof=NDOF1*NUMVERTICES; … … 8415 8409 penta=penta->GetUpperElement(); _assert_(penta->Id()!=this->id); 8416 8410 } 8417 8411 8418 8412 /*Free ressources:*/ 8419 8413 xDelete<int>(doflist); … … 8687 8681 /*FUNCTION Penta::InputUpdateFromSolutionDiagnosticPattyn {{{*/ 8688 8682 void Penta::InputUpdateFromSolutionDiagnosticPattyn(IssmDouble* solution){ 8689 8683 8690 8684 const int numdof=NDOF2*NUMVERTICES; 8691 8685 … … 8855 8849 /*FUNCTION Penta::InputUpdateFromSolutionDiagnosticHutter {{{*/ 8856 8850 void Penta::InputUpdateFromSolutionDiagnosticHutter(IssmDouble* solution){ 8857 8851 8858 8852 const int numdof=NDOF2*NUMVERTICES; 8859 8853 … … 8920 8914 8921 8915 const int numdof=NDOF1*NUMVERTICES; 8922 8916 8923 8917 int i; 8924 8918 int approximation; … … 8937 8931 int* doflist = NULL; 8938 8932 8939 8940 8933 /*Get the approximation and do nothing if the element in Stokes or None*/ 8941 8934 inputs->GetInputValue(&approximation,ApproximationEnum); … … 9022 9015 /*FUNCTION Penta::InputUpdateFromSolutionDiagnosticStokes {{{*/ 9023 9016 void Penta::InputUpdateFromSolutionDiagnosticStokes(IssmDouble* solution){ 9024 9017 9025 9018 const int numdof=NDOF4*NUMVERTICES; 9026 9019 … … 9062 9055 for(i=0;i<NUMVERTICES;i++) pressure[i]=pressure[i]*stokesreconditioning; 9063 9056 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); 9064 9057 9065 9058 /*Now, we have to move the previous inputs to old 9066 9059 * status, otherwise, we'll wipe them off: */ … … 9132 9125 /*}}}*/ 9133 9126 #endif 9134
Note:
See TracChangeset
for help on using the changeset viewer.