Ice Sheet System Model
4.18
Code documentation
src
c
toolkits
issm
IssmToolkitUtils.cpp
Go to the documentation of this file.
1
5
/*Headers:*/
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 "../../shared/MemOps/MemOps.h"
14
#include "../../shared/io/Comm/IssmComm.h"
15
#include "../../shared/Enum/Enum.h"
16
#include "../../shared/Exceptions/exceptions.h"
17
#include "../ToolkitOptions.h"
18
#include "
./IssmToolkitUtils.h
"
19
#include <string.h>
20
/*}}}*/
21
22
/*Routines: */
23
int
IssmMatTypeFromToolkitOptions
(
void
){
/*{{{*/
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
}
/*}}}*/
56
int
IssmVecTypeFromToolkitOptions
(
void
){
/*{{{*/
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
}
/*}}}*/
86
int
IssmSolverTypeFromToolkitOptions
(
void
){
/*{{{*/
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
}
/*}}}*/
IssmToolkitUtils.h
routines used throughout the ISSM toolkit
IssmMatTypeFromToolkitOptions
int IssmMatTypeFromToolkitOptions(void)
Definition:
IssmToolkitUtils.cpp:23
DenseEnum
@ DenseEnum
Definition:
EnumDefinitions.h:1034
MpiEnum
@ MpiEnum
Definition:
EnumDefinitions.h:1193
IssmSolverTypeFromToolkitOptions
int IssmSolverTypeFromToolkitOptions(void)
Definition:
IssmToolkitUtils.cpp:86
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
IssmVecTypeFromToolkitOptions
int IssmVecTypeFromToolkitOptions(void)
Definition:
IssmToolkitUtils.cpp:56
MpiDenseEnum
@ MpiDenseEnum
Definition:
EnumDefinitions.h:1192
GslEnum
@ GslEnum
Definition:
EnumDefinitions.h:1094
Generated on Thu Jul 2 2020 08:09:22 for Ice Sheet System Model by
1.8.19