]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Example update.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Mon, 6 Apr 1998 17:33:00 +0000 (17:33 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Mon, 6 Apr 1998 17:33:00 +0000 (17:33 +0000)
git-svn-id: https://svn.dealii.org/trunk@150 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/Attic/examples/poisson/problem.cc
tests/big-tests/poisson/problem.cc

index b33cf6f708df50b3c6e9b16e9dc2409528f7e72c..917884bae588e38dc12f6d13ef9f13e5488a8feb 100644 (file)
@@ -161,7 +161,7 @@ double RHSPoly<dim>::operator () (const Point<dim> &p) const {
 
 template <int dim>
 double Solution<dim>::operator () (const Point<dim> &p) const {
-  double ret_val = 0;
+  double ret_val = 1;
   for (unsigned int i=0; i<dim; ++i)
     ret_val *= p(i)*(1.-p(i));
   return ret_val;
@@ -467,22 +467,27 @@ void PoissonProblem<dim>::run (ParameterHandler &prm) {
   cout << "    Writing to file <" << prm.get("Output file") << ">..."
        << endl;
   
-  DataOut<dim> out;
-  String o_filename = prm.get ("Output file");
-  ofstream gnuplot(o_filename);
-  fill_data (out); 
-  out.write_gnuplot (gnuplot);
-  gnuplot.close ();
-
   cout << "    Calculation L2 error... ";
   Solution<dim> sol;
   vector<double> difference;
   QGauss3<dim> q;
   integrate_difference (sol, difference, q, fe, L2_norm);
-  double error = 0;
+  double error = 0.;
   for (unsigned int i=0; i<difference.size(); ++i)
     error += difference[i]*difference[i];
-  cout << sqrt(error) << endl;
+  cout << sqrt(error) << " on " << difference.size() << " cells." << endl;
+
+  dVector error_per_dof;
+  dof->distribute_cell_to_dof_vector (difference, error_per_dof);
+
+  DataOut<dim> out;
+  String o_filename = prm.get ("Output file");
+  ofstream gnuplot(o_filename);
+  fill_data (out);
+  out.add_data_vector (error_per_dof, "Error");
+  out.write_gnuplot (gnuplot);
+  gnuplot.close ();
+
 
   cout << endl;
 };
index b33cf6f708df50b3c6e9b16e9dc2409528f7e72c..917884bae588e38dc12f6d13ef9f13e5488a8feb 100644 (file)
@@ -161,7 +161,7 @@ double RHSPoly<dim>::operator () (const Point<dim> &p) const {
 
 template <int dim>
 double Solution<dim>::operator () (const Point<dim> &p) const {
-  double ret_val = 0;
+  double ret_val = 1;
   for (unsigned int i=0; i<dim; ++i)
     ret_val *= p(i)*(1.-p(i));
   return ret_val;
@@ -467,22 +467,27 @@ void PoissonProblem<dim>::run (ParameterHandler &prm) {
   cout << "    Writing to file <" << prm.get("Output file") << ">..."
        << endl;
   
-  DataOut<dim> out;
-  String o_filename = prm.get ("Output file");
-  ofstream gnuplot(o_filename);
-  fill_data (out); 
-  out.write_gnuplot (gnuplot);
-  gnuplot.close ();
-
   cout << "    Calculation L2 error... ";
   Solution<dim> sol;
   vector<double> difference;
   QGauss3<dim> q;
   integrate_difference (sol, difference, q, fe, L2_norm);
-  double error = 0;
+  double error = 0.;
   for (unsigned int i=0; i<difference.size(); ++i)
     error += difference[i]*difference[i];
-  cout << sqrt(error) << endl;
+  cout << sqrt(error) << " on " << difference.size() << " cells." << endl;
+
+  dVector error_per_dof;
+  dof->distribute_cell_to_dof_vector (difference, error_per_dof);
+
+  DataOut<dim> out;
+  String o_filename = prm.get ("Output file");
+  ofstream gnuplot(o_filename);
+  fill_data (out);
+  out.add_data_vector (error_per_dof, "Error");
+  out.write_gnuplot (gnuplot);
+  gnuplot.close ();
+
 
   cout << endl;
 };

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.