source: issm/trunk-jpl/src/c/classes/Constraints/SpcStatic.cpp@ 25506

Last change on this file since 25506 was 25506, checked in by Mathieu Morlighem, 5 years ago

NEW: new way of Marshalling femmodel

File size: 4.8 KB
Line 
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*/
16SpcStatic::SpcStatic(){/*{{{*/
17 return;
18}
19/*}}}*/
20SpcStatic::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/*}}}*/
32SpcStatic::~SpcStatic(){/*{{{*/
33 return;
34}
35/*}}}*/
36
37/*Object virtual functions definitions:*/
38Object* 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/*}}}*/
51void 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/*}}}*/
62void 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/*}}}*/
73int SpcStatic::Id(void){ return id; }/*{{{*/
74/*}}}*/
75void 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/*}}}*/
88void SpcStatic::Marshall2(MarshallHandle* marshallhandle){ /*{{{*/
89
90 int object_enum = SpcStaticEnum;
91 marshallhandle->call(object_enum);
92
93 marshallhandle->call(this->id);
94 marshallhandle->call(this->nodeid);
95 marshallhandle->call(this->dof);
96 marshallhandle->call(this->value);
97 marshallhandle->call(this->analysis_type);
98 marshallhandle->call(this->penalty);
99
100}
101/*}}}*/
102int SpcStatic::ObjectEnum(void){/*{{{*/
103
104 return SpcStaticEnum;
105
106}
107/*}}}*/
108
109/*Constraint virtual functions definitions: */
110void SpcStatic::ActivatePenaltyMethod(void){/*{{{*/
111 this->penalty = true;
112}
113/*}}}*/
114void SpcStatic::ConstrainNode(Nodes* nodes,Parameters* parameters){/*{{{*/
115
116 /*Chase through nodes and find the node to which this SpcStatic applys: */
117 Node* node=(Node*)nodes->GetObjectById(NULL,nodeid);
118
119 /*Apply constraint: */
120 if(!this->penalty && node){ //in case the spc is dealing with a node on another cpu
121 node->ApplyConstraint(dof,value);
122 }
123}
124/*}}}*/
125void SpcStatic::InputUpdateFromVectorDakota(IssmDouble* vector,Nodes* nodes,int name,int type){/*{{{*/
126
127 /*Only update if this is a constraint parameter*/
128 if(name != BalancethicknessSpcthicknessEnum) return;
129
130 /*Chase through nodes and find the node to which this SpcStatic applies: */
131 Node* node=(Node*)nodes->GetObjectById(NULL,nodeid);
132
133 /*Apply constraint: */
134 if(node){ //in case the spc is dealing with a node on another cpu
135 int sid = node->Sid();
136 this->value = vector[sid];
137 _assert_(!xIsNan<IssmDouble>(this->value));
138 }
139}
140/*}}}*/
141void SpcStatic::PenaltyDofAndValue(int* pdof,IssmDouble* pvalue,Nodes* nodes,Parameters* parameters){/*{{{*/
142
143 if(!this->penalty) _error_("cannot return dof and value for non penalty constraint");
144
145 IssmDouble value_out = this->value;
146 int gdof;
147
148 /*Chase through nodes and find the node to which this SpcTransient applys: */
149 Node* node=(Node*)nodes->GetObjectById(NULL,nodeid);
150
151 if(node){ //in case the spc is dealing with a node on another cpu
152
153 /*Get gdof */
154 gdof = node->GetDof(dof,GsetEnum);
155 if(xIsNan<IssmDouble>(value_out)) gdof = -1;
156 }
157 else{
158 value_out = NAN;
159 gdof = -1;
160 }
161
162 /*Assign output pointers*/
163 *pdof = gdof;
164 *pvalue = value_out;
165}
166/*}}}*/
167
168void SpcStatic::UpdateSpcThicknessAD(IssmDouble* vector,Nodes* nodes){/*{{{*/
169
170 /*Chase through nodes and find the node to which this SpcStatic applies: */
171 Node* node=(Node*)nodes->GetObjectById(NULL,nodeid);
172
173 /*Apply constraint: */
174 if(node){ //in case the spc is dealing with a node on another cpu
175 int sid = node->Sid();
176 this->value = vector[sid];
177 _assert_(!xIsNan<IssmDouble>(this->value));
178 }
179}
180/*}}}*/
181
182/*SpcStatic functions*/
183int SpcStatic::GetDof(){/*{{{*/
184 return dof;
185}
186/*}}}*/
187int SpcStatic::GetNodeId(){/*{{{*/
188
189 return nodeid;
190}
191/*}}}*/
192IssmDouble SpcStatic::GetValue(){/*{{{*/
193 _assert_(!xIsNan<IssmDouble>(value));
194 return value;
195}
196/*}}}*/
Note: See TracBrowser for help on using the repository browser.