1 | /*
|
---|
2 | * CreateConstraintsStressbalanceSIA.c:
|
---|
3 | */
|
---|
4 |
|
---|
5 | #include "../../../toolkits/toolkits.h"
|
---|
6 | #include "../../../classes/classes.h"
|
---|
7 | #include "../../../shared/shared.h"
|
---|
8 | #include "../ModelProcessorx.h"
|
---|
9 |
|
---|
10 | void CreateConstraintsStressbalanceSIA(Constraints** pconstraints, IoModel* iomodel){
|
---|
11 |
|
---|
12 | /*Intermediary*/
|
---|
13 | int count;
|
---|
14 | IssmDouble yts;
|
---|
15 | bool isSIA;
|
---|
16 |
|
---|
17 | /*Output*/
|
---|
18 | Constraints* constraints = NULL;
|
---|
19 | SpcStatic* spcstatic = NULL;
|
---|
20 |
|
---|
21 | /*Recover pointer: */
|
---|
22 | constraints=*pconstraints;
|
---|
23 |
|
---|
24 | /*Fetch parameters: */
|
---|
25 | iomodel->Constant(&yts,ConstantsYtsEnum);
|
---|
26 | iomodel->Constant(&isSIA,FlowequationIsSIAEnum);
|
---|
27 |
|
---|
28 | /*Now, is the flag isSIA on? otherwise, do nothing: */
|
---|
29 | if (!isSIA) return;
|
---|
30 |
|
---|
31 | /*Fetch data: */
|
---|
32 | iomodel->FetchData(3,StressbalanceSpcvxEnum,StressbalanceSpcvyEnum,FlowequationVertexEquationEnum);
|
---|
33 |
|
---|
34 | /*Initialize conunter*/
|
---|
35 | count=0;
|
---|
36 |
|
---|
37 | /*vx and vy are spc'd if we are not on nodeonSIA: */
|
---|
38 | for(int i=0;i<iomodel->numberofvertices;i++){
|
---|
39 | /*keep only this partition's nodes:*/
|
---|
40 | if((iomodel->my_vertices[i])){
|
---|
41 | if (!reCast<int,IssmDouble>(iomodel->Data(FlowequationVertexEquationEnum)[i])==SIAApproximationEnum){
|
---|
42 |
|
---|
43 | constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,1,0,StressbalanceSIAAnalysisEnum));
|
---|
44 | count++;
|
---|
45 |
|
---|
46 | constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,2,0,StressbalanceSIAAnalysisEnum));
|
---|
47 | count++;
|
---|
48 | }
|
---|
49 | else{
|
---|
50 | if (!xIsNan<IssmDouble>(iomodel->Data(StressbalanceSpcvxEnum)[i])){
|
---|
51 | constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,1,iomodel->Data(StressbalanceSpcvxEnum)[i]/yts,StressbalanceSIAAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx.
|
---|
52 | count++;
|
---|
53 | }
|
---|
54 |
|
---|
55 | if (!xIsNan<IssmDouble>(iomodel->Data(StressbalanceSpcvyEnum)[i])){
|
---|
56 | constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,2,iomodel->Data(StressbalanceSpcvyEnum)[i]/yts,StressbalanceSIAAnalysisEnum)); //add count'th spc, on node i+1, setting dof 2 to vy
|
---|
57 | count++;
|
---|
58 | }
|
---|
59 | }
|
---|
60 | }
|
---|
61 | }
|
---|
62 |
|
---|
63 | /*Free data: */
|
---|
64 | iomodel->DeleteData(3,StressbalanceSpcvxEnum,StressbalanceSpcvyEnum,FlowequationVertexEquationEnum);
|
---|
65 |
|
---|
66 | /*Assign output pointer: */
|
---|
67 | *pconstraints=constraints;
|
---|
68 | }
|
---|