本文整理汇总了C++中teuchos::ParameterList::end方法的典型用法代码示例。如果您正苦于以下问题:C++ ParameterList::end方法的具体用法?C++ ParameterList::end怎么用?C++ ParameterList::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类teuchos::ParameterList
的用法示例。
在下文中一共展示了ParameterList::end方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rcp
/** \brief Build an inverse library from a parameter list.
*
* Build an inverse library from a parameter list. This will
* contain all the labeled inverses specified.
*
* \param[in] pl Parameter list to build the library from
*
* \returns A pointer to the inverse library created.
*/
RCP<InverseLibrary> InverseLibrary::buildFromParameterList(const Teuchos::ParameterList & pl,bool useStratDefaults)
{
// build from Stratimikos or allocate a new inverse library
RCP<InverseLibrary> invLib;
if(useStratDefaults)
invLib = InverseLibrary::buildFromStratimikos();
else
invLib = rcp(new InverseLibrary());
// to convert the void* like entry
Teuchos::ParameterList * temp = 0;
// loop over all entries in parameter list
Teuchos::ParameterList::ConstIterator itr;
for(itr=pl.begin();itr!=pl.end();++itr) {
// get current entry
std::string label = itr->first;
Teuchos::ParameterList & list = itr->second.getValue(temp);
// add to library
invLib->addInverse(label,list);
}
return invLib;
}
示例2: printListDocumentation
void printListDocumentation(
const Teuchos::ParameterList &pl,
std::ostream &os,
std::string listNames)
{
if (listNames.size() == 0)
listNames = std::string("top");
Array<std::string> subLists;
ParameterList::ConstIterator next = pl.begin();
while (next != pl.end()){
const std::string &name = next->first;
const ParameterEntry &entry = pl.getEntry(name);
if (entry.isList()){
subLists.append(name);
}
else{
std::string doc = entry.docString();
os << "List: "<< listNames << ", parameter: " << name << "\n";
if (doc.size())
os << doc << "\n";
}
++next;
}
for (int i=0; i < subLists.size(); i++){
std::string newListName = listNames + std::string("/") + subLists[i];
const ParameterList &sublist = pl.sublist(subLists[i]);
printListDocumentation(sublist, os, newListName);
}
}
示例3: 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
}
}
示例4: 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;
}
示例5:
template<typename T> void
QCAD::MaterialDatabase::
getAllMatchingParams_helper(const std::string& paramName, std::vector<T>& results, Teuchos::ParameterList& list)
{
Teuchos::ParameterList::ConstIterator it;
Teuchos::ParameterList* list_type = NULL;
T* param_type = NULL;
for(it = list.begin(); it != list.end(); it++) {
if( it->second.isList() ) {
Teuchos::ParameterList& subList = it->second.getValue(list_type);
getAllMatchingParams_helper(paramName, results, subList);
continue;
}
if( it->second.isType<T>() && it->first == paramName )
results.push_back( it->second.getValue(param_type) );
}
}
示例6: 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;
}
示例7: 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;
}
}
}
}
示例8: updateRequestedParameters
/** \brief Update this object with the fields from a parameter list.
*
* Update the requested fields using a parameter list. This method is
* expected to pair with the getRequestedParameters method (i.e. the fields
* requested are going to be update using this method).
*
* \param[in] pl Parameter list containing the requested parameters.
*
* \returns If the method succeeded (found all its required parameters) this
* method returns true, otherwise it returns false.
*
* \note The default implementation returns true (it does nothing!).
*/
bool PreconditionerInverseFactory::updateRequestedParameters(const Teuchos::ParameterList & pl)
{
Teuchos::RCP<BlockPreconditionerFactory> bpf = rcp_dynamic_cast<BlockPreconditionerFactory>(precFactory_);
// update the parameters of a BPF is required
if(bpf!=Teuchos::null)
return bpf->updateRequestedParameters(pl);
// for non block preconditioners see if there are user requested additional parameters
if(extraParams_==Teuchos::null)
return true;
Teuchos::ParameterList::ConstIterator itr;
RCP<Teuchos::ParameterList> srcPl = precFactory_->unsetParameterList();
// find name of settings sublist
std::string subName = "";
for(itr=srcPl->begin();itr!=srcPl->end();++itr) {
// search for std::string with "Settings" in name
if(itr->first.find("Settings")!=std::string::npos) {
subName = itr->first;
continue;
}
}
// update fails if no settings list was found
if(subName=="") {
precFactory_->setParameterList(srcPl);
return false;
}
// add extra parameters to list
Teuchos::ParameterList & settingsList = srcPl->sublist(subName);
for(itr=pl.begin();itr!=pl.end();++itr) {
if(extraParams_->isParameter(itr->first))
settingsList.setEntry(itr->first,itr->second);
}
// set the parameter list
precFactory_->setParameterList(srcPl);
return true;
}
示例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: UpdateContFile
bool UpdateContFile( const string & fileName,
const int & idStep,
const Teuchos::ParameterList & fileParams )
{
// The file to open
ofstream oFile(fileName.c_str(), ios_base::app);
// Writing the id
oFile << scientific << setw(7) << idStep;
// Looping on the parameters
Teuchos::map<string, Teuchos::ParameterEntry>::const_iterator i;
for (i = fileParams.begin(); i !=fileParams.end(); ++i)
oFile << scientific << setw(15) << fileParams.entry(i);
oFile << std::endl;
// Closing
oFile.close();
return true;
}
示例11: 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
}
示例12: 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;
//.........这里部分代码省略.........
示例13: desigNode
HybridPlatform::
HybridPlatform (const Teuchos::RCP<const Teuchos::Comm<int> >& comm,
Teuchos::ParameterList& pl)
: comm_ (comm)
, nodeCreated_ (false)
, nodeType_ (SERIALNODE)
{
// ParameterList format:
//
// Node designation sublists have a name beginning with one of the
// following characters: % = [ and satisfying the following
// format:
// %M=N is satisfied if mod(myrank,M) == N
// =N is satisfied if myrank == N
// [M,N] is satisfied if myrank \in [M,N]
//
// A node designation sublist must have a parameter entry of type
// std::string named "NodeType". The value indicates the type of
// the Node. The activated node designation sublist will be
// passed to the Node constructor.
//
// For example:
// "%2=0" ->
// NodeType = "KokkosClassic::ThrustGPUNode"
// DeviceNumber = 0
// Verbose = 1
// "%2=1" ->
// NodeType = "KokkosClassic::TPINode"
// NumThreads = 8
//
// In this scenario, nodes that are equivalent to zero module 2,
// that is, even nodes, will be selected to use ThrustGPUNode
// objects and initialized with the parameter list containing
// NodeType = "KokkosClassic::ThrustGPUNode"
// DeviceNumber = 0
// Verbose = 1
//
// Nodes that are equivalent to one modulo 2, i.e., odd nodes,
// will be selected to use TPINode objects and initialized with
// the parameter list containing
// NodeType = "KokkosClassic::TPINode"
// NumThreads = 8
//
// If multiple node designation sublists match the process rank,
// then the first encountered node designation will be used. I
// don't know if ParameterList respects any ordering, therefore,
// multiple matching designations are to be avoided.
const int myrank = comm_->getRank();
std::string desigNode("");
bool matchFound = false;
for (Teuchos::ParameterList::ConstIterator it = pl.begin(); it != pl.end(); ++it) {
if (it->second.isList()) {
int parsedLen, M, N;
const std::string &name = it->first;
const Teuchos::ParameterList &sublist = Teuchos::getValue<Teuchos::ParameterList>(it->second);
// select and assign instList_;
parsedLen = 0;
if (std::sscanf(name.c_str(),"%%%d=%d%n",&M,&N,&parsedLen) == 2 && (size_t)parsedLen == name.length()) {
if ((myrank % M) == N) {
matchFound = true;
}
}
parsedLen = 0;
if (std::sscanf(name.c_str(),"=%d%n",&N,&parsedLen) == 1 && (size_t)parsedLen == name.length()) {
if (myrank == N) {
matchFound = true;
}
}
parsedLen = 0;
if (std::sscanf(name.c_str(),"[%d,%d]%n",&M,&N,&parsedLen) == 2 && (size_t)parsedLen == name.length()) {
if (M <= myrank && myrank <= N) {
matchFound = true;
}
}
if (name == "default") {
matchFound = true;
}
if (matchFound) {
try {
desigNode = sublist.get<std::string>("NodeType");
}
catch (Teuchos::Exceptions::InvalidParameterName &e) {
TEUCHOS_TEST_FOR_EXCEPTION_PURE_MSG(true, std::runtime_error,
std::endl << Teuchos::typeName(*this) << ": Invalid machine file." << std::endl
<< "Missing parameter \"NodeType\" on Node " << myrank << " for Node designator " << "\"" << name << "\":" << std::endl
<< sublist << std::endl);
}
if (desigNode == "KokkosClassic::SerialNode") {
nodeType_ = SERIALNODE;
}
#ifdef HAVE_KOKKOSCLASSIC_THREADPOOL
else if (desigNode == "KokkosClassic::TPINode") {
nodeType_ = TPINODE;
}
#endif
#ifdef HAVE_KOKKOSCLASSIC_TBB
else if (desigNode == "KokkosClassic::TBBNode") {
nodeType_ = TBBNODE;
//.........这里部分代码省略.........