Teuchos - Trilinos Tools Package
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
remainder
src
Trilinos_Details_LinearSolverFactory.cpp
1
// @HEADER
2
// *****************************************************************************
3
// Teuchos: Common Tools Package
4
//
5
// Copyright 2004 NTESS and the Teuchos contributors.
6
// SPDX-License-Identifier: BSD-3-Clause
7
// *****************************************************************************
8
// @HEADER
9
10
#include "
Trilinos_Details_LinearSolverFactory.hpp
"
11
#include <set>
12
13
namespace
Trilinos
{
14
namespace
Details {
15
namespace
Impl
{
16
17
namespace
{
// (anonymous)
18
19
// All package names that registerLinearSolverFactory has seen,
20
// for any combination of template parameters MV and OP.
21
static
std::set<std::string>* packageNames_ = NULL;
22
23
// atexit() hook for freeing packageNames_.
24
void
freePackageNames ()
25
{
26
if
(packageNames_ != NULL) {
27
delete
packageNames_;
28
packageNames_ = NULL;
29
}
30
}
31
32
void
createPackageNames ()
33
{
34
if
(packageNames_ == NULL) {
35
packageNames_ =
new
std::set<std::string> ();
36
// It _is_ possible for atexit() to fail (e.g., because it ran
37
// out of memory for storing callbacks). We could throw an
38
// exception here in that case, but I think it's better just
39
// to let the minor memory leak happen.
40
(void) atexit (freePackageNames);
41
}
42
}
43
44
}
// namespace (anonymous)
45
46
bool
rememberRegisteredSomeLinearSolverFactory
(
const
std::string& packageName)
47
{
48
createPackageNames ();
49
TEUCHOS_TEST_FOR_EXCEPTION
50
(packageNames_ == NULL, std::logic_error,
"Trilinos::Details::"
51
"Impl::rememberRegisteredSomeLinearSolverFactory: "
52
"Should never get here! packageNames_ is NULL."
);
53
54
std::pair<std::set<std::string>::iterator,
bool
> ret =
55
packageNames_->insert (packageName);
56
// ret.second is true if the item was NOT in the set before.
57
return
! ret.second;
58
}
59
60
bool
registeredSomeLinearSolverFactory
(
const
std::string& packageName)
61
{
62
createPackageNames ();
63
TEUCHOS_TEST_FOR_EXCEPTION
64
(packageNames_ == NULL, std::logic_error,
"Trilinos::Details::"
65
"Impl::rememberRegisteredSomeLinearSolverFactory: "
66
"Should never get here! packageNames_ is NULL."
);
67
68
std::set<std::string>::const_iterator it = packageNames_->find (packageName);
69
return
it != packageNames_->end ();
70
}
71
72
bool
haveLinearSolverFactoryRunTimeRegistration
()
73
{
74
#if defined(TRILINOS_HAVE_LINEAR_SOLVER_FACTORY_REGISTRATION)
75
return
true
;
76
#else
// NOT defined(TRILINOS_HAVE_LINEAR_SOLVER_FACTORY_REGISTRATION)
77
return
false
;
78
#endif
// defined(TRILINOS_HAVE_LINEAR_SOLVER_FACTORY_REGISTRATION)
79
}
80
81
}
// namespace Impl
82
}
// namespace Details
83
}
// namespace Trilinos
84
85
Trilinos_Details_LinearSolverFactory.hpp
Declaration and definition of linear solver factory, and "factory of factories".
TEUCHOS_TEST_FOR_EXCEPTION
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
Definition
Teuchos_TestForException.hpp:146
Trilinos::Details::Impl
Implementation details of implementation details.
Definition
Trilinos_Details_LinearSolverFactory.cpp:15
Trilinos::Details::Impl::registeredSomeLinearSolverFactory
bool registeredSomeLinearSolverFactory(const std::string &packageName)
Did the package with the given name register at least one LinearSolverFactory, with any template para...
Definition
Trilinos_Details_LinearSolverFactory.cpp:60
Trilinos::Details::Impl::rememberRegisteredSomeLinearSolverFactory
bool rememberRegisteredSomeLinearSolverFactory(const std::string &packageName)
Remember which packages registered at least one LinearSolverFactory, with any template parameters.
Definition
Trilinos_Details_LinearSolverFactory.cpp:46
Trilinos::Details::Impl::haveLinearSolverFactoryRunTimeRegistration
bool haveLinearSolverFactoryRunTimeRegistration()
Whether the CMake run-time registration option is ON.
Definition
Trilinos_Details_LinearSolverFactory.cpp:72
Trilinos
Namespace of things generally useful to many Trilinos packages.
Generated by
1.17.0