--- /dev/null
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"
+ "http://www.w3.org/TR/REC-html40/strict.dtd">
+<html>
+<head>
+<!-- deal.II tutorial template
+ Jan Schrage <schrage@gaia.iwr.uni-heidelberg.de> 1999
+-->
+
+<title>Parameter Input</title>
+ <link href="../dealtut.css" rel="StyleSheet" title="deal.II Tutorial">
+ <meta name="author" content="Jan Schrage <schrage@gaia.iwr.uni-heidelberg.de>">
+ <meta name="keywords" content="deal.II,deal.II tutorial,deal II">
+</head>
+
+<!-- Page Body -->
+<body lang="en">
+
+<h1>Parameter Input</h1>
+
+<p>
+When writing a numerical program you will usually wish to keep it flexible
+with regard to parameter settings and the like. Rewriting a program
+everytime a parameter changes is ever so annoying.
+For this reason <acronym>deal.II</acronym> provides a class
+called <code>ParameterHandler</code>. This class enables you to easily
+parse a parameter file and extract the values of the parameters.
+The names and allowed values of the parameters can be defined by you.
+</p>
+
+<p class=example>
+<span class=example>Example:</span>
+We enable a program, that is, the class TestCases that really handles
+everything to read parameters from a file given on the command line.
+Everything that is not strictly relevant to parameter input has been cut out.
+</p>
+
+<pre class=example>
+<code>
+#include <base/parameter_handler.h>
+
+
+#include <fstream>
+#include <cmath>
+#include <cstdlib>
+
+
+
+template <int dim>
+class TestCases : public MultipleParameterLoop::UserClass{
+ public:
+ TestCases ();
+
+ virtual void declare_parameters (ParameterHandler &prm);
+ virtual void run (ParameterHandler &prm);
+
+};
+
+
+
+template <int dim>
+TestCases<dim>::TestCases () :
+ {};
+
+
+
+template <int dim>
+void TestCases<dim>::declare_parameters (ParameterHandler &prm) {
+ if (dim>=2)
+ prm.declare_entry ("Test run", "zoom in",
+ Patterns::Sequence("zoom in|ball|curved line|random"));
+ else
+ prm.declare_entry ("Test run", "zoom in",
+ Patterns::Sequence("zoom in|random"));
+ prm.declare_entry ("Grid file", "grid.1");
+ prm.declare_entry ("Sparsity file", "sparsity.1");
+ prm.declare_entry ("Condensed sparsity file", "sparsity.c.1");
+};
+
+
+
+template <int dim>
+void TestCases<dim>::run (ParameterHandler &prm) {
+ cout << "Test case = " << prm.get ("Test run") << endl
+ << endl;
+
+ cout << " Making grid..." << endl;
+
+ string test = prm.get ("Test run");
+ unsigned int test_case;
+ if (test=="zoom in") test_case = 1;
+ else
+ if (test=="ball") test_case = 2;
+ else
+ if (test=="curved line") test_case = 3;
+ else
+ if (test=="random") test_case = 4;
+ else
+ cerr << "This test seems not to be implemented!" << endl;
+
+
+ switch (test_case)
+ {
+ case 1: // code for case 1: zoom in
+ case 2: // code for case 2: ball
+ case 3: // code for case 3: curved line
+ case 4: // code for case 4: random
+ };
+
+ cout << " Writing grid..." << endl;
+ ofstream out(prm.get("Grid file").c_str());
+ // code for output
+
+};
+
+
+
+int main (int argc, char **argv) {
+ if (argc!=2)
+ {
+ cout << "Usage: grid_test parameterfile" << endl << endl;
+ return 1;
+ };
+
+ TestCases<2> tests;
+ class MultipleParameterLoop input_data; //needs at least gcc2.8
+
+ tests.declare_parameters(input_data);
+ input_data.read_input (argv[1]);
+ input_data.loop (tests);
+
+ return 0;
+};
+</code>
+</pre>
+
+<!-- Page Foot -->
+<hr>
+<table class="navbar">
+<tr>
+<!-- This is the last chapter.
+ <td>
+ <a href="URLS_NEEDS_TO_BE_SET">Next Chapter: </a>
+ </td>
+-->
+ <td>
+ <a href="toc.html">Back to this chapter's index</a>
+ </td>
+ <td>
+ <a href="../index.html" target="_top">Back to the tutorial index</a>
+ </td>
+</tr>
+</table>
+<hr>
+<address>
+<a href="mailto:schrage@gaia.iwr.uni-heidelberg.de">Jan Schrage</a></address>
+<p>
+Last modified: $Date$
+</p>
+</body>
+</html>