source: issm/trunk/src/c/objects/Results/DoubleResult.cpp@ 4037

Last change on this file since 4037 was 4037, checked in by Eric.Larour, 15 years ago

New results framework. Now, elements have results datasets,
which they fill up as they wish with results found in the inputs.
Then, the results dataset will be processed in OutputResults, to output
something to disk. We ended up putting the results inside the elements,
because they depend on the interpolation, this avoids partitioning of vectors,
and inputs cannot hold different time steps for the same enum!

File size: 4.7 KB
Line 
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*/
22DoubleResult::DoubleResult(){
23 return;
24}
25/*}}}*/
26/*FUNCTION DoubleResult::DoubleResult(int in_enum_type,IssmDouble in_value,int in_step, double in_time){{{1*/
27DoubleResult::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*/
34DoubleResult::~DoubleResult(){
35 return;
36}
37/*}}}*/
38
39/*Object management*/
40/*FUNCTION DoubleResult::copy{{{1*/
41Object* DoubleResult::copy() {
42
43 return new DoubleResult(this->enum_type,this->value,this->step,this->time);
44
45}
46/*}}}*/
47/*FUNCTION DoubleResult::DeepEcho{{{1*/
48void DoubleResult::DeepEcho(void){
49
50 printf("DoubleResult:\n");
51 DoubleInput::DeepEcho();
52 printf(" step: %i\n",this->step);
53 printf(" time: %g\n",this->time);
54}
55/*}}}*/
56/*FUNCTION DoubleResult::Demarshall{{{1*/
57void DoubleResult::Demarshall(char** pmarshalled_dataset){
58
59 char* marshalled_dataset=NULL;
60 int i;
61
62 /*recover marshalled_dataset: */
63 marshalled_dataset=*pmarshalled_dataset;
64
65 /*this time, no need to get enum type, the pointer directly points to the beginning of the
66 *object data (thanks to DataSet::Demarshall):*/
67 memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
68 memcpy(&value,marshalled_dataset,sizeof(value));marshalled_dataset+=sizeof(value);
69 memcpy(&step,marshalled_dataset,sizeof(step));marshalled_dataset+=sizeof(step);
70 memcpy(&time,marshalled_dataset,sizeof(time));marshalled_dataset+=sizeof(time);
71
72 /*return: */
73 *pmarshalled_dataset=marshalled_dataset;
74 return;
75}
76/*}}}*/
77/*FUNCTION DoubleResult::Echo {{{1*/
78void DoubleResult::Echo(void){
79 this->DeepEcho();
80}
81/*}}}*/
82/*FUNCTION DoubleResult::Enum{{{1*/
83int DoubleResult::Enum(void){
84
85 return DoubleResultEnum;
86
87}
88/*}}}*/
89/*FUNCTION DoubleResult::EnumType{{{1*/
90int DoubleResult::EnumType(void){
91
92 return this->enum_type;
93
94}
95/*}}}*/
96/*FUNCTION DoubleResult::Id{{{1*/
97int DoubleResult::Id(void){ return -1; }
98/*}}}*/
99/*FUNCTION DoubleResult::Marshall{{{1*/
100void DoubleResult::Marshall(char** pmarshalled_dataset){
101
102 char* marshalled_dataset=NULL;
103 int enum_value=0;
104
105 /*recover marshalled_dataset: */
106 marshalled_dataset=*pmarshalled_dataset;
107
108 /*get enum value of DoubleResult: */
109 enum_value=DoubleResultEnum;
110
111 /*marshall enum: */
112 memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);
113
114 /*marshall DoubleResult data: */
115 memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
116 memcpy(marshalled_dataset,&value,sizeof(value));marshalled_dataset+=sizeof(value);
117 memcpy(marshalled_dataset,&time,sizeof(time));marshalled_dataset+=sizeof(time);
118 memcpy(marshalled_dataset,&step,sizeof(step));marshalled_dataset+=sizeof(step);
119
120 *pmarshalled_dataset=marshalled_dataset;
121}
122/*}}}*/
123/*FUNCTION DoubleResult::MarshallSize{{{1*/
124int DoubleResult::MarshallSize(){
125
126 return sizeof(value)+
127 +sizeof(enum_type)
128 +sizeof(time)
129 +sizeof(step)
130 +sizeof(int); //sizeof(int) for enum value
131}
132/*}}}*/
133/*FUNCTION DoubleResult::MyRank{{{1*/
134int DoubleResult::MyRank(void){
135 extern int my_rank;
136 return my_rank;
137}
138/*}}}*/
139
140/*Result functions*/
141/*FUNCTION DoubleResult::SpawnSingResult{{{1*/
142Result* DoubleResult::SpawnSingResult(int index){
143
144 /*output*/
145 DoubleResult* outresult=new DoubleResult();
146
147 /*copy fields: */
148 outresult->enum_type=this->enum_type;
149 outresult->value=this->value;
150 outresult->time=this->time;
151 outresult->step=this->step;
152
153 /*Assign output*/
154 return outresult;
155
156}
157/*}}}*/
158/*FUNCTION DoubleResult::SpawnBeamResult{{{1*/
159Result* DoubleResult::SpawnBeamResult(int* indices){
160
161 /*output*/
162 DoubleResult* outresult=new DoubleResult();
163
164 /*copy fields: */
165 outresult->enum_type=this->enum_type;
166 outresult->value=this->value;
167 outresult->time=this->time;
168 outresult->step=this->step;
169
170
171 /*Assign output*/
172 return outresult;
173
174}
175/*}}}*/
176/*FUNCTION DoubleResult::SpawnTriaResult{{{1*/
177Result* DoubleResult::SpawnTriaResult(int* indices){
178
179 /*output*/
180 DoubleResult* outresult=new DoubleResult();
181
182 /*copy fields: */
183 outresult->enum_type=this->enum_type;
184 outresult->value=this->value;
185 outresult->time=this->time;
186 outresult->step=this->step;
187
188 /*Assign output*/
189 return outresult;
190
191}
192/*}}}*/
193
Note: See TracBrowser for help on using the repository browser.