1 | /*!\file PentaVertexElementResult.c
|
---|
2 | * \brief: implementation of the PentaVertexElementResult 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 "./ElementResultLocal.h"
|
---|
14 | #include "../objects.h"
|
---|
15 | #include "../../EnumDefinitions/EnumDefinitions.h"
|
---|
16 | #include "../../shared/shared.h"
|
---|
17 | #include "../../Container/Container.h"
|
---|
18 | #include "../../include/include.h"
|
---|
19 |
|
---|
20 | /*PentaVertexElementResult constructors and destructor*/
|
---|
21 | /*FUNCTION PentaVertexElementResult::PentaVertexElementResult(){{{1*/
|
---|
22 | PentaVertexElementResult::PentaVertexElementResult(){
|
---|
23 | return;
|
---|
24 | }
|
---|
25 | /*}}}*/
|
---|
26 | /*FUNCTION PentaVertexElementResult::PentaVertexElementResult(int in_enum_type,double* in_values,int in_step, double in_time){{{1*/
|
---|
27 | PentaVertexElementResult::PentaVertexElementResult(int in_enum_type,double* in_values,int in_step, double in_time){
|
---|
28 |
|
---|
29 | int i;
|
---|
30 |
|
---|
31 | enum_type=in_enum_type;
|
---|
32 | for(i=0;i<6;i++)values[i]=in_values[i];
|
---|
33 | step=in_step;
|
---|
34 | time=in_time;
|
---|
35 | }
|
---|
36 | /*}}}*/
|
---|
37 | /*FUNCTION PentaVertexElementResult::~PentaVertexElementResult(){{{1*/
|
---|
38 | PentaVertexElementResult::~PentaVertexElementResult(){
|
---|
39 | return;
|
---|
40 | }
|
---|
41 | /*}}}*/
|
---|
42 |
|
---|
43 | /*Object virtual functions definitions:*/
|
---|
44 | /*FUNCTION PentaVertexElementResult::Echo {{{1*/
|
---|
45 | void PentaVertexElementResult::Echo(void){
|
---|
46 | this->DeepEcho();
|
---|
47 | }
|
---|
48 | /*}}}*/
|
---|
49 | /*FUNCTION PentaVertexElementResult::DeepEcho{{{1*/
|
---|
50 | void PentaVertexElementResult::DeepEcho(void){
|
---|
51 |
|
---|
52 | printf("PentaVertexElementResult:\n");
|
---|
53 | printf(" enum: %i (%s)\n",this->enum_type,EnumAsString(this->enum_type));
|
---|
54 | printf(" values: [%g %g %g %g %g %g]\n",this->values[0],this->values[1],this->values[2],this->values[3],this->values[4],this->values[5]);
|
---|
55 | printf(" step: %i\n",this->step);
|
---|
56 | printf(" time: %g\n",this->time);
|
---|
57 |
|
---|
58 | }
|
---|
59 | /*}}}*/
|
---|
60 | /*FUNCTION PentaVertexElementResult::Id{{{1*/
|
---|
61 | int PentaVertexElementResult::Id(void){ return -1; }
|
---|
62 | /*}}}*/
|
---|
63 | /*FUNCTION PentaVertexElementResult::MyRank{{{1*/
|
---|
64 | int PentaVertexElementResult::MyRank(void){
|
---|
65 | extern int my_rank;
|
---|
66 | return my_rank;
|
---|
67 | }
|
---|
68 | /*}}}*/
|
---|
69 | /*FUNCTION PentaVertexElementResult::Marshall{{{1*/
|
---|
70 | void PentaVertexElementResult::Marshall(char** pmarshalled_dataset){
|
---|
71 |
|
---|
72 | char* marshalled_dataset=NULL;
|
---|
73 | int enum_value=0;
|
---|
74 |
|
---|
75 | /*recover marshalled_dataset: */
|
---|
76 | marshalled_dataset=*pmarshalled_dataset;
|
---|
77 |
|
---|
78 | /*get enum value of PentaVertexElementResult: */
|
---|
79 | enum_value=PentaVertexElementResultEnum;
|
---|
80 |
|
---|
81 | /*marshall enum: */
|
---|
82 | memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);
|
---|
83 |
|
---|
84 | /*marshall PentaVertexElementResult data: */
|
---|
85 | memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
|
---|
86 | memcpy(marshalled_dataset,&values,sizeof(values));marshalled_dataset+=sizeof(values);
|
---|
87 | memcpy(marshalled_dataset,&time,sizeof(time));marshalled_dataset+=sizeof(time);
|
---|
88 | memcpy(marshalled_dataset,&step,sizeof(step));marshalled_dataset+=sizeof(step);
|
---|
89 |
|
---|
90 | *pmarshalled_dataset=marshalled_dataset;
|
---|
91 | }
|
---|
92 | /*}}}*/
|
---|
93 | /*FUNCTION PentaVertexElementResult::MarshallSize{{{1*/
|
---|
94 | int PentaVertexElementResult::MarshallSize(){
|
---|
95 |
|
---|
96 | return sizeof(values)+
|
---|
97 | +sizeof(enum_type)
|
---|
98 | +sizeof(time)
|
---|
99 | +sizeof(step)
|
---|
100 | +sizeof(int); //sizeof(int) for enum value
|
---|
101 | }
|
---|
102 | /*}}}*/
|
---|
103 | /*FUNCTION PentaVertexElementResult::Demarshall{{{1*/
|
---|
104 | void PentaVertexElementResult::Demarshall(char** pmarshalled_dataset){
|
---|
105 |
|
---|
106 | char* marshalled_dataset=NULL;
|
---|
107 | int i;
|
---|
108 |
|
---|
109 | /*recover marshalled_dataset: */
|
---|
110 | marshalled_dataset=*pmarshalled_dataset;
|
---|
111 |
|
---|
112 | /*this time, no need to get enum type, the pointer directly points to the beginning of the
|
---|
113 | *object data (thanks to DataSet::Demarshall):*/
|
---|
114 | memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
|
---|
115 | memcpy(&values,marshalled_dataset,sizeof(values));marshalled_dataset+=sizeof(values);
|
---|
116 | memcpy(&time,marshalled_dataset,sizeof(time));marshalled_dataset+=sizeof(time);
|
---|
117 | memcpy(&step,marshalled_dataset,sizeof(step));marshalled_dataset+=sizeof(step);
|
---|
118 |
|
---|
119 | /*return: */
|
---|
120 | *pmarshalled_dataset=marshalled_dataset;
|
---|
121 | return;
|
---|
122 | }
|
---|
123 | /*}}}*/
|
---|
124 | /*FUNCTION PentaVertexElementResult::Enum{{{1*/
|
---|
125 | int PentaVertexElementResult::Enum(void){
|
---|
126 |
|
---|
127 | return PentaVertexElementResultEnum;
|
---|
128 |
|
---|
129 | }
|
---|
130 | /*}}}*/
|
---|
131 | /*FUNCTION PentaVertexElementResult::copy{{{1*/
|
---|
132 | Object* PentaVertexElementResult::copy() {
|
---|
133 |
|
---|
134 | return new PentaVertexElementResult(this->enum_type,this->values,this->step,this->time);
|
---|
135 |
|
---|
136 | }
|
---|
137 | /*}}}*/
|
---|
138 |
|
---|
139 | /*ElementResult management*/
|
---|
140 | /*FUNCTION PentaVertexElementResult::EnumType{{{1*/
|
---|
141 | int PentaVertexElementResult::EnumType(void){
|
---|
142 |
|
---|
143 | return this->enum_type;
|
---|
144 |
|
---|
145 | }
|
---|
146 | /*}}}*/
|
---|
147 | /*FUNCTION PentaVertexElementResult::SpawnSingElementResult{{{1*/
|
---|
148 | ElementResult* PentaVertexElementResult::SpawnSingElementResult(int index){
|
---|
149 |
|
---|
150 | /*output*/
|
---|
151 | SingVertexElementResult* outresult=NULL;
|
---|
152 |
|
---|
153 | /*Create new Sing result (copy of current result)*/
|
---|
154 | ISSMASSERT(index<6 && index>=0);
|
---|
155 | outresult=new SingVertexElementResult(this->enum_type,this->values[index],this->step,this->time);
|
---|
156 |
|
---|
157 | /*Assign output*/
|
---|
158 | return outresult;
|
---|
159 |
|
---|
160 | }
|
---|
161 | /*}}}*/
|
---|
162 | /*FUNCTION PentaVertexElementResult::SpawnBeamElementResult{{{1*/
|
---|
163 | ElementResult* PentaVertexElementResult::SpawnBeamElementResult(int* indices){
|
---|
164 |
|
---|
165 | /*output*/
|
---|
166 | BeamVertexElementResult* outresult=NULL;
|
---|
167 | double newvalues[2];
|
---|
168 |
|
---|
169 | /*Loop over the new indices*/
|
---|
170 | for(int i=0;i<2;i++){
|
---|
171 |
|
---|
172 | /*Check index value*/
|
---|
173 | ISSMASSERT(indices[i]>=0 && indices[i]<6);
|
---|
174 |
|
---|
175 | /*Assign value to new result*/
|
---|
176 | newvalues[i]=this->values[indices[i]];
|
---|
177 | }
|
---|
178 |
|
---|
179 | /*Create new Beam result*/
|
---|
180 | outresult=new BeamVertexElementResult(this->enum_type,&newvalues[0],this->step,this->time);
|
---|
181 |
|
---|
182 | /*Assign output*/
|
---|
183 | return outresult;
|
---|
184 |
|
---|
185 | }
|
---|
186 | /*}}}*/
|
---|
187 | /*FUNCTION PentaVertexElementResult::SpawnTriaElementResult{{{1*/
|
---|
188 | ElementResult* PentaVertexElementResult::SpawnTriaElementResult(int* indices){
|
---|
189 |
|
---|
190 | /*output*/
|
---|
191 | TriaVertexElementResult* outresult=NULL;
|
---|
192 | double newvalues[3];
|
---|
193 |
|
---|
194 | /*Loop over the new indices*/
|
---|
195 | for(int i=0;i<3;i++){
|
---|
196 |
|
---|
197 | /*Check index value*/
|
---|
198 | ISSMASSERT(indices[i]>=0 && indices[i]<6);
|
---|
199 |
|
---|
200 | /*Assign value to new result*/
|
---|
201 | newvalues[i]=this->values[indices[i]];
|
---|
202 | }
|
---|
203 |
|
---|
204 | /*Create new Tria result*/
|
---|
205 | outresult=new TriaVertexElementResult(this->enum_type,&newvalues[0],this->step,this->time);
|
---|
206 |
|
---|
207 | /*Assign output*/
|
---|
208 | return outresult;
|
---|
209 |
|
---|
210 | }
|
---|
211 | /*}}}*/
|
---|
212 | /*FUNCTION PentaVertexElementResult::ProcessUnits{{{1*/
|
---|
213 | void PentaVertexElementResult::ProcessUnits(Parameters* parameters){
|
---|
214 |
|
---|
215 | NodalValuesUnitConversion(this->values,6,this->enum_type,parameters);
|
---|
216 |
|
---|
217 | }
|
---|
218 | /*}}}*/
|
---|
219 | /*FUNCTION PentaVertexElementResult::NumberOfNodalValues{{{1*/
|
---|
220 | int PentaVertexElementResult::NumberOfNodalValues(void){
|
---|
221 | return 6;
|
---|
222 | }
|
---|
223 | /*}}}*/
|
---|
224 | /*FUNCTION PentaVertexElementResult::PatchFill{{{1*/
|
---|
225 | void PentaVertexElementResult::PatchFill(int row, Patch* patch){
|
---|
226 |
|
---|
227 | /*Here, we fill the result information into the patch object. First, let's remember what is in a row
|
---|
228 | * of the patch object: enum_type step time element_id interpolation vertices_ids nodal_values
|
---|
229 | * Here, we will supply the enum_type, step, time, interpolation and nodal_values: */
|
---|
230 | patch->fillresultinfo(row,this->enum_type,this->step,this->time,P1Enum,this->values,6);
|
---|
231 |
|
---|
232 | }
|
---|
233 | /*}}}*/
|
---|