51 #include "Epetra_MpiComm.h" 52 #include "Epetra_BlockMap.h" 53 #include "Epetra_MultiVector.h" 59 RestrictedMultiVectorWrapper::RestrictedMultiVectorWrapper()
60 : proc_is_active(true),
61 subcomm_is_set(false),
62 MPI_SubComm_(MPI_COMM_NULL),
70 RestrictedMultiVectorWrapper::~RestrictedMultiVectorWrapper() {
72 delete RestrictedComm_;
76 int RestrictedMultiVectorWrapper::SetMPISubComm(MPI_Comm MPI_SubComm){
78 MPI_SubComm_=MPI_SubComm;
delete RestrictedComm_; subcomm_is_set=
true;
86 RestrictedMultiVectorWrapper::
87 restrict_comm (Teuchos::RCP<Epetra_MultiVector> input_mv)
93 const Epetra_MpiComm *InComm =
94 dynamic_cast<const Epetra_MpiComm*
> (& (input_mv_->Comm ()));
95 const Epetra_BlockMap *InMap =
96 dynamic_cast<const Epetra_BlockMap*
> (& (input_mv_->Map ()));
98 if (! InComm || ! InMap) {
102 if (! subcomm_is_set) {
105 if (InMap->NumMyElements()) {
109 color = MPI_UNDEFINED;
112 MPI_Comm_split (InComm->Comm(), color, InComm->MyPID(), &MPI_SubComm_);
113 if (err != MPI_SUCCESS) {
120 if (input_mv->MyLength() && MPI_SubComm_ == MPI_COMM_NULL) {
126 if (MPI_SubComm_ == MPI_COMM_NULL) {
127 proc_is_active =
false;
130 proc_is_active =
true;
133 int Nrows = InMap->NumGlobalElements ();
135 if (proc_is_active) {
136 RestrictedComm_ =
new Epetra_MpiComm (MPI_SubComm_);
139 ResMap_ =
new Epetra_BlockMap (Nrows, InMap->NumMyElements(),
140 InMap->MyGlobalElements(),
141 InMap->ElementSizeList(),
142 InMap->IndexBase(), *RestrictedComm_);
146 input_mv_->ExtractView (&A,&LDA);
147 restricted_mv_ = rcp (
new Epetra_MultiVector (View, *ResMap_, A, LDA,
148 input_mv_->NumVectors ()));
EpetraExt::BlockCrsMatrix: A class for constructing a distributed block matrix.