[24335] | 1 | /*\file Inputs.cpp
|
---|
| 2 | * \brief: Implementation of the Inputs class, derived from DataSet class.
|
---|
| 3 | */
|
---|
| 4 |
|
---|
| 5 | /*Headers: {{{*/
|
---|
| 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 |
|
---|
[25379] | 12 | #include "./Input.h"
|
---|
| 13 | #include "./Inputs.h"
|
---|
[24335] | 14 |
|
---|
[25379] | 15 | #include "./BoolInput.h"
|
---|
| 16 | #include "./IntInput.h"
|
---|
| 17 | #include "./DoubleInput.h"
|
---|
| 18 | #include "./ElementInput.h"
|
---|
| 19 | #include "./SegInput.h"
|
---|
| 20 | #include "./TriaInput.h"
|
---|
| 21 | #include "./PentaInput.h"
|
---|
| 22 | #include "./TransientInput.h"
|
---|
| 23 | #include "./ControlInput.h"
|
---|
| 24 | #include "./DatasetInput.h"
|
---|
| 25 | #include "./ArrayInput.h"
|
---|
[27128] | 26 | #include "./IntArrayInput.h"
|
---|
[24335] | 27 | using namespace std;
|
---|
| 28 | /*}}}*/
|
---|
| 29 |
|
---|
| 30 | /*Object constructors and destructor*/
|
---|
[25379] | 31 | Inputs::Inputs(void){/*{{{*/
|
---|
[24335] | 32 |
|
---|
| 33 | this->numberofelements_local = 0;
|
---|
| 34 | this->numberofvertices_local = 0;
|
---|
| 35 |
|
---|
| 36 | /*Initialize pointers*/
|
---|
| 37 | for(int i=0;i<NUMINPUTS;i++) this->inputs[i] = NULL;
|
---|
| 38 | }
|
---|
| 39 | /*}}}*/
|
---|
[25379] | 40 | Inputs::Inputs(int nbe,int nbv){/*{{{*/
|
---|
[24335] | 41 |
|
---|
| 42 | this->numberofelements_local = nbe;
|
---|
| 43 | this->numberofvertices_local = nbv;
|
---|
| 44 |
|
---|
| 45 | /*Initialize pointers*/
|
---|
| 46 | for(int i=0;i<NUMINPUTS;i++) this->inputs[i] = NULL;
|
---|
| 47 | }
|
---|
| 48 | /*}}}*/
|
---|
[25379] | 49 | Inputs::~Inputs(){/*{{{*/
|
---|
[24335] | 50 | for(int i=0;i<NUMINPUTS;i++){
|
---|
| 51 | if(this->inputs[i]) delete this->inputs[i];
|
---|
| 52 | }
|
---|
| 53 | return;
|
---|
| 54 | }
|
---|
| 55 | /*}}}*/
|
---|
| 56 |
|
---|
[25379] | 57 | Inputs* Inputs::Copy(void){/*{{{*/
|
---|
[24335] | 58 |
|
---|
[25379] | 59 | Inputs* output = new Inputs(this->numberofelements_local,this->numberofvertices_local);
|
---|
[24335] | 60 |
|
---|
| 61 | for(int i=0;i<NUMINPUTS;i++){
|
---|
| 62 | if(this->inputs[i]) output->inputs[i]=this->inputs[i]->copy();
|
---|
| 63 | }
|
---|
| 64 |
|
---|
| 65 | return output;
|
---|
| 66 | }/*}}}*/
|
---|
[25379] | 67 | void Inputs::DeepEcho(void){/*{{{*/
|
---|
[24335] | 68 | for(int i=0;i<NUMINPUTS;i++) {
|
---|
| 69 | if(this->inputs[i]) this->inputs[i]->DeepEcho();
|
---|
| 70 | }
|
---|
| 71 | return;
|
---|
| 72 | }
|
---|
| 73 | /*}}}*/
|
---|
[25379] | 74 | void Inputs::Echo(void){/*{{{*/
|
---|
[24335] | 75 | _printf_("Inputs Echo:\n");
|
---|
| 76 | for(int i=0;i<NUMINPUTS;i++) {
|
---|
| 77 | if(this->inputs[i]) _printf_(setw(25)<<EnumToStringx(i+InputsSTARTEnum+1)<<": set as "<<EnumToStringx(this->inputs[i]->ObjectEnum())<<"\n");
|
---|
| 78 | }
|
---|
| 79 | return;
|
---|
| 80 | }
|
---|
| 81 | /*}}}*/
|
---|
[26071] | 82 | void Inputs::DeepEcho(int enum_in){/*{{{*/
|
---|
| 83 | int index= EnumToIndex(enum_in);
|
---|
| 84 | if(this->inputs[index])this->inputs[index]->DeepEcho();
|
---|
| 85 | return;
|
---|
| 86 | }
|
---|
| 87 | /*}}}*/
|
---|
[26099] | 88 | void Inputs::Echo(int enum_in){/*{{{*/
|
---|
| 89 | _printf_("Inputs Echo:\n");
|
---|
| 90 | int index= EnumToIndex(enum_in);
|
---|
| 91 | if(this->inputs[index])this->inputs[index]->Echo();
|
---|
| 92 | return;
|
---|
| 93 | }
|
---|
| 94 | /*}}}*/
|
---|
[25508] | 95 | void Inputs::Marshall(MarshallHandle* marshallhandle){/*{{{*/
|
---|
[24335] | 96 |
|
---|
[25506] | 97 | int num_inputs=0;
|
---|
| 98 | int index;
|
---|
| 99 |
|
---|
[25529] | 100 | int object_enum = InputsEnum;
|
---|
[25506] | 101 | marshallhandle->call(object_enum);
|
---|
[25529] | 102 | marshallhandle->call(this->numberofelements_local);
|
---|
| 103 | marshallhandle->call(this->numberofvertices_local);
|
---|
[25506] | 104 |
|
---|
[25523] | 105 | if(marshallhandle->OperationNumber()!=MARSHALLING_LOAD){
|
---|
[25506] | 106 |
|
---|
| 107 | /*Marshall num_inputs first*/
|
---|
| 108 | for(int i=0;i<NUMINPUTS;i++){
|
---|
| 109 | if(this->inputs[i]) num_inputs++;
|
---|
| 110 | }
|
---|
| 111 | marshallhandle->call(num_inputs);
|
---|
| 112 |
|
---|
| 113 | /*Marshall Parameters one by one now*/
|
---|
| 114 | for(int i=0;i<NUMINPUTS;i++){
|
---|
| 115 | if(this->inputs[i]){
|
---|
| 116 | object_enum = this->inputs[i]->ObjectEnum();
|
---|
| 117 | marshallhandle->call(i);
|
---|
| 118 | marshallhandle->call(object_enum);
|
---|
[25508] | 119 | this->inputs[i]->Marshall(marshallhandle);
|
---|
[25506] | 120 | }
|
---|
| 121 | }
|
---|
| 122 | }
|
---|
| 123 | else{
|
---|
| 124 |
|
---|
| 125 | /*Get number of inputs marshalled*/
|
---|
| 126 | marshallhandle->call(num_inputs);
|
---|
| 127 |
|
---|
| 128 | /*Recover input2eters one by one*/
|
---|
| 129 | for(int i=0;i<num_inputs;i++){
|
---|
| 130 |
|
---|
| 131 | /*Recover enum of object first: */
|
---|
| 132 | marshallhandle->call(index);
|
---|
| 133 | marshallhandle->call(object_enum);
|
---|
| 134 |
|
---|
| 135 | if(object_enum==BoolInputEnum){
|
---|
| 136 | BoolInput* boolinput2=new BoolInput();
|
---|
[25508] | 137 | boolinput2->Marshall(marshallhandle);
|
---|
[25506] | 138 | this->inputs[index]=boolinput2;
|
---|
| 139 | }
|
---|
| 140 | else if(object_enum==IntInputEnum){
|
---|
| 141 | IntInput* intinput2=new IntInput();
|
---|
[25508] | 142 | intinput2->Marshall(marshallhandle);
|
---|
[25506] | 143 | this->inputs[index]=intinput2;
|
---|
| 144 | }
|
---|
| 145 | else if(object_enum==TriaInputEnum){
|
---|
| 146 | TriaInput* triainput2=new TriaInput();
|
---|
[25508] | 147 | triainput2->Marshall(marshallhandle);
|
---|
[25506] | 148 | this->inputs[index]=triainput2;
|
---|
| 149 | }
|
---|
| 150 | else if(object_enum==PentaInputEnum){
|
---|
| 151 | PentaInput* pentainput2=new PentaInput();
|
---|
[25508] | 152 | pentainput2->Marshall(marshallhandle);
|
---|
[25506] | 153 | this->inputs[index]=pentainput2;
|
---|
| 154 | }
|
---|
[25523] | 155 | else if(object_enum==ControlInputEnum){
|
---|
| 156 | ControlInput* input=new ControlInput();
|
---|
| 157 | input->Marshall(marshallhandle);
|
---|
| 158 | this->inputs[index]=input;
|
---|
| 159 | }
|
---|
[26170] | 160 | else if(object_enum==TransientInputEnum){
|
---|
| 161 | TransientInput* input=new TransientInput();
|
---|
| 162 | input->Marshall(marshallhandle);
|
---|
| 163 | this->inputs[index]=input;
|
---|
| 164 | }
|
---|
[26174] | 165 | else if(object_enum==DatasetInputEnum){
|
---|
| 166 | DatasetInput* input=new DatasetInput();
|
---|
| 167 | input->Marshall(marshallhandle);
|
---|
| 168 | this->inputs[index]=input;
|
---|
| 169 | }
|
---|
[27113] | 170 | else if(object_enum==ArrayInputEnum){
|
---|
| 171 | ArrayInput* input=new ArrayInput();
|
---|
| 172 | input->Marshall(marshallhandle);
|
---|
| 173 | this->inputs[index]=input;
|
---|
| 174 | }
|
---|
[25506] | 175 | else{
|
---|
| 176 | _error_("input "<<EnumToStringx(object_enum)<<" not supported");
|
---|
| 177 | }
|
---|
| 178 | }
|
---|
| 179 | }
|
---|
| 180 | }
|
---|
| 181 | /*}}}*/
|
---|
| 182 |
|
---|
[25379] | 183 | void Inputs::AddInput(Input* newinput){/*{{{*/
|
---|
[24335] | 184 |
|
---|
| 185 | /*Get Enum from Param*/
|
---|
| 186 | _assert_(newinput);
|
---|
| 187 | int input_enum = newinput->InstanceEnum();
|
---|
| 188 |
|
---|
| 189 | /*Get index in array*/
|
---|
| 190 | #ifdef _ISSM_DEBUG_
|
---|
| 191 | if(input_enum<=InputsSTARTEnum) _error_("Cannot add input: Enum "<<EnumToStringx(input_enum)<<" should appear after InputsSTARTEnum");
|
---|
| 192 | if(input_enum>=InputsENDEnum) _error_("Cannot add input: Enum "<<EnumToStringx(input_enum)<<" should appear before InputsENDEnum");
|
---|
| 193 | #endif
|
---|
| 194 | int index = input_enum - InputsSTARTEnum -1;
|
---|
| 195 |
|
---|
| 196 | /*Delete input if it already exists*/
|
---|
| 197 | if(this->inputs[index]){
|
---|
| 198 | delete this->inputs[index];
|
---|
| 199 | this->inputs[index] = NULL;
|
---|
| 200 | }
|
---|
| 201 |
|
---|
| 202 | /*Add input to array*/
|
---|
| 203 | this->inputs[index] = newinput;
|
---|
| 204 | }
|
---|
| 205 | /*}}}*/
|
---|
[25379] | 206 | void Inputs::ChangeEnum(int oldenumtype,int newenumtype){/*{{{*/
|
---|
[24335] | 207 |
|
---|
| 208 | /*Get indices from enums*/
|
---|
| 209 | int index_old = EnumToIndex(oldenumtype);
|
---|
| 210 | int index_new = EnumToIndex(newenumtype);
|
---|
| 211 |
|
---|
| 212 | /*Delete input if it already exists*/
|
---|
| 213 | if(this->inputs[index_new]) delete this->inputs[index_new];
|
---|
| 214 |
|
---|
| 215 | /*Make sure that old one exists*/
|
---|
| 216 | if(!this->inputs[index_old]){
|
---|
| 217 | _error_("Input "<<EnumToStringx(oldenumtype)<<" not found");
|
---|
| 218 | }
|
---|
| 219 |
|
---|
| 220 | /*Replace Enums*/
|
---|
| 221 | this->inputs[index_old]->ChangeEnum(newenumtype);
|
---|
| 222 | this->inputs[index_new] = this->inputs[index_old];
|
---|
| 223 | this->inputs[index_old] = NULL;
|
---|
| 224 | }/*}}}*/
|
---|
[25379] | 225 | void Inputs::Configure(Parameters* parameters){/*{{{*/
|
---|
[24335] | 226 | for(int i=0;i<NUMINPUTS;i++){
|
---|
| 227 | if(this->inputs[i]) this->inputs[i]->Configure(parameters);
|
---|
| 228 | }
|
---|
| 229 | }
|
---|
| 230 | /*}}}*/
|
---|
[25379] | 231 | int Inputs::DeleteInput(int input_enum){/*{{{*/
|
---|
[24335] | 232 |
|
---|
| 233 | int index = EnumToIndex(input_enum);
|
---|
| 234 | if(this->inputs[index]){
|
---|
| 235 | delete this->inputs[index];
|
---|
| 236 | this->inputs[index] = NULL;
|
---|
| 237 | }
|
---|
| 238 |
|
---|
| 239 | return 1;
|
---|
| 240 | }
|
---|
| 241 | /*}}}*/
|
---|
[25379] | 242 | void Inputs::DuplicateInput(int original_enum,int new_enum){/*{{{*/
|
---|
[24335] | 243 |
|
---|
| 244 | _assert_(this);
|
---|
| 245 |
|
---|
| 246 | /*Get indices from enums*/
|
---|
| 247 | int index_ori = EnumToIndex(original_enum);
|
---|
| 248 | int index_new = EnumToIndex(new_enum);
|
---|
| 249 |
|
---|
| 250 | /*Delete input if it already exists*/
|
---|
| 251 | if(this->inputs[index_new]) delete this->inputs[index_new];
|
---|
| 252 |
|
---|
| 253 | /*Make sure that old one exists*/
|
---|
| 254 | if(!this->inputs[index_ori]){
|
---|
| 255 | _error_("Input "<<EnumToStringx(original_enum)<<" not found");
|
---|
| 256 | }
|
---|
| 257 |
|
---|
| 258 | /*Make a copy*/
|
---|
[25379] | 259 | Input* copy=this->inputs[index_ori]->copy();
|
---|
[24335] | 260 |
|
---|
| 261 | /*Add copy*/
|
---|
| 262 | this->inputs[index_new] = copy;
|
---|
| 263 | }
|
---|
| 264 | /*}}}*/
|
---|
[26121] | 265 | void Inputs::ZAXPY(IssmDouble alpha, int xenum, int yenum, int zenum){/*{{{*/
|
---|
[26047] | 266 |
|
---|
| 267 | _assert_(this);
|
---|
| 268 |
|
---|
| 269 | /*Get indices from enums*/
|
---|
| 270 | int index_x = EnumToIndex(xenum);
|
---|
| 271 | int index_y = EnumToIndex(yenum);
|
---|
| 272 | int index_z = EnumToIndex(zenum);
|
---|
| 273 |
|
---|
| 274 | /*Delete output if it already exists*/
|
---|
| 275 | if(this->inputs[index_z]) delete this->inputs[index_z];
|
---|
| 276 |
|
---|
| 277 | /*Make sure that old one exists*/
|
---|
| 278 | if(!this->inputs[index_x]) _error_("Input "<<EnumToStringx(xenum)<<" not found");
|
---|
| 279 | if(!this->inputs[index_y]) _error_("Input "<<EnumToStringx(yenum)<<" not found");
|
---|
| 280 |
|
---|
| 281 | /*Make a copy*/
|
---|
[26072] | 282 | this->inputs[index_z]=this->inputs[index_y]->copy();
|
---|
[26047] | 283 |
|
---|
| 284 | /*AXPY: */
|
---|
| 285 | this->inputs[index_z]->AXPY(this->inputs[index_x],alpha);
|
---|
| 286 | }
|
---|
| 287 | /*}}}*/
|
---|
[26121] | 288 | void Inputs::AXPY(IssmDouble alpha, int xenum, int yenum ){/*{{{*/
|
---|
| 289 |
|
---|
| 290 | _assert_(this);
|
---|
| 291 |
|
---|
| 292 | /*Get indices from enums*/
|
---|
| 293 | int index_x = EnumToIndex(xenum);
|
---|
| 294 | int index_y = EnumToIndex(yenum);
|
---|
| 295 |
|
---|
| 296 | /*Make sure that old one exists*/
|
---|
| 297 | if(!this->inputs[index_x]) _error_("Input "<<EnumToStringx(xenum)<<" not found");
|
---|
| 298 | if(!this->inputs[index_y]) _error_("Input "<<EnumToStringx(yenum)<<" not found");
|
---|
| 299 |
|
---|
| 300 | /*AXPY: */
|
---|
| 301 | this->inputs[index_y]->AXPY(this->inputs[index_x],alpha);
|
---|
| 302 | }
|
---|
| 303 | /*}}}*/
|
---|
[27956] | 304 | void Inputs::Shift(int xenum, IssmDouble alpha){/*{{{*/
|
---|
[26121] | 305 |
|
---|
| 306 | _assert_(this);
|
---|
| 307 |
|
---|
| 308 | /*Get indices from enums*/
|
---|
| 309 | int index_x = EnumToIndex(xenum);
|
---|
| 310 |
|
---|
| 311 | /*Make sure that x exists*/
|
---|
| 312 | if(!this->inputs[index_x]) _error_("Input "<<EnumToStringx(xenum)<<" not found");
|
---|
| 313 |
|
---|
| 314 | /*Shift: */
|
---|
| 315 | this->inputs[index_x]->Shift(alpha);
|
---|
| 316 | }
|
---|
| 317 | /*}}}*/
|
---|
[25379] | 318 | int Inputs::EnumToIndex(int enum_in){/*{{{*/
|
---|
[24335] | 319 |
|
---|
| 320 | _assert_(this);
|
---|
| 321 |
|
---|
| 322 | /*Make sure this parameter is at the right place*/
|
---|
| 323 | #ifdef _ISSM_DEBUG_
|
---|
[24360] | 324 | if(enum_in<=InputsSTARTEnum){
|
---|
| 325 | //int* temp = xNew<int>(3);
|
---|
| 326 | _error_("Enum "<<EnumToStringx(enum_in)<<" should appear after InputsSTARTEnum");
|
---|
| 327 | }
|
---|
| 328 | if(enum_in>=InputsENDEnum){
|
---|
| 329 | _error_("Enum "<<EnumToStringx(enum_in)<<" should appear before InputsENDEnum");
|
---|
| 330 | }
|
---|
[24335] | 331 | #endif
|
---|
| 332 | return enum_in - InputsSTARTEnum -1;
|
---|
| 333 | }/*}}}*/
|
---|
[25379] | 334 | bool Inputs::Exist(int enum_in){/*{{{*/
|
---|
[24335] | 335 |
|
---|
| 336 | _assert_(this);
|
---|
| 337 |
|
---|
| 338 | int index = EnumToIndex(enum_in);
|
---|
| 339 | if(this->inputs[index]) return true;
|
---|
| 340 | return false;
|
---|
| 341 | }
|
---|
| 342 | /*}}}*/
|
---|
[25379] | 343 | int Inputs::GetInputObjectEnum(int enum_in){/*{{{*/
|
---|
[24344] | 344 |
|
---|
| 345 | _assert_(this);
|
---|
| 346 |
|
---|
| 347 | int index = EnumToIndex(enum_in);
|
---|
| 348 | if(!this->inputs[index]) _error_("Input "<<EnumToStringx(enum_in)<<" not found");
|
---|
| 349 | return this->inputs[index]->ObjectEnum();
|
---|
| 350 | }
|
---|
| 351 | /*}}}*/
|
---|
[25379] | 352 | void Inputs::GetInputsInterpolations(int* pnuminputs,int** pinterpolations,int** pinputenums){/*{{{*/
|
---|
[24340] | 353 |
|
---|
| 354 | /*First count number of inputs*/
|
---|
| 355 | int count = 0;
|
---|
| 356 | for(int i=0;i<NUMINPUTS;i++){
|
---|
| 357 | if(this->inputs[i]) count++;
|
---|
| 358 | }
|
---|
| 359 | int numinputs = count;
|
---|
| 360 |
|
---|
| 361 | /*Allocate output*/
|
---|
| 362 | int* interpolations = xNew<int>(count);
|
---|
| 363 | int* enumlist = xNew<int>(count);
|
---|
| 364 |
|
---|
| 365 | /*Go through all inputs and assign interpolation in vector*/
|
---|
| 366 | count = 0;
|
---|
| 367 | for(int i=0;i<NUMINPUTS;i++){
|
---|
| 368 |
|
---|
[25379] | 369 | Input* input=this->inputs[i];
|
---|
[24340] | 370 | if(!input) continue;
|
---|
| 371 |
|
---|
| 372 | enumlist[count] = i+InputsSTARTEnum+1;
|
---|
| 373 | switch(input->ObjectEnum()){
|
---|
[25379] | 374 | case BoolInputEnum:
|
---|
| 375 | case IntInputEnum:
|
---|
[24340] | 376 | interpolations[count] = input->ObjectEnum();
|
---|
| 377 | break;
|
---|
[25379] | 378 | case TriaInputEnum:
|
---|
[24340] | 379 | interpolations[count] = input->GetResultInterpolation();
|
---|
| 380 | break;
|
---|
| 381 | default:
|
---|
| 382 | _error_("Input "<<EnumToStringx(input->ObjectEnum())<<" not supported yet");
|
---|
| 383 | }
|
---|
| 384 | count++;
|
---|
| 385 | }
|
---|
| 386 | _assert_(count == numinputs);
|
---|
| 387 |
|
---|
| 388 | /*Return pointer*/
|
---|
| 389 | *pnuminputs = numinputs;
|
---|
| 390 | *pinterpolations = interpolations;
|
---|
| 391 | *pinputenums = enumlist;
|
---|
| 392 |
|
---|
| 393 | }/*}}}*/
|
---|
[25379] | 394 | SegInput* Inputs::GetSegInput(int enum_in){/*{{{*/
|
---|
[24335] | 395 |
|
---|
| 396 | _assert_(this);
|
---|
| 397 |
|
---|
| 398 | /*Get input id*/
|
---|
| 399 | int id = EnumToIndex(enum_in);
|
---|
| 400 |
|
---|
| 401 | /*Check that it has the right format*/
|
---|
[25379] | 402 | Input* input = this->inputs[id];
|
---|
[24335] | 403 | if(!input) return NULL;
|
---|
| 404 |
|
---|
| 405 | return input->GetSegInput();
|
---|
| 406 | }/*}}}*/
|
---|
[25379] | 407 | TriaInput* Inputs::GetTriaInput(int enum_in){/*{{{*/
|
---|
[24335] | 408 |
|
---|
| 409 | _assert_(this);
|
---|
| 410 |
|
---|
| 411 | /*Get input id*/
|
---|
| 412 | int id = EnumToIndex(enum_in);
|
---|
| 413 |
|
---|
| 414 | /*Check that it has the right format*/
|
---|
[25379] | 415 | Input* input = this->inputs[id];
|
---|
[24335] | 416 | if(!input) return NULL;
|
---|
| 417 |
|
---|
| 418 | return input->GetTriaInput();
|
---|
| 419 | }/*}}}*/
|
---|
[25379] | 420 | TriaInput* Inputs::GetTriaInput(int enum_in,IssmDouble time){/*{{{*/
|
---|
[24335] | 421 |
|
---|
| 422 | /*Get input id*/
|
---|
| 423 | int id = EnumToIndex(enum_in);
|
---|
| 424 |
|
---|
| 425 | /*Check that it has the right format*/
|
---|
[25379] | 426 | Input* input = this->inputs[id];
|
---|
[24335] | 427 | if(!input) return NULL;
|
---|
| 428 |
|
---|
[25379] | 429 | if(input->ObjectEnum()==TransientInputEnum){
|
---|
| 430 | return xDynamicCast<TransientInput*>(input)->GetTriaInput(time);
|
---|
[24335] | 431 | }
|
---|
| 432 | else{
|
---|
| 433 | return input->GetTriaInput();
|
---|
| 434 | }
|
---|
| 435 | }/*}}}*/
|
---|
[25379] | 436 | TriaInput* Inputs::GetTriaInput(int enum_in,IssmDouble start_time,IssmDouble end_time,int averaging_method){/*{{{*/
|
---|
[24565] | 437 |
|
---|
| 438 | /*Get input id*/
|
---|
| 439 | int id = EnumToIndex(enum_in);
|
---|
| 440 |
|
---|
| 441 | /*Check that it has the right format*/
|
---|
[25379] | 442 | Input* input = this->inputs[id];
|
---|
[24565] | 443 | if(!input) return NULL;
|
---|
| 444 |
|
---|
[25379] | 445 | if(input->ObjectEnum()==TransientInputEnum){
|
---|
| 446 | return xDynamicCast<TransientInput*>(input)->GetTriaInput(start_time,end_time,averaging_method);
|
---|
[24565] | 447 | }
|
---|
| 448 | else{
|
---|
[25379] | 449 | _error_("Input "<<EnumToStringx(enum_in)<<" is not an TransientInput");
|
---|
[24565] | 450 | }
|
---|
| 451 | }/*}}}*/
|
---|
[25379] | 452 | PentaInput* Inputs::GetPentaInput(int enum_in){/*{{{*/
|
---|
[24335] | 453 |
|
---|
| 454 | /*Get input id*/
|
---|
| 455 | int id = EnumToIndex(enum_in);
|
---|
| 456 |
|
---|
| 457 | /*Check that it has the right format*/
|
---|
[25379] | 458 | Input* input = this->inputs[id];
|
---|
[24335] | 459 | if(!input) return NULL;
|
---|
| 460 |
|
---|
| 461 | return input->GetPentaInput();
|
---|
| 462 | }/*}}}*/
|
---|
[25379] | 463 | PentaInput* Inputs::GetPentaInput(int enum_in,IssmDouble time){/*{{{*/
|
---|
[24335] | 464 |
|
---|
| 465 | /*Get input id*/
|
---|
| 466 | int id = EnumToIndex(enum_in);
|
---|
| 467 |
|
---|
| 468 | /*Check that it has the right format*/
|
---|
[25379] | 469 | Input* input = this->inputs[id];
|
---|
[24335] | 470 | if(!input) return NULL;
|
---|
| 471 |
|
---|
[25379] | 472 | if(input->ObjectEnum()==TransientInputEnum){
|
---|
| 473 | return xDynamicCast<TransientInput*>(input)->GetPentaInput(time);
|
---|
[24335] | 474 | }
|
---|
| 475 | else{
|
---|
| 476 | return input->GetPentaInput();
|
---|
| 477 | }
|
---|
| 478 | }/*}}}*/
|
---|
[25379] | 479 | PentaInput* Inputs::GetPentaInput(int enum_in,IssmDouble start_time,IssmDouble end_time,int averaging_method){/*{{{*/
|
---|
[25024] | 480 |
|
---|
| 481 | /*Get input id*/
|
---|
| 482 | int id = EnumToIndex(enum_in);
|
---|
| 483 |
|
---|
| 484 | /*Check that it has the right format*/
|
---|
[25379] | 485 | Input* input = this->inputs[id];
|
---|
[25024] | 486 | if(!input) return NULL;
|
---|
| 487 |
|
---|
[25379] | 488 | if(input->ObjectEnum()==TransientInputEnum){
|
---|
| 489 | return xDynamicCast<TransientInput*>(input)->GetPentaInput(start_time,end_time,averaging_method);
|
---|
[25024] | 490 | }
|
---|
| 491 | else{
|
---|
[25379] | 492 | _error_("Input "<<EnumToStringx(enum_in)<<" is not an TransientInput");
|
---|
[25024] | 493 | }
|
---|
| 494 | }/*}}}*/
|
---|
[25379] | 495 | TransientInput* Inputs::GetTransientInput(int enum_in){/*{{{*/
|
---|
[24335] | 496 |
|
---|
| 497 | /*Get input id*/
|
---|
| 498 | int id = EnumToIndex(enum_in);
|
---|
| 499 |
|
---|
| 500 | /*Check that it has the right format*/
|
---|
[25379] | 501 | Input* input = this->inputs[id];
|
---|
[24335] | 502 | if(!input) return NULL;
|
---|
| 503 |
|
---|
[25379] | 504 | if(input->ObjectEnum() != TransientInputEnum){
|
---|
| 505 | _error_("Input "<<EnumToStringx(enum_in)<<" is not an TransientInput");
|
---|
[24335] | 506 | }
|
---|
| 507 |
|
---|
| 508 | /*Cast and return*/
|
---|
[25379] | 509 | TransientInput* output = xDynamicCast<TransientInput*>(input);
|
---|
[24335] | 510 | return output;
|
---|
| 511 | }/*}}}*/
|
---|
[25379] | 512 | ElementInput* Inputs::GetControlInputData(int enum_in,const char* data){/*{{{*/
|
---|
[24335] | 513 |
|
---|
| 514 | /*Get input id*/
|
---|
| 515 | int id = EnumToIndex(enum_in);
|
---|
| 516 |
|
---|
| 517 | /*Check that it has the right format*/
|
---|
[25379] | 518 | Input* input = this->inputs[id];
|
---|
[24335] | 519 | if(!input) return NULL;
|
---|
[25379] | 520 | if(input->ObjectEnum() != ControlInputEnum){
|
---|
| 521 | _error_("Input "<<EnumToStringx(enum_in)<<" is not an ControlInput");
|
---|
[24335] | 522 | }
|
---|
| 523 |
|
---|
| 524 | /*Cast and return*/
|
---|
[25379] | 525 | return xDynamicCast<ControlInput*>(input)->GetInput(data);
|
---|
[24335] | 526 | }/*}}}*/
|
---|
[25379] | 527 | DatasetInput* Inputs::GetDatasetInput(int enum_in){/*{{{*/
|
---|
[24335] | 528 |
|
---|
| 529 | /*Get input id*/
|
---|
| 530 | int id = EnumToIndex(enum_in);
|
---|
| 531 |
|
---|
| 532 | /*Check that it has the right format*/
|
---|
[25379] | 533 | Input* input = this->inputs[id];
|
---|
[24335] | 534 | if(!input) return NULL;
|
---|
[25379] | 535 | if(input->ObjectEnum() != DatasetInputEnum){
|
---|
| 536 | _error_("Input "<<EnumToStringx(enum_in)<<" is not an DatasetInput");
|
---|
[24335] | 537 | }
|
---|
| 538 |
|
---|
| 539 | /*Cast and return*/
|
---|
[25379] | 540 | return xDynamicCast<DatasetInput*>(input);
|
---|
[24335] | 541 | }/*}}}*/
|
---|
[25379] | 542 | ControlInput* Inputs::GetControlInput(int enum_in){/*{{{*/
|
---|
[24335] | 543 |
|
---|
| 544 | /*Get input id*/
|
---|
| 545 | int id = EnumToIndex(enum_in);
|
---|
| 546 |
|
---|
| 547 | /*Check that it has the right format*/
|
---|
[25379] | 548 | Input* input = this->inputs[id];
|
---|
[24335] | 549 | if(!input) return NULL;
|
---|
[25379] | 550 | if(input->ObjectEnum() != ControlInputEnum){
|
---|
| 551 | _error_("Input "<<EnumToStringx(enum_in)<<" is not an ControlInput");
|
---|
[24335] | 552 | }
|
---|
| 553 |
|
---|
| 554 | /*Cast and return*/
|
---|
[25379] | 555 | return xDynamicCast<ControlInput*>(input);
|
---|
[24335] | 556 | }/*}}}*/
|
---|
[25379] | 557 | void Inputs::GetArrayPtr(int enum_in,int row,IssmDouble** pvalues,int* pN){/*{{{*/
|
---|
[24926] | 558 |
|
---|
| 559 | /*Get input id*/
|
---|
| 560 | int id = EnumToIndex(enum_in);
|
---|
| 561 |
|
---|
| 562 | /*Create it if necessary*/
|
---|
| 563 | if(this->inputs[id]){
|
---|
[25379] | 564 | if(this->inputs[id]->ObjectEnum()!=ArrayInputEnum) _error_(EnumToStringx(this->inputs[id]->ObjectEnum())<<" cannot return an array");
|
---|
[24926] | 565 | }
|
---|
| 566 | else{
|
---|
| 567 | _error_("Input "<<EnumToStringx(enum_in)<<" not found");
|
---|
| 568 | }
|
---|
| 569 |
|
---|
| 570 | /*Set input*/
|
---|
[25379] | 571 | ArrayInput* input = xDynamicCast<ArrayInput*>(this->inputs[id]);
|
---|
[24926] | 572 | input->GetArrayPtr(row,pvalues,pN);
|
---|
| 573 | }/*}}}*/
|
---|
[27128] | 574 | void Inputs::GetIntArrayPtr(int enum_in,int row,int** pvalues,int* pN){/*{{{*/
|
---|
| 575 |
|
---|
| 576 | /*Get input id*/
|
---|
| 577 | int id = EnumToIndex(enum_in);
|
---|
| 578 |
|
---|
| 579 | /*Create it if necessary*/
|
---|
| 580 | if(this->inputs[id]){
|
---|
| 581 | if(this->inputs[id]->ObjectEnum()!=IntArrayInputEnum) _error_(EnumToStringx(this->inputs[id]->ObjectEnum())<<" cannot return an int array");
|
---|
| 582 | }
|
---|
| 583 | else{
|
---|
| 584 | _error_("Input "<<EnumToStringx(enum_in)<<" not found");
|
---|
| 585 | }
|
---|
| 586 |
|
---|
| 587 | /*Set input*/
|
---|
| 588 | IntArrayInput* input = xDynamicCast<IntArrayInput*>(this->inputs[id]);
|
---|
| 589 | input->GetArrayPtr(row,pvalues,pN);
|
---|
| 590 | }/*}}}*/
|
---|
[25379] | 591 | void Inputs::GetArray(int enum_in,int row,IssmDouble** pvalues,int* pN){/*{{{*/
|
---|
[24360] | 592 |
|
---|
| 593 | /*Get input id*/
|
---|
| 594 | int id = EnumToIndex(enum_in);
|
---|
| 595 |
|
---|
| 596 | /*Create it if necessary*/
|
---|
| 597 | if(this->inputs[id]){
|
---|
[25379] | 598 | if(this->inputs[id]->ObjectEnum()!=ArrayInputEnum) _error_(EnumToStringx(this->inputs[id]->ObjectEnum())<<" cannot return an array");
|
---|
[24360] | 599 | }
|
---|
| 600 | else{
|
---|
| 601 | _error_("Input "<<EnumToStringx(enum_in)<<" not found");
|
---|
| 602 | }
|
---|
| 603 |
|
---|
| 604 | /*Set input*/
|
---|
[25379] | 605 | ArrayInput* input = xDynamicCast<ArrayInput*>(this->inputs[id]);
|
---|
[24360] | 606 | input->GetArray(row,pvalues,pN);
|
---|
| 607 | }/*}}}*/
|
---|
[27128] | 608 | void Inputs::GetIntArray(int enum_in,int row,int** pvalues,int* pN){/*{{{*/
|
---|
| 609 |
|
---|
| 610 | /*Get input id*/
|
---|
| 611 | int id = EnumToIndex(enum_in);
|
---|
| 612 |
|
---|
| 613 | /*Create it if necessary*/
|
---|
| 614 | if(this->inputs[id]){
|
---|
| 615 | if(this->inputs[id]->ObjectEnum()!=IntArrayInputEnum) _error_(EnumToStringx(this->inputs[id]->ObjectEnum())<<" cannot return an int array");
|
---|
| 616 | }
|
---|
| 617 | else{
|
---|
| 618 | _error_("Input "<<EnumToStringx(enum_in)<<" not found");
|
---|
| 619 | }
|
---|
| 620 |
|
---|
| 621 | /*Set input*/
|
---|
| 622 | IntArrayInput* input = xDynamicCast<IntArrayInput*>(this->inputs[id]);
|
---|
| 623 | input->GetArray(row,pvalues,pN);
|
---|
| 624 | }/*}}}*/
|
---|
[25379] | 625 | void Inputs::GetInputValue(bool* pvalue,int enum_in,int index){/*{{{*/
|
---|
[24335] | 626 |
|
---|
| 627 | /*Get input id*/
|
---|
| 628 | int id = EnumToIndex(enum_in);
|
---|
| 629 |
|
---|
| 630 | /*Create it if necessary*/
|
---|
| 631 | if(this->inputs[id]){
|
---|
[25379] | 632 | if(this->inputs[id]->ObjectEnum()!=BoolInputEnum) _error_(EnumToStringx(this->inputs[id]->ObjectEnum())<<" cannot return a bool");
|
---|
[24335] | 633 | }
|
---|
| 634 | else{
|
---|
| 635 | _error_("Input "<<EnumToStringx(enum_in)<<" not found");
|
---|
| 636 | }
|
---|
| 637 |
|
---|
| 638 | /*Set input*/
|
---|
[25379] | 639 | BoolInput* input = xDynamicCast<BoolInput*>(this->inputs[id]);
|
---|
[24335] | 640 | input->GetInput(pvalue,index);
|
---|
| 641 | }/*}}}*/
|
---|
[25379] | 642 | void Inputs::GetInputValue(int* pvalue,int enum_in,int index){/*{{{*/
|
---|
[24335] | 643 |
|
---|
| 644 | /*Get input id*/
|
---|
| 645 | int id = EnumToIndex(enum_in);
|
---|
| 646 |
|
---|
| 647 | /*Create it if necessary*/
|
---|
| 648 | if(this->inputs[id]){
|
---|
[25379] | 649 | if(this->inputs[id]->ObjectEnum()!=IntInputEnum) _error_(EnumToStringx(this->inputs[id]->ObjectEnum())<<" cannot return a int");
|
---|
[24335] | 650 | }
|
---|
| 651 | else{
|
---|
| 652 | int* temp = xNew<int>(3);
|
---|
| 653 | _error_("Input "<<EnumToStringx(enum_in)<<" not found");
|
---|
| 654 | }
|
---|
| 655 |
|
---|
| 656 | /*Set input*/
|
---|
[25379] | 657 | IntInput* input = xDynamicCast<IntInput*>(this->inputs[id]);
|
---|
[24335] | 658 | input->GetInput(pvalue,index);
|
---|
| 659 | }/*}}}*/
|
---|
[25379] | 660 | void Inputs::GetInputValue(IssmDouble* pvalue,int enum_in,int index){/*{{{*/
|
---|
[24935] | 661 |
|
---|
| 662 | /*Get input id*/
|
---|
| 663 | int id = EnumToIndex(enum_in);
|
---|
| 664 |
|
---|
| 665 | /*Create it if necessary*/
|
---|
| 666 | if(this->inputs[id]){
|
---|
[25379] | 667 | if(this->inputs[id]->ObjectEnum()!=DoubleInputEnum) _error_(EnumToStringx(this->inputs[id]->ObjectEnum())<<" cannot return a double!");
|
---|
[24935] | 668 | }
|
---|
| 669 | else{
|
---|
| 670 | int* temp = xNew<int>(3);
|
---|
| 671 | _error_("Input "<<EnumToStringx(enum_in)<<" not found");
|
---|
| 672 | }
|
---|
| 673 |
|
---|
| 674 | /*Set input*/
|
---|
[25379] | 675 | DoubleInput* input = xDynamicCast<DoubleInput*>(this->inputs[id]);
|
---|
[24935] | 676 | input->GetInput(pvalue,index);
|
---|
| 677 |
|
---|
| 678 | }/*}}}*/
|
---|
[25379] | 679 | void Inputs::ResultInterpolation(int* pinterpolation,int* pnodesperelement,int* parray_size, int output_enum){/*{{{*/
|
---|
[24335] | 680 |
|
---|
| 681 | /*Get input */
|
---|
| 682 | int index = EnumToIndex(output_enum);
|
---|
[25379] | 683 | Input* input = this->inputs[index];
|
---|
[24335] | 684 |
|
---|
| 685 | /*Check that it is found*/
|
---|
| 686 | if(!input){
|
---|
| 687 | _error_("Input "<<EnumToStringx(output_enum)<<" not found and cannot be added to model results");
|
---|
| 688 | }
|
---|
| 689 |
|
---|
| 690 | /*Assign output pointer*/
|
---|
| 691 | *pinterpolation = input->GetResultInterpolation();
|
---|
| 692 | *pnodesperelement = input->GetResultNumberOfNodes();
|
---|
| 693 | *parray_size = input->GetResultArraySize();
|
---|
| 694 | }/*}}}*/
|
---|
[25379] | 695 | void Inputs::SetInput(int enum_in,int index,bool value){/*{{{*/
|
---|
[24335] | 696 |
|
---|
| 697 | /*Get input id*/
|
---|
| 698 | int id = EnumToIndex(enum_in);
|
---|
| 699 |
|
---|
| 700 | /*Create it if necessary*/
|
---|
| 701 | if(this->inputs[id]){
|
---|
[25379] | 702 | if(this->inputs[id]->ObjectEnum()!=BoolInputEnum) _error_("cannot add a bool to a "<<EnumToStringx(this->inputs[id]->ObjectEnum()));
|
---|
[24335] | 703 | }
|
---|
| 704 | else{
|
---|
[25379] | 705 | this->inputs[id] = new BoolInput(this->numberofelements_local);
|
---|
[24335] | 706 | }
|
---|
| 707 |
|
---|
| 708 | /*Set input*/
|
---|
[25379] | 709 | BoolInput* input = xDynamicCast<BoolInput*>(this->inputs[id]);
|
---|
[24335] | 710 | input->SetInput(index,value);
|
---|
| 711 | }/*}}}*/
|
---|
[25379] | 712 | void Inputs::SetInput(int enum_in,int index,int value){/*{{{*/
|
---|
[24335] | 713 |
|
---|
| 714 | /*Get input id*/
|
---|
| 715 | int id = EnumToIndex(enum_in);
|
---|
| 716 |
|
---|
| 717 | /*Create it if necessary*/
|
---|
| 718 | if(this->inputs[id]){
|
---|
[25379] | 719 | if(this->inputs[id]->ObjectEnum()!=IntInputEnum) _error_("cannot add an int to a "<<EnumToStringx(this->inputs[id]->ObjectEnum()));
|
---|
[24335] | 720 | }
|
---|
| 721 | else{
|
---|
[25379] | 722 | this->inputs[id] = new IntInput(this->numberofelements_local);
|
---|
[24335] | 723 | }
|
---|
| 724 |
|
---|
| 725 | /*Set input*/
|
---|
[25379] | 726 | IntInput* input = xDynamicCast<IntInput*>(this->inputs[id]);
|
---|
[24335] | 727 | input->SetInput(index,value);
|
---|
| 728 | }/*}}}*/
|
---|
[25379] | 729 | void Inputs::SetDoubleInput(int enum_in,int index,IssmDouble value){/*{{{*/
|
---|
[24935] | 730 |
|
---|
| 731 | /*Get input id*/
|
---|
| 732 | int id = EnumToIndex(enum_in);
|
---|
| 733 |
|
---|
| 734 | /*Create it if necessary*/
|
---|
| 735 | if(this->inputs[id]){
|
---|
[25379] | 736 | if(this->inputs[id]->ObjectEnum()!=DoubleInputEnum) _error_("cannot add a double to a "<<EnumToStringx(this->inputs[id]->ObjectEnum()));
|
---|
[24935] | 737 | }
|
---|
| 738 | else{
|
---|
[25379] | 739 | this->inputs[id] = new DoubleInput(this->numberofelements_local);
|
---|
[24935] | 740 | }
|
---|
| 741 |
|
---|
| 742 | /*Set input*/
|
---|
[25379] | 743 | DoubleInput* input = xDynamicCast<DoubleInput*>(this->inputs[id]);
|
---|
[24935] | 744 | input->SetInput(index,value);
|
---|
| 745 | }/*}}}*/
|
---|
[25379] | 746 | void Inputs::SetArrayInput(int enum_in,int row,IssmDouble* values,int numlayers){/*{{{*/
|
---|
[24335] | 747 |
|
---|
| 748 | bool recreate = false;
|
---|
| 749 |
|
---|
| 750 | /*Get input id*/
|
---|
| 751 | int id = EnumToIndex(enum_in);
|
---|
| 752 |
|
---|
| 753 | /*Create it if necessary*/
|
---|
| 754 | if(this->inputs[id]){
|
---|
[25379] | 755 | if(this->inputs[id]->ObjectEnum()!=ArrayInputEnum){
|
---|
[24335] | 756 | delete this->inputs[id];
|
---|
| 757 | recreate = true;
|
---|
| 758 | }
|
---|
| 759 | }
|
---|
| 760 | else{
|
---|
| 761 | recreate = true;
|
---|
| 762 | }
|
---|
| 763 |
|
---|
| 764 | if(recreate){
|
---|
[25379] | 765 | this->inputs[id] = new ArrayInput(this->numberofelements_local);
|
---|
[24335] | 766 | }
|
---|
| 767 |
|
---|
| 768 | /*Set input*/
|
---|
[25379] | 769 | ArrayInput* input = xDynamicCast<ArrayInput*>(this->inputs[id]);
|
---|
[24335] | 770 | input->SetInput(row,numlayers,values);
|
---|
| 771 | }/*}}}*/
|
---|
[27128] | 772 | void Inputs::SetIntArrayInput(int enum_in,int row,int* values,int numlayers){/*{{{*/
|
---|
| 773 |
|
---|
| 774 | bool recreate = false;
|
---|
| 775 |
|
---|
| 776 | /*Get input id*/
|
---|
| 777 | int id = EnumToIndex(enum_in);
|
---|
| 778 |
|
---|
| 779 | /*Create it if necessary*/
|
---|
| 780 | if(this->inputs[id]){
|
---|
| 781 | if(this->inputs[id]->ObjectEnum()!=IntArrayInputEnum){
|
---|
| 782 | delete this->inputs[id];
|
---|
| 783 | recreate = true;
|
---|
| 784 | }
|
---|
| 785 | }
|
---|
| 786 | else{
|
---|
| 787 | recreate = true;
|
---|
| 788 | }
|
---|
| 789 |
|
---|
| 790 | if(recreate){
|
---|
| 791 | this->inputs[id] = new IntArrayInput(this->numberofelements_local);
|
---|
| 792 | }
|
---|
| 793 |
|
---|
| 794 | /*Set input*/
|
---|
| 795 | IntArrayInput* input = xDynamicCast<IntArrayInput*>(this->inputs[id]);
|
---|
| 796 | input->SetInput(row,numlayers,values);
|
---|
| 797 | }/*}}}*/
|
---|
[25379] | 798 | TransientInput* Inputs::SetDatasetTransientInput(int enum_in,int dataset_id,IssmDouble* times,int numtimes){/*{{{*/
|
---|
[24335] | 799 |
|
---|
| 800 | bool recreate = false;
|
---|
| 801 | /*Get input id*/
|
---|
| 802 | int id = EnumToIndex(enum_in);
|
---|
| 803 |
|
---|
| 804 | /*Create it if necessary*/
|
---|
| 805 | if(this->inputs[id]){
|
---|
[25379] | 806 | if(this->inputs[id]->ObjectEnum()!=DatasetInputEnum){
|
---|
[24335] | 807 | delete this->inputs[id];
|
---|
| 808 | recreate = true;
|
---|
| 809 | }
|
---|
| 810 | }
|
---|
| 811 | else{
|
---|
| 812 | recreate = true;
|
---|
| 813 | }
|
---|
| 814 |
|
---|
| 815 | if(recreate){
|
---|
[25379] | 816 | this->inputs[id] = new DatasetInput(this->numberofelements_local,this->numberofvertices_local);
|
---|
[24335] | 817 | }
|
---|
| 818 |
|
---|
| 819 | /*Get Dataset Input now*/
|
---|
[25379] | 820 | DatasetInput* input = xDynamicCast<DatasetInput*>(this->inputs[id]);
|
---|
[24335] | 821 |
|
---|
| 822 | /*Create and return transient input*/
|
---|
| 823 | return input->SetTransientInput(dataset_id,times,numtimes);
|
---|
| 824 | }/*}}}*/
|
---|
[25379] | 825 | void Inputs::SetTransientInput(int enum_in,IssmDouble* times,int numtimes){/*{{{*/
|
---|
[24335] | 826 |
|
---|
| 827 | /*Get input id*/
|
---|
| 828 | int id = EnumToIndex(enum_in);
|
---|
| 829 |
|
---|
| 830 | /*Create it if necessary*/
|
---|
| 831 | if(this->inputs[id]){
|
---|
| 832 | /*Input already there, make sure it is the right type*/
|
---|
[25379] | 833 | if(this->inputs[id]->ObjectEnum()!=TransientInputEnum){
|
---|
[24335] | 834 | _error_("cannot add a TransientInput to a "<<EnumToStringx(this->inputs[id]->ObjectEnum()));
|
---|
| 835 | }
|
---|
| 836 | }
|
---|
| 837 | else{
|
---|
[25379] | 838 | this->inputs[id] = new TransientInput(enum_in,this->numberofelements_local,this->numberofvertices_local,times,numtimes);
|
---|
[24335] | 839 | }
|
---|
| 840 | }/*}}}*/
|
---|
[25406] | 841 | void Inputs::SetControlInput(int enum_in,int layout,int interpolation,int control_id){/*{{{*/
|
---|
[24335] | 842 |
|
---|
| 843 | bool recreate = false;
|
---|
[25406] | 844 |
|
---|
[24335] | 845 | /*Get input id*/
|
---|
| 846 | int id = EnumToIndex(enum_in);
|
---|
| 847 |
|
---|
| 848 | /*Create it if necessary*/
|
---|
| 849 | if(this->inputs[id]){
|
---|
[25379] | 850 | if(this->inputs[id]->ObjectEnum()!=ControlInputEnum){
|
---|
[24335] | 851 | delete this->inputs[id];
|
---|
| 852 | recreate = true;
|
---|
| 853 | }
|
---|
| 854 | }
|
---|
| 855 | else{
|
---|
| 856 | recreate = true;
|
---|
| 857 | }
|
---|
| 858 |
|
---|
| 859 | if(recreate){
|
---|
[25379] | 860 | this->inputs[id] = new ControlInput(this->numberofelements_local,this->numberofvertices_local,layout,interpolation,control_id);
|
---|
[24335] | 861 | }
|
---|
| 862 |
|
---|
| 863 | }/*}}}*/
|
---|
[25406] | 864 | void Inputs::SetTransientControlInput(int enum_in,int control_id,IssmDouble* times,int numtimes){/*{{{*/
|
---|
| 865 |
|
---|
| 866 | bool recreate = false;
|
---|
| 867 |
|
---|
| 868 | /*Get input id*/
|
---|
| 869 | int id = EnumToIndex(enum_in);
|
---|
| 870 |
|
---|
| 871 | /*Create it if necessary*/
|
---|
| 872 | if(this->inputs[id]){
|
---|
| 873 | if(this->inputs[id]->ObjectEnum()!=ControlInputEnum){
|
---|
| 874 | delete this->inputs[id];
|
---|
| 875 | recreate = true;
|
---|
| 876 | }
|
---|
| 877 | }
|
---|
| 878 | else{
|
---|
| 879 | recreate = true;
|
---|
| 880 | }
|
---|
| 881 |
|
---|
| 882 | if(recreate){
|
---|
| 883 | this->inputs[id] = new ControlInput(enum_in,this->numberofelements_local,this->numberofvertices_local,control_id,times,numtimes);
|
---|
| 884 | }
|
---|
| 885 |
|
---|
| 886 | }/*}}}*/
|
---|
[25379] | 887 | void Inputs::SetTriaControlInputGradient(int enum_in,int interpolation,int numindices,int* indices,IssmDouble* values){/*{{{*/
|
---|
[24335] | 888 |
|
---|
| 889 | /*Get input id*/
|
---|
| 890 | int id = EnumToIndex(enum_in);
|
---|
| 891 |
|
---|
| 892 | /*Create it if necessary*/
|
---|
| 893 | if(!this->inputs[id]) _error_("could not find Input "<<EnumToStringx(enum_in));
|
---|
[25379] | 894 | if( this->inputs[id]->ObjectEnum()!=ControlInputEnum) _error_("Input "<<EnumToStringx(enum_in)<<" is not a ControlInput");
|
---|
[24335] | 895 |
|
---|
| 896 | /*Set input*/
|
---|
[25379] | 897 | ControlInput* input = xDynamicCast<ControlInput*>(this->inputs[id]);
|
---|
[24335] | 898 | input->SetGradient(interpolation,numindices,indices,values);
|
---|
| 899 | }/*}}}*/
|
---|
[25379] | 900 | void Inputs::SetTriaControlInputGradient(int enum_in,int interpolation,int numindices,int* indices,IssmDouble* values,int n){/*{{{*/
|
---|
[24335] | 901 |
|
---|
| 902 | /*Get input id*/
|
---|
| 903 | int id = EnumToIndex(enum_in);
|
---|
| 904 |
|
---|
| 905 | /*Create it if necessary*/
|
---|
| 906 | if(!this->inputs[id]) _error_("could not find Input "<<EnumToStringx(enum_in));
|
---|
[25379] | 907 | if( this->inputs[id]->ObjectEnum()!=ControlInputEnum) _error_("Input "<<EnumToStringx(enum_in)<<" is not a ControlInput");
|
---|
[24335] | 908 |
|
---|
| 909 | /*Set input*/
|
---|
[25379] | 910 | ControlInput* input = xDynamicCast<ControlInput*>(this->inputs[id]);
|
---|
[24335] | 911 | input->SetGradient(interpolation,numindices,indices,values,n);
|
---|
| 912 | }/*}}}*/
|
---|
[25379] | 913 | void Inputs::SetTriaDatasetInput(int enum_in,int id_in,int interpolation,int numindices,int* indices,IssmDouble* values){/*{{{*/
|
---|
[24335] | 914 |
|
---|
| 915 | bool recreate = false;
|
---|
| 916 | /*Get input id*/
|
---|
| 917 | int id = EnumToIndex(enum_in);
|
---|
| 918 |
|
---|
| 919 | /*Create it if necessary*/
|
---|
| 920 | if(this->inputs[id]){
|
---|
[25379] | 921 | if(this->inputs[id]->ObjectEnum()!=DatasetInputEnum){
|
---|
[24335] | 922 | delete this->inputs[id];
|
---|
| 923 | recreate = true;
|
---|
| 924 | }
|
---|
| 925 | }
|
---|
| 926 | else{
|
---|
| 927 | recreate = true;
|
---|
| 928 | }
|
---|
| 929 |
|
---|
| 930 | if(recreate){
|
---|
[25379] | 931 | this->inputs[id] = new DatasetInput(this->numberofelements_local,this->numberofvertices_local);
|
---|
[24335] | 932 | }
|
---|
| 933 |
|
---|
| 934 | /*Set input*/
|
---|
[25379] | 935 | DatasetInput* input = xDynamicCast<DatasetInput*>(this->inputs[id]);
|
---|
[24335] | 936 | input->SetTriaInput(id_in,P1Enum,numindices,indices,values);
|
---|
| 937 | }/*}}}*/
|
---|
[25379] | 938 | void Inputs::SetTriaInput(int enum_in,int interpolation,int row,IssmDouble value){/*{{{*/
|
---|
[24335] | 939 |
|
---|
| 940 | /*This one only supports P0 and P1 because it assumes col=0*/
|
---|
[24565] | 941 | _assert_(interpolation==P0Enum || interpolation==P1Enum);
|
---|
[24335] | 942 |
|
---|
| 943 | /*Get input id*/
|
---|
| 944 | int id = EnumToIndex(enum_in);
|
---|
| 945 |
|
---|
| 946 | /*Create it if necessary*/
|
---|
| 947 | if(this->inputs[id]){
|
---|
[25379] | 948 | if(this->inputs[id]->ObjectEnum()!=TriaInputEnum) _error_("cannot add a bool to a "<<EnumToStringx(this->inputs[id]->ObjectEnum()));
|
---|
[24335] | 949 | }
|
---|
| 950 | else{
|
---|
[25379] | 951 | this->inputs[id] = new TriaInput(this->numberofelements_local,this->numberofvertices_local,interpolation);
|
---|
[24335] | 952 | }
|
---|
| 953 |
|
---|
| 954 | /*Set input*/
|
---|
[25379] | 955 | TriaInput* input = xDynamicCast<TriaInput*>(this->inputs[id]);
|
---|
[24335] | 956 | input->SetInput(interpolation,row,value);
|
---|
| 957 | }/*}}}*/
|
---|
[25379] | 958 | void Inputs::SetTriaInput(int enum_in,int interpolation,int numindices,int* indices,IssmDouble* values){/*{{{*/
|
---|
[24335] | 959 |
|
---|
| 960 | /*Get input id*/
|
---|
| 961 | int id = EnumToIndex(enum_in);
|
---|
| 962 |
|
---|
| 963 | /*Create it if necessary*/
|
---|
| 964 | if(this->inputs[id]){
|
---|
[25379] | 965 | if(this->inputs[id]->ObjectEnum()!=TriaInputEnum){
|
---|
[24365] | 966 | _error_("cannot add Element values to a "<<EnumToStringx(this->inputs[id]->ObjectEnum())<<" while trying to set "<<EnumToStringx(enum_in));
|
---|
| 967 | }
|
---|
[24335] | 968 | }
|
---|
| 969 | else{
|
---|
[25379] | 970 | this->inputs[id] = new TriaInput(this->numberofelements_local,this->numberofvertices_local,interpolation);
|
---|
[24335] | 971 | }
|
---|
| 972 |
|
---|
| 973 | /*Set input*/
|
---|
[25379] | 974 | TriaInput* input = xDynamicCast<TriaInput*>(this->inputs[id]);
|
---|
[24335] | 975 | input->SetInput(interpolation,numindices,indices,values);
|
---|
| 976 | }/*}}}*/
|
---|
[25379] | 977 | void Inputs::SetTriaInput(int enum_in,int interpolation,int row,int numindices,IssmDouble* values){/*{{{*/
|
---|
[24335] | 978 |
|
---|
| 979 | /*Get input id*/
|
---|
| 980 | int id = EnumToIndex(enum_in);
|
---|
| 981 |
|
---|
| 982 | /*Create it if necessary*/
|
---|
| 983 | if(this->inputs[id]){
|
---|
[25379] | 984 | if(this->inputs[id]->ObjectEnum()!=TriaInputEnum) _error_("cannot add Element values to a "<<EnumToStringx(this->inputs[id]->ObjectEnum()));
|
---|
[24335] | 985 | }
|
---|
| 986 | else{
|
---|
[25379] | 987 | this->inputs[id] = new TriaInput(this->numberofelements_local,this->numberofvertices_local,interpolation);
|
---|
[24335] | 988 | }
|
---|
| 989 |
|
---|
| 990 | /*Set input*/
|
---|
[25379] | 991 | TriaInput* input = xDynamicCast<TriaInput*>(this->inputs[id]);
|
---|
[24335] | 992 | input->SetInput(interpolation,row,numindices,values);
|
---|
| 993 | }/*}}}*/
|
---|
[25379] | 994 | void Inputs::SetPentaControlInputGradient(int enum_in,int interpolation,int numindices,int* indices,IssmDouble* values){/*{{{*/
|
---|
[24335] | 995 |
|
---|
| 996 | /*Get input id*/
|
---|
| 997 | int id = EnumToIndex(enum_in);
|
---|
| 998 |
|
---|
| 999 | /*Create it if necessary*/
|
---|
| 1000 | if(!this->inputs[id]) _error_("could not find Input "<<EnumToStringx(enum_in));
|
---|
[25379] | 1001 | if( this->inputs[id]->ObjectEnum()!=ControlInputEnum) _error_("Input "<<EnumToStringx(enum_in)<<" is not a ControlInput");
|
---|
[24335] | 1002 |
|
---|
| 1003 | /*Set input*/
|
---|
[25379] | 1004 | ControlInput* input = xDynamicCast<ControlInput*>(this->inputs[id]);
|
---|
[24335] | 1005 | input->SetGradient(interpolation,numindices,indices,values);
|
---|
| 1006 | }/*}}}*/
|
---|
[25379] | 1007 | void Inputs::SetPentaDatasetInput(int enum_in,int id_in,int interpolation,int numindices,int* indices,IssmDouble* values){/*{{{*/
|
---|
[24335] | 1008 |
|
---|
| 1009 | bool recreate = false;
|
---|
| 1010 | /*Get input id*/
|
---|
| 1011 | int id = EnumToIndex(enum_in);
|
---|
| 1012 |
|
---|
| 1013 | /*Create it if necessary*/
|
---|
| 1014 | if(this->inputs[id]){
|
---|
[25379] | 1015 | if(this->inputs[id]->ObjectEnum()!=DatasetInputEnum){
|
---|
[24335] | 1016 | delete this->inputs[id];
|
---|
| 1017 | recreate = true;
|
---|
| 1018 | }
|
---|
| 1019 | }
|
---|
| 1020 | else{
|
---|
| 1021 | recreate = true;
|
---|
| 1022 | }
|
---|
| 1023 |
|
---|
| 1024 | if(recreate){
|
---|
[25379] | 1025 | this->inputs[id] = new DatasetInput(this->numberofelements_local,this->numberofvertices_local);
|
---|
[24335] | 1026 | }
|
---|
| 1027 |
|
---|
| 1028 | /*Set input*/
|
---|
[25379] | 1029 | DatasetInput* input = xDynamicCast<DatasetInput*>(this->inputs[id]);
|
---|
[24335] | 1030 | input->SetPentaInput(id_in,P1Enum,numindices,indices,values);
|
---|
| 1031 | }/*}}}*/
|
---|
[25379] | 1032 | void Inputs::SetPentaInput(int enum_in,int interpolation,int row,IssmDouble value){/*{{{*/
|
---|
[24335] | 1033 |
|
---|
| 1034 | /*This one only supports P0 and P1 because it assumes col=0*/
|
---|
[24565] | 1035 | _assert_(interpolation==P0Enum || interpolation==P1Enum);
|
---|
[24335] | 1036 |
|
---|
| 1037 | /*Get input id*/
|
---|
| 1038 | int id = EnumToIndex(enum_in);
|
---|
| 1039 |
|
---|
| 1040 | /*Create it if necessary*/
|
---|
| 1041 | if(this->inputs[id]){
|
---|
[25379] | 1042 | if(this->inputs[id]->ObjectEnum()!=PentaInputEnum) _error_("cannot add a bool to a "<<EnumToStringx(this->inputs[id]->ObjectEnum()));
|
---|
[24335] | 1043 | }
|
---|
| 1044 | else{
|
---|
[25379] | 1045 | this->inputs[id] = new PentaInput(this->numberofelements_local,this->numberofvertices_local,interpolation);
|
---|
[24335] | 1046 | }
|
---|
| 1047 |
|
---|
| 1048 | /*Set input*/
|
---|
[25379] | 1049 | PentaInput* input = xDynamicCast<PentaInput*>(this->inputs[id]);
|
---|
[24335] | 1050 | input->SetInput(interpolation,row,value);
|
---|
| 1051 | }/*}}}*/
|
---|
[25379] | 1052 | void Inputs::SetPentaInput(int enum_in,int interpolation,int numindices,int* indices,IssmDouble* values){/*{{{*/
|
---|
[24335] | 1053 |
|
---|
| 1054 | /*Get input id*/
|
---|
| 1055 | int id = EnumToIndex(enum_in);
|
---|
| 1056 |
|
---|
| 1057 | /*Create it if necessary*/
|
---|
| 1058 | if(this->inputs[id]){
|
---|
[25379] | 1059 | if(this->inputs[id]->ObjectEnum()!=PentaInputEnum) _error_("cannot add Element values to a "<<EnumToStringx(this->inputs[id]->ObjectEnum()));
|
---|
[24335] | 1060 | }
|
---|
| 1061 | else{
|
---|
[25379] | 1062 | this->inputs[id] = new PentaInput(this->numberofelements_local,this->numberofvertices_local,interpolation);
|
---|
[24335] | 1063 | }
|
---|
| 1064 |
|
---|
| 1065 | /*Set input*/
|
---|
[25379] | 1066 | PentaInput* input = xDynamicCast<PentaInput*>(this->inputs[id]);
|
---|
[24335] | 1067 | input->SetInput(interpolation,numindices,indices,values);
|
---|
| 1068 | }/*}}}*/
|
---|
[25379] | 1069 | void Inputs::SetPentaInput(int enum_in,int interpolation,int row,int numindices,IssmDouble* values){/*{{{*/
|
---|
[24335] | 1070 |
|
---|
| 1071 | /*Get input id*/
|
---|
| 1072 | int id = EnumToIndex(enum_in);
|
---|
| 1073 |
|
---|
| 1074 | /*Create it if necessary*/
|
---|
| 1075 | if(this->inputs[id]){
|
---|
[25379] | 1076 | if(this->inputs[id]->ObjectEnum()!=PentaInputEnum) _error_("cannot add Element values to a "<<EnumToStringx(this->inputs[id]->ObjectEnum()));
|
---|
[24335] | 1077 | }
|
---|
| 1078 | else{
|
---|
[25379] | 1079 | this->inputs[id] = new PentaInput(this->numberofelements_local,this->numberofvertices_local,interpolation);
|
---|
[24335] | 1080 | }
|
---|
| 1081 |
|
---|
| 1082 | /*Set input*/
|
---|
[25379] | 1083 | PentaInput* input = xDynamicCast<PentaInput*>(this->inputs[id]);
|
---|
[24335] | 1084 | input->SetInput(interpolation,row,numindices,values);
|
---|
| 1085 | }/*}}}*/
|
---|