Ice Sheet System Model  4.18
Code documentation
SpcStatic.cpp
Go to the documentation of this file.
1 
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*/
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 /*}}}*/
33  return;
34 }
35 /*}}}*/
36 
37 /*Object virtual functions definitions:*/
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 
78 
79  MARSHALLING(id);
85 
86 }
87 /*}}}*/
88 int SpcStatic::ObjectEnum(void){/*{{{*/
89 
90  return SpcStaticEnum;
91 
92 }
93 /*}}}*/
94 
95 /*Constraint virtual functions definitions: */
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 /*SpcStatic functions*/
155 int SpcStatic::GetDof(){/*{{{*/
156  return dof;
157 }
158 /*}}}*/
159 int SpcStatic::GetNodeId(){/*{{{*/
160 
161  return nodeid;
162 }
163 /*}}}*/
165  _assert_(!xIsNan<IssmDouble>(value));
166  return value;
167 }
168 /*}}}*/
SpcStatic::SpcStatic
SpcStatic()
Definition: SpcStatic.cpp:16
_assert_
#define _assert_(ignore)
Definition: exceptions.h:37
IssmDouble
double IssmDouble
Definition: types.h:37
SpcStatic::~SpcStatic
~SpcStatic()
Definition: SpcStatic.cpp:32
Nodes
Declaration of Nodes class.
Definition: Nodes.h:19
DataSet::GetObjectById
Object * GetObjectById(int *poffset, int eid)
Definition: DataSet.cpp:345
_printf_
#define _printf_(StreamArgs)
Definition: Print.h:22
Parameters
Declaration of Parameters class.
Definition: Parameters.h:18
SpcStatic::Echo
void Echo()
Definition: SpcStatic.cpp:62
MARSHALLING_ENUM
#define MARSHALLING_ENUM(EN)
Definition: Marshalling.h:14
SpcStatic::value
IssmDouble value
Definition: SpcStatic.h:19
SpcStatic::ConstrainNode
void ConstrainNode(Nodes *nodes, Parameters *parameters)
Definition: SpcStatic.cpp:100
Constraint.h
abstract class for Constraint object This class is a place holder for constraints It is derived from ...
SpcStatic::GetValue
IssmDouble GetValue()
Definition: SpcStatic.cpp:164
SpcStatic::GetNodeId
int GetNodeId()
Definition: SpcStatic.cpp:159
SpcStatic::analysis_type
int analysis_type
Definition: SpcStatic.h:20
SpcStatic
Definition: SpcStatic.h:13
SpcStatic::GetDof
int GetDof()
Definition: SpcStatic.cpp:155
SpcStatic::Marshall
void Marshall(char **pmarshalled_data, int *pmarshalled_data_size, int marshall_direction)
Definition: SpcStatic.cpp:75
Object
Definition: Object.h:13
SpcStaticEnum
@ SpcStaticEnum
Definition: EnumDefinitions.h:1280
SpcStatic::ObjectEnum
int ObjectEnum()
Definition: SpcStatic.cpp:88
SpcStatic::copy
Object * copy()
Definition: SpcStatic.cpp:38
EnumToStringx
const char * EnumToStringx(int enum_in)
Definition: EnumToStringx.cpp:15
GsetEnum
@ GsetEnum
Definition: EnumDefinitions.h:1093
MARSHALLING
#define MARSHALLING(FIELD)
Definition: Marshalling.h:29
SpcStatic::id
int id
Definition: SpcStatic.h:16
SpcStatic::Id
int Id()
Definition: SpcStatic.cpp:73
SpcStatic::penalty
bool penalty
Definition: SpcStatic.h:21
SpcStatic::dof
int dof
Definition: SpcStatic.h:18
Node
Definition: Node.h:23
Node::Sid
int Sid(void)
Definition: Node.cpp:622
SpcStatic::DeepEcho
void DeepEcho()
Definition: SpcStatic.cpp:51
_error_
#define _error_(StreamArgs)
Definition: exceptions.h:49
SpcStatic::nodeid
int nodeid
Definition: SpcStatic.h:17
Node::ApplyConstraint
void ApplyConstraint(int dof, IssmDouble value)
Definition: Node.cpp:646
SpcStatic::ActivatePenaltyMethod
void ActivatePenaltyMethod(void)
Definition: SpcStatic.cpp:96
BalancethicknessSpcthicknessEnum
@ BalancethicknessSpcthicknessEnum
Definition: EnumDefinitions.h:986
SpcStatic::PenaltyDofAndValue
void PenaltyDofAndValue(int *dof, IssmDouble *value, Nodes *nodes, Parameters *parameters)
Definition: SpcStatic.cpp:127
SpcStatic::InputUpdateFromVectorDakota
void InputUpdateFromVectorDakota(IssmDouble *vector, Nodes *nodes, int name, int type)
Definition: SpcStatic.cpp:111
Node::GetDof
int GetDof(int dofindex, int setenum)
Definition: Node.cpp:374