Ice Sheet System Model
4.18
Code documentation
src
c
modules
OutputDefinitionsResponsex
OutputDefinitionsResponsex.cpp
Go to the documentation of this file.
1
5
#include "
./OutputDefinitionsResponsex.h
"
6
#include "../../shared/shared.h"
7
#include "../../toolkits/toolkits.h"
8
#include "../../classes/classes.h"
9
10
IssmDouble
OutputDefinitionsResponsex
(
FemModel
*
femmodel
,
const
char
* output_string){
11
12
/*Ok, go find the output definitions dataset in the parameters, where our responses are hiding: */
13
DataSet
* output_definitions=((
DataSetParam
*)
femmodel
->
parameters
->
FindParamObject
(
OutputdefinitionEnum
))->value;
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
}
37
38
IssmDouble
OutputDefinitionsResponsex
(
FemModel
*
femmodel
,
int
output_enum){
39
40
/*Ok, go find the output definitions dataset in the parameters, where our responses are hiding: */
41
DataSet
* output_definitions=((
DataSetParam
*)
femmodel
->
parameters
->
FindParamObject
(
OutputdefinitionEnum
))->value;
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
OutputDefinitionsResponsex.h
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
FemModel
Definition:
FemModel.h:31
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
OutputDefinitionsResponsex
IssmDouble OutputDefinitionsResponsex(FemModel *femmodel, const char *output_string)
Definition:
OutputDefinitionsResponsex.cpp:10
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
Generated on Thu Jul 2 2020 08:09:19 for Ice Sheet System Model by
1.8.19