| 1 | /*! \file CreateLoadsStressbalance.c:
|
|---|
| 2 | */
|
|---|
| 3 | #include <string.h>
|
|---|
| 4 | #include "../../../toolkits/toolkits.h"
|
|---|
| 5 | #include "../../../classes/classes.h"
|
|---|
| 6 | #include "../../../shared/shared.h"
|
|---|
| 7 | #include "../ModelProcessorx.h"
|
|---|
| 8 |
|
|---|
| 9 | void CreateLoadsStressbalance(Loads** ploads, IoModel* iomodel){
|
|---|
| 10 |
|
|---|
| 11 | /*DataSets*/
|
|---|
| 12 | Pengrid *pengrid = NULL;
|
|---|
| 13 |
|
|---|
| 14 | /*Intermediary*/
|
|---|
| 15 | int segment_width;
|
|---|
| 16 | int element;
|
|---|
| 17 | int i;
|
|---|
| 18 | int count;
|
|---|
| 19 | int penpair_ids[2];
|
|---|
| 20 | bool isSSA,isL1L2,isHO,isFS;
|
|---|
| 21 | int numpenalties,numberofpressureloads,numrifts,numriftsegments;
|
|---|
| 22 | IssmDouble *pressureload = NULL;
|
|---|
| 23 | IssmDouble *elements_type = NULL;
|
|---|
| 24 | IssmDouble *nodeoniceshelf = NULL;
|
|---|
| 25 | IssmDouble *riftinfo = NULL;
|
|---|
| 26 | IssmDouble *nodeonbed = NULL;
|
|---|
| 27 | IssmDouble *nodeonFS = NULL;
|
|---|
| 28 | IssmDouble *nodeonicesheet = NULL;
|
|---|
| 29 | IssmDouble *vertices_type = NULL;
|
|---|
| 30 | IssmDouble *penalties = NULL;
|
|---|
| 31 | int assert_int;
|
|---|
| 32 |
|
|---|
| 33 | /*Fetch parameters: */
|
|---|
| 34 | iomodel->Constant(&isL1L2,FlowequationIsL1L2Enum);
|
|---|
| 35 | iomodel->Constant(&isFS,FlowequationIsFSEnum);
|
|---|
| 36 | iomodel->Constant(&isSSA,FlowequationIsSSAEnum);
|
|---|
| 37 | iomodel->Constant(&isHO,FlowequationIsHOEnum);
|
|---|
| 38 | iomodel->Constant(&numrifts,RiftsNumriftsEnum);
|
|---|
| 39 |
|
|---|
| 40 | /*Recover pointer: */
|
|---|
| 41 | Loads* loads=*ploads;
|
|---|
| 42 |
|
|---|
| 43 | /*Now, is the flag macayaealHO on? otherwise, do nothing: */
|
|---|
| 44 | if(!isSSA & !isHO & !isFS & !isL1L2) return;
|
|---|
| 45 |
|
|---|
| 46 | /*Initialize counter: */
|
|---|
| 47 | count=0;
|
|---|
| 48 |
|
|---|
| 49 | /*Create Penpair for penalties: */
|
|---|
| 50 | iomodel->FetchData(&penalties,&numpenalties,NULL,StressbalanceVertexPairingEnum);
|
|---|
| 51 |
|
|---|
| 52 | for(i=0;i<numpenalties;i++){
|
|---|
| 53 |
|
|---|
| 54 | if(iomodel->my_vertices[reCast<int,IssmDouble>(penalties[2*i+0]-1)]){
|
|---|
| 55 |
|
|---|
| 56 | /*In debugging mode, check that the second node is in the same cpu*/
|
|---|
| 57 | assert_int=iomodel->my_vertices[reCast<int,IssmDouble>(penalties[2*i+1]-1)]; _assert_(assert_int);
|
|---|
| 58 |
|
|---|
| 59 | /*Get node ids*/
|
|---|
| 60 | penpair_ids[0]=iomodel->nodecounter+reCast<int,IssmDouble>(penalties[2*i+0]);
|
|---|
| 61 | penpair_ids[1]=iomodel->nodecounter+reCast<int,IssmDouble>(penalties[2*i+1]);
|
|---|
| 62 |
|
|---|
| 63 | /*Create Load*/
|
|---|
| 64 | loads->AddObject(new Penpair(iomodel->loadcounter+count+1,&penpair_ids[0],StressbalanceAnalysisEnum));
|
|---|
| 65 | count++;
|
|---|
| 66 | }
|
|---|
| 67 | }
|
|---|
| 68 |
|
|---|
| 69 | /*free ressources: */
|
|---|
| 70 | iomodel->DeleteData(penalties,StressbalanceVertexPairingEnum);
|
|---|
| 71 |
|
|---|
| 72 | /*Create Riffront loads for rifts: */
|
|---|
| 73 | #ifdef _HAVE_RIFTS_
|
|---|
| 74 | if(numrifts){
|
|---|
| 75 | iomodel->FetchData(&riftinfo,&numriftsegments,NULL,RiftsRiftstructEnum);
|
|---|
| 76 | iomodel->FetchData(5,RiftsRiftstructEnum,ThicknessEnum,BedEnum,SurfaceEnum,MaskGroundediceLevelsetEnum);
|
|---|
| 77 | for(i=0;i<numriftsegments;i++){
|
|---|
| 78 | if(iomodel->my_elements[reCast<int,IssmDouble>(*(riftinfo+RIFTINFOSIZE*i+2))-1]){
|
|---|
| 79 | loads->AddObject(new Riftfront(iomodel->loadcounter+count+1,i,iomodel,StressbalanceAnalysisEnum));
|
|---|
| 80 | count++;
|
|---|
| 81 | }
|
|---|
| 82 | }
|
|---|
| 83 | iomodel->DeleteData(5,RiftsRiftstructEnum,ThicknessEnum,BedEnum,SurfaceEnum,MaskGroundediceLevelsetEnum);
|
|---|
| 84 | xDelete<IssmDouble>(riftinfo);
|
|---|
| 85 | }
|
|---|
| 86 | #endif
|
|---|
| 87 |
|
|---|
| 88 | /*Assign output pointer: */
|
|---|
| 89 | *ploads=loads;
|
|---|
| 90 | }
|
|---|