本文整理汇总了C++中ParameterList::print方法的典型用法代码示例。如果您正苦于以下问题:C++ ParameterList::print方法的具体用法?C++ ParameterList::print怎么用?C++ ParameterList::print使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParameterList
的用法示例。
在下文中一共展示了ParameterList::print方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writeThenReadPL
TEUCHOS_UNIT_TEST(Teuchos_ParameterList, parameterEntryXMLConverters)
{
ParameterList myList;
ADD_TYPE_AND_ARRAY_TYPE_PARAMETER(int, 2);
ADD_TYPE_AND_ARRAY_TYPE_PARAMETER(unsigned int, 3);
ADD_TYPE_AND_ARRAY_TYPE_PARAMETER(short int, 4);
ADD_TYPE_AND_ARRAY_TYPE_PARAMETER(unsigned short int, 5);
ADD_TYPE_AND_ARRAY_TYPE_PARAMETER(long int, 6);
ADD_TYPE_AND_ARRAY_TYPE_PARAMETER(unsigned long int, 7);
#ifdef HAVE_TEUCHOS_LONG_LONG_INT
ADD_TYPE_AND_ARRAY_TYPE_PARAMETER(long long int, 8);
ADD_TYPE_AND_ARRAY_TYPE_PARAMETER(unsigned long long int, 9);
#endif //HAVE_TEUCHOS_LONG_LONG_INT
ADD_TYPE_AND_ARRAY_TYPE_PARAMETER(double, 10.0);
ADD_TYPE_AND_ARRAY_TYPE_PARAMETER(float, 11.0);
ADD_TYPE_AND_ARRAY_TYPE_PARAMETER(std::string, "hello");
ADD_TYPE_PARAMETER(char, 'a');
ADD_TYPE_PARAMETER(bool, true);
RCP<ParameterList> readInPL = writeThenReadPL(myList);
out << "\nmyList:\n";
myList.print(out);
out << "\n*readInPL:\n";
readInPL->print(out);
TEST_ASSERT(haveSameValues(myList, *readInPL));
}
示例2: toString
void ParameterListInterpreter<Scalar, LocalOrdinal, GlobalOrdinal, Node, LocalMatOps>::SetEasyParameterList(const Teuchos::ParameterList& constParamList) {
// Create a non const copy of the parameter list
// Working with a modifiable list is much much easier than with original one
ParameterList paramList = constParamList;
// Translate cycle type parameter
if (paramList.isParameter("cycle type")) {
std::map<std::string,CycleType> cycleMap;
cycleMap["V"] = VCYCLE;
cycleMap["W"] = WCYCLE;
std::string cycleType = paramList.get<std::string>("cycle type");
TEUCHOS_TEST_FOR_EXCEPTION(cycleMap.count(cycleType) == 0, Exceptions::RuntimeError, "Invalid cycle type: \"" << cycleType << "\"");
Cycle_ = cycleMap[cycleType];
}
this->maxCoarseSize_ = paramList.get<int> ("coarse: max size", Hierarchy::GetDefaultMaxCoarseSize());
this->numDesiredLevel_ = paramList.get<int> ("max levels", Hierarchy::GetDefaultMaxLevels());
this->graphOutputLevel_ = paramList.get<int> ("debug: graph level", -1);
blockSize_ = paramList.get<int> ("number of equations", 1);
// Save level data
if (paramList.isSublist("print")) {
ParameterList printList = paramList.sublist("print");
if (printList.isParameter("A"))
this->matricesToPrint_ = Teuchos::getArrayFromStringParameter<int>(printList, "A");
if (printList.isParameter("P"))
this->prolongatorsToPrint_ = Teuchos::getArrayFromStringParameter<int>(printList, "P");
if (printList.isParameter("R"))
this->restrictorsToPrint_ = Teuchos::getArrayFromStringParameter<int>(printList, "R");
}
// Translate verbosity parameter
this->verbosity_ = static_cast<MsgType>(Hierarchy::GetDefaultVerbLevel()); // cast int to enum
if (paramList.isParameter("verbosity")) {
std::map<std::string,MsgType> verbMap;
verbMap["none"] = None;
verbMap["low"] = Low;
verbMap["medium"] = Medium;
verbMap["high"] = High;
verbMap["extreme"] = Extreme;
verbMap["test"] = Test;
std::string verbosityLevel = paramList.get<std::string>("verbosity");
TEUCHOS_TEST_FOR_EXCEPTION(verbMap.count(verbosityLevel) == 0, Exceptions::RuntimeError, "Invalid verbosity level: \"" << verbosityLevel << "\"");
this->verbosity_ = verbMap[verbosityLevel];
this->SetVerbLevel(this->verbosity_);
}
// Detect if we need to transfer coordinates to coarse levels. We do that iff
// - we use "laplacian" dropping on some level, or
// - we use repartitioning on some level
// This is not ideal, as we may have "repartition: enable" turned on by default
// and not present in the list, but it is better than nothing.
useCoordinates_ = false;
if ((paramList.isParameter("repartition: enable") && paramList.get<bool>("repartition: enable") == true) ||
(paramList.isParameter("aggregation: drop scheme") && paramList.get<std::string>("aggregation: drop scheme") == "laplacian")) {
useCoordinates_ = true;
} else {
for (int levelID = 0; levelID < this->numDesiredLevel_; levelID++) {
std::string levelStr = "level" + toString(levelID);
if (paramList.isSublist(levelStr)) {
const ParameterList& levelList = paramList.sublist(levelStr);
if ((levelList.isParameter("repartition: enable") && levelList.get<bool>("repartition: enable") == true) ||
(levelList.isParameter("aggregation: drop scheme") && levelList.get<std::string>("aggregation: drop scheme") == "laplacian")) {
useCoordinates_ = true;
break;
}
}
}
}
// Detect if we do implicit P and R rebalance
if (paramList.isParameter("repartition: enable") && paramList.get<bool>("repartition: enable") == true)
this->doPRrebalance_ = paramList.get<bool>("repartition: rebalance P and R", Hierarchy::GetDefaultPRrebalance());
this->implicitTranspose_ = paramList.get<bool>("transpose: use implicit", Hierarchy::GetDefaultImplicitTranspose());
// Create default manager
RCP<FactoryManager> defaultManager = rcp(new FactoryManager());
defaultManager->SetVerbLevel(this->verbosity_);
UpdateFactoryManager(paramList, ParameterList(), *defaultManager);
defaultManager->Print();
for (int levelID = 0; levelID < this->numDesiredLevel_; levelID++) {
RCP<FactoryManager> levelManager;
if (paramList.isSublist("level " + toString(levelID))) {
// Some level specific parameters, update default manager
bool mustAlreadyExist = true;
ParameterList& levelList = paramList.sublist("level " + toString(levelID), mustAlreadyExist);
levelManager = rcp(new FactoryManager(*defaultManager));
levelManager->SetVerbLevel(defaultManager->GetVerbLevel());
UpdateFactoryManager(levelList, paramList, *levelManager);
//.........这里部分代码省略.........
示例3: main
int main(int narg, char *arg[]) {
Teuchos::GlobalMPISession mpiSession(&narg, &arg,0);
Platform &platform = Tpetra::DefaultPlatform::getDefaultPlatform();
RCP<const Teuchos::Comm<int> > CommT = platform.getComm();
int me = CommT->getRank();
int numProcs = CommT->getSize();
if (me == 0){
cout
<< "====================================================================\n"
<< "| |\n"
<< "| Example: Partition Pamgen Hexahedral Mesh |\n"
<< "| |\n"
<< "| Questions? Contact Karen Devine ([email protected]), |\n"
<< "| Erik Boman ([email protected]), |\n"
<< "| Siva Rajamanickam ([email protected]). |\n"
<< "| |\n"
<< "| Pamgen's website: http://trilinos.sandia.gov/packages/pamgen |\n"
<< "| Zoltan2's website: http://trilinos.sandia.gov/packages/zoltan2 |\n"
<< "| Trilinos website: http://trilinos.sandia.gov |\n"
<< "| |\n"
<< "====================================================================\n";
}
#ifdef HAVE_MPI
if (me == 0) {
cout << "PARALLEL executable \n";
}
#else
if (me == 0) {
cout << "SERIAL executable \n";
}
#endif
/***************************************************************************/
/*************************** GET XML INPUTS ********************************/
/***************************************************************************/
// default values for command-line arguments
std::string xmlMeshInFileName("Poisson.xml");
std::string action("mj");
int nParts = CommT->getSize();
// Read run-time options.
Teuchos::CommandLineProcessor cmdp (false, false);
cmdp.setOption("xmlfile", &xmlMeshInFileName,
"XML file with PamGen specifications");
cmdp.setOption("action", &action,
"Method to use: mj, scotch, zoltan_rcb, zoltan_hg, hg_ghost, "
"parma or color");
cmdp.setOption("nparts", &nParts,
"Number of parts to create");
cmdp.parse(narg, arg);
// Read xml file into parameter list
ParameterList inputMeshList;
if(xmlMeshInFileName.length()) {
if (me == 0) {
cout << "\nReading parameter list from the XML file \""
<<xmlMeshInFileName<<"\" ...\n\n";
}
Teuchos::updateParametersFromXmlFile(xmlMeshInFileName,
Teuchos::inoutArg(inputMeshList));
if (me == 0) {
inputMeshList.print(cout,2,true,true);
cout << "\n";
}
}
else {
cout << "Cannot read input file: " << xmlMeshInFileName << "\n";
return 5;
}
// Get pamgen mesh definition
std::string meshInput = Teuchos::getParameter<std::string>(inputMeshList,
"meshInput");
/***************************************************************************/
/********************** GET CELL TOPOLOGY **********************************/
/***************************************************************************/
// Get dimensions
int dim = 3;
/***************************************************************************/
/***************************** GENERATE MESH *******************************/
/***************************************************************************/
if (me == 0) cout << "Generating mesh ... \n\n";
// Generate mesh with Pamgen
long long maxInt = 9223372036854775807LL;
Create_Pamgen_Mesh(meshInput.c_str(), dim, me, numProcs, maxInt);
// Creating mesh adapter
if (me == 0) cout << "Creating mesh adapter ... \n\n";
//.........这里部分代码省略.........
示例4: mpiSession
int
main (int argc, char *argv[])
{
using namespace TrilinosCouplings; // Yes, this means I'm lazy.
using TpetraIntrepidPoissonExample::exactResidualNorm;
using TpetraIntrepidPoissonExample::makeMatrixAndRightHandSide;
using TpetraIntrepidPoissonExample::solveWithBelos;
using TpetraIntrepidPoissonExample::solveWithBelosGPU;
using IntrepidPoissonExample::makeMeshInput;
using IntrepidPoissonExample::parseCommandLineArguments;
using IntrepidPoissonExample::setCommandLineArgumentDefaults;
using IntrepidPoissonExample::setMaterialTensorOffDiagonalValue;
using IntrepidPoissonExample::setUpCommandLineArguments;
using Tpetra::DefaultPlatform;
using Teuchos::Comm;
using Teuchos::outArg;
using Teuchos::ParameterList;
using Teuchos::parameterList;
using Teuchos::RCP;
using Teuchos::rcp;
using Teuchos::rcpFromRef;
using Teuchos::getFancyOStream;
using Teuchos::FancyOStream;
using std::endl;
// Pull in typedefs from the example's namespace.
typedef TpetraIntrepidPoissonExample::ST ST;
#ifdef HAVE_TRILINOSCOUPLINGS_MUELU
typedef TpetraIntrepidPoissonExample::LO LO;
typedef TpetraIntrepidPoissonExample::GO GO;
#endif // HAVE_TRILINOSCOUPLINGS_MUELU
typedef TpetraIntrepidPoissonExample::Node Node;
typedef Teuchos::ScalarTraits<ST> STS;
typedef STS::magnitudeType MT;
typedef Teuchos::ScalarTraits<MT> STM;
typedef TpetraIntrepidPoissonExample::sparse_matrix_type sparse_matrix_type;
typedef TpetraIntrepidPoissonExample::vector_type vector_type;
typedef TpetraIntrepidPoissonExample::operator_type operator_type;
bool success = true;
try {
Teuchos::oblackholestream blackHole;
Teuchos::GlobalMPISession mpiSession (&argc, &argv, &blackHole);
const int myRank = mpiSession.getRank ();
//const int numProcs = mpiSession.getNProc ();
// Get the default communicator and Kokkos Node instance
RCP<const Comm<int> > comm =
DefaultPlatform::getDefaultPlatform ().getComm ();
RCP<Node> node = DefaultPlatform::getDefaultPlatform ().getNode ();
// Did the user specify --help at the command line to print help
// with command-line arguments?
bool printedHelp = false;
// Values of command-line arguments.
int nx, ny, nz;
std::string xmlInputParamsFile;
bool verbose, debug;
int maxNumItersFromCmdLine = -1; // -1 means "read from XML file"
double tolFromCmdLine = -1.0; // -1 means "read from XML file"
std::string solverName = "GMRES";
ST materialTensorOffDiagonalValue = 0.0;
// Set default values of command-line arguments.
setCommandLineArgumentDefaults (nx, ny, nz, xmlInputParamsFile,
solverName, verbose, debug);
// Parse and validate command-line arguments.
Teuchos::CommandLineProcessor cmdp (false, true);
setUpCommandLineArguments (cmdp, nx, ny, nz, xmlInputParamsFile,
solverName, tolFromCmdLine,
maxNumItersFromCmdLine,
verbose, debug);
cmdp.setOption ("materialTensorOffDiagonalValue",
&materialTensorOffDiagonalValue, "Off-diagonal value in "
"the material tensor. This controls the iteration count. "
"Be careful with this if you use CG, since you can easily "
"make the matrix indefinite.");
// Additional command-line arguments for GPU experimentation.
bool gpu = false;
cmdp.setOption ("gpu", "no-gpu", &gpu,
"Run example using GPU node (if supported)");
int ranks_per_node = 1;
cmdp.setOption ("ranks_per_node", &ranks_per_node,
"Number of MPI ranks per node");
int gpu_ranks_per_node = 1;
cmdp.setOption ("gpu_ranks_per_node", &gpu_ranks_per_node,
"Number of MPI ranks per node for GPUs");
int device_offset = 0;
cmdp.setOption ("device_offset", &device_offset,
"Offset for attaching MPI ranks to CUDA devices");
// Additional command-line arguments for dumping the generated
// matrix or its row Map to output files.
//
// FIXME (mfh 09 Apr 2014) Need to port these command-line
// arguments to the Epetra version.
// If matrixFilename is nonempty, dump the matrix to that file
// in MatrixMarket format.
//.........这里部分代码省略.........
示例5: main
int main(int narg, char *arg[]) {
Teuchos::GlobalMPISession mpiSession(&narg, &arg,0);
Platform &platform = Tpetra::DefaultPlatform::getDefaultPlatform();
RCP<const Teuchos::Comm<int> > CommT = platform.getComm();
int me = CommT->getRank();
int numProcs = CommT->getSize();
/***************************************************************************/
/*************************** GET XML INPUTS ********************************/
/***************************************************************************/
// default values for command-line arguments
std::string xmlMeshInFileName("Poisson.xml");
// Read run-time options.
Teuchos::CommandLineProcessor cmdp (false, false);
cmdp.setOption("xmlfile", &xmlMeshInFileName,
"XML file with PamGen specifications");
cmdp.parse(narg, arg);
// Read xml file into parameter list
ParameterList inputMeshList;
if(xmlMeshInFileName.length()) {
if (me == 0) {
cout << "\nReading parameter list from the XML file \""
<<xmlMeshInFileName<<"\" ...\n\n";
}
Teuchos::updateParametersFromXmlFile(xmlMeshInFileName,
Teuchos::inoutArg(inputMeshList));
if (me == 0) {
inputMeshList.print(cout,2,true,true);
cout << "\n";
}
}
else {
cout << "Cannot read input file: " << xmlMeshInFileName << "\n";
return 5;
}
// Get pamgen mesh definition
std::string meshInput = Teuchos::getParameter<std::string>(inputMeshList,
"meshInput");
/***************************************************************************/
/********************** GET CELL TOPOLOGY **********************************/
/***************************************************************************/
// Get dimensions
int dim = 3;
/***************************************************************************/
/***************************** GENERATE MESH *******************************/
/***************************************************************************/
if (me == 0) cout << "Generating mesh ... \n\n";
// Generate mesh with Pamgen
long long maxInt = 9223372036854775807LL;
Create_Pamgen_Mesh(meshInput.c_str(), dim, me, numProcs, maxInt);
// Creating mesh adapter
if (me == 0) cout << "Creating mesh adapter ... \n\n";
typedef Zoltan2::PamgenMeshAdapter<tMVector_t> inputAdapter_t;
inputAdapter_t ia(*CommT, "region");
inputAdapter_t ia2(*CommT, "vertex");
inputAdapter_t::gno_t const *adjacencyIds=NULL;
inputAdapter_t::lno_t const *offsets=NULL;
ia.print(me);
Zoltan2::MeshEntityType primaryEType = ia.getPrimaryEntityType();
Zoltan2::MeshEntityType adjEType = ia.getAdjacencyEntityType();
int dimension, num_nodes, num_elem;
int error = 0;
char title[100];
int exoid = 0;
int num_elem_blk, num_node_sets, num_side_sets;
error += im_ex_get_init(exoid, title, &dimension, &num_nodes, &num_elem,
&num_elem_blk, &num_node_sets, &num_side_sets);
int *element_num_map = new int [num_elem];
error += im_ex_get_elem_num_map(exoid, element_num_map);
inputAdapter_t::gno_t *node_num_map = new int [num_nodes];
error += im_ex_get_node_num_map(exoid, node_num_map);
int *elem_blk_ids = new int [num_elem_blk];
error += im_ex_get_elem_blk_ids(exoid, elem_blk_ids);
int *num_nodes_per_elem = new int [num_elem_blk];
int *num_attr = new int [num_elem_blk];
int *num_elem_this_blk = new int [num_elem_blk];
char **elem_type = new char * [num_elem_blk];
int **connect = new int * [num_elem_blk];
for(int i = 0; i < num_elem_blk; i++){
//.........这里部分代码省略.........
示例6: mpiSession
int
main (int argc, char *argv[])
{
using namespace TrilinosCouplings; // Yes, this means I'm lazy.
using TpetraIntrepidPoissonExample::exactResidualNorm;
using TpetraIntrepidPoissonExample::makeMatrixAndRightHandSide;
using TpetraIntrepidPoissonExample::solveWithBelos;
using TpetraIntrepidPoissonExample::solveWithBelosGPU;
using IntrepidPoissonExample::makeMeshInput;
using IntrepidPoissonExample::setCommandLineArgumentDefaults;
using IntrepidPoissonExample::setUpCommandLineArguments;
using IntrepidPoissonExample::parseCommandLineArguments;
using Tpetra::DefaultPlatform;
using Teuchos::Comm;
using Teuchos::outArg;
using Teuchos::ParameterList;
using Teuchos::parameterList;
using Teuchos::RCP;
using Teuchos::rcp;
using Teuchos::rcpFromRef;
using Teuchos::getFancyOStream;
using Teuchos::FancyOStream;
using std::endl;
// Pull in typedefs from the example's namespace.
typedef TpetraIntrepidPoissonExample::ST ST;
typedef TpetraIntrepidPoissonExample::LO LO;
typedef TpetraIntrepidPoissonExample::GO GO;
typedef TpetraIntrepidPoissonExample::Node Node;
typedef Teuchos::ScalarTraits<ST> STS;
typedef STS::magnitudeType MT;
typedef Teuchos::ScalarTraits<MT> STM;
typedef TpetraIntrepidPoissonExample::sparse_matrix_type sparse_matrix_type;
typedef TpetraIntrepidPoissonExample::vector_type vector_type;
typedef TpetraIntrepidPoissonExample::operator_type operator_type;
bool success = true;
try {
Teuchos::oblackholestream blackHole;
Teuchos::GlobalMPISession mpiSession (&argc, &argv, &blackHole);
const int myRank = mpiSession.getRank ();
//const int numProcs = mpiSession.getNProc ();
// Get the default communicator and Kokkos Node instance
RCP<const Comm<int> > comm =
DefaultPlatform::getDefaultPlatform ().getComm ();
RCP<Node> node = DefaultPlatform::getDefaultPlatform ().getNode ();
// Did the user specify --help at the command line to print help
// with command-line arguments?
bool printedHelp = false;
// Values of command-line arguments.
int nx, ny, nz;
std::string xmlInputParamsFile;
bool verbose, debug;
// Set default values of command-line arguments.
setCommandLineArgumentDefaults (nx, ny, nz, xmlInputParamsFile,
verbose, debug);
// Parse and validate command-line arguments.
Teuchos::CommandLineProcessor cmdp (false, true);
setUpCommandLineArguments (cmdp, nx, ny, nz, xmlInputParamsFile,
verbose, debug);
bool gpu = false;
cmdp.setOption ("gpu", "no-gpu", &gpu,
"Run example using GPU node (if supported)");
int ranks_per_node = 1;
cmdp.setOption("ranks_per_node", &ranks_per_node,
"Number of MPI ranks per node");
int gpu_ranks_per_node = 1;
cmdp.setOption("gpu_ranks_per_node", &gpu_ranks_per_node,
"Number of MPI ranks per node for GPUs");
int device_offset = 0;
cmdp.setOption("device_offset", &device_offset,
"Offset for attaching MPI ranks to CUDA devices");
parseCommandLineArguments (cmdp, printedHelp, argc, argv, nx, ny, nz,
xmlInputParamsFile, verbose, debug);
if (printedHelp) {
// The user specified --help at the command line to print help
// with command-line arguments. We printed help already, so quit
// with a happy return code.
return EXIT_SUCCESS;
}
// Both streams only print on MPI Rank 0. "out" only prints if the
// user specified --verbose.
RCP<FancyOStream> out =
getFancyOStream (rcpFromRef ((myRank == 0 && verbose) ? std::cout : blackHole));
RCP<FancyOStream> err =
getFancyOStream (rcpFromRef ((myRank == 0 && debug) ? std::cerr : blackHole));
#ifdef HAVE_MPI
*out << "PARALLEL executable" << endl;
#else
*out << "SERIAL executable" << endl;
#endif
/**********************************************************************************/
/********************************** GET XML INPUTS ********************************/
//.........这里部分代码省略.........