本文整理汇总了C++中teuchos::ParameterList::name方法的典型用法代码示例。如果您正苦于以下问题:C++ ParameterList::name方法的具体用法?C++ ParameterList::name怎么用?C++ ParameterList::name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类teuchos::ParameterList
的用法示例。
在下文中一共展示了ParameterList::name方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ValidateMLPParameters
bool ML_Epetra::ValidateMLPParameters(const Teuchos::ParameterList &inList, int depth){
using Teuchos::ParameterList;
using Teuchos::Exceptions::InvalidParameterName;
using Teuchos::Exceptions::InvalidParameterType;
using Teuchos::Exceptions::InvalidParameterValue;
using std::cout;
using std::endl;
using std::string;
ParameterList List,*validList;
bool rv=true;
/* Build a copy of the list to be validated. */
for (ParameterList::ConstIterator param = inList.begin(); param != inList.end(); ++param) {
const std::string pname=inList.name(param);
if (pname.find("user-defined function",0) == std::string::npos) {
List.setEntry(pname,inList.entry(param));
}
}
List.setName(inList.name());
/* Get Defaults + Validate */
try {
validList = GetValidMLPParameters();
}
catch(...) {
std::cout << "Error in GetValidMLPParameters. Please report this bug to the ML "
"developers." << std::endl;
#ifdef HAVE_MPI
MPI_Finalize();
#endif
exit(EXIT_FAILURE);
}
try {
List.validateParameters (*validList, depth, Teuchos::VALIDATE_USED_ENABLED,
Teuchos::VALIDATE_DEFAULTS_DISABLED);
}
#ifdef HAVE_IFPACK_DYNAMIC_FACTORY
catch(InvalidParameterName &excpt) {/*rv=false; std::cout<<excpt.what()<<std::endl;*/}
#else
catch(InvalidParameterName &excpt) {rv=false; std::cout<<excpt.what()<<std::endl;}
#endif
catch(InvalidParameterType &excpt) {rv=false; std::cout<<excpt.what()<<std::endl;}
catch(InvalidParameterValue &excpt) {rv=false; std::cout<<excpt.what()<<std::endl;}
catch(...) {rv=false;}
delete validList;
return rv;
}
示例2: global
bool
ComparisonHelper::metricComparisonTest(const RCP<const Comm<int> > &comm,
const Zoltan2::MetricValues<zscalar_t> & metric,
const Zoltan2::MetricValues<zscalar_t> & ref_metric,
const Teuchos::ParameterList & metricPlist,
ostringstream &msg)
{
// run a comparison of min and max agains a given metric
// return an error message on failure
bool pass = true;
string test_name = metricPlist.name() + " test";
double local_ref_value = ref_metric.getMaxImbalance()/ref_metric.getAvgImbalance();
double local_value = metric.getMaxImbalance()/metric.getAvgImbalance();
// reduce problem metric
double value;
Teuchos::Ptr<double> global(&value);
comm->barrier();
reduceAll<int, double>(*comm.get(),Teuchos::EReductionType::REDUCE_MAX,local_value,global);
// reduce reference metric
double ref_value;
Teuchos::Ptr<double> globalRef(&ref_value);
comm->barrier();
reduceAll<int, double>(*comm.get(),Teuchos::EReductionType::REDUCE_MAX,local_ref_value,globalRef);
// want to reduce value to max value for all procs
if (metricPlist.isParameter("lower"))
{
double min = metricPlist.get<double>("lower")*ref_value;
if(value < min)
{
msg << test_name << " FAILED: Minimum imbalance per part, "
<< value << ", less than specified allowable minimum, " << min << ".\n";
pass = false;
}else{
msg << test_name << " PASSED: Minimum imbalance per part, "
<< value << ", greater than specified allowable minimum, " << min << ".\n";
}
}
if(metricPlist.isParameter("upper" ) && pass != false) {
double max = metricPlist.get<double>("upper") * ref_value;
if (value > max)
{
msg << test_name << " FAILED: Maximum imbalance per part, "
<< value << ", greater than specified allowable maximum, " << max << ".\n";
pass = false;
}else{
msg << test_name << " PASSED: Maximum imbalance per part, "
<< value << ", less than specified allowable maximum, " << max << ".\n";
}
}
return pass;
}
示例3: timerComparisonTest
// BDD, to do: print metrics even for pass
// reduce max metric to process 0
// print only on process 0 --- duh.
bool ComparisonHelper::timerComparisonTest(const RCP<const Comm<int> > &comm,
const double time,
const double ref_time,
const Teuchos::ParameterList & metricPlist,
ostringstream &msg)
{
// Reduce time from test
double global_time;
Teuchos::Ptr<double> global(&global_time);
comm->barrier();
reduceAll<int, double>(*comm.get(),Teuchos::EReductionType::REDUCE_MAX,time,global);
// Reduce time from reference
double global_ref_time;
Teuchos::Ptr<double> globalRef(&global_ref_time);
comm->barrier();
reduceAll<int, double>(*comm.get(),Teuchos::EReductionType::REDUCE_MAX,ref_time,globalRef);
// run a comparison of min and max agains a given metric
// return an error message on failure
bool pass = true;
string test_name = metricPlist.name() + " test";
if (metricPlist.isParameter("lower"))
{
double min = metricPlist.get<double>("lower")*global_ref_time;
if(global_time < min)
{
msg << test_name << " FAILED: Minimum time, "
<< time <<
"[s], less than specified allowable minimum time, " << min <<"[s]"<< ".\n";
pass = false;
}else{
msg << test_name << " PASSED: Minimum time, "
<< time <<
"[s], greater than specified allowable minimum time, " << min <<"[s]"<< ".\n";
}
}
if(metricPlist.isParameter("upper" ) && pass != false) {
double max = metricPlist.get<double>("upper") * global_ref_time;
if (global_time > max)
{
msg << test_name << " FAILED: Maximum time, "
<< global_time <<
"[s], greater than specified allowable maximum time, " << max <<"[s]"<< ".\n";
pass = false;
}else{
msg << test_name << " PASSED: Maximum time, "
<< global_time <<
"[s], less than specified allowable maximum time, " << max <<"[s]"<< ".\n";
}
}
return pass;
}
示例4: TouchContFileParameters
bool TouchContFileParameters( Teuchos::ParameterList & fileParams )
{
// Either int or double type
int dummyInt;
double dummyDouble;
// Looping the list
Teuchos::map<string, Teuchos::ParameterEntry>::const_iterator i;
for (i = fileParams.begin(); i !=fileParams.end(); ++i) {
if (fileParams.isType<int>(fileParams.name(i)))
dummyInt = fileParams.get<int>(fileParams.name(i));
if (fileParams.isType<double>(fileParams.name(i)))
dummyDouble = fileParams.get<double>(fileParams.name(i));
}
return true;
}
示例5: buildResponseMap
void buildResponseMap(const Teuchos::ParameterList & p,
std::map<std::string,std::pair<ResponseId,std::pair<std::list<std::string>,std::list<std::string> > > > & responses)
{
static Teuchos::RCP<const Teuchos::ParameterList> validList;
// build valid parameter list
if(validList==Teuchos::null) {
Teuchos::RCP<Teuchos::ParameterList> tmpList = Teuchos::rcp(new Teuchos::ParameterList);
tmpList->set<std::string>("Type","");
tmpList->set<std::string>("Field Name","");
tmpList->set<std::string>("Element Blocks","empty","Element blocks for this response",Teuchos::rcp(new CommaSeperatedEntryValidator));
tmpList->set<std::string>("Evaluation Types","empty","Evaluation types for this response",Teuchos::rcp(new CommaSeperatedEntryValidator));
validList = tmpList;
}
CommaSeperatedEntryValidator validator;
const std::string & sublistName = p.name();
std::vector<std::string> tokens;
responses.clear();
// loop over entries of parameter list, must satisfy response formatting
for(Teuchos::ParameterList::ConstIterator itr=p.begin(); itr!=p.end();++itr) {
const std::string & paramName = itr->first;
const Teuchos::ParameterEntry & pe = itr->second;
// make sure this is a parameter list
TEUCHOS_TEST_FOR_EXCEPTION(!pe.isList(),Teuchos::Exceptions::InvalidParameterValue,
"In list \""+sublistName+"\", the parameter \""+paramName+"\" is expected "
"to be a sublist. Response map cannot be built!");
// extract parameter list and validate
const Teuchos::ParameterList & respList = Teuchos::getValue<Teuchos::ParameterList>(pe);
respList.validateParameters(*validList);
const std::string & respLabel = paramName;
ResponseId & rid = responses[respLabel].first;
std::list<std::string> & eBlocks = responses[respLabel].second.first; // element blocks
std::list<std::string> & eTypes = responses[respLabel].second.second; // evaluation types
rid.type = respList.get<std::string>("Type");
rid.name = respList.get<std::string>("Field Name");
CommaSeperatedEntryValidator::split(respList.get<std::string>("Element Blocks"),",",tokens);
eBlocks.assign(tokens.begin(),tokens.end()); // this should automatically wipe out old values
CommaSeperatedEntryValidator::split(respList.get<std::string>("Evaluation Types"),",",tokens);
eTypes.assign(tokens.begin(),tokens.end()); // this should automatically wipe out old values
}
}
示例6: setParameters
Operator<Node>::Operator(Teuchos::RCP<const ::Tpetra::CrsGraph<int,int,Node> > input_graph,
const Teuchos::ParameterList& paramlist, int base)
: input_graph_(input_graph),
operation_already_computed_(false),
base_(base)
{
input_map_ = input_graph->getRowMap(); //think this is safe
if(paramlist.name() != "EmptyParameterList")
{
setParameters(paramlist);
}
}
示例7:
bool
ComparisonHelper::metricComparisonTest(const RCP<const Comm<int> > &comm,
const Zoltan2::MetricValues<zscalar_t> & metric,
const Zoltan2::MetricValues<zscalar_t> & ref_metric,
const Teuchos::ParameterList & metricPlist,
ostringstream &msg)
{
// run a comparison of min and max agains a given metric
// return an error message on failure
bool pass = true;
string test_name = metricPlist.name() + " test";
double ref_value = ref_metric.getMaxImbalance();
double value = metric.getMaxImbalance();
// want to reduce value to max value for all procs
if (metricPlist.isParameter("lower"))
{
double min = metricPlist.get<double>("lower")*ref_value;
if(value < min)
{
msg << test_name << " FAILED: imbalance per part, "
<< value << ", less than specified allowable minimum, " << min << ".\n";
pass = false;
}else{
msg << test_name << " PASSED: imbalance per part, "
<< value << ", greater than specified allowable minimum, " << min << ".\n";
}
}
if(metricPlist.isParameter("upper" ) && pass != false) {
double max = metricPlist.get<double>("upper") * ref_value;
if (value > max)
{
msg << test_name << " FAILED: imbalance per part, "
<< value << ", greater than specified allowable maximum, " << max << ".\n";
pass = false;
}else{
msg << test_name << " PASSED: imbalance per part, "
<< value << ", less than specified allowable maximum, " << max << ".\n";
}
}
return pass;
}
示例8: metricComparisonTest
bool ComparisonHelper::metricComparisonTest(const RCP<const Comm<int> > &comm,
const MetricAnalyzerInfo & metric,
const MetricAnalyzerInfo & ref_metric,
const Teuchos::ParameterList & metricPlist,
ostringstream &msg)
{
// run a comparison of min and max against a given metric
// return an error message on failure
bool pass = true;
string test_name = metricPlist.name() + " test";
double ref_value = ref_metric.theValue;
double value = metric.theValue;
if (ref_value == 0) {
throw std::logic_error( "The parameter list had a 0 value for the reference value so a percentage cannot be calculated." );
}
double percentRatio = value / ref_value;
// want to reduce value to max value for all procs
if (ref_metric.bFoundLowerBound) {
double min = ref_metric.lowerValue;
if (percentRatio < min) {
msg << test_name << " FAILED: " << ref_metric.parameterDescription << ": " << value << " is " << percentRatio << " percent of the reference value " << ref_value << ", which less than specified allowable minimum percent, " << min << ".\n";
pass = false;
}
else {
msg << test_name << " PASSED: " << ref_metric.parameterDescription << ": " << value << " is " << percentRatio << " percent of the reference value " << ref_value << ", which is greater than specified allowable minimum percent, " << min << ".\n";
}
}
if (ref_metric.bFoundUpperBound) {
double max = ref_metric.upperValue;
if (percentRatio > max) {
msg << test_name << " FAILED: " << ref_metric.parameterDescription << ": " << value << " is " << percentRatio << " percent of the reference value " << ref_value << ", which is greater than specified allowable maximum percent, " << max << ".\n";
pass = false;
}
else {
msg << test_name << " PASSED: " << ref_metric.parameterDescription << ": " << value << " is " << percentRatio << " percent of the reference value " << ref_value << ", which is less than specified allowable maximum percent, " << max << ".\n";
}
}
return pass;
}
示例9: WriteHeaderToContFile
bool WriteHeaderToContFile( const string & fileName,
const Teuchos::ParameterList & fileParams )
{
// The file to open
ofstream oFile(fileName.c_str());
// Writing the header
oFile << "#" << setw(6) << "ID";
// Looping on the parameters
Teuchos::map<string, Teuchos::ParameterEntry>::const_iterator i;
for (i = fileParams.begin(); i !=fileParams.end(); ++i)
oFile << setw(15) << fileParams.name(i);
oFile << std::endl;
// Closing
oFile.close();
return true;
}
示例10: origName
void Operator<Node>::paramsToUpper(Teuchos::ParameterList &plist, int &changed, bool rmUnderscore)
{
changed = 0;
// get a list of all parameter names in the list
std::vector<std::string> paramNames ;
Teuchos::ParameterList::ConstIterator pIter;
pIter = plist.begin();
while (1){
//////////////////////////////////////////////////////////////////////
// Compiler considered this while statement an error
// for ( pIter = plist.begin() ; pIter != plist.end() ; pIter++ ){
// }
//////////////////////////////////////////////////////////////////////
if (pIter == plist.end()) break;
const std::string & nm = plist.name(pIter);
paramNames.push_back(nm);
pIter++;
}
// Change parameter names and values to upper case
for (unsigned int i=0; i < paramNames.size(); i++){
std::string origName(paramNames[i]);
int paramNameChanged = 0;
stringToUpper(paramNames[i], paramNameChanged, rmUnderscore);
if (plist.isSublist(origName)){
Teuchos::ParameterList &sublist = plist.sublist(origName);
int sublistChanged=0;
paramsToUpper(sublist, sublistChanged, false);
if (paramNameChanged){
// this didn't work, so I need to remove the old sublist
// and create a new one
//
//sublist.setName(paramNames[i]);
Teuchos::ParameterList newlist(sublist);
plist.remove(origName);
plist.set(paramNames[i], newlist);
}
}
else if (plist.isParameter(origName)){
std::string paramVal(plist.get<std::string>(origName));
int paramValChanged=0;
stringToUpper(paramVal, paramValChanged);
if (paramNameChanged || paramValChanged){
if (paramNameChanged){
plist.remove(origName);
}
plist.set(paramNames[i], paramVal);
changed++;
}
}
} // next parameter or sublist
}
示例11: AMGXOperator
//! @name Constructor/Destructor
//@{
AMGXOperator(const Teuchos::RCP<Tpetra::CrsMatrix<SC,LO,GO,NO> > &inA, Teuchos::ParameterList ¶mListIn) {
RCP<const Teuchos::Comm<int> > comm = inA->getRowMap()->getComm();
int numProcs = comm->getSize();
int myRank = comm->getRank();
RCP<Teuchos::Time> amgxTimer = Teuchos::TimeMonitor::getNewTimer("MueLu: AMGX: initialize");
amgxTimer->start();
// Initialize
AMGX_SAFE_CALL(AMGX_initialize());
AMGX_SAFE_CALL(AMGX_initialize_plugins());
/*system*/
//AMGX_SAFE_CALL(AMGX_register_print_callback(&print_callback));
AMGX_SAFE_CALL(AMGX_install_signal_handler());
Teuchos::ParameterList configs = paramListIn.sublist("amgx:params", true);
if (configs.isParameter("json file")) {
AMGX_SAFE_CALL(AMGX_config_create_from_file(&Config_, (const char *) &configs.get<std::string>("json file")[0]));
} else {
std::ostringstream oss;
oss << "";
ParameterList::ConstIterator itr;
for (itr = configs.begin(); itr != configs.end(); ++itr) {
const std::string& name = configs.name(itr);
const ParameterEntry& entry = configs.entry(itr);
oss << name << "=" << filterValueToString(entry) << ", ";
}
oss << "\0";
std::string configString = oss.str();
if (configString == "") {
//print msg that using defaults
//GetOStream(Warnings0) << "Warning: No configuration parameters specified, using default AMGX configuration parameters. \n";
}
AMGX_SAFE_CALL(AMGX_config_create(&Config_, configString.c_str()));
}
// TODO: we probably need to add "exception_handling=1" to the parameter list
// to switch on internal error handling (with no need for AMGX_SAFE_CALL)
#define NEW_COMM
#ifdef NEW_COMM
// NOTE: MPI communicator used in AMGX_resources_create must exist in the scope of AMGX_matrix_comm_from_maps_one_ring
// FIXME: fix for serial comm
RCP<const Teuchos::MpiComm<int> > tmpic = Teuchos::rcp_dynamic_cast<const Teuchos::MpiComm<int> >(comm->duplicate());
TEUCHOS_TEST_FOR_EXCEPTION(tmpic.is_null(), Exceptions::RuntimeError, "Communicator is not MpiComm");
RCP<const Teuchos::OpaqueWrapper<MPI_Comm> > rawMpiComm = tmpic->getRawMpiComm();
MPI_Comm mpiComm = *rawMpiComm;
#endif
// Construct AMGX resources
if (numProcs == 1) {
AMGX_resources_create_simple(&Resources_, Config_);
} else {
int numGPUDevices;
cudaGetDeviceCount(&numGPUDevices);
int device[] = {(comm->getRank() % numGPUDevices)};
AMGX_config_add_parameters(&Config_, "communicator=MPI");
#ifdef NEW_COMM
AMGX_resources_create(&Resources_, Config_, &mpiComm, 1/* number of GPU devices utilized by this rank */, device);
#else
AMGX_resources_create(&Resources_, Config_, MPI_COMM_WORLD, 1/* number of GPU devices utilized by this rank */, device);
#endif
}
AMGX_Mode mode = AMGX_mode_dDDI;
AMGX_solver_create(&Solver_, Resources_, mode, Config_);
AMGX_matrix_create(&A_, Resources_, mode);
AMGX_vector_create(&X_, Resources_, mode);
AMGX_vector_create(&Y_, Resources_, mode);
amgxTimer->stop();
amgxTimer->incrementNumCalls();
std::vector<int> amgx2muelu;
// Construct AMGX communication pattern
if (numProcs > 1) {
RCP<const Tpetra::Import<LO,GO> > importer = inA->getCrsGraph()->getImporter();
TEUCHOS_TEST_FOR_EXCEPTION(importer.is_null(), MueLu::Exceptions::RuntimeError, "The matrix A has no Import object.");
Tpetra::Distributor distributor = importer->getDistributor();
Array<int> sendRanks = distributor.getImagesTo();
Array<int> recvRanks = distributor.getImagesFrom();
std::sort(sendRanks.begin(), sendRanks.end());
std::sort(recvRanks.begin(), recvRanks.end());
bool match = true;
if (sendRanks.size() != recvRanks.size()) {
match = false;
} else {
for (int i = 0; i < sendRanks.size(); i++) {
if (recvRanks[i] != sendRanks[i])
match = false;
//.........这里部分代码省略.........