Ice Sheet System Model  4.18
Code documentation
Functions
IssmToolkitUtils.cpp File Reference

utilities used throughout our ISSM toolkit More...

#include "../../shared/MemOps/MemOps.h"
#include "../../shared/io/Comm/IssmComm.h"
#include "../../shared/Enum/Enum.h"
#include "../../shared/Exceptions/exceptions.h"
#include "../ToolkitOptions.h"
#include "./IssmToolkitUtils.h"
#include <string.h>

Go to the source code of this file.

Functions

int IssmMatTypeFromToolkitOptions (void)
 
int IssmVecTypeFromToolkitOptions (void)
 
int IssmSolverTypeFromToolkitOptions (void)
 

Detailed Description

utilities used throughout our ISSM toolkit

Definition in file IssmToolkitUtils.cpp.

Function Documentation

◆ IssmMatTypeFromToolkitOptions()

int IssmMatTypeFromToolkitOptions ( void  )

Definition at line 23 of file IssmToolkitUtils.cpp.

23  { /*{{{*/
24 
25  char *mat_type = NULL;
26  int mat_type_enum;
27  int num_procs = 0;
28  bool isparallel = false;
29 
30  /*first, figure out if we are running in parallel: */
31  num_procs=IssmComm::GetSize();
32  if(num_procs>1)isparallel=true;
33 
34  /*retrieve matrix type as a string, from the Toolkits Options database, similar to what Petsc does. Actually,
35  *we try and stick with the Petsc matrix types: */
36  mat_type=ToolkitOptions::GetToolkitOptionValue("mat_type");
37 
38  if (strcmp(mat_type,"mpidense")==0){
39  mat_type_enum=MpiDenseEnum;
40  }
41  else if (strcmp(mat_type,"mpisparse")==0){
42  mat_type_enum=MpiSparseEnum;
43  }
44  else if (strcmp(mat_type,"dense")==0){
45  if (isparallel) _error_("Dense matrix type not supported for parallel runs with num_procs>1");
46  else mat_type_enum=DenseEnum;
47  }
48  else _error_("matrix type not supported yet!");
49 
50  /*free ressources: */
51  xDelete<char>(mat_type);
52 
53  /*return: */
54  return mat_type_enum;
55 } /*}}}*/

◆ IssmVecTypeFromToolkitOptions()

int IssmVecTypeFromToolkitOptions ( void  )

Definition at line 56 of file IssmToolkitUtils.cpp.

56  { /*{{{*/
57 
58  char* vec_type=NULL;
59  int vec_type_enum;
60  int num_procs=0;
61  bool isparallel=false;
62 
63  /*first, figure out if we are running in parallel: */
64  num_procs=IssmComm::GetSize();
65  if(num_procs>1)isparallel=true;
66 
67  /*retrieve vector type as a string, from the Toolkits Options database, similar to what Petsc does. Actually,
68  *we try and stick with the Petsc vector types: */
69  vec_type=ToolkitOptions::GetToolkitOptionValue("vec_type");
70 
71  if (strcmp(vec_type,"mpi")==0){
72  vec_type_enum=MpiEnum;
73  }
74  else if (strcmp(vec_type,"seq")==0){
75  if (isparallel) _error_("Dense vector type not supported for parallel runs with num_procs>1");
76  else vec_type_enum=SeqEnum;
77  }
78  else _error_("vector type not supported yet!");
79 
80  /*free ressources: */
81  xDelete<char>(vec_type);
82 
83  /*return: */
84  return vec_type_enum;
85 } /*}}}*/

◆ IssmSolverTypeFromToolkitOptions()

int IssmSolverTypeFromToolkitOptions ( void  )

Definition at line 86 of file IssmToolkitUtils.cpp.

86  { /*{{{*/
87 
88  int solver_type_enum;
89  bool isparallel=false;
90 
91  /*first, figure out if we are running in parallel: */
92  int num_procs=IssmComm::GetSize();
93  if(num_procs>1)isparallel=true;
94 
95  /*retrieve solver type as a string, from the Toolkits Options database, similar to what Petsc does. Actually,
96  *we try and stick with the Petsc vector types: */
97  char* solver_type=ToolkitOptions::GetToolkitOptionValue("solver_type");
98  if(!solver_type) _error_("Solver not set");
99 
100  if (strcmp(solver_type,"mumps")==0){
101  solver_type_enum=MumpsEnum;
102  }
103  else if (strcmp(solver_type,"gsl")==0){
104  if (isparallel) _error_("Gsl solver type not supported for parallel runs with num_procs>1");
105  else solver_type_enum=GslEnum;
106  }
107  else _error_("solver type not supported yet!");
108 
109  /*free ressources: */
110  xDelete<char>(solver_type);
111 
112  /*return: */
113  return solver_type_enum;
114 } /*}}}*/
DenseEnum
@ DenseEnum
Definition: EnumDefinitions.h:1034
MpiEnum
@ MpiEnum
Definition: EnumDefinitions.h:1193
MumpsEnum
@ MumpsEnum
Definition: EnumDefinitions.h:1195
ToolkitOptions::GetToolkitOptionValue
static char * GetToolkitOptionValue(const char *option)
Definition: ToolkitOptions.cpp:36
IssmComm::GetSize
static int GetSize(void)
Definition: IssmComm.cpp:46
MpiSparseEnum
@ MpiSparseEnum
Definition: EnumDefinitions.h:1194
SeqEnum
@ SeqEnum
Definition: EnumDefinitions.h:1273
_error_
#define _error_(StreamArgs)
Definition: exceptions.h:49
MpiDenseEnum
@ MpiDenseEnum
Definition: EnumDefinitions.h:1192
GslEnum
@ GslEnum
Definition: EnumDefinitions.h:1094