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 if (proc_is_active) {
135 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES 136 if(InMap->GlobalIndicesInt()) {
137 int Nrows = InMap->NumGlobalElements ();
138 RestrictedComm_ =
new Epetra_MpiComm (MPI_SubComm_);
141 ResMap_ =
new Epetra_BlockMap (Nrows, InMap->NumMyElements(),
142 InMap->MyGlobalElements(),
143 InMap->ElementSizeList(),
144 InMap->IndexBase(), *RestrictedComm_);
148 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES 149 if(InMap->GlobalIndicesLongLong()) {
150 long long Nrows = InMap->NumGlobalElements64 ();
151 RestrictedComm_ =
new Epetra_MpiComm (MPI_SubComm_);
154 ResMap_ =
new Epetra_BlockMap (Nrows, InMap->NumMyElements(),
155 InMap->MyGlobalElements64(),
156 InMap->ElementSizeList(),
157 InMap->IndexBase64(), *RestrictedComm_);
161 throw "EpetraExt::RestrictedMultiVectorWrapper::restrict_comm ERROR: GlobalIndices type unknown";
166 input_mv_->ExtractView (&A,&LDA);
167 restricted_mv_ = rcp (
new Epetra_MultiVector (View, *ResMap_, A, LDA,
168 input_mv_->NumVectors ()));
EpetraExt::BlockCrsMatrix: A class for constructing a distributed block matrix.