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 | /*Intermediary*/
|
---|
12 | int i;
|
---|
13 | int count;
|
---|
14 | int penpair_ids[2];
|
---|
15 | bool isSSA,isL1L2,isHO,isFS;
|
---|
16 | int numpenalties,numrifts,numriftsegments;
|
---|
17 | IssmDouble *riftinfo = NULL;
|
---|
18 | IssmDouble *penalties = NULL;
|
---|
19 | int assert_int;
|
---|
20 |
|
---|
21 | /*Fetch parameters: */
|
---|
22 | iomodel->Constant(&isL1L2,FlowequationIsL1L2Enum);
|
---|
23 | iomodel->Constant(&isFS,FlowequationIsFSEnum);
|
---|
24 | iomodel->Constant(&isSSA,FlowequationIsSSAEnum);
|
---|
25 | iomodel->Constant(&isHO,FlowequationIsHOEnum);
|
---|
26 | iomodel->Constant(&numrifts,RiftsNumriftsEnum);
|
---|
27 |
|
---|
28 | /*Recover pointer: */
|
---|
29 | Loads* loads=*ploads;
|
---|
30 |
|
---|
31 | /*Now, is the flag macayaealHO on? otherwise, do nothing: */
|
---|
32 | if(!isSSA && !isHO && !isFS && !isL1L2) return;
|
---|
33 |
|
---|
34 | /*Initialize counter: */
|
---|
35 | count=0;
|
---|
36 |
|
---|
37 | /*Create Penpair for penalties: */
|
---|
38 | iomodel->FetchData(&penalties,&numpenalties,NULL,StressbalanceVertexPairingEnum);
|
---|
39 |
|
---|
40 | for(i=0;i<numpenalties;i++){
|
---|
41 |
|
---|
42 | if(iomodel->my_vertices[reCast<int,IssmDouble>(penalties[2*i+0]-1)]){
|
---|
43 |
|
---|
44 | /*In debugging mode, check that the second node is in the same cpu*/
|
---|
45 | assert_int=iomodel->my_vertices[reCast<int,IssmDouble>(penalties[2*i+1]-1)]; _assert_(assert_int);
|
---|
46 |
|
---|
47 | /*Get node ids*/
|
---|
48 | penpair_ids[0]=iomodel->nodecounter+reCast<int,IssmDouble>(penalties[2*i+0]);
|
---|
49 | penpair_ids[1]=iomodel->nodecounter+reCast<int,IssmDouble>(penalties[2*i+1]);
|
---|
50 |
|
---|
51 | /*Create Load*/
|
---|
52 | loads->AddObject(new Penpair(iomodel->loadcounter+count+1,&penpair_ids[0],StressbalanceAnalysisEnum));
|
---|
53 | count++;
|
---|
54 | }
|
---|
55 | }
|
---|
56 |
|
---|
57 | /*free ressources: */
|
---|
58 | iomodel->DeleteData(penalties,StressbalanceVertexPairingEnum);
|
---|
59 |
|
---|
60 | /*Create Riffront loads for rifts: */
|
---|
61 | #ifdef _HAVE_RIFTS_
|
---|
62 | if(numrifts){
|
---|
63 | iomodel->FetchData(&riftinfo,&numriftsegments,NULL,RiftsRiftstructEnum);
|
---|
64 | iomodel->FetchData(5,RiftsRiftstructEnum,ThicknessEnum,BedEnum,SurfaceEnum,MaskGroundediceLevelsetEnum);
|
---|
65 | for(i=0;i<numriftsegments;i++){
|
---|
66 | if(iomodel->my_elements[reCast<int,IssmDouble>(*(riftinfo+RIFTINFOSIZE*i+2))-1]){
|
---|
67 | loads->AddObject(new Riftfront(iomodel->loadcounter+count+1,i,iomodel,StressbalanceAnalysisEnum));
|
---|
68 | count++;
|
---|
69 | }
|
---|
70 | }
|
---|
71 | iomodel->DeleteData(5,RiftsRiftstructEnum,ThicknessEnum,BedEnum,SurfaceEnum,MaskGroundediceLevelsetEnum);
|
---|
72 | xDelete<IssmDouble>(riftinfo);
|
---|
73 | }
|
---|
74 | #endif
|
---|
75 |
|
---|
76 | /*Assign output pointer: */
|
---|
77 | *ploads=loads;
|
---|
78 | }
|
---|