|
Reference documentation for deal.II version 9.2.0
|
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\)
\(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\)
\(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\)
\(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Go to the documentation of this file.
16 #ifndef dealii_parameter_handler_h
17 #define dealii_parameter_handler_h
26 #include <boost/archive/basic_archive.hpp>
27 #include <boost/property_tree/ptree_fwd.hpp>
28 #include <boost/property_tree/ptree_serialization.hpp>
29 #include <boost/serialization/split_member.hpp>
1018 const std::string &filename =
"input file",
1019 const std::string &last_line =
"",
1020 const bool skip_undefined =
false);
1045 const std::string &last_line =
"",
1046 const bool skip_undefined =
false,
1047 const bool assert_mandatory_entries_are_found =
false);
1059 const std::string &last_line =
"",
1060 const bool skip_undefined =
false);
1116 const std::string & default_value,
1118 const std::string & documentation =
"",
1119 const bool has_to_be_set =
false);
1166 const std::function<
void(
const std::string &
value)> &action);
1183 template <
class ParameterType>
1186 ParameterType & parameter,
1187 const std::string & documentation =
"",
1190 const bool has_to_be_set =
false);
1237 const std::string &alias_name,
1238 const bool alias_is_deprecated =
false);
1266 get(
const std::string &entry_string)
const;
1279 get(
const std::vector<std::string> &entry_subsection_path,
1280 const std::string & entry_string)
const;
1288 get_integer(
const std::string &entry_string)
const;
1299 get_integer(
const std::vector<std::string> &entry_subsection_path,
1300 const std::string & entry_string)
const;
1306 get_double(
const std::string &entry_name)
const;
1315 get_double(
const std::vector<std::string> &entry_subsection_path,
1316 const std::string & entry_string)
const;
1323 get_bool(
const std::string &entry_name)
const;
1334 get_bool(
const std::vector<std::string> &entry_subsection_path,
1335 const std::string & entry_string)
const;
1347 set(
const std::string &entry_name,
const std::string &new_value);
1360 set(
const std::string &entry_name,
const char *new_value);
1372 set(
const std::string &entry_name,
const long int new_value);
1388 set(
const std::string &entry_name,
const double new_value);
1400 set(
const std::string &entry_name,
const bool new_value);
1553 template <
class Archive>
1555 save(Archive &ar,
const unsigned int version)
const;
1561 template <
class Archive>
1563 load(Archive &ar,
const unsigned int version);
1570 template <
class Archive>
1572 serialize(Archive &archive,
const unsigned int version);
1576 BOOST_SERIALIZATION_SPLIT_MEMBER()
1593 std::set<std::string>
1614 <<
"The following entry already exists: " << arg1 <<
".");
1621 <<
"The string <" << arg1
1622 <<
"> does not match the given pattern <" << arg2 <<
">.");
1628 "You can't leave a subsection if you are already at the top level "
1629 "of the subsection hierarchy.");
1635 <<
"You can't ask for entry <" << arg1
1636 <<
"> you have not yet declared.");
1647 <<
"There are unequal numbers of 'subsection' and 'end' "
1648 "statements in the parameter file <"
1649 << arg1 <<
">." << (arg2.size() > 0 ?
"\n" + arg2 :
""));
1659 <<
"Line <" << arg1 <<
"> of file <" << arg2
1661 "no such subsection to be entered: "
1673 <<
"Line <" << arg1 <<
"> of file <" << arg2 <<
">: " << arg3);
1686 <<
"Line <" << arg1 <<
"> of file <" << arg2
1688 " The entry value \n"
1689 <<
" " << arg3 <<
'\n'
1690 <<
" for the entry named\n"
1691 <<
" " << arg4 <<
'\n'
1692 <<
" does not match the given pattern:\n"
1701 "The provided file could not be parsed as a "
1702 "ParameterHandler description.");
1725 <<
"Line <" << arg1 <<
"> of file <" << arg2
1727 "contains an 'include' or 'INCLUDE' statement, but the given "
1729 << arg3 <<
"> cannot be opened.");
1753 std::unique_ptr<boost::property_tree::ptree>
entries;
1770 std::vector<std::unique_ptr<const Patterns::PatternBase>>
patterns;
1778 std::vector<std::function<void(
const std::string &)>>
actions;
1804 const std::string & name)
const;
1826 const std::string &input_filename,
1827 const unsigned int current_line_n,
1828 const bool skip_undefined);
1843 const boost::property_tree::ptree & tree,
1844 const std::vector<std::string> & target_subsection_path,
1846 const unsigned int indent_level,
1847 std::ostream & out)
const;
1864 static_cast<unsigned int>(f1) |
static_cast<unsigned int>(f2));
2147 const std::string &filename =
"input file",
2148 const std::string &last_line =
"",
2149 const bool skip_undefined =
false)
override;
2209 Entry(
const std::vector<std::string> &Path,
2210 const std::string & Name,
2211 const std::string & Value);
2288 template <
class Archive>
2298 std::vector<std::string> descriptions;
2300 for (
const auto &pattern :
patterns)
2301 descriptions.push_back(pattern->description());
2307 template <
class Archive>
2317 std::vector<std::string> descriptions;
2321 for (
const auto &description : descriptions)
2326 template <
class ParameterType>
2329 ParameterType & parameter,
2330 const std::string & documentation,
2332 const bool has_to_be_set)
2335 "You tried to add a parameter using a type "
2336 "that is const. Use a non-const type.");
2340 parameter, pattern.
clone()),
2346 const unsigned int pattern_index =
2349 auto action = [&, pattern_index](
const std::string &val) {
2351 val,
patterns[pattern_index]->clone());
virtual std::unique_ptr< PatternBase > clone() const =0
#define DeclExceptionMsg(Exception, defaulttext)
std::string get(const std::string &entry_string) const
static const char path_separator
void serialize(Archive &archive, const unsigned int version)
static ::ExceptionBase & ExcUnbalancedSubsections(std::string arg1, std::string arg2)
double get_double(const std::string &entry_name) const
static ::ExceptionBase & ExcCannotOpenIncludeStatementFile(int arg1, std::string arg2, std::string arg3)
std::string get_current_path() const
ParameterHandler::OutputStyle operator|(const ParameterHandler::OutputStyle f1, const ParameterHandler::OutputStyle f2)
std::string get_current_full_path(const std::string &name) const
void scan_line(std::string line, const std::string &input_filename, const unsigned int current_line_n, const bool skip_undefined)
virtual ~UserClass()=default
virtual void parse_input_from_xml(std::istream &input, const bool skip_undefined=false)
bool get_bool(const std::string &entry_name) const
std::set< std::string > get_entries_wrongly_not_set() const
static ::ExceptionBase & ExcEntryAlreadyExists(std::string arg1)
void declare_entry(const std::string &entry, const std::string &default_value, const Patterns::PatternBase &pattern=Patterns::Anything(), const std::string &documentation="", const bool has_to_be_set=false)
static ::ExceptionBase & ExcValueDoesNotMatchPattern(std::string arg1, std::string arg2)
void split_different_values()
static ::ExceptionBase & ExcInvalidEntryForPattern(int arg1, std::string arg2, std::string arg3, std::string arg4, std::string arg5)
std::unique_ptr< PatternBase > pattern_factory(const std::string &description)
void log_parameters_section(LogStream &out, const OutputStyle style=DefaultStyle)
void save(Archive &ar, const unsigned int version) const
static ::ExceptionBase & ExcInvalidXMLParameterFile()
std::size_t memory_consumption() const
virtual void create_new(const unsigned int run_no)=0
void recursively_print_parameters(const boost::property_tree::ptree &tree, const std::vector< std::string > &target_subsection_path, const ParameterHandler::OutputStyle style, const unsigned int indent_level, std::ostream &out) const
std::vector< std::string > subsection_path
std::map< std::string, std::pair< bool, bool > > entries_set_status
static ::ExceptionBase & ExcAlreadyAtTopLevel()
virtual ~ParameterHandler() override=default
#define DeclException5( Exception5, type1, type2, type3, type4, type5, outsequence)
void assert_that_entries_have_been_set() const
virtual void parse_input(std::istream &input, const std::string &filename="input file", const std::string &last_line="", const bool skip_undefined=false) override
long int get_integer(const std::string &entry_string) const
bool operator==(const ParameterHandler &prm2) const
#define DEAL_II_NAMESPACE_OPEN
void log_parameters(LogStream &out, const OutputStyle style=DefaultStyle)
std::size_t memory_consumption() const
virtual void run(ParameterHandler &prm)=0
#define DeclException3(Exception3, type1, type2, type3, outsequence)
std::vector< std::string > subsection_path
std::ostream & print_parameters(std::ostream &out, const OutputStyle style) const
#define DEAL_II_DEPRECATED
#define DeclException1(Exception1, type1, outsequence)
void add_action(const std::string &entry, const std::function< void(const std::string &value)> &action)
void load(Archive &ar, const unsigned int version)
void fill_entry_values(const unsigned int run_no)
virtual ~MultipleParameterLoop() override=default
static T to_value(const std::string &s, const std::unique_ptr< Patterns::PatternBase > &p=Convert< T >::to_pattern())=delete
static ::ExceptionBase & ExcEntryUndeclared(std::string arg1)
std::size_t memory_consumption() const
ParameterHandler & operator=(const ParameterHandler &)=delete
ExcValueDoesNotMatchPattern ExcInvalidEntryForPatternXML
std::vector< Entry > multiple_choices
static ::ExceptionBase & ExcCannotParseLine(int arg1, std::string arg2, std::string arg3)
virtual void parse_input_from_string(const std::string &s, const std::string &last_line="", const bool skip_undefined=false)
void declare_alias(const std::string &existing_entry_name, const std::string &alias_name, const bool alias_is_deprecated=false)
std::vector< std::unique_ptr< const Patterns::PatternBase > > patterns
void add_parameter(const std::string &entry, ParameterType ¶meter, const std::string &documentation="", const Patterns::PatternBase &pattern= *Patterns::Tools::Convert< ParameterType >::to_pattern(), const bool has_to_be_set=false)
void enter_subsection(const std::string &subsection)
virtual void parse_input_from_json(std::istream &input, const bool skip_undefined=false)
void init_branches_current_section()
void set(const std::string &entry_name, const std::string &new_value)
#define DEAL_II_NAMESPACE_CLOSE
static ::ExceptionBase & ExcNoSubsection(int arg1, std::string arg2, std::string arg3)
std::vector< std::string > different_values
bool subsection_path_exists(const std::vector< std::string > &sub_path) const
#define DeclException2(Exception2, type1, type2, outsequence)
virtual void parse_input(std::istream &input, const std::string &filename="input file", const std::string &last_line="", const bool skip_undefined=false)
std::unique_ptr< boost::property_tree::ptree > entries
std::vector< std::function< void(const std::string &)> > actions