FEI Package Browser (Single Doxygen Collection)
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
test_utils
LibraryFactory.cpp
Go to the documentation of this file.
1
/*--------------------------------------------------------------------*/
2
/* Copyright 2005 Sandia Corporation. */
3
/* Under the terms of Contract DE-AC04-94AL85000, there is a */
4
/* non-exclusive license for use of this work by or on behalf */
5
/* of the U.S. Government. Export of this program may require */
6
/* a license from the United States Government. */
7
/*--------------------------------------------------------------------*/
8
9
#include <
fei_macros.hpp
>
10
11
#include <
fei_mpi.h
>
12
13
#include <
test_utils/LibraryFactory.hpp
>
14
15
#include <
fei_LibraryWrapper.hpp
>
16
17
#include <
snl_fei_Factory.hpp
>
18
19
#include <
fei_Factory_Trilinos.hpp
>
20
#ifdef HAVE_FEI_AZTECOO
21
#include <
fei_Aztec_LinSysCore.hpp
>
22
#endif
23
24
#ifdef HAVE_FEI_FETI
25
#include <FETI_DP_FiniteElementData.h>
26
#endif
27
28
//----------------------------------------------------------------------------
29
fei::SharedPtr<LibraryWrapper>
30
fei::create_LibraryWrapper
(
MPI_Comm
comm,
31
const
char
* libraryName)
32
{
33
std::string libname(libraryName);
34
35
fei::SharedPtr<LinearSystemCore>
lsc;
36
fei::SharedPtr<FiniteElementData>
fedata;
37
fei::SharedPtr<LibraryWrapper>
wrapper;
38
39
if
(libname ==
"Aztec"
) {
40
#ifdef HAVE_FEI_AZTECOO
41
lsc.
reset
(
new
fei_trilinos::Aztec_LinSysCore
(comm));
42
#else
43
std::string msg(
"Aztec not available."
);
44
throw
std::runtime_error(msg);
45
#endif
46
}
47
48
if
(libname ==
"FETI"
) {
49
#ifdef HAVE_FEI_FETI
50
fedata.
reset
(
new
FETI_DP_FiniteElementData(comm));
51
#endif
52
}
53
54
if
(lsc.
get
() == NULL && fedata.
get
() == NULL) {
55
//libraryName not found
56
std::string msg(
"create_LibraryWrapper: "
);
57
msg += libraryName;
58
msg +=
" not a valid name."
;
59
throw
std::runtime_error(msg);
60
}
61
62
if
(lsc.
get
() != NULL) {
63
wrapper.
reset
(
new
LibraryWrapper
(lsc));
64
return
(wrapper);
65
}
66
67
if
(fedata.
get
() != NULL) {
68
wrapper.
reset
(
new
LibraryWrapper
(fedata));
69
return
(wrapper);
70
}
71
72
return
(wrapper);
73
}
74
75
//----------------------------------------------------------------------------
76
fei::SharedPtr<fei::Factory>
77
fei::create_fei_Factory
(
MPI_Comm
comm,
78
const
char
* libraryName)
79
{
80
std::string libname(libraryName);
81
82
if
(libname.find(
"Trilinos"
) != std::string::npos) {
83
fei::SharedPtr<fei::Factory>
factory(
new
Factory_Trilinos
(comm));
84
85
if
(libname.find(
"Amesos"
) != std::string::npos) {
86
fei::ParameterSet
paramset;
87
paramset.
add
(
fei::Param
(
"Trilinos_Solver"
,
"Amesos"
));
88
factory->parameters(paramset);
89
}
90
else
if
(libname.find(
"Aztec"
) != std::string::npos) {
91
92
//if libname contains "AztecOO" we'll return the Trilinos factory
93
//but if libname only contains "Aztec" then we want to skip on down
94
//and return an snl_fei::Factory with a Aztec LibraryWrapper...
95
96
if
(libname.find(
"AztecOO"
) != std::string::npos) {
97
return
(factory);
98
}
99
}
100
else
{
101
//This else handles the case where libname contains "Trilinos", but
102
//doesn't contain "Aztec" or "Amesos"...
103
return
(factory);
104
}
105
}
106
107
fei::SharedPtr<LibraryWrapper>
wrapper;
108
try
{
109
wrapper =
fei::create_LibraryWrapper
(comm, libraryName);
110
}
111
catch
(std::runtime_error& exc) {
112
std::string msg(
"create_fei_Factory: "
);
113
msg += exc.what();
114
throw
std::runtime_error(msg);
115
}
116
117
if
(wrapper.
get
() != NULL) {
118
fei::SharedPtr<fei::Factory>
factory(
new
snl_fei::Factory
(comm, wrapper));
119
return
(factory);
120
}
121
122
fei::SharedPtr<fei::Factory>
empty;
123
return
(empty);
124
}
125
LibraryFactory.hpp
Factory_Trilinos
Definition
fei_Factory_Trilinos.hpp:76
LibraryWrapper
Definition
fei_LibraryWrapper.hpp:18
fei::Param
Definition
fei_Param.hpp:23
fei::ParameterSet
Definition
fei_ParameterSet.hpp:46
fei::ParameterSet::add
void add(const Param ¶m, bool maintain_unique_keys=true)
Definition
fei_ParameterSet.hpp:235
fei::SharedPtr
Definition
fei_SharedPtr.hpp:65
fei::SharedPtr::reset
void reset(T *p=0)
Definition
fei_SharedPtr.hpp:203
fei::SharedPtr::get
T * get() const
Definition
fei_SharedPtr.hpp:242
fei_trilinos::Aztec_LinSysCore
Definition
fei_Aztec_LinSysCore.hpp:70
snl_fei::Factory
Definition
snl_fei_Factory.hpp:35
fei_Aztec_LinSysCore.hpp
fei_Factory_Trilinos.hpp
fei_LibraryWrapper.hpp
fei_macros.hpp
fei_mpi.h
MPI_Comm
#define MPI_Comm
Definition
fei_mpi.h:56
fei::create_fei_Factory
fei::SharedPtr< fei::Factory > create_fei_Factory(MPI_Comm comm, const char *libraryName)
Definition
LibraryFactory.cpp:77
fei::create_LibraryWrapper
fei::SharedPtr< LibraryWrapper > create_LibraryWrapper(MPI_Comm comm, const char *libraryName)
Definition
LibraryFactory.cpp:30
snl_fei_Factory.hpp
Generated by
1.17.0