FEI Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
test_Factory.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 #include <fei_mpi.h>
11 
13 
15 
18 
19 #include <fei_Factory.hpp>
20 #include <snl_fei_Factory.hpp>
21 
23 
24 #ifdef HAVE_FEI_AZTECOO
25 #include <fei_Aztec_LinSysCore.hpp>
26 #endif
27 
28 #include <fei_Factory_Trilinos.hpp>
29 
30 #undef fei_file
31 #define fei_file "test_Factory.cpp"
32 #include <fei_ErrMacros.hpp>
33 
35  : tester(comm)
36 {
37 }
38 
40 {
41 }
42 
44 {
46  {
47  if (localProc_==0) FEI_COUT << "constructing Factory_Trilinos...";
48 
50 
51  if (localProc_==0) FEI_COUT << "ok" << FEI_ENDL;
52 
53  factory_test1(factory);
54 
55  if (localProc_==0) FEI_COUT << "testing fei::Factory::clone..." << FEI_ENDL;
56 
57  fei::SharedPtr<fei::Factory> clone(factory->clone());
58 
59  factory_test1(clone);
60 
61  FEI_COUT << FEI_ENDL;
62  }
63 
64 #ifdef HAVE_FEI_AZTECOO
65  {
67  if (localProc_==0) FEI_COUT << "constructing snl_fei::Factory(Aztec)...";
68 
70 
72 
73  if (localProc_==0) FEI_COUT << "ok" << FEI_ENDL;
74 
75  factory_test1(factory);
76 
77  if (localProc_==0) FEI_COUT << "testing fei::Factory::clone..." << FEI_ENDL;
78 
79  fei::SharedPtr<fei::Factory> clone(factory->clone());
80 
81  factory_test1(clone);
82 
83  FEI_COUT << FEI_ENDL;
84  }
85 
86 #endif
87  return(0);
88 }
89 
91 {
92  if (localProc_==0) FEI_COUT << " testing factory->createVectorSpace...";
93 
95  factory->createVectorSpace(comm_, "dummy_Name");
96 
97  if (vecspace.get() == 0) {
98  FEI_COUT << "no"<<FEI_ENDL;
99  throw std::runtime_error("factory failed to create a fei::VectorSpace");
100  }
101 
102  //do an extremely simple test to make sure the vector-space
103  //is 'alive'.
104  int fieldID = 0;
105  int fieldSize = 3;
106  vecspace->defineFields(1, &fieldID, &fieldSize);
107 
108  if (vecspace->getNumFields() != 1) {
109  FEI_COUT << "no"<<FEI_ENDL;
110  throw std::runtime_error("vecspace->defineFields/getNumFields failed.");
111  }
112 
113  if (localProc_==0) FEI_COUT << "ok"<<FEI_ENDL;
114 
115  if (localProc_==0) FEI_COUT << " testing factory->createFEI...";
116 
117  fei::SharedPtr<FEI> fei = factory->createFEI(comm_);
118 
119  //again, do a simple test to make sure the FEI instance is alive...
120 
121  int err = fei->initFields(1, &fieldSize, &fieldID);
122  if (err != 0) {
123  FEI_COUT << "failed"<<FEI_ENDL;
124  throw std::runtime_error("fei->initFields() failed.");
125  }
126 
127  int testFieldSize = -1;
128  err = fei->getFieldSize(fieldID, testFieldSize);
129  if (err != 0 || testFieldSize != fieldSize) {
130  FEI_COUT << "failed"<<FEI_ENDL;
131  throw std::runtime_error("fei->getFieldSize() failed.");
132  }
133 
134  if (localProc_==0) FEI_COUT << "ok"<<FEI_ENDL;
135 }
#define FEI_COUT
MPI_Comm comm_
Definition: tester.hpp:37
int localProc_
Definition: tester.hpp:38
void defineFields(int numFields, const int *fieldIDs, const int *fieldSizes, const int *fieldTypes=NULL)
virtual ~test_Factory()
#define MPI_Comm
Definition: fei_mpi.h:56
virtual fei::SharedPtr< VectorSpace > createVectorSpace(MPI_Comm, const char *name)
virtual int initFields(int numFields, const int *fieldSizes, const int *fieldIDs, const int *fieldTypes=NULL)=0
virtual int getFieldSize(int fieldID, int &numScalars)=0
T * get() const
virtual fei::SharedPtr< Factory > clone() const =0
#define FEI_ENDL
test_Factory(MPI_Comm comm)
virtual fei::SharedPtr< FEI > createFEI(fei::SharedPtr< LibraryWrapper > wrapper, MPI_Comm comm)
Definition: fei_Factory.cpp:65
void factory_test1(fei::SharedPtr< fei::Factory > factory)