Ice Sheet System Model  4.18
Code documentation
Public Member Functions | Private Attributes
DatasetInput2 Class Reference

#include <DatasetInput2.h>

Inheritance diagram for DatasetInput2:
Input2 Object

Public Member Functions

int GetNumIds () const
 
 DatasetInput2 ()
 
 DatasetInput2 (int nbe, int nbv)
 
 ~DatasetInput2 ()
 
Input2copy ()
 
void Configure (Parameters *params)
 
void DeepEcho ()
 
void Echo ()
 
int Id ()
 
void Marshall (char **pmarshalled_data, int *pmarshalled_data_size, int marshall_direction)
 
int ObjectEnum ()
 
void SetTriaInput (int interp_in, int numinds, int *rows, IssmDouble *values_in)
 
void SetTriaInput (int id, int interp_in, int numinds, int *rows, IssmDouble *values_in)
 
void SetPentaInput (int id, int interp_in, int numinds, int *rows, IssmDouble *values_in)
 
TransientInput2SetTransientInput (int id, IssmDouble *times, int numtimes)
 
PentaInput2GetPentaInputByOffset (int i)
 
TriaInput2GetTriaInputByOffset (int i)
 
void GetInputValue (IssmDouble *pvalue, Gauss *gauss, int index)
 
- Public Member Functions inherited from Input2
int InstanceEnum ()
 
void ChangeEnum (int newenumtype)
 
virtual ~Input2 ()
 
virtual void GetInputAverage (IssmDouble *pvalue)
 
virtual IssmDouble GetInputMax (void)
 
virtual IssmDouble GetInputMaxAbs (void)
 
virtual IssmDouble GetInputMin (void)
 
virtual void GetInputDerivativeValue (IssmDouble *derivativevalues, IssmDouble *xyz_list, Gauss *gauss)
 
virtual void GetInputValue (IssmDouble *pvalue, Gauss *gauss)
 
virtual int GetInputInterpolationType ()
 
virtual SegInput2GetSegInput ()
 
virtual TriaInput2GetTriaInput ()
 
virtual PentaInput2GetPentaInput ()
 
virtual void AXPY (Input2 *xinput, IssmDouble scalar)
 
virtual void PointWiseMult (Input2 *xinput)
 
virtual void Pow (IssmDouble scale_factor)
 
virtual void Scale (IssmDouble scale_factor)
 
virtual int GetResultArraySize (void)
 
virtual int GetResultInterpolation (void)
 
virtual int GetResultNumberOfNodes (void)
 
- Public Member Functions inherited from Object
virtual ~Object ()
 

Private Attributes

int numids
 
Input2 ** inputs
 
int * ids
 
int numberofelements_local
 
int numberofvertices_local
 

Detailed Description

Definition at line 14 of file DatasetInput2.h.

Constructor & Destructor Documentation

◆ DatasetInput2() [1/2]

DatasetInput2::DatasetInput2 ( )

Definition at line 17 of file DatasetInput2.cpp.

17  {/*{{{*/
18  this->inputs = NULL;
19  this->numids = 0;
20  this->ids = NULL;
21  this->numberofelements_local = -1;
22  this->numberofvertices_local = -1;
23 }

◆ DatasetInput2() [2/2]

DatasetInput2::DatasetInput2 ( int  nbe,
int  nbv 
)

Definition at line 25 of file DatasetInput2.cpp.

25  {/*{{{*/
26  this->inputs = NULL;
27  this->numids = 0;
28  this->ids = NULL;
29  this->numberofelements_local = nbe;
30  this->numberofvertices_local = nbv;
31 }

◆ ~DatasetInput2()

DatasetInput2::~DatasetInput2 ( )

Definition at line 33 of file DatasetInput2.cpp.

33  {/*{{{*/
34  xDelete<int>(this->ids);
35  for(int i=0;i<this->numids;i++){
36  delete this->inputs[i];
37  }
38  xDelete<Input2*>(this->inputs);
39 }

Member Function Documentation

◆ GetNumIds()

int DatasetInput2::GetNumIds ( ) const
inline

Definition at line 24 of file DatasetInput2.h.

24 {return this->numids;};

◆ copy()

Input2 * DatasetInput2::copy ( void  )
virtual

Implements Input2.

Definition at line 43 of file DatasetInput2.cpp.

