1 | /*!\file SpcStatic.c
|
---|
2 | * \brief: implementation of the SpcStatic object
|
---|
3 | */
|
---|
4 |
|
---|
5 | #ifdef HAVE_CONFIG_H
|
---|
6 | #include <config.h>
|
---|
7 | #else
|
---|
8 | #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
---|
9 | #endif
|
---|
10 |
|
---|
11 | #include "../classes.h"
|
---|
12 | #include "./Constraint.h"
|
---|
13 | #include "../../shared/shared.h"
|
---|
14 |
|
---|
15 | /*SpcStatic constructors and destructor*/
|
---|
16 | SpcStatic::SpcStatic(){/*{{{*/
|
---|
17 | return;
|
---|
18 | }
|
---|
19 | /*}}}*/
|
---|
20 | SpcStatic::SpcStatic(int spc_id,int spc_nodeid, int spc_dof,IssmDouble spc_value,int spc_analysis_type){/*{{{*/
|
---|
21 |
|
---|
22 | id = spc_id;
|
---|
23 | nodeid = spc_nodeid;
|
---|
24 | dof = spc_dof;
|
---|
25 | value = spc_value;
|
---|
26 | analysis_type = spc_analysis_type;
|
---|
27 | penalty = false;
|
---|
28 |
|
---|
29 | return;
|
---|
30 | }
|
---|
31 | /*}}}*/
|
---|
32 | SpcStatic::~SpcStatic(){/*{{{*/
|
---|
33 | return;
|
---|
34 | }
|
---|
35 | /*}}}*/
|
---|
36 |
|
---|
37 | /*Object virtual functions definitions:*/
|
---|
38 | Object* SpcStatic::copy() {/*{{{*/
|
---|
39 |
|
---|
40 | SpcStatic* spcstat = new SpcStatic(*this);
|
---|
41 |
|
---|
42 | spcstat->id=this->id;
|
---|
43 | spcstat->nodeid=this->nodeid;
|
---|
44 | spcstat->dof=this->dof;
|
---|
45 | spcstat->value=this->value;
|
---|
46 | spcstat->analysis_type=this->analysis_type;
|
---|
47 |
|
---|
48 | return (Object*) spcstat;
|
---|
49 | }
|
---|
50 | /*}}}*/
|
---|
51 | void SpcStatic::DeepEcho(void){/*{{{*/
|
---|
52 |
|
---|
53 | _printf_("SpcStatic:\n");
|
---|
54 | _printf_(" id: " << id << "\n");
|
---|
55 | _printf_(" nodeid: " << nodeid << "\n");
|
---|
56 | _printf_(" dof: " << dof << "\n");
|
---|
57 | _printf_(" value: " << value << "\n");
|
---|
58 | _printf_(" analysis_type: " << EnumToStringx(analysis_type) << "\n");
|
---|
59 | return;
|
---|
60 | }
|
---|
61 | /*}}}*/
|
---|
62 | void SpcStatic::Echo(void){/*{{{*/
|
---|
63 |
|
---|
64 | _printf_("SpcStatic:\n");
|
---|
65 | _printf_(" id: " << id << "\n");
|
---|
66 | _printf_(" nodeid: " << nodeid << "\n");
|
---|
67 | _printf_(" dof: " << dof << "\n");
|
---|
68 | _printf_(" value: " << value << "\n");
|
---|
69 | _printf_(" analysis_type: " << EnumToStringx(analysis_type) << "\n");
|
---|
70 | return;
|
---|
71 | }
|
---|
72 | /*}}}*/
|
---|
73 | int SpcStatic::Id(void){ return id; }/*{{{*/
|
---|
74 | /*}}}*/
|
---|
75 | void SpcStatic::Marshall(MarshallHandle* marshallhandle){ /*{{{*/
|
---|
76 |
|
---|
77 | int object_enum = SpcStaticEnum;
|
---|
78 | marshallhandle->call(object_enum);
|
---|
79 |
|
---|
80 | marshallhandle->call(this->id);
|
---|
81 | marshallhandle->call(this->nodeid);
|
---|
82 | marshallhandle->call(this->dof);
|
---|
83 | marshallhandle->call(this->value);
|
---|
84 | marshallhandle->call(this->analysis_type);
|
---|
85 | marshallhandle->call(this->penalty);
|
---|
86 |
|
---|
87 | }
|
---|
88 | /*}}}*/
|
---|
89 | int SpcStatic::ObjectEnum(void){/*{{{*/
|
---|
90 |
|
---|
91 | return SpcStaticEnum;
|
---|
92 |
|
---|
93 | }
|
---|
94 | /*}}}*/
|
---|
95 |
|
---|
96 | /*Constraint virtual functions definitions: */
|
---|
97 | void SpcStatic::ActivatePenaltyMethod(void){/*{{{*/
|
---|
98 | this->penalty = true;
|
---|
99 | }
|
---|
100 | /*}}}*/
|
---|
101 | void SpcStatic::ConstrainNode(Nodes* nodes,Parameters* parameters){/*{{{*/
|
---|
102 |
|
---|
103 | /*Chase through nodes and find the node to which this SpcStatic applys: */
|
---|
104 | Node* node=(Node*)nodes->GetObjectById(NULL,nodeid);
|
---|
105 |
|
---|
106 | /*Apply constraint: */
|
---|
107 | if(!this->penalty && node){ //in case the spc is dealing with a node on another cpu
|
---|
108 | node->ApplyConstraint(dof,value);
|
---|
109 | }
|
---|
110 | }
|
---|
111 | /*}}}*/
|
---|
112 | void SpcStatic::InputUpdateFromVectorDakota(IssmDouble* vector,Nodes* nodes,int name,int type){/*{{{*/
|
---|
113 |
|
---|
114 | /*Only update if this is a constraint parameter*/
|
---|
115 | if(name != BalancethicknessSpcthicknessEnum) return;
|
---|
116 |
|
---|
117 | /*Chase through nodes and find the node to which this SpcStatic applies: */
|
---|
118 | Node* node=(Node*)nodes->GetObjectById(NULL,nodeid);
|
---|
119 |
|
---|
120 | /*Apply constraint: */
|
---|
121 | if(node){ //in case the spc is dealing with a node on another cpu
|
---|
122 | int sid = node->Sid();
|
---|
123 | this->value = vector[sid];
|
---|
124 | _assert_(!xIsNan<IssmDouble>(this->value));
|
---|
125 | }
|
---|
126 | }
|
---|
127 | /*}}}*/
|
---|
128 | void SpcStatic::PenaltyDofAndValue(int* pdof,IssmDouble* pvalue,Nodes* nodes,Parameters* parameters){/*{{{*/
|
---|
129 |
|
---|
130 | if(!this->penalty) _error_("cannot return dof and value for non penalty constraint");
|
---|
131 |
|
---|
132 | IssmDouble value_out = this->value;
|
---|
133 | int gdof;
|
---|
134 |
|
---|
135 | /*Chase through nodes and find the node to which this SpcTransient applys: */
|
---|
136 | Node* node=(Node*)nodes->GetObjectById(NULL,nodeid);
|
---|
137 |
|
---|
138 | if(node){ //in case the spc is dealing with a node on another cpu
|
---|
139 |
|
---|
140 | /*Get gdof */
|
---|
141 | gdof = node->GetDof(dof,GsetEnum);
|
---|
142 | if(xIsNan<IssmDouble>(value_out)) gdof = -1;
|
---|
143 | }
|
---|
144 | else{
|
---|
145 | value_out = NAN;
|
---|
146 | gdof = -1;
|
---|
147 | }
|
---|
148 |
|
---|
149 | /*Assign output pointers*/
|
---|
150 | *pdof = gdof;
|
---|
151 | *pvalue = value_out;
|
---|
152 | }
|
---|
153 | /*}}}*/
|
---|
154 |
|
---|
155 | void SpcStatic::UpdateSpcThicknessAD(IssmDouble* vector,Nodes* nodes){/*{{{*/
|
---|
156 |
|
---|
157 | /*Chase through nodes and find the node to which this SpcStatic applies: */
|
---|
158 | Node* node=(Node*)nodes->GetObjectById(NULL,nodeid);
|
---|
159 |
|
---|
160 | /*Apply constraint: */
|
---|
161 | if(node){ //in case the spc is dealing with a node on another cpu
|
---|
162 | int sid = node->Sid();
|
---|
163 | this->value = vector[sid];
|
---|
164 | _assert_(!xIsNan<IssmDouble>(this->value));
|
---|
165 | }
|
---|
166 | }
|
---|
167 | /*}}}*/
|
---|
168 |
|
---|
169 | /*SpcStatic functions*/
|
---|
170 | int SpcStatic::GetDof(){/*{{{*/
|
---|
171 | return dof;
|
---|
172 | }
|
---|
173 | /*}}}*/
|
---|
174 | int SpcStatic::GetNodeId(){/*{{{*/
|
---|
175 |
|
---|
176 | return nodeid;
|
---|
177 | }
|
---|
178 | /*}}}*/
|
---|
179 | IssmDouble SpcStatic::GetValue(){/*{{{*/
|
---|
180 | _assert_(!xIsNan<IssmDouble>(value));
|
---|
181 | return value;
|
---|
182 | }
|
---|
183 | /*}}}*/
|
---|