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

Last change on this file since 23066 was 23066, checked in by Mathieu Morlighem, 7 years ago

CHG: removing double white lines

File size: 4.3 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/*}}}*/
69int Regionaloutput::ObjectEnum(void){/*{{{*/
70 return RegionaloutputEnum;
71}
72/*}}}*/
73
74/*Definition virtual function resolutoin: */
75int Regionaloutput::DefinitionEnum(){/*{{{*/
76
77 return this->definitionenum;
78}
79/*}}}*/
80char* Regionaloutput::Name(){/*{{{*/
81
82 char* name2=xNew<char>(strlen(this->name)+1);
83 xMemCpy(name2,this->name,strlen(this->name)+1);
84
85 return name2;
86}
87/*}}}*/
88IssmDouble Regionaloutput::Response(FemModel* femmodel){/*{{{*/
89
90 int i;
91 IssmDouble val_t=0.;
92 IssmDouble all_val_t=0.;
93 int outputenum = StringToEnumx(this->outputname);
94
95 for(i=0;i<femmodel->elements->Size();i++){
96 Element* element=(Element*)femmodel->elements->GetObjectByOffset(i);
97 switch(outputenum){
98 case GroundedAreaEnum:
99 val_t+=element->GroundedArea(this->mask,false);
100 break;
101 case GroundedAreaScaledEnum:
102 val_t+=element->GroundedArea(this->mask,true);
103 break;
104 case FloatingAreaEnum:
105 val_t+=element->FloatingArea(this->mask,false);
106 break;
107 case FloatingAreaScaledEnum:
108 val_t+=element->FloatingArea(this->mask,true);
109 break;
110 case IceMassEnum:
111 val_t+=element->IceMass(this->mask,false);
112 break;
113 case IceMassScaledEnum:
114 val_t+=element->IceMass(this->mask,true);
115 break;
116 case IceVolumeEnum:
117 val_t+=element->IceVolume(this->mask,false);
118 break;
119 case IceVolumeScaledEnum:
120 val_t+=element->IceVolume(this->mask,true);
121 break;
122 case IceVolumeAboveFloatationEnum:
123 val_t+=element->IceVolumeAboveFloatation(this->mask,false);
124 break;
125 case IceVolumeAboveFloatationScaledEnum:
126 val_t+=element->IceVolumeAboveFloatation(this->mask,true);
127 break;
128 case TotalFloatingBmbEnum:
129 val_t+=element->TotalFloatingBmb(this->mask,false);
130 break;
131 case TotalFloatingBmbScaledEnum:
132 val_t+=element->TotalFloatingBmb(this->mask,true);
133 break;
134 case TotalGroundedBmbEnum:
135 val_t+=element->TotalGroundedBmb(this->mask,false);
136 break;
137 case TotalGroundedBmbScaledEnum:
138 val_t+=element->TotalGroundedBmb(this->mask,true);
139 break;
140 case TotalSmbEnum:
141 val_t+=element->TotalSmb(this->mask,false);
142 break;
143 case TotalSmbScaledEnum:
144 val_t+=element->TotalSmb(this->mask,true);
145 break;
146 default:
147 _error_("Regional output type " << this->outputname << " not supported yet!");
148 }
149 }
150
151 ISSM_MPI_Allreduce ( (void*)&val_t,(void*)&all_val_t,1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,IssmComm::GetComm());
152 val_t=all_val_t;
153
154 return val_t;
155}
156/*}}}*/
Note: See TracBrowser for help on using the repository browser.