Teuchos::RCP<const Thyra::VectorBase<double> > Thyra::create_Vector( const RCP<const Epetra_Vector> &epetra_v, const RCP<const VectorSpaceBase<double> > &space_in ) { #ifdef TEUCHOS_DEBUG TEUCHOS_TEST_FOR_EXCEPT(space_in.get()==NULL); #endif RCP<const SpmdVectorSpaceBase<double> > space = Teuchos::rcp_dynamic_cast<const SpmdVectorSpaceBase<double> >( space_in,true); if(!epetra_v.get()) return Teuchos::null; // New local view of raw data double *localValues; epetra_v->ExtractView( &localValues ); // Build the Vector RCP<const SpmdVectorBase<double> > v = Teuchos::rcp( new DefaultSpmdVector<double>( space, Teuchos::arcp(localValues,0,epetra_v->Map().NumMyElements(),false), 1 ) ); Teuchos::set_extra_data<RCP<const Epetra_Vector> >( epetra_v, "Epetra_Vector", Teuchos::inOutArg(v) ); return v; }
Teuchos::RCP<const Thyra::MultiVectorBase<double> > Thyra::create_MultiVector( const RCP<const Epetra_MultiVector> &epetra_mv, const RCP<const VectorSpaceBase<double> > &range_in, const RCP<const VectorSpaceBase<double> > &domain_in ) { using Teuchos::rcp_dynamic_cast; #ifdef TEUCHOS_DEBUG TEUCHOS_TEST_FOR_EXCEPT(range_in.get()==NULL); #endif const RCP<const SpmdVectorSpaceBase<double> > range = Teuchos::rcp_dynamic_cast<const SpmdVectorSpaceBase<double> >( unwrapSingleProductVectorSpace(range_in), true ); RCP<const ScalarProdVectorSpaceBase<double> > domain = Teuchos::rcp_dynamic_cast<const ScalarProdVectorSpaceBase<double> >( unwrapSingleProductVectorSpace(domain_in), true ); if (!epetra_mv.get()) return Teuchos::null; if ( is_null(domain) ) { domain = rcp_dynamic_cast<const ScalarProdVectorSpaceBase<double> >( create_LocallyReplicatedVectorSpace(range,epetra_mv->NumVectors()) ); } // New local view of raw data double *localValues; int leadingDim; if( epetra_mv->ConstantStride() ) { epetra_mv->ExtractView( &localValues, &leadingDim ); } else { TEUCHOS_TEST_FOR_EXCEPT(true); // ToDo: Implement views of non-contiguous mult-vectors! } // Build the MultiVector RCP<const SpmdMultiVectorBase<double> > mv = Teuchos::rcp( new DefaultSpmdMultiVector<double>( range, domain, Teuchos::arcp(localValues,0,leadingDim*epetra_mv->NumVectors(),false), leadingDim ) ); Teuchos::set_extra_data<RCP<const Epetra_MultiVector> >( epetra_mv, "Epetra_MultiVector", Teuchos::inOutArg(mv) ); return mv; }