43  {/*{{{*/
44 
45  DatasetInput2* output=NULL;
46 
47  output = new DatasetInput2();
48  output->numids=this->numids;
49  if(this->numids>0){
50  output->ids=xNew<int>(output->numids);
51  xMemCpy(output->ids,this->ids,output->numids);
52  output->inputs = xNew<Input2*>(this->numids);
53  for(int i=0;i<this->numids;i++){
54  output->inputs[i] = this->inputs[i]->copy();
55  }
56  }
57 
58  return output;
59 }

◆ Configure()

void DatasetInput2::Configure ( Parameters params)
virtual

Reimplemented from Input2.

Definition at line 61 of file DatasetInput2.cpp.

61  {/*{{{*/
62  for(int i=0;i<this->numids;i++){
63  this->inputs[i]->Configure(params);
64  }
65 }

◆ DeepEcho()

void DatasetInput2::DeepEcho ( void  )
virtual

Implements Object.

Definition at line 67 of file DatasetInput2.cpp.

67  {/*{{{*/
68 
69  _printf_("DatasetInput2:\n");
70  _printf_(" numids:"<< this->numids<< "\n");
71  _printf_(" ids: ");
72  for(int i=0;i<this->numids;i++) _printf_(this->ids[i]<<" ("<<EnumToStringx(this->ids[i])<<") ");
73  _printf_("\n");
74  //_printf_(" inputs: \n"); inputs->Echo();
75 }

◆ Echo()

void DatasetInput2::Echo ( void  )
virtual

Implements Object.

Definition at line 77 of file DatasetInput2.cpp.

77  {/*{{{*/
78  this->DeepEcho();
79 }

◆ Id()

int DatasetInput2::Id ( void  )
virtual

Implements Object.

Definition at line 81 of file DatasetInput2.cpp.

81 { return -1; }/*{{{*/

◆ Marshall()

void DatasetInput2::Marshall ( char **  pmarshalled_data,
int *  pmarshalled_data_size,
int  marshall_direction 
)
virtual

Implements Object.

Definition at line 83 of file DatasetInput2.cpp.

83  { /*{{{*/
84 
86 
91  //if (marshall_direction == MARSHALLING_BACKWARD) inputs = new Inputs();
92  //inputs->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
93  _error_("not implemented");
94 
95 }

◆ ObjectEnum()

int DatasetInput2::ObjectEnum ( void  )
virtual

Implements Object.

Definition at line 97 of file DatasetInput2.cpp.

97  {/*{{{*/
98  return DatasetInput2Enum;
99 }/*}}}*/

◆ SetTriaInput() [1/2]

void DatasetInput2::SetTriaInput ( int  interp_in,
int  numinds,
int *  rows,
IssmDouble values_in 
)

◆ SetTriaInput() [2/2]

void DatasetInput2::SetTriaInput ( int  id,
int  interp_in,
int  numinds,
int *  rows,
IssmDouble values_in 
)

Definition at line 101 of file DatasetInput2.cpp.

101  { /*{{{*/
102 
103  int index = -1;
104  for(int i=0;i<this->numids;i++){
105  if(this->ids[i] == id) index = i;
106  }
107 
108  /*Create new input if not found*/
109  if(index == -1){
110  int* new_ids = xNew<int>(this->numids+1);
111  if(this->numids) xMemCpy(new_ids,this->ids,this->numids);
112  new_ids[this->numids] = id;
113 
114  Input2** new_inputs = xNew<Input2*>(this->numids+1);
115  if(this->numids) xMemCpy(new_inputs,this->inputs,this->numids);
116  new_inputs[this->numids] = new TriaInput2(this->numberofelements_local,this->numberofvertices_local,interp_in);
117  index = this->numids;
118 
119  xDelete<int>(this->ids);
120  this->ids = new_ids;
121  xDelete<Input2*>(this->inputs);
122  this->inputs = new_inputs;
123 
124  this->numids ++;
125  }
126 
127  /*Set input*/
128  if(this->inputs[index]->ObjectEnum()!=TriaInput2Enum) _error_("cannot add Element values to a "<<EnumToStringx(this->inputs[index]->ObjectEnum()));
129  TriaInput2* input = xDynamicCast<TriaInput2*>(this->inputs[index]);
130  input->SetInput(interp_in,numinds,rows,values_in);
131 
132 }

◆ SetPentaInput()

void DatasetInput2::SetPentaInput ( int  id,
int  interp_in,
int  numinds,
int *  rows,
IssmDouble values_in 
)

Definition at line 134 of file DatasetInput2.cpp.

