]> https://gitweb.dealii.org/ - code-gallery.git/commitdiff
Tabulate the exact measurement values, rather than compute them on the fly.
authorWolfgang Bangerth <bangerth@colostate.edu>
Thu, 28 Mar 2019 15:20:03 +0000 (09:20 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Thu, 28 Mar 2019 15:48:29 +0000 (09:48 -0600)
MCMC-Laplace/mcmc-laplace.cc

index a50ca6a98ff6f08e3cc506ce58f26ae587978eb9..813f048cd39ac14da1d09999f270ca5850a874a3 100644 (file)
@@ -661,7 +661,32 @@ namespace Sampler
 
 
 // The final function is `main()`, which simply puts all of these pieces
-// together into one:
+// together into one. The "exact solution", i.e., the "measurement values"
+// we use for this program are tabulated to make it easier for other
+// people to use in their own implementations of this benchmark. These
+// values created using the same main class above, but using 8 mesh
+// refinements and using a Q3 element -- i.e., using a much more accurate
+// method than the one we use in the forward simulator for generating
+// samples below (which uses 5 global mesh refinement steps and a Q1
+// element). If you wanted to regenerate this set of numbers, then
+// the following code snippet would do that:
+// @code
+//  /* Set the exact coefficient: */
+//  Vector<double> exact_coefficients(64);
+//  for (auto &el : exact_coefficients)
+//    el = 1.;
+//  exact_coefficients(9) = exact_coefficients(10) = exact_coefficients(17) =
+//    exact_coefficients(18)                       = 0.1;
+//  exact_coefficients(45) = exact_coefficients(46) = exact_coefficients(53) =
+//    exact_coefficients(54)                        = 10.;
+//
+//  /* Compute the "correct" solution vector: */
+//  const Vector<double> exact_solution =
+//    ForwardSimulator::PoissonSolver<2>(/* global_refinements = */ 8,
+//                                       /* fe_degree = */ 3,
+//                                       /* prefix = */ "exact")
+//      .evaluate(exact_coefficients);
+// @endcode
 int main()
 {
   const bool testing = true;
@@ -675,23 +700,92 @@ int main()
   const unsigned int random_seed  = (testing ? 1U : std::random_device()());
   const std::string  dataset_name = std::to_string(random_seed);
 
-  // Set the exact coefficient:
-  Vector<double> exact_coefficients(64);
-  for (auto &el : exact_coefficients)
-    el = 1.;
-  exact_coefficients(9) = exact_coefficients(10) = exact_coefficients(17) =
-    exact_coefficients(18)                       = 0.1;
-  exact_coefficients(45) = exact_coefficients(46) = exact_coefficients(53) =
-    exact_coefficients(54)                        = 10.;
-
-  // Compute the "correct" solution vector:
-  const Vector<double> exact_solution =
-    ForwardSimulator::PoissonSolver<2>(/* global_refinements = */ (testing ? 6 :
-                                                                             8),
-                                       /* fe_degree = */ 2,
-                                       /* prefix = */ "exact")
-      .evaluate(exact_coefficients);
-
+  const Vector<double> exact_solution(
+    {   0.06076511762259369, 0.09601910120848481, 
+        0.1238852517838584,  0.1495184117375201, 
+        0.1841596127549784,  0.2174525028261122, 
+        0.2250996160898698,  0.2197954769002993, 
+        0.2074695698370926,  0.1889996477663016, 
+        0.1632722532153726,  0.1276782480038186, 
+        0.07711845915789312, 0.09601910120848552, 
+        0.2000589533367983,  0.3385592591951766, 
+        0.3934300024647806,  0.4040223892461541, 
+        0.4122329537843092,  0.4100480091545554, 
+        0.3949151637189968,  0.3697873264791232, 
+        0.33401826235924,    0.2850397806663382, 
+        0.2184260032478671,  0.1271121156350957, 
+        0.1238852517838611,  0.3385592591951819, 
+        0.7119285162766475,  0.8175712861756428, 
+        0.6836254116578105,  0.5779452419831157, 
+        0.5555615956136897,  0.5285181561736719, 
+        0.491439702849224,   0.4409367494853282, 
+        0.3730060082060772,  0.2821694983395214, 
+        0.1610176733857739,  0.1495184117375257, 
+        0.3934300024647929,  0.8175712861756562, 
+        0.9439154625527653,  0.8015904115095128, 
+        0.6859683749254024,  0.6561235366960599, 
+        0.6213197201867315,  0.5753611315000049, 
+        0.5140091754526823,  0.4325325506354165, 
+        0.3248315148915482,  0.1834600412730086, 
+        0.1841596127549917,  0.4040223892461832, 
+        0.6836254116578439,  0.8015904115095396, 
+        0.7870119561144977,  0.7373108331395808, 
+        0.7116558878070463,  0.6745179049094283, 
+        0.6235300574156917,  0.5559332704045935, 
+        0.4670304994474178,  0.3499809143811, 
+        0.19688263746294,    0.2174525028261253, 
+        0.4122329537843404,  0.5779452419831566, 
+        0.6859683749254372,  0.7373108331396063, 
+        0.7458811983178246,  0.7278968022406559, 
+        0.6904793535357751,  0.6369176452710288, 
+        0.5677443693743215,  0.4784738764865867, 
+        0.3602190632823262,  0.2031792054737325, 
+        0.2250996160898818,  0.4100480091545787, 
+        0.5555615956137137,  0.6561235366960938, 
+        0.7116558878070715,  0.727896802240657, 
+        0.7121928678670187,  0.6712187391428729, 
+        0.6139157775591492,  0.5478251665295381, 
+        0.4677122687599031,  0.3587654911000848, 
+        0.2050734291675918,  0.2197954769003094, 
+        0.3949151637190157,  0.5285181561736911, 
+        0.6213197201867471,  0.6745179049094407, 
+        0.690479353535786,   0.6712187391428787, 
+        0.6178408289359514,  0.5453605027237883, 
+        0.489575966490909,   0.4341716881061278, 
+        0.3534389974779456,  0.2083227496961347, 
+        0.207469569837099,   0.3697873264791366, 
+        0.4914397028492412,  0.5753611315000203, 
+        0.6235300574157017,  0.6369176452710497, 
+        0.6139157775591579,  0.5453605027237935, 
+        0.4336604929612851,  0.4109641743019312, 
+        0.3881864790111245,  0.3642640090182592, 
+        0.2179599909280145,  0.1889996477663011, 
+        0.3340182623592461,  0.4409367494853381, 
+        0.5140091754526943,  0.5559332704045969, 
+        0.5677443693743304,  0.5478251665295453, 
+        0.4895759664908982,  0.4109641743019171, 
+        0.395727260284338,   0.3778949322004734, 
+        0.3596268271857124,  0.2191250268948948, 
+        0.1632722532153683,  0.2850397806663325, 
+        0.373006008206081,   0.4325325506354207, 
+        0.4670304994474315,  0.4784738764866023, 
+        0.4677122687599041,  0.4341716881061055, 
+        0.388186479011099,   0.3778949322004602, 
+        0.3633362567187364,  0.3464457261905399, 
+        0.2096362321365655,  0.1276782480038148, 
+        0.2184260032478634,  0.2821694983395252, 
+        0.3248315148915535,  0.3499809143811097, 
+        0.3602190632823333,  0.3587654911000799, 
+        0.3534389974779268,  0.3642640090182283, 
+        0.35962682718569,    0.3464457261905295, 
+        0.3260728953424643,  0.180670595355394, 
+        0.07711845915789244, 0.1271121156350963, 
+        0.1610176733857757,  0.1834600412730144, 
+        0.1968826374629443,  0.2031792054737354, 
+        0.2050734291675885,  0.2083227496961245, 
+        0.2179599909279998,  0.2191250268948822, 
+        0.2096362321365551,  0.1806705953553887, 
+        0.1067965550010013                         });
 
   // Now run the forward simulator for samples:
   ForwardSimulator::PoissonSolver<2> laplace_problem(

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.