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 <stdio.h>
|
---|
12 | #include <string.h>
|
---|
13 | #include "../../include/include.h"
|
---|
14 | #include "../../shared/shared.h"
|
---|
15 | #include "../../EnumDefinitions/EnumDefinitions.h"
|
---|
16 | #include "../../Container/Container.h"
|
---|
17 | #include "../objects.h"
|
---|
18 |
|
---|
19 | /*SpcStatic constructors and destructor*/
|
---|
20 | /*FUNCTION SpcStatic::SpcStatic(){{{1*/
|
---|
21 | SpcStatic::SpcStatic(){
|
---|
22 | return;
|
---|
23 | }
|
---|
24 | /*}}}1*/
|
---|
25 | /*FUNCTION SpcStatic::SpcStatic(int spc_sid,int spc_nodeid,...){{{1*/
|
---|
26 | SpcStatic::SpcStatic(int spc_sid,int spc_nodeid, int spc_dof,double spc_value,int spc_analysis_type){
|
---|
27 |
|
---|
28 | sid=spc_sid;
|
---|
29 | nodeid=spc_nodeid;
|
---|
30 | dof=spc_dof;
|
---|
31 | value=spc_value;
|
---|
32 | analysis_type=spc_analysis_type;
|
---|
33 |
|
---|
34 | return;
|
---|
35 | }
|
---|
36 | /*}}}1*/
|
---|
37 | /*FUNCTION SpcStatic::~SpcStatic{{{1*/
|
---|
38 | SpcStatic::~SpcStatic(){
|
---|
39 | return;
|
---|
40 | }
|
---|
41 | /*}}}1*/
|
---|
42 |
|
---|
43 | /*Object virtual functions definitions:*/
|
---|
44 | /*FUNCTION SpcStatic::Echo {{{1*/
|
---|
45 | void SpcStatic::Echo(void){
|
---|
46 |
|
---|
47 | printf("SpcStatic:\n");
|
---|
48 | printf(" sid: %i\n",sid);
|
---|
49 | printf(" nodeid: %i\n",nodeid);
|
---|
50 | printf(" dof: %i\n",dof);
|
---|
51 | printf(" value: %g\n",value);
|
---|
52 | printf(" analysis_type: %s\n",EnumToStringx(analysis_type));
|
---|
53 | return;
|
---|
54 | }
|
---|
55 | /*}}}1*/
|
---|
56 | /*FUNCTION SpcStatic::DeepEcho {{{1*/
|
---|
57 | void SpcStatic::DeepEcho(void){
|
---|
58 |
|
---|
59 | printf("SpcStatic:\n");
|
---|
60 | printf(" sid: %i\n",sid);
|
---|
61 | printf(" nodeid: %i\n",nodeid);
|
---|
62 | printf(" dof: %i\n",dof);
|
---|
63 | printf(" value: %g\n",value);
|
---|
64 | printf(" analysis_type: %s\n",EnumToStringx(analysis_type));
|
---|
65 | return;
|
---|
66 | }
|
---|
67 | /*}}}1*/
|
---|
68 | /*FUNCTION SpcStatic::Id {{{1*/
|
---|
69 | int SpcStatic::Id(void){ return sid; }
|
---|
70 | /*}}}1*/
|
---|
71 | /*FUNCTION SpcStatic::MyRank {{{1*/
|
---|
72 | int SpcStatic::MyRank(void){
|
---|
73 | extern int my_rank;
|
---|
74 | return my_rank;
|
---|
75 | }
|
---|
76 | /*}}}1*/
|
---|
77 | #ifdef _SERIAL_
|
---|
78 | /*FUNCTION SpcStatic::Marshall {{{1*/
|
---|
79 | void SpcStatic::Marshall(char** pmarshalled_dataset){
|
---|
80 |
|
---|
81 | char* marshalled_dataset=NULL;
|
---|
82 | int enum_type=0;
|
---|
83 |
|
---|
84 | /*recover marshalled_dataset: */
|
---|
85 | marshalled_dataset=*pmarshalled_dataset;
|
---|
86 |
|
---|
87 | /*get enum type of SpcStatic: */
|
---|
88 | enum_type=SpcStaticEnum;
|
---|
89 |
|
---|
90 | /*marshall enum: */
|
---|
91 | memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
|
---|
92 |
|
---|
93 | /*marshall SpcStatic data: */
|
---|
94 | memcpy(marshalled_dataset,&sid,sizeof(sid));marshalled_dataset+=sizeof(sid);
|
---|
95 | memcpy(marshalled_dataset,&nodeid,sizeof(nodeid));marshalled_dataset+=sizeof(nodeid);
|
---|
96 | memcpy(marshalled_dataset,&dof,sizeof(dof));marshalled_dataset+=sizeof(dof);
|
---|
97 | memcpy(marshalled_dataset,&value,sizeof(value));marshalled_dataset+=sizeof(value);
|
---|
98 | memcpy(marshalled_dataset,&analysis_type,sizeof(analysis_type));marshalled_dataset+=sizeof(analysis_type);
|
---|
99 |
|
---|
100 | *pmarshalled_dataset=marshalled_dataset;
|
---|
101 | return;
|
---|
102 | }
|
---|
103 | /*}}}1*/
|
---|
104 | /*FUNCTION SpcStatic::MarshallSize {{{1*/
|
---|
105 | int SpcStatic::MarshallSize(){
|
---|
106 |
|
---|
107 | return sizeof(sid)
|
---|
108 | +sizeof(nodeid)
|
---|
109 | +sizeof(dof)
|
---|
110 | +sizeof(value)
|
---|
111 | +sizeof(analysis_type)
|
---|
112 | +sizeof(int); //sizeof(int) for enum type
|
---|
113 | }
|
---|
114 | /*}}}1*/
|
---|
115 | /*FUNCTION SpcStatic::Demarshall {{{1*/
|
---|
116 | void SpcStatic::Demarshall(char** pmarshalled_dataset){
|
---|
117 |
|
---|
118 | char* marshalled_dataset=NULL;
|
---|
119 |
|
---|
120 | /*recover marshalled_dataset: */
|
---|
121 | marshalled_dataset=*pmarshalled_dataset;
|
---|
122 |
|
---|
123 | /*this time, no need to get enum type, the pointer directly points to the beginning of the
|
---|
124 | *object data (thanks to DataSet::Demarshall):*/
|
---|
125 |
|
---|
126 | memcpy(&sid,marshalled_dataset,sizeof(sid));marshalled_dataset+=sizeof(sid);
|
---|
127 | memcpy(&nodeid,marshalled_dataset,sizeof(nodeid));marshalled_dataset+=sizeof(nodeid);
|
---|
128 | memcpy(&dof,marshalled_dataset,sizeof(dof));marshalled_dataset+=sizeof(dof);
|
---|
129 | memcpy(&value,marshalled_dataset,sizeof(value));marshalled_dataset+=sizeof(value);
|
---|
130 | memcpy(&analysis_type,marshalled_dataset,sizeof(analysis_type));marshalled_dataset+=sizeof(analysis_type);
|
---|
131 |
|
---|
132 | /*return: */
|
---|
133 | *pmarshalled_dataset=marshalled_dataset;
|
---|
134 | return;
|
---|
135 | }
|
---|
136 | /*}}}1*/
|
---|
137 | #endif
|
---|
138 | /*FUNCTION SpcStatic::ObjectEnum{{{1*/
|
---|
139 | int SpcStatic::ObjectEnum(void){
|
---|
140 |
|
---|
141 | return SpcStaticEnum;
|
---|
142 |
|
---|
143 | }
|
---|
144 | /*}}}1*/
|
---|
145 | /*FUNCTION SpcStatic::copy {{{1*/
|
---|
146 | Object* SpcStatic::copy() {
|
---|
147 | return new SpcStatic(*this);
|
---|
148 | }
|
---|
149 | /*}}}1*/
|
---|
150 |
|
---|
151 | /*Constraint virtual functions definitions: */
|
---|
152 | /*FUNCTION SpcStatic::InAnalysis{{{1*/
|
---|
153 | bool SpcStatic::InAnalysis(int in_analysis_type){
|
---|
154 | if (in_analysis_type==this->analysis_type) return true;
|
---|
155 | else return false;
|
---|
156 | }
|
---|
157 | /*}}}*/
|
---|
158 | /*FUNCTION SpcStatic::ConstrainNode{{{1*/
|
---|
159 | void SpcStatic::ConstrainNode(Nodes* nodes,Parameters* parameters){
|
---|
160 |
|
---|
161 | Node* node=NULL;
|
---|
162 |
|
---|
163 | /*Chase through nodes and find the node to which this SpcStatic applys: */
|
---|
164 | node=(Node*)nodes->GetObjectById(NULL,nodeid);
|
---|
165 |
|
---|
166 | /*Apply constraint: */
|
---|
167 | if(node){ //in case the spc is dealing with a node on another cpu
|
---|
168 | node->ApplyConstraint(dof,value);
|
---|
169 | }
|
---|
170 | }
|
---|
171 | /*}}}*/
|
---|
172 |
|
---|
173 | /*SpcStatic functions*/
|
---|
174 | /*FUNCTION SpcStatic::GetDof {{{1*/
|
---|
175 | int SpcStatic::GetDof(){
|
---|
176 | return dof;
|
---|
177 | }
|
---|
178 | /*}}}1*/
|
---|
179 | /*FUNCTION SpcStatic::GetNodeId {{{1*/
|
---|
180 | int SpcStatic::GetNodeId(){
|
---|
181 |
|
---|
182 | return nodeid;
|
---|
183 | }
|
---|
184 | /*}}}1*/
|
---|
185 | /*FUNCTION SpcStatic::GetValue {{{1*/
|
---|
186 | double SpcStatic::GetValue(){
|
---|
187 | _assert_(!isnan(value));
|
---|
188 | return value;
|
---|
189 | }
|
---|
190 | /*}}}1*/
|
---|