// ============================================================================ void BorderingHelpers:: dissect(const Tpetra::MultiVector<double,int,int> & x, Tpetra::MultiVector<double,int,int> & xSmall, double * lambda ) { #ifndef NDEBUG TEUCHOS_ASSERT_EQUALITY(x.NumVectors(), xSmall.NumVectors()); // Make sure the maps are matching. std::shared_ptr<const Tpetra::Map<int,int>> extendedMap = nosh::BorderingHelpers::extendMapBy1(xSmall.getMap()); TEUCHOS_ASSERT(x.getMap().SameAs(*extendedMap)); #endif Epetra_Import importer(xSmall.getMap(), x.getMap()); // Strip off the phase constraint variable. xSmall.Import(x, importer, Insert); // TODO Check if we need lambda on all procs. if (x.getMap().Comm().MyPID() == 0) { const int n = x.MyLength(); for (int k = 0; k < x.NumVectors(); k++) lambda[k] = (*(x(k)))[n - 1]; } return; }
// ============================================================================ void BorderingHelpers:: merge(const Tpetra::MultiVector<double,int,int> & x, const double * lambda, Tpetra::MultiVector<double,int,int> & out ) { #ifndef NDEBUG // Check if the maps are matching. std::shared_ptr<const Tpetra::Map<int,int>> extendedMap = nosh::BorderingHelpers::extendMapBy1(x.getMap()); TEUCHOS_ASSERT(out.getMap().SameAs(*extendedMap)); #endif Epetra_Import importer(out.getMap(), x.getMap()); TEUCHOS_ASSERT_EQUALITY(0, out.Import(x, importer, Insert)); // Set last entry on proc 0. if (x.getMap().Comm().MyPID() == 0) { const int numMyElems = x.getMap().NumMyElements(); for (int k = 0; k < x.NumVectors(); k++) (*out(k))[numMyElems] = lambda[k]; } return; }
void Redistributor<Node>::redistribute(const ::Tpetra::MultiVector<double,int,int,Node> & inputVector, ::Tpetra::MultiVector<double,int,int,Node> * &outputVector) { if (!created_importer_) { create_importer(inputVector.Map()); } outputVector = new ::Tpetra::MultiVector<double,int,int,Node> (*target_map_, inputVector.NumVectors()); outputVector->Import(inputVector, *importer_, ::Tpetra::INSERT); return; }