Changeset 586
- Timestamp:
- 05/26/09 10:54:45 (15 years ago)
- Location:
- issm/trunk/src
- Files:
-
- 31 added
- 42 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/DataSet/DataSet.cpp
r503 r586 1229 1229 1230 1230 } 1231 1231 void DataSet::ThicknessExtrude(Vec tg,double* tg_serial){ 1232 1233 vector<Object*>::iterator object; 1234 Penta* penta=NULL; 1235 1236 for ( object=objects.begin() ; object < objects.end(); object++ ){ 1237 1238 if((*object)->Enum()==PentaEnum()){ 1239 1240 penta=(Penta*)(*object); 1241 penta->ThicknessExtrude(tg,tg_serial); 1242 1243 } 1244 } 1245 1246 } 1247 void DataSet::VelocityExtrudeAllElements(Vec ug,double* ug_serial){ 1248 1249 vector<Object*>::iterator object; 1250 Penta* penta=NULL; 1251 1252 for ( object=objects.begin() ; object < objects.end(); object++ ){ 1253 1254 if((*object)->Enum()==PentaEnum()){ 1255 1256 penta=(Penta*)(*object); 1257 penta->VelocityExtrudeAllElements(ug,ug_serial); 1258 1259 } 1260 } 1261 1262 } 1263 void DataSet::VelocityDepthAverageAtBase(Vec ug,double* ug_serial){ 1264 1265 1266 vector<Object*>::iterator object; 1267 Penta* penta=NULL; 1268 1269 for ( object=objects.begin() ; object < objects.end(); object++ ){ 1270 1271 if((*object)->Enum()==PentaEnum()){ 1272 1273 penta=(Penta*)(*object); 1274 penta->VelocityDepthAverageAtBase(ug,ug_serial); 1275 1276 } 1277 } 1278 1279 } 1232 1280 void DataSet::SlopeExtrude(Vec sg,double* sg_serial){ 1233 1281 -
issm/trunk/src/c/DataSet/DataSet.h
r465 r586 75 75 void Misfit(double* pJ, double* u_g,double* u_g_obs,void* inputs,int analysis_type,int sub_analysis_type); 76 76 void VelocityExtrude(Vec ug,double* ug_serial); 77 void ThicknessExtrude(Vec ug,double* ug_serial); 78 void VelocityExtrudeAllElements(Vec ug,double* ug_serial); 79 void VelocityDepthAverageAtBase(Vec ug,double* ug_serial); 77 80 void SlopeExtrude(Vec sg,double* sg_serial); 78 81 int DeleteObject(Object* object); -
issm/trunk/src/c/Makefile.am
r483 r586 1 INCLUDES = @ PETSCINCL@ @SLEPCINCL@ @MPIINCL@ @MATLABINCL@ @METISINCL@@PLAPACKINCL@ @BLASLAPACKINCL@ @MUMPSINCL@ @TRIANGLEINCL@1 INCLUDES = @DAKOTAINCL@ @PETSCINCL@ @SLEPCINCL@ @MPIINCL@ @MATLABINCL@ @METISINCL@ @PLAPACKINCL@ @BLASLAPACKINCL@ @MUMPSINCL@ @TRIANGLEINCL@ 2 2 3 3 #Compile serial library, and then try and compile parallel library … … 126 126 ./toolkits/petsc/patches/PetscOptionsInsertMultipleString.cpp\ 127 127 ./toolkits/petsc/patches/NewMat.cpp\ 128 ./toolkits/petsc/patches/SerialToVec.cpp\ 128 129 ./toolkits/petsc/patches/VecFree.cpp\ 129 130 ./toolkits/petsc/patches/VecDuplicatePatch.cpp\ … … 196 197 ./ModelProcessorx/Melting/CreateLoadsMelting.cpp\ 197 198 ./ModelProcessorx/Melting/CreateParametersMelting.cpp\ 199 ./ModelProcessorx/Prognostic/CreateElementsNodesAndMaterialsPrognostic.cpp\ 200 ./ModelProcessorx/Prognostic/CreateConstraintsPrognostic.cpp\ 201 ./ModelProcessorx/Prognostic/CreateLoadsPrognostic.cpp\ 202 ./ModelProcessorx/Prognostic/CreateParametersPrognostic.cpp\ 198 203 ./Dofx/Dofx.h\ 199 204 ./Dofx/Dofx.cpp\ … … 252 257 ./ProcessParamsx/ProcessParamsx.cpp\ 253 258 ./ProcessParamsx/ProcessParamsx.h\ 259 ./ThicknessExtrudex/ThicknessExtrudex.cpp\ 260 ./ThicknessExtrudex/ThicknessExtrudex.h\ 254 261 ./VelocityExtrudex/VelocityExtrudex.cpp\ 255 262 ./VelocityExtrudex/VelocityExtrudex.h\ 263 ./VelocityDepthAveragex/VelocityDepthAveragex.cpp\ 264 ./VelocityDepthAveragex/VelocityDepthAveragex.h\ 256 265 ./SlopeExtrudex/SlopeExtrudex.cpp\ 257 266 ./SlopeExtrudex/SlopeExtrudex.h … … 288 297 ./objects/Node.h\ 289 298 ./objects/Node.cpp\ 299 ./objects/DakotaPlugin.h\ 300 ./objects/DakotaPlugin.cpp\ 290 301 ./objects/Tria.h\ 291 302 ./objects/Tria.cpp\ … … 380 391 ./toolkits/petsc/patches/PetscOptionsInsertMultipleString.cpp\ 381 392 ./toolkits/petsc/patches/NewMat.cpp\ 393 ./toolkits/petsc/patches/SerialToVec.cpp\ 382 394 ./toolkits/petsc/patches/VecFree.cpp\ 383 395 ./toolkits/petsc/patches/VecDuplicatePatch.cpp\ … … 450 462 ./ModelProcessorx/Melting/CreateLoadsMelting.cpp\ 451 463 ./ModelProcessorx/Melting/CreateParametersMelting.cpp\ 464 ./ModelProcessorx/Prognostic/CreateElementsNodesAndMaterialsPrognostic.cpp\ 465 ./ModelProcessorx/Prognostic/CreateConstraintsPrognostic.cpp\ 466 ./ModelProcessorx/Prognostic/CreateLoadsPrognostic.cpp\ 467 ./ModelProcessorx/Prognostic/CreateParametersPrognostic.cpp\ 452 468 ./Dofx/Dofx.h\ 453 469 ./Dofx/Dofx.cpp\ … … 502 518 ./Solverx/Solverx.cpp\ 503 519 ./Solverx/Solverx.h\ 520 ./ThicknessExtrudex/ThicknessExtrudex.cpp\ 521 ./ThicknessExtrudex/ThicknessExtrudex.h\ 504 522 ./Mergesolutionfromftogx/Mergesolutionfromftogx.cpp\ 505 523 ./Mergesolutionfromftogx/Mergesolutionfromftogx.h\ … … 508 526 ./VelocityExtrudex/VelocityExtrudex.cpp\ 509 527 ./VelocityExtrudex/VelocityExtrudex.h\ 528 ./VelocityDepthAveragex/VelocityDepthAveragex.cpp\ 529 ./VelocityDepthAveragex/VelocityDepthAveragex.h\ 510 530 ./SlopeExtrudex/SlopeExtrudex.cpp\ 511 531 ./SlopeExtrudex/SlopeExtrudex.h\ … … 520 540 ./parallel/OutputControl.cpp\ 521 541 ./parallel/OutputThermal.cpp\ 542 ./parallel/OutputPrognostic.cpp\ 522 543 ./parallel/objectivefunctionC.cpp\ 523 ./parallel/GradJCompute.cpp 544 ./parallel/GradJCompute.cpp\ 545 ./parallel/qmu.cpp\ 546 ./parallel/SpawnCore.cpp\ 547 ./parallel/DakotaResponses.cpp 524 548 525 549 libpISSM_a_CXXFLAGS = -fPIC -D_PARALLEL_ -D_C_ … … 528 552 bin_PROGRAMS = 529 553 else 530 bin_PROGRAMS = diagnostic.exe control.exe thermal.exe 554 bin_PROGRAMS = diagnostic.exe 555 #control.exe thermal.exe prognostic.exe 531 556 endif 532 557 533 LDADD = ./libpISSM.a $(TRIANGLELIB) $(METISLIB) $(PETSCLIB) $( SLEPCLIB) $(MUMPSLIB) $(PLAPACKLIB) $(MPILIB) $(X_LIBS) -lX11 $(BLASLAPACKLIB) $(SCALAPACKLIB) $(BLACSLIB) $(FLIBS)558 LDADD = ./libpISSM.a $(TRIANGLELIB) $(METISLIB) $(PETSCLIB) $(DAKOTALIB) $(SLEPCLIB) $(MUMPSLIB) $(PLAPACKLIB) $(MPILIB) $(X_LIBS) -lX11 $(BLASLAPACKLIB) $(SCALAPACKLIB) $(BLACSLIB) $(FLIBS) 534 559 535 560 diagnostic_exe_SOURCES = parallel/diagnostic.cpp … … 541 566 thermal_exe_SOURCES = parallel/thermal.cpp 542 567 thermal_exe_CXXFLAGS= -fPIC -D_PARALLEL_ 568 569 prognostic_exe_SOURCES = parallel/prognostic.cpp 570 prognostic_exe_CXXFLAGS= -fPIC -D_PARALLEL_ 571 -
issm/trunk/src/c/ModelProcessorx/CreateDataSets.cpp
r576 r586 87 87 } 88 88 else if (strcmp(model->analysis_type,"prognostic")==0){ 89 90 //CreateElementsNodesAndMaterialsPrognostic(pelements,pnodes,pmaterials, model,model_handle); 91 //CreateConstraintsPrognostic(pconstraints,model,model_handle); 92 //CreateLoadsPrognostic(ploads,model,model_handle); 89 90 CreateElementsNodesAndMaterialsPrognostic(pelements,pnodes,pmaterials, model,model_handle); 91 CreateConstraintsPrognostic(pconstraints,model,model_handle); 92 CreateLoadsPrognostic(ploads,model,model_handle); 93 CreateParametersPrognostic(pparameters,model,model_handle); 94 93 95 } 94 96 else{ -
issm/trunk/src/c/ModelProcessorx/CreateParameters.cpp
r465 r586 24 24 int numberofdofspernode; 25 25 int dim; 26 double* epart=NULL; 27 double* part=NULL; 28 26 29 27 30 /*Initialize dataset: */ … … 42 45 parameters->AddObject(param); 43 46 47 //qmu analysis? 48 count++; 49 param= new Param(count,"qmu_analysis",INTEGER); 50 param->SetInteger(model->qmu_analysis); 51 parameters->AddObject(param); 52 53 count++; 54 param= new Param(count,"qmu_npart",INTEGER); 55 param->SetInteger(model->qmu_npart); 56 parameters->AddObject(param); 57 44 58 //dimension 2d or 3d: 45 59 if (strcmp(model->meshtype,"2d")==0)dim=2; … … 201 215 parameters->AddObject(param); 202 216 217 /*Deal with responses and partition for qmu modeling: */ 218 if(model->qmu_analysis){ 219 char** descriptors=NULL; 220 char* descriptor=NULL; 221 char* tag=NULL; 222 223 descriptors=(char**)xmalloc(model->numberofresponses*sizeof(char*)); 224 tag=(char*)xmalloc((strlen("descriptori")+1)*sizeof(char)); 225 226 /*Fetch descriptors: */ 227 for(i=0;i<model->numberofresponses;i++){ 228 sprintf(tag,"%s%i","descriptor",i); 229 ModelFetchData((void**)&descriptor,NULL,NULL,model_handle,tag,"String",NULL); 230 descriptors[i]=descriptor; 231 } 232 233 /*Ok, we have all the descriptors. Build a parameter with it: */ 234 count++; 235 param= new Param(count,"descriptors",STRINGARRAY); 236 param->SetStringArray(descriptors,model->numberofresponses); 237 parameters->AddObject(param); 238 239 /*Free data: */ 240 xfree((void**)&tag); 241 for(i=0;i<model->numberofresponses;i++){ 242 char* descriptor=descriptors[i]; 243 xfree((void**)&descriptor); 244 } 245 xfree((void**)&descriptors); 246 247 #ifdef _PARALLEL_ 248 /*partition grids in model->qmu_npart parts: */ 249 250 if(strcmp(model->meshtype,"2d")==0){ 251 ModelFetchData((void**)&model->elements,NULL,NULL,model_handle,"elements","Matrix","Mat"); 252 } 253 else{ 254 ModelFetchData((void**)&model->elements2d,NULL,NULL,model_handle,"elements2d","Matrix","Mat"); 255 } 256 257 MeshPartitionx(&epart, &part,model->numberofelements,model->numberofnodes,model->elements, model->numberofelements2d,model->numberofnodes2d,model->elements2d,model->numlayers,elements_width, model->meshtype,model->qmu_npart); 258 259 count++; 260 param= new Param(count,"qmu_part",DOUBLEVEC); 261 param->SetDoubleVec(part,model->numberofnodes); 262 parameters->AddObject(param); 263 264 /*Free elements and elements2d: */ 265 xfree((void**)&model->elements); 266 xfree((void**)&model->elements2d); 267 xfree((void**)&epart); 268 xfree((void**)&part); 269 270 #endif 271 } 203 272 204 273 -
issm/trunk/src/c/ModelProcessorx/DiagnosticHoriz/CreateConstraintsDiagnosticHoriz.cpp
r300 r586 84 84 85 85 86 cleanup_and_return:87 86 /*Free data: */ 88 87 xfree((void**)&gridondirichlet_diag); 89 88 xfree((void**)&dirichletvalues_diag); 90 89 90 cleanup_and_return: 91 91 /*Assign output pointer: */ 92 92 *pconstraints=constraints; -
issm/trunk/src/c/ModelProcessorx/DiagnosticHoriz/CreateElementsNodesAndMaterialsDiagnosticHoriz.cpp
r483 r586 69 69 double tria_meanvel;/*!scaling ratio for velocities*/ 70 70 double tria_epsvel; /*!minimum velocity to avoid infinite velocity ratios*/ 71 double tria_viscosity_overshoot; 72 71 double tria_viscosity_overshoot; 72 int tria_artdiff; 73 73 74 /*matice constructor input: */ 74 75 int matice_mid; … … 294 295 295 296 /*Create tria element using its constructor:*/ 296 tria=new Tria(tria_id, tria_mid, tria_mparid, tria_g, tria_h, tria_s, tria_b, tria_k, tria_melting,tria_accumulation,tria_geothermalflux,tria_friction_type, tria_p, tria_q, tria_shelf, tria_meanvel, tria_epsvel, tria_viscosity_overshoot );297 tria=new Tria(tria_id, tria_mid, tria_mparid, tria_g, tria_h, tria_s, tria_b, tria_k, tria_melting,tria_accumulation,tria_geothermalflux,tria_friction_type, tria_p, tria_q, tria_shelf, tria_meanvel, tria_epsvel, tria_viscosity_overshoot,tria_artdiff); 297 298 298 299 /*Add tria element to elements dataset: */ … … 653 654 xfree((void**)&model->uppernodes); 654 655 655 cleanup_and_return:656 657 /*Assign output pointer: */658 *pelements=elements;659 *pnodes=nodes;660 *pmaterials=materials;661 656 662 657 /*Keep partitioning information into model*/ … … 672 667 #endif 673 668 669 cleanup_and_return: 670 671 /*Assign output pointer: */ 672 *pelements=elements; 673 *pnodes=nodes; 674 *pmaterials=materials; 675 674 676 } -
issm/trunk/src/c/ModelProcessorx/DiagnosticHoriz/CreateLoadsDiagnosticHoriz.cpp
r300 r586 265 265 loads->Presort(); 266 266 267 cleanup_and_return:268 267 269 268 /*Free ressources:*/ … … 276 275 xfree((void**)&riftsfill); 277 276 xfree((void**)&riftsfriction); 278 277 278 cleanup_and_return: 279 279 280 280 /*Assign output pointer: */ -
issm/trunk/src/c/ModelProcessorx/DiagnosticHutter/CreateElementsNodesAndMaterialsDiagnosticHutter.cpp
r465 r586 357 357 xfree((void**)&model->uppernodes); 358 358 359 360 /*Keep partitioning information into model*/ 361 xfree((void**)&epart); 362 model->npart=npart; 363 359 364 cleanup_and_return: 360 365 … … 364 369 *pmaterials=materials; 365 370 366 /*Keep partitioning information into model*/367 xfree((void**)&epart);368 model->npart=npart;369 371 } -
issm/trunk/src/c/ModelProcessorx/DiagnosticStokes/CreateConstraintsDiagnosticStokes.cpp
r394 r586 88 88 constraints->Presort(); 89 89 90 cleanup_and_return:91 90 /*Free data: */ 92 91 xfree((void**)&gridonstokes); 92 93 cleanup_and_return: 93 94 94 95 /*Assign output pointer: */ -
issm/trunk/src/c/ModelProcessorx/DiagnosticStokes/CreateElementsNodesAndMaterialsDiagnosticStokes.cpp
r465 r586 517 517 xfree((void**)&model->borderstokes); 518 518 519 cleanup_and_return:520 521 /*Assign output pointer: */522 *pelements=elements;523 *pnodes=nodes;524 *pmaterials=materials;525 519 526 520 /*Keep partitioning information into model*/ … … 536 530 #endif 537 531 532 cleanup_and_return: 533 534 /*Assign output pointer: */ 535 *pelements=elements; 536 *pnodes=nodes; 537 *pmaterials=materials; 538 538 539 } -
issm/trunk/src/c/ModelProcessorx/DiagnosticVert/CreateElementsNodesAndMaterialsDiagnosticVert.cpp
r465 r586 146 146 sub_analysis_type=AnalysisTypeAsEnum(model->sub_analysis_type); 147 147 148 /*Width of elements: */149 if(strcmp(model->meshtype,"2d")==0){150 throw ErrorException(__FUNCT__," 2d mesh not supported for vertical velocity");151 }152 153 154 148 #ifdef _PARALLEL_ 155 149 /*Determine parallel partitioning of elements: we use Metis for now. First load the data, then partition*/ … … 420 414 xfree((void**)&model->uppernodes); 421 415 416 417 /*Keep partitioning information into model*/ 418 model->epart=epart; 419 model->my_grids=my_grids; 420 model->my_bordergrids=my_bordergrids; 421 422 /*Free ressources:*/ 423 #ifdef _PARALLEL_ 424 xfree((void**)&all_numgrids); 425 xfree((void**)&npart); 426 VecFree(&gridborder); 427 #endif 428 422 429 cleanup_and_return: 423 430 … … 427 434 *pmaterials=materials; 428 435 429 /*Keep partitioning information into model*/430 model->epart=epart;431 model->my_grids=my_grids;432 model->my_bordergrids=my_bordergrids;433 434 /*Free ressources:*/435 #ifdef _PARALLEL_436 xfree((void**)&all_numgrids);437 xfree((void**)&npart);438 VecFree(&gridborder);439 #endif440 441 436 } -
issm/trunk/src/c/ModelProcessorx/Melting/CreateElementsNodesAndMaterialsMelting.cpp
r483 r586 476 476 xfree((void**)&model->uppernodes); 477 477 478 479 /*Keep partitioning information into model*/ 480 model->epart=epart; 481 model->my_grids=my_grids; 482 model->my_bordergrids=my_bordergrids; 483 484 /*Free ressources:*/ 485 #ifdef _PARALLEL_ 486 xfree((void**)&all_numgrids); 487 xfree((void**)&npart); 488 VecFree(&gridborder); 489 #endif 490 478 491 cleanup_and_return: 479 492 … … 483 496 *pmaterials=materials; 484 497 485 /*Keep partitioning information into model*/486 model->epart=epart;487 model->my_grids=my_grids;488 model->my_bordergrids=my_bordergrids;489 490 /*Free ressources:*/491 #ifdef _PARALLEL_492 xfree((void**)&all_numgrids);493 xfree((void**)&npart);494 VecFree(&gridborder);495 #endif496 497 498 } -
issm/trunk/src/c/ModelProcessorx/Model.cpp
r575 r586 32 32 33 33 /*!initialize all pointers to 0: */ 34 35 36 34 model->repository=NULL; 37 35 model->meshtype=NULL; 38 36 model->analysis_type=NULL; 39 37 model->sub_analysis_type=NULL; 38 model->qmu_analysis=0; 39 model->solverstring=NULL; 40 model->numberofresponses=0; 41 model->qmu_npart=0; 40 42 model->numberofelements=0; 41 43 model->numberofnodes=0; … … 75 77 model->drag=NULL; 76 78 model->p=NULL; 79 model->q=NULL; 77 80 78 81 … … 100 103 model->rho_water=0; 101 104 model->rho_ice=0; 102 103 model->n= 0;105 model->g=0; 106 model->n=NULL; 104 107 model->B=NULL; 105 108 … … 165 168 model->ismacayealpattyn=0; 166 169 model->isstokes=0; 170 171 172 model->epart=NULL; 173 model->npart=NULL; 174 model->my_grids=NULL; 175 model->my_bordergrids=NULL; 167 176 168 177 return model; … … 295 304 296 305 /*In ModelInit, we get all the data that is not difficult to get, and that is small: */ 306 297 307 ModelFetchData((void**)&model->analysis_type,NULL,NULL,model_handle,"analysis_type","String",NULL); 298 308 ModelFetchData((void**)&model->sub_analysis_type,NULL,NULL,model_handle,"sub_analysis_type","String",NULL); 309 ModelFetchData((void**)&model->qmu_analysis,NULL,NULL,model_handle,"qmu_analysis","Integer",NULL); 299 310 300 311 ModelFetchData((void**)&model->meshtype,NULL,NULL,model_handle,"type","String",NULL); … … 302 313 ModelFetchData((void**)&model->numberofnodes,NULL,NULL,model_handle,"numberofgrids","Integer",NULL); 303 314 ModelFetchData((void**)&model->numberofelements,NULL,NULL,model_handle,"numberofelements","Integer",NULL); 304 305 315 /*!In case we are running 3d, we are going to need the collapsed and non-collapsed 2d meshes, from which the 3d mesh was extruded: */ 306 316 if (strcmp(model->meshtype,"3d")==0){ … … 311 321 ModelFetchData((void**)&model->numlayers,NULL,NULL,model_handle,"numlayers","Integer",NULL); 312 322 } 323 313 324 314 325 /*elements type: */ … … 367 378 ModelFetchData((void**)&model->numrifts,NULL,NULL,model_handle,"numrifts","Integer",NULL); 368 379 380 /*qmu: */ 381 if(model->qmu_analysis){ 382 ModelFetchData((void**)&model->numberofresponses,NULL,NULL,model_handle,"numberofresponses","Integer",NULL); 383 ModelFetchData((void**)&model->qmu_npart,NULL,NULL,model_handle,"npart","Integer",NULL); 384 } 385 369 386 /*Assign output pointers: */ 370 387 *pmodel=model; -
issm/trunk/src/c/ModelProcessorx/Model.h
r575 r586 17 17 char* analysis_type; 18 18 char* sub_analysis_type; 19 int qmu_analysis; 19 20 char* solverstring; 20 21 … … 52 53 double* vx_obs; 53 54 double* vy_obs; 55 56 /*qmu: */ 57 int numberofresponses; 58 int qmu_npart; 54 59 55 60 /*geometry: */ … … 221 226 void CreateElementsNodesAndMaterialsMelting(DataSet** pelements,DataSet** pnodes, DataSet** pmaterials, Model* model,ConstDataHandle model_handle); 222 227 void CreateConstraintsMelting(DataSet** pconstraints,Model* model,ConstDataHandle model_handle); 223 void CreateLoadsMelting(DataSet** ploads, Model* model, ConstDataHandle model_handle); 224 void CreateParametersMelting(DataSet** pparameters,Model* model,ConstDataHandle model_handle); 228 void CreateLoadsMelting(DataSet** ploads, Model* model, ConstDataHandle model_handle); 229 void CreateParametersMelting(DataSet** pparameters,Model* model,ConstDataHandle model_handle); 230 231 /*prognostic:*/ 232 void CreateElementsNodesAndMaterialsPrognostic(DataSet** pelements,DataSet** pnodes, DataSet** pmaterials, Model* model,ConstDataHandle model_handle); 233 void CreateConstraintsPrognostic(DataSet** pconstraints,Model* model,ConstDataHandle model_handle); 234 void CreateLoadsPrognostic(DataSet** ploads, Model* model, ConstDataHandle model_handle); 235 void CreateParametersPrognostic(DataSet** pparameters,Model* model,ConstDataHandle model_handle); 225 236 226 237 -
issm/trunk/src/c/ModelProcessorx/SlopeCompute/CreateElementsNodesAndMaterialsSlopeCompute.cpp
r483 r586 66 66 double tria_epsvel; /*!minimum velocity to avoid infinite velocity ratios*/ 67 67 double tria_viscosity_overshoot; 68 int tria_artdiff; 68 69 69 70 /*penta constructor input: */ … … 227 228 228 229 /*Create tria element using its constructor:*/ 229 tria=new Tria(tria_id, tria_mid, tria_mparid, tria_g, tria_h, tria_s, tria_b, tria_k, tria_melting,tria_accumulation,tria_geothermalflux,tria_friction_type, tria_p, tria_q, tria_shelf, tria_meanvel, tria_epsvel, tria_viscosity_overshoot );230 tria=new Tria(tria_id, tria_mid, tria_mparid, tria_g, tria_h, tria_s, tria_b, tria_k, tria_melting,tria_accumulation,tria_geothermalflux,tria_friction_type, tria_p, tria_q, tria_shelf, tria_meanvel, tria_epsvel, tria_viscosity_overshoot,tria_artdiff); 230 231 231 232 /*Add tria element to elements dataset: */ … … 479 480 xfree((void**)&model->uppernodes); 480 481 481 cleanup_and_return:482 483 /*Assign output pointer: */484 *pelements=elements;485 *pnodes=nodes;486 *pmaterials=materials;487 482 488 483 /*Keep partitioning information into model*/ … … 497 492 VecFree(&gridborder); 498 493 #endif 494 495 cleanup_and_return: 496 497 /*Assign output pointer: */ 498 *pelements=elements; 499 *pnodes=nodes; 500 *pmaterials=materials; 501 499 502 } -
issm/trunk/src/c/PenaltySystemMatricesx/PenaltySystemMatricesx.cpp
r543 r586 47 47 } 48 48 49 #ifdef _DEBUG_ 50 MatNorm(Kgg,NORM_INFINITY,&kmax2); 51 _printf_(" K_gg infinity norm after penalties: %g\n",kmax2); 52 #endif 53 49 54 /*Assign output pointers:*/ 50 55 if(pkmax)*pkmax=kmax; -
issm/trunk/src/c/ProcessParamsx/ProcessParamsx.cpp
r552 r586 24 24 double* vy=NULL; 25 25 double* vz=NULL; 26 26 double* pressure=NULL; 27 27 28 double* u_g=NULL; 28 29 /*thermal*/30 double* pressure=NULL;31 double* temperature=NULL;32 double* melting=NULL;33 34 double* p_g=NULL;35 double* t_g=NULL;36 double* m_g=NULL;37 29 38 30 /*control: */ … … 46 38 47 39 double* u_g_obs=NULL; 40 double* p_g=NULL; 41 42 /*prognostic: */ 43 double* a_g=NULL; 44 double* m_g=NULL; 45 double* h_g=NULL; 46 double* accumulation=NULL; 47 double* thickness=NULL; 48 double* melting=NULL; 49 48 50 49 51 /*diverse: */ 50 52 int numberofnodes; 51 53 int analysis_type; 52 int sub_analysis_type;53 54 int count; 54 55 55 56 parameters->FindParam((void*)&analysis_type,"analysis_type"); 56 parameters->FindParam((void*)&sub_analysis_type,"sub_analysis_type");57 57 count=parameters->Size(); 58 58 … … 63 63 64 64 65 if ( (analysis_type==ControlAnalysisEnum()) || (analysis_type==DiagnosticAnalysisEnum()) || (analysis_type==ThermalAnalysisEnum())){ 65 if ( (analysis_type==ControlAnalysisEnum()) || 66 (analysis_type==DiagnosticAnalysisEnum()) || 67 (analysis_type==ThermalAnalysisEnum()) || 68 (analysis_type==PrognosticAnalysisEnum()) 69 ){ 66 70 67 71 parameters->FindParam((void*)&vx,"vx"); … … 170 174 param=(Param*)parameters->FindParamObject("pressure"); 171 175 parameters->DeleteObject((Object*)param); 172 173 if(sub_analysis_type==TransientAnalysisEnum()){ 174 175 parameters->FindParam((void*)&temperature,"temperature"); 176 parameters->FindParam((void*)&melting,"melting"); 177 178 /*Now, from temperature and melting, build t_g and m_g, correctly partitioned: */ 179 t_g=(double*)xcalloc(numberofnodes,sizeof(double)); 180 m_g=(double*)xcalloc(numberofnodes,sizeof(double)); 181 182 for(i=0;i<numberofnodes;i++){ 183 t_g[(int)(partition[i])]=temperature[i]; 184 m_g[(int)(partition[i])]=melting[i]; 185 } 186 187 /*Now, create new parameter: */ 188 count++; 189 param= new Param(count,"t_g",DOUBLEVEC); 190 param->SetDoubleVec(t_g,numberofnodes); 191 parameters->AddObject(param); 192 193 count++; 194 param= new Param(count,"m_g",DOUBLEVEC); 195 param->SetDoubleVec(m_g,numberofnodes); 196 parameters->AddObject(param); 197 198 /*erase old parameter: */ 199 param=(Param*)parameters->FindParamObject("temperature"); 200 parameters->DeleteObject((Object*)param); 201 202 param=(Param*)parameters->FindParamObject("melting"); 203 parameters->DeleteObject((Object*)param); 204 } 205 } 206 176 } 177 178 if(analysis_type==PrognosticAnalysisEnum()){ 179 180 parameters->FindParam((void*)&melting,"melting"); 181 182 /*Now, from melting, build m_g, correctly partitioned: */ 183 m_g=(double*)xcalloc(numberofnodes,sizeof(double)); 184 185 for(i=0;i<numberofnodes;i++){ 186 m_g[(int)(partition[i])]= melting[i]; 187 } 188 189 /*Now, create new parameter: */ 190 count++; 191 param= new Param(count,"m_g",DOUBLEVEC); 192 param->SetDoubleVec(m_g,numberofnodes); 193 parameters->AddObject(param); 194 195 /*erase old parameter: */ 196 param=(Param*)parameters->FindParamObject("melting"); 197 parameters->DeleteObject((Object*)param); 198 199 200 201 parameters->FindParam((void*)&thickness,"thickness"); 202 203 /*Now, from thickness, build h_g, correctly partitioned: */ 204 h_g=(double*)xcalloc(numberofnodes,sizeof(double)); 205 206 for(i=0;i<numberofnodes;i++){ 207 h_g[(int)(partition[i])]= thickness[i]; 208 } 209 210 /*Now, create new parameter: */ 211 count++; 212 param= new Param(count,"h_g",DOUBLEVEC); 213 param->SetDoubleVec(h_g,numberofnodes); 214 parameters->AddObject(param); 215 216 /*erase old parameter: */ 217 param=(Param*)parameters->FindParamObject("thickness"); 218 parameters->DeleteObject((Object*)param); 219 220 221 222 223 parameters->FindParam((void*)&accumulation,"accumulation"); 224 225 /*Now, from accumulation, build a_g, correctly partitioned: */ 226 a_g=(double*)xcalloc(numberofnodes,sizeof(double)); 227 228 for(i=0;i<numberofnodes;i++){ 229 a_g[(int)(partition[i])]= accumulation[i]; 230 } 231 232 /*Now, create new parameter: */ 233 count++; 234 param= new Param(count,"a_g",DOUBLEVEC); 235 param->SetDoubleVec(a_g,numberofnodes); 236 parameters->AddObject(param); 237 238 /*erase old parameter: */ 239 param=(Param*)parameters->FindParamObject("accumulation"); 240 parameters->DeleteObject((Object*)param); 241 242 243 244 } 207 245 xfree((void**)&partition); 208 246 … … 215 253 xfree((void**)&vy_obs); 216 254 xfree((void**)&pressure); 217 xfree((void**)&temperature);218 xfree((void**)&melting);219 255 xfree((void**)&control_parameter); 220 256 xfree((void**)&u_g_obs); 221 257 xfree((void**)&p_g); 222 xfree((void**)&t_g); 258 xfree((void**)&a_g); 259 xfree((void**)&h_g); 223 260 xfree((void**)&m_g); 224 261 -
issm/trunk/src/c/issm.h
r358 r586 45 45 #include "./ControlConstrainx/ControlConstrainx.h" 46 46 #include "./VelocityExtrudex/VelocityExtrudex.h" 47 #include "./VelocityDepthAveragex/VelocityDepthAveragex.h" 47 48 #include "./GriddataMeshToGridx/GriddataMeshToGridx.h" 48 49 #include "./ComputePressurex/ComputePressurex.h" 49 50 #include "./SlopeExtrudex/SlopeExtrudex.h" 51 #include "./ThicknessExtrudex/ThicknessExtrudex.h" 50 52 51 53 -
issm/trunk/src/c/objects/Param.cpp
r209 r586 19 19 20 20 Param::Param(){ 21 stringarray=NULL; 21 22 doublevec=NULL; 22 23 doublemat=NULL; … … 34 35 strcpy(name,param_name); 35 36 type=param_type; 36 if ((param_type!=STRING) & (param_type!= INTEGER) & (param_type!=DOUBLE) &37 if ((param_type!=STRING) & (param_type!=STRINGARRAY) & (param_type!=INTEGER) & (param_type!=DOUBLE) & 37 38 (param_type!=DOUBLEVEC) & (param_type!=DOUBLEMAT) & (param_type!=PETSCVEC) & (param_type!=PETSCMAT) 38 39 ){ 39 40 throw ErrorException(__FUNCT__,exprintf("%s%i"," unknow parameter type ",param_type)); 40 41 } 42 stringarray=NULL; 41 43 doublevec=NULL; 42 44 doublemat=NULL; … … 47 49 48 50 Param::~Param(){ 51 52 int i; 49 53 50 54 switch(type){ … … 52 56 case STRING: 53 57 break; 58 59 case STRINGARRAY: 60 61 for(i=0;i<M;i++){ 62 char* descriptor=stringarray[i]; 63 xfree((void**)&descriptor); 64 } 65 xfree((void**)&stringarray); 66 67 break; 54 68 55 69 case INTEGER: 56 70 break; 71 57 72 58 73 case DOUBLE: … … 94 109 printf(" string value: %s\n",string); 95 110 break; 111 112 case STRINGARRAY: 113 printf(" string array: %i strings\n",M); 114 for(i=0;i<M;i++){ 115 printf(" %i: %s\n",i,stringarray[i]); 116 } 96 117 97 118 case INTEGER: … … 142 163 double* serial_vec=NULL; 143 164 double* serial_mat=NULL; 165 int i; 144 166 145 167 /*recover marshalled_dataset: */ … … 161 183 memcpy(marshalled_dataset,&string,sizeof(string));marshalled_dataset+=sizeof(string); 162 184 break; 185 186 case STRINGARRAY: 187 memcpy(marshalled_dataset,&M,sizeof(M));marshalled_dataset+=sizeof(M); 188 for(i=0;i<M;i++){ 189 int size=(strlen(stringarray[i])+1)*sizeof(char); 190 memcpy(marshalled_dataset,&size,sizeof(size));marshalled_dataset+=sizeof(size); 191 memcpy(marshalled_dataset,&stringarray[i],size);marshalled_dataset+=size; 192 } 193 break; 194 163 195 case INTEGER: 164 196 memcpy(marshalled_dataset,&integer,sizeof(integer));marshalled_dataset+=sizeof(integer); … … 228 260 229 261 int size; 262 int i; 230 263 231 264 size=sizeof(id)+ … … 238 271 size+=sizeof(string); 239 272 break; 273 274 case STRINGARRAY: 275 size+=sizeof(M); 276 for(i=0;i<M;i++){ 277 size+=sizeof(integer); 278 size+=(strlen(stringarray[i])+1)*sizeof(char); 279 } 280 break; 281 240 282 case INTEGER: 241 283 size+= sizeof(integer); … … 297 339 case STRING: 298 340 memcpy(&string,marshalled_dataset,sizeof(string));marshalled_dataset+=sizeof(string); 341 break; 342 343 case STRINGARRAY: 344 memcpy(&M,marshalled_dataset,sizeof(M));marshalled_dataset+=sizeof(M); 345 if(M){ 346 stringarray=(char**)xmalloc(M*sizeof(char*)); 347 for(i=0;i<M;i++){ 348 int size; 349 memcpy(&size,marshalled_dataset,sizeof(integer));marshalled_dataset+=sizeof(integer); 350 memcpy(&stringarray[i],marshalled_dataset,size);marshalled_dataset+=size; 351 } 352 } 299 353 break; 300 354 … … 392 446 void Param::GetParameterValue(void* pvalue){ 393 447 448 int i; 449 394 450 if (type==STRING){ 395 451 char** pstring=(char**)pvalue; //a little dangerous, but hey! … … 398 454 strcpy(outstring,string); 399 455 *pstring=outstring; 456 } 457 else if (type==STRINGARRAY){ 458 char*** pstringarray=(char***)pvalue; //a little dangerous, but hey! 459 char** outstringarray=NULL; 460 outstringarray=(char**)xmalloc(M*sizeof(char*)); 461 for(i=0;i<M;i++){ 462 char* outstring=(char*)xmalloc((strlen(stringarray[i])+1)*sizeof(char)); 463 strcpy(outstring,stringarray[i]); 464 outstringarray[i]=outstring; 465 } 466 *pstringarray=outstringarray; 400 467 } 401 468 else if(type==INTEGER){ … … 488 555 } 489 556 557 #undef __FUNCT__ 558 #define __FUNCT__ "SetStringArray" 559 void Param::SetStringArray(char** value,int size){ 560 561 int i; 562 if (type!=STRINGARRAY) throw ErrorException(__FUNCT__,exprintf("%s%i"," trying to set string for type",type)); 563 M=size; 564 stringarray=(char**)xmalloc(M*sizeof(char*)); 565 for(i=0;i<M;i++){ 566 char* instring=(char*)xmalloc((strlen(value[i])+1)*sizeof(char)); 567 strcpy(instring,value[i]); 568 stringarray[i]=instring; 569 } 570 } 571 572 490 573 int Param::GetM(){ 491 574 return M; -
issm/trunk/src/c/objects/Param.h
r202 r586 11 11 #define PARAMSTRING 200 //max string length 12 12 13 enum param_type { STRING, INTEGER, DOUBLE, DOUBLEVEC, DOUBLEMAT, PETSCVEC, PETSCMAT };13 enum param_type { STRING, STRINGARRAY, INTEGER, DOUBLE, DOUBLEVEC, DOUBLEMAT, PETSCVEC, PETSCMAT }; 14 14 15 15 class Param: public Object{ … … 23 23 double ddouble; 24 24 char string[PARAMSTRING]; 25 char** stringarray; 25 26 double* doublevec; 26 27 double* doublemat; … … 49 50 void SetInteger(int value); 50 51 void SetString(char* value); 52 void SetStringArray(char** value,int size); 51 53 void GetParameterValue(void* pvalue); 52 54 -
issm/trunk/src/c/objects/Penta.cpp
r545 r586 1 /*!\file Penta.c 1 /*!\file Penta.cpp 2 2 * \brief: implementation of the Penta object 3 3 */ … … 20 20 } 21 21 Penta::Penta( int penta_id, int penta_mid, int penta_mparid, int penta_node_ids[6], double penta_h[6], double penta_s[6], double penta_b[6], double penta_k[6], int penta_friction_type, 22 double penta_p, double penta_q, int penta_shelf, int penta_onbed, int penta_onsurface, double penta_meanvel,double penta_epsvel,23 int penta_collapse, double penta_melting[6], double penta_accumulation[6], double penta_geothermalflux[6],24 int penta_artdiff, int penta_thermal_steadystate,double penta_viscosity_overshoot,double penta_stokesreconditioning){25 22 double penta_p, double penta_q, int penta_shelf, int penta_onbed, int penta_onsurface, double penta_meanvel,double penta_epsvel, 23 int penta_collapse, double penta_melting[6], double penta_accumulation[6], double penta_geothermalflux[6], 24 int penta_artdiff, int penta_thermal_steadystate,double penta_viscosity_overshoot,double penta_stokesreconditioning){ 25 26 26 int i; 27 27 … … 83 83 printf(" b=[%i,%i,%i,%i,%i,%i]\n",b[0],b[1],b[2],b[3],b[4],b[5]); 84 84 printf(" k=[%i,%i,%i,%i,%i,%i]\n",k[0],k[1],k[2],k[3],k[4],k[5]); 85 85 86 86 printf(" friction_type: %i\n",friction_type); 87 87 printf(" p: %g\n",p); … … 93 93 printf(" epsvel: %g\n",epsvel); 94 94 printf(" collapse: %i\n",collapse); 95 95 96 96 printf(" melting=[%i,%i,%i,%i,%i,%i]\n",melting[0],melting[1],melting[2],melting[3],melting[4],melting[5]); 97 97 printf(" accumulation=[%i,%i,%i,%i,%i,%i]\n",accumulation[0],accumulation[1],accumulation[2],accumulation[3],accumulation[4],accumulation[5]); … … 114 114 /*get enum type of Penta: */ 115 115 enum_type=PentaEnum(); 116 116 117 117 /*marshall enum: */ 118 118 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type); 119 119 120 120 /*marshall Penta data: */ 121 121 memcpy(marshalled_dataset,&id,sizeof(id));marshalled_dataset+=sizeof(id); … … 149 149 memcpy(marshalled_dataset,&viscosity_overshoot,sizeof(viscosity_overshoot));marshalled_dataset+=sizeof(viscosity_overshoot); 150 150 memcpy(marshalled_dataset,&stokesreconditioning,sizeof(stokesreconditioning));marshalled_dataset+=sizeof(stokesreconditioning); 151 151 152 152 *pmarshalled_dataset=marshalled_dataset; 153 153 return; 154 154 } 155 155 156 156 int Penta::MarshallSize(){ 157 157 158 158 return sizeof(id)+ 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 159 sizeof(mid)+ 160 sizeof(mparid)+ 161 sizeof(node_ids)+ 162 sizeof(nodes)+ 163 sizeof(node_offsets)+ 164 sizeof(matice)+ 165 sizeof(matice_offset)+ 166 sizeof(matpar)+ 167 sizeof(matpar_offset)+ 168 sizeof(h)+ 169 sizeof(s)+ 170 sizeof(b)+ 171 sizeof(k)+ 172 sizeof(friction_type)+ 173 sizeof(p)+ 174 sizeof(q)+ 175 sizeof(shelf)+ 176 sizeof(onbed)+ 177 sizeof(onsurface)+ 178 sizeof(meanvel)+ 179 sizeof(epsvel)+ 180 sizeof(collapse)+ 181 sizeof(melting)+ 182 sizeof(accumulation)+ 183 sizeof(geothermalflux)+ 184 sizeof(artdiff)+ 185 sizeof(thermal_steadystate) + 186 sizeof(viscosity_overshoot) + 187 sizeof(stokesreconditioning) + 188 sizeof(int); //sizeof(int) for enum type 189 189 } 190 190 … … 262 262 263 263 int i; 264 264 265 265 DataSet* loadsin=NULL; 266 266 DataSet* nodesin=NULL; … … 274 274 /*Link this element with its nodes, ie find pointers to the nodes in the nodes dataset.: */ 275 275 ResolvePointers((Object**)nodes,node_ids,node_offsets,6,nodesin); 276 276 277 277 /*Same for materials: */ 278 278 ResolvePointers((Object**)&matice,&mid,&matice_offset,1,materialsin); … … 293 293 } 294 294 else if (analysis_type==DiagnosticAnalysisEnum()){ 295 295 296 296 if (sub_analysis_type==HorizAnalysisEnum()){ 297 297 298 298 CreateKMatrixDiagnosticHoriz( Kgg,inputs,analysis_type,sub_analysis_type); 299 299 } 300 300 else if (sub_analysis_type==VertAnalysisEnum()){ 301 301 302 302 CreateKMatrixDiagnosticVert( Kgg,inputs,analysis_type,sub_analysis_type); 303 303 } 304 304 else if (sub_analysis_type==StokesAnalysisEnum()){ 305 305 306 306 CreateKMatrixDiagnosticStokes( Kgg,inputs,analysis_type,sub_analysis_type); 307 307 308 308 } 309 309 else throw ErrorException(__FUNCT__,exprintf("%s%i%s\n","sub_analysis: ",sub_analysis_type," not supported yet")); 310 310 } 311 311 else if (analysis_type==SlopeComputeAnalysisEnum()){ 312 312 313 313 CreateKMatrixSlopeCompute( Kgg,inputs,analysis_type,sub_analysis_type); 314 314 } 315 315 else if (analysis_type==ThermalAnalysisEnum()){ 316 316 317 317 CreateKMatrixThermal( Kgg,inputs,analysis_type,sub_analysis_type); 318 318 } 319 319 else if (analysis_type==MeltingAnalysisEnum()){ 320 320 321 321 CreateKMatrixMelting( Kgg,inputs,analysis_type,sub_analysis_type); 322 322 } … … 342 342 int doflist[numdof]; 343 343 int numberofdofspernode; 344 345 344 345 346 346 /* 3d gaussian points: */ 347 347 int num_gauss,ig; … … 359 359 int num_area_gauss; 360 360 double gauss_weight; 361 361 362 362 /* 2d gaussian point: */ 363 363 int num_gauss2d; … … 391 391 double Ke_gg_drag_gaussian[numdof][numdof]; //stiffness matrix contribution from drag 392 392 double Jdet; 393 393 394 394 /*slope: */ 395 395 double slope[2]={0.0,0.0}; … … 454 454 } 455 455 456 #ifdef _DEBUGELEMENTS_456 #ifdef _DEBUGELEMENTS_ 457 457 if(my_rank==RANK && id==ELID){ 458 458 printf("El id %i Rank %i PentaElement input list before gaussian loop: \n",ELID,RANK); … … 471 471 printf(" temperature_average [%g %g %g %g %g %g]\n",temperature_average_list[0],temperature_average_list[1],temperature_average_list[2],temperature_average_list[3],temperature_average_list[4],temperature_average_list[5]); 472 472 } 473 #endif473 #endif 474 474 475 475 /*Get gaussian points and weights. Penta is an extrusion of a Tria, we therefore … … 484 484 GaussPenta( &num_area_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &area_gauss_weights, &fourth_gauss_vert_coord,&vert_gauss_weights,order_area_gauss,num_vert_gauss); 485 485 486 #ifdef _DEBUGGAUSS_486 #ifdef _DEBUGGAUSS_ 487 487 if(my_rank==RANK && id==ELID){ 488 488 printf("El id %i Rank %i PentaElement gauss points\n",ELID,RANK); … … 494 494 } 495 495 } 496 #endif496 #endif 497 497 /* Start looping on the number of gaussian points: */ 498 498 for (ig1=0; ig1<num_area_gauss; ig1++){ 499 499 for (ig2=0; ig2<num_vert_gauss; ig2++){ 500 500 501 501 /*Pick up the gaussian point: */ 502 502 gauss_weight1=*(area_gauss_weights+ig1); 503 503 gauss_weight2=*(vert_gauss_weights+ig2); 504 504 gauss_weight=gauss_weight1*gauss_weight2; 505 506 505 506 507 507 gauss_l1l2l3l4[0]=*(first_gauss_area_coord+ig1); 508 508 gauss_l1l2l3l4[1]=*(second_gauss_area_coord+ig1); … … 514 514 GetStrainRate(&epsilon[0],&vxvy_list[0][0],&xyz_list[0][0],gauss_l1l2l3l4); 515 515 GetStrainRate(&oldepsilon[0],&oldvxvy_list[0][0],&xyz_list[0][0],gauss_l1l2l3l4); 516 516 517 517 /*Get viscosity: */ 518 518 matice->GetViscosity3d(&viscosity, &epsilon[0]); … … 525 525 /* Get Jacobian determinant: */ 526 526 GetJacobianDeterminant(&Jdet, &xyz_list[0][0],gauss_l1l2l3l4); 527 527 528 528 /*Build the D matrix: we plug the gaussian weight, the thickness, the viscosity, and the jacobian determinant 529 529 onto this scalar matrix, so that we win some computational time: */ 530 530 531 531 newviscosity=viscosity+viscosity_overshoot*(viscosity-oldviscosity); 532 532 D_scalar=newviscosity*gauss_weight*Jdet; … … 534 534 D[i][i]=D_scalar; 535 535 } 536 536 537 537 /* Do the triple product tB*D*Bprime: */ 538 538 TripleMultiply( &B[0][0],5,numdof,1, 539 540 541 539 &D[0][0],5,5,0, 540 &Bprime[0][0],5,numdof,0, 541 &Ke_gg_gaussian[0][0],0); 542 542 543 543 /* Add the Ke_gg_gaussian, and optionally Ke_gg_gaussian onto Ke_gg: */ … … 549 549 } //for (ig2=0; ig2<num_vert_gauss; ig2++) 550 550 } //for (ig1=0; ig1<num_area_gauss; ig1++) 551 551 552 552 553 553 /*Add Ke_gg to global matrix Kgg: */ 554 554 MatSetValues(Kgg,numdof,doflist,numdof,doflist,(const double*)Ke_gg,ADD_VALUES); 555 555 556 556 //Deal with 2d friction at the bedrock interface 557 557 if((onbed && !shelf)){ … … 567 567 568 568 } 569 570 cleanup_and_return:569 570 cleanup_and_return: 571 571 xfree((void**)&first_gauss_area_coord); 572 572 xfree((void**)&second_gauss_area_coord); … … 627 627 /*recover pointers: */ 628 628 inputs=(ParameterInputs*)vinputs; 629 629 630 630 631 631 /*If this element is on the surface, we have a dynamic boundary condition that applies, as a stiffness … … 660 660 661 661 GaussPenta( &num_area_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &area_gauss_weights, &fourth_gauss_vert_coord,&vert_gauss_weights,order_area_gauss,num_vert_gauss); 662 #ifdef _DEBUG_662 #ifdef _DEBUG_ 663 663 for (i=0;i<num_area_gauss;i++){ 664 664 _printf_("Area Gauss coord %i: %lf %lf %lf Weight: %lf\n",i,*(first_gauss_area_coord+i),*(second_gauss_area_coord+i),*(third_gauss_area_coord+i),*(area_gauss_weights+i)); … … 667 667 _printf_("Vert Gauss coord %i: %lf Weight: %lf\n",i,*(fourth_gauss_vert_coord+i),*(vert_gauss_weights+i)); 668 668 } 669 #endif670 669 #endif 670 671 671 /* Start looping on the number of gaussian points: */ 672 672 for (ig1=0; ig1<num_area_gauss; ig1++){ 673 673 for (ig2=0; ig2<num_vert_gauss; ig2++){ 674 674 675 675 /*Pick up the gaussian point: */ 676 676 gauss_weight1=*(area_gauss_weights+ig1); 677 677 gauss_weight2=*(vert_gauss_weights+ig2); 678 678 gauss_weight=gauss_weight1*gauss_weight2; 679 679 680 680 gauss_l1l2l3l4[0]=*(first_gauss_area_coord+ig1); 681 681 gauss_l1l2l3l4[1]=*(second_gauss_area_coord+ig1); … … 693 693 /* Do the triple product tB*D*Bprime: */ 694 694 TripleMultiply( &B[0][0],1,numgrids,1, 695 696 697 695 &DL_scalar,1,1,0, 696 &Bprime[0][0],1,numgrids,0, 697 &Ke_gg_gaussian[0][0],0); 698 698 699 699 /* Add the Ke_gg_gaussian, and optionally Ke_gg_drag_gaussian onto Ke_gg: */ … … 708 708 /*Add Ke_gg to global matrix Kgg: */ 709 709 MatSetValues(Kgg,numdof,doflist,numdof,doflist,(const double*)Ke_gg,ADD_VALUES); 710 711 cleanup_and_return:710 711 cleanup_and_return: 712 712 xfree((void**)&first_gauss_area_coord); 713 713 xfree((void**)&second_gauss_area_coord); … … 740 740 double gravity,rho_ice,rho_water; 741 741 742 742 743 743 /*Collapsed formulation: */ 744 744 Tria* tria=NULL; … … 746 746 /*Grid data: */ 747 747 double xyz_list[numgrids][3]; 748 748 749 749 /*parameters: */ 750 750 double xyz_list_tria[numgrids2d][3]; … … 770 770 double DLStokes[14][14]={0.0}; 771 771 double tLDStokes[numdof2d][14]; 772 772 773 773 /* gaussian points: */ 774 774 int num_area_gauss; … … 792 792 double alpha2_list[numgrids2d]; 793 793 double alpha2_gauss; 794 794 795 795 ParameterInputs* inputs=NULL; 796 796 … … 804 804 } 805 805 } 806 806 807 807 /*recovre material parameters: */ 808 808 rho_water=matpar->GetRhoWater(); … … 818 818 819 819 /* Get gaussian points and weights. Penta is an extrusion of a Tria, we therefore 820 821 822 823 820 get tria gaussian points as well as segment gaussian points. For tria gaussian 821 points, order of integration is 2, because we need to integrate the product tB*D*B' 822 which is a polynomial of degree 3 (see GaussTria for more details). For segment gaussian 823 points, same deal, which yields 3 gaussian points.*/ 824 824 825 825 area_order=5; … … 845 845 /*Compute strain rate: */ 846 846 GetStrainRateStokes(&epsilon[0],&vxvyvz_list[0][0],&xyz_list[0][0],gauss_coord); 847 847 848 848 /*Get viscosity: */ 849 849 matice->GetViscosity3dStokes(&viscosity,&epsilon[0]); … … 883 883 /*Build alpha2_list used by drag stiffness matrix*/ 884 884 Friction* friction=NewFriction(); 885 885 886 886 /*Initialize all fields: */ 887 887 friction->element_type=(char*)xmalloc((strlen("2d")+1)*sizeof(char)); 888 888 strcpy(friction->element_type,"2d"); 889 889 890 890 friction->gravity=matpar->GetG(); 891 891 friction->rho_ice=matpar->GetRhoIce(); … … 910 910 } 911 911 } 912 912 913 913 GaussTria (&num_area_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &area_gauss_weights, 2); 914 914 … … 920 920 gauss_coord[2]=*(third_gauss_area_coord+igarea); 921 921 gauss_coord[3]=-1; 922 922 923 923 gauss_coord_tria[0]=*(first_gauss_area_coord+igarea); 924 924 gauss_coord_tria[1]=*(second_gauss_area_coord+igarea); 925 925 gauss_coord_tria[2]=*(third_gauss_area_coord+igarea); 926 926 927 927 /*Get the Jacobian determinant */ 928 928 tria->GetJacobianDeterminant3d(&Jdet2d, &xyz_list_tria[0][0], gauss_coord_tria); 929 929 930 930 /*Get L matrix if viscous basal drag present: */ 931 931 GetLStokes(&LStokes[0][0], gauss_coord_tria); 932 932 GetLprimeStokes(&LprimeStokes[0][0], &xyz_list[0][0], gauss_coord_tria, gauss_coord); 933 933 934 934 /*Compute strain rate: */ 935 935 GetStrainRateStokes(&epsilon[0],&vxvyvz_list[0][0],&xyz_list[0][0],gauss_coord); 936 936 937 937 /*Get viscosity at last iteration: */ 938 938 matice->GetViscosity3dStokes(&viscosity,&epsilon[0]); 939 939 940 940 /*Get normal vecyor to the bed */ 941 941 SurfaceNormal(&surface_normal[0],xyz_list_tria); 942 942 943 943 bed_normal[0]=-surface_normal[0]; //Program is for surface, so the normal to the bed is the opposite of the result 944 944 bed_normal[1]=-surface_normal[1]; … … 974 974 } 975 975 } //if ( (onbed==1) && (shelf==0)) 976 976 977 977 /*Reduce the matrix */ 978 978 ReduceMatrixStokes(&Ke_reduced[0][0], &Ke_temp[0][0]); … … 986 986 /*Add Ke_gg to global matrix Kgg: */ 987 987 MatSetValues(Kgg,numdof,doflist,numdof,doflist,(const double*)K_terms,ADD_VALUES); 988 989 cleanup_and_return:988 989 cleanup_and_return: 990 990 991 991 return; … … 998 998 /*Just branch to the correct element stiffness matrix generator, according to the type of analysis we are carrying out: */ 999 999 if (analysis_type==ControlAnalysisEnum()){ 1000 1000 1001 1001 CreatePVectorDiagnosticHoriz( pg,inputs,analysis_type,sub_analysis_type); 1002 1002 } 1003 1003 else if (analysis_type==DiagnosticAnalysisEnum()){ 1004 1004 1005 1005 if (sub_analysis_type==HorizAnalysisEnum()){ 1006 1006 … … 1008 1008 } 1009 1009 else if (sub_analysis_type==VertAnalysisEnum()){ 1010 1010 1011 1011 CreatePVectorDiagnosticVert( pg,inputs,analysis_type,sub_analysis_type); 1012 1012 } 1013 1013 else if (sub_analysis_type==StokesAnalysisEnum()){ 1014 1014 1015 1015 CreatePVectorDiagnosticStokes( pg,inputs,analysis_type,sub_analysis_type); 1016 1016 } … … 1018 1018 } 1019 1019 else if (analysis_type==SlopeComputeAnalysisEnum()){ 1020 1020 1021 1021 CreatePVectorSlopeCompute( pg,inputs,analysis_type,sub_analysis_type); 1022 1022 } 1023 1023 else if (analysis_type==ThermalAnalysisEnum()){ 1024 1024 1025 1025 CreatePVectorThermal( pg,inputs,analysis_type,sub_analysis_type); 1026 1026 } 1027 1027 else if (analysis_type==MeltingAnalysisEnum()){ 1028 1028 1029 1029 CreatePVectorMelting( pg,inputs,analysis_type,sub_analysis_type); 1030 1030 } … … 1056 1056 inputs->Recover("melting",&melting[0],1,dofs,6,(void**)nodes); 1057 1057 inputs->Recover("accumulation_param",&accumulation[0],1,dofs,6,(void**)nodes); 1058 1058 1059 1059 //Update material if necessary 1060 1060 if(inputs->Recover("temperature_average",&temperature_list[0],1,dofs,6,(void**)nodes)){ … … 1063 1063 matice->SetB(B_average); 1064 1064 } 1065 1065 1066 1066 if(inputs->Recover("B",&B_list[0],1,dofs,6,(void**)nodes)){ 1067 1067 B_average=(B_list[0]+B_list[1]+B_list[2]+B_list[3]+B_list[4]+B_list[5])/6.0; … … 1088 1088 } 1089 1089 } 1090 1090 1091 1091 int Penta::GetOnBed(){ 1092 1092 return onbed; … … 1099 1099 } 1100 1100 void Penta::GetBedList(double* bed_list){ 1101 1101 1102 1102 int i; 1103 1103 for(i=0;i<6;i++)bed_list[i]=b[i]; … … 1115 1115 int i; 1116 1116 Tria* tria=NULL; 1117 1117 1118 1118 /*Bail out if this element if: 1119 1119 * -> Non collapsed and not on the surface … … 1132 1132 } 1133 1133 else{ 1134 1134 1135 1135 tria=(Tria*)SpawnTria(3,4,5); //grids 3, 4 and 5 make the new tria (upper face). 1136 1136 tria->Du(du_g,u_g,u_g_obs,inputs,analysis_type,sub_analysis_type); … … 1156 1156 #define __FUNCT__ "Penta::GradjDrag" 1157 1157 void Penta::GradjDrag(Vec grad_g,double* u_g,double* lambda_g,void* inputs,int analysis_type,int sub_analysis_type){ 1158 1159 1158 1159 1160 1160 Tria* tria=NULL; 1161 1161 1162 1162 /*Bail out if this element does not touch the bedrock: */ 1163 1163 if (!onbed){ … … 1165 1165 } 1166 1166 else{ 1167 1167 1168 1168 tria=(Tria*)SpawnTria(0,1,2); //grids 0, 1 and 2 make the new tria. 1169 1169 tria->GradjDrag( grad_g,u_g,lambda_g,inputs,analysis_type,sub_analysis_type); … … 1178 1178 throw ErrorException(__FUNCT__," not supported yet!"); 1179 1179 } 1180 1180 1181 1181 #undef __FUNCT__ 1182 1182 #define __FUNCT__ "Penta::Misfit" 1183 1183 double Penta::Misfit(double* velocity,double* obs_velocity,void* inputs,int analysis_type,int sub_analysis_type){ 1184 1184 1185 1185 double J; 1186 1186 Tria* tria=NULL; 1187 1187 1188 1188 /*Bail out if this element if: 1189 1189 * -> Non collapsed and not on the surface … … 1209 1209 } 1210 1210 } 1211 1211 1212 1212 #undef __FUNCT__ 1213 1213 #define __FUNCT__ "Penta::SpawnTria" … … 1224 1224 double tria_accumulation[3]; 1225 1225 double tria_geothermalflux[3]; 1226 1226 1227 1227 /*configuration: */ 1228 1228 int tria_node_ids[3]; … … 1249 1249 tria_melting[1]=melting[g1]; 1250 1250 tria_melting[2]=melting[g2]; 1251 1251 1252 1252 tria_accumulation[0]=accumulation[g0]; 1253 1253 tria_accumulation[1]=accumulation[g1]; … … 1270 1270 tria_node_offsets[2]=node_offsets[g2]; 1271 1271 1272 tria= new Tria(id,mid,mparid,tria_node_ids,tria_h,tria_s,tria_b,tria_k, tria_melting, tria_accumulation, tria_geothermalflux,friction_type,p,q,shelf,meanvel,epsvel,viscosity_overshoot );1272 tria= new Tria(id,mid,mparid,tria_node_ids,tria_h,tria_s,tria_b,tria_k, tria_melting, tria_accumulation, tria_geothermalflux,friction_type,p,q,shelf,meanvel,epsvel,viscosity_overshoot,artdiff); 1273 1273 1274 1274 tria->NodeConfiguration(tria_node_ids,tria_nodes,tria_node_offsets); … … 1286 1286 int doflist_per_node[MAXDOFSPERNODE]; 1287 1287 int numberofdofspernode; 1288 1288 1289 1289 for(i=0;i<6;i++){ 1290 1290 nodes[i]->GetDofList(&doflist_per_node[0],&numberofdofspernode); … … 1320 1320 GetB(&B[0][0], xyz_list, gauss_l1l2l3l4); 1321 1321 1322 #ifdef _DEBUG_1322 #ifdef _DEBUG_ 1323 1323 _printf_("B for grid1 : [ %lf %lf \n",B[0][0],B[0][1]); 1324 1324 _printf_(" [ %lf %lf \n",B[1][0],B[1][1]); … … 1326 1326 _printf_(" [ %lf %lf ]\n",B[3][0],B[3][1]); 1327 1327 _printf_(" [ %lf %lf ]\n",B[4][0],B[4][1]); 1328 1328 1329 1329 _printf_("B for grid2 : [ %lf %lf \n",B[0][2],B[0][3]); 1330 1330 _printf_(" [ %lf %lf \n",B[1][2],B[1][3]); … … 1332 1332 _printf_(" [ %lf %lf ]\n",B[3][2],B[3][3]); 1333 1333 _printf_(" [ %lf %lf ]\n",B[4][2],B[4][3]); 1334 1334 1335 1335 _printf_("B for grid3 : [ %lf %lf \n", B[0][4],B[0][5]); 1336 1336 _printf_(" [ %lf %lf \n", B[1][4],B[1][5]); … … 1338 1338 _printf_(" [ %lf %lf ]\n",B[3][4],B[3][5]); 1339 1339 _printf_(" [ %lf %lf ]\n",B[4][4],B[4][5]); 1340 1340 1341 1341 _printf_("B for grid4 : [ %lf %lf \n", B[0][6],B[0][7]); 1342 1342 _printf_(" [ %lf %lf \n", B[1][6],B[1][7]); … … 1344 1344 _printf_(" [ %lf %lf ]\n",B[3][6],B[3][7]); 1345 1345 _printf_(" [ %lf %lf ]\n",B[4][6],B[4][7]); 1346 1346 1347 1347 _printf_("B for grid5 : [ %lf %lf \n", B[0][8],B[0][9]); 1348 1348 _printf_(" [ %lf %lf \n", B[1][8],B[1][9]); … … 1360 1360 _printf_("Velocity for grid %i %lf %lf\n",i,*(vxvy_list+2*i+0),*(vxvy_list+2*i+1)); 1361 1361 } 1362 #endif1362 #endif 1363 1363 1364 1364 /*Multiply B by velocity, to get strain rate: */ 1365 1365 MatrixMultiply( &B[0][0],5,NDOF2*numgrids,0, 1366 1367 epsilon,0);1366 velocity,NDOF2*numgrids,1,0, 1367 epsilon,0); 1368 1368 1369 1369 } … … 1385 1385 * We assume B has been allocated already, of size: 5x(NDOF2*numgrids) 1386 1386 */ 1387 1387 1388 1388 int i; 1389 1389 const int numgrids=6; … … 1396 1396 GetNodalFunctionsDerivativesBasic(&dh1dh2dh3dh4dh5dh6_basic[0][0],xyz_list, gauss_l1l2l3l4); 1397 1397 1398 #ifdef _DEBUG_1398 #ifdef _DEBUG_ 1399 1399 for (i=0;i<numgrids;i++){ 1400 1400 _printf_("Node %i dh/dx=%lf dh/dy=%lf dh/dz=%lf\n",i,dh1dh2dh3dh4dh5dh6_basic[0][i],dh1dh2dh3dh4dh5dh6_basic[1][i],dh1dh2dh3dh4dh5dh6_basic[2][i]); 1401 1401 } 1402 #endif1402 #endif 1403 1403 1404 1404 /*Build B: */ … … 1415 1415 *(B+NDOF2*numgrids*3+NDOF2*i)=(float).5*dh1dh2dh3dh4dh5dh6_basic[2][i]; 1416 1416 *(B+NDOF2*numgrids*3+NDOF2*i+1)=0.0; 1417 1417 1418 1418 *(B+NDOF2*numgrids*4+NDOF2*i)=0.0; 1419 1419 *(B+NDOF2*numgrids*4+NDOF2*i+1)=(float).5*dh1dh2dh3dh4dh5dh6_basic[2][i]; … … 1439 1439 * We assume B has been allocated already, of size: 5x(NDOF2*numgrids) 1440 1440 */ 1441 1441 1442 1442 int i; 1443 1443 const int NDOF3=3; … … 1450 1450 GetNodalFunctionsDerivativesBasic(&dh1dh2dh3dh4dh5dh6_basic[0][0],xyz_list, gauss_l1l2l3l4); 1451 1451 1452 #ifdef _DEBUG_1452 #ifdef _DEBUG_ 1453 1453 for (i=0;i<numgrids;i++){ 1454 1454 _printf_("Node %i dh/dx=%lf dh/dy=%lf dh/dz=%lf\n",i,dh1dh2dh3dh4dh5dh6_basic[0][i],dh1dh2dh3dh4dh5dh6_basic[1][i],dh1dh2dh3dh4dh5dh6_basic[2][i]); 1455 1455 } 1456 #endif1456 #endif 1457 1457 1458 1458 /*Build BPrime: */ … … 1469 1469 *(B+NDOF2*numgrids*3+NDOF2*i)=dh1dh2dh3dh4dh5dh6_basic[2][i]; 1470 1470 *(B+NDOF2*numgrids*3+NDOF2*i+1)=0.0; 1471 1471 1472 1472 *(B+NDOF2*numgrids*4+NDOF2*i)=0.0; 1473 1473 *(B+NDOF2*numgrids*4+NDOF2*i+1)=dh1dh2dh3dh4dh5dh6_basic[2][i]; … … 1482 1482 * the determinant of it: */ 1483 1483 const int NDOF3=3; 1484 1484 1485 1485 double J[NDOF3][NDOF3]; 1486 1486 … … 1496 1496 #define __FUNCT__ "Penta::GetNodalFunctionsDerivativesBasic" 1497 1497 void Penta::GetNodalFunctionsDerivativesBasic(double* dh1dh2dh3dh4dh5dh6_basic,double* xyz_list, double* gauss_l1l2l3l4){ 1498 1498 1499 1499 /*This routine returns the values of the nodal functions derivatives (with respect to the basic coordinate system: */ 1500 1500 1501 1501 1502 1502 int i; 1503 1503 const int NDOF3=3; … … 1534 1534 const int NDOF3=3; 1535 1535 int i,j; 1536 1536 1537 1537 /*The Jacobian is constant over the element, discard the gaussian points. 1538 1538 * J is assumed to have been allocated of size NDOF2xNDOF2.*/ … … 1544 1544 double y1,y2,y3,y4,y5,y6; 1545 1545 double z1,z2,z3,z4,z5,z6; 1546 1546 1547 1547 double sqrt3=sqrt(3.0); 1548 1548 1549 1549 /*Figure out xi,eta and zi (parametric coordinates), for this gaussian point: */ 1550 1550 A1=gauss_l1l2l3l4[0]; … … 1562 1562 x5=*(xyz_list+3*4+0); 1563 1563 x6=*(xyz_list+3*5+0); 1564 1564 1565 1565 y1=*(xyz_list+3*0+1); 1566 1566 y2=*(xyz_list+3*1+1); … … 1590 1590 *(J+NDOF3*2+2)=sqrt3/12.0*(z1+z2-2*z3-z4-z5+2*z6)*eta+1.0/4.0*(z1-z2-z4+z5)*xi+1.0/4.0*(-z1+z5-z2+z4); 1591 1591 1592 #ifdef _DEBUG_1592 #ifdef _DEBUG_ 1593 1593 for(i=0;i<3;i++){ 1594 1594 for (j=0;j<3;j++){ … … 1597 1597 printf("\n"); 1598 1598 } 1599 #endif1599 #endif 1600 1600 } 1601 1601 … … 1603 1603 #define __FUNCT__ "Penta::GetNodalFunctionsDerivativesParams" 1604 1604 void Penta::GetNodalFunctionsDerivativesParams(double* dl1dl2dl3dl4dl5dl6,double* gauss_l1l2l3l4){ 1605 1605 1606 1606 /*This routine returns the values of the nodal functions derivatives (with respect to the 1607 1607 * natural coordinate system) at the gaussian point. Those values vary along xi,eta,z */ … … 1610 1610 double A1,A2,A3,z; 1611 1611 double sqrt3=sqrt(3.0); 1612 1612 1613 1613 A1=gauss_l1l2l3l4[0]; //first area coordinate value. In term of xi and eta: A1=(1-xi)/2-eta/(2*sqrt(3)); 1614 1614 A2=gauss_l1l2l3l4[1]; //second area coordinate value In term of xi and eta: A2=(1+xi)/2-eta/(2*sqrt(3)); … … 1677 1677 int doflist[numdof]; 1678 1678 int numberofdofspernode; 1679 1679 1680 1680 /* parameters: */ 1681 1681 double slope[NDOF2]; … … 1752 1752 1753 1753 GaussPenta( &num_area_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &area_gauss_weights, &fourth_gauss_vert_coord,&vert_gauss_weights,order_area_gauss,num_vert_gauss); 1754 #ifdef _DEBUG_1754 #ifdef _DEBUG_ 1755 1755 for (i=0;i<num_area_gauss;i++){ 1756 1756 _printf_("Area Gauss coord %i: %lf %lf %lf Weight: %lf\n",i,*(first_gauss_area_coord+i),*(second_gauss_area_coord+i),*(third_gauss_area_coord+i),*(area_gauss_weights+i)); … … 1759 1759 _printf_("Vert Gauss coord %i: %lf Weight: %lf\n",i,*(fourth_gauss_vert_coord+i),*(vert_gauss_weights+i)); 1760 1760 } 1761 #endif1762 1761 #endif 1762 1763 1763 /* Start looping on the number of gaussian points: */ 1764 1764 for (ig1=0; ig1<num_area_gauss; ig1++){ 1765 1765 for (ig2=0; ig2<num_vert_gauss; ig2++){ 1766 1766 1767 1767 /*Pick up the gaussian point: */ 1768 1768 gauss_weight1=*(area_gauss_weights+ig1); 1769 1769 gauss_weight2=*(vert_gauss_weights+ig2); 1770 1770 gauss_weight=gauss_weight1*gauss_weight2; 1771 1771 1772 1772 gauss_l1l2l3l4[0]=*(first_gauss_area_coord+ig1); 1773 1773 gauss_l1l2l3l4[1]=*(second_gauss_area_coord+ig1); 1774 1774 gauss_l1l2l3l4[2]=*(third_gauss_area_coord+ig1); 1775 1775 gauss_l1l2l3l4[3]=*(fourth_gauss_vert_coord+ig2); 1776 1776 1777 1777 /*Compute thickness at gaussian point: */ 1778 1778 GetParameterValue(&thickness, &h[0],gauss_l1l2l3l4); … … 1783 1783 /* Get Jacobian determinant: */ 1784 1784 GetJacobianDeterminant(&Jdet, &xyz_list[0][0],gauss_l1l2l3l4); 1785 1786 /*Get nodal functions: */1785 1786 /*Get nodal functions: */ 1787 1787 GetNodalFunctions(l1l2l3l4l5l6, gauss_l1l2l3l4); 1788 1788 … … 1808 1808 VecSetValues(pg,numdof,doflist,(const double*)pe_g,ADD_VALUES); 1809 1809 1810 cleanup_and_return:1810 cleanup_and_return: 1811 1811 xfree((void**)&first_gauss_area_coord); 1812 1812 xfree((void**)&second_gauss_area_coord); … … 1822 1822 #define __FUNCT__ "Penta::CreateKMatrix" 1823 1823 void Penta::GetParameterValue(double* pvalue, double* v_list,double* gauss_l1l2l3l4){ 1824 1824 1825 1825 const int numgrids=6; 1826 1826 double l1l2l3l4l5l6[numgrids]; … … 1834 1834 #define __FUNCT__ "Penta::GetParameterDerivativeValue" 1835 1835 void Penta::GetParameterDerivativeValue(double* p, double* p_list,double* xyz_list, double* gauss_l1l2l3l4){ 1836 1836 1837 1837 /*From grid values of parameter p (p_list[0], p_list[1], p_list[2], p_list[3], p_list[4] and p_list[4]), return parameter derivative value at gaussian point specified by gauss_l1l2l3l4: 1838 1838 * dp/dx=p_list[0]*dh1/dx+p_list[1]*dh2/dx+p_list[2]*dh3/dx+p_list[3]*dh4/dx+p_list[4]*dh5/dx+p_list[5]*dh6/dx; … … 1849 1849 /*Get dh1dh2dh3dh4dh5dh6_basic in basic coordinate system: */ 1850 1850 GetNodalFunctionsDerivativesBasic(&dh1dh2dh3dh4dh5dh6_basic[0][0],xyz_list, gauss_l1l2l3l4); 1851 1851 1852 1852 *(p+0)=p_list[0]*dh1dh2dh3dh4dh5dh6_basic[0][0]+p_list[1]*dh1dh2dh3dh4dh5dh6_basic[0][1]+p_list[2]*dh1dh2dh3dh4dh5dh6_basic[0][2]+p_list[3]*dh1dh2dh3dh4dh5dh6_basic[0][3]+p_list[4]*dh1dh2dh3dh4dh5dh6_basic[0][4]+p_list[5]*dh1dh2dh3dh4dh5dh6_basic[0][5]; 1853 1853 ; 1854 1854 *(p+1)=p_list[0]*dh1dh2dh3dh4dh5dh6_basic[1][0]+p_list[1]*dh1dh2dh3dh4dh5dh6_basic[1][1]+p_list[2]*dh1dh2dh3dh4dh5dh6_basic[1][2]+p_list[3]*dh1dh2dh3dh4dh5dh6_basic[1][3]+p_list[4]*dh1dh2dh3dh4dh5dh6_basic[1][4]+p_list[5]*dh1dh2dh3dh4dh5dh6_basic[1][5]; 1855 1855 … … 1861 1861 #define __FUNCT__ "Penta::GetNodalFunctions" 1862 1862 void Penta::GetNodalFunctions(double* l1l2l3l4l5l6, double* gauss_l1l2l3l4){ 1863 1863 1864 1864 /*This routine returns the values of the nodal functions at the gaussian point.*/ 1865 1865 … … 1867 1867 1868 1868 l1l2l3l4l5l6[1]=gauss_l1l2l3l4[1]*(1-gauss_l1l2l3l4[3])/2.0; 1869 1869 1870 1870 l1l2l3l4l5l6[2]=gauss_l1l2l3l4[2]*(1-gauss_l1l2l3l4[3])/2.0; 1871 1871 … … 1873 1873 1874 1874 l1l2l3l4l5l6[4]=gauss_l1l2l3l4[1]*(1+gauss_l1l2l3l4[3])/2.0; 1875 1875 1876 1876 l1l2l3l4l5l6[5]=gauss_l1l2l3l4[2]*(1+gauss_l1l2l3l4[3])/2.0; 1877 1877 … … 1888 1888 int nodedofs[2]; 1889 1889 int numberofdofspernode; 1890 1890 1891 1891 Node* node=NULL; 1892 1892 int i; 1893 1893 double velocity[2]; 1894 1894 1895 1895 1896 1896 if((collapse==1) && (onbed==1)){ 1897 1897 1898 1898 GetDofList(&doflist[0],&numberofdofspernode); 1899 1899 … … 1902 1902 * inserting the same velocity value into ug, until we reach the surface: */ 1903 1903 for(i=0;i<3;i++){ 1904 1904 1905 1905 node=nodes[i]; //base nodes 1906 1906 1907 1907 /*get velocity for this base node: */ 1908 1908 velocity[0]=ug_serial[doflist[numberofdofspernode*i+0]]; … … 1926 1926 1927 1927 } 1928 1929 #undef __FUNCT__ 1930 #define __FUNCT__ "Penta::VelocityExtrudeAllElements" 1931 void Penta::VelocityExtrudeAllElements(Vec ug,double* ug_serial){ 1932 1933 /* node data: */ 1934 const int numgrids=6; 1935 const int numdof=2*numgrids; 1936 int doflist[numdof]; 1937 int nodedofs[2]; 1938 int numberofdofspernode; 1939 1940 Node* node=NULL; 1941 int i; 1942 double velocity[2]; 1943 1944 1945 if(onbed==1){ 1946 1947 GetDofList(&doflist[0],&numberofdofspernode); 1948 1949 /*this penta is on the bed. For each node on the base of this penta, 1950 * we grab the velocity. Once we know the velocity, we follow the upper nodes, 1951 * inserting the same velocity value into ug, until we reach the surface: */ 1952 for(i=0;i<3;i++){ 1953 1954 node=nodes[i]; //base nodes 1955 1956 /*get velocity for this base node: */ 1957 velocity[0]=ug_serial[doflist[numberofdofspernode*i+0]]; 1958 velocity[1]=ug_serial[doflist[numberofdofspernode*i+1]]; 1959 1960 //go througn all nodes which sit on top of this node, until we reach the surface, 1961 //and plug velocity in ug 1962 for(;;){ 1963 1964 node->GetDofList(&nodedofs[0],&numberofdofspernode); 1965 VecSetValues(ug,1,&nodedofs[0],&velocity[0],INSERT_VALUES); 1966 VecSetValues(ug,1,&nodedofs[1],&velocity[1],INSERT_VALUES); 1967 1968 if (node->IsOnSurface())break; 1969 /*get next node: */ 1970 node=node->GetUpperNode(); 1971 } 1972 } 1973 1974 } 1975 1976 } 1977 1978 #undef __FUNCT__ 1979 #define __FUNCT__ "Penta::ThicknessExtrude" 1980 void Penta::ThicknessExtrude(Vec tg,double* tg_serial){ 1981 1982 /* node data: */ 1983 const int numgrids=6; 1984 const int numdof=1*numgrids; 1985 int doflist[numdof]; 1986 int nodedofs; 1987 int numberofdofspernode; 1988 1989 Node* node=NULL; 1990 int i; 1991 double thickness; 1992 1993 1994 if(onbed==1){ 1995 1996 GetDofList(&doflist[0],&numberofdofspernode); 1997 1998 /*this penta is on the bed. For each node on the base of this penta, 1999 * we grab the thickness. Once we know the thickness, we follow the upper nodes, 2000 * inserting the same thickness value into tg, until we reach the surface: */ 2001 for(i=0;i<3;i++){ 2002 2003 node=nodes[i]; //base nodes 2004 2005 /*get velocity for this base node: */ 2006 thickness=tg_serial[doflist[numberofdofspernode*i+0]]; 2007 2008 //go through all nodes which sit on top of this node, until we reach the surface, 2009 //and pltg velocity in tg 2010 for(;;){ 2011 2012 node->GetDofList(&nodedofs,&numberofdofspernode); 2013 VecSetValues(tg,1,&nodedofs,&thickness,INSERT_VALUES); 2014 2015 if (node->IsOnSurface())break; 2016 /*get next node: */ 2017 node=node->GetUpperNode(); 2018 } 2019 } 2020 2021 } 2022 2023 } 2024 2025 #undef __FUNCT__ 2026 #define __FUNCT__ "Penta::VelocityDepthAverageAtBase" 2027 void Penta::VelocityDepthAverageAtBase(Vec ug,double* ug_serial){ 2028 2029 /* node data: */ 2030 const int numgrids=6; 2031 const int numdof=2*numgrids; 2032 int doflist[numdof]; 2033 int nodedofs[2]; 2034 int numberofdofspernode; 2035 int dofx,dofy; 2036 2037 Node* node=NULL; 2038 Node* upper_node=NULL; 2039 int i; 2040 double base_velocity[2]; 2041 double velocity2[2]; 2042 double velocity1[2]; 2043 double velocity_average[2]; 2044 double sum[2]; 2045 double z1,z2,dz; 2046 double thickness; 2047 2048 if(onbed==1){ 2049 2050 GetDofList(&doflist[0],&numberofdofspernode); 2051 2052 /*this penta is on the bed. For each node on the base of this penta, we are going to 2053 * follow the upper nodes until we reach the surface. At each upper node, we'll grab the 2054 * velocity for this node, and add it to ug. We'll finish by 2055 * we grab the velocity. Once we know the velocity, we follow the upper nodes, 2056 * inserting the same velocity value into ug, until we reach the surface: */ 2057 for(i=0;i<3;i++){ 2058 2059 //get thickness for this grid 2060 thickness=h[i]; //pick up from the penta element itself. 2061 2062 node=nodes[i]; //base nodes 2063 2064 /*get dofs for this base node velocity: */ 2065 dofx=doflist[numberofdofspernode*i+0]; 2066 dofy=doflist[numberofdofspernode*i+1]; 2067 2068 /*first thing, cancel velocity on the base nodes, so that we start with the value 0: */ 2069 base_velocity[0]=-ug_serial[doflist[numberofdofspernode*i+0]]; //- to cancel 2070 base_velocity[1]=-ug_serial[doflist[numberofdofspernode*i+1]]; 2071 2072 VecSetValues(ug,1,&dofx,&base_velocity[0],ADD_VALUES); 2073 VecSetValues(ug,1,&dofy,&base_velocity[1],ADD_VALUES); 2074 2075 //go through all nodes which sit on top of this node, until we reach the surface, 2076 //and plug deltaV*deltaH/H at base of ug: */ 2077 2078 for(;;){ 2079 2080 if (node->IsOnSurface())break; 2081 2082 node->GetDofList(&nodedofs[0],&numberofdofspernode); 2083 2084 velocity1[0]=ug_serial[nodedofs[numberofdofspernode*i+0]]; 2085 velocity1[1]=ug_serial[nodedofs[numberofdofspernode*i+1]]; 2086 z1=node->GetZ(); 2087 2088 upper_node=node->GetUpperNode(); 2089 upper_node->GetDofList(&nodedofs[0],&numberofdofspernode); 2090 2091 velocity2[0]=ug_serial[nodedofs[numberofdofspernode*i+0]]; 2092 velocity2[1]=ug_serial[nodedofs[numberofdofspernode*i+1]]; 2093 z2=upper_node->GetZ(); 2094 2095 dz=(z2-z1); 2096 velocity_average[0]=(velocity1[0]+velocity2[0])/2.0; 2097 velocity_average[1]=(velocity1[1]+velocity2[1])/2.0; 2098 2099 sum[0]=velocity_average[0]*dz/thickness; 2100 sum[1]=velocity_average[1]*dz/thickness; 2101 2102 /*Plug velocity_average*deltaH/H into base of ug: */ 2103 VecSetValues(ug,1,&dofx,&sum[0],ADD_VALUES); 2104 VecSetValues(ug,1,&dofy,&sum[1],ADD_VALUES); 2105 2106 /*get next node: */ 2107 node=node->GetUpperNode(); 2108 } 2109 } 2110 2111 } 2112 2113 } 2114 1928 2115 1929 2116 #undef __FUNCT__ … … 1938 2125 int nodedof; 1939 2126 int numberofdofspernode; 1940 2127 1941 2128 Node* node=NULL; 1942 2129 int i; 1943 2130 double slope; 1944 2131 1945 2132 1946 2133 if(onbed==1){ 1947 2134 1948 2135 GetDofList(&doflist[0],&numberofdofspernode); 1949 2136 … … 1952 2139 /*For each node on the base of this penta, we grab the slope. Once we know the slope, we follow the upper nodes, 1953 2140 * inserting the same slope value into sg, until we reach the surface: */ 1954 2141 1955 2142 for(i=0;i<3;i++){ 1956 2143 1957 2144 node=nodes[i]; //base nodes 1958 2145 1959 2146 /*get velocity for this base node: */ 1960 2147 slope=sg_serial[doflist[i]]; … … 1984 2171 1985 2172 /* Compute B matrix. B=[dh1/dz dh2/dz dh3/dz dh4/dz dh5/dz dh6/dz]; 1986 2173 where hi is the interpolation function for grid i.*/ 1987 2174 1988 2175 int i; … … 1994 2181 GetNodalFunctionsDerivativesBasic(&dh1dh2dh3dh4dh5dh6_basic[0][0],xyz_list, gauss_l1l2l3l4); 1995 2182 1996 #ifdef _DEBUG_2183 #ifdef _DEBUG_ 1997 2184 for (i=0;i<numgrids;i++){ 1998 2185 _printf_("Node %i dh/dx=%lf dh/dy=%lf dh/dz=%lf\n",i,dh1dh2dh3dh4dh5dh6_basic[0][i],dh1dh2dh3dh4dh5dh6_basic[1][i],dh1dh2dh3dh4dh5dh6_basic[2][i]); 1999 2186 } 2000 #endif2187 #endif 2001 2188 2002 2189 /*Build B: */ … … 2004 2191 B[i]=dh1dh2dh3dh4dh5dh6_basic[2][i]; 2005 2192 } 2006 2193 2007 2194 } 2008 2195 … … 2015 2202 2016 2203 int i; 2017 2204 2018 2205 GetNodalFunctions(B, gauss_l1l2l3l4); 2019 2206 … … 2034 2221 int doflist[numdof]; 2035 2222 int numberofdofspernode; 2036 2223 2037 2224 /* gaussian points: */ 2038 2225 int num_gauss,ig; … … 2094 2281 /* recover input parameters: */ 2095 2282 if(!inputs->Recover("velocity",&vx_list[0],1,dofs1,numgrids,(void**)nodes))throw ErrorException(__FUNCT__," cannot compute vertical velocity without horizontal velocity!"); 2096 inputs->Recover("velocity",&vy_list[0],1,dofs2,numgrids,(void**)nodes);2283 inputs->Recover("velocity",&vy_list[0],1,dofs2,numgrids,(void**)nodes); 2097 2284 2098 2285 /*Get gaussian points and weights :*/ … … 2101 2288 2102 2289 GaussPenta( &num_area_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &area_gauss_weights, &fourth_gauss_vert_coord,&vert_gauss_weights,order_area_gauss,num_vert_gauss); 2103 #ifdef _DEBUG_2290 #ifdef _DEBUG_ 2104 2291 for (i=0;i<num_area_gauss;i++){ 2105 2292 _printf_("Area Gauss coord %i: %lf %lf %lf Weight: %lf\n",i,*(first_gauss_area_coord+i),*(second_gauss_area_coord+i),*(third_gauss_area_coord+i),*(area_gauss_weights+i)); … … 2108 2295 _printf_("Vert Gauss coord %i: %lf Weight: %lf\n",i,*(fourth_gauss_vert_coord+i),*(vert_gauss_weights+i)); 2109 2296 } 2110 #endif2297 #endif 2111 2298 2112 2299 /* Start looping on the number of gaussian points: */ 2113 2300 for (ig1=0; ig1<num_area_gauss; ig1++){ 2114 2301 for (ig2=0; ig2<num_vert_gauss; ig2++){ 2115 2302 2116 2303 /*Pick up the gaussian point: */ 2117 2304 gauss_weight1=*(area_gauss_weights+ig1); 2118 2305 gauss_weight2=*(vert_gauss_weights+ig2); 2119 2306 gauss_weight=gauss_weight1*gauss_weight2; 2120 2307 2121 2308 gauss_l1l2l3l4[0]=*(first_gauss_area_coord+ig1); 2122 2309 gauss_l1l2l3l4[1]=*(second_gauss_area_coord+ig1); 2123 2310 gauss_l1l2l3l4[2]=*(third_gauss_area_coord+ig1); 2124 2311 gauss_l1l2l3l4[3]=*(fourth_gauss_vert_coord+ig2); 2125 2312 2126 2313 /*Get velocity derivative, with respect to x and y: */ 2127 2314 GetParameterDerivativeValue(&du[0], &vx_list[0],&xyz_list[0][0], gauss_l1l2l3l4); … … 2129 2316 dudx=du[0]; 2130 2317 dvdy=dv[1]; 2131 2318 2132 2319 2133 2320 /* Get Jacobian determinant: */ 2134 2321 GetJacobianDeterminant(&Jdet, &xyz_list[0][0],gauss_l1l2l3l4); 2135 #ifdef _DEBUG_2322 #ifdef _DEBUG_ 2136 2323 _printf_("Element id %i Jacobian determinant: %lf\n",PentaElementGetID(this),Jdet); 2137 #endif2138 2139 /*Get nodal functions: */2324 #endif 2325 2326 /*Get nodal functions: */ 2140 2327 GetNodalFunctions(l1l2l3l4l5l6, gauss_l1l2l3l4); 2141 2328 … … 2154 2341 VecSetValues(pg,numdof,doflist,(const double*)pe_g,ADD_VALUES); 2155 2342 2156 cleanup_and_return:2343 cleanup_and_return: 2157 2344 xfree((void**)&first_gauss_area_coord); 2158 2345 xfree((void**)&second_gauss_area_coord); … … 2175 2362 double rho_ice,g; 2176 2363 double xyz_list[numgrids][3]; 2177 2364 2178 2365 /*Get node data: */ 2179 2366 GetElementNodeData( &xyz_list[0][0], nodes, numgrids); 2180 2367 2181 2368 /*pressure is lithostatic: */ 2182 2369 //md.pressure=md.rho_ice*md.g*(md.surface-md.z); a la matlab … … 2191 2378 pressure[i]=rho_ice*g*(s[i]-xyz_list[i][2]); 2192 2379 } 2193 2380 2194 2381 /*plug local pressure values into global pressure vector: */ 2195 2382 VecSetValues(pg,numgrids,doflist,(const double*)pressure,INSERT_VALUES); … … 2205 2392 /*Collapsed formulation: */ 2206 2393 Tria* tria=NULL; 2207 2394 2208 2395 /*Is this element on the bed? :*/ 2209 2396 if(!onbed)return; … … 2221 2408 2222 2409 void Penta::CreatePVectorSlopeCompute( Vec pg, void* inputs, int analysis_type,int sub_analysis_type){ 2223 2410 2224 2411 /*Collapsed formulation: */ 2225 2412 Tria* tria=NULL; 2226 2413 2227 2414 /*Is this element on the bed? :*/ 2228 2415 if(!onbed)return; … … 2238 2425 #define __FUNCT__ "ReduceMatrixStokes" 2239 2426 void Penta::ReduceMatrixStokes(double* Ke_reduced, double* Ke_temp){ 2240 2427 2241 2428 int i,j; 2242 2429 … … 2292 2479 double det; 2293 2480 int calculationdof=3; 2294 2481 2295 2482 /*Take the matrix components: */ 2296 2483 a=*(Ke+calculationdof*0+0); … … 2305 2492 2306 2493 det=a*(e*i-f*h)-b*(d*i-f*g)+c*(d*h-e*g); 2307 2494 2308 2495 *(Ke_invert+calculationdof*0+0)=(e*i-f*h)/det; 2309 2496 *(Ke_invert+calculationdof*0+1)=(c*h-b*i)/det; … … 2392 2579 * For grid i, Bi can be expressed in the basic coordinate system 2393 2580 * by: Bi_basic=[ dh/dx 0 0 0 ] 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2581 * [ 0 dh/dy 0 0 ] 2582 * [ 0 0 dh/dy 0 ] 2583 * [ 1/2*dh/dy 1/2*dh/dx 0 0 ] 2584 * [ 1/2*dh/dz 0 1/2*dh/dx 0 ] 2585 * [ 0 1/2*dh/dz 1/2*dh/dy 0 ] 2586 * [ 0 0 0 h ] 2587 * [ dh/dx dh/dy dh/dz 0 ] 2588 * where h is the interpolation function for grid i. 2589 * Same thing for Bb except the last column that does not exist. 2590 */ 2591 2405 2592 int i; 2406 2593 int calculationdof=3; … … 2416 2603 2417 2604 GetNodalFunctions(l1l6, gauss_coord); 2418 2419 #ifdef _DEBUG_2605 2606 #ifdef _DEBUG_ 2420 2607 for (i=0;i<7;i++){ 2421 2608 printf("Node %i dh/dx=%lf dh/dy=%lf dh/dz=%lf \n",i,dh1dh7_basic[0][i],dh1dh7_basic[1][i],dh1dh7_basic[2][i]); 2422 2609 } 2423 2610 2424 #endif2611 #endif 2425 2612 2426 2613 /*Build B: */ … … 2470 2657 2471 2658 /* Compute B' matrix. B'=[B1' B2' B3' B4' B5' B6' Bb'] where Bi' is of size 3*NDOF2. 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2659 * For grid i, Bi' can be expressed in the basic coordinate system 2660 * by: 2661 * Bi_basic'=[ dh/dx 0 0 0] 2662 * [ 0 dh/dy 0 0] 2663 * [ 0 0 dh/dz 0] 2664 * [ dh/dy dh/dx 0 0] 2665 * [ dh/dz 0 dh/dx 0] 2666 * [ 0 dh/dz dh/dy 0] 2667 * [ dh/dx dh/dy dh/dz 0] 2668 * [ 0 0 0 h] 2669 * where h is the interpolation function for grid i. 2670 * 2671 * Same thing for the bubble fonction except that there is no fourth column 2672 */ 2486 2673 2487 2674 int i; … … 2498 2685 2499 2686 GetNodalFunctions(l1l6, gauss_coord); 2500 2501 #ifdef _DEBUG_2687 2688 #ifdef _DEBUG_ 2502 2689 for (i=0;i<6;i++){ 2503 2690 printf("Node %i dh/dx=%lf dh/dy=%lf dh/dz=%lf \n",i,dh1dh7_basic[0][i],dh1dh7_basic[1][i]); 2504 2691 } 2505 2692 2506 #endif2693 #endif 2507 2694 2508 2695 /*B_primeuild B_prime: */ … … 2551 2738 2552 2739 /* 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2740 * Compute L matrix. L=[L1 L2 L3] where Li is square and of size numdof. 2741 * For grid i, Li can be expressed in the basic coordinate system 2742 * by: 2743 * Li_basic=[ h 0 0 0] 2744 * [ 0 h 0 0] 2745 * [ 0 0 h 0] 2746 * [ 0 0 h 0] 2747 * [ h 0 0 0] 2748 * [ 0 h 0 0] 2749 * [ h 0 0 0] 2750 * [ 0 h 0 0] 2751 * [ 0 0 h 0] 2752 * [ 0 0 h 0] 2753 * [ 0 0 h 0] 2754 * [ h 0 0 0] 2755 * [ 0 h 0 0] 2756 * [ 0 0 h 0] 2757 * where h is the interpolation function for grid i. 2758 */ 2572 2759 2573 2760 int i; … … 2582 2769 l1l2l3[1]=gauss_coord_tria[1]; 2583 2770 l1l2l3[2]=gauss_coord_tria[2]; 2584 2585 2586 #ifdef _DELUG_2771 2772 2773 #ifdef _DELUG_ 2587 2774 for (i=0;i<3;i++){ 2588 2775 printf("Node %i h=%lf \n",i,l1l2l3[i]); 2589 2776 } 2590 #endif2777 #endif 2591 2778 2592 2779 /*Build LStokes: */ … … 2648 2835 *(LStokes+num_dof*numgrids2d*13+num_dof*i+2)=l1l2l3[i]; 2649 2836 *(LStokes+num_dof*numgrids2d*13+num_dof*i+3)=0; 2650 2837 2651 2838 } 2652 2839 } … … 2658 2845 2659 2846 /* 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2847 * Compute Lprime matrix. Lprime=[Lp1 Lp2 Lp3] where Lpi is square and of size numdof. 2848 * For grid i, Lpi can be expressed in the basic coordinate system 2849 * by: 2850 * Lpi_basic=[ h 0 0 0] 2851 * [ 0 h 0 0] 2852 * [ h 0 0 0] 2853 * [ 0 h 0 0] 2854 * [ 0 0 h 0] 2855 * [ 0 0 h 0] 2856 * [ 0 0 dh/dz 0] 2857 * [ 0 0 dh/dz 0] 2858 * [ 0 0 dh/dz 0] 2859 * [dh/dz 0 dh/dx 0] 2860 * [ 0 dh/dz dh/dy 0] 2861 * [ 0 0 0 h] 2862 * [ 0 0 0 h] 2863 * [ 0 0 0 h] 2864 * where h is the interpolation function for grid i. 2865 */ 2679 2866 2680 2867 int i; … … 2690 2877 l1l2l3[1]=gauss_coord_tria[1]; 2691 2878 l1l2l3[2]=gauss_coord_tria[2]; 2692 2879 2693 2880 GetNodalFunctionsDerivativesBasic(&dh1dh6_basic[0][0],xyz_list,gauss_coord); 2694 2881 2695 #ifdef _DELUG_2882 #ifdef _DELUG_ 2696 2883 for (i=0;i<3;i++){ 2697 2884 printf("Node %i h=%lf \n",i,l1l2l3[i]); 2698 2885 } 2699 #endif2886 #endif 2700 2887 2701 2888 /*Build LprimeStokes: */ … … 2757 2944 *(LprimeStokes+num_dof*numgrids2d*13+num_dof*i+2)=0; 2758 2945 *(LprimeStokes+num_dof*numgrids2d*13+num_dof*i+3)=l1l2l3[i]; 2759 2760 } 2761 2946 2947 } 2948 2762 2949 } 2763 2950 … … 2765 2952 #define __FUNCT__ "Penta::GetNodalFunctionsDerivativesBasicStokes" 2766 2953 void Penta::GetNodalFunctionsDerivativesBasicStokes(double* dh1dh7_basic,double* xyz_list, double* gauss_coord){ 2767 2954 2768 2955 /*This routine returns the values of the nodal functions derivatives (with respect to the 2769 2956 * basic coordinate system: */ … … 2801 2988 #define __FUNCT__ "Penta::GetNodalFunctionsDerivativesParamsStokes" 2802 2989 void Penta::GetNodalFunctionsDerivativesParamsStokes(double* dl1dl7,double* gauss_coord){ 2803 2990 2804 2991 /*This routine returns the values of the nodal functions derivatives (with respect to the 2805 2992 * natural coordinate system) at the gaussian point. */ … … 2893 3080 int area_order=5; 2894 3081 int num_vert_gauss=5; 2895 3082 2896 3083 double epsilon[6]; /* epsilon=[exx,eyy,ezz,exy,exz,eyz];*/ 2897 3084 double viscosity; … … 2916 3103 double tBD[27][8]; 2917 3104 double P_terms[numdof]; 2918 3105 2919 3106 ParameterInputs* inputs=NULL; 2920 3107 Tria* tria=NULL; … … 2941 3128 2942 3129 /* Get gaussian points and weights. Penta is an extrusion of a Tria, we therefore 2943 2944 2945 2946 3130 get tria gaussian points as well as segment gaussian points. For tria gaussian 3131 points, order of integration is 2, because we need to integrate the product tB*D*B' 3132 which is a polynomial of degree 3 (see GaussTria for more details). For segment gaussian 3133 points, same deal, which yields 3 gaussian points.*/ 2947 3134 2948 3135 /* Get gaussian points and weights (make this a statically initialized list of points? fstd): */ … … 2964 3151 GetStrainRateStokes(&epsilon[0],&vxvyvz_list[0][0],&xyz_list[0][0],gauss_coord); 2965 3152 matice->GetViscosity3dStokes(&viscosity,&epsilon[0]); 2966 3153 2967 3154 /* Get Jacobian determinant: */ 2968 3155 GetJacobianDeterminant(&Jdet, &xyz_list[0][0],gauss_coord); … … 2984 3171 GetBStokes(&B[0][0],&xyz_list[0][0],gauss_coord); 2985 3172 GetBprimeStokes(&B_prime[0][0],&xyz_list[0][0], gauss_coord); 2986 3173 2987 3174 /*Get bubble part of Bprime */ 2988 3175 for(i=0;i<8;i++){ … … 3033 3220 gauss_coord[2]=*(third_gauss_area_coord+igarea); 3034 3221 gauss_coord[3]=-1; 3035 3222 3036 3223 gauss_coord_tria[0]=*(first_gauss_area_coord+igarea); 3037 3224 gauss_coord_tria[1]=*(second_gauss_area_coord+igarea); … … 3040 3227 /*Get the Jacobian determinant */ 3041 3228 tria->GetJacobianDeterminant3d(&Jdet2d, &xyz_list_tria[0][0], gauss_coord_tria); 3042 3229 3043 3230 /* Get bed at gaussian point */ 3044 3231 GetParameterValue(&bed,&b[0],gauss_coord); … … 3046 3233 /*Get L matrix : */ 3047 3234 tria->GetL(&L[0], &xyz_list[0][0], gauss_coord_tria,1); 3048 3235 3049 3236 /*Get water_pressure at gaussian point */ 3050 3237 water_pressure=gravity*rho_water*bed; … … 3052 3239 /*Get normal vecyor to the bed */ 3053 3240 SurfaceNormal(&surface_normal[0],xyz_list_tria); 3054 3241 3055 3242 bed_normal[0]=-surface_normal[0]; //Program is for surface, so the normal to the bed is the opposite of the result 3056 3243 bed_normal[1]=-surface_normal[1]; … … 3064 3251 } 3065 3252 } //if ( (onbed==1) && (shelf==1)) 3066 3253 3067 3254 /*Reduce the matrix */ 3068 3255 ReduceVectorStokes(&Pe_reduced[0], &Ke_temp[0][0], &Pe_temp[0]); … … 3080 3267 #define __FUNCT__ "Penta::ReduceVectorStokes" 3081 3268 void Penta::ReduceVectorStokes(double* Pe_reduced, double* Ke_temp, double* Pe_temp){ 3082 3269 3083 3270 int i,j; 3084 3271 … … 3123 3310 #define __FUNCT__ "Penta::GetNodalFunctionsStokes" 3124 3311 void Penta::GetNodalFunctionsStokes(double* l1l7, double* gauss_coord){ 3125 3312 3126 3313 /*This routine returns the values of the nodal functions at the gaussian point.*/ 3127 3314 … … 3181 3368 int dofs[3]={0,1,2}; 3182 3369 double dt; 3183 int dt_exists;3184 3370 3185 3371 double vxvyvz_list[numgrids][3]; … … 3195 3381 3196 3382 /*matrices: */ 3197 double K_terms[numdof][numdof]={0.0};3198 double Ke_gaussian_conduct[numdof][numdof];3199 double Ke_gaussian_advec[numdof][numdof];3200 double Ke_gaussian_transient[numdof][numdof];3201 double B[3][numdof];3202 double Bprime[3][numdof];3203 double B_conduct[3][numdof];3204 double B_advec[3][numdof];3205 double Bprime_advec[3][numdof];3206 double L[numdof];3207 double D_scalar;3208 double D[3][3];3209 double l1l2l3[3];3210 double tl1l2l3D[3];3211 double tBD[3][numdof];3212 double tBD_conduct[3][numdof];3213 double tBD_advec[3][numdof];3214 double tLD[numdof];3215 3216 double Jdet;3383 double K_terms[numdof][numdof]={0.0}; 3384 double Ke_gaussian_conduct[numdof][numdof]; 3385 double Ke_gaussian_advec[numdof][numdof]; 3386 double Ke_gaussian_transient[numdof][numdof]; 3387 double B[3][numdof]; 3388 double Bprime[3][numdof]; 3389 double B_conduct[3][numdof]; 3390 double B_advec[3][numdof]; 3391 double Bprime_advec[3][numdof]; 3392 double L[numdof]; 3393 double D_scalar; 3394 double D[3][3]; 3395 double l1l2l3[3]; 3396 double tl1l2l3D[3]; 3397 double tBD[3][numdof]; 3398 double tBD_conduct[3][numdof]; 3399 double tBD_advec[3][numdof]; 3400 double tLD[numdof]; 3401 3402 double Jdet; 3217 3403 3218 3404 /*Material properties: */ 3219 double gravity,rho_ice,rho_water;3220 double heatcapacity,thermalconductivity;3221 double mixed_layer_capacity,thermal_exchange_velocity;3405 double gravity,rho_ice,rho_water; 3406 double heatcapacity,thermalconductivity; 3407 double mixed_layer_capacity,thermal_exchange_velocity; 3222 3408 3223 3409 /*Collapsed formulation: */ … … 3232 3418 GetDofList(&doflist[0],&numberofdofspernode); 3233 3419 3234 / *recovre material parameters: */3420 // /*recovre material parameters: */ 3235 3421 rho_water=matpar->GetRhoWater(); 3236 3422 rho_ice=matpar->GetRhoIce(); … … 3238 3424 heatcapacity=matpar->GetHeatCapacity(); 3239 3425 thermalconductivity=matpar->GetThermalConductivity(); 3426 3240 3427 3241 3428 /*recover extra inputs from users, dt and velocity: */ … … 3294 3481 D[2][0]=0; D[2][1]=0; D[2][2]=D_scalar; 3295 3482 3483 3296 3484 /* Do the triple product B'*D*B: */ 3297 3485 MatrixMultiply(&B_conduct[0][0],3,numdof,1,&D[0][0],3,3,0,&tBD_conduct[0][0],0); … … 3303 3491 GetB_advec(&B_advec[0][0],&xyz_list[0][0],gauss_coord); 3304 3492 GetBprime_advec(&Bprime_advec[0][0],&xyz_list[0][0],gauss_coord); 3493 3305 3494 3306 3495 //Build the D matrix … … 3322 3511 MatrixMultiply(&B_advec[0][0],3,numdof,1,&D[0][0],3,3,0,&tBD_advec[0][0],0); 3323 3512 MatrixMultiply(&tBD_advec[0][0],numdof,3,0,&Bprime_advec[0][0],3,numdof,0,&Ke_gaussian_advec[0][0],0); 3513 3324 3514 3325 3515 /*Transient: */ … … 3361 3551 xfree((void**)&vert_gauss_weights); 3362 3552 xfree((void**)&vert_gauss_coord); 3363 3553 3364 3554 //Ice/ocean heat exchange flux on ice shelf base 3365 3555 if(onbed && shelf){ … … 3385 3575 * We assume B has been allocated already, of size: 3x(DOFPERGRID*numgrids) 3386 3576 */ 3387 3577 3388 3578 int i; 3389 3579 int calculationdof=3; … … 3419 3609 * We assume B has been allocated already, of size: 3x(DOFPERGRID*numgrids) 3420 3610 */ 3421 3611 3422 3612 int i; 3423 3613 int calculationdof=3; … … 3454 3644 * We assume B has been allocated already, of size: 3x(DOFPERGRID*numgrids) 3455 3645 */ 3456 3646 3457 3647 int i; 3458 3648 int calculationdof=3; … … 3477 3667 #define __FUNCT__ "Penta::CreateKMatrixMelting" 3478 3668 void Penta::CreateKMatrixMelting(Mat Kgg,void* inputs,int analysis_type,int sub_analysis_type){ 3479 3669 3480 3670 Tria* tria=NULL; 3481 3671 if (!onbed){ … … 3483 3673 } 3484 3674 else{ 3485 3675 3486 3676 tria=(Tria*)SpawnTria(0,1,2); //grids 0, 1 and 2 make the new tria. 3487 3677 tria->CreateKMatrixMelting(Kgg,inputs, analysis_type,sub_analysis_type); … … 3508 3698 /*Grid data: */ 3509 3699 double xyz_list[numgrids][3]; 3510 3700 3511 3701 /* gaussian points: */ 3512 3702 int num_area_gauss,igarea,igvert; … … 3521 3711 int area_order=2; 3522 3712 int num_vert_gauss=3; 3523 3713 3524 3714 double dt; 3525 3715 double vx_list[numgrids]; … … 3537 3727 /* element parameters: */ 3538 3728 int friction_type; 3539 3729 3540 3730 int dofs[3]={0,1,2}; 3541 3731 int dofs1[1]={0}; … … 3572 3762 GetElementNodeData( &xyz_list[0][0], nodes, numgrids); 3573 3763 GetDofList(&doflist[0],&numberofdofspernode); 3574 3764 3575 3765 // /*recovre material parameters: */ 3576 3766 rho_water=matpar->GetRhoWater(); … … 3592 3782 if(!found)throw ErrorException(__FUNCT__," could not find temperature in inputs!"); 3593 3783 } 3594 3784 3595 3785 for(i=0;i<numgrids;i++){ 3596 3786 vx_list[i]=vxvyvz_list[i][0]; … … 3600 3790 3601 3791 /* Get gaussian points and weights. Penta is an extrusion of a Tria, we therefore 3602 3603 3604 3605 3606 3792 get tria gaussian points as well as segment gaussian points. For tria gaussian 3793 points, order of integration is 2, because we need to integrate the product tB*D*B' 3794 which is a polynomial of degree 3 (see GaussTria for more details). For segment gaussian 3795 points, same deal, which yields 3 gaussian points.: */ 3796 3607 3797 /*Get gaussian points: */ 3608 3798 GaussPenta( &num_area_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &area_gauss_weights,&vert_gauss_coord, &vert_gauss_weights, area_order, num_vert_gauss); … … 3619 3809 gauss_coord[2]=*(third_gauss_area_coord+igarea); 3620 3810 gauss_coord[3]=*(vert_gauss_coord+igvert); 3621 3811 3622 3812 /*Compute strain rate and viscosity: */ 3623 3813 GetStrainRateStokes(&epsilon[0],&vxvyvz_list[0][0],&xyz_list[0][0],gauss_coord); 3624 matice->GetViscosity3d Stokes(&viscosity,&epsilon[0]);3814 matice->GetViscosity3d(&viscosity,&epsilon[0]); 3625 3815 3626 3816 /* Get Jacobian determinant: */ … … 3661 3851 /* Ice/ocean heat exchange flux on ice shelf base */ 3662 3852 if(onbed && shelf){ 3853 3663 3854 3664 3855 tria=(Tria*)SpawnTria(0,1,2); //grids 0, 1 and 2 make the new tria. -
issm/trunk/src/c/objects/Penta.h
r483 r586 110 110 void GetParameterDerivativeValue(double* p, double* p_list,double* xyz_list, double* gauss_l1l2l3l4); 111 111 void GetNodalFunctions(double* l1l2l3l4l5l6, double* gauss_l1l2l3l4); 112 void VelocityExtrudeAllElements(Vec ug,double* ug_serial); 112 113 void VelocityExtrude(Vec ug,double* ug_serial); 114 void ThicknessExtrude(Vec ug,double* ug_serial); 115 void VelocityDepthAverageAtBase(Vec ug,double* ug_serial); 113 116 void SlopeExtrude(Vec sg,double* sg_serial); 114 117 void ComputePressure(Vec p_g); -
issm/trunk/src/c/objects/Tria.cpp
r511 r586 17 17 #include "../include/typedefs.h" 18 18 19 19 20 /*For debugging purposes: */ 20 21 #define ELID 141 //element for which to print debug statements … … 33 34 Tria::Tria(int tria_id,int tria_mid,int tria_mparid,int tria_node_ids[3],double tria_h[3],double tria_s[3],double tria_b[3],double tria_k[3],double tria_melting[3], 34 35 double tria_accumulation[3],double tria_geothermalflux[3],int tria_friction_type,double tria_p,double tria_q,int tria_shelf,double tria_meanvel,double tria_epsvel, 35 double tria_viscosity_overshoot ){36 double tria_viscosity_overshoot,int tria_artdiff){ 36 37 37 38 int i; … … 50 51 melting[i]=tria_melting[i]; 51 52 accumulation[i]=tria_accumulation[i]; 52 geothermalflux[i]=tria_geothermalflux[i]; 53 } 53 geothermalflux[i]=tria_geothermalflux[i]; } 54 54 matice=NULL; 55 55 matice_offset=UNDEF; … … 64 64 onbed=1; 65 65 viscosity_overshoot=tria_viscosity_overshoot; 66 artdiff=tria_artdiff; 66 67 67 68 return; … … 96 97 printf(" onbed: %i\n",onbed); 97 98 printf(" viscosity_overshoot=%g\n",viscosity_overshoot); 99 printf(" artdiff=%g\n",artdiff); 98 100 printf(" nodes: \n"); 99 101 if(nodes[0])nodes[0]->Echo(); … … 146 148 memcpy(marshalled_dataset,&epsvel,sizeof(epsvel));marshalled_dataset+=sizeof(epsvel); 147 149 memcpy(marshalled_dataset,&viscosity_overshoot,sizeof(viscosity_overshoot));marshalled_dataset+=sizeof(viscosity_overshoot); 150 memcpy(marshalled_dataset,&artdiff,sizeof(artdiff));marshalled_dataset+=sizeof(artdiff); 148 151 149 152 *pmarshalled_dataset=marshalled_dataset; … … 177 180 +sizeof(epsvel) 178 181 +sizeof(viscosity_overshoot) 182 +sizeof(artdiff) 179 183 +sizeof(int); //sizeof(int) for enum type 180 184 } … … 220 224 memcpy(&epsvel,marshalled_dataset,sizeof(epsvel));marshalled_dataset+=sizeof(epsvel); 221 225 memcpy(&viscosity_overshoot,marshalled_dataset,sizeof(viscosity_overshoot));marshalled_dataset+=sizeof(viscosity_overshoot); 226 memcpy(&artdiff,marshalled_dataset,sizeof(artdiff));marshalled_dataset+=sizeof(artdiff); 222 227 223 228 /*nodes and materials are not pointing to correct objects anymore:*/ … … 242 247 } 243 248 249 244 250 #undef __FUNCT__ 245 251 #define __FUNCT__ "Tria::Configure" … … 290 296 291 297 } 298 else if (analysis_type==PrognosticAnalysisEnum()){ 299 300 CreateKMatrixPrognostic( Kgg,inputs,analysis_type,sub_analysis_type); 301 302 } 292 303 else{ 293 304 throw ErrorException(__FUNCT__,exprintf("%s%i%s\n","analysis: ",analysis_type," not supported yet")); 294 305 } 295 } 306 307 } 308 296 309 297 310 #undef __FUNCT__ … … 299 312 300 313 void Tria::CreateKMatrixDiagnosticHoriz(Mat Kgg,void* vinputs,int analysis_type,int sub_analysis_type){ 314 301 315 302 316 /* local declarations */ … … 509 523 510 524 } 525 #undef __FUNCT__ 526 #define __FUNCT__ "Tria::CreateKMatrixPrognostic" 527 void Tria::CreateKMatrixPrognostic(Mat Kgg,void* vinputs,int analysis_type,int sub_analysis_type){ 528 529 530 /* local declarations */ 531 int i,j; 532 533 /* node data: */ 534 const int numgrids=3; 535 const int NDOF1=1; 536 const int numdof=NDOF1*numgrids; 537 double xyz_list[numgrids][3]; 538 int doflist[numdof]; 539 int numberofdofspernode; 540 541 /* gaussian points: */ 542 int num_gauss,ig; 543 double* first_gauss_area_coord = NULL; 544 double* second_gauss_area_coord = NULL; 545 double* third_gauss_area_coord = NULL; 546 double* gauss_weights = NULL; 547 double gauss_weight; 548 double gauss_l1l2l3[3]; 549 550 /* matrices: */ 551 double L[numgrids]; 552 double DL[2][2]={0.0}; 553 double DLprime[2][2]={0.0}; 554 double DL_scalar; 555 double Ke_gg[numdof][numdof]={0.0};//local element stiffness matrix 556 double Ke_gg_gaussian[numdof][numdof]={0.0}; //stiffness matrix evaluated at the gaussian point. 557 double Ke_gg_thickness[numdof][numdof]={0.0}; //stiffness matrix evaluated at the gaussian point. 558 559 double Jdettria; 560 561 /*input parameters for structural analysis (diagnostic): */ 562 double vxvy_list[numgrids][2]={0,0}; 563 double vx_list[numgrids]={0,0}; 564 double vy_list[numgrids]={0,0}; 565 double dvx[2]; 566 double dvy[2]; 567 double vx,vy; 568 double v_gauss[2]={0.0}; 569 double K[2][2]={0.0}; 570 double dt; 571 int dofs[2]={0,1}; 572 int found=0; 573 574 ParameterInputs* inputs=NULL; 575 576 /*recover pointers: */ 577 inputs=(ParameterInputs*)vinputs; 578 579 /*recover extra inputs from users, at current convergence iteration: */ 580 found=inputs->Recover("velocity",&vxvy_list[0][0],2,dofs,numgrids,(void**)nodes); 581 if(!found)throw ErrorException(__FUNCT__," could not find velocity_average in inputs!"); 582 583 for(i=0;i<numgrids;i++){ 584 vx_list[i]=vxvy_list[i][0]; 585 vy_list[i]=vxvy_list[i][1]; 586 } 587 588 found=inputs->Recover("dt",&dt); 589 if(!found)throw ErrorException(__FUNCT__," could not find dt in inputs!"); 590 591 /* Get node coordinates and dof list: */ 592 GetElementNodeData( &xyz_list[0][0], nodes, numgrids); 593 GetDofList(&doflist[0],&numberofdofspernode); 594 595 //Create Artificial diffusivity once for all if requested 596 if(artdiff){ 597 //Get the Jacobian determinant 598 gauss_l1l2l3[0]=1.0/3.0; gauss_l1l2l3[1]=1.0/3.0; gauss_l1l2l3[2]=1.0/3.0; 599 GetJacobianDeterminant2d(&Jdettria, &xyz_list[0][0],gauss_l1l2l3); 600 601 //Build K matrix (artificial diffusivity matrix) 602 v_gauss[0]=1.0/3.0*(vxvy_list[0][0]+vxvy_list[1][0]+vxvy_list[2][0]); 603 v_gauss[1]=1.0/3.0*(vxvy_list[0][1]+vxvy_list[1][1]+vxvy_list[2][1]); 604 605 K[0][0]=pow(Jdettria,.5)/2.0*fabs(v_gauss[0]); 606 K[1][1]=pow(Jdettria,.5)/2.0*fabs(v_gauss[1]); 607 } 608 609 /* Get gaussian points and weights (make this a statically initialized list of points? fstd): */ 610 GaussTria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2); 611 612 /* Start looping on the number of gaussian points: */ 613 for (ig=0; ig<num_gauss; ig++){ 614 /*Pick up the gaussian point: */ 615 gauss_weight=*(gauss_weights+ig); 616 gauss_l1l2l3[0]=*(first_gauss_area_coord+ig); 617 gauss_l1l2l3[1]=*(second_gauss_area_coord+ig); 618 gauss_l1l2l3[2]=*(third_gauss_area_coord+ig); 619 620 /* Get Jacobian determinant: */ 621 GetJacobianDeterminant2d(&Jdettria, &xyz_list[0][0],gauss_l1l2l3); 622 623 /*Get L matrix: */ 624 GetL(&L[0], &xyz_list[0][0], gauss_l1l2l3,numberofdofspernode); 625 626 627 DL_scalar=gauss_weight*Jdettria; 628 629 /* Do the triple product tL*D*L: */ 630 TripleMultiply( &L[0],1,numdof,1, 631 &DL_scalar,1,1,0, 632 &L[0],1,numdof,0, 633 &Ke_gg_gaussian[0][0],0); 634 635 636 /*Get B and B prime matrix: */ 637 //GetB_prog(&B[0][0], &xyz_list[0][0], gauss_l1l2l3); 638 //GetBprime_prog(&Bprime[0][0], &xyz_list[0][0], gauss_l1l2l3); 639 640 //Get vx, vy and their derivatives at gauss point 641 GetParameterValue(&vx, &vx_list[0],gauss_l1l2l3); 642 GetParameterValue(&vy, &vy_list[0],gauss_l1l2l3); 643 644 GetParameterDerivativeValue(&dvx[0], &vx_list[0],&xyz_list[0][0], gauss_l1l2l3); 645 GetParameterDerivativeValue(&dvy[0], &vy_list[0],&xyz_list[0][0], gauss_l1l2l3); 646 647 //dvxdx=dvx[0]; 648 //dvydy=dvy[1]; 649 650 DL_scalar=dt*gauss_weight*Jdettria; 651 652 //Create DL and DLprime matrix 653 //DL[0][0]=DL_scalar*dvxdx; 654 //DL[1][1]=DL_scalar*dvydy; 655 656 DLprime[0][0]=DL_scalar*vx; 657 DLprime[1][1]=DL_scalar*vy; 658 659 //Do the triple product tL*D*L. 660 //Ke_gg_thickness=B'*DL*B+B'*DLprime*Bprime; 661 662 /*TripleMultiply( &B[0][0],numdof,numdof,1, 663 &DL_scalar,1,1,0, 664 &L[0],1,numdof,0, 665 &Ke_gg_gaussian[0][0],0);*/ 666 667 668 669 670 671 /* Add the Ke_gg_gaussian, and optionally Ke_gg_drag_gaussian onto Ke_gg: */ 672 for( i=0; i<numdof; i++) for(j=0;j<numdof;j++) Ke_gg[i][j]+=Ke_gg_gaussian[i][j]; 673 674 #ifdef _DEBUGELEMENTS_ 675 if(my_rank==RANK && id==ELID){ 676 printf(" B:\n"); 677 for(i=0;i<3;i++){ 678 for(j=0;j<numdof;j++){ 679 printf("%g ",B[i][j]); 680 } 681 printf("\n"); 682 } 683 printf(" Bprime:\n"); 684 for(i=0;i<3;i++){ 685 for(j=0;j<numdof;j++){ 686 printf("%g ",Bprime[i][j]); 687 } 688 printf("\n"); 689 } 690 } 691 #endif 692 } // for (ig=0; ig<num_gauss; ig++) 693 694 /*Add Ke_gg to global matrix Kgg: */ 695 MatSetValues(Kgg,numdof,doflist,numdof,doflist,(const double*)Ke_gg,ADD_VALUES); 696 697 698 /*Do not forget to include friction: */ 699 if(!shelf){ 700 //CreateKMatrixPrognosticFriction(Kgg,inputs,analysis_type,sub_analysis_type); 701 } 702 703 704 #ifdef _DEBUGELEMENTS_ 705 if(my_rank==RANK && id==ELID){ 706 printf(" Ke_gg erms:\n"); 707 for( i=0; i<numdof; i++){ 708 for (j=0;j<numdof;j++){ 709 printf("%g ",Ke_gg[i][j]); 710 } 711 printf("\n"); 712 } 713 printf(" Ke_gg row_indices:\n"); 714 for( i=0; i<numdof; i++){ 715 printf("%i ",doflist[i]); 716 } 717 718 } 719 #endif 720 721 cleanup_and_return: 722 xfree((void**)&first_gauss_area_coord); 723 xfree((void**)&second_gauss_area_coord); 724 xfree((void**)&third_gauss_area_coord); 725 xfree((void**)&gauss_weights); 726 727 } 728 511 729 512 730 #undef __FUNCT__ -
issm/trunk/src/c/objects/Tria.h
r483 r586 49 49 int onbed; 50 50 double viscosity_overshoot; 51 int artdiff; 51 52 52 53 public: … … 54 55 Tria(); 55 56 Tria(int id,int mid,int mparid,int node_ids[3],double h[3],double s[3],double b[3],double k[3],double melting[3],double accumulation[3],double geothermalflux[3], 56 int friction_type,double p,double q,int shelf,double meanvel,double epsvel,double viscosity_overshoot );57 int friction_type,double p,double q,int shelf,double meanvel,double epsvel,double viscosity_overshoot,int artdiff); 57 58 ~Tria(); 58 59 … … 113 114 void CreatePVectorThermalShelf( Vec pg, void* vinputs, int analysis_type,int sub_analysis_type); 114 115 void CreatePVectorThermalSheet( Vec pg, void* vinputs, int analysis_type,int sub_analysis_type); 116 void CreateKMatrixPrognostic(Mat Kgg,void* vinputs,int analysis_type,int sub_analysis_type); 115 117 116 118 -
issm/trunk/src/c/objects/objects.h
r387 r586 37 37 #include "./OptPars.h" 38 38 39 39 40 #endif -
issm/trunk/src/c/parallel/CreateFemModel.cpp
r557 r586 63 63 _printf_(" normalizing rigid body constraints matrix:\n"); 64 64 NormalizeConstraintsx(&Gmn, Rmg,nodesets); 65 65 66 66 _printf_(" configuring element and loads:\n"); 67 67 ConfigureObjectsx(elements, loads, nodes, materials); 68 68 69 69 _printf_(" process parameters:\n"); 70 70 ProcessParamsx( parameters, partition); 71 71 72 72 _printf_(" free ressources:\n"); 73 73 DeleteModel(&model); 74 74 75 75 76 /*Assign output pointers:*/ -
issm/trunk/src/c/parallel/diagnostic.cpp
r472 r586 23 23 char* outputfilename=NULL; 24 24 char* lockname=NULL; 25 char* qmuname=NULL; 25 26 int numberofnodes; 27 int qmu_analysis=0; 26 28 27 29 /*Fem models : */ … … 52 54 outputfilename=argv[3]; 53 55 lockname=argv[4]; 56 qmuname=argv[5]; 54 57 55 58 /*Open handle to data on disk: */ … … 68 71 CreateFemModel(&femmodels[4],fid,"slope_compute",""); 69 72 73 70 74 _printf_("initialize inputs:\n"); 71 75 femmodels[0].parameters->FindParam((void*)&u_g_initial,"u_g"); … … 79 83 femmodels[0].parameters->DeleteObject((Object*)param); 80 84 81 _printf_("call computational core:\n"); 82 diagnostic_core(&u_g,&p_g,femmodels,inputs); 85 /*are we running the solutoin sequence, or a qmu wrapper around it? : */ 86 femmodels[0].parameters->FindParam((void*)&qmu_analysis,"qmu_analysis"); 87 if(!qmu_analysis){ 88 /*run diagnostic analysis: */ 89 _printf_("call computational core:\n"); 90 diagnostic_core(&u_g,&p_g,femmodels,inputs); 83 91 84 _printf_("write results to disk:\n"); 85 OutputDiagnostic(u_g,p_g,&femmodels[0],outputfilename); 92 _printf_("write results to disk:\n"); 93 OutputDiagnostic(u_g,p_g,&femmodels[0],outputfilename); 94 } 95 else{ 96 97 /*run qmu analysis: */ 98 _printf_("calling qmu analysis on diagnostic core:\n"); 99 100 qmu(qmuname,&femmodels[0],inputs,DiagnosticAnalysisEnum(),NoneAnalysisEnum()); 101 } 86 102 87 103 _printf_("write lock file:\n"); -
issm/trunk/src/c/parallel/diagnostic_core.cpp
r465 r586 14 14 15 15 void diagnostic_core(Vec* pug, Vec* ppg,FemModel* fems, ParameterInputs* inputs){ 16 17 extern int my_rank; 16 18 17 19 /*fem models: */ -
issm/trunk/src/c/parallel/diagnostic_core_nonlinear.cpp
r551 r586 46 46 kflag=1; pflag=1; 47 47 48 49 48 50 fem->parameters->FindParam((void*)&connectivity,"connectivity"); 49 51 fem->parameters->FindParam((void*)&numberofdofspernode,"numberofdofspernode"); … … 57 59 /*Copy loads for backup: */ 58 60 loads=fem->loads->Copy(); 59 61 60 62 /*Initialize ug and ug_old */ 61 63 if (numberofdofspernode>=3)dofs[2]=1;//only keep vz if running with more than 3 dofs per node -
issm/trunk/src/c/parallel/parallel.h
r568 r586 31 31 void OutputThermal(Vec* t_g,Vec* m_g, double* time,FemModel* femmodels,char* filename); 32 32 void OutputControl(Vec u_g,double* p_g, double* J, int nsteps, Vec partition,char* filename,NodeSets* nodesets); 33 void OutputPrognostic(Vec h_g,FemModel* femmodel,char* filename); 33 34 void WriteLockFile(char* filename); 34 35 35 36 void CreateFemModel(FemModel* femmodel,ConstDataHandle MODEL,char* analysis_type,char* sub_analysis_type); 36 37 //int BatchDebug(Mat* Kgg,Vec* pg,FemModel* femmodel,char* filename); 38 void qmu(const char* dakota_input_file,FemModel* femmodels,ParameterInputs* inputs,int analysis_type,int sub_analysis_type); 39 void SpawnCore(double* responses,double* variables,char** variable_descriptors,int numvariables, FemModel* femmodels,ParameterInputs* inputs,int analysis_type,int sub_analysis_type); 40 void DakotaResponses(double* responses,char** responses_descriptors,int numresponses,Vec u_g,Vec p_g,int analysis_type,int sub_analysis_type); 37 41 38 42 #endif -
issm/trunk/src/c/shared/Dofs/DistributeNumDofs.cpp
r496 r586 42 42 numdofs=1; 43 43 } 44 else if (analysis_type==PrognosticAnalysisEnum()){ 45 numdofs=1; 46 } 44 47 else throw ErrorException(__FUNCT__,exprintf("%s%i%s"," analysis type: ",analysis_type," not implemented yet!")); 45 48 -
issm/trunk/src/c/toolkits/metis/metisincludes.h
r1 r586 9 9 #include <metis.h> 10 10 11 extern "C" void METIS_PartMeshNodal(int *, int *, idxtype *, int *, int *, int *, int *, idxtype *, idxtype *); 12 11 13 #endif -
issm/trunk/src/c/toolkits/petsc/patches/petscpatches.h
r434 r586 42 42 void MatToSerial(double** poutmatrix,Mat matrix); 43 43 void VecDuplicatePatch(Vec* output, Vec input); 44 Vec SerialToVec(double* vector,int vector_size); 44 45 45 46 -
issm/trunk/src/m/classes/@model/model.m
r465 r586 274 274 md.dakotaout=''; 275 275 md.dakotadat=''; 276 md.qmu_analysis=0; 277 md.iresp=1; 276 278 277 279 md.npart=0; -
issm/trunk/src/m/classes/public/BuildQueueingScriptGeneric.m
r465 r586 27 27 end 28 28 29 fprintf(fid,' %s %s.bin %s.outbin %s.lock 2> %s.errlog >%s.outlog & ',executionpath,md.name,md.name,md.name,md.name,md.name);29 fprintf(fid,' %s %s.bin %s.outbin %s.lock qmu.in 2> %s.errlog >%s.outlog & ',executionpath,md.name,md.name,md.name,md.name,md.name); 30 30 fclose(fid); -
issm/trunk/src/m/classes/public/LaunchQueueJobGeneric.m
r1 r586 20 20 disp('uploading input file and queueing script'); 21 21 if strcmpi(hostname,md.cluster), 22 system(['cp ' md.name '.bin' ' ' md.name '.queue' ' ' executionpath]); 22 if md.qmu_analysis, 23 system(['cp ' md.name '.bin' ' ' md.name '.queue qmu/qmu.in ' ' ' executionpath]); 24 else 25 system(['cp ' md.name '.bin' ' ' md.name '.queue' ' ' executionpath]); 26 end 23 27 else 24 system(['scp ' md.name '.bin' ' ' md.name '.queue' ' ' md.cluster ':' executionpath]); 28 if md.qmu_analysis, 29 system(['scp ' md.name '.bin' ' ' md.name '.queue qmu/qmu.in ' ' ' md.cluster ':' executionpath]); 30 else 31 system(['scp ' md.name '.bin' ' ' md.name '.queue' ' ' md.cluster ':' executionpath]); 32 end 25 33 end 26 34 -
issm/trunk/src/m/classes/public/marshall.m
r574 r586 153 153 WriteData(fid,md.rifts(i).friction,'Scalar',['friction' num2str(i)]); 154 154 end 155 156 %Qmu 157 WriteData(fid,md.qmu_analysis,'Integer','qmu_analysis'); 158 if md.qmu_analysis, 159 responses=md.responses(md.iresp).rf; 160 WriteData(fid,numel(responses),'Integer','numberofresponses'); 161 for i=1:numel(responses), 162 WriteData(fid,responses(i).descriptor,'String',['descriptor' num2str(i-1)]); 163 end 164 end 155 165 156 166 %Get penalties to connect collapsed and non-collapsed 3d meshes: -
issm/trunk/src/m/classes/public/process_solve_options.m
r490 r586 46 46 end 47 47 if ~found, 48 sub_analysis_type=' ';48 sub_analysis_type='none'; 49 49 end 50 50 … … 56 56 strcmpi(analysis_type,'mesh') | ... 57 57 strcmpi(analysis_type,'mesh2grid') | ... 58 strcmpi(analysis_type,'qmu') | ...59 58 strcmpi(analysis_type,'transient') ), 60 59 error(['process_solve_options error message: analysis_type ' analysis_type ' not supported yet!']); 61 60 end 62 if ~(strcmpi(sub_analysis_type,' ') | ...61 if ~(strcmpi(sub_analysis_type,'none') | ... 63 62 strcmpi(sub_analysis_type,'steady') | ... 64 63 strcmpi(sub_analysis_type,'horiz') | ... -
issm/trunk/src/m/solutions/dakota/dakota_m_write.m
r449 r586 208 208 209 209 disp(sprintf(' Writing %d %s responses.',length(dresp),class(dresp))); 210 211 210 for i=1:length(dresp) 212 211 ifnvals=ifnvals+1; -
issm/trunk/src/m/utils/Nightly/testsgetpackage.m
r522 r586 25 25 elseif strcmpi(string,'cielo_parallel'), 26 26 package='cielo'; 27 md.cluster=' wilkes';27 md.cluster='astrid'; 28 28 29 29 else -
issm/trunk/src/mex/Makefile.am
r358 r586 38 38 SystemMatrices\ 39 39 Test\ 40 ThicknessExtrude\ 40 41 TriMesh\ 41 42 TriMeshProcessRifts\ 42 43 TriMeshRefine\ 43 44 UpdateFromInputs\ 44 VelocityExtrude 45 VelocityExtrude\ 46 VelocityDepthAverage 45 47 46 48 endif … … 167 169 SystemMatrices/SystemMatrices.h 168 170 171 ThicknessExtrude_SOURCES = ThicknessExtrude/ThicknessExtrude.cpp\ 172 ThicknessExtrude/ThicknessExtrude.h 173 169 174 TriMesh_SOURCES = TriMesh/TriMesh.cpp\ 170 175 TriMesh/TriMesh.h … … 182 187 VelocityExtrude/VelocityExtrude.h 183 188 189 VelocityDepthAverage_SOURCES = VelocityDepthAverage/VelocityDepthAverage.cpp\ 190 VelocityDepthAverage/VelocityDepthAverage.h
Note:
See TracChangeset
for help on using the changeset viewer.