Xpetra
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
Xpetra_Parameters.hpp
Go to the documentation of this file.
1
// @HEADER
2
// *****************************************************************************
3
// Xpetra: A linear algebra interface package
4
//
5
// Copyright 2012 NTESS and the Xpetra contributors.
6
// SPDX-License-Identifier: BSD-3-Clause
7
// *****************************************************************************
8
// @HEADER
9
10
#ifndef XPETRA_PARAMETERS_HPP
11
#define XPETRA_PARAMETERS_HPP
12
13
#include <Teuchos_Describable.hpp>
14
#include <Teuchos_VerboseObject.hpp>
15
#include <
Teuchos_CommandLineProcessor.hpp
>
16
17
#include <Xpetra_Map.hpp>
// for UnderlyingLib definition
18
#include <
Xpetra_Utils.hpp
>
// for toString(lib_)
19
20
namespace
Xpetra
{
21
22
enum
Instantiation
{
23
DOUBLE_INT_INT
,
24
DOUBLE_INT_LONGINT
,
25
DOUBLE_INT_LONGLONGINT
,
26
COMPLEX_INT_INT
,
27
FLOAT_INT_INT
28
};
29
30
class
Parameters
31
:
public
Teuchos::VerboseObject
<Parameters>,
32
public
Teuchos::Describable
{
33
public
:
34
Parameters
(
Teuchos::CommandLineProcessor
& clp) {
35
setCLP
(clp);
36
}
37
38
void
setCLP
(
Teuchos::CommandLineProcessor
& clp) {
39
int
nOptions = 0;
// Gives the number of possible option values to select
40
const
int
maxOptions = 2;
// No more than 2 libraries are supported right now
41
Xpetra::UnderlyingLib
optionValues[maxOptions];
// Array that gives the numeric values for each option.
42
const
char
* optionNames[maxOptions];
// Array that gives the name used in the commandline for each option.
43
44
std::stringstream documentation;
// documentation for the option
45
// documentation << "linear algebra library (Epetra, Tpetra)";
46
documentation <<
"linear algebra library ("
;
47
48
// Default is Tpetra if available. If not, default is Epetra
49
documentation <<
"Tpetra"
;
50
lib_
=
Xpetra::UseTpetra
;
// set default
51
optionValues[nOptions] =
Xpetra::UseTpetra
;
52
// optionsValues[nOptions] = "tpetra"; //TODO: do not break compatibility right now
53
optionNames[nOptions] =
"Tpetra"
;
54
nOptions++;
55
documentation <<
")"
;
56
57
clp.
setOption
<
Xpetra::UnderlyingLib
>(
"linAlgebra"
, &
lib_
, nOptions, optionValues, optionNames, documentation.str().c_str());
58
59
int
nInstOptions = 0;
// Gives the number of possible option values to select
60
const
int
maxInstOptions = 5;
// No more than 5 instantiations are supported right now
61
Xpetra::Instantiation
instOptionValues[maxInstOptions];
// Array that gives the numeric values for each option.
62
const
char
* instOptionNames[maxInstOptions];
// Array that gives the name used in the commandline for each option.
63
64
// The ordering of these blocks determines the default behavior.
65
// We test the first available instantiation from the bottom
66
// (i.e. DOUBLE_INT_INT runs if nothing else is available).
67
#if defined(HAVE_MUELU_INST_DOUBLE_INT_INT) || defined(HAVE_TPETRA_INST_DOUBLE) && defined(HAVE_TPETRA_INST_INT_INT)
68
inst_
=
Xpetra::DOUBLE_INT_INT
;
// set default
69
instOptionValues[nInstOptions] =
Xpetra::DOUBLE_INT_INT
;
70
instOptionNames[nInstOptions] =
"DOUBLE_INT_INT"
;
71
nInstOptions++;
72
#endif
73
#if defined(HAVE_MUELU_INST_DOUBLE_INT_LONGINT) || defined(HAVE_TPETRA_INST_DOUBLE) && defined(HAVE_TPETRA_INST_INT_LONG)
74
inst_
=
Xpetra::DOUBLE_INT_LONGINT
;
// set default
75
instOptionValues[nInstOptions] =
Xpetra::DOUBLE_INT_LONGINT
;
76
instOptionNames[nInstOptions] =
"DOUBLE_INT_LONGINT"
;
77
nInstOptions++;
78
#endif
79
#if defined(HAVE_MUELU_INST_DOUBLE_INT_LONGLONGINT) || defined(HAVE_TPETRA_INST_DOUBLE) && defined(HAVE_TPETRA_INST_INT_LONG_LONG)
80
inst_
=
Xpetra::DOUBLE_INT_LONGLONGINT
;
// set default
81
instOptionValues[nInstOptions] =
Xpetra::DOUBLE_INT_LONGLONGINT
;
82
instOptionNames[nInstOptions] =
"DOUBLE_INT_LONGLONGINT"
;
83
nInstOptions++;
84
#endif
85
#if defined(HAVE_MUELU_INST_COMPLEX_INT_INT) || defined(HAVE_TPETRA_INST_COMPLEX_DOUBLE) && defined(HAVE_TPETRA_INST_INT_INT)
86
inst_
=
Xpetra::COMPLEX_INT_INT
;
// set default
87
instOptionValues[nInstOptions] =
Xpetra::COMPLEX_INT_INT
;
88
instOptionNames[nInstOptions] =
"COMPLEX_INT_INT"
;
89
nInstOptions++;
90
#endif
91
#if defined(HAVE_MUELU_INST_FLOAT_INT_INT) || defined(HAVE_TPETRA_INST_FLOAT) && defined(HAVE_TPETRA_INST_INT_INT)
92
inst_
=
Xpetra::FLOAT_INT_INT
;
// set default
93
instOptionValues[nInstOptions] =
Xpetra::FLOAT_INT_INT
;
94
instOptionNames[nInstOptions] =
"FLOAT_INT_INT"
;
95
nInstOptions++;
96
#endif
97
std::stringstream instDocumentation;
// documentation for the option
98
instDocumentation <<
"choice of instantiation"
;
99
100
clp.
setOption
<
Xpetra::Instantiation
>(
"instantiation"
, &
inst_
, nInstOptions, instOptionValues, instOptionNames, instDocumentation.str().c_str());
101
}
102
103
void
check
()
const
{
104
// TODO with ifdef...
105
}
106
107
Xpetra::UnderlyingLib
GetLib
()
const
{
108
check
();
109
return
lib_
;
110
}
111
112
Xpetra::Instantiation
GetInstantiation
()
const
{
113
check
();
114
return
inst_
;
115
}
116
118
119
121
std::string
description
()
const
{
122
std::ostringstream out;
123
out <<
Teuchos::Describable::description
();
124
out <<
"{lib = "
<<
toString
(
lib_
) <<
"} "
;
125
return
out.str();
126
}
127
129
void
describe
(
Teuchos::FancyOStream
& out,
const
Teuchos::EVerbosityLevel
verbLevel =
verbLevel_default
)
const
{
130
using
std::endl;
131
int
vl = (verbLevel ==
Teuchos::VERB_DEFAULT
) ?
Teuchos::VERB_LOW
: verbLevel;
132
if
(vl ==
Teuchos::VERB_NONE
)
return
;
133
134
if
(vl ==
Teuchos::VERB_LOW
) {
135
out <<
description
() << endl;
136
}
else
{
137
out <<
Teuchos::Describable::description
() << endl;
138
}
139
140
if
(vl ==
Teuchos::VERB_MEDIUM
|| vl ==
Teuchos::VERB_HIGH
|| vl ==
Teuchos::VERB_EXTREME
) {
141
Teuchos::OSTab
tab1(out);
142
out <<
"Linear algebra library: "
<<
toString
(
lib_
) << endl;
143
}
144
}
145
147
148
private
:
149
Xpetra::UnderlyingLib
lib_
;
150
Xpetra::Instantiation
inst_
;
151
};
152
153
}
// namespace Xpetra
154
155
#endif
Teuchos_CommandLineProcessor.hpp
Xpetra_Utils.hpp
Teuchos::CommandLineProcessor
Teuchos::CommandLineProcessor::setOption
void setOption(const char option_true[], const char option_false[], bool *option_val, const char documentation[]=NULL)
Teuchos::Describable
Teuchos::Describable::verbLevel_default
static const EVerbosityLevel verbLevel_default
Teuchos::Describable::description
virtual std::string description() const
Teuchos::VerboseObject
Xpetra::Parameters::lib_
Xpetra::UnderlyingLib lib_
Definition
Xpetra_Parameters.hpp:149
Xpetra::Parameters::check
void check() const
Definition
Xpetra_Parameters.hpp:103
Xpetra::Parameters::Parameters
Parameters(Teuchos::CommandLineProcessor &clp)
Definition
Xpetra_Parameters.hpp:34
Xpetra::Parameters::GetInstantiation
Xpetra::Instantiation GetInstantiation() const
Definition
Xpetra_Parameters.hpp:112
Xpetra::Parameters::setCLP
void setCLP(Teuchos::CommandLineProcessor &clp)
Definition
Xpetra_Parameters.hpp:38
Xpetra::Parameters::describe
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=verbLevel_default) const
Print the object with some verbosity level to an FancyOStream object.
Definition
Xpetra_Parameters.hpp:129
Xpetra::Parameters::description
std::string description() const
Return a simple one-line description of this object.
Definition
Xpetra_Parameters.hpp:121
Xpetra::Parameters::GetLib
Xpetra::UnderlyingLib GetLib() const
Definition
Xpetra_Parameters.hpp:107
Xpetra::Parameters::inst_
Xpetra::Instantiation inst_
Definition
Xpetra_Parameters.hpp:150
Teuchos::FancyOStream
basic_FancyOStream< char > FancyOStream
Teuchos::OSTab
basic_OSTab< char > OSTab
Teuchos::EVerbosityLevel
EVerbosityLevel
Teuchos::VERB_MEDIUM
VERB_MEDIUM
Teuchos::VERB_HIGH
VERB_HIGH
Teuchos::VERB_EXTREME
VERB_EXTREME
Teuchos::VERB_NONE
VERB_NONE
Teuchos::VERB_DEFAULT
VERB_DEFAULT
Teuchos::VERB_LOW
VERB_LOW
Xpetra
Xpetra namespace
Definition
Xpetra_BlockedCrsMatrix_decl.hpp:52
Xpetra::Instantiation
Instantiation
Definition
Xpetra_Parameters.hpp:22
Xpetra::COMPLEX_INT_INT
@ COMPLEX_INT_INT
Definition
Xpetra_Parameters.hpp:26
Xpetra::FLOAT_INT_INT
@ FLOAT_INT_INT
Definition
Xpetra_Parameters.hpp:27
Xpetra::DOUBLE_INT_INT
@ DOUBLE_INT_INT
Definition
Xpetra_Parameters.hpp:23
Xpetra::DOUBLE_INT_LONGLONGINT
@ DOUBLE_INT_LONGLONGINT
Definition
Xpetra_Parameters.hpp:25
Xpetra::DOUBLE_INT_LONGINT
@ DOUBLE_INT_LONGINT
Definition
Xpetra_Parameters.hpp:24
Xpetra::UnderlyingLib
UnderlyingLib
Definition
Xpetra_Map_decl.hpp:26
Xpetra::UseTpetra
@ UseTpetra
Definition
Xpetra_Map_decl.hpp:27
Xpetra::toString
std::string toString(Xpetra::UnderlyingLib lib)
Convert a Xpetra::UnderlyingLib to a std::string.
Definition
Xpetra_Utils.cpp:15
src
Utils
Xpetra_Parameters.hpp
Generated by
1.17.0