134  { /*{{{*/
135 
136  int index = -1;
137  for(int i=0;i<this->numids;i++){
138  if(this->ids[i] == id) index = i;
139  }
140 
141  /*Create new input if not found*/
142  if(index == -1){
143  int* new_ids = xNew<int>(this->numids+1);
144  if(this->numids) xMemCpy(new_ids,this->ids,this->numids);
145  new_ids[this->numids] = id;
146 
147  Input2** new_inputs = xNew<Input2*>(this->numids+1);
148  if(this->numids) xMemCpy(new_inputs,this->inputs,this->numids);
149  new_inputs[this->numids] = new PentaInput2(this->numberofelements_local,this->numberofvertices_local,interp_in);
150  index = this->numids;
151 
152  xDelete<int>(this->ids);
153  this->ids = new_ids;
154  xDelete<Input2*>(this->inputs);
155  this->inputs = new_inputs;
156 
157  this->numids ++;
158  }
159 
160  /*Set input*/
161  if(this->inputs[index]->ObjectEnum()!=PentaInput2Enum) _error_("cannot add Element values to a "<<EnumToStringx(this->inputs[index]->ObjectEnum()));
162  PentaInput2* input = xDynamicCast<PentaInput2*>(this->inputs[index]);
163  input->SetInput(interp_in,numinds,rows,values_in);
164 
165 }

◆ SetTransientInput()

TransientInput2 * DatasetInput2::SetTransientInput ( int  id,
IssmDouble times,
int  numtimes 
)

Definition at line 167 of file DatasetInput2.cpp.

167  { /*{{{*/
168 
169  int index = -1;
170  for(int i=0;i<this->numids;i++){
171  if(this->ids[i] == id) index = i;
172  }
173 
174  /*Create new input if not found*/
175  if(index == -1){
176  int* new_ids = xNew<int>(this->numids+1);
177  if(this->numids) xMemCpy(new_ids,this->ids,this->numids);
178  new_ids[this->numids] = id;
179 
180  Input2** new_inputs = xNew<Input2*>(this->numids+1);
181  if(this->numids) xMemCpy(new_inputs,this->inputs,this->numids);
182  new_inputs[this->numids] = new TransientInput2(NoneEnum,this->numberofelements_local,this->numberofvertices_local,times,numtimes);
183  index = this->numids;
184 
185  xDelete<int>(this->ids);
186  this->ids = new_ids;
187  xDelete<Input2*>(this->inputs);
188  this->inputs = new_inputs;
189 
190  this->numids ++;
191  }
192 
193  /*Set input*/
194  if(this->inputs[index]->ObjectEnum()!=TransientInput2Enum) _error_("cannot add values to a "<<EnumToStringx(this->inputs[index]->ObjectEnum()));
195  TransientInput2* input = xDynamicCast<TransientInput2*>(this->inputs[index]);
196  return input;
197 }

◆ GetPentaInputByOffset()

PentaInput2 * DatasetInput2::GetPentaInputByOffset ( int  i)

Definition at line 237 of file DatasetInput2.cpp.

237  {/*{{{*/
238 
239  _assert_(offset>=0 && offset<this->numids);
240  _assert_(this->inputs[offset]);
241 
242  /*Cast and return*/
243  if(this->inputs[offset]->ObjectEnum()==TransientInput2Enum){
244  return xDynamicCast<TransientInput2*>(this->inputs[offset])->GetPentaInput();
245  }
246  if(this->inputs[offset]->ObjectEnum()!=PentaInput2Enum){
247  _error_("Cannot return a PentaInput2");
248  }
249  return xDynamicCast<PentaInput2*>(this->inputs[offset]);
250 
251 }/*}}}*/

◆ GetTriaInputByOffset()

TriaInput2 * DatasetInput2::GetTriaInputByOffset ( int  i)

Definition at line 222 of file DatasetInput2.cpp.

222  {/*{{{*/
223 
224  _assert_(offset>=0 && offset<this->numids);
225  _assert_(this->inputs[offset]);
226 
227  /*Cast and return*/
228  if(this->inputs[offset]->ObjectEnum()==TransientInput2Enum){
229  return xDynamicCast<TransientInput2*>(this->inputs[offset])->GetTriaInput();
230  }
231  if(this->inputs[offset]->ObjectEnum()!=TriaInput2Enum){
232  _error_("Cannot return a TriaInput2");
233  }
234  return xDynamicCast<TriaInput2*>(this->inputs[offset]);
235 
236 }/*}}}*/

◆ GetInputValue()

void DatasetInput2::GetInputValue ( IssmDouble pvalue,
Gauss gauss,
int  index 
)

