47 #include "AbstractLinAlgPack_ThyraAccessors.hpp"
48 #include "AbstractLinAlgPack_VectorMutableThyra.hpp"
49 #include "Teuchos_dyn_cast.hpp"
51 void AbstractLinAlgPack::get_thyra_vector(
52 const VectorSpaceThyra &thyra_vec_spc
60 const VectorMutableThyra *vmthyra_vec =
dynamic_cast<const VectorMutableThyra*
>(&vec);
63 *thyra_vec = vmthyra_vec->thyra_vec();
65 else if(vec.space().is_in_core()) {
68 _thyra_vec = ::Thyra::createMember(thyra_vec_spc.thyra_vec_spc());
70 RTOpPack::SubVector vec_sv;
71 vec.get_sub_vector(
Range1D(), &vec_sv );
73 _thyra_vec->acquireDetachedView( convert(
Range1D()), &_thyra_vec_sv );
78 for(
int i = 0; i < vec_sv.subDim(); ++i )
79 _thyra_vec_sv[i] = vec_sv[i];
81 vec.free_sub_vector( &vec_sv );
82 _thyra_vec->commitDetachedView( &_thyra_vec_sv );
84 *thyra_vec = _thyra_vec;
88 true, std::logic_error
89 ,
"AbstractLinAlgPack::get_thyra_vector(...): Error, the vector of concrete type \'"
90 <<
typeName(vec) <<
"\' is not an incore vector."
95 void AbstractLinAlgPack::free_thyra_vector(
96 const VectorSpaceThyra &thyra_vec_spc
104 *thyra_vec = Teuchos::null;
107 void AbstractLinAlgPack::get_thyra_vector(
108 const VectorSpaceThyra &thyra_vec_spc
116 VectorMutableThyra *vmthyra_vec =
dynamic_cast<VectorMutableThyra*
>(vec);
119 *thyra_vec = vmthyra_vec->set_uninitialized();
121 else if(thyra_vec_spc.is_in_core()) {
124 _thyra_vec = ::Thyra::createMember(thyra_vec_spc.thyra_vec_spc());
126 RTOpPack::SubVector vec_sv;
127 vec->get_sub_vector(
Range1D(), &vec_sv );
129 _thyra_vec->acquireDetachedView( convert(
Range1D()), &_thyra_vec_sv );
134 for(
int i = 0; i < vec_sv.subDim(); ++i )
135 _thyra_vec_sv[i] = vec_sv[i];
137 vec->free_sub_vector( &vec_sv );
138 _thyra_vec->commitDetachedView( &_thyra_vec_sv );
140 *thyra_vec = _thyra_vec;
144 true, std::logic_error
145 ,
"AbstractLinAlgPack::get_thyra_vector(...): Error, the vector of concrete type \'"
146 <<
typeName(vec) <<
"\' is not an incore vector."
151 void AbstractLinAlgPack::commit_thyra_vector(
152 const VectorSpaceThyra &thyra_vec_spc
161 VectorMutableThyra *vmthyra_vec =
dynamic_cast<VectorMutableThyra*
>(vec);
164 vmthyra_vec->initialize(thyra_vec);
166 else if(thyra_vec_spc.is_in_core()) {
170 thyra_vec->acquireDetachedView( convert(
Range1D()), &thyra_vec_sv );
171 RTOpPack::MutableSubVector vec_sv;
172 vec->get_sub_vector(
Range1D(), &vec_sv );
177 for(
int i = 0; i < vec_sv.subDim(); ++i )
178 vec_sv[i] = thyra_vec_sv[i];
180 thyra_vec->releaseDetachedView( &thyra_vec_sv );
181 vec->commit_sub_vector( &vec_sv );
183 thyra_vec = Teuchos::null;
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
std::string typeName(const T &t)