FEI Package Browser (Single Doxygen Collection)
Version of the Day
test_utils
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
12
#include <
test_utils/test_Factory.hpp
>
13
14
#include <
test_utils/LibraryFactory.hpp
>
15
16
#include <
test_utils/test_VectorSpace.hpp
>
17
#include <
test_utils/test_MatrixGraph.hpp
>
18
19
#include <
fei_Factory.hpp
>
20
#include <
snl_fei_Factory.hpp
>
21
22
#include <
test_utils/test_Factory_helper.hpp
>
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
34
test_Factory::test_Factory
(
MPI_Comm
comm)
35
:
tester
(comm)
36
{
37
}
38
39
test_Factory::~test_Factory
()
40
{
41
}
42
43
int
test_Factory::runtests
()
44
{
46
{
47
if
(
localProc_
==0)
FEI_COUT
<<
"constructing Factory_Trilinos..."
;
48
49
fei::SharedPtr<fei::Factory>
factory(
new
Factory_Trilinos
(
comm_
));
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
69
fei::SharedPtr<LinearSystemCore>
az_lsc(
new
fei_trilinos::Aztec_LinSysCore
(
comm_
));
70
71
fei::SharedPtr<fei::Factory>
factory(
new
snl_fei::Factory
(
comm_
, az_lsc));
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
90
void
test_Factory::factory_test1
(
fei::SharedPtr<fei::Factory>
factory)
91
{
92
if
(
localProc_
==0)
FEI_COUT
<<
" testing factory->createVectorSpace..."
;
93
94
fei::SharedPtr<fei::VectorSpace>
vecspace =
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
}
tester::localProc_
int localProc_
Definition:
tester.hpp:38
fei::Factory::clone
virtual fei::SharedPtr< Factory > clone() const =0
FEI_ENDL
#define FEI_ENDL
Definition:
fei_iostream.hpp:34
fei::SharedPtr::get
T * get() const
Definition:
fei_SharedPtr.hpp:242
fei::SharedPtr< fei::Factory >
fei_macros.hpp
fei::VectorSpace::Factory::createVectorSpace
virtual fei::SharedPtr< VectorSpace > createVectorSpace(MPI_Comm, const char *name)
Definition:
fei_VectorSpace.cpp:131
fei_trilinos::Aztec_LinSysCore
Definition:
fei_Aztec_LinSysCore.hpp:70
LibraryFactory.hpp
fei_Factory.hpp
tester::comm_
MPI_Comm comm_
Definition:
tester.hpp:37
test_Factory_helper.hpp
fei::VectorSpace::defineFields
void defineFields(int numFields, const int *fieldIDs, const int *fieldSizes, const int *fieldTypes=NULL)
Definition:
fei_VectorSpace.cpp:260
test_MatrixGraph.hpp
fei_Aztec_LinSysCore.hpp
test_Factory.hpp
fei_mpi.h
test_Factory::runtests
int runtests()
Definition:
test_Factory.cpp:43
test_VectorSpace.hpp
snl_fei::Factory
Definition:
snl_fei_Factory.hpp:35
fei::VectorSpace::getNumFields
int getNumFields()
Definition:
fei_VectorSpace.cpp:1288
test_Factory::~test_Factory
virtual ~test_Factory()
Definition:
test_Factory.cpp:39
fei
Definition:
fei_ArrayUtils.hpp:16
test_Factory::test_Factory
test_Factory(MPI_Comm comm)
Definition:
test_Factory.cpp:34
FEI_COUT
#define FEI_COUT
Definition:
fei_iostream.hpp:33
MPI_Comm
#define MPI_Comm
Definition:
fei_mpi.h:56
test_Factory::factory_test1
void factory_test1(fei::SharedPtr< fei::Factory > factory)
Definition:
test_Factory.cpp:90
fei_ErrMacros.hpp
fei_Factory_Trilinos.hpp
tester
Definition:
tester.hpp:22
Factory_Trilinos
Definition:
fei_Factory_Trilinos.hpp:76
snl_fei_Factory.hpp
fei::Factory::createFEI
virtual fei::SharedPtr< FEI > createFEI(fei::SharedPtr< LibraryWrapper > wrapper, MPI_Comm comm)
Definition:
fei_Factory.cpp:65
Generated by
1.8.16