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