本文整理汇总了C++中teuchos::ParameterList::isSublist方法的典型用法代码示例。如果您正苦于以下问题:C++ ParameterList::isSublist方法的具体用法?C++ ParameterList::isSublist怎么用?C++ ParameterList::isSublist使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类teuchos::ParameterList
的用法示例。
在下文中一共展示了ParameterList::isSublist方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: utils
// ****************************************************************
// ****************************************************************
Teuchos::RCP<NOX::StatusTest::Generic> Thyra::NOXNonlinearSolver::
buildStatusTests(Teuchos::ParameterList& p)
{
Teuchos::RCP<NOX::StatusTest::Generic> status_test;
NOX::Utils utils(p.sublist("Printing"));
if (p.isSublist("Status Tests")) {
status_test =
NOX::StatusTest::buildStatusTests(p.sublist("Status Tests"), utils);
}
else { // Default status test
Teuchos::RCP<NOX::StatusTest::NormF> absresid =
Teuchos::rcp(new NOX::StatusTest::NormF(1.0e-8));
Teuchos::RCP<NOX::StatusTest::NormWRMS> wrms =
Teuchos::rcp(new NOX::StatusTest::NormWRMS(1.0e-2, 1.0e-8));
Teuchos::RCP<NOX::StatusTest::Combo> converged =
Teuchos::rcp(new NOX::StatusTest::Combo(NOX::StatusTest::Combo::AND));
converged->addStatusTest(absresid);
converged->addStatusTest(wrms);
Teuchos::RCP<NOX::StatusTest::MaxIters> maxiters =
Teuchos::rcp(new NOX::StatusTest::MaxIters(20));
Teuchos::RCP<NOX::StatusTest::FiniteValue> fv =
Teuchos::rcp(new NOX::StatusTest::FiniteValue);
Teuchos::RCP<NOX::StatusTest::Combo> combo =
Teuchos::rcp(new NOX::StatusTest::Combo(NOX::StatusTest::Combo::OR));
combo->addStatusTest(fv);
combo->addStatusTest(converged);
combo->addStatusTest(maxiters);
status_test = combo;
}
return status_test;
}
示例2: SetParameters
//=============================================================================
int Amesos_Klu::SetParameters( Teuchos::ParameterList &ParameterList ) {
// ========================================= //
// retrive KLU's parameters from list. //
// default values defined in the constructor //
// ========================================= //
// retrive general parameters
SetStatusParameters( ParameterList );
SetControlParameters( ParameterList );
if (ParameterList.isParameter("TrustMe") )
TrustMe_ = ParameterList.get<bool>( "TrustMe" );
#if 0
unused for now
if (ParameterList.isSublist("Klu") ) {
Teuchos::ParameterList KluParams = ParameterList.sublist("Klu") ;
}
#endif
return 0;
}
示例3: 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> >& A)
{
using Teuchos::FancyOStream;
using Teuchos::getFancyOStream;
using Teuchos::OSTab;
using Teuchos::RCP;
using Teuchos::rcpFromRef;
using std::cout;
using std::endl;
typedef Tpetra::RowMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> row_matrix_type;
Teuchos::Time timer("precond");
const int myRank = A->getRowMap ()->getComm ()->getRank ();
RCP<FancyOStream> out = getFancyOStream (rcpFromRef (cout));
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<row_matrix_type> (prec_name, A);
Teuchos::ParameterList tif_params;
if (test_params.isSublist("Ifpack2")) {
tif_params = test_params.sublist("Ifpack2");
}
if (myRank == 0) {
*out << "Configuring, initializing, and computing Ifpack2 preconditioner" << endl;
}
{
OSTab tab (*out);
prec->setParameters (tif_params);
prec->initialize ();
{
Teuchos::TimeMonitor timeMon (timer);
prec->compute ();
}
if (myRank == 0) {
*out << "Finished computing Ifpack2 preconditioner" << endl;
OSTab tab2 (*out);
*out << "Time (s): " << timer.totalElapsedTime () << endl;
}
}
if (myRank == 0) {
*out << "Preconditioner attributes:" << endl;
OSTab tab (*out);
prec->describe (*out, Teuchos::VERB_LOW);
}
return prec;
}
示例4: if
Teuchos::RCP<Method<Epetra_MultiVector,Epetra_Operator> > EpetraMVMethodFactory::create( const Teuchos::ParameterList& params )
{
TEUCHOS_TEST_FOR_EXCEPTION(!params.isSublist( "Reduced Basis Method" ), std::invalid_argument, "Reduced Basis Method sublist does not exist!");
// Get the "Reduced Basis Method" sublist.
const Teuchos::ParameterList& rbmethod_params = params.sublist( "Reduced Basis Method" );
// Get the file format type
std::string method = Teuchos::getParameter<std::string>( const_cast<Teuchos::ParameterList&>(rbmethod_params),
"Method" );
Teuchos::RCP< Method<Epetra_MultiVector,Epetra_Operator> > RBMethod;
// POD computed using exact SVD through LAPACK
if ( method == "Lapack POD" ) {
RBMethod = Teuchos::rcp( new LapackPOD() );
}
// Inexact POD computed using inexact SVD through Anasazi
// IncSVDPOD uses Anasazi utility classes, while AnasaziPOD uses Anasazi for the solution
else if ( method == "IncSVD POD" ) {
std::string incsvdmethod = rbmethod_params.get<std::string>("IncSVD Method");
if ( incsvdmethod == "Single/UDV" ) {
RBMethod = Teuchos::rcp( new ISVD_SingleUDV() );
}
else if ( incsvdmethod == "MultiCD/UDV" ) {
RBMethod = Teuchos::rcp( new ISVD_MultiCDUDV() );
}
else if ( incsvdmethod == "MultiSDA/UDV" ) {
RBMethod = Teuchos::rcp( new ISVD_MultiSDAUDV() );
}
else if ( incsvdmethod == "MultiSDB/UDV" ) {
RBMethod = Teuchos::rcp( new ISVD_MultiSDBUDV() );
}
}
else if ( method == "StSVD/RTR") {
RBMethod = Teuchos::rcp( new StSVDRTR() );
}
else if ( method == "Anasazi POD" ) {
RBMethod = Teuchos::rcp( new AnasaziPOD() );
} else
{
std::string err_str = "Reduced basis method, 'Method = " + method + "', is not recognized!";
TEUCHOS_TEST_FOR_EXCEPTION(true, std::invalid_argument, err_str);
}
//
// Return the method created
//
return RBMethod;
}
示例5: SetParameters
//=============================================================================
// Default values are defined in the constructor.
int Amesos_Lapack::SetParameters( Teuchos::ParameterList &ParameterList )
{
// retrive general parameters
SetStatusParameters( ParameterList );
SetControlParameters( ParameterList );
bool Equilibrate = true;
if (ParameterList.isSublist("Lapack") ) {
const Teuchos::ParameterList& LAPACKParams = ParameterList.sublist("Lapack") ;
if ( LAPACKParams.isParameter("Equilibrate") )
Equilibrate = LAPACKParams.get<bool>("Equilibrate");
}
DenseSolver_.FactorWithEquilibration(Equilibrate);
return(0);
}
示例6: 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,LocalMatVec,LocalMatSolve> >& 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;
}
示例7: 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;
}
示例8: 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);
}
}
示例9: 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;
}
示例10: rcp
Teuchos::RCP< std::vector< Teuchos::RCP<PHX::Evaluator<panzer::Traits> > > >
Example::ModelFactory<EvalT>::
buildClosureModels(const std::string& model_id,
const Teuchos::ParameterList& models,
const panzer::FieldLayoutLibrary& fl,
const Teuchos::RCP<panzer::IntegrationRule>& ir,
const Teuchos::ParameterList& default_params,
const Teuchos::ParameterList& user_data,
const Teuchos::RCP<panzer::GlobalData>& global_data,
PHX::FieldManager<panzer::Traits>& fm) const
{
using std::string;
using std::vector;
using Teuchos::RCP;
using Teuchos::rcp;
using Teuchos::ParameterList;
using PHX::Evaluator;
RCP< vector< RCP<Evaluator<panzer::Traits> > > > evaluators =
rcp(new vector< RCP<Evaluator<panzer::Traits> > > );
if (!models.isSublist(model_id)) {
models.print(std::cout);
std::stringstream msg;
msg << "Falied to find requested model, \"" << model_id
<< "\", for equation set:\n" << std::endl;
TEUCHOS_TEST_FOR_EXCEPTION(!models.isSublist(model_id), std::logic_error, msg.str());
}
std::vector<Teuchos::RCP<const panzer::PureBasis> > bases;
fl.uniqueBases(bases);
const ParameterList& my_models = models.sublist(model_id);
for (ParameterList::ConstIterator model_it = my_models.begin();
model_it != my_models.end(); ++model_it) {
bool found = false;
const std::string key = model_it->first;
ParameterList input;
const Teuchos::ParameterEntry& entry = model_it->second;
const ParameterList& plist = Teuchos::getValue<Teuchos::ParameterList>(entry);
if (plist.isType<double>("Value")) {
{ // at IP
input.set("Name", key);
input.set("Value", plist.get<double>("Value"));
input.set("Data Layout", ir->dl_scalar);
RCP< Evaluator<panzer::Traits> > e =
rcp(new panzer::Constant<EvalT,panzer::Traits>(input));
evaluators->push_back(e);
}
for (std::vector<Teuchos::RCP<const panzer::PureBasis> >::const_iterator basis_itr = bases.begin();
basis_itr != bases.end(); ++basis_itr) { // at BASIS
input.set("Name", key);
input.set("Value", plist.get<double>("Value"));
Teuchos::RCP<const panzer::BasisIRLayout> basis = basisIRLayout(*basis_itr,*ir);
input.set("Data Layout", basis->functional);
RCP< Evaluator<panzer::Traits> > e =
rcp(new panzer::Constant<EvalT,panzer::Traits>(input));
evaluators->push_back(e);
}
found = true;
}
if (plist.isType<std::string>("Type")) {
const std::string type = plist.get<std::string>("Type");
if (type == "SIMPLE SOURCE") {
RCP<Evaluator<panzer::Traits> > e = rcp(new Example::SimpleSource<EvalT,panzer::Traits>(key, *ir));
evaluators->push_back(e);
found = true;
} else if (type == "EXACT") {
RCP<Evaluator<panzer::Traits> > e = rcp(new Example::Solution<EvalT,panzer::Traits>(key, *ir));
evaluators->push_back(e);
found = true;
} else if (type == "EXACT nonlinear Robin") {
RCP<Evaluator<panzer::Traits> > e = rcp(new Example::Solution<EvalT,panzer::Traits>(key, *ir, false));
evaluators->push_back(e);
found = true;
} else if (type == "ERROR_CALC") {
{
std::vector<std::string> values(2);
values[0] = plist.get<std::string>("Field A");
values[1] = plist.get<std::string>("Field B");
std::vector<double> scalars(2);
scalars[0] = 1.0;
scalars[1] = -1.0;
Teuchos::ParameterList p;
p.set("Sum Name", key + "_DIFF");
p.set<RCP<std::vector<std::string> > >("Values Names", Teuchos::rcpFromRef(values));
p.set<RCP<const std::vector<double> > >("Scalars", Teuchos::rcpFromRef(scalars));
p.set("Data Layout", ir->dl_scalar);
RCP<Evaluator<panzer::Traits> > e = rcp(new panzer::Sum<EvalT,panzer::Traits>(p));
evaluators->push_back(e);
}
//.........这里部分代码省略.........
示例11: Solve
bool SolverTrilinosML::Solve(INMOST::Sparse::Vector &RHS, INMOST::Sparse::Vector &SOL) {
std::string name = Epetra_problem->first;
Epetra_LinearProblem *Epetra_linear_problem = &Epetra_problem->second;
Epetra_Vector VectorRHS(View, matrix->Map(), &*RHS.Begin());
Epetra_Vector VectorSOL(View, matrix->Map(), &*SOL.Begin());
Epetra_linear_problem->SetRHS(&VectorRHS);
Epetra_linear_problem->SetLHS(&VectorSOL);
bool have_params = parameters_file != "";
const Teuchos::RCP<Teuchos::ParameterList> top_level_params = Teuchos::createParameterList();
Teuchos::ParameterList local_list;
if (have_params) {
Teuchos::updateParametersFromXmlFileAndBroadcast(parameters_file, top_level_params.ptr(),
Teuchos::MpiComm<int>(Teuchos::opaqueWrapper(
RHS.GetCommunicator())));
if (!top_level_params->isSublist(name))
have_params = false;
else {
local_list = top_level_params->sublist(name);
}
}
AztecOO AztecSolver(*Epetra_linear_problem);
if (have_params && local_list.isSublist("AztecOO")) {
Teuchos::ParameterList AztecOOParams = local_list.sublist("AztecOO");
if (AztecOOParams.isParameter("Max Iterations")) {
maximum_iterations = AztecOOParams.get<int>("Max Iterations");
}
if (AztecOOParams.isParameter("Tolerance")) {
rtol = AztecOOParams.get<double>("Tolerance");
}
if (AztecOOParams.isSublist("AztecOO Settings")) {
AztecSolver.SetParameters(AztecOOParams.sublist("AztecOO Settings"));
}
} else {
AztecSolver.SetAztecOption(AZ_diagnostics, AZ_none);
AztecSolver.SetAztecOption(AZ_output, AZ_none);
AztecSolver.SetAztecOption(AZ_solver, AZ_bicgstab);
AztecSolver.SetAztecOption(AZ_overlap, schwartz_overlap);
}
Teuchos::ParameterList List;
if (have_params && local_list.isSublist("ML") && local_list.sublist("ML").isSublist("ML Settings")) {
List = local_list.sublist("ML").sublist("ML Settings");
} else {
ML_Epetra::SetDefaults("SA", List);
List.set("max levels", 6);
List.set("increasing or decreasing", "decreasing");
}
ML_Epetra::MultiLevelPreconditioner *Prec = new ML_Epetra::MultiLevelPreconditioner(*matrix, List, true);
AztecSolver.SetPrecOperator(Prec);
AztecSolver.Iterate(maximum_iterations, rtol);
const double *stats = AztecSolver.GetAztecStatus();
bool success = true;
std::string reason = "";
TrilinosCheckStatus(static_cast<int>(stats[AZ_why]), success, reason);
lastIterations = static_cast<INMOST_DATA_ENUM_TYPE>(AztecSolver.NumIters());
lastResidual = AztecSolver.TrueResidual();
returnReason = reason;
delete Prec;
return success;
}
示例12: if
void NOX::Utils::reset(Teuchos::ParameterList& p)
{
using namespace Teuchos;
// "Output Information" may be stored as a sublist, an int, or as
// a NOX::Utils::MsgType
if (p.isSublist("Output Information")) {
ParameterList& printList = p.sublist("Output Information");
typedef std::map<std::string, NOX::Utils::MsgType> OptionMap;
OptionMap output_options;
output_options["Error"] = NOX::Utils::Error;
output_options["Warning"] = NOX::Utils::Warning;
output_options["Outer Iteration"] = NOX::Utils::OuterIteration;
output_options["Inner Iteration"] = NOX::Utils::InnerIteration;
output_options["Parameters"] = NOX::Utils::Parameters;
output_options["Details"] = NOX::Utils::Details;
output_options["Outer Iteration StatusTest"] = NOX::Utils::OuterIterationStatusTest;
output_options["Linear Solver Details"] = NOX::Utils::LinearSolverDetails;
output_options["Test Details"] = NOX::Utils::TestDetails;
output_options["Stepper Iteration"] = NOX::Utils::StepperIteration;
output_options["Stepper Details"] = NOX::Utils::StepperDetails;
output_options["Stepper Parameters"] = NOX::Utils::StepperParameters;
output_options["Debug"] = NOX::Utils::Debug;
bool add_test = false;
OptionMap::const_iterator start = output_options.begin();
OptionMap::const_iterator stop = output_options.end();
for (OptionMap::const_iterator i = start; i != stop; ++i) {
add_test = printList.get(i->first, false);
if (add_test)
printTest += i->second;
}
}
else if (isParameterType<NOX::Utils::MsgType>(p, "Output Information"))
printTest = get<NOX::Utils::MsgType>(p, "Output Information");
else
printTest = p.get("Output Information", 0xf);
#ifdef HAVE_MPI
if (p.isParameter("MyPID"))
myPID = p.get("MyPID", 0);
else {
// We have to check to ensure MPI has been initialized before calling
// MPI_Comm_rank. Relates to bug 2566. - KL, 17 Sept 2006.
int mpiIsRunning = 0;
MPI_Initialized(&mpiIsRunning);
if (mpiIsRunning)
{
MPI_Comm_rank(MPI_COMM_WORLD, &myPID);
}
else
{
myPID=0;
}
// Set the default in the parameter list
p.get("MyPID", myPID);
}
#else
myPID = p.get("MyPID", 0);
#endif
printProc = p.get("Output Processor", 0);
precision = p.get("Output Precision", 3);
// Output streams
blackholeStream = Teuchos::rcp(new Teuchos::oblackholestream);
if (p.INVALID_TEMPLATE_QUALIFIER
isType< Teuchos::RCP<std::ostream> >("Output Stream"))
printStream =
(p).INVALID_TEMPLATE_QUALIFIER
get< Teuchos::RCP<std::ostream> >("Output Stream");
else
printStream = Teuchos::rcp(&(std::cout), false);
myStream = (myPID == printProc) ? printStream : blackholeStream;
if (p.INVALID_TEMPLATE_QUALIFIER
isType< Teuchos::RCP<std::ostream> >("Error Stream"))
errorStream =
(p).INVALID_TEMPLATE_QUALIFIER
get< Teuchos::RCP<std::ostream> >("Error Stream");
else
errorStream = Teuchos::rcp(&(std::cerr), false);
}
示例13: SetParameters
//=============================================================================
int Amesos_Mumps::SetParameters( Teuchos::ParameterList & ParameterList)
{
// ========================================= //
// retrive MUMPS' parameters from list. //
// default values defined in the constructor //
// ========================================= //
// retrive general parameters
SetStatusParameters(ParameterList);
SetControlParameters(ParameterList);
if (ParameterList.isParameter("NoDestroy"))
NoDestroy_ = ParameterList.get<bool>("NoDestroy");
// can be use using mumps sublist, via "ICNTL(2)"
// if (debug_)
// MDS.ICNTL(2) = 6; // Turn on Mumps verbose output
// retrive MUMPS' specific parameters
if (ParameterList.isSublist("mumps"))
{
Teuchos::ParameterList MumpsParams = ParameterList.sublist("mumps") ;
// ICNTL
for (int i = 1 ; i <= 40 ; ++i)
{
char what[80];
sprintf(what, "ICNTL(%d)", i);
if (MumpsParams.isParameter(what))
SetICNTL(i, MumpsParams.get<int>(what));
}
// CNTL
for (int i = 1 ; i <= 5 ; ++i)
{
char what[80];
sprintf(what, "CNTL(%d)", i);
if (MumpsParams.isParameter(what))
SetCNTL(i, MumpsParams.get<double>(what));
}
// ordering
if (MumpsParams.isParameter("PermIn"))
{
int* PermIn = 0;
PermIn = MumpsParams.get<int*>("PermIn");
if (PermIn) SetOrdering(PermIn);
}
// Col scaling
if (MumpsParams.isParameter("ColScaling"))
{
double * ColSca = 0;
ColSca = MumpsParams.get<double *>("ColScaling");
if (ColSca) SetColScaling(ColSca);
}
// Row scaling
if (MumpsParams.isParameter("RowScaling"))
{
double * RowSca = 0;
RowSca = MumpsParams.get<double *>("RowScaling");
if (RowSca) SetRowScaling(RowSca);
}
// that's all folks
}
return(0);
}
示例14:
Teuchos::RCP< std::vector<std::string> > RBGen::genFileList( const Teuchos::ParameterList& params )
{
Teuchos::RCP< std::vector< std::string > > filenames = Teuchos::rcp( new std::vector< std::string >() );
// See if the "File I/O" sublist exists
TEUCHOS_TEST_FOR_EXCEPTION(!params.isSublist( "File IO" ), std::invalid_argument, "File I/O sublist does not exist!");
// Get the "File I/O" sublist.
Teuchos::ParameterList& fileio_params = const_cast<Teuchos::ParameterList&>(params.sublist( "File IO" ) );
// See if the "Data Filename Format" sublist exists
TEUCHOS_TEST_FOR_EXCEPTION(!fileio_params.isSublist( "Data Filename Format" ), std::invalid_argument, "Data Filename Format sublist does not exist!");
// Get the "Data Filename Format" sublist.
Teuchos::ParameterList& fileformat_params = fileio_params.sublist( "Data Filename Format" );
// Get the string prepended to the numeric characters.
std::string prepend = "";
if ( fileformat_params.isParameter( "Prepend" ) ) {
prepend = Teuchos::getParameter<std::string>( fileformat_params, "Prepend" );
}
// Get the string postpended to the numeric characters.
std::string postpend = "";
if ( fileformat_params.isParameter( "Postpend" ) ) {
postpend = Teuchos::getParameter<std::string>( fileformat_params, "Postpend" );
}
// Get the string prepended to the numeric characters.
std::string extension = "";
if ( fileformat_params.isParameter( "Extension" ) ) {
extension = Teuchos::getParameter<std::string>( fileformat_params, "Extension" );
}
// Get the base for the numeric count
int base_num = 0;
if ( fileformat_params.isParameter( "File Number Base" ) ) {
base_num = Teuchos::getParameter<int>( fileformat_params, "File Number Base" );
}
std::string format_type = Teuchos::getParameter<std::string>( fileformat_params, "Type" );
if ( format_type == "Single file" ) {
// Get the file to process
filenames->push_back( Teuchos::getParameter<std::string>( fileformat_params, "Data File" ) );
} else
if ( format_type == "Fixed length numeric" ) {
// Get the number of files to process
int num_files = Teuchos::getParameter<int>( fileformat_params, "Number of Files" );
int max_num = base_num + num_files;
int num_places = (int)::ceil( ::log10( (double)(max_num) ) );
for (int i=base_num; i<max_num; i++) {
// Generate the current filename
std::string curr_filename = prepend;
// Get the number of places needed for the current file number
int curr_places = (int)::ceil( ::log10( (double)(i+1) ) );
// Add zeros to pad the file number
for (int j=curr_places; j<num_places; j++) {
curr_filename += "0";
}
// Now add on the current file number, postpend string and extension
filenames->push_back( curr_filename + Teuchos::Utils::toString( i ) + postpend + extension );
}
} else
if ( format_type == "Variable length numeric" ) {
// Get the number of files to process
int num_files = Teuchos::getParameter<int>( fileformat_params, "Number of Files" );
int max_num = base_num + num_files;
for (int i=base_num; i<max_num; i++) {
filenames->push_back( prepend + Teuchos::Utils::toString( i ) + postpend + extension );
}
}
else {
std::string err_str = "File format type, 'Type = " + format_type + "', is not recognized!";
TEUCHOS_TEST_FOR_EXCEPTION(true, std::invalid_argument, err_str);
}
return filenames;
}
示例15: if
Teuchos::RCP< std::vector< Teuchos::RCP<PHX::Evaluator<panzer::Traits> > > >
user_app::MyModelFactory<EvalT>::
buildClosureModels(const std::string& model_id,
const Teuchos::ParameterList& models,
const panzer::FieldLayoutLibrary& fl,
const Teuchos::RCP<panzer::IntegrationRule>& ir,
const Teuchos::ParameterList& default_params,
const Teuchos::ParameterList& user_data,
const Teuchos::RCP<panzer::GlobalData>& global_data,
PHX::FieldManager<panzer::Traits>& fm) const
{
using std::string;
using std::vector;
using Teuchos::RCP;
using Teuchos::rcp;
using Teuchos::ParameterList;
using PHX::Evaluator;
RCP< vector< RCP<Evaluator<panzer::Traits> > > > evaluators =
rcp(new vector< RCP<Evaluator<panzer::Traits> > > );
if (!models.isSublist(model_id)) {
models.print(std::cout);
std::stringstream msg;
msg << "Falied to find requested model, \"" << model_id
<< "\", for equation set:\n" << std::endl;
TEUCHOS_TEST_FOR_EXCEPTION(!models.isSublist(model_id), std::logic_error, msg.str());
}
std::vector<Teuchos::RCP<const panzer::PureBasis> > bases;
fl.uniqueBases(bases);
const ParameterList& my_models = models.sublist(model_id);
for (ParameterList::ConstIterator model_it = my_models.begin();
model_it != my_models.end(); ++model_it) {
bool found = false;
const std::string key = model_it->first;
ParameterList input;
const Teuchos::ParameterEntry& entry = model_it->second;
const ParameterList& plist = Teuchos::getValue<Teuchos::ParameterList>(entry);
if (plist.isType<std::string>("Type")) {
if (plist.get<std::string>("Type") == "Parameter") {
TEUCHOS_ASSERT(!plist.isParameter("Value"));
// Defaults for backward compatibility
std::string parameter_name = key;
std::string field_name = key;
if (plist.isType<std::string>("Parameter Name"))
parameter_name = plist.get<std::string>("Parameter Name");
if (plist.isType<std::string>("Field Name"))
field_name = plist.get<std::string>("Field Name");
{ // at IP
RCP< Evaluator<panzer::Traits> > e =
rcp(new panzer::Parameter<EvalT,panzer::Traits>(parameter_name,field_name,ir->dl_scalar,*global_data->pl));
evaluators->push_back(e);
}
for (std::vector<Teuchos::RCP<const panzer::PureBasis> >::const_iterator basis_itr = bases.begin();
basis_itr != bases.end(); ++basis_itr) { // at BASIS
Teuchos::RCP<const panzer::BasisIRLayout> basis = basisIRLayout(*basis_itr,*ir);
RCP< Evaluator<panzer::Traits> > e =
rcp(new panzer::Parameter<EvalT,panzer::Traits>(parameter_name,field_name,basis->functional,*global_data->pl));
evaluators->push_back(e);
}
found = true;
continue;
}
else if (plist.get<std::string>("Type") == "Distributed Parameter") {
// sanity check
TEUCHOS_ASSERT(distr_param_lof!=Teuchos::null);
// build a nodal basis
Teuchos::RCP<const panzer::PureBasis> nodal_basis
= Teuchos::rcp(new panzer::PureBasis("HGrad",1,bases[0]->numCells(),
bases[0]->getCellTopology()));
{
Teuchos::RCP<std::vector<std::string> > dof_names = Teuchos::rcp(new std::vector<std::string>);
dof_names->push_back(key);
ParameterList p("Gather");
p.set("Basis", nodal_basis);
p.set("DOF Names", dof_names);
p.set("Indexer Names", dof_names);
p.set("Sensitivities Name", key);
p.set("Disable Sensitivities", false);
p.set("Gather Seed Index", 0);
p.set("Global Data Key", key);
RCP< PHX::Evaluator<panzer::Traits> > e = distr_param_lof->buildGatherDomain<EvalT>(p);
evaluators->push_back(e);
//.........这里部分代码省略.........