Changeset 5847
- Timestamp:
- 09/16/10 13:11:42 (15 years ago)
- Location:
- issm/trunk/src/c/objects/Elements
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/objects/Elements/Penta.cpp
r5843 r5847 2193 2193 switch(approximation){ 2194 2194 case MacAyealApproximationEnum: 2195 CreateKMatrixDiagnosticMacAyeal ( Kgg);2195 CreateKMatrixDiagnosticMacAyeal2d( Kgg); 2196 2196 break; 2197 2197 case PattynApproximationEnum: … … 2206 2206 break; 2207 2207 case MacAyealPattynApproximationEnum: 2208 CreateKMatrixDiagnosticMacAyeal ( Kgg);2208 CreateKMatrixDiagnosticMacAyeal3d( Kgg); 2209 2209 CreateKMatrixDiagnosticPattyn( Kgg); 2210 2210 CreateKMatrixCouplingMacAyealPattyn( Kgg); … … 2290 2290 2291 2291 } 2292 /*FUNCTION Penta::CreateKMatrixDiagnosticMacAyeal {{{1*/2293 void Penta::CreateKMatrixDiagnosticMacAyeal (Mat Kgg){2292 /*FUNCTION Penta::CreateKMatrixDiagnosticMacAyeal2d{{{1*/ 2293 void Penta::CreateKMatrixDiagnosticMacAyeal2d(Mat Kgg){ 2294 2294 2295 /* local declarations */ 2296 int i,j; 2297 2298 /* node data: */ 2295 /*If on water, skip stiffness: */ 2296 if(IsOnWater()) return; 2297 2298 /*Figure out if this pentaelem is collapsed. If so, then bailout, except if it is at the 2299 bedrock, in which case we spawn a tria element using the 3 first grids, and use it to build 2300 the stiffness matrix. */ 2301 2302 if (!IsOnBed()){ 2303 /*This element should be collapsed, but this element is not on the bedrock, therefore all its 2304 * dofs have already been frozen! Do nothing: */ 2305 return; 2306 } 2307 else{ 2308 2309 /*This element should be collapsed into a tria element at its base. Create this tria element, 2310 *and use its CreateKMatrix functionality to fill the global stiffness matrix: */ 2311 2312 /*Depth Averaging B*/ 2313 this->InputDepthAverageAtBase(RheologyBEnum,RheologyBbarEnum,MaterialsEnum); 2314 2315 /*Call Tria function*/ 2316 Tria* tria=(Tria*)SpawnTria(0,1,2); //grids 0, 1 and 2 make the new tria. 2317 tria->CreateKMatrix(Kgg,NULL,NULL); 2318 delete tria->matice; delete tria; 2319 2320 /*Delete B averaged*/ 2321 this->matice->inputs->DeleteInput(RheologyBbarEnum); 2322 2323 return; 2324 } 2325 } 2326 /*}}}*/ 2327 /*FUNCTION Penta::CreateKMatrixDiagnosticMacAyeal3d{{{1*/ 2328 void Penta::CreateKMatrixDiagnosticMacAyeal3d( Mat Kgg){ 2329 2299 2330 const int numdof2d=2*NUMVERTICES2D; 2331 int i,j,ig; 2300 2332 double xyz_list[NUMVERTICES][3]; 2301 2333 int* doflist=NULL; 2302 2303 /* 3d gaussian points: */2304 int ig;2305 2334 GaussPenta *gauss=NULL; 2306 2335 GaussTria *gauss_tria=NULL; 2307 2308 /* material data: */ 2309 double viscosity; //viscosity 2310 double oldviscosity; //viscosity 2311 double newviscosity; //viscosity 2312 2313 /* strain rate: */ 2336 double viscosity, oldviscosity, newviscosity, viscosity_overshoot; 2314 2337 double epsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/ 2315 2338 double oldepsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/ 2316 2317 /* matrices: */2318 2339 double B[3][numdof2d]; 2319 2340 double Bprime[3][numdof2d]; … … 2323 2344 double DL[2][2]={0.0}; //for basal drag 2324 2345 double DL_scalar; 2325 2326 /* local element matrices: */2327 2346 double Ke_gg[numdof2d][numdof2d]={0.0}; //local element stiffness matrix 2328 2347 double Ke_gg_gaussian[numdof2d][numdof2d]; //stiffness matrix evaluated at the gaussian point. 2329 2348 double Jdet; 2330 2331 /*slope: */2332 2349 double slope[2]={0.0}; 2333 2350 double slope_magnitude; 2334 2335 /*friction: */2336 2351 double alpha2_list[3]; 2337 2352 double alpha2; 2338 2339 2353 double MAXSLOPE=.06; // 6 % 2340 2354 double MOUNTAINKEXPONENT=10; 2341 2342 /*parameters: */2343 double viscosity_overshoot;2344 2345 /*Collapsed formulation: */2346 2355 Tria* tria=NULL; 2347 2356 Penta* pentabase=NULL; 2348 int approximation;2349 2350 inputs->GetParameterValue(&approximation,ApproximationEnum);2351 2357 2352 2358 /*If on water, skip stiffness: */ 2353 if(approximation==MacAyealApproximationEnum){ 2354 if(IsOnWater())return; 2355 2356 /*Figure out if this pentaelem is collapsed. If so, then bailout, except if it is at the 2357 bedrock, in which case we spawn a tria element using the 3 first grids, and use it to build 2358 the stiffness matrix. */ 2359 2360 if (!IsOnBed()){ 2361 /*This element should be collapsed, but this element is not on the bedrock, therefore all its 2362 * dofs have already been frozen! Do nothing: */ 2363 return; 2364 } 2365 else{ 2366 2367 /*This element should be collapsed into a tria element at its base. Create this tria element, 2368 *and use its CreateKMatrix functionality to fill the global stiffness matrix: */ 2369 2370 /*Depth Averaging B*/ 2371 this->InputDepthAverageAtBase(RheologyBEnum,RheologyBbarEnum,MaterialsEnum); 2372 2373 /*Call Tria function*/ 2374 tria=(Tria*)SpawnTria(0,1,2); //grids 0, 1 and 2 make the new tria. 2375 tria->CreateKMatrix(Kgg,NULL,NULL); 2376 delete tria->matice; delete tria; 2377 2378 /*Delete B averaged*/ 2379 this->matice->inputs->DeleteInput(RheologyBbarEnum); 2380 2381 return; 2382 } 2383 } 2384 else if(approximation==MacAyealPattynApproximationEnum){ 2385 /*retrieve some parameters: */ 2386 this->parameters->FindParam(&viscosity_overshoot,ViscosityOvershootEnum); 2387 2388 /*If on water, skip stiffness: */ 2389 if(IsOnWater())return; 2390 2391 /*Find penta on bed as this is a macayeal elements: */ 2392 pentabase=GetBasalElement(); 2393 tria=pentabase->SpawnTria(0,1,2); //grids 0, 1 and 2 make the new tria. 2394 2395 /* Get node coordinates and dof list: */ 2396 GetVerticesCoordinates(&xyz_list[0][0], nodes,NUMVERTICES); 2397 tria->GetDofList(&doflist,MacAyealApproximationEnum,GsetEnum); //Pattyn dof list 2398 2399 /*Retrieve all inputs we will be needing: */ 2400 Input* vx_input=inputs->GetInput(VxEnum); ISSMASSERT(vx_input); 2401 Input* vy_input=inputs->GetInput(VyEnum); ISSMASSERT(vy_input); 2402 Input* vxold_input=inputs->GetInput(VxOldEnum); ISSMASSERT(vxold_input); 2403 Input* vyold_input=inputs->GetInput(VyOldEnum); ISSMASSERT(vyold_input); 2404 2405 /* Start looping on the number of gaussian points: */ 2406 gauss=new GaussPenta(5,5); 2407 gauss_tria=new GaussTria(); 2408 for (ig=gauss->begin();ig<gauss->end();ig++){ 2409 2410 gauss->GaussPoint(ig); 2411 gauss->SynchronizeGaussTria(gauss_tria); 2412 2413 /*Get strain rate from velocity: */ 2414 this->GetStrainRate3dPattyn(&epsilon[0],&xyz_list[0][0],gauss,vx_input,vy_input); 2415 this->GetStrainRate3dPattyn(&oldepsilon[0],&xyz_list[0][0],gauss,vxold_input,vyold_input); 2416 2417 /*Get viscosity: */ 2418 matice->GetViscosity3d(&viscosity, &epsilon[0]); 2419 matice->GetViscosity3d(&oldviscosity, &oldepsilon[0]); 2420 2421 /*Get B and Bprime matrices: */ 2422 tria->GetBMacAyeal(&B[0][0], &xyz_list[0][0], gauss_tria); 2423 tria->GetBprimeMacAyeal(&Bprime[0][0], &xyz_list[0][0], gauss_tria); 2424 2425 /* Get Jacobian determinant: */ 2426 GetJacobianDeterminant(&Jdet, &xyz_list[0][0],gauss); 2427 2428 /*Build the D matrix: we plug the gaussian weight, the viscosity, and the jacobian determinant 2429 onto this scalar matrix, so that we win some computational time: */ 2430 newviscosity=viscosity+viscosity_overshoot*(viscosity-oldviscosity); 2431 D_scalar=2*newviscosity*gauss->weight*Jdet; 2432 for (i=0;i<3;i++) D[i][i]=D_scalar; 2433 2434 /* Do the triple product tB*D*Bprime: */ 2435 TripleMultiply( &B[0][0],3,numdof2d,1, 2436 &D[0][0],3,3,0, 2437 &Bprime[0][0],3,numdof2d,0, 2438 &Ke_gg_gaussian[0][0],0); 2439 2440 /* Add the Ke_gg_gaussian, and optionally Ke_gg_gaussian onto Ke_gg: */ 2441 for(i=0;i<numdof2d;i++) for(j=0;j<numdof2d;j++) Ke_gg[i][j]+=Ke_gg_gaussian[i][j]; 2442 } 2443 2444 /*Add Ke_gg to global matrix Kgg: */ 2445 MatSetValues(Kgg,numdof2d,doflist,numdof2d,doflist,(const double*)Ke_gg,ADD_VALUES); 2446 2447 //Deal with 2d friction at the bedrock interface 2448 if(IsOnBed() && !IsOnShelf()){ 2449 /*Build a tria element using the 3 grids of the base of the penta. Then use 2450 * the tria functionality to build a friction stiffness matrix on these 3 2451 * grids: */ 2452 2453 tria->CreateKMatrixDiagnosticMacAyealFriction(Kgg,NULL,NULL); 2454 } 2455 2456 /*Clean up and return*/ 2457 delete tria->matice; 2458 delete tria; 2459 delete gauss_tria; 2460 delete gauss; 2461 xfree((void**)&doflist); 2462 } 2359 if(IsOnWater())return; 2360 2361 /*Find penta on bed as this is a macayeal elements: */ 2362 pentabase=GetBasalElement(); 2363 tria=pentabase->SpawnTria(0,1,2); //grids 0, 1 and 2 make the new tria. 2364 2365 /* Get dof list: */ 2366 tria->GetDofList(&doflist,MacAyealApproximationEnum,GsetEnum); //Pattyn dof list 2367 2368 /*Retrieve all inputs and parameters*/ 2369 GetVerticesCoordinates(&xyz_list[0][0], nodes,NUMVERTICES); 2370 this->parameters->FindParam(&viscosity_overshoot,ViscosityOvershootEnum); 2371 Input* vx_input=inputs->GetInput(VxEnum); ISSMASSERT(vx_input); 2372 Input* vy_input=inputs->GetInput(VyEnum); ISSMASSERT(vy_input); 2373 Input* vxold_input=inputs->GetInput(VxOldEnum); ISSMASSERT(vxold_input); 2374 Input* vyold_input=inputs->GetInput(VyOldEnum); ISSMASSERT(vyold_input); 2375 2376 /* Start looping on the number of gaussian points: */ 2377 gauss=new GaussPenta(5,5); 2378 gauss_tria=new GaussTria(); 2379 for (ig=gauss->begin();ig<gauss->end();ig++){ 2380 2381 gauss->GaussPoint(ig); 2382 gauss->SynchronizeGaussTria(gauss_tria); 2383 2384 tria->GetBMacAyeal(&B[0][0], &xyz_list[0][0], gauss_tria); 2385 tria->GetBprimeMacAyeal(&Bprime[0][0], &xyz_list[0][0], gauss_tria); 2386 2387 2388 this->GetStrainRate3dPattyn(&epsilon[0],&xyz_list[0][0],gauss,vx_input,vy_input); 2389 this->GetStrainRate3dPattyn(&oldepsilon[0],&xyz_list[0][0],gauss,vxold_input,vyold_input); 2390 matice->GetViscosity3d(&viscosity, &epsilon[0]); 2391 matice->GetViscosity3d(&oldviscosity, &oldepsilon[0]); 2392 newviscosity=viscosity+viscosity_overshoot*(viscosity-oldviscosity); 2393 GetJacobianDeterminant(&Jdet, &xyz_list[0][0],gauss); 2394 D_scalar=2*newviscosity*gauss->weight*Jdet; 2395 for (i=0;i<3;i++) D[i][i]=D_scalar; 2396 2397 TripleMultiply( &B[0][0],3,numdof2d,1, 2398 &D[0][0],3,3,0, 2399 &Bprime[0][0],3,numdof2d,0, 2400 &Ke_gg_gaussian[0][0],0); 2401 2402 for(i=0;i<numdof2d;i++) for(j=0;j<numdof2d;j++) Ke_gg[i][j]+=Ke_gg_gaussian[i][j]; 2403 } 2404 2405 MatSetValues(Kgg,numdof2d,doflist,numdof2d,doflist,(const double*)Ke_gg,ADD_VALUES); 2406 2407 //Deal with 2d friction at the bedrock interface 2408 if(IsOnBed() && !IsOnShelf()){ 2409 /*Build a tria element using the 3 grids of the base of the penta. Then use 2410 * the tria functionality to build a friction stiffness matrix on these 3 2411 * grids: */ 2412 2413 tria->CreateKMatrixDiagnosticMacAyealFriction(Kgg,NULL,NULL); 2414 } 2415 2416 /*Clean up and return*/ 2417 delete tria->matice; 2418 delete tria; 2419 delete gauss_tria; 2420 delete gauss; 2421 xfree((void**)&doflist); 2463 2422 } 2464 2423 /*}}}*/ -
issm/trunk/src/c/objects/Elements/Penta.h
r5843 r5847 127 127 void CreateKMatrixDiagnosticHoriz( Mat Kgg); 128 128 void CreateKMatrixDiagnosticHutter( Mat Kgg); 129 void CreateKMatrixDiagnosticMacAyeal( Mat Kgg); 129 void CreateKMatrixDiagnosticMacAyeal2d(Mat Kgg); 130 void CreateKMatrixDiagnosticMacAyeal3d(Mat Kgg); 130 131 void CreateKMatrixDiagnosticPattyn( Mat Kgg); 131 132 void CreateKMatrixDiagnosticStokes( Mat Kgg);
Note:
See TracChangeset
for help on using the changeset viewer.