4#include <Teuchos_ParameterList.hpp>
5#include <Teuchos_XMLParameterListCoreHelpers.hpp>
6#include <Teuchos_YamlParameterListCoreHelpers.hpp>
17 Teuchos::RCP<Teuchos::ParameterList> parseParameterList(
const std::string &fileName,
18 const std::string &type =
"yaml")
20 Teuchos::RCP<Teuchos::ParameterList> parameterList;
22 if (!type.compare(
"yaml"))
24 parameterList = Teuchos::getParametersFromYamlFile(fileName);
26 else if (!type.compare(
"xml"))
28 parameterList = Teuchos::getParametersFromXmlFile(fileName);
32 TEUCHOS_TEST_FOR_EXCEPTION(
true,std::logic_error,
"File type not supported.");
46 Teuchos::RCP<Teuchos::ParameterList> parseParameterListFiles(Teuchos::RCP<Teuchos::ParameterList> ¶meterList,
47 const std::string &nameName =
"ParameterLists File Names",
48 const std::string &pathName =
"ParameterLists File Paths",
49 const std::string &typeName =
"ParameterLists File Types")
51 Teuchos::Array<std::string> names(1,
""), filePaths(1,
""), fileTypes(1,
"");
52 if (parameterList->isParameter(pathName))
54 filePaths = parameterList->get(pathName,filePaths);
56 if (parameterList->isParameter(nameName))
58 names = parameterList->get(nameName,names);
59 TEUCHOS_TEST_FOR_EXCEPTION(names.size()!=filePaths.size(),std::logic_error,
"names.size()!=filePaths.size()");
61 TEUCHOS_TEST_FOR_EXCEPTION(
true,std::logic_error,
"ParameterLists File Names are not specified.");
64 if (parameterList->isParameter(typeName))
66 fileTypes = parameterList->get(typeName,fileTypes);
67 TEUCHOS_TEST_FOR_EXCEPTION(fileTypes.size()!=filePaths.size(),std::logic_error,
"fileTypes.size()!=filePaths.size()");
69 TEUCHOS_TEST_FOR_EXCEPTION(
true,std::logic_error,
"ParameterLists File Types are not specified.");
73 for (
auto it = filePaths.begin(); it != filePaths.end(); it++, i++)
75 Teuchos::RCP<Teuchos::ParameterList> parameterListTmp = parseParameterList(filePaths[i],fileTypes[i]);
76 parameterList->set(names[i],*parameterListTmp);
Adaptive Mesh Refinement.
Definition AdaptiveMeshRefinement_decl.hpp:36