source: issm/trunk/src/c/classes/Regionaloutput.cpp@ 26744

Last change on this file since 26744 was 25836, checked in by Mathieu Morlighem, 4 years ago

merged trunk-jpl and trunk for revision 25834

File size: 4.2 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(MarshallHandle* marshallhandle){/*{{{*/
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 IssmDouble val_t=0.;
91 IssmDouble all_val_t=0.;
92 int outputenum = StringToEnumx(this->outputname);
93
94 for(Object* & object : femmodel->elements->objects){
95 Element* element=xDynamicCast<Element*>(object);
96 switch(outputenum){
97 case GroundedAreaEnum:
98 val_t+=element->GroundedArea(this->mask,false);
99 break;
100 case GroundedAreaScaledEnum:
101 val_t+=element->GroundedArea(this->mask,true);
102 break;
103 case FloatingAreaEnum:
104 val_t+=element->FloatingArea(this->mask,false);
105 break;
106 case FloatingAreaScaledEnum:
107 val_t+=element->FloatingArea(this->mask,true);
108 break;
109 case IceMassEnum:
110 val_t+=element->IceMass(this->mask,false);
111 break;
112 case IceMassScaledEnum:
113 val_t+=element->IceMass(this->mask,true);
114 break;
115 case IceVolumeEnum:
116 val_t+=element->IceVolume(this->mask,false);
117 break;
118 case IceVolumeScaledEnum:
119 val_t+=element->IceVolume(this->mask,true);
120 break;
121 case IceVolumeAboveFloatationEnum:
122 val_t+=element->IceVolumeAboveFloatation(this->mask,false);
123 break;
124 case IceVolumeAboveFloatationScaledEnum:
125 val_t+=element->IceVolumeAboveFloatation(this->mask,true);
126 break;
127 case TotalFloatingBmbEnum:
128 val_t+=element->TotalFloatingBmb(this->mask,false);
129 break;
130 case TotalFloatingBmbScaledEnum:
131 val_t+=element->TotalFloatingBmb(this->mask,true);
132 break;
133 case TotalGroundedBmbEnum:
134 val_t+=element->TotalGroundedBmb(this->mask,false);
135 break;
136 case TotalGroundedBmbScaledEnum:
137 val_t+=element->TotalGroundedBmb(this->mask,true);
138 break;
139 case TotalSmbEnum:
140 val_t+=element->TotalSmb(this->mask,false);
141 break;
142 case TotalSmbScaledEnum:
143 val_t+=element->TotalSmb(this->mask,true);
144 break;
145 default:
146 _error_("Regional output type " << this->outputname << " not supported yet!");
147 }
148 }
149
150 ISSM_MPI_Allreduce ( (void*)&val_t,(void*)&all_val_t,1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,IssmComm::GetComm());
151 val_t=all_val_t;
152
153 return val_t;
154}
155/*}}}*/
Note: See TracBrowser for help on using the repository browser.