From: guido Date: Thu, 9 Nov 2000 17:59:24 +0000 (+0000) Subject: log-output of parameters X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=68485948e83d990feeb1aebe0411085004e875f5;p=dealii-svn.git log-output of parameters git-svn-id: https://svn.dealii.org/trunk@3474 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/base/include/base/parameter_handler.h b/deal.II/base/include/base/parameter_handler.h index 325b505bff..a17c5291fd 100644 --- a/deal.II/base/include/base/parameter_handler.h +++ b/deal.II/base/include/base/parameter_handler.h @@ -26,7 +26,7 @@ class MultipleParameterLoop; class istream; class ostream; - +class LogStream; /** * List of possible output formats. @@ -1098,6 +1098,23 @@ class ParameterHandler const OutputStyle Style, const unsigned int indent_level); + /** + * Print parameters to a logstream. + * This function allows to print + * all parameters into a log-file. + * Sections will be indented in the + * usual log-file style. + */ + void log_parameters (LogStream& out); + + /** + * Log parameters in + * subsection. The subsection is + * determined by the + * @p{subsection_path} member * + * variable. + */ + void log_parameters_section (LogStream& out); /** * Exception diff --git a/deal.II/base/source/parameter_handler.cc b/deal.II/base/source/parameter_handler.cc index b35ecae774..94286d487f 100644 --- a/deal.II/base/source/parameter_handler.cc +++ b/deal.II/base/source/parameter_handler.cc @@ -13,6 +13,7 @@ #include +#include #include #include #include @@ -627,6 +628,17 @@ ostream & ParameterHandler::print_parameters (ostream &out, OutputStyle style) }; +void +ParameterHandler::log_parameters (LogStream &out) +{ + out.push("parameters"); + // dive recursively into the subsections + log_parameters_section (out); + + out.pop(); +}; + + void ParameterHandler::print_parameters_section (ostream &out, const OutputStyle style, @@ -755,6 +767,45 @@ void ParameterHandler::print_parameters_section (ostream &out, +void ParameterHandler::log_parameters_section (LogStream &out) +{ + Section *pd = get_present_defaults_subsection (); + Section *pc = get_present_changed_subsection (); + + // traverse entry list + Section::EntryType::const_iterator ptr; + + // first find out the longest entry name + unsigned int longest_entry = 0; + for (ptr = pd->entries.begin(); ptr != pd->entries.end(); ++ptr) + if (ptr->first.length() > longest_entry) + longest_entry = ptr->first.length(); + + // print entries one by one + for (ptr = pd->entries.begin(); ptr != pd->entries.end(); ++ptr) + { + // check whether this entry is listed + // in the Changed tree and actually + // differs from the default value + out << ptr->first << setw(longest_entry-ptr->first.length()+2) << "= " + << ptr->second.first << endl; + }; + + + // now transverse subsections tree + map::const_iterator ptrss; + for (ptrss = pd->subsections.begin(); ptrss != pd->subsections.end(); ++ptrss) + { + out.push(ptrss->first); + enter_subsection (ptrss->first); + log_parameters_section (out); + leave_subsection (); + out.pop(); + }; +}; + + + bool ParameterHandler::scan_line (string line, const unsigned int lineno) {