void MLRigidBodyModes::setPiroPL(const Teuchos::RCP<Teuchos::ParameterList>& piroParams){ const Teuchos::RCP<Teuchos::ParameterList> stratList = extractStratimikosParams(piroParams); if (Teuchos::nonnull(stratList) && stratList->isParameter("Preconditioner Type")) { if ("ML" == stratList->get<std::string>("Preconditioner Type")) { // ML preconditioner is used, get nodal coordinates from application mlList = sublist(sublist(sublist(stratList, "Preconditioner Types"), "ML"), "ML Settings"); mlUsed = true; } } }
void BelosOperator::doSetParameterList() { if ( !M_pList->sublist ( "Trilinos: Belos List" ).isParameter ( "Verbosity" ) ) M_pList->sublist ( "Trilinos: Belos List" ).set ( "Verbosity", Belos::Errors + Belos::Warnings + Belos::TimingDetails + Belos::StatusTestDetails ); if ( M_tolerance > 0 ) { M_pList->sublist ( "Trilinos: Belos List" ).set ( "Convergence Tolerance", M_tolerance ); } std::string solverType ( M_pList->get<std::string> ( "Solver Manager Type" ) ); allocateSolver ( getSolverManagerTypeFromString ( solverType ) ); M_solverManager->setParameters ( sublist ( M_pList, "Trilinos: Belos List", true ) ); std::string precSideStr ( M_pList->get<std::string> ( "Preconditioner Side" ) ); PreconditionerSide precSide ( getPreconditionerSideFromString ( precSideStr ) ); switch (precSide) { case None: break; case Left: M_linProblem->setLeftPrec ( M_belosPrec ); break; case Right: M_linProblem->setRightPrec ( M_belosPrec ); break; default: exit (1); } }
Teuchos::RCP<const ErrorEstimateBase<double> > GAASPErrorEstimator::controlGlobalError(double uTOL) { if (!isInitialized_) { initialize_(); } Teuchos::EVerbosityLevel verbLevel = this->getVerbLevel(); Teuchos::RCP<Teuchos::FancyOStream> out = this->getOStream(); Teuchos::OSTab ostab(out,1,"GAASPErrorEstimator::"); paramList_->sublist(GAASPInterface_name_).set("uTOL",uTOL); gaaspInterfacePtr_->setParameterList(sublist(paramList_,GAASPInterface_name_)); if (Teuchos::as<int>(verbLevel) != Teuchos::VERB_NONE) { *out << "controlGlobalError: Global error tolerance = " << uTOL << std::endl; } Teuchos::RCP<const ErrorEstimateBase<double> > gaaspEE; gaaspEE = getErrorEstimate(); while (fabs(gaaspEE->getTotalError()) > uTOL) { if (Teuchos::as<int>(verbLevel) != Teuchos::VERB_NONE) { *out << "controlGlobalError: Calling GAASPInterface::refineMesh()..." << std::endl; } gaaspInterfacePtr_->refineMesh(); gaaspEE = getErrorEstimate(); } return(gaaspEE); }
Teuchos::RCP<const Teuchos::ParameterList> GAASPErrorEstimator::getValidParameters() const { static Teuchos::RCP<Teuchos::ParameterList> validPL; if (is_null(validPL)) { Teuchos::RCP<Teuchos::ParameterList> pl = Teuchos::parameterList(); Teuchos::RCP<Teuchos::ParameterList> gaaspPL = sublist(pl,GAASPInterface_name_); GAASPInterface gaaspI; gaaspPL->setParameters(*(gaaspI.getValidParameters())); Teuchos::setupVerboseObjectSublist(&*pl); validPL = pl; } Teuchos::RCP<Teuchos::FancyOStream> out = this->getOStream(); Teuchos::EVerbosityLevel verbLevel = this->getVerbLevel(); Teuchos::OSTab ostab(out,1,"getValidParameters"); if (Teuchos::as<int>(verbLevel) == Teuchos::VERB_HIGH) { *out << "Setting up valid parameterlist." << std::endl; validPL->print(*out); } return (validPL); }
FbTextElement FbTextElement::insertInside(const QString &style, const QString &html) { const TypeList * types = subtypes(); if (!types) return FbTextElement(); Sublist sublist(*types, style); if (!sublist) return FbTextElement(); FbTextElement child = firstChild(); if (sublist < child) { prependInside(html); return firstChild(); } while (!child.isNull()) { FbTextElement subling = child.nextSibling(); if (sublist >= child && sublist != subling) { child.appendOutside(html); return child.nextSibling(); } child = subling; } return FbTextElement(); }
TEUCHOS_UNIT_TEST( Rythmos_ImplicitBDFStepper, minOrder ) { // Model RCP<ParameterList> modelParamList = Teuchos::parameterList(); sublist(modelParamList,Stratimikos_name); sublist(modelParamList,DiagonalTransientModel_name); RCP<Thyra::ModelEvaluator<double> > model = getDiagonalModel<double>(modelParamList); Thyra::ModelEvaluatorBase::InArgs<double> model_ic = model->getNominalValues(); // Solver RCP<TimeStepNonlinearSolver<double> > nlSolver = timeStepNonlinearSolver<double>(); std::vector<StepSizeType> stepTypeVec(2); stepTypeVec[0] = STEP_TYPE_VARIABLE; stepTypeVec[1] = STEP_TYPE_FIXED; int maxOrder = 5; for (int minOrder=1 ; minOrder <= 5 ; ++minOrder ) { // parameter list RCP<ParameterList> stepperParamList = Teuchos::parameterList(); ParameterList& pl = stepperParamList->sublist("Step Control Settings"); pl.set("minOrder",minOrder); pl.set("maxOrder",maxOrder); ParameterList& vopl = pl.sublist("VerboseObject"); vopl.set("Verbosity Level","none"); for (int i=0 ; i<Teuchos::as<int>(stepTypeVec.size()) ; ++i) { StepSizeType stepType = stepTypeVec[i]; // Stepper RCP<ImplicitBDFStepper<double> > stepper = Teuchos::rcp(new ImplicitBDFStepper<double>(model,nlSolver,stepperParamList)); TEST_EQUALITY_CONST( Teuchos::is_null(stepper), false ); stepper->setInitialCondition(model_ic); for (int order=1 ; order<=minOrder ; ++order) { stepper->takeStep(1.0,stepType); const StepStatus<double> status = stepper->getStepStatus(); TEST_EQUALITY_CONST( status.order, order ); } for (int steps=0 ; steps<4 ; ++steps) { stepper->takeStep(1.0,stepType); const StepStatus<double> status = stepper->getStepStatus(); TEST_COMPARE( status.order, >=, minOrder ); TEST_COMPARE( status.order, <=, maxOrder ); } } } }
void TreeModel::readInParameterList(Teuchos::RCP<Teuchos::ParameterList> parameterList, TreeItem *parentItem){ for(Teuchos::ParameterList::ConstIterator itr = parameterList->begin(); itr != parameterList->end(); ++itr){ std::string name = parameterList->name(itr); if(parameterList->isSublist(name)){ insertParameterList(sublist(parameterList, name), parameterList->getEntryPtr(name), name, parentItem); } else if(parameterList->isParameter(name)){ insertParameter(parameterList->getEntryPtr(name), name, parentItem); } } }
void GAASPErrorEstimator::initialize_() { TEUCHOS_TEST_FOR_EXCEPT(is_null(model_)); // Create GAASP interface gaaspInterfacePtr_ = Teuchos::rcp(new GAASPInterface ); // Pass parameter sublist to GAASP Interface Teuchos::RCP<Teuchos::ParameterList> pl = sublist(paramList_, GAASPInterface_name_); gaaspInterfacePtr_->setParameterList(pl); // Verify we have a valid model. gaaspInterfacePtr_->setThyraModelEvaluator(model_); // Verify we have a valid quantity of interest isInitialized_ = true; }
bool Dependency::doesListContainList(Teuchos::RCP<Teuchos::ParameterList> parentList, Teuchos::RCP<Teuchos::ParameterList> listToFind){ if(parentList.get() == listToFind.get()){ return true; } else{ for(Teuchos::ParameterList::ConstIterator it = parentList->begin(); it!=parentList->end(); ++it){ if(it->second.isList()){ if(doesListContainList(sublist(parentList, it->first,true), listToFind)){ return true; } } } } return false; }
void TreeModel::insertParameterList(Teuchos::RCP<Teuchos::ParameterList> parameterList, Teuchos::ParameterEntry *listEntry, std::string name, TreeItem *parent) { QList<QVariant> values = QList<QVariant>() << QString::fromStdString(name).section("->",-1) << QString("") << listId; TreeItem *newList = new TreeItem(values, listEntry, parent); parent->appendChild(newList); for(Teuchos::ParameterList::ConstIterator itr = parameterList->begin(); itr != parameterList->end(); ++itr){ std::string name = parameterList->name(itr); if(parameterList->isSublist(name)){ insertParameterList(sublist(parameterList, name), parameterList->getEntryPtr(name), name, newList); } else if(parameterList->isParameter(name)){ insertParameter(parameterList->getEntryPtr(name), name, newList); } } }
CELL * p_chop(CELL * params) { size_t number = 1; size_t length = 0; CELL * next; #ifdef SUPPORT_UTF8 char * ptr; #endif next = getEvalDefault(params, ¶ms); if(next != nilCell) getInteger(next, (UINT *)&number); if(params->type == CELL_STRING) { #ifndef SUPPORT_UTF8 length = params->aux - 1; if(number > length) number = length; length = length - number; return stuffStringN((char *)params->contents, length); #else length = utf8_wlen((char *)params->contents); if(number > length) number = length; length = length - number; ptr = (char *)params->contents; while(length--) ptr += utf8_1st_len(ptr); return stuffStringN((char *)params->contents, ptr - (char *)params->contents); #endif } if(!isList(params->type)) return(errorProc(ERR_LIST_OR_STRING_EXPECTED)); length = listlen((CELL *)params->contents); if(number > length) number = length; return(sublist((CELL *)params->contents, 0, length - number)); }
CELL * p_slice(CELL * params) { CELL * cell; ssize_t offset; ssize_t length; params = getEvalDefault(params, &cell); params = getInteger(params, (UINT *)&offset); if(params != nilCell) getInteger(params, (UINT *)&length); else length = MAX_LONG; if(isList(cell->type)) return(sublist((CELL *)cell->contents, offset, length)); else if(cell->type == CELL_STRING) return(substring((char *)cell->contents, cell->aux - 1, offset, length)); else if(cell->type == CELL_ARRAY) return(subarray(cell, offset, length)); return(errorProcExt(ERR_LIST_OR_STRING_EXPECTED, params)); }
PAL_all, reg_set##_REG_SET, RS_NONE }, REG_NAME( invd ); REG_NAME( dzed ); REG_NAME( ovfd ); REG_NAME( inv ); REG_NAME( dze ); REG_NAME( ovf ); REG_NAME( unf ); REG_NAME( ine ); REG_NAME( iov ); REG_NAME( dyn ); REG_NAME( sum ); static const axp_reg_info FPCRSubList[] = { sublist( invd, BYTE, FPU, fpcr, 49, 1 ) sublist( dzed, BYTE, FPU, fpcr, 50, 1 ) sublist( ovfd, BYTE, FPU, fpcr, 51, 1 ) sublist( inv, BYTE, FPU, fpcr, 52, 1 ) sublist( dze, BYTE, FPU, fpcr, 53, 1 ) sublist( ovf, BYTE, FPU, fpcr, 54, 1 ) sublist( unf, BYTE, FPU, fpcr, 55, 1 ) sublist( ine, BYTE, FPU, fpcr, 56, 1 ) sublist( iov, BYTE, FPU, fpcr, 57, 1 ) sublist( dyn, BYTE, FPU, fpcr, 58, 2 ) sublist( sum, BYTE, FPU, fpcr, 63, 1 ) { NULL } }; REG_NAME( mode ); REG_NAME( ie );
CP::SlipFamily<CP::MAX_DIM, CP::MAX_SLIP> CP::ParameterReader<EvalT, Traits>::getSlipFamily(int index) { SlipFamily<MAX_DIM, MAX_SLIP> slip_family; auto family_plist = p_->sublist(Albany::strint("Slip System Family", index)); // Get flow rule parameters auto f_list = family_plist.sublist("Flow Rule"); static utility::ParameterEnum<CP::FlowRuleType> const fmap( "Type", CP::FlowRuleType::UNDEFINED, { {"Power Law", CP::FlowRuleType::POWER_LAW}, {"Thermal Activation", CP::FlowRuleType::THERMAL_ACTIVATION}, {"Power Law with Drag", CP::FlowRuleType::POWER_LAW_DRAG} }); slip_family.setFlowRuleType(fmap.get(&f_list)); for (auto & param : slip_family.pflow_parameters_->param_map_) { auto const index_param = param.second; auto const value_param = f_list.get<RealType>(param.first); slip_family.pflow_parameters_->setParameter(index_param, value_param); } slip_family.pflow_parameters_->setTolerance(); // set max slip increment if user specified RealType const max_incr = family_plist.get<RealType>("Max Slip Increment", LOG_HUGE); slip_family.pflow_parameters_->setMaxIncrement(max_incr); // Obtain hardening law parameters Teuchos::ParameterList h_list = family_plist.sublist("Hardening Law"); static utility::ParameterEnum<CP::HardeningLawType> const hmap( "Type", CP::HardeningLawType::UNDEFINED, { {"Linear Minus Recovery", CP::HardeningLawType::LINEAR_MINUS_RECOVERY}, {"Saturation", CP::HardeningLawType::SATURATION}, {"Dislocation Density", CP::HardeningLawType::DISLOCATION_DENSITY} }); slip_family.setHardeningLawType(hmap.get(&h_list)); for (auto & param : slip_family.phardening_parameters_->param_map_) { auto const index_param = param.second; auto const value_param = h_list.get<RealType>(param.first); slip_family.phardening_parameters_->setParameter(index_param, value_param); } return slip_family; }
void AmesosLinearOpWithSolveFactory::initializeOp( const Teuchos::RCP<const LinearOpSourceBase<double> > &fwdOpSrc ,LinearOpWithSolveBase<double> *Op ,const ESupportSolveUse supportSolveUse ) const { Teuchos::TimeMonitor overallTimeMonitor(*overallTimer); #ifdef TEUCHOS_DEBUG TEUCHOS_TEST_FOR_EXCEPT(Op==NULL); #endif const Teuchos::RCP<const LinearOpBase<double> > fwdOp = fwdOpSrc->getOp(); // // Unwrap and get the forward Epetra_Operator object // Teuchos::RCP<const Epetra_Operator> epetraFwdOp; ETransp epetraFwdOpTransp; EApplyEpetraOpAs epetraFwdOpApplyAs; EAdjointEpetraOp epetraFwdOpAdjointSupport; double epetraFwdOpScalar; epetraFwdOpViewExtractor_->getEpetraOpView( fwdOp,&epetraFwdOp,&epetraFwdOpTransp,&epetraFwdOpApplyAs,&epetraFwdOpAdjointSupport,&epetraFwdOpScalar ); // Get the AmesosLinearOpWithSolve object AmesosLinearOpWithSolve *amesosOp = &Teuchos::dyn_cast<AmesosLinearOpWithSolve>(*Op); // // Determine if we must start over or not // bool startOver = ( amesosOp->get_amesosSolver()==Teuchos::null ); if(!startOver) { startOver = ( epetraFwdOpTransp != amesosOp->get_amesosSolverTransp() || epetraFwdOp.get() != amesosOp->get_epetraLP()->GetOperator() // We must start over if the matrix object changes. This is a // weakness of Amesos but there is nothing I can do about this right // now! ); } // // Update the amesos solver // if(startOver) { // // This LOWS object has not be initialized yet or is not compatible with the existing // // so this is where we setup everything from the ground up. // // Create the linear problem and set the operator with memory of RCP to Epetra_Operator view! Teuchos::RCP<Epetra_LinearProblem> epetraLP = Teuchos::rcp(new Epetra_LinearProblem()); epetraLP->SetOperator(const_cast<Epetra_Operator*>(&*epetraFwdOp)); Teuchos::set_extra_data< Teuchos::RCP<const Epetra_Operator> >( epetraFwdOp, epetraFwdOp_str, Teuchos::inOutArg(epetraLP) ); // Create the concrete solver Teuchos::RCP<Amesos_BaseSolver> amesosSolver; { Teuchos::TimeMonitor constructTimeMonitor(*constructTimer); switch(solverType_) { case Thyra::Amesos::LAPACK : amesosSolver = Teuchos::rcp(new Amesos_Lapack(*epetraLP)); break; #ifdef HAVE_AMESOS_KLU case Thyra::Amesos::KLU : amesosSolver = Teuchos::rcp(new Amesos_Klu(*epetraLP)); break; #endif #ifdef HAVE_AMESOS_MUMPS case Thyra::Amesos::MUMPS : amesosSolver = Teuchos::rcp(new Amesos_Mumps(*epetraLP)); break; #endif #ifdef HAVE_AMESOS_SCALAPACK case Thyra::Amesos::SCALAPACK : amesosSolver = Teuchos::rcp(new Amesos_Scalapack(*epetraLP)); break; #endif #ifdef HAVE_AMESOS_UMFPACK case Thyra::Amesos::UMFPACK : amesosSolver = Teuchos::rcp(new Amesos_Umfpack(*epetraLP)); break; #endif #ifdef HAVE_AMESOS_SUPERLUDIST case Thyra::Amesos::SUPERLUDIST : amesosSolver = Teuchos::rcp(new Amesos_Superludist(*epetraLP)); break; #endif #ifdef HAVE_AMESOS_SUPERLU case Thyra::Amesos::SUPERLU : amesosSolver = Teuchos::rcp(new Amesos_Superlu(*epetraLP)); break; #endif #ifdef HAVE_AMESOS_DSCPACK case Thyra::Amesos::DSCPACK : amesosSolver = Teuchos::rcp(new Amesos_Dscpack(*epetraLP)); break; #endif #ifdef HAVE_AMESOS_PARDISO case Thyra::Amesos::PARDISO : amesosSolver = Teuchos::rcp(new Amesos_Pardiso(*epetraLP)); break; #endif #ifdef HAVE_AMESOS_TAUCS case Thyra::Amesos::TAUCS : amesosSolver = Teuchos::rcp(new Amesos_Taucs(*epetraLP)); break; #endif #ifdef HAVE_AMESOS_PARAKLETE case Thyra::Amesos::PARAKLETE : amesosSolver = Teuchos::rcp(new Amesos_Paraklete(*epetraLP)); break; #endif default: TEUCHOS_TEST_FOR_EXCEPTION( true, std::logic_error ,"Error, the solver type ID = " << solverType_ << " is invalid!" ); } } // Set the parameters if(paramList_.get()) amesosSolver->setParameterList(sublist(paramList_,"Amesos Settings")); // Do the initial factorization { Teuchos::TimeMonitor symbolicTimeMonitor(*symbolicTimer); amesosSolver->SymbolicFactorization(); } { Teuchos::TimeMonitor factorTimeMonitor(*factorTimer); amesosSolver->NumericFactorization(); } // Initialize the LOWS object and we are done! amesosOp->initialize(fwdOp,fwdOpSrc,epetraLP,amesosSolver,epetraFwdOpTransp,epetraFwdOpScalar); } else { // // This LOWS object has already be initialized once so we must just reset // the matrix and refactor it. // // Get non-const pointers to the linear problem and the amesos solver. // These const-casts are just fine since the amesosOp in non-const. Teuchos::RCP<Epetra_LinearProblem> epetraLP = Teuchos::rcp_const_cast<Epetra_LinearProblem>(amesosOp->get_epetraLP()); Teuchos::RCP<Amesos_BaseSolver> amesosSolver = amesosOp->get_amesosSolver(); // Reset the forward operator with memory of RCP to Epetra_Operator view! epetraLP->SetOperator(const_cast<Epetra_Operator*>(&*epetraFwdOp)); Teuchos::get_extra_data< Teuchos::RCP<const Epetra_Operator> >(epetraLP,epetraFwdOp_str) = epetraFwdOp; // Reset the parameters if(paramList_.get()) amesosSolver->setParameterList(sublist(paramList_,Amesos_Settings_name)); // Repivot if asked if(refactorizationPolicy_==Amesos::REPIVOT_ON_REFACTORIZATION) { Teuchos::TimeMonitor symbolicTimeMonitor(*symbolicTimer); amesosSolver->SymbolicFactorization(); } { Teuchos::TimeMonitor factorTimeMonitor(*factorTimer); amesosSolver->NumericFactorization(); } // Reinitialize the LOWS object and we are done! (we must do this to get the // possibly new transpose and scaling factors back in) amesosOp->initialize(fwdOp,fwdOpSrc,epetraLP,amesosSolver,epetraFwdOpTransp,epetraFwdOpScalar); } amesosOp->setOStream(this->getOStream()); amesosOp->setVerbLevel(this->getVerbLevel()); }
/** * Testing all the visual dependencies */ TEUCHOS_UNIT_TEST(Teuchos_Dependencies, testVisualDeps){ RCP<ParameterList> My_deplist = RCP<ParameterList>(new ParameterList); RCP<DependencySheet> depSheet1 = RCP<DependencySheet>(new DependencySheet); /* * Two Simple NumberVisualDependency test */ ParameterList simpleNumDepTestList = My_deplist->sublist( "NumberVisual Dependency List (double)", false, "Number visual Dependency testing list" ); simpleNumDepTestList.set("Temperature",101.0); simpleNumDepTestList.set("Cheese to Fondue", "Swiss", "The cheese to fondue"); simpleNumDepTestList.set("reverse param", "hello"); RCP<NumberVisualDependency<double> > simpleNumDep = RCP<NumberVisualDependency<double> >( new NumberVisualDependency<double>( simpleNumDepTestList.getEntryRCP("Temperature"), simpleNumDepTestList.getEntryRCP("Cheese to Fondue"), true ) ); RCP<NumberVisualDependency<double> > reverseNumDep = RCP<NumberVisualDependency<double> >( new NumberVisualDependency<double>( simpleNumDepTestList.getEntryRCP("Temperature"), simpleNumDepTestList.getEntryRCP("reverse param"), false ) ); depSheet1->addDependency(simpleNumDep); depSheet1->addDependency(reverseNumDep); simpleNumDep->evaluate(); reverseNumDep->evaluate(); TEST_ASSERT(simpleNumDep->isDependentVisible()); TEST_ASSERT(!reverseNumDep->isDependentVisible()); simpleNumDepTestList.set("Temperature",-1.0); simpleNumDep->evaluate(); reverseNumDep->evaluate(); TEST_ASSERT(!simpleNumDep->isDependentVisible()); TEST_ASSERT(reverseNumDep->isDependentVisible()); /* * complex Testing the NumberVisualDependency */ ParameterList doubleVisualDepList = My_deplist->sublist( "NumberVisual Dependency List (double)", false, "Number visual Dependency testing list" ); doubleVisualDepList.set( "Temperature",101.0, "The temperature of the fondue"); doubleVisualDepList.set( "Cheese to Fondue", "Swiss", "The cheese to fondue"); doubleVisualDepList.set("reverse param", "hello"); RCP<SubtractionFunction<double> > fondueFunc = rcp(new SubtractionFunction<double>(100)); RCP<NumberVisualDependency<double> > fondueDep = RCP<NumberVisualDependency<double> >( new NumberVisualDependency<double>( doubleVisualDepList.getEntryRCP("Temperature"), doubleVisualDepList.getEntryRCP("Cheese to Fondue"), true, fondueFunc ) ); RCP<NumberVisualDependency<double> > reverseFondueDep = RCP<NumberVisualDependency<double> >( new NumberVisualDependency<double>( doubleVisualDepList.getEntryRCP("Temperature"), doubleVisualDepList.getEntryRCP("reverse param"), false, fondueFunc ) ); depSheet1->addDependency(fondueDep); depSheet1->addDependency(reverseFondueDep); fondueDep->evaluate(); reverseFondueDep->evaluate(); TEST_ASSERT(fondueDep->isDependentVisible()); TEST_ASSERT(!reverseFondueDep->isDependentVisible()); doubleVisualDepList.set("Temperature",99.0); fondueDep->evaluate(); reverseFondueDep->evaluate(); TEST_ASSERT(!fondueDep->isDependentVisible()); TEST_ASSERT(reverseFondueDep->isDependentVisible()); /* * Testing the BoolVisualDependency */ ParameterList& boolVisDepList = My_deplist->sublist( "Bool Visual Dependency List", false, "Bool Visual Dependency testing list." ); boolVisDepList.set( "ShowPrecs", true, "Whether or not to should the Preciondtioner list"); ParameterList Prec_List0 = boolVisDepList.sublist( "Preconditioner",false,"Sublist that defines the preconditioner."); Prec_List0.set("Type", "ILU", "The tpye of preconditioner to use"); RCP<EnhancedNumberValidator<double> > droptolValidator = rcp(new EnhancedNumberValidator<double>(0,10,1e-3)); Prec_List0.set( "Drop Tolerance", 1e-3, "The tolerance below which entries from the " "factorization are left out of the factors.", droptolValidator); RCP<BoolVisualDependency> precDep1 = RCP<BoolVisualDependency>( new BoolVisualDependency( boolVisDepList.getEntryRCP("ShowPrecs"), boolVisDepList.getEntryRCP("Preconditioner"), true ) ); depSheet1->addDependency(precDep1); precDep1->evaluate(); TEST_ASSERT(precDep1->isDependentVisible()); boolVisDepList.set("ShowPrecs", false); precDep1->evaluate(); TEST_ASSERT(!precDep1->isDependentVisible()); /* * Testing the StringVisualDepenency */ ParameterList& stringVisDepList = My_deplist->sublist( "String Visual Dependency List", false, "String Visual Dependency testing list." ); RCP<StringToIntegralParameterEntryValidator<int> > favCheeseValidator = rcp( new StringToIntegralParameterEntryValidator<int>( tuple<std::string>( "Swiss", "American", "Cheder" ), "Favorite Cheese" ) ); stringVisDepList.set("Favorite Cheese", "American", "Your favorite type of cheese", favCheeseValidator); RCP<EnhancedNumberValidator<int> > swissValidator = rcp(new EnhancedNumberValidator<int>(0,10)); stringVisDepList.set("Swiss rating", 0, "How you rate swiss on a scale of 1 to 10", swissValidator); RCP<StringVisualDependency> swissDep1 = RCP<StringVisualDependency>( new StringVisualDependency( stringVisDepList.getEntryRCP("Favorite Cheese"), stringVisDepList.getEntryRCP("Swiss rating"), "Swiss", true ) ); depSheet1->addDependency(swissDep1); swissDep1->evaluate(); TEST_ASSERT(!swissDep1->isDependentVisible()); stringVisDepList.set("Favorite Cheese", "Swiss"); swissDep1->evaluate(); TEST_ASSERT(swissDep1->isDependentVisible()); /* * String Visual Tester with multiple values */ ParameterList multiStringVisDepList = My_deplist->sublist( "Multi String Visual Dependency List", false ); RCP<StringToIntegralParameterEntryValidator<int> > favCheeseValidator2 = rcp( new StringToIntegralParameterEntryValidator<int>( tuple<std::string>( "Provalone", "Swiss", "American", "Cheder" ), "Favorite Cheese" ) ); multiStringVisDepList.set( "Favorite Cheese", "American", "Your favorite type of cheese", favCheeseValidator2); multiStringVisDepList.set("Swiss rating", 0, "How you rate swiss on a scale of 1 to 10", swissValidator); RCP<StringVisualDependency> swissDep2 = RCP<StringVisualDependency>( new StringVisualDependency( multiStringVisDepList.getEntryRCP("Favorite Cheese"), multiStringVisDepList.getEntryRCP("Swiss rating"), tuple<std::string>("Swiss", "Cheder"), true ) ); depSheet1->addDependency(swissDep2); swissDep2->evaluate(); TEST_ASSERT(!swissDep2->isDependentVisible()); multiStringVisDepList.set("Favorite Cheese", "Cheder"); swissDep2->evaluate(); TEST_ASSERT(swissDep2->isDependentVisible()); /* * Another test of the NumberVisualDependency. */ ParameterList numberVisDepList = My_deplist->sublist( "Number Visual Dependency List", false, "Number Visual Dependency testing list." ); numberVisDepList.set("Ice", 50, "Ice stuff"); numberVisDepList.set("Room Temp", 10, "Room temperature"); RCP<SubtractionFunction<int> > visFunc = rcp(new SubtractionFunction<int>(32)); RCP<NumberVisualDependency<int> > iceDep = RCP<NumberVisualDependency<int> >( new NumberVisualDependency<int>( numberVisDepList.getEntryRCP("Room Temp"), numberVisDepList.getEntryRCP("Ice"), true, visFunc ) ); depSheet1->addDependency(iceDep); iceDep->evaluate(); TEST_ASSERT(!iceDep->isDependentVisible()); numberVisDepList.set("Room Temp", 33); iceDep->evaluate(); TEST_ASSERT(iceDep->isDependentVisible()); /* * Test condition visual dependency */ RCP<ParameterList> conVisDepList = sublist( My_deplist,"Condition Visual Dependency List", false); conVisDepList->set("double param", 4.0, "double parameter"); conVisDepList->set("bool param", true, "bool parameter"); conVisDepList->set("string param", "blah", "a string parameter"); RCP<NumberCondition<double> > numberCon = rcp( new NumberCondition<double>( conVisDepList->getEntryRCP("double param"))); RCP<BoolCondition> boolCon = rcp(new BoolCondition(conVisDepList->getEntryRCP("bool param"))); Condition::ConstConditionList conList = tuple<RCP<const Condition> >(numberCon, boolCon); RCP<AndCondition> andCon = rcp(new AndCondition(conList)); RCP<ConditionVisualDependency> conVisDep = rcp(new ConditionVisualDependency( andCon, conVisDepList->getEntryRCP("string param"), true)); depSheet1->addDependency(conVisDep); conVisDep->evaluate(); TEST_ASSERT(conVisDep->isDependentVisible()); conVisDepList->set("bool param", false); conVisDep->evaluate(); TEST_ASSERT(!conVisDep->isDependentVisible()); }
Teuchos::RCP< Belos::LinearProblem< Scalar, Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>, Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node> > > build_problem(Teuchos::ParameterList& test_params, const Teuchos::RCP<const Teuchos::Comm<int> >& comm, Teuchos::RCP<Node> node, int myWeight) { typedef Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> TMV; typedef Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> TV; typedef Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node> TOP; typedef Tpetra::CrsMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> TCRS; typedef Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> TMap; typedef Belos::LinearProblem<Scalar,TMV,TOP> BLinProb; Teuchos::RCP<TCRS> A; Teuchos::RCP<TMV> b = Teuchos::null; Teuchos::RCP<TV> dvec; std::string mm_file("not specified"); std::string rhs_mm_file("not specified"); std::string gen_mat("not specified"); // std::string hb_file("not specified"); Ifpack2::getParameter(test_params, "mm_file", mm_file); int mm_file_maxnnz = test_params.get<int>("mm_file_maxnnz", -1); // Ifpack2::getParameter(test_params, "hb_file", hb_file); Ifpack2::getParameter(test_params, "rhs_mm_file", rhs_mm_file); Ifpack2::getParameter(test_params, "gen_mat", gen_mat); const bool IAmRoot = (comm->getRank() == 0); if (mm_file != "not specified") { if (IAmRoot) { std::cout << "Matrix-Market file: " << mm_file << std::endl; } read_matrix_mm<Scalar,LocalOrdinal,GlobalOrdinal,Node>(mm_file, comm, node, myWeight, mm_file_maxnnz, A, dvec); if (rhs_mm_file != "not specified") { if (IAmRoot) { std::cout << "Right-hand-side Matrix-Market file: " << rhs_mm_file << std::endl; } b = read_vector_mm<Scalar,LocalOrdinal,GlobalOrdinal,Node>(rhs_mm_file, comm, node, A->getRowMap()); } } // else if (hb_file != "not specified") { // if (IAmRoot) { // std::cout << "Harwell-Boeing file: " << hb_file << std::endl; // } // A = read_matrix_hb<Scalar,LocalOrdinal,GlobalOrdinal,Node>(hb_file, comm, node, myWeight); // } else if (gen_mat != "not specified") { Teuchos::RCP<Teuchos::ParameterList> genparams = sublist(rcpFromRef(test_params),"GenMat"); if (genparams == Teuchos::null) { throw std::runtime_error("Missing parameter list \"GenMat\"."); } Teuchos::RCP<TCRS> ncA; Tpetra::Utils::generateMatrix(genparams,comm,node,ncA); A = ncA; dvec = rcp(new TV(A->getRowMap(), false)); dvec->putScalar(6); } else { throw std::runtime_error("No matrix specified."); } // print node details { RCP<const Tpetra::Import<LocalOrdinal,GlobalOrdinal,Node> > importer = A->getGraph()->getImporter(); for (int i=0; i<comm->getSize(); ++i) { if (comm->getRank() == i) { if (importer != Teuchos::null) { if (IAmRoot) { std::cout << "\nPartitioning details" << std::endl; } std::cout << "node: " << i << " same: " << importer->getNumSameIDs() << " permute: " << importer->getNumPermuteIDs() << " remote: " << importer->getNumRemoteIDs() << " export: " << importer->getNumExportIDs() << std::endl; } } comm->barrier(); comm->barrier(); comm->barrier(); } if (IAmRoot) { std::cout << std::endl; } } Teuchos::RCP<BLinProb> problem = build_problem_mm<Scalar,LocalOrdinal,GlobalOrdinal,Node>(test_params, A, b, dvec); return problem; }