9 #include <fei_macros.hpp>
11 #include <test_utils/test_Vector.hpp>
12 #include <test_utils/test_VectorSpace.hpp>
13 #include <test_utils/test_MatrixGraph.hpp>
15 #include <fei_Factory.hpp>
16 #include <snl_fei_Factory.hpp>
17 #include <fei_Vector_Impl.hpp>
19 #include <test_utils/LibraryFactory.hpp>
21 #ifdef HAVE_FEI_AZTECOO
22 #include <fei_Aztec_LinSysCore.hpp>
24 #include <fei_Factory_Trilinos.hpp>
27 #define fei_file "test_Vector.cpp"
28 #include <fei_ErrMacros.hpp>
31 test_Vector::test_Vector(MPI_Comm comm)
36 test_Vector::~test_Vector()
40 int test_Vector::runtests()
46 if (localProc_==0) FEI_COUT <<
"getting fei::Vector from Factory_Trilinos..."
50 vector_test1(fei_vec);
52 if (localProc_==0) FEI_COUT << FEI_ENDL;
60 testData test_data(localProc_, numProcs_);
63 test_VectorSpace::create_VectorSpace(comm_, &test_data, localProc_, numProcs_,
64 false,
false, (
const char*)0, factory);
67 FEI_COUT <<
"ERROR, failed to create valid fei::VectorSpace." << FEI_ENDL;
68 throw std::runtime_error(
"test_Vector::create_vector: ERROR, failed to create valid fei::VectorSpace.");
71 if (localProc_==0) FEI_COUT <<
" creating fei::Vector instance... ";
75 if (localProc_==0) FEI_COUT <<
"ok" << FEI_ENDL;
83 FEI_COUT <<
" vector_test1: testing fei::Vector with type '"
84 << fei_vec->
typeName() <<
"':"<<FEI_ENDL;
88 std::vector<int> global_offsets;
91 int i, my_first_offset = global_offsets[localProc_];
92 int my_last_offset = global_offsets[localProc_+1]-1;
93 int num_local_indices = my_last_offset - my_first_offset + 1;
95 std::vector<double> coefs(num_local_indices, 1.0);
96 std::vector<double> check_coefs(num_local_indices);
97 std::vector<int> indices(num_local_indices);
98 for(i=0; i<num_local_indices; ++i) {
99 indices[i] = my_first_offset + i;
103 FEI_COUT <<
" testing fei::Vector::copyIn/copyOut...";
105 int errcode = fei_vec->
copyIn(num_local_indices, &indices[0], &coefs[0]);
107 throw std::runtime_error(
"nonzero errcode from fei_vec->copyIn");
110 errcode = fei_vec->
copyOut(num_local_indices, &indices[0], &check_coefs[0]);
112 throw std::runtime_error(
"nonzero errcode from fei_vec->copyOut");
115 if (coefs != check_coefs) {
116 throw std::runtime_error(
"fei_vec->copyOut didn't produce the right coefs");
120 FEI_COUT <<
"ok"<<FEI_ENDL <<
" testing fei::Vector::putScalar...";
125 throw std::runtime_error(
"nonzero errcode from fei_vec->putScalar");
128 errcode = fei_vec->
copyOut(num_local_indices, &indices[0], &check_coefs[0]);
130 throw std::runtime_error(
"nonzero errcode from fei_vec->copyOut");
133 for(i=0; i<num_local_indices; ++i) {
134 if (std::abs(check_coefs[i]) > 1.e-38) {
135 throw std::runtime_error(
"fei_vec->putScalar(0.0) didn't zero the vector");
139 if (localProc_==0) FEI_COUT <<
"ok"<<FEI_ENDL;
virtual fei::SharedPtr< fei::VectorSpace > getVectorSpace() const =0
virtual int copyIn(int numValues, const int *indices, const double *values, int vectorIndex=0)=0
virtual int putScalar(double scalar)=0
virtual fei::SharedPtr< fei::Vector > createVector(fei::SharedPtr< fei::VectorSpace > vecSpace, int numVectors=1)=0
virtual const char * typeName() const =0
void getGlobalIndexOffsets(std::vector< int > &globalOffsets) const
virtual int copyOut(int numValues, const int *indices, double *values, int vectorIndex=0) const =0