11#include "Thyra_DefaultSpmdVectorSpace.hpp" 
   12#include "Thyra_DefaultSpmdMultiVector.hpp" 
   13#include "Thyra_DefaultSpmdVector.hpp" 
   14#include "Thyra_DetachedVectorView.hpp" 
   15#include "Thyra_DetachedMultiVectorView.hpp" 
   16#include "Thyra_VectorSpaceFactoryBase.hpp" 
   17#include "Thyra_ProductVectorSpaceBase.hpp" 
   18#include "Teuchos_Assert.hpp" 
   19#include "Teuchos_dyn_cast.hpp" 
   21#include "Teuchos_DefaultSerialComm.hpp" 
   23#include "Teuchos_DefaultMpiComm.hpp" 
   26#include "Epetra_Map.h" 
   27#include "Epetra_Comm.h" 
   28#include "Epetra_SerialComm.h" 
   30#  include "Epetra_MpiComm.h" 
   32#include "Epetra_MultiVector.h" 
   33#include "Epetra_Vector.h" 
   44unwrapSingleProductVectorSpace(
 
   49  using Teuchos::rcp_dynamic_cast;
 
   51  const RCP<const ProductVectorSpaceBase<double> > pvs =
 
   52    rcp_dynamic_cast<const ProductVectorSpaceBase<double> >(vs_in);
 
   55    return pvs->getBlock(0);
 
   73  using Teuchos::rcp_dynamic_cast;
 
   74  using Teuchos::set_extra_data;
 
   77    serialEpetraComm = rcp_dynamic_cast<const Epetra_SerialComm>(epetraComm);
 
   78  if( serialEpetraComm.
get() ) {
 
   81    set_extra_data( serialEpetraComm, 
"serialEpetraComm", Teuchos::inOutArg(serialComm) );
 
   88    mpiEpetraComm = rcp_dynamic_cast<const Epetra_MpiComm>(epetraComm);
 
   89  if( mpiEpetraComm.
get() ) {
 
   91      rawMpiComm = Teuchos::opaqueWrapper(mpiEpetraComm->Comm());
 
   92    set_extra_data( mpiEpetraComm, 
"mpiEpetraComm", Teuchos::inOutArg(rawMpiComm) );
 
 
  115    !epetra_map.
get(), std::invalid_argument,
 
  116    "create_VectorSpace::initialize(...): Error!" );
 
  122  Teuchos::set_extra_data(epetra_map, 
"epetra_map", inoutArg(comm));
 
  123  const Ordinal localSubDim = epetra_map->NumMyElements();
 
  126    defaultSpmdVectorSpace<double>(
 
  127      comm, localSubDim, epetra_map->NumGlobalElements64(),
 
  128      !epetra_map->DistributedGlobal());
 
  138  Teuchos::set_extra_data( epetra_map, 
"epetra_map", inoutArg(vs) );
 
 
  150  using Teuchos::rcp_dynamic_cast;
 
  156  return parentSpace->smallVecSpcFcty()->createVecSpc(dim);
 
 
  180  epetra_v->ExtractView( &localValues );
 
  186        Teuchos::arcp(localValues,0,epetra_v->Map().NumMyElements(),
false),
 
  191    Teuchos::inOutArg(v) );
 
 
  216  epetra_v->ExtractView( &localValues );
 
  222        Teuchos::arcp(localValues,0,epetra_v->Map().NumMyElements(),
false),
 
  227    Teuchos::inOutArg(v) );
 
 
  239  using Teuchos::rcp_dynamic_cast;
 
  245      unwrapSingleProductVectorSpace(range_in),
 
  250      unwrapSingleProductVectorSpace(domain_in),
 
  257  if (!epetra_mv.
get() )
 
  259  if ( is_null(domain) ) {
 
  260    domain = rcp_dynamic_cast<const ScalarProdVectorSpaceBase<double> >(
 
  265  double *localValues; 
int leadingDim;
 
  266  if( epetra_mv->ConstantStride() ) {
 
  267    epetra_mv->ExtractView( &localValues, &leadingDim );
 
  278        Teuchos::arcp(localValues,0,leadingDim*epetra_mv->NumVectors(),
false),
 
  283    epetra_mv, 
"Epetra_MultiVector", Teuchos::inOutArg(mv) );
 
 
  295  using Teuchos::rcp_dynamic_cast;
 
  301      unwrapSingleProductVectorSpace(range_in),
 
  306      unwrapSingleProductVectorSpace(domain_in),
 
  313  if (!epetra_mv.
get())
 
  315  if ( is_null(domain) ) {
 
  316    domain = rcp_dynamic_cast<const ScalarProdVectorSpaceBase<double> >(
 
  321  double *localValues; 
int leadingDim;
 
  322  if( epetra_mv->ConstantStride() ) {
 
  323    epetra_mv->ExtractView( &localValues, &leadingDim );
 
  334        Teuchos::arcp(localValues,0,leadingDim*epetra_mv->NumVectors(),
false),
 
  339    epetra_mv, 
"Epetra_MultiVector", Teuchos::inOutArg(mv) );
 
 
  349  using Teuchos::ptrFromRef;
 
  350  using Teuchos::ptr_dynamic_cast;
 
  359    ptr_dynamic_cast<const SerialComm<Ordinal> >(comm);
 
  366    ptr_dynamic_cast<const MpiComm<Ordinal> >(comm);
 
  370    "SPMD std::vector space has a communicator that is " 
  371    "neither a serial comm nor an MPI comm");
 
  373  if (nonnull(mpiComm)) {
 
  374    epetraComm = rcp(
new Epetra_MpiComm(*mpiComm->getRawMpiComm()()));
 
  383    "SPMD std::vector space has a communicator that is " 
  384    "neither a serial comm nor an MPI comm");
 
  391    "null communicator created");
 
 
  404  using Teuchos::rcpFromRef;
 
  405  using Teuchos::rcpFromPtr;
 
  406  using Teuchos::rcp_dynamic_cast;
 
  407  using Teuchos::ptrFromRef;
 
  408  using Teuchos::ptr_dynamic_cast;
 
  413    ptr_dynamic_cast<const SpmdVectorSpaceBase<double> >(vs_ptr);
 
  416    ptr_dynamic_cast<const ProductVectorSpaceBase<double> >(vs_ptr);
 
  419    "Error, the concrete VectorSpaceBase object of type " 
  421    " SpmdVectorSpaceBase or the ProductVectorSpaceBase interfaces!" );
 
  423  const int numBlocks = (nonnull(prod_vs) ? prod_vs->numBlocks() : 1);
 
  428  if (nonnull(prod_vs)) {
 
  429    for (
int block_i = 0; block_i < numBlocks; ++block_i) {
 
  431        rcp_dynamic_cast<const SpmdVectorSpaceBase<double> >(
 
  432          prod_vs->getBlock(block_i), 
true);
 
  437    spmd_vs_blocks.
push_back(rcpFromPtr(spmd_vs));
 
  442  int myLocalElements = 0;
 
  443  for (
int block_i = 0; block_i < numBlocks; ++block_i) {
 
  444    myLocalElements += spmd_vs_blocks[block_i]->localSubDim();
 
  451#ifndef EPETRA_NO_32BIT_GLOBAL_INDICES 
  456  for (
int block_i = 0; block_i < numBlocks; ++block_i) {
 
  458    const int lowGIDInBlock = spmd_vs_i->localOffset();
 
  459    const int numLocalElementsInBlock = spmd_vs_i->localSubDim();
 
  460    for (
int i=0; i < numLocalElementsInBlock; ++i, ++count) {
 
  461      myGIDs[count] = blockOffset + lowGIDInBlock + i;
 
  463    blockOffset += spmd_vs_i->dim();
 
  466#ifndef EPETRA_NO_32BIT_GLOBAL_INDICES 
  467  const int globalDim = vs_in.
dim();
 
  469  const long long globalDim = vs_in.
dim();
 
 
  481  const RCP<
const VectorSpaceBase<double>>& vs,
 
  482  const RCP<const Epetra_Comm>& comm)
 
  488  const Ptr<const RCP<const Epetra_Map> >
 
  493  if(!is_null(epetra_map_ptr)) {
 
  494    return *epetra_map_ptr;
 
  499                             "Error! No RCP Epetra_Map attached to the input vector space RCP, " 
  500                             "and the input comm RCP is null.\n");
 
  511  using Teuchos::get_optional_extra_data;
 
  516    "Thyra::get_Epetra_Vector(map,v)", *epetra_vs, *v->space() );
 
  523    epetra_v_ptr = get_optional_extra_data<RCP<Epetra_Vector> >(
 
  527  if(!is_null(epetra_v_ptr)) {
 
  528    return *epetra_v_ptr;
 
  558        ,
Range1D(localOffset,localOffset+localSubDim-1)
 
  569        ,
const_cast<double*
>(emvv->values())   
 
  577  Teuchos::set_extra_data( emvv, 
"emvv", Teuchos::inOutArg(epetra_v),
 
 
  587  const RCP<VectorBase<double> > &v,
 
  588  const RCP<const Epetra_Map>& map
 
  595  const Ptr<const RCP<Epetra_Vector> >
 
  600  if(!is_null(epetra_v_ptr)) {
 
  601    return *epetra_v_ptr;
 
  606                            "Error! No RCP Epetra_Vector attached to the input vector RCP, " 
  607                            "and the input map RCP is null.\n");
 
  618  using Teuchos::get_optional_extra_data;
 
  623    "Thyra::get_Epetra_Vector(map,v)", *epetra_vs, *v->space() );
 
  630    epetra_v_ptr = get_optional_extra_data<RCP<const Epetra_Vector> >(
 
  634  if(!is_null(epetra_v_ptr))
 
  635    return *epetra_v_ptr;
 
  637    epetra_nonconst_v_ptr = get_optional_extra_data<RCP<Epetra_Vector> >(
 
  641  if(!is_null(epetra_nonconst_v_ptr))
 
  642    return *epetra_nonconst_v_ptr;
 
  657        ,
Range1D(localOffset,localOffset+localSubDim-1)
 
  668        ,
const_cast<double*
>(evv->values())     
 
  676  Teuchos::set_extra_data( evv, 
"evv", Teuchos::inOutArg(epetra_v),
 
 
  686  const RCP<
const VectorBase<double> > &v,
 
  687  const RCP<const Epetra_Map>& map
 
  694  const Ptr<const RCP<const Epetra_Vector> >
 
  699  if(!is_null(epetra_v_ptr)) {
 
  700    return *epetra_v_ptr;
 
  705                             "Error! No RCP to Epetra_Vector attached to the input vector RCP, " 
  706                             "and the input map RCP is null.\n");
 
  717  using Teuchos::get_optional_extra_data;
 
  722    "Thyra::get_Epetra_MultiVector(map,mv)", *epetra_vs, *mv->range() );
 
  729    epetra_mv_ptr = get_optional_extra_data<RCP<Epetra_MultiVector> >(
 
  730      mv,
"Epetra_MultiVector");
 
  733  if(!is_null(epetra_mv_ptr)) {
 
  734    return *epetra_mv_ptr;
 
  761        ,
Range1D(localOffset,localOffset+localSubDim-1)
 
  771        ,
const_cast<double*
>(emmvv->values())   
 
  782  Teuchos::set_extra_data( emmvv, 
"emmvv", Teuchos::inOutArg(epetra_mv),
 
  785  Teuchos::set_extra_data( mv, 
"mv", Teuchos::inOutArg(epetra_mv) );
 
 
  794  const RCP<MultiVectorBase<double> > &mv,
 
  795  const RCP<const Epetra_Map>& map
 
  802  const Ptr<const RCP<Epetra_MultiVector> >
 
  804      mv,
"Epetra_MultiVector");
 
  807  if(!is_null(epetra_mv_ptr)) {
 
  808    return *epetra_mv_ptr;
 
  813                             "Error! No RCP to Epetra_MultiVector attached to the input vector RCP, " 
  814                             "and the input map RCP is null.\n");
 
  825  using Teuchos::get_optional_extra_data;
 
  832    "Thyra::get_Epetra_MultiVector(map,mv)",
 
  833    *epetra_vs, *mv->range() );
 
  842    = get_optional_extra_data<RCP<const Epetra_MultiVector> >(
 
  843      mv,
"Epetra_MultiVector" );
 
  846  if(!is_null(epetra_mv_ptr)) {
 
  847    return *epetra_mv_ptr;
 
  864        ,
Range1D(localOffset,localOffset+localSubDim-1)
 
  875        ,
const_cast<double*
>(emvv->values())    
 
  886  Teuchos::set_extra_data( emvv, 
"emvv", Teuchos::inOutArg(epetra_mv),
 
  889  Teuchos::set_extra_data( mv, 
"mv", Teuchos::inOutArg(epetra_mv) );
 
 
  899  const RCP<
const MultiVectorBase<double> > &mv,
 
  900  const RCP<const Epetra_Map>& map
 
  907  const Ptr<const RCP<const Epetra_MultiVector> >
 
  909      mv,
"Epetra_MultiVector");
 
  912  if(!is_null(epetra_mv_ptr)) {
 
  913    return *epetra_mv_ptr;
 
  918                             "Error! No RCP to Epetra_MultiVector attached to the input vector RCP, " 
  919                             "and the input map RCP is null.\n");
 
  930  using Teuchos::rcpWithEmbeddedObj;
 
  931  using Teuchos::ptrFromRef;
 
  932  using Teuchos::ptr_dynamic_cast;
 
  933  using Teuchos::outArg;
 
  936    ptr_dynamic_cast<SpmdMultiVectorBase<double> >(ptrFromRef(mv));
 
  940  if (nonnull(mvSpmdMv)) {
 
  941    mvSpmdMv->getNonconstLocalData(outArg(mvData), outArg(mvLeadingDim));
 
  944  return rcpWithEmbeddedObj(
 
  946      ::View, map, mvData.getRawPtr(), mvLeadingDim, mv.
domain()->dim()
 
 
  959  using Teuchos::rcpWithEmbeddedObj;
 
  960  using Teuchos::ptrFromRef;
 
  961  using Teuchos::ptr_dynamic_cast;
 
  962  using Teuchos::outArg;
 
  965    ptr_dynamic_cast<const SpmdMultiVectorBase<double> >(ptrFromRef(mv));
 
  969  if (nonnull(mvSpmdMv)) {
 
  970    mvSpmdMv->getLocalData(outArg(mvData), outArg(mvLeadingDim));
 
  973  return rcpWithEmbeddedObj(
 
  975      ::View, map, 
const_cast<double*
>(mvData.getRawPtr()), mvLeadingDim, mv.
domain()->dim()
 
 
void push_back(const value_type &x)
 
const RCP< T > & assert_not_null() const
 
Create an explicit non-mutable (const) view of a MultiVectorBase object.
 
Create an explicit non-mutable (const) view of a VectorBase object.
 
Efficient concrete implementation subclass for SPMD multi-vectors.
 
Efficient concrete implementation subclass for SPMD vectors.
 
Create an explicit mutable (non-const) view of a MultiVectorBase object.
 
Create an explicit mutable (non-const) view of a VectorBase object.
 
virtual RCP< const VectorSpaceBase< Scalar > > domain() const =0
Return a smart pointer for the domain space for this operator.
 
Interface for a collection of column vectors called a multi-vector.
 
Base abstract VectorSpaceBase class for all SPMD-based vector spaces.
 
virtual Ordinal localSubDim() const =0
Returns the number of local elements stored on this process.
 
virtual Ordinal localOffset() const =0
Returns the offset for the local sub-vector stored on this process.
 
Abstract interface for finite-dimensional dense vectors.
 
Abstract interface for objects that represent a space for vectors.
 
virtual Ordinal dim() const =0
Return the dimension of the vector space.
 
RCP< const Epetra_Comm > get_Epetra_Comm(const Teuchos::Comm< Ordinal > &comm)
Get (or create) and Epetra_Comm given a Teuchos::Comm object.
 
RCP< VectorBase< double > > create_Vector(const RCP< Epetra_Vector > &epetra_v, const RCP< const VectorSpaceBase< double > > &space=Teuchos::null)
Create a non-const VectorBase object from a non-const Epetra_Vector object.
 
RCP< MultiVectorBase< double > > create_MultiVector(const RCP< Epetra_MultiVector > &epetra_mv, const RCP< const VectorSpaceBase< double > > &range=Teuchos::null, const RCP< const VectorSpaceBase< double > > &domain=Teuchos::null)
Create a non-const MultiVectorBase object from a non-const Epetra_MultiVector object.
 
RCP< const Teuchos::Comm< Ordinal > > create_Comm(const RCP< const Epetra_Comm > &epetraComm)
Given an Epetra_Comm object, return an equivalent Teuchos::Comm object.
 
RCP< const VectorSpaceBase< double > > create_VectorSpace(const RCP< const Epetra_Map > &epetra_map)
Create an VectorSpaceBase object given an Epetra_Map object.
 
RCP< Epetra_Vector > get_Epetra_Vector(const Epetra_Map &map, const RCP< VectorBase< double > > &v)
Get a non-const Epetra_Vector view from a non-const VectorBase object if possible.
 
RCP< const Epetra_Map > get_Epetra_Map(const VectorSpaceBase< double > &vs, const RCP< const Epetra_Comm > &comm)
Get (or create) an Epetra_Map object given an VectorSpaceBase object an optionally an extra Epetra_Co...
 
RCP< Epetra_MultiVector > get_Epetra_MultiVector(const Epetra_Map &map, const RCP< MultiVectorBase< double > > &mv)
Get a non-const Epetra_MultiVector view from a non-const MultiVectorBase object if possible.
 
RCP< const VectorSpaceBase< double > > create_LocallyReplicatedVectorSpace(const RCP< const VectorSpaceBase< double > > &parentSpace, const int dim)
Create a VectorSpaceBase object that creates locally replicated vector objects.
 
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
 
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
 
#define TEUCHOS_ASSERT_EQUALITY(val1, val2)
 
bool nonnull(const std::shared_ptr< T > &p)
 
#define THYRA_ASSERT_VEC_SPACES(FUNC_NAME, VS1, VS2)
This is a very useful macro that should be used to validate that two vector spaces are compatible.
 
Teuchos::Ordinal Ordinal
Type for the dimension of a vector space. `*.
 
TypeTo as(const TypeFrom &t)
 
T_To & dyn_cast(T_From &from)
 
TEUCHOSCORE_LIB_DLL_EXPORT std::string demangleName(const std::string &mangledName)
 
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)