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(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
|
---|
76 |
|
---|
77 | MARSHALLING_ENUM(SpcStaticEnum);
|
---|
78 |
|
---|
79 | MARSHALLING(id);
|
---|
80 | MARSHALLING(nodeid);
|
---|
81 | MARSHALLING(dof);
|
---|
82 | MARSHALLING(value);
|
---|
83 | MARSHALLING(analysis_type);
|
---|
84 | MARSHALLING(penalty);
|
---|
85 |
|
---|
86 | }
|
---|
87 | /*}}}*/
|
---|
88 | int SpcStatic::ObjectEnum(void){/*{{{*/
|
---|
89 |
|
---|
90 | return SpcStaticEnum;
|
---|
91 |
|
---|
92 | }
|
---|
93 | /*}}}*/
|
---|
94 |
|
---|
95 | /*Constraint virtual functions definitions: */
|
---|
96 | void SpcStatic::ActivatePenaltyMethod(void){/*{{{*/
|
---|
97 | this->penalty = true;
|
---|
98 | }
|
---|
99 | /*}}}*/
|
---|
100 | void SpcStatic::ConstrainNode(Nodes* nodes,Parameters* parameters){/*{{{*/
|
---|
101 |
|
---|
102 | /*Chase through nodes and find the node to which this SpcStatic applys: */
|
---|
103 | Node* node=(Node*)nodes->GetObjectById(NULL,nodeid);
|
---|
104 |
|
---|
105 | /*Apply constraint: */
|
---|
106 | if(!this->penalty && node){ //in case the spc is dealing with a node on another cpu
|
---|
107 | node->ApplyConstraint(dof,value);
|
---|
108 | }
|
---|
109 | }
|
---|
110 | /*}}}*/
|
---|
111 | void SpcStatic::InputUpdateFromVectorDakota(IssmDouble* vector,Nodes* nodes,int name,int type){/*{{{*/
|
---|
112 |
|
---|
113 | /*Only update if this is a constraint parameter*/
|
---|
114 | if(name != BalancethicknessSpcthicknessEnum) return;
|
---|
115 |
|
---|
116 | /*Chase through nodes and find the node to which this SpcStatic applies: */
|
---|
117 | Node* node=(Node*)nodes->GetObjectById(NULL,nodeid);
|
---|
118 |
|
---|
119 | /*Apply constraint: */
|
---|
120 | if(node){ //in case the spc is dealing with a node on another cpu
|
---|
121 | int sid = node->Sid();
|
---|
122 | this->value = vector[sid];
|
---|
123 | _assert_(!xIsNan<IssmDouble>(this->value));
|
---|
124 | }
|
---|
125 | }
|
---|
126 | /*}}}*/
|
---|
127 | void SpcStatic::PenaltyDofAndValue(int* pdof,IssmDouble* pvalue,Nodes* nodes,Parameters* parameters){/*{{{*/
|
---|
128 |
|
---|
129 | if(!this->penalty) _error_("cannot return dof and value for non penalty constraint");
|
---|
130 |
|
---|
131 | IssmDouble value_out = this->value;
|
---|
132 | int gdof;
|
---|
133 |
|
---|
134 | /*Chase through nodes and find the node to which this SpcTransient applys: */
|
---|
135 | Node* node=(Node*)nodes->GetObjectById(NULL,nodeid);
|
---|
136 |
|
---|
137 | if(node){ //in case the spc is dealing with a node on another cpu
|
---|
138 |
|
---|
139 | /*Get gdof */
|
---|
140 | gdof = node->GetDof(dof,GsetEnum);
|
---|
141 | if(xIsNan<IssmDouble>(value_out)) gdof = -1;
|
---|
142 | }
|
---|
143 | else{
|
---|
144 | value_out = NAN;
|
---|
145 | gdof = -1;
|
---|
146 | }
|
---|
147 |
|
---|
148 | /*Assign output pointers*/
|
---|
149 | *pdof = gdof;
|
---|
150 | *pvalue = value_out;
|
---|
151 | }
|
---|
152 | /*}}}*/
|
---|
153 |
|
---|
154 | void SpcStatic::UpdateSpcThicknessAD(IssmDouble* vector,Nodes* nodes){/*{{{*/
|
---|
155 |
|
---|
156 | /*Chase through nodes and find the node to which this SpcStatic applies: */
|
---|
157 | Node* node=(Node*)nodes->GetObjectById(NULL,nodeid);
|
---|
158 |
|
---|
159 | /*Apply constraint: */
|
---|
160 | if(node){ //in case the spc is dealing with a node on another cpu
|
---|
161 | int sid = node->Sid();
|
---|
162 | this->value = vector[sid];
|
---|
163 | _assert_(!xIsNan<IssmDouble>(this->value));
|
---|
164 | }
|
---|
165 | }
|
---|
166 | /*}}}*/
|
---|
167 |
|
---|
168 | /*SpcStatic functions*/
|
---|
169 | int SpcStatic::GetDof(){/*{{{*/
|
---|
170 | return dof;
|
---|
171 | }
|
---|
172 | /*}}}*/
|
---|
173 | int SpcStatic::GetNodeId(){/*{{{*/
|
---|
174 |
|
---|
175 | return nodeid;
|
---|
176 | }
|
---|
177 | /*}}}*/
|
---|
178 | IssmDouble SpcStatic::GetValue(){/*{{{*/
|
---|
179 | _assert_(!xIsNan<IssmDouble>(value));
|
---|
180 | return value;
|
---|
181 | }
|
---|
182 | /*}}}*/
|
---|