Ice Sheet System Model  4.18
Code documentation
DoubleMatParam.cpp
Go to the documentation of this file.
1 
5 /*header files: */
6 /*{{{*/
7 #ifdef HAVE_CONFIG_H
8  #include <config.h>
9 #else
10 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
11 #endif
12 
13 #include "../classes.h"
14 #include "shared/shared.h"
15 /*}}}*/
16 
17 /*DoubleMatParam constructors and destructor*/
19  return;
20 }
21 /*}}}*/
22 DoubleMatParam::DoubleMatParam(int in_enum_type,IssmDouble* in_value, int in_M,int in_N){/*{{{*/
23 
24  enum_type=in_enum_type;
25  M=in_M;
26  N=in_N;
27 
28  value=xNew<IssmDouble>(M*N);
29  xMemCpy<IssmDouble>(value,in_value,M*N);
30 }
31 /*}}}*/
33  xDelete<IssmDouble>(value);
34  return;
35 }
36 /*}}}*/
37 
38 /*Object virtual functions definitions:*/
39 void DoubleMatParam::Echo(void){/*{{{*/
40 
41  _printf_("DoubleMatParam:\n");
42  _printf_(" enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")\n");
43  _printf_(" matrix size: " << this->M << "x" << this->N << "\n");
44 
45 }
46 /*}}}*/
47 void DoubleMatParam::DeepEcho(void){/*{{{*/
48 
49  int i,j;
50 
51  _printf_("DoubleMatParam:\n");
52  _printf_(" enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")\n");
53  _printf_(" matrix size: " << this->M << "x" << this->N << "\n");
54  for(i=0;i<this->M;i++){
55  for(j=0;j<this->N;j++){
56  _printf_(i << " " << j << " " << *(this->value+N*i+j) << "\n");
57  }
58  }
59 }
60 /*}}}*/
61 int DoubleMatParam::Id(void){ return -1; }/*{{{*/
62 /*}}}*/
63 int DoubleMatParam::ObjectEnum(void){/*{{{*/
64 
65  return DoubleMatParamEnum;
66 
67 }
68 /*}}}*/
70 
71  return new DoubleMatParam(this->enum_type,this->value,this->M,this->N);
72 
73 }
74 /*}}}*/
75 void DoubleMatParam::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
76 
78 
80  MARSHALLING(M);
81  MARSHALLING(N);
83 }
84 /*}}}*/
85 
86 /*DoubleMatParam virtual functions definitions: */
87 void DoubleMatParam::GetParameterValue(IssmDouble** pIssmDoublearray,int* pM,int* pN){/*{{{*/
88  IssmDouble* output=NULL;
89 
90  output=xNew<IssmDouble>(M*N);
91  xMemCpy<IssmDouble>(output,value,M*N);
92 
93  /*Assign output pointers:*/
94  if(pM) *pM=M;
95  if(pN) *pN=N;
96  *pIssmDoublearray=output;
97 }
98 /*}}}*/
99 void DoubleMatParam::GetParameterValue(int** pintarray,int* pM,int* pN){/*{{{*/
100  _error_("DoubleMat of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an array of int");
101 }
102 /*}}}*/
103 void DoubleMatParam::SetValue(IssmDouble* IssmDoublearray,int in_M,int in_N){/*{{{*/
104 
105  /*avoid leak: */
106  xDelete<IssmDouble>(this->value);
107 
108  this->value=xNew<IssmDouble>(in_M*in_N);
109  xMemCpy<IssmDouble>(this->value,IssmDoublearray,in_M*in_N);
110 
111  this->M=in_M;
112  this->N=in_N;
113 }
114 /*}}}*/
115 
116 /*DoubleMatParam specific routines:*/
117 void DoubleMatParam::GetParameterValueByPointer(IssmDouble** pIssmDoublearray,int* pM,int* pN){/*{{{*/
118 
119  /*Assign output pointers:*/
120  if(pM) *pM=M;
121  if(pN) *pN=N;
122  *pIssmDoublearray=value;
123 }
124 /*}}}*/
DoubleMatParam::copy
Param * copy()
Definition: DoubleMatParam.cpp:69
DoubleMatParam::enum_type
int enum_type
Definition: DoubleMatParam.h:23
DoubleMatParam::M
int M
Definition: DoubleMatParam.h:25
IssmDouble
double IssmDouble
Definition: types.h:37
Param
Definition: Param.h:21
DoubleMatParam::GetParameterValue
void GetParameterValue(bool *pbool)
Definition: DoubleMatParam.h:44
_printf_
#define _printf_(StreamArgs)
Definition: Print.h:22
MARSHALLING_ENUM
#define MARSHALLING_ENUM(EN)
Definition: Marshalling.h:14
DoubleMatParam::Id
int Id()
Definition: DoubleMatParam.cpp:61
DoubleMatParam::DeepEcho
void DeepEcho()
Definition: DoubleMatParam.cpp:47
MARSHALLING_DYNAMIC
#define MARSHALLING_DYNAMIC(FIELD, TYPE, SIZE)
Definition: Marshalling.h:61
DoubleMatParam::value
IssmDouble * value
Definition: DoubleMatParam.h:24
DoubleMatParam::N
int N
Definition: DoubleMatParam.h:26
EnumToStringx
const char * EnumToStringx(int enum_in)
Definition: EnumToStringx.cpp:15
MARSHALLING
#define MARSHALLING(FIELD)
Definition: Marshalling.h:29
DoubleMatParam::Echo
void Echo()
Definition: DoubleMatParam.cpp:39
_error_
#define _error_(StreamArgs)
Definition: exceptions.h:49
DoubleMatParamEnum
@ DoubleMatParamEnum
Definition: EnumDefinitions.h:1046
DoubleMatParam::~DoubleMatParam
~DoubleMatParam()
Definition: DoubleMatParam.cpp:32
DoubleMatParam::ObjectEnum
int ObjectEnum()
Definition: DoubleMatParam.cpp:63
DoubleMatParam::GetParameterValueByPointer
void GetParameterValueByPointer(IssmDouble **pIssmDoublearray, int *pM, int *pN)
Definition: DoubleMatParam.cpp:117
DoubleMatParam::DoubleMatParam
DoubleMatParam()
Definition: DoubleMatParam.cpp:18
DoubleMatParam::SetValue
void SetValue(bool boolean)
Definition: DoubleMatParam.h:60
shared.h
DoubleMatParam::Marshall
void Marshall(char **pmarshalled_data, int *pmarshalled_data_size, int marshall_direction)
Definition: DoubleMatParam.cpp:75