本文整理汇总了C++中teuchos::ParameterList::sublist方法的典型用法代码示例。如果您正苦于以下问题:C++ ParameterList::sublist方法的具体用法?C++ ParameterList::sublist怎么用?C++ ParameterList::sublist使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类teuchos::ParameterList
的用法示例。
在下文中一共展示了ParameterList::sublist方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: timer
Teuchos::RCP<Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node> >
build_precond(Teuchos::ParameterList& test_params,
const Teuchos::RCP<const Tpetra::CrsMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node,LocalMatOps> >& A)
{
Teuchos::Time timer("precond");
typedef Ifpack2::Preconditioner<Scalar,LocalOrdinal,GlobalOrdinal,Node> Tprec;
Teuchos::RCP<Tprec> prec;
Ifpack2::Factory factory;
std::string prec_name("not specified");
Ifpack2::getParameter(test_params, "Ifpack2::Preconditioner", prec_name);
prec = factory.create(prec_name, A);
Teuchos::ParameterList tif_params;
if (test_params.isSublist("Ifpack2")) {
tif_params = test_params.sublist("Ifpack2");
}
if (A->getRowMap()->getComm()->getRank() == 0) {
std::cout << "Configuring/Initializing/Computing Ifpack2 preconditioner..."
<< std::endl;
}
prec->setParameters(tif_params);
prec->initialize();
timer.start();
prec->compute();
timer.stop();
if (A->getRowMap()->getComm()->getRank() == 0) {
std::cout << "... Finished Computing Ifpack2 preconditioner (time: "<<timer.totalElapsedTime() << "s)"
<< std::endl;
}
typedef typename Teuchos::ScalarTraits<Scalar>::magnitudeType magnitudeType;
magnitudeType condest = prec->computeCondEst(Ifpack2::Cheap);
if (A->getRowMap()->getComm()->getRank() == 0) {
std::cout << "Condition estimate(cheap) for preconditioner on proc 0: "
<< condest << std::endl;
}
return prec;
}
示例2: iss
void PeridigmNS::HorizonManager::loadHorizonInformationFromBlockParameters(Teuchos::ParameterList& blockParams) {
// Find the horizon value for each block and record the default horizon value (if any)
for(Teuchos::ParameterList::ConstIterator it = blockParams.begin() ; it != blockParams.end() ; it++){
Teuchos::ParameterList& params = blockParams.sublist(it->first);
bool hasConstantHorizon = params.isType<double>("Horizon");
bool hasVariableHorizon = params.isType<string>("Horizon");
TEUCHOS_TEST_FOR_EXCEPT_MSG(hasConstantHorizon && hasVariableHorizon, "\n**** Error parsing horizon information! Multiple horizon definitions found!\n");
TEUCHOS_TEST_FOR_EXCEPT_MSG(!hasConstantHorizon && !hasVariableHorizon, "\n**** Error parsing horizon information! No horizon definition found!\n");
// Record the horizon as a string regardless of whether or not it is constant
string horizonString;
if(hasConstantHorizon){
double constantHorizon = params.get<double>("Horizon");
stringstream horizonStringStream;
horizonStringStream.precision(16);
horizonStringStream << constantHorizon;
horizonString = horizonStringStream.str();
}
else{
horizonString = params.get<string>("Horizon");
}
// Parse space-delimited list of block names
string blockNamesString = params.get<string>("Block Names");
istringstream iss(blockNamesString);
vector<string> blockNames;
copy(istream_iterator<string>(iss),
istream_iterator<string>(),
back_inserter<vector<string> >(blockNames));
for(vector<string>::const_iterator it = blockNames.begin() ; it != blockNames.end() ; ++it){
if( *it == "Default" || *it == "default" || *it == "DEFAULT" ){
horizonIsConstant["default"] = hasConstantHorizon;
horizonStrings["default"] = horizonString;
}
else{
horizonIsConstant[*it] = hasConstantHorizon;
horizonStrings[*it] = horizonString;
}
}
}
}
示例3: rcp
inline Teuchos::RCP<RiskMeasure<Real> > RiskMeasureFactory(Teuchos::ParameterList &parlist) {
std::string dist = parlist.sublist("SOL").sublist("Risk Measure").get("Name","CVaR");
ERiskMeasure ed = StringToERiskMeasure(dist);
switch(ed) {
case RISKMEASURE_CVAR:
return Teuchos::rcp(new CVaR<Real>(parlist));
case RISKMEASURE_EXPUTILITY:
return Teuchos::rcp(new ExpUtility<Real>(parlist));
case RISKMEASURE_HMCR:
return Teuchos::rcp(new HMCR<Real>(parlist));
case RISKMEASURE_MEANDEVIATIONFROMTARGET:
return Teuchos::rcp(new MeanDeviationFromTarget<Real>(parlist));
case RISKMEASURE_MEANDEVIATION:
return Teuchos::rcp(new MeanDeviation<Real>(parlist));
case RISKMEASURE_MEANVARIANCEFROMTARGET:
return Teuchos::rcp(new MeanVarianceFromTarget<Real>(parlist));
case RISKMEASURE_MEANVARIANCE:
return Teuchos::rcp(new MeanVariance<Real>(parlist));
case RISKMEASURE_MOREAUYOSIDACVAR:
return Teuchos::rcp(new MoreauYosidaCVaR<Real>(parlist));
case RISKMEASURE_LOGEXPONENTIALQUADRANGLE:
return Teuchos::rcp(new LogExponentialQuadrangle<Real>(parlist));
case RISKMEASURE_LOGQUANTILEQUADRANGLE:
return Teuchos::rcp(new LogQuantileQuadrangle<Real>(parlist));
case RISKMEASURE_MIXEDQUANTILEQUADRANGLE:
return Teuchos::rcp(new MixedQuantileQuadrangle<Real>(parlist));
case RISKMEASURE_QUANTILEQUADRANGLE:
return Teuchos::rcp(new QuantileQuadrangle<Real>(parlist));
case RISKMEASURE_QUANTILERADIUSQUADRANGLE:
return Teuchos::rcp(new QuantileRadiusQuadrangle<Real>(parlist));
case RISKMEASURE_SMOOTHEDWORSTCASEQUADRANGLE:
return Teuchos::rcp(new SmoothedWorstCaseQuadrangle<Real>(parlist));
case RISKMEASURE_TRUNCATEDMEANQUADRANGLE:
return Teuchos::rcp(new TruncatedMeanQuadrangle<Real>(parlist));
case RISKMEASURE_CHI2DIVERGENCE:
return Teuchos::rcp(new Chi2Divergence<Real>(parlist));
case RISKMEASURE_KLDIVERGENCE:
return Teuchos::rcp(new KLDivergence<Real>(parlist));
default:
TEUCHOS_TEST_FOR_EXCEPTION(true,std::logic_error,
"Invalid risk measure type" << dist);
}
}
示例4: input_block
bool NOX::Epetra::LinearSystemMPBD::
applyJacobianInverse(Teuchos::ParameterList ¶ms,
const NOX::Epetra::Vector &input,
NOX::Epetra::Vector &result)
{
TEUCHOS_FUNC_TIME_MONITOR("Total deterministic solve Time");
// Extract blocks
EpetraExt::BlockVector input_block(View, *base_map,
input.getEpetraVector());
EpetraExt::BlockVector result_block(View, *base_map,
result.getEpetraVector());
result_block.PutScalar(0.0);
Teuchos::ParameterList& block_solver_params =
params.sublist("Deterministic Solver Parameters");
// Solve block linear systems
bool final_status = true;
bool status;
for (int i=0; i<num_mp_blocks; i++) {
NOX::Epetra::Vector nox_input(input_block.GetBlock(i),
NOX::Epetra::Vector::CreateView);
NOX::Epetra::Vector nox_result(result_block.GetBlock(i),
NOX::Epetra::Vector::CreateView);
block_solver->setJacobianOperatorForSolve(block_ops->getCoeffPtr(i));
if (precStrategy == STANDARD)
block_solver->setPrecOperatorForSolve(precs[i]);
else if (precStrategy == ON_THE_FLY) {
block_solver->createPreconditioner(*(prec_x->GetBlock(i)),
block_solver_params, false);
}
status = block_solver->applyJacobianInverse(block_solver_params, nox_input,
nox_result);
final_status = final_status && status;
}
return final_status;
}
示例5: main
int main(int argc, char *argv[]) {
bool success = false;
bool verbose = false;
try {
// Set up the printing utilities
Teuchos::ParameterList noxParams;
Teuchos::ParameterList& printParams = noxParams.sublist("Printing");
printParams.set("Output Precision", 5);
if (argc > 1) {
if (argv[1][0]=='-' && argv[1][1]=='v')
printParams.set("Output Information",
NOX::Utils::OuterIteration +
NOX::Utils::OuterIterationStatusTest +
NOX::Utils::InnerIteration +
NOX::Utils::Parameters +
NOX::Utils::Details +
NOX::Utils::Warning +
NOX::Utils::TestDetails);
else
printParams.set("Output Information", NOX::Utils::Error);
}
NOX::Utils printing(printParams);
// Identify the test
if (printing.isPrintType(NOX::Utils::TestDetails)) {
std::cout << "Starting lapack/NOX_NewTest/NOX_NewTest.exe" << std::endl;
}
// *** Insert your testing here! ***
success = true;
if (success)
std::cout << "Test passed!" << std::endl;
else
std::cout << "Test failed!" << std::endl;
}
TEUCHOS_STANDARD_CATCH_STATEMENTS(verbose, std::cerr, success);
return ( success ? EXIT_SUCCESS : EXIT_FAILURE );
}
示例6: solver_type
Teuchos::RCP<Belos::SolverManager<Scalar,MV,OP> >
build_solver(const Teuchos::RCP<const Teuchos::Comm<int> > &comm,
Teuchos::ParameterList& test_params,
Teuchos::RCP<Belos::LinearProblem<Scalar,MV,OP> > problem)
{
typedef Belos::LinearProblem<Scalar,MV,OP> BLinProb;
Teuchos::RCP<Belos::SolverManager<Scalar,MV,OP> > solver;
Teuchos::ParameterList bparams;
if (test_params.isSublist("Belos")) {
bparams = test_params.sublist("Belos");
}
Teuchos::RCP<Teuchos::ParameterList> rcpparams = Teuchos::rcpFromRef(bparams);
std::string solver_type("not specified");
Ifpack2::getParameter(test_params, "solver_type", solver_type);
if (solver_type == "BlockGmres") {
// if (comm->getRank() == 0) std::cout << *rcpparams << std::endl;
solver = Teuchos::rcp(new Belos::BlockGmresSolMgr<Scalar,MV,OP>(problem,rcpparams));
}
// else if (solver_type == "PseudoBlockGmres") {
// solver = Teuchos::rcp(new Belos::PseudoBlockGmresSolMgr<Scalar,MV,OP>(problem,rcpparams));
// }
// else if (solver_type == "PseudoBlockCG") {
// solver = Teuchos::rcp(new Belos::PseudoBlockCGSolMgr<Scalar,MV,OP>(problem,rcpparams));
// }
// else if (solver_type == "TFQMR") {
// solver = Teuchos::rcp(new Belos::TFQMRSolMgr<Scalar,MV,OP>(problem,rcpparams));
// }
else if (solver_type == "not specified") {
throw std::runtime_error("Error in build_solver: solver_type not specified.");
}
else {
std::ostringstream os;
os << "Error in build_solver: solver_type ("<<solver_type<<") not recognized.";
os << "\nIfpack2's test-driver recognizes these solvers: PseudoBlockCG, PesudoBlockGmres, BlockGmres, TFQMR.";
std::string str = os.str();
throw std::runtime_error(str);
}
return solver;
}
示例7: xmlToModelPList
void xmlToModelPList(const Teuchos::XMLObject &xml, Teuchos::ParameterList & plist)
{
// This method composes a plist for the problem
Teuchos::XMLParameterListReader reader;
plist = reader.toParameterList(xml);
// Get list of valid Zoltan2 Parameters
// Zoltan 2 parameters appear in the input file
// Right now we have default values stored in
// the parameter list, we would like to apply
// the options specified by the user in their
// input file
Teuchos::ParameterList zoltan2Parameters;
Zoltan2::createAllParameters(zoltan2Parameters);
if (plist.isSublist("Zoltan2Parameters")) {
// Apply user specified zoltan2Parameters
ParameterList &sub = plist.sublist("Zoltan2Parameters");
zoltan2Parameters.setParameters(sub);
}
}
示例8: bc
TEUCHOS_UNIT_TEST(bc, dirichlet_complete_param_list)
{
Teuchos::ParameterList p;
p.set("Type", "Dirichlet");
p.set("Sideset ID", "4");
p.set("Element Block ID", "fluid");
p.set("Equation Set Name", "UX");
p.set("Strategy", "Constant");
p.sublist("Data").set("Value",1.0);
panzer::BC bc(0,p);
TEST_EQUALITY(bc.bcID(), 0);
TEST_EQUALITY(bc.bcType(), BCT_Dirichlet);
TEST_EQUALITY(bc.sidesetID(), "4");
TEST_EQUALITY(bc.elementBlockID(), "fluid");
TEST_EQUALITY(bc.equationSetName(), "UX");
std::stringstream s;
s << bc << std::endl;
}
示例9: NewtonKrylovStep
/** \brief Constructor.
Constructor to build a NewtonKrylovStep object with user-defined
secant and Krylov objects. Algorithmic specifications are passed in through
a Teuchos::ParameterList.
@param[in] parlist is a parameter list containing algorithmic specifications
@param[in] krylov is a user-defined Krylov object
@param[in] secant is a user-defined secant object
*/
NewtonKrylovStep(Teuchos::ParameterList &parlist,
const Teuchos::RCP<Krylov<Real> > &krylov,
const Teuchos::RCP<Secant<Real> > &secant,
const bool computeObj = true)
: Step<Real>(), secant_(secant), krylov_(krylov),
ekv_(KRYLOV_USERDEFINED), esec_(SECANT_USERDEFINED),
gp_(Teuchos::null), iterKrylov_(0), flagKrylov_(0),
verbosity_(0), computeObj_(computeObj), useSecantPrecond_(false) {
// Parse ParameterList
Teuchos::ParameterList& Glist = parlist.sublist("General");
useSecantPrecond_ = Glist.sublist("Secant").get("Use as Preconditioner", false);
verbosity_ = Glist.get("Print Verbosity",0);
// Initialize secant object
if ( useSecantPrecond_ && secant_ == Teuchos::null ) {
esec_ = StringToESecant(Glist.sublist("Secant").get("Type","Limited-Memory BFGS"));
secant_ = SecantFactory<Real>(parlist);
}
// Initialize Krylov object
if ( krylov_ == Teuchos::null ) {
ekv_ = StringToEKrylov(Glist.sublist("Krylov").get("Type","Conjugate Gradients"));
krylov_ = KrylovFactory<Real>(parlist);
}
}
示例10: if
// ************************************************************************
// ************************************************************************
Teuchos::RCP<LOCA::StatusTest::Abstract> LOCA::StatusTest::Factory::
buildComboTest(Teuchos::ParameterList& p,
const Teuchos::RCP<const LOCA::GlobalData> & globalData,
std::map<std::string, Teuchos::RCP<LOCA::StatusTest::Abstract> >*
tagged_tests) const
{
int number_of_tests = get<int>(p, "Number of Tests");
std::string combo_type_string = get<std::string>(p, "Combo Type");
LOCA::StatusTest::Combo::ComboType combo_type;
if (combo_type_string == "AND")
combo_type = LOCA::StatusTest::Combo::AND;
else if (combo_type_string == "OR")
combo_type = LOCA::StatusTest::Combo::OR;
else{
std::string msg =
"Error - The \"Combo Type\" must be \"AND\" or \"OR\"!";
TEST_FOR_EXCEPTION(true, std::logic_error, msg);
}
RCP<LOCA::StatusTest::Combo> combo_test =
rcp(new LOCA::StatusTest::Combo(combo_type, globalData));
for (int i=0; i < number_of_tests; ++i) {
ostringstream subtest_name;
subtest_name << "Test " << i;
ParameterList& subtest_list = p.sublist(subtest_name.str(), true);
RCP<LOCA::StatusTest::Abstract> subtest =
this->buildStatusTests(subtest_list, globalData, tagged_tests);
combo_test->addStatusTest(subtest);
}
return combo_test;
}
示例11: SetParameters
int Amesos_Scalapack::SetParameters( Teuchos::ParameterList &ParameterList ) {
if( debug_ == 1 ) std::cout << "Entering `SetParameters()'" << std::endl;
// retrive general parameters
SetStatusParameters( ParameterList );
SetControlParameters( ParameterList );
//
// We have to set these to their defaults here because user codes
// are not guaranteed to have a "Scalapack" parameter list.
//
TwoD_distribution_ = true;
grid_nb_ = 32;
// Some compilers reject the following cast:
// if( &ParameterList == 0 ) return 0;
// ========================================= //
// retrive ScaLAPACK's parameters from list. //
// ========================================= //
// retrive general parameters
// check to see if they exist before trying to retrieve them
if (ParameterList.isSublist("Scalapack") ) {
const Teuchos::ParameterList ScalapackParams = ParameterList.sublist("Scalapack") ;
// Fix Bug #3251
if ( ScalapackParams.isParameter("2D distribution") )
TwoD_distribution_ = ScalapackParams.get<bool>("2D distribution");
if ( ScalapackParams.isParameter("grid_nb") )
grid_nb_ = ScalapackParams.get<int>("grid_nb");
}
return 0;
}
示例12: if
// ************************************************************************
// ************************************************************************
Teuchos::RCP<NOX::StatusTest::Generic> NOX::StatusTest::Factory::
buildComboTest(Teuchos::ParameterList& p, const NOX::Utils& u,
std::map<std::string, Teuchos::RCP<NOX::StatusTest::Generic> >*
tagged_tests) const
{
int number_of_tests = get<int>(p, "Number of Tests");
std::string combo_type_string = get<std::string>(p, "Combo Type");
NOX::StatusTest::Combo::ComboType combo_type;
if (combo_type_string == "AND")
combo_type = NOX::StatusTest::Combo::AND;
else if (combo_type_string == "OR")
combo_type = NOX::StatusTest::Combo::OR;
else{
std::string msg =
"Error - The \"Combo Type\" must be \"AND\" or \"OR\"!";
TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error, msg);
}
RCP<NOX::StatusTest::Combo> combo_test =
rcp(new NOX::StatusTest::Combo(combo_type, &u));
for (int i=0; i < number_of_tests; ++i) {
std::ostringstream subtest_name;
subtest_name << "Test " << i;
ParameterList& subtest_list = p.sublist(subtest_name.str(), true);
RCP<NOX::StatusTest::Generic> subtest =
this->buildStatusTests(subtest_list, u, tagged_tests);
combo_test->addStatusTest(subtest);
}
return combo_test;
}
示例13: GMRES
GMRES( Teuchos::ParameterList &parlist ) : isInitialized_(false) {
using Teuchos::RCP;
using Teuchos::rcp;
using std::vector;
Teuchos::ParameterList &gList = parlist.sublist("General");
Teuchos::ParameterList &kList = gList.sublist("Krylov");
useInexact_ = gList.get("Inexact Hessian-Times-A-Vector",false);
maxit_ = kList.get("Iteration Limit",50);
absTol_ = kList.get("Absolute Tolerance", 1.e-4);
relTol_ = kList.get("Relative Tolerance", 1.e-2);
useInitialGuess_ = kList.get("Use Initial Guess",false);
H_ = rcp( new SDMatrix( maxit_+1, maxit_ ) );
cs_ = rcp( new SDVector( maxit_ ) );
sn_ = rcp( new SDVector( maxit_ ) );
s_ = rcp( new SDVector( maxit_+1 ) );
y_ = rcp( new SDVector( maxit_+1 ) );
cnorm_ = rcp( new SDVector( maxit_ ) );
res_ = rcp( new std::vector<Real>(maxit_+1,0.0) );
}
示例14: DistributionFactory
inline Teuchos::RCP<Distribution<Real> > DistributionFactory(Teuchos::ParameterList &parlist) {
std::string dist = parlist.sublist("Distribution").get("Name","Dirac");
EDistribution ed = StringToEDistribution(dist);
switch(ed) {
case DISTRIBUTION_ARCSINE: return Teuchos::rcp(new Arcsine<Real>(parlist));
case DISTRIBUTION_BETA: return Teuchos::rcp(new Beta<Real>(parlist));
case DISTRIBUTION_CAUCHY: return Teuchos::rcp(new Cauchy<Real>(parlist));
case DISTRIBUTION_DIRAC: return Teuchos::rcp(new Dirac<Real>(parlist));
case DISTRIBUTION_EXPONENTIAL: return Teuchos::rcp(new Exponential<Real>(parlist));
case DISTRIBUTION_GAMMA: return Teuchos::rcp(new Gamma<Real>(parlist));
case DISTRIBUTION_GAUSSIAN: return Teuchos::rcp(new Gaussian<Real>(parlist));
case DISTRIBUTION_KUMARASWAMY: return Teuchos::rcp(new Kumaraswamy<Real>(parlist));
case DISTRIBUTION_LAPLACE: return Teuchos::rcp(new Laplace<Real>(parlist));
case DISTRIBUTION_LOGISTIC: return Teuchos::rcp(new Logistic<Real>(parlist));
case DISTRIBUTION_PARABOLIC: return Teuchos::rcp(new Parabolic<Real>(parlist));
case DISTRIBUTION_RAISEDCOSINE: return Teuchos::rcp(new RaisedCosine<Real>(parlist));
case DISTRIBUTION_SMALE: return Teuchos::rcp(new Smale<Real>(parlist));
case DISTRIBUTION_TRIANGLE: return Teuchos::rcp(new Triangle<Real>(parlist));
case DISTRIBUTION_TRUNCATEDEXPONENTIAL: return Teuchos::rcp(new TruncatedExponential<Real>(parlist));
case DISTRIBUTION_TRUNCATEDGAUSSIAN: return Teuchos::rcp(new TruncatedGaussian<Real>(parlist));
case DISTRIBUTION_UNIFORM: return Teuchos::rcp(new Uniform<Real>(parlist));
default: return Teuchos::null;
}
}
示例15: main
int main(int argc, char *argv[]) {
// Set up the printing utilities
Teuchos::ParameterList noxParams;
Teuchos::ParameterList& printParams = noxParams.sublist("Printing");
printParams.set("Output Precision", 5);
if (argc > 1) {
if (argv[1][0]=='-' && argv[1][1]=='v')
printParams.set("Output Information",
NOX::Utils::OuterIteration +
NOX::Utils::OuterIterationStatusTest +
NOX::Utils::InnerIteration +
NOX::Utils::Parameters +
NOX::Utils::Details +
NOX::Utils::Warning +
NOX::Utils::TestDetails);
else
printParams.set("Output Information", NOX::Utils::Error);
}
NOX::Utils printing(printParams);
if (printing.isPrintType(NOX::Utils::TestDetails)) {
cout << "Starting lapack/NOX_Group/NOX_Group.exe" << endl;
}
int status = 0;
// Begin real testing here!
if (status == 0)
cout << "Test passed!" << endl;
else
cout << "Test failed!" << endl;
// 0 is success
return status;
}