| 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(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 |
|
|---|
| 128 | /*SpcStatic functions*/
|
|---|
| 129 | int SpcStatic::GetDof(){/*{{{*/
|
|---|
| 130 | return dof;
|
|---|
| 131 | }
|
|---|
| 132 | /*}}}*/
|
|---|
| 133 | int SpcStatic::GetNodeId(){/*{{{*/
|
|---|
| 134 |
|
|---|
| 135 | return nodeid;
|
|---|
| 136 | }
|
|---|
| 137 | /*}}}*/
|
|---|
| 138 | IssmDouble SpcStatic::GetValue(){/*{{{*/
|
|---|
| 139 | _assert_(!xIsNan<IssmDouble>(value));
|
|---|
| 140 | return value;
|
|---|
| 141 | }
|
|---|
| 142 | /*}}}*/
|
|---|