[1] | 1 | /*!\file ProcessParamsx
|
---|
| 2 | * \brief: process parameters using partitioning vector
|
---|
| 3 | */
|
---|
| 4 |
|
---|
| 5 | #include "./ProcessParamsx.h"
|
---|
| 6 |
|
---|
| 7 | #undef __FUNCT__
|
---|
| 8 | #define __FUNCT__ "ProcessParamsx"
|
---|
| 9 |
|
---|
| 10 | #include "../shared/shared.h"
|
---|
| 11 | #include "../include/macros.h"
|
---|
| 12 | #include "../toolkits/toolkits.h"
|
---|
| 13 | #include "../EnumDefinitions/EnumDefinitions.h"
|
---|
| 14 |
|
---|
| 15 | void ProcessParamsx( DataSet* parameters, Vec part){
|
---|
| 16 |
|
---|
| 17 | int i;
|
---|
| 18 |
|
---|
| 19 | double* partition=NULL;
|
---|
| 20 | Param* param=NULL;
|
---|
[202] | 21 |
|
---|
| 22 | /*diagnostic: */
|
---|
| 23 | double* vx=NULL;
|
---|
| 24 | double* vy=NULL;
|
---|
| 25 | double* vz=NULL;
|
---|
[586] | 26 |
|
---|
[202] | 27 | double* u_g=NULL;
|
---|
| 28 |
|
---|
| 29 | /*control: */
|
---|
| 30 | Vec vec_vx_obs=NULL;
|
---|
| 31 | Vec vec_vy_obs=NULL;
|
---|
| 32 | Vec vec_control_parameter=NULL;
|
---|
| 33 |
|
---|
[1] | 34 | double* vx_obs=NULL;
|
---|
| 35 | double* vy_obs=NULL;
|
---|
| 36 | double* control_parameter=NULL;
|
---|
[202] | 37 |
|
---|
| 38 | double* u_g_obs=NULL;
|
---|
| 39 |
|
---|
[596] | 40 | /*thermal*/
|
---|
| 41 | double* pressure=NULL;
|
---|
| 42 | double* temperature=NULL;
|
---|
| 43 | double* melting=NULL;
|
---|
| 44 |
|
---|
| 45 | double* p_g=NULL;
|
---|
| 46 | double* t_g=NULL;
|
---|
| 47 | double* m_g=NULL;
|
---|
| 48 |
|
---|
[586] | 49 | /*prognostic: */
|
---|
| 50 | double* a_g=NULL;
|
---|
| 51 | double* h_g=NULL;
|
---|
| 52 | double* accumulation=NULL;
|
---|
| 53 | double* thickness=NULL;
|
---|
| 54 |
|
---|
[202] | 55 | /*diverse: */
|
---|
[1] | 56 | int numberofnodes;
|
---|
| 57 | int analysis_type;
|
---|
| 58 | int count;
|
---|
| 59 |
|
---|
| 60 | parameters->FindParam((void*)&analysis_type,"analysis_type");
|
---|
| 61 | count=parameters->Size();
|
---|
[202] | 62 |
|
---|
| 63 | parameters->FindParam((void*)&numberofnodes,"numberofnodes");
|
---|
[1] | 64 |
|
---|
[202] | 65 | /*First serialize partition vector: */
|
---|
[304] | 66 | if(part)VecToMPISerial(&partition,part);
|
---|
[202] | 67 |
|
---|
[586] | 68 | if ( (analysis_type==ControlAnalysisEnum()) ||
|
---|
| 69 | (analysis_type==DiagnosticAnalysisEnum()) ||
|
---|
| 70 | (analysis_type==ThermalAnalysisEnum()) ||
|
---|
| 71 | (analysis_type==PrognosticAnalysisEnum())
|
---|
| 72 | ){
|
---|
[202] | 73 |
|
---|
[209] | 74 | parameters->FindParam((void*)&vx,"vx");
|
---|
| 75 | parameters->FindParam((void*)&vy,"vy");
|
---|
| 76 | parameters->FindParam((void*)&vz,"vz");
|
---|
[202] | 77 |
|
---|
[304] | 78 | if(numberofnodes){
|
---|
| 79 | u_g=(double*)xcalloc(numberofnodes*3,sizeof(double));
|
---|
[202] | 80 |
|
---|
[304] | 81 | if(vx){
|
---|
| 82 | for(i=0;i<numberofnodes;i++){
|
---|
| 83 | u_g[(int)(3*partition[i]+0)]=vx[i];
|
---|
| 84 | }
|
---|
[202] | 85 | }
|
---|
| 86 |
|
---|
[304] | 87 | if(vy){
|
---|
| 88 | for(i=0;i<numberofnodes;i++){
|
---|
| 89 | u_g[(int)(3*partition[i]+1)]=vy[i];
|
---|
| 90 | }
|
---|
[202] | 91 | }
|
---|
[304] | 92 | if(vz){
|
---|
| 93 | for(i=0;i<numberofnodes;i++){
|
---|
| 94 | u_g[(int)(3*partition[i]+2)]=vz[i];
|
---|
| 95 | }
|
---|
[202] | 96 | }
|
---|
| 97 |
|
---|
| 98 |
|
---|
[304] | 99 | /*Now, create new parameters: */
|
---|
| 100 | count++;
|
---|
| 101 | param= new Param(count,"u_g",DOUBLEVEC);
|
---|
| 102 | param->SetDoubleVec(u_g,3*numberofnodes);
|
---|
| 103 | parameters->AddObject(param);
|
---|
[202] | 104 |
|
---|
[304] | 105 | /*erase old parameters: */
|
---|
| 106 | param=(Param*)parameters->FindParamObject("vx");
|
---|
| 107 | parameters->DeleteObject((Object*)param);
|
---|
[202] | 108 |
|
---|
[304] | 109 | param=(Param*)parameters->FindParamObject("vy");
|
---|
| 110 | parameters->DeleteObject((Object*)param);
|
---|
[202] | 111 |
|
---|
[304] | 112 | param=(Param*)parameters->FindParamObject("vz");
|
---|
| 113 | parameters->DeleteObject((Object*)param);
|
---|
| 114 | }
|
---|
[202] | 115 |
|
---|
| 116 | }
|
---|
| 117 |
|
---|
| 118 |
|
---|
[1] | 119 | if(analysis_type==ControlAnalysisEnum()){
|
---|
| 120 |
|
---|
[209] | 121 | parameters->FindParam((void*)&vx_obs,"vx_obs");
|
---|
| 122 | parameters->FindParam((void*)&vy_obs,"vy_obs");
|
---|
| 123 | parameters->FindParam((void*)&control_parameter,"control_parameter");
|
---|
[1] | 124 |
|
---|
| 125 | /*Now, from vx_obs and vy_obs, build u_g_obs, correctly partitioned: */
|
---|
[202] | 126 |
|
---|
[1] | 127 | u_g_obs=(double*)xcalloc(numberofnodes*2,sizeof(double));
|
---|
| 128 | p_g=(double*)xcalloc(numberofnodes*2,sizeof(double));
|
---|
| 129 |
|
---|
| 130 | for(i=0;i<numberofnodes;i++){
|
---|
[202] | 131 | u_g_obs[(int)(2*partition[i]+0)]=vx_obs[i];
|
---|
| 132 | u_g_obs[(int)(2*partition[i]+1)]=vy_obs[i];
|
---|
| 133 | p_g[(int)(2*partition[i]+0)]=control_parameter[i];
|
---|
[1] | 134 | }
|
---|
| 135 |
|
---|
| 136 | /*Now, create new parameters: */
|
---|
| 137 | count++;
|
---|
| 138 | param= new Param(count,"u_g_obs",DOUBLEVEC);
|
---|
| 139 | param->SetDoubleVec(u_g_obs,2*numberofnodes);
|
---|
| 140 | parameters->AddObject(param);
|
---|
| 141 |
|
---|
| 142 | count++;
|
---|
| 143 | param= new Param(count,"p_g",DOUBLEVEC);
|
---|
[219] | 144 | param->SetDoubleVec(p_g,2*numberofnodes);
|
---|
[1] | 145 | parameters->AddObject(param);
|
---|
[202] | 146 |
|
---|
| 147 | /*erase old parameter: */
|
---|
| 148 | param=(Param*)parameters->FindParamObject("vx_obs");
|
---|
| 149 | parameters->DeleteObject((Object*)param);
|
---|
| 150 |
|
---|
| 151 | param=(Param*)parameters->FindParamObject("vy_obs");
|
---|
| 152 | parameters->DeleteObject((Object*)param);
|
---|
| 153 |
|
---|
| 154 | param=(Param*)parameters->FindParamObject("control_parameter");
|
---|
| 155 | parameters->DeleteObject((Object*)param);
|
---|
| 156 |
|
---|
[1] | 157 | }
|
---|
| 158 |
|
---|
[503] | 159 | if(analysis_type==ThermalAnalysisEnum()){
|
---|
| 160 |
|
---|
[596] | 161 | parameters->FindParam((void*)&temperature,"temperature");
|
---|
| 162 | parameters->FindParam((void*)&melting,"melting");
|
---|
[503] | 163 | parameters->FindParam((void*)&pressure,"pressure");
|
---|
[596] | 164 |
|
---|
| 165 | /*Now, from temperature and melting, build t_g and m_g, correctly partitioned: */
|
---|
| 166 | t_g=(double*)xcalloc(numberofnodes,sizeof(double));
|
---|
| 167 | m_g=(double*)xcalloc(numberofnodes,sizeof(double));
|
---|
[503] | 168 | p_g=(double*)xcalloc(numberofnodes,sizeof(double));
|
---|
| 169 |
|
---|
[596] | 170 | for(i=0;i<numberofnodes;i++){
|
---|
| 171 | t_g[(int)(partition[i])]=temperature[i];
|
---|
| 172 | m_g[(int)(partition[i])]=melting[i];
|
---|
[503] | 173 | p_g[(int)(partition[i])]= pressure[i];
|
---|
[596] | 174 | }
|
---|
[503] | 175 |
|
---|
[596] | 176 | /*Now, create new parameter: */
|
---|
| 177 | count++;
|
---|
| 178 | param= new Param(count,"t_g",DOUBLEVEC);
|
---|
| 179 | param->SetDoubleVec(t_g,numberofnodes);
|
---|
| 180 | parameters->AddObject(param);
|
---|
| 181 |
|
---|
| 182 | count++;
|
---|
| 183 | param= new Param(count,"m_g",DOUBLEVEC);
|
---|
| 184 | param->SetDoubleVec(m_g,numberofnodes);
|
---|
| 185 | parameters->AddObject(param);
|
---|
| 186 |
|
---|
[503] | 187 | count++;
|
---|
| 188 | param= new Param(count,"p_g",DOUBLEVEC);
|
---|
| 189 | param->SetDoubleVec(p_g,numberofnodes);
|
---|
| 190 | parameters->AddObject(param);
|
---|
| 191 |
|
---|
[596] | 192 | /*erase old parameter: */
|
---|
| 193 | param=(Param*)parameters->FindParamObject("temperature");
|
---|
| 194 | parameters->DeleteObject((Object*)param);
|
---|
| 195 |
|
---|
| 196 | param=(Param*)parameters->FindParamObject("melting");
|
---|
| 197 | parameters->DeleteObject((Object*)param);
|
---|
| 198 |
|
---|
[503] | 199 | param=(Param*)parameters->FindParamObject("pressure");
|
---|
| 200 | parameters->DeleteObject((Object*)param);
|
---|
[586] | 201 | }
|
---|
[548] | 202 |
|
---|
[586] | 203 | if(analysis_type==PrognosticAnalysisEnum()){
|
---|
[548] | 204 |
|
---|
[586] | 205 | parameters->FindParam((void*)&melting,"melting");
|
---|
[596] | 206 | parameters->FindParam((void*)&thickness,"thickness");
|
---|
| 207 | parameters->FindParam((void*)&accumulation,"accumulation");
|
---|
[586] | 208 |
|
---|
[596] | 209 | /*Now, from melting accumulation and thickness, build m_g, h_g, correctly partitioned: */
|
---|
[586] | 210 | m_g=(double*)xcalloc(numberofnodes,sizeof(double));
|
---|
[596] | 211 | h_g=(double*)xcalloc(numberofnodes,sizeof(double));
|
---|
| 212 | a_g=(double*)xcalloc(numberofnodes,sizeof(double));
|
---|
[548] | 213 |
|
---|
[586] | 214 | for(i=0;i<numberofnodes;i++){
|
---|
| 215 | m_g[(int)(partition[i])]= melting[i];
|
---|
[596] | 216 | h_g[(int)(partition[i])]= thickness[i];
|
---|
| 217 | a_g[(int)(partition[i])]= accumulation[i];
|
---|
[586] | 218 | }
|
---|
[548] | 219 |
|
---|
[586] | 220 | /*Now, create new parameter: */
|
---|
| 221 | count++;
|
---|
| 222 | param= new Param(count,"m_g",DOUBLEVEC);
|
---|
| 223 | param->SetDoubleVec(m_g,numberofnodes);
|
---|
| 224 | parameters->AddObject(param);
|
---|
[548] | 225 |
|
---|
[586] | 226 | count++;
|
---|
| 227 | param= new Param(count,"h_g",DOUBLEVEC);
|
---|
| 228 | param->SetDoubleVec(h_g,numberofnodes);
|
---|
| 229 | parameters->AddObject(param);
|
---|
| 230 |
|
---|
| 231 | count++;
|
---|
| 232 | param= new Param(count,"a_g",DOUBLEVEC);
|
---|
| 233 | param->SetDoubleVec(a_g,numberofnodes);
|
---|
| 234 | parameters->AddObject(param);
|
---|
| 235 |
|
---|
| 236 | /*erase old parameter: */
|
---|
[596] | 237 | param=(Param*)parameters->FindParamObject("melting");
|
---|
[586] | 238 | parameters->DeleteObject((Object*)param);
|
---|
| 239 |
|
---|
[596] | 240 | param=(Param*)parameters->FindParamObject("thickness");
|
---|
| 241 | parameters->DeleteObject((Object*)param);
|
---|
[586] | 242 |
|
---|
[596] | 243 | param=(Param*)parameters->FindParamObject("accumulation");
|
---|
| 244 | parameters->DeleteObject((Object*)param);
|
---|
[503] | 245 | }
|
---|
[1] | 246 | xfree((void**)&partition);
|
---|
[202] | 247 |
|
---|
| 248 | xfree((void**)&vx);
|
---|
| 249 | xfree((void**)&vy);
|
---|
| 250 | xfree((void**)&vz);
|
---|
| 251 | xfree((void**)&u_g);
|
---|
| 252 |
|
---|
[1] | 253 | xfree((void**)&vx_obs);
|
---|
| 254 | xfree((void**)&vy_obs);
|
---|
[503] | 255 | xfree((void**)&pressure);
|
---|
[1] | 256 | xfree((void**)&control_parameter);
|
---|
| 257 | xfree((void**)&u_g_obs);
|
---|
| 258 | xfree((void**)&p_g);
|
---|
[586] | 259 | xfree((void**)&a_g);
|
---|
| 260 | xfree((void**)&h_g);
|
---|
[552] | 261 | xfree((void**)&m_g);
|
---|
[202] | 262 |
|
---|
[1] | 263 | }
|
---|