本文整理汇总了C++中teuchos::ParameterList::get方法的典型用法代码示例。如果您正苦于以下问题:C++ ParameterList::get方法的具体用法?C++ ParameterList::get怎么用?C++ ParameterList::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类teuchos::ParameterList
的用法示例。
在下文中一共展示了ParameterList::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
// ************************************************************************
// ************************************************************************
Teuchos::RCP<NOX::StatusTest::Generic> NOX::StatusTest::Factory::
buildFiniteValueTest(Teuchos::ParameterList& p, const NOX::Utils& u) const
{
std::string vector_type_string = p.get("Vector Type","F Vector");
std::string norm_type_string = p.get("Norm Type", "Two Norm");
NOX::StatusTest::FiniteValue::VectorType vector_type =
NOX::StatusTest::FiniteValue::FVector;
NOX::Abstract::Vector::NormType norm_type = NOX::Abstract::Vector::TwoNorm;
if (vector_type_string == "F Vector")
vector_type = NOX::StatusTest::FiniteValue::FVector;
else if (vector_type_string == "Solution Vector")
vector_type = NOX::StatusTest::FiniteValue::SolutionVector;
else {
std::string msg = "\"Vector Type\" must be either \"F Vector\" or \"Solution Vector\"!";
TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error, msg);
}
if (norm_type_string == "Two Norm")
norm_type = NOX::Abstract::Vector::TwoNorm;
else if (vector_type_string == "One Norm")
norm_type = NOX::Abstract::Vector::OneNorm;
else if (vector_type_string == "Max Norm")
norm_type = NOX::Abstract::Vector::MaxNorm;
else {
std::string msg = "\"Norm Type\" must be either \"Two Norm\", \"One Norm\", or \"Max Norm\"!";
TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error, msg);
}
RCP<NOX::StatusTest::FiniteValue> status_test =
rcp(new NOX::StatusTest::FiniteValue(vector_type, norm_type));
return status_test;
}
示例2: createResponseTable
Teuchos::Array<bool> parseResponseParameters(Teuchos::ParameterList ¶ms, int responseCount)
{
const std::string selectionType = params.get("Response Selection", "All");
const int userIndex = parseResponseIndex(params);
const Teuchos::Array<int> userList = params.get("Response List", Teuchos::Array<int>());
return createResponseTable(responseCount, selectionType, userIndex, userList);
}
示例3: setPartitionParameters
void
OverlappingPartitioner<GraphType>::
setParameters (Teuchos::ParameterList& List)
{
NumLocalParts_ = List.get("partitioner: local parts", NumLocalParts_);
OverlappingLevel_ = List.get("partitioner: overlap", OverlappingLevel_);
verbose_ = List.get("partitioner: print level", verbose_);
if (NumLocalParts_ < 0) {
NumLocalParts_ = Graph_->getNodeNumRows() / (-NumLocalParts_);
}
if (NumLocalParts_ == 0) {
NumLocalParts_ = 1;
}
// Sanity checking
TEUCHOS_TEST_FOR_EXCEPTION(
NumLocalParts_ < 0 ||
Teuchos::as<size_t> (NumLocalParts_) > Graph_->getNodeNumRows(),
std::runtime_error,
"Ifpack2::OverlappingPartitioner::setParameters: "
"Invalid NumLocalParts_ = " << NumLocalParts_ << ".");
TEUCHOS_TEST_FOR_EXCEPTION(
OverlappingLevel_ < 0, std::runtime_error,
"Ifpack2::OverlappingPartitioner::setParameters: "
"Invalid OverlappingLevel_ = " << OverlappingLevel_ << ".");
setPartitionParameters(List);
}
示例4: Krylov
// ======================================================================
void Krylov(const Operator& A, const MultiVector& LHS,
const MultiVector& RHS, const BaseOperator& Prec,
Teuchos::ParameterList& List)
{
#ifndef HAVE_ML_AZTECOO
std::cerr << "Please configure ML with --enable-aztecoo to use" << std::endl;
std::cerr << "MLAPI Krylov solvers" << std::endl;
exit(EXIT_FAILURE);
#else
if (LHS.GetNumVectors() != 1)
ML_THROW("FIXME: only one vector is currently supported", -1);
Epetra_LinearProblem Problem;
const Epetra_RowMatrix& A_Epetra = *(A.GetRowMatrix());
Epetra_Vector LHS_Epetra(View,A_Epetra.OperatorDomainMap(),
(double*)&(LHS(0)));
Epetra_Vector RHS_Epetra(View,A_Epetra.OperatorRangeMap(),
(double*)&(RHS(0)));
// FIXME: this works only for Epetra-based operators
Problem.SetOperator((const_cast<Epetra_RowMatrix*>(&A_Epetra)));
Problem.SetLHS(&LHS_Epetra);
Problem.SetRHS(&RHS_Epetra);
AztecOO solver(Problem);
EpetraBaseOperator Prec_Epetra(A_Epetra.OperatorDomainMap(),Prec);
solver.SetPrecOperator(&Prec_Epetra);
// get options from List
int NumIters = List.get("krylov: max iterations", 1550);
double Tol = List.get("krylov: tolerance", 1e-9);
std::string type = List.get("krylov: type", "gmres");
int output = List.get("krylov: output level", GetPrintLevel());
// set options in `solver'
if (type == "cg")
solver.SetAztecOption(AZ_solver, AZ_cg);
else if (type == "cg_condnum")
solver.SetAztecOption(AZ_solver, AZ_cg_condnum);
else if (type == "gmres")
solver.SetAztecOption(AZ_solver, AZ_gmres);
else if (type == "gmres_condnum")
solver.SetAztecOption(AZ_solver, AZ_gmres_condnum);
else if (type == "fixed point")
solver.SetAztecOption(AZ_solver, AZ_fixed_pt);
else
ML_THROW("krylov: type has incorrect value (" +
type + ")", -1);
solver.SetAztecOption(AZ_output, output);
solver.Iterate(NumIters, Tol);
#endif
}
示例5: L
Stokhos::KL::OneDExponentialCovarianceFunction<value_type>::
OneDExponentialCovarianceFunction(int M,
const value_type& a,
const value_type& b,
const value_type& L_,
const std::string& dim_name,
Teuchos::ParameterList& solverParams) :
L(L_),
eig_pair(M)
{
// Get parameters with default values
magnitude_type eps = solverParams.get("Bound Perturbation Size", 1e-6);
magnitude_type tol = solverParams.get("Nonlinear Solver Tolerance", 1e-10);
int max_it = solverParams.get("Maximum Nonlinear Solver Iterations", 100);
value_type aa, alpha, omega, lambda;
int i=0;
double pi = 4.0*std::atan(1.0);
int idx = 0;
aa = (b-a)/2.0;
while (i < M-1) {
alpha = aa/L;
omega = bisection(EigFuncCos(alpha), idx*pi, idx*pi+pi/2.0-eps,
tol, max_it) / aa;
lambda = 2.0*L/(L*L*omega*omega + 1.0);
eig_pair[i].eig_val = lambda;
eig_pair[i].eig_func = Teuchos::rcp(new
ExponentialOneDEigenFunction<value_type>(
ExponentialOneDEigenFunction<value_type>::COS, a, b, omega, dim_name)
);
i++;
omega = bisection(EigFuncSin(alpha), idx*pi+pi/2.0+eps, (idx+1)*pi,
tol, max_it) / aa;
lambda = 2.0*L/(L*L*omega*omega + 1.0);
eig_pair[i].eig_val = lambda;
eig_pair[i].eig_func = Teuchos::rcp(new
ExponentialOneDEigenFunction<value_type>(
ExponentialOneDEigenFunction<value_type>::SIN, a, b, omega, dim_name)
);
i++;
idx++;
}
if (i < M) {
omega = bisection(EigFuncCos(alpha), idx*pi, idx*pi+pi/2.0-eps,
tol, max_it) / aa;
lambda = 2.0*L/(L*L*omega*omega + 1.0);
eig_pair[i].eig_val = lambda;
eig_pair[i].eig_func = Teuchos::rcp(new
ExponentialOneDEigenFunction<value_type>(
ExponentialOneDEigenFunction<value_type>::COS, a, b, omega, dim_name)
);
}
}
示例6: type_name
void ConstitutiveModelParameters<EvalT, Traits>::
parseParameters(const std::string &n,
Teuchos::ParameterList &p,
Teuchos::RCP<ParamLib> paramLib)
{
Teuchos::ParameterList pl =
p.get<Teuchos::ParameterList*>("Material Parameters")->sublist(n);
std::string type_name(n + " Type");
std::string type = pl.get(type_name, "Constant");
if (type == "Constant") {
is_constant_map_.insert(std::make_pair(n, true));
constant_value_map_.insert(std::make_pair(n, pl.get("Value", 1.0)));
new Sacado::ParameterRegistration<EvalT, SPL_Traits>(n, this, paramLib);
if (have_temperature_) {
if (pl.get<std::string>("Temperature Dependence Type", "Linear")
== "Linear") {
temp_type_map_.insert(std::make_pair(n,"Linear"));
dparam_dtemp_map_.insert
(std::make_pair(n,
pl.get<RealType>("Linear Temperature Coefficient", 0.0)));
ref_temp_map_.insert
(std::make_pair(n, pl.get<RealType>("Reference Temperature", -1)));
} else if (pl.get<std::string>("Temperature Dependence Type", "Linear")
== "Arrhenius") {
temp_type_map_.insert(std::make_pair(n,"Arrhenius"));
pre_exp_map_.insert(
std::make_pair(n, pl.get<RealType>("Pre Exponential", 0.0)));
exp_param_map_.insert(
std::make_pair(n, pl.get<RealType>("Exponential Parameter", 0.0)));
}
}
} else if (type == "Truncated KL Expansion") {
is_constant_map_.insert(std::make_pair(n, false));
PHX::MDField<MeshScalarT, Cell, QuadPoint, Dim>
fx(p.get<std::string>("QP Coordinate Vector Name"), dl_->qp_vector);
coord_vec_ = fx;
this->addDependentField(coord_vec_);
exp_rf_kl_map_.
insert(
std::make_pair(n,
Teuchos::rcp(
new Stokhos::KL::ExponentialRandomField<MeshScalarT>(pl))));
int num_KL = exp_rf_kl_map_[n]->stochasticDimension();
// Add KL random variables as Sacado-ized parameters
rv_map_.insert(std::make_pair(n, Teuchos::Array<ScalarT>(num_KL)));
for (int i(0); i < num_KL; ++i) {
std::string ss = Albany::strint(n + " KL Random Variable", i);
new Sacado::ParameterRegistration<EvalT, SPL_Traits>(ss, this, paramLib);
rv_map_[n][i] = pl.get(ss, 0.0);
}
}
}
示例7: rcp
// ************************************************************************
// ************************************************************************
Teuchos::RCP<NOX::StatusTest::Generic> NOX::StatusTest::Factory::
buildStagnationTest(Teuchos::ParameterList& p, const NOX::Utils& u) const
{
double tolerance = p.get("Tolerance", 1.0e+12);
int iterations = p.get("Consecutive Iterations", 1);
RCP<NOX::StatusTest::Stagnation> status_test =
rcp(new NOX::StatusTest::Stagnation(iterations, tolerance));
return status_test;
}
示例8: SetParameters
//==============================================================================
int Ifpack_PointRelaxation::SetParameters(Teuchos::ParameterList& List)
{
using std::cout;
using std::endl;
std::string PT;
if (PrecType_ == IFPACK_JACOBI)
PT = "Jacobi";
else if (PrecType_ == IFPACK_GS)
PT = "Gauss-Seidel";
else if (PrecType_ == IFPACK_SGS)
PT = "symmetric Gauss-Seidel";
PT = List.get("relaxation: type", PT);
if (PT == "Jacobi")
PrecType_ = IFPACK_JACOBI;
else if (PT == "Gauss-Seidel")
PrecType_ = IFPACK_GS;
else if (PT == "symmetric Gauss-Seidel")
PrecType_ = IFPACK_SGS;
else {
IFPACK_CHK_ERR(-2);
}
NumSweeps_ = List.get("relaxation: sweeps",NumSweeps_);
DampingFactor_ = List.get("relaxation: damping factor",
DampingFactor_);
MinDiagonalValue_ = List.get("relaxation: min diagonal value",
MinDiagonalValue_);
ZeroStartingSolution_ = List.get("relaxation: zero starting solution",
ZeroStartingSolution_);
DoBackwardGS_ = List.get("relaxation: backward mode",DoBackwardGS_);
DoL1Method_ = List.get("relaxation: use l1",DoL1Method_);
L1Eta_ = List.get("relaxation: l1 eta",L1Eta_);
// This (partial) reordering would require a very different implementation of Jacobi than we have no, so we're not
// going to do it.
NumLocalSmoothingIndices_= List.get("relaxation: number of local smoothing indices",NumLocalSmoothingIndices_);
LocalSmoothingIndices_ = List.get("relaxation: local smoothing indices",LocalSmoothingIndices_);
if(PrecType_ == IFPACK_JACOBI && LocalSmoothingIndices_) {
NumLocalSmoothingIndices_=NumMyRows_;
LocalSmoothingIndices_=0;
if(!Comm().MyPID()) cout<<"Ifpack_PointRelaxation: WARNING: Reordered/Local Smoothing not implemented for Jacobi. Defaulting to regular Jacobi"<<endl;
}
SetLabel();
return(0);
}
示例9:
void
LinePartitioner<GraphType,Scalar>::
setPartitionParameters(Teuchos::ParameterList& List) {
threshold_ = List.get("partitioner: line detection threshold",threshold_);
TEUCHOS_TEST_FOR_EXCEPTION(threshold_ < Teuchos::ScalarTraits<MT>::zero() || threshold_ > Teuchos::ScalarTraits<MT>::one(),
std::runtime_error,"Ifpack2::LinePartitioner: threshold not valid");
NumEqns_ = List.get("partitioner: PDE equations",NumEqns_);
TEUCHOS_TEST_FOR_EXCEPTION(NumEqns_<1,std::runtime_error,"Ifpack2::LinePartitioner: NumEqns not valid");
coord_ = List.get("partitioner: coordinates",coord_);
TEUCHOS_TEST_FOR_EXCEPTION(coord_.is_null(),std::runtime_error,"Ifpack2::LinePartitioner: coordinates not defined");
}
示例10: sprintf
//==========================================================================
int Ifpack2_ILU::SetParameters(Teuchos::ParameterList& List)
{
RelaxValue_ = List.get("fact: relax value", RelaxValue_);
Athresh_ = List.get("fact: absolute threshold", Athresh_);
Rthresh_ = List.get("fact: relative threshold", Rthresh_);
LevelOfFill_ = List.get("fact: level-of-fill", LevelOfFill_);
// set label
sprintf(Label_, "TIFPACK ILU (fill=%d, relax=%f, athr=%f, rthr=%f)",
LevelOfFill(), RelaxValue(), AbsoluteThreshold(),
RelativeThreshold());
return(0);
}
示例11: SetParameters
//==========================================================================
int Ifpack_IC::SetParameters(Teuchos::ParameterList& List)
{
// Lfil_ = List.get("fact: level-of-fill",Lfil_); // Confusing parameter since Ifpack_IC can only do ICT not IC(k)
Lfil_ = List.get("fact: ict level-of-fill", Lfil_); // Lfil_ is now the fill ratio as in ICT (1.0 means same #nonzeros as A)
Athresh_ = List.get("fact: absolute threshold", Athresh_);
Rthresh_ = List.get("fact: relative threshold", Rthresh_);
Droptol_ = List.get("fact: drop tolerance", Droptol_);
// set label
sprintf(Label_, "IFPACK IC (fill=%f, drop=%f)",
Lfil_, Droptol_);
return(0);
}
示例12: KrylovFactory
void KrylovFactory(Teuchos::ParameterList &parlist) {
EKrylov ekv = StringToEKrylov(parlist.get("Krylov Method","Conjugate Residuals"));
Real absTol = parlist.get("Absolute Krylov Tolerance", 1.e-4);
Real relTol = parlist.get("Relative Krylov Tolerance", 1.e-2);
int maxit = parlist.get("Maximum Number of Krylov Iterations", 20);
bool inexact = parlist.get("Use Inexact Hessian-Times-A-Vector",false);
switch(ekv) {
case KRYLOV_CR:
krylov_ = Teuchos::rcp( new ConjugateResiduals<Real>(absTol,relTol,maxit,inexact) ); break;
case KRYLOV_CG:
default:
krylov_ = Teuchos::rcp( new ConjugateGradients<Real>(absTol,relTol,maxit,inexact) ); break;
}
}
示例13: TruncatedExponential
TruncatedExponential(Teuchos::ParameterList &parlist) {
Teuchos::ParameterList TElist
= parlist.sublist("SOL").sublist("Distribution").sublist("Truncated Exponential");
a_ = TElist.get("Lower Bound",0.);
b_ = TElist.get("Upper Bound",1.);
Real tmp = a_;
a_ = std::min(a_,b_);
b_ = std::max(b_,tmp);
scale_ = TElist.get("Scale",1.);
scale_ = (scale_ > 0.) ? scale_ : 1.;
expa_ = std::exp(-scale_*a_);
expb_ = std::exp(-scale_*b_);
diff_ = expa_ - expb_;
coeff_ = scale_/diff_;
}
示例14: createResponseFunction
Teuchos::Array< Teuchos::RCP<Albany::AbstractResponseFunction> >
Albany::ResponseFactory::
createResponseFunctions(Teuchos::ParameterList& responseList) const
{
using Teuchos::RCP;
using Teuchos::rcp;
using Teuchos::ParameterList;
using Teuchos::Array;
// First check for the old response specification
if (responseList.isType<int>("Number")) {
int num_aggregate_responses = responseList.get<int>("Number");
if (num_aggregate_responses > 0) {
Array<RCP<AbstractResponseFunction> > responses;
createResponseFunction("Aggregated", responseList, responses);
return responses;
}
}
int num_response_vecs = responseList.get("Number of Response Vectors", 0);
Array<RCP<AbstractResponseFunction> > responses;
for (int i=0; i<num_response_vecs; i++) {
std::string sublist_name = Albany::strint("Response Vector",i);
ParameterList& response_params =
responseList.sublist(sublist_name);
std::string response_name = response_params.get<std::string>("Name");
createResponseFunction(response_name, response_params, responses);
}
return responses;
}
示例15: check_for_existance
inline bool Monotone::check_for_existance(Teuchos::ParameterList &source_list)
{
std::string g("Monotone");
bool exists = source_list.getEntryPtr("Type");
if (exists) exists = g==source_list.get("Type",g);
return exists;
}