Ice Sheet System Model  4.18
Code documentation
IoModel.h
Go to the documentation of this file.
1 /* \file IoModel.h
2  * \brief Header file defining the IoModel structure that will help in processing the input data coming
3  * into ISSM, from Matlab, or through a binary file opened for reading.
4  * \sa IoModel.cpp
5  */
6 
7 #ifndef _IOMODEL_H
8 #define _IOMODEL_H
9 
10 #include "../shared/Enum/Enum.h"
11 #include <vector>
12 
13 class Parameters;
14 class Elements;
15 class Inputs2;
16 class Param;
17 class Options;
18 
19 class IoConstant { /*holds single IssmDouble, int, bool and char from input*/
20  public:
23  char* name;
24 
25  ~IoConstant();
26  IoConstant();
27  IoConstant(bool value,const char* name_in);
28  IoConstant(int value,const char* name_in);
29  IoConstant(IssmDouble value,const char* name_in);
30  IoConstant(char* value,const char* name_in);
31  IoConstant(char** value,int numstrings,const char* name_in);
32 };
33 
34 class IoData { /*holds temporary data (array), memory intensive*/
35  public:
36  int code;
39  int layout;
40  int M,N;
41  char* name;
42 
43  ~IoData();
44  IoData();
45  IoData(IssmDouble* matrix,int code,int layout_in,int M,int N,const char* name_in);
46 };
47 
48 class IoModel {
49 
50  private:
51  std::vector<IoConstant*> constants; //this dataset holds all IssmDouble, int, bool and char from input
52  std::vector<IoData*> data; //this dataset holds temporary data, memory intensive
53 
54  /*for AD mode: to keep track of our independent variables we fetch:*/
55  //bool *independents;
56  //DataSet *independent_objects;
57 
58  public:
59  /*pointer to input file*/
60  FILE *fid;
61 
62  /*Solution*/
64 
65  /*Partitioning*/
66  bool *my_elements;
67  bool *my_faces;
68  bool *my_vfaces;
69  bool *my_edges;
70  bool *my_vedges;
71  bool *my_hedges;
72  bool *my_vertices;
74  int *epart;
75 
76  /*Mesh properties and connectivity tables*/
77  int domaindim;
79  int *elements;
80  int *edges;
88  int *faces;
90  int facescols;
101 
102  /*Methods*/
103  ~IoModel();
104  IoModel();
105  IoModel(FILE* iomodel_handle,int solution_enum_in,bool trace,IssmPDouble* X);
106 
107  /*NEW*/
108  void AddConstant(IoConstant* constant_in);
109  void AddConstantIndependent(IoConstant* constant_in);
110  void AddData(IoData* data_in);
111  void AddDataIndependent(IoData* data_in);
112  void FetchIndependentConstant(int* pXcount,IssmPDouble* X,const char* name);
113  void FetchIndependentData(int* pXcount,IssmPDouble* X,const char* name);
114  void FillIndependents(IssmDouble* xp);
115  void FindConstant(bool* pvalue,const char* constant_name);
116  void FindConstant(int* pvalue,const char* constant_name);
117  void FindConstant(IssmDouble* pvalue,const char* constant_name);
118  void FindConstant(char **pvalue,const char* constant_name);
119  void FindConstant(char ***pvalue,int* psize,const char* constant_name);
120  int NumIndependents();
121 
122  /*Input/Output*/
123  void CheckFile(void);
124  Param *CopyConstantObject(const char* constant_name,int param_enum);
125  IssmDouble *Data(const char* data_name);
126  void DeclareIndependents(bool trace,IssmPDouble* X);
127  void DeleteData(int num,...);
128  void DeleteData(IssmDouble* vector,const char* data_name);
129  void DeleteData(char*** pstringarray, int numstrings,const char* data_name);
130  void FetchConstants(void);
131  void FetchData(bool* pboolean,const char* data_name);
132  void FetchData(int* pinteger,const char* data_name);
133  void FetchData(IssmDouble* pscalar,const char* data_name);
134  void FetchData(char** pstring,const char* data_name);
135  void FetchData(char*** pstrings,int* pnumstrings,const char* data_name);
136  void FetchData(int** pmatrix,int* pM,int* pN,const char* data_name);
137  void FetchData(IssmDouble** pscalarmatrix,int* pM,int* pN,const char* data_name);
138  void FetchData(IssmDouble*** pmatrixarray,int** pmdims,int** pndims, int* pnumrecords,const char* data_name);
139  void FetchData(Options *options,const char* data_name);
140  void FetchData(int num,...);
141  void FetchDataToInput(Inputs2* inputs2,Elements* elements,const char* vector_name,int input_enum);
142  void FetchDataToInput(Inputs2* inputs2,Elements* elements,const char* vector_name,int input_enum,IssmDouble default_value);
143  void FetchDataToDatasetInput(Inputs2* inputs2,Elements* elements,const char* vector_name,int input_enum);
144  void FetchIndependent(const char* dependent_name);
145  void FetchMultipleData(char*** pstringarray,int* pnumstrings,const char* data_name);
146  void FetchMultipleData(IssmDouble*** pmatrixarray,int** pmdims,int** pndims, int* pnumrecords,const char* data_name);
147  void FetchMultipleData(int*** pmatrices,int** pmdims,int** pndims, int* pnumrecords,const char* data_name);
148  void FetchMultipleData(int** pvector, int* pnum_instances,const char* data_name);
149  void FetchMultipleData(IssmDouble** pvector, int* pnum_instances,const char* data_name);
150  fpos_t* SetFilePointersToData(int** pcodes,int** pvector_types, int* pnum_instances, const char* data_name);
151  FILE* SetFilePointerToData(int* pcode,int* pvector_type, const char* data_name);
152  void StartTrace(bool trace);
153 };
154 
155 #endif /* _IOMODEL_H */
IoData::IoData
IoData()
Definition: IoModel.cpp:99
IoModel::solution_enum
int solution_enum
Definition: IoModel.h:63
IoModel::AddConstantIndependent
void AddConstantIndependent(IoConstant *constant_in)
Definition: IoModel.cpp:305
IoData::isindependent
bool isindependent
Definition: IoModel.h:38
Options
Definition: Options.h:9
IoModel::verticalfaces
int * verticalfaces
Definition: IoModel.h:89
IssmDouble
double IssmDouble
Definition: types.h:37
Param
Definition: Param.h:21
IoModel::IoModel
IoModel()
Definition: IoModel.cpp:131
IoModel::~IoModel
~IoModel()
Definition: IoModel.cpp:240
IoModel::numbernodetoelementconnectivity
int * numbernodetoelementconnectivity
Definition: IoModel.h:92
IoModel::elementtohorizontaledgeconnectivity
int * elementtohorizontaledgeconnectivity
Definition: IoModel.h:85
IoModel::elementtofaceconnectivity
int * elementtofaceconnectivity
Definition: IoModel.h:86
IoModel::DeclareIndependents
void DeclareIndependents(bool trace, IssmPDouble *X)
Definition: IoModel.cpp:450
IoModel::my_vfaces
bool * my_vfaces
Definition: IoModel.h:68
IoModel::constants
std::vector< IoConstant * > constants
Definition: IoModel.h:51
Parameters
Declaration of Parameters class.
Definition: Parameters.h:18
IoModel::my_hedges
bool * my_hedges
Definition: IoModel.h:71
IoModel::my_vertices_lids
int * my_vertices_lids
Definition: IoModel.h:73
Elements
Declaration of Elements class.
Definition: Elements.h:17
IoModel::numberoffaces
int numberoffaces
Definition: IoModel.h:97
IoModel::my_elements
bool * my_elements
Definition: IoModel.h:66
IoModel::FetchMultipleData
void FetchMultipleData(char ***pstringarray, int *pnumstrings, const char *data_name)
Definition: IoModel.cpp:1960
IoModel::data
std::vector< IoData * > data
Definition: IoModel.h:52
IoData::~IoData
~IoData()
Definition: IoModel.cpp:109
IoConstant::constant
Param * constant
Definition: IoModel.h:21
IoModel::my_vertices
bool * my_vertices
Definition: IoModel.h:72
IoData::data
IssmDouble * data
Definition: IoModel.h:37
IoModel::numberofvertices
int numberofvertices
Definition: IoModel.h:99
IoModel::AddConstant
void AddConstant(IoConstant *constant_in)
Definition: IoModel.cpp:288
IoModel::DeleteData
void DeleteData(int num,...)
Definition: IoModel.cpp:500
IoModel::numberofelements
int numberofelements
Definition: IoModel.h:96
IoModel::facescols
int facescols
Definition: IoModel.h:90
IoData
Definition: IoModel.h:34
IoModel::CopyConstantObject
Param * CopyConstantObject(const char *constant_name, int param_enum)
Definition: IoModel.cpp:418
IoModel::elementtoverticaledgeconnectivity
int * elementtoverticaledgeconnectivity
Definition: IoModel.h:84
IoModel::AddDataIndependent
void AddDataIndependent(IoData *data_in)
Definition: IoModel.cpp:333
IoModel::verticaledges
int * verticaledges
Definition: IoModel.h:81
IoModel::elementtoedgeconnectivity
int * elementtoedgeconnectivity
Definition: IoModel.h:83
IoModel::FindConstant
void FindConstant(bool *pvalue, const char *constant_name)
Definition: IoModel.cpp:2362
IoModel::horizontaledges
int * horizontaledges
Definition: IoModel.h:82
IoConstant::IoConstant
IoConstant()
Definition: IoModel.cpp:36
IoModel::my_edges
bool * my_edges
Definition: IoModel.h:69
IoModel::fid
FILE * fid
Definition: IoModel.h:60
IoModel::SetFilePointersToData
fpos_t * SetFilePointersToData(int **pcodes, int **pvector_types, int *pnum_instances, const char *data_name)
Definition: IoModel.cpp:2471
IoModel::FetchData
void FetchData(bool *pboolean, const char *data_name)
Definition: IoModel.cpp:933
IoModel::numberofhorizontaledges
int numberofhorizontaledges
Definition: IoModel.h:95
Inputs2
Declaration of Inputs class.
Definition: Inputs2.h:23
IoModel::domaindim
int domaindim
Definition: IoModel.h:77
IoModel::FetchIndependentConstant
void FetchIndependentConstant(int *pXcount, IssmPDouble *X, const char *name)
Definition: IoModel.cpp:1814
IoConstant
Definition: IoModel.h:19
IoData::N
int N
Definition: IoModel.h:40
IoModel::singlenodetoelementconnectivity
int * singlenodetoelementconnectivity
Definition: IoModel.h:100
IoModel::CheckFile
void CheckFile(void)
Definition: IoModel.cpp:344
IoModel::FetchIndependentData
void FetchIndependentData(int *pXcount, IssmPDouble *X, const char *name)
Definition: IoModel.cpp:1868
IoData::name
char * name
Definition: IoModel.h:41
IoModel::Data
IssmDouble * Data(const char *data_name)
Definition: IoModel.cpp:437
IoModel::StartTrace
void StartTrace(bool trace)
Definition: IoModel.cpp:2700
IoModel::faces
int * faces
Definition: IoModel.h:88
IoModel::numberofverticalfaces
int numberofverticalfaces
Definition: IoModel.h:98
IoModel::numberofverticaledges
int numberofverticaledges
Definition: IoModel.h:94
IoModel::NumIndependents
int NumIndependents()
Definition: IoModel.cpp:2448
IoModel::SetFilePointerToData
FILE * SetFilePointerToData(int *pcode, int *pvector_type, const char *data_name)
Definition: IoModel.cpp:2612
IoData::code
int code
Definition: IoModel.h:36
IoModel::FetchDataToInput
void FetchDataToInput(Inputs2 *inputs2, Elements *elements, const char *vector_name, int input_enum)
Definition: IoModel.cpp:1651
IoModel::FetchDataToDatasetInput
void FetchDataToDatasetInput(Inputs2 *inputs2, Elements *elements, const char *vector_name, int input_enum)
Definition: IoModel.cpp:1735
IoConstant::~IoConstant
~IoConstant()
Definition: IoModel.cpp:42
IoData::layout
int layout
Definition: IoModel.h:39
IoModel::AddData
void AddData(IoData *data_in)
Definition: IoModel.cpp:316
IoModel::epart
int * epart
Definition: IoModel.h:74
IoModel::elements
int * elements
Definition: IoModel.h:79
IoModel::edges
int * edges
Definition: IoModel.h:80
IoModel::FetchIndependent
void FetchIndependent(const char *dependent_name)
IoModel
Definition: IoModel.h:48
IoModel::meshelementtype
int meshelementtype
Definition: IoModel.h:91
IoModel::elementtoverticalfaceconnectivity
int * elementtoverticalfaceconnectivity
Definition: IoModel.h:87
IssmPDouble
IssmDouble IssmPDouble
Definition: types.h:38
IoModel::my_faces
bool * my_faces
Definition: IoModel.h:67
IoModel::domaintype
int domaintype
Definition: IoModel.h:78
IoConstant::name
char * name
Definition: IoModel.h:23
IoData::M
int M
Definition: IoModel.h:40
IoModel::FillIndependents
void FillIndependents(IssmDouble *xp)
Definition: IoModel.cpp:2334
IoModel::FetchConstants
void FetchConstants(void)
Definition: IoModel.cpp:557
IoConstant::isindependent
bool isindependent
Definition: IoModel.h:22
IoModel::numberofedges
int numberofedges
Definition: IoModel.h:93
IoModel::my_vedges
bool * my_vedges
Definition: IoModel.h:70