Definition at line 199 of file DatasetInput2.cpp.

199  { /*{{{*/
200 
201  int index = -1;
202  for(int i=0;i<this->numids;i++){
203  if(this->ids[i] == id) index = i;
204  }
205 
206  /*Create new input if not found*/
207  if(index == -1){
208  this->Echo();
209  _error_("Could not find input "<<id<<" ("<<EnumToStringx(id)<<"?) in DatasetInput");
210  }
211 
212  Input2* input = this->inputs[index];
213 
214  if(this->inputs[index]->ObjectEnum()==TransientInput2Enum){
215  input = xDynamicCast<TransientInput2*>(this->inputs[index])->current_input;
216  }
217 
218  input->GetInputValue(pvalue,gauss);
219 
220 }

Field Documentation

◆ numids

int DatasetInput2::numids
private

Definition at line 17 of file DatasetInput2.h.

◆ inputs

Input2** DatasetInput2::inputs
private

Definition at line 18 of file DatasetInput2.h.

◆ ids

int* DatasetInput2::ids
private

Definition at line 19 of file DatasetInput2.h.

◆ numberofelements_local

int DatasetInput2::numberofelements_local
private

Definition at line 20 of file DatasetInput2.h.

◆ numberofvertices_local

int DatasetInput2::numberofvertices_local
private

Definition at line 21 of file DatasetInput2.h.


The documentation for this class was generated from the following files:
DatasetInput2::Echo
void Echo()
Definition: DatasetInput2.cpp:77
TransientInput2Enum
@ TransientInput2Enum
Definition: EnumDefinitions.h:1315
_assert_
#define _assert_(ignore)
Definition: exceptions.h:37
DatasetInput2::numids
int numids
Definition: DatasetInput2.h:17
DatasetInput2
Definition: DatasetInput2.h:14
_printf_
#define _printf_(StreamArgs)
Definition: Print.h:22
DatasetInput2Enum
@ DatasetInput2Enum
Definition: EnumDefinitions.h:1031
MARSHALLING_ENUM
#define MARSHALLING_ENUM(EN)
Definition: Marshalling.h:14
PentaInput2::SetInput
void SetInput(int interp_in, int row, IssmDouble value_in)
Definition: PentaInput2.cpp:154
TransientInput2
Definition: TransientInput2.h:13
Input2::copy
virtual Input2 * copy()=0
MARSHALLING_DYNAMIC
#define MARSHALLING_DYNAMIC(FIELD, TYPE, SIZE)
Definition: Marshalling.h:61
TriaInput2Enum
@ TriaInput2Enum
Definition: EnumDefinitions.h:1124
EnumToStringx
const char * EnumToStringx(int enum_in)
Definition: EnumToStringx.cpp:15
TriaInput2
Definition: TriaInput2.h:8
DatasetInput2::numberofvertices_local
int numberofvertices_local
Definition: DatasetInput2.h:21
MARSHALLING
#define MARSHALLING(FIELD)
Definition: Marshalling.h:29
DatasetInput2::numberofelements_local
int numberofelements_local
Definition: DatasetInput2.h:20
PentaInput2
Definition: PentaInput2.h:8
Input2::Configure
virtual void Configure(Parameters *parameters)
Definition: Input2.h:30
Input2
Definition: Input2.h:18
DatasetInput2::DeepEcho
void DeepEcho()
Definition: DatasetInput2.cpp:67
PentaInput2Enum
@ PentaInput2Enum
Definition: EnumDefinitions.h:1125
NoneEnum
@ NoneEnum
Definition: EnumDefinitions.h:1202
_error_
#define _error_(StreamArgs)
Definition: exceptions.h:49
DatasetInput2::DatasetInput2
DatasetInput2()
Definition: DatasetInput2.cpp:17
TriaInput2::SetInput
void SetInput(int interp_in, int row, IssmDouble value_in)
Definition: TriaInput2.cpp:141
Input2::GetInputValue
virtual void GetInputValue(IssmDouble *pvalue, Gauss *gauss)
Definition: Input2.h:38
xMemCpy
T * xMemCpy(T *dest, const T *src, unsigned int size)
Definition: MemOps.h:152
DatasetInput2::ObjectEnum
int ObjectEnum()
Definition: DatasetInput2.cpp:97
DatasetInput2::inputs
Input2 ** inputs
Definition: DatasetInput2.h:18
DatasetInput2::ids
int * ids
Definition: DatasetInput2.h:19