Ice Sheet System Model  4.18
Code documentation
Functions
OutputDefinitionsResponsex.cpp File Reference
#include "./OutputDefinitionsResponsex.h"
#include "../../shared/shared.h"
#include "../../toolkits/toolkits.h"
#include "../../classes/classes.h"

Go to the source code of this file.

Functions

IssmDouble OutputDefinitionsResponsex (FemModel *femmodel, const char *output_string)
 
IssmDouble OutputDefinitionsResponsex (FemModel *femmodel, int output_enum)
 

Function Documentation

◆ OutputDefinitionsResponsex() [1/2]

IssmDouble OutputDefinitionsResponsex ( FemModel femmodel,
const char *  output_string 
)

Definition at line 10 of file OutputDefinitionsResponsex.cpp.

10  {
11 
12  /*Ok, go find the output definitions dataset in the parameters, where our responses are hiding: */
14 
15  /*Now, go through the output definitions, and retrieve the object which corresponds to our requested response, output_string: */
16  for(int i=0;i<output_definitions->Size();i++){
17  Definition* definition=dynamic_cast<Definition*>(output_definitions->GetObjectByOffset(i));
18 
19  char* name = definition->Name();
20  if(strcmp(name,output_string)==0){
21 
22  /*This is the object that we have been chasing for. compute the response and return: */
23  IssmDouble return_value=definition->Response(femmodel);
24 
25  /*cleanup: */
26  xDelete<char>(name);
27 
28  /*return:*/
29  return return_value;
30  }
31  xDelete<char>(name);
32  }
33 
34  /*If we are here, did not find the definition for this response, not good!: */
35  _error_("Could not find the response for output definition " << output_string << " because could not find the definition itself!");
36 }

◆ OutputDefinitionsResponsex() [2/2]

IssmDouble OutputDefinitionsResponsex ( FemModel femmodel,
int  output_enum 
)

Definition at line 38 of file OutputDefinitionsResponsex.cpp.

38  {
39 
40  /*Ok, go find the output definitions dataset in the parameters, where our responses are hiding: */
42 
43  /*Now, go through the output definitions, and retrieve the object which corresponds to our requested response, output_enum: */
44  for(int i=0;i<output_definitions->Size();i++){
45 
46  //Definition* definition=xDynamicCast<Definition*>(output_definitions->GetObjectByOffset(i));
47  Definition* definition=dynamic_cast<Definition*>(output_definitions->GetObjectByOffset(i));
48 
49  int en = definition->DefinitionEnum();
50  if(en==output_enum){
51 
52  /*This is the object that we have been chasing for. compute the response and return: */
53  IssmDouble return_value=definition->Response(femmodel);
54 
55  /*return:*/
56  return return_value;
57  }
58  }
59 
60  /*If we are here, did not find the definition for this response, not good!: */
61  _error_("Could not find the response for output definition " << EnumToStringx(output_enum)
62  <<" ("<<output_enum<<")"
63  << " because could not find the definition itself!");
64 }
DataSet::Size
int Size()
Definition: DataSet.cpp:399
Definition::Response
virtual IssmDouble Response(FemModel *)=0
Definition::Name
virtual char * Name()=0
IssmDouble
double IssmDouble
Definition: types.h:37
FemModel::parameters
Parameters * parameters
Definition: FemModel.h:46
OutputdefinitionEnum
@ OutputdefinitionEnum
Definition: EnumDefinitions.h:285
EnumToStringx
const char * EnumToStringx(int enum_in)
Definition: EnumToStringx.cpp:15
Definition
Definition: Definition.h:10
DataSetParam
Definition: DataSetParam.h:20
Definition::DefinitionEnum
virtual int DefinitionEnum()=0
_error_
#define _error_(StreamArgs)
Definition: exceptions.h:49
DataSet::GetObjectByOffset
Object * GetObjectByOffset(int offset)
Definition: DataSet.cpp:334
Parameters::FindParamObject
Param * FindParamObject(int enum_type)
Definition: Parameters.cpp:588
DataSet
Declaration of DataSet class.
Definition: DataSet.h:14
femmodel
FemModel * femmodel
Definition: esmfbinders.cpp:16