| 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 |
|
|---|
| 20 | /*Recover pointer: */
|
|---|
| 21 | constraints=*pconstraints;
|
|---|
| 22 |
|
|---|
| 23 | /*Fetch parameters: */
|
|---|
| 24 | iomodel->Constant(&yts,ConstantsYtsEnum);
|
|---|
| 25 | iomodel->Constant(&isSIA,FlowequationIsSIAEnum);
|
|---|
| 26 |
|
|---|
| 27 | /*Now, is the flag isSIA on? otherwise, do nothing: */
|
|---|
| 28 | if (!isSIA) return;
|
|---|
| 29 |
|
|---|
| 30 | /*Fetch data: */
|
|---|
| 31 | iomodel->FetchData(3,StressbalanceSpcvxEnum,StressbalanceSpcvyEnum,FlowequationVertexEquationEnum);
|
|---|
| 32 |
|
|---|
| 33 | /*Initialize conunter*/
|
|---|
| 34 | count=0;
|
|---|
| 35 |
|
|---|
| 36 | /*vx and vy are spc'd if we are not on nodeonSIA: */
|
|---|
| 37 | for(int i=0;i<iomodel->numberofvertices;i++){
|
|---|
| 38 | /*keep only this partition's nodes:*/
|
|---|
| 39 | if((iomodel->my_vertices[i])){
|
|---|
| 40 | if (!reCast<int,IssmDouble>(iomodel->Data(FlowequationVertexEquationEnum)[i])==SIAApproximationEnum){
|
|---|
| 41 |
|
|---|
| 42 | constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,1,0,StressbalanceSIAAnalysisEnum));
|
|---|
| 43 | count++;
|
|---|
| 44 |
|
|---|
| 45 | constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,2,0,StressbalanceSIAAnalysisEnum));
|
|---|
| 46 | count++;
|
|---|
| 47 | }
|
|---|
| 48 | else{
|
|---|
| 49 | if (!xIsNan<IssmDouble>(iomodel->Data(StressbalanceSpcvxEnum)[i])){
|
|---|
| 50 | 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.
|
|---|
| 51 | count++;
|
|---|
| 52 | }
|
|---|
| 53 |
|
|---|
| 54 | if (!xIsNan<IssmDouble>(iomodel->Data(StressbalanceSpcvyEnum)[i])){
|
|---|
| 55 | 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
|
|---|
| 56 | count++;
|
|---|
| 57 | }
|
|---|
| 58 | }
|
|---|
| 59 | }
|
|---|
| 60 | }
|
|---|
| 61 |
|
|---|
| 62 | /*Free data: */
|
|---|
| 63 | iomodel->DeleteData(3,StressbalanceSpcvxEnum,StressbalanceSpcvyEnum,FlowequationVertexEquationEnum);
|
|---|
| 64 |
|
|---|
| 65 | /*Assign output pointer: */
|
|---|
| 66 | *pconstraints=constraints;
|
|---|
| 67 | }
|
|---|