void EminPFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node, LocalMatOps>::BuildP(Level& fineLevel, Level& coarseLevel) const { FactoryMonitor m(*this, "Prolongator minimization", coarseLevel); const ParameterList & pL = GetParameterList(); // Set keep flags if (pL.isParameter("Keep P0") && pL.get<bool>("Keep P0")) coarseLevel.Keep("P0",this); if (pL.isParameter("Keep Constraint0") && pL.get<bool>("Keep Constraint0")) coarseLevel.Keep("Constraint0",this); // Reuse int Niterations; // Get A, B RCP<Matrix> A = Get< RCP<Matrix> > (fineLevel, "A"); RCP<MultiVector> B = Get< RCP<MultiVector> >(fineLevel, "Nullspace"); // Get P0 or make P RCP<Matrix> P0; if (coarseLevel.IsAvailable("P0", this)) { P0 = coarseLevel.Get<RCP<Matrix> >("P0", this); Niterations = pL.get<int>("Reuse Niterations"); GetOStream(Runtime0, 0) << "EminPFactory: Reusing P0"<<std::endl; } else { P0 = Get< RCP<Matrix> >(coarseLevel, "P"); Niterations = pL.get<int>("Niterations"); } // Get Constraint0 or make Constraint RCP<Constraint> X; if (coarseLevel.IsAvailable("Constraint0", this)) { X = coarseLevel.Get<RCP<Constraint> >("Constraint0", this); GetOStream(Runtime0, 0) << "EminPFactory: Reusing Constraint0"<<std::endl; } else { X = Get< RCP<Constraint> > (coarseLevel, "Constraint"); } RCP<Matrix> P; CGSolver EminSolver(Niterations); EminSolver.Iterate(*A, *X, *P0, *B, P); Set(coarseLevel, "Constraint0", X); Set(coarseLevel, "P", P); Set(coarseLevel, "P0", P); RCP<ParameterList> params = rcp(new ParameterList()); params->set("printLoadBalancingInfo", true); GetOStream(Statistics0,0) << Utils::PrintMatrixInfo(*P, "P", params); }
void EminPFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node, LocalMatOps>::BuildP(Level& fineLevel, Level& coarseLevel) const { FactoryMonitor m(*this, "Prolongator minimization", coarseLevel); const ParameterList & pL = GetParameterList(); // Get the matrix RCP<Matrix> A = Get< RCP<Matrix> >(fineLevel, "A"); // Get/make initial guess RCP<Matrix> P0; int Niterations; if (coarseLevel.IsAvailable("P0", this)) { // Reuse data P0 = coarseLevel.Get<RCP<Matrix> >("P0", this); Niterations = pL.get<int>("Reuse Niterations"); GetOStream(Runtime0, 0) << "Reusing P0" << std::endl; } else { // Construct data P0 = Get< RCP<Matrix> >(coarseLevel, "P"); Niterations = pL.get<int>("Niterations"); } // NOTE: the main assumption here that P0 satisfies both constraints: // - nonzero pattern // - nullspace preservation // Get/make constraint operator RCP<Constraint> X; if (coarseLevel.IsAvailable("Constraint0", this)) { // Reuse data X = coarseLevel.Get<RCP<Constraint> >("Constraint0", this); GetOStream(Runtime0, 0) << "Reusing Constraint0" << std::endl; } else { // Construct data X = Get< RCP<Constraint> >(coarseLevel, "Constraint"); } GetOStream(Runtime0,0) << "Number of emin iterations = " << Niterations << std::endl; RCP<Matrix> P; CGSolver EminSolver(Niterations); EminSolver.Iterate(*A, *X, *P0, P); Set(coarseLevel, "P", P); if (pL.get<bool>("Keep P0")) { // NOTE: we must do Keep _before_ set as the Needs class only sets if // a) data has been requested (which is not the case here), or // b) data has some keep flag coarseLevel.Keep("P0", this); Set(coarseLevel, "P0", P); } if (pL.get<bool>("Keep Constraint0")) { // NOTE: we must do Keep _before_ set as the Needs class only sets if // a) data has been requested (which is not the case here), or // b) data has some keep flag coarseLevel.Keep("Constraint0", this); Set(coarseLevel, "Constraint0", X); } RCP<ParameterList> params = rcp(new ParameterList()); params->set("printLoadBalancingInfo", true); GetOStream(Statistics1,0) << Utils::PrintMatrixInfo(*P, "P", params); }