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

Last change on this file since 24106 was 24106, checked in by Mathieu Morlighem, 6 years ago

CHG: minor

File size: 3.3 KB
RevLine 
[9285]1/*!\file SpcStatic.c
2 * \brief: implementation of the SpcStatic object
[3683]3 */
4
5#ifdef HAVE_CONFIG_H
[9320]6 #include <config.h>
[3683]7#else
8#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
9#endif
10
[15012]11#include "../classes.h"
12#include "./Constraint.h"
13#include "../../shared/shared.h"
[3683]14
[9285]15/*SpcStatic constructors and destructor*/
[18064]16SpcStatic::SpcStatic(){/*{{{*/
[3683]17 return;
18}
[12365]19/*}}}*/
[22361]20SpcStatic::SpcStatic(int spc_id,int spc_nodeid, int spc_dof,IssmDouble spc_value,int spc_analysis_type){/*{{{*/
[3683]21
[22361]22 id = spc_id;
[15448]23 nodeid = spc_nodeid;
24 dof = spc_dof;
25 value = spc_value;
26 analysis_type = spc_analysis_type;
[18388]27 penalty = false;
[3683]28
29 return;
30}
[12365]31/*}}}*/
[18064]32SpcStatic::~SpcStatic(){/*{{{*/
[3683]33 return;
34}
[12365]35/*}}}*/
[13622]36
[4248]37/*Object virtual functions definitions:*/
[18931]38Object* SpcStatic::copy() {/*{{{*/
[23066]39
[18931]40 SpcStatic* spcstat = new SpcStatic(*this);
[4248]41
[22361]42 spcstat->id=this->id;
[18931]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
[15104]53 _printf_("SpcStatic:\n");
[22361]54 _printf_(" id: " << id << "\n");
[15100]55 _printf_(" nodeid: " << nodeid << "\n");
56 _printf_(" dof: " << dof << "\n");
57 _printf_(" value: " << value << "\n");
58 _printf_(" analysis_type: " << EnumToStringx(analysis_type) << "\n");
[4248]59 return;
[18931]60}
[12365]61/*}}}*/
[18931]62void SpcStatic::Echo(void){/*{{{*/
[4248]63
[15104]64 _printf_("SpcStatic:\n");
[22361]65 _printf_(" id: " << id << "\n");
[15100]66 _printf_(" nodeid: " << nodeid << "\n");
67 _printf_(" dof: " << dof << "\n");
68 _printf_(" value: " << value << "\n");
69 _printf_(" analysis_type: " << EnumToStringx(analysis_type) << "\n");
[4248]70 return;
[18931]71}
[12365]72/*}}}*/
[22361]73int SpcStatic::Id(void){ return id; }/*{{{*/
[12365]74/*}}}*/
[19254]75void SpcStatic::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
[18237]76
[19216]77 MARSHALLING_ENUM(SpcStaticEnum);
78
[22361]79 MARSHALLING(id);
[19216]80 MARSHALLING(nodeid);
81 MARSHALLING(dof);
82 MARSHALLING(value);
83 MARSHALLING(analysis_type);
84 MARSHALLING(penalty);
85
86}
87/*}}}*/
[20810]88int SpcStatic::ObjectEnum(void){/*{{{*/
[19216]89
[20810]90 return SpcStaticEnum;
91
92}
93/*}}}*/
94
[9002]95/*Constraint virtual functions definitions: */
[18388]96void SpcStatic::ActivatePenaltyMethod(void){/*{{{*/
97 this->penalty = true;
98}
99/*}}}*/
[18064]100void SpcStatic::ConstrainNode(Nodes* nodes,Parameters* parameters){/*{{{*/
[9002]101
[9285]102 /*Chase through nodes and find the node to which this SpcStatic applys: */
[22200]103 Node* node=(Node*)nodes->GetObjectById(NULL,nodeid);
[9002]104
105 /*Apply constraint: */
106 if(node){ //in case the spc is dealing with a node on another cpu
107 node->ApplyConstraint(dof,value);
108 }
109}
110/*}}}*/
[22200]111void SpcStatic::InputUpdateFromVectorDakota(IssmDouble* vector,Nodes* nodes,int name,int type){/*{{{*/
[9002]112
[22202]113 /*Only update if this is a constraint parameter*/
114 if(name != BalancethicknessSpcthicknessEnum) return;
115
[24106]116 /*Chase through nodes and find the node to which this SpcStatic applies: */
[22200]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
[9285]128/*SpcStatic functions*/
[18931]129int SpcStatic::GetDof(){/*{{{*/
[3683]130 return dof;
131}
[12365]132/*}}}*/
[18931]133int SpcStatic::GetNodeId(){/*{{{*/
[13622]134
[3683]135 return nodeid;
136}
[12365]137/*}}}*/
[18064]138IssmDouble SpcStatic::GetValue(){/*{{{*/
[12529]139 _assert_(!xIsNan<IssmDouble>(value));
[3683]140 return value;
141}
[12365]142/*}}}*/
Note: See TracBrowser for help on using the repository browser.