[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] | 16 | SpcStatic::SpcStatic(){/*{{{*/
|
---|
[3683] | 17 | return;
|
---|
| 18 | }
|
---|
[12365] | 19 | /*}}}*/
|
---|
[22361] | 20 | SpcStatic::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] | 32 | SpcStatic::~SpcStatic(){/*{{{*/
|
---|
[3683] | 33 | return;
|
---|
| 34 | }
|
---|
[12365] | 35 | /*}}}*/
|
---|
[13622] | 36 |
|
---|
[4248] | 37 | /*Object virtual functions definitions:*/
|
---|
[18931] | 38 | Object* SpcStatic::copy() {/*{{{*/
|
---|
| 39 |
|
---|
| 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 | /*}}}*/
|
---|
| 51 | void 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] | 62 | void 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] | 73 | int SpcStatic::Id(void){ return id; }/*{{{*/
|
---|
[12365] | 74 | /*}}}*/
|
---|
[19254] | 75 | void 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] | 88 | int SpcStatic::ObjectEnum(void){/*{{{*/
|
---|
[19216] | 89 |
|
---|
[20810] | 90 | return SpcStaticEnum;
|
---|
| 91 |
|
---|
| 92 | }
|
---|
| 93 | /*}}}*/
|
---|
| 94 |
|
---|
[9002] | 95 | /*Constraint virtual functions definitions: */
|
---|
[18388] | 96 | void SpcStatic::ActivatePenaltyMethod(void){/*{{{*/
|
---|
| 97 | this->penalty = true;
|
---|
| 98 | }
|
---|
| 99 | /*}}}*/
|
---|
[18064] | 100 | void 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 | /*}}}*/
|
---|
[18931] | 111 | bool SpcStatic::InAnalysis(int in_analysis_type){/*{{{*/
|
---|
| 112 | if (in_analysis_type==this->analysis_type) return true;
|
---|
| 113 | else return false;
|
---|
| 114 | }
|
---|
| 115 | /*}}}*/
|
---|
[22200] | 116 | void SpcStatic::InputUpdateFromVectorDakota(IssmDouble* vector,Nodes* nodes,int name,int type){/*{{{*/
|
---|
[9002] | 117 |
|
---|
[22202] | 118 | /*Only update if this is a constraint parameter*/
|
---|
| 119 | if(name != BalancethicknessSpcthicknessEnum) return;
|
---|
| 120 |
|
---|
[22200] | 121 | /*Chase through nodes and find the node to which this SpcStatic applys: */
|
---|
| 122 | Node* node=(Node*)nodes->GetObjectById(NULL,nodeid);
|
---|
| 123 |
|
---|
| 124 | /*Apply constraint: */
|
---|
| 125 | if(node){ //in case the spc is dealing with a node on another cpu
|
---|
| 126 | int sid = node->Sid();
|
---|
| 127 | this->value = vector[sid];
|
---|
| 128 | _assert_(!xIsNan<IssmDouble>(this->value));
|
---|
| 129 | }
|
---|
| 130 | }
|
---|
| 131 | /*}}}*/
|
---|
| 132 |
|
---|
[9285] | 133 | /*SpcStatic functions*/
|
---|
[18931] | 134 | int SpcStatic::GetDof(){/*{{{*/
|
---|
[3683] | 135 | return dof;
|
---|
| 136 | }
|
---|
[12365] | 137 | /*}}}*/
|
---|
[18931] | 138 | int SpcStatic::GetNodeId(){/*{{{*/
|
---|
[13622] | 139 |
|
---|
[3683] | 140 | return nodeid;
|
---|
| 141 | }
|
---|
[12365] | 142 | /*}}}*/
|
---|
[18064] | 143 | IssmDouble SpcStatic::GetValue(){/*{{{*/
|
---|
[12529] | 144 | _assert_(!xIsNan<IssmDouble>(value));
|
---|
[3683] | 145 | return value;
|
---|
| 146 | }
|
---|
[12365] | 147 | /*}}}*/
|
---|