source: issm/trunk-jpl/src/c/classes/Regionaloutput.cpp@ 25506

Last change on this file since 25506 was 25506, checked in by Mathieu Morlighem, 5 years ago

NEW: new way of Marshalling femmodel

File size: 4.4 KB
Line 
1/*!\file Regionaloutput.cpp
2 * \brief: implementation for the Regionaloutput object
3 */
4
5/*Include files: {{{*/
6#ifdef HAVE_CONFIG_H
7 #include <config.h>
8#else
9#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
10#endif
11
12/*Headers:*/
13#include "./classes.h"
14#include "./Definition.h"
15#include "./Elements/Element.h"
16#include "./Elements/Elements.h"
17#include "./FemModel.h"
18#include "../classes/Params/Parameters.h"
19
20/*}}}*/
21
22Regionaloutput::Regionaloutput(char* in_name, int in_definitionenum, char* in_outputname, IssmDouble* maskin, int Min){ /*{{{*/
23
24 this->definitionenum=in_definitionenum;
25 this->outputname = xNew<char>(strlen(in_outputname)+1);
26 xMemCpy<char>(this->outputname,in_outputname,strlen(in_outputname)+1);
27 this->name = xNew<char>(strlen(in_name)+1);
28 xMemCpy<char>(this->name,in_name,strlen(in_name)+1);
29
30 this->mask = xNew<IssmDouble>(Min);
31 xMemCpy<IssmDouble>(this->mask, maskin, Min);
32
33 this->M=Min;
34
35}
36/*}}}*/
37Regionaloutput::~Regionaloutput(){/*{{{*/
38 if(this->name)xDelete(this->name);
39 if(this->outputname)xDelete(this->outputname);
40 if(this->mask)xDelete(this->mask);
41}
42/*}}}*/
43
44/*Object virtual function resolutoin: */
45Object* Regionaloutput::copy() {/*{{{*/
46 Regionaloutput* mf = new Regionaloutput(this->name,this->definitionenum,this->outputname,this->mask,this->M);
47 return (Object*) mf;
48}
49/*}}}*/
50void Regionaloutput::DeepEcho(void){/*{{{*/
51 this->Echo();
52}
53/*}}}*/
54void Regionaloutput::Echo(void){/*{{{*/
55 _printf_(" Regionaloutput: " << this->name << " " << this->definitionenum << "\n");
56 _printf_(" outputname enum: " << this->outputname << "Enum\n");
57 _printf_(" mask: " << this->mask << "\n");
58 _printf_(" M: " << this->M << "\n");
59}
60/*}}}*/
61int Regionaloutput::Id(void){/*{{{*/
62 return -1;
63}
64/*}}}*/
65void Regionaloutput::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){/*{{{*/
66 _error_("not implemented yet!");
67}
68/*}}}*/
69void Regionaloutput::Marshall2(MarshallHandle* marshallhandle){/*{{{*/
70 _error_("not implemented yet!");
71}
72/*}}}*/
73int Regionaloutput::ObjectEnum(void){/*{{{*/
74 return RegionaloutputEnum;
75}
76/*}}}*/
77
78/*Definition virtual function resolutoin: */
79int Regionaloutput::DefinitionEnum(){/*{{{*/
80
81 return this->definitionenum;
82}
83/*}}}*/
84char* Regionaloutput::Name(){/*{{{*/
85
86 char* name2=xNew<char>(strlen(this->name)+1);
87 xMemCpy(name2,this->name,strlen(this->name)+1);
88
89 return name2;
90}
91/*}}}*/
92IssmDouble Regionaloutput::Response(FemModel* femmodel){/*{{{*/
93
94 int i;
95 IssmDouble val_t=0.;
96 IssmDouble all_val_t=0.;
97 int outputenum = StringToEnumx(this->outputname);
98
99 for(i=0;i<femmodel->elements->Size();i++){
100 Element* element=(Element*)femmodel->elements->GetObjectByOffset(i);
101 switch(outputenum){
102 case GroundedAreaEnum:
103 val_t+=element->GroundedArea(this->mask,false);
104 break;
105 case GroundedAreaScaledEnum:
106 val_t+=element->GroundedArea(this->mask,true);
107 break;
108 case FloatingAreaEnum:
109 val_t+=element->FloatingArea(this->mask,false);
110 break;
111 case FloatingAreaScaledEnum:
112 val_t+=element->FloatingArea(this->mask,true);
113 break;
114 case IceMassEnum:
115 val_t+=element->IceMass(this->mask,false);
116 break;
117 case IceMassScaledEnum:
118 val_t+=element->IceMass(this->mask,true);
119 break;
120 case IceVolumeEnum:
121 val_t+=element->IceVolume(this->mask,false);
122 break;
123 case IceVolumeScaledEnum:
124 val_t+=element->IceVolume(this->mask,true);
125 break;
126 case IceVolumeAboveFloatationEnum:
127 val_t+=element->IceVolumeAboveFloatation(this->mask,false);
128 break;
129 case IceVolumeAboveFloatationScaledEnum:
130 val_t+=element->IceVolumeAboveFloatation(this->mask,true);
131 break;
132 case TotalFloatingBmbEnum:
133 val_t+=element->TotalFloatingBmb(this->mask,false);
134 break;
135 case TotalFloatingBmbScaledEnum:
136 val_t+=element->TotalFloatingBmb(this->mask,true);
137 break;
138 case TotalGroundedBmbEnum:
139 val_t+=element->TotalGroundedBmb(this->mask,false);
140 break;
141 case TotalGroundedBmbScaledEnum:
142 val_t+=element->TotalGroundedBmb(this->mask,true);
143 break;
144 case TotalSmbEnum:
145 val_t+=element->TotalSmb(this->mask,false);
146 break;
147 case TotalSmbScaledEnum:
148 val_t+=element->TotalSmb(this->mask,true);
149 break;
150 default:
151 _error_("Regional output type " << this->outputname << " not supported yet!");
152 }
153 }
154
155 ISSM_MPI_Allreduce ( (void*)&val_t,(void*)&all_val_t,1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,IssmComm::GetComm());
156 val_t=all_val_t;
157
158 return val_t;
159}
160/*}}}*/
Note: See TracBrowser for help on using the repository browser.