FEI Package Browser (Single Doxygen Collection) Version of the Day
Loading...
Searching...
No Matches
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
14
16
17#include <snl_fei_Factory.hpp>
18
20#ifdef HAVE_FEI_AZTECOO
22#endif
23
24#ifdef HAVE_FEI_FETI
25#include <FETI_DP_FiniteElementData.h>
26#endif
27
28//----------------------------------------------------------------------------
31 const char* libraryName)
32{
33 std::string libname(libraryName);
34
38
39 if (libname == "Aztec") {
40#ifdef HAVE_FEI_AZTECOO
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//----------------------------------------------------------------------------
78 const char* libraryName)
79{
80 std::string libname(libraryName);
81
82 if (libname.find("Trilinos") != std::string::npos) {
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
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
123 return(empty);
124}
125
void add(const Param &param, bool maintain_unique_keys=true)
void reset(T *p=0)
T * get() const
#define MPI_Comm
Definition: fei_mpi.h:56
fei::SharedPtr< fei::Factory > create_fei_Factory(MPI_Comm comm, const char *libraryName)
fei::SharedPtr< LibraryWrapper > create_LibraryWrapper(MPI_Comm comm, const char *libraryName)