verify.c.svn-base 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  1. //---------------------------------------------------------------------
  2. //
  3. // Copyright 2010 Intel Corporation
  4. //
  5. // Licensed under the Apache License, Version 2.0 (the "License");
  6. // you may not use this file except in compliance with the License.
  7. // You may obtain a copy of the License at
  8. //
  9. // http://www.apache.org/licenses/LICENSE-2.0
  10. //
  11. // Unless required by applicable law or agreed to in writing, software
  12. // distributed under the License is distributed on an "AS IS" BASIS,
  13. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. // See the License for the specific language governing permissions and
  15. // limitations under the License.
  16. //
  17. //---------------------------------------------------------------------
  18. #include <stdio.h>
  19. #include "header.h"
  20. #include "mpinpb.h"
  21. #define FABS(x) ((x)>0 ? (x) : -(x))
  22. void verify(int no_time_steps, char *class_r, int *verified_r) {
  23. //---------------------------------------------------------------------
  24. //---------------------------------------------------------------------
  25. //---------------------------------------------------------------------
  26. // verification routine
  27. //---------------------------------------------------------------------
  28. double xcrref[5],xceref[5],xcrdif[5],xcedif[5],
  29. epsilon, xce[5], xcr[5], dtref;
  30. int m;
  31. char class;
  32. int verified;
  33. #define xcrref(m) xcrref[m-1]
  34. #define xceref(m) xceref[m-1]
  35. #define xcrdif(m) xcrdif[m-1]
  36. #define xcedif(m) xcedif[m-1]
  37. #define xce(m) xce[m-1]
  38. #define xcr(m) xcr[m-1]
  39. //---------------------------------------------------------------------
  40. // tolerance level
  41. //---------------------------------------------------------------------
  42. epsilon = 1.0e-08;
  43. verified = 1;
  44. //---------------------------------------------------------------------
  45. // compute the error norm and the residual norm, and exit if not printing
  46. //---------------------------------------------------------------------
  47. error_norm(xce);
  48. copy_faces();
  49. rhs_norm(xcr);
  50. for (m = 1; m <= 5; m++) {
  51. xcr(m) = xcr(m) / dt;
  52. }
  53. if (node != root) return;
  54. class = 'U';
  55. for (m = 1; m <= 5; m++) {
  56. xcrref(m) = 1.0;
  57. xceref(m) = 1.0;
  58. }
  59. //---------------------------------------------------------------------
  60. // reference data for 12X12X12 grids after 60 time steps, with DT = 1.0e-02
  61. //---------------------------------------------------------------------
  62. if ( (grid_points(1) == 12 ) &&
  63. (grid_points(2) == 12 ) &&
  64. (grid_points(3) == 12 ) &&
  65. (no_time_steps == 60 )) {
  66. class = 'S';
  67. dtref = 1.0e-2;
  68. //---------------------------------------------------------------------
  69. // Reference values of RMS-norms of residual.
  70. //---------------------------------------------------------------------
  71. xcrref(1) = 1.7034283709541311e-01;
  72. xcrref(2) = 1.2975252070034097e-02;
  73. xcrref(3) = 3.2527926989486055e-02;
  74. xcrref(4) = 2.6436421275166801e-02;
  75. xcrref(5) = 1.9211784131744430e-01;
  76. //---------------------------------------------------------------------
  77. // Reference values of RMS-norms of solution error.
  78. //---------------------------------------------------------------------
  79. xceref(1) = 4.9976913345811579e-04;
  80. xceref(2) = 4.5195666782961927e-05;
  81. xceref(3) = 7.3973765172921357e-05;
  82. xceref(4) = 7.3821238632439731e-05;
  83. xceref(5) = 8.9269630987491446e-04;
  84. //---------------------------------------------------------------------
  85. // reference data for 24X24X24 grids after 200 time steps, with DT = 0.8e-3
  86. //---------------------------------------------------------------------
  87. } else if ( (grid_points(1) == 24) &&
  88. (grid_points(2) == 24) &&
  89. (grid_points(3) == 24) &&
  90. (no_time_steps == 200) ) {
  91. class = 'W';
  92. dtref = 0.8e-3;
  93. //---------------------------------------------------------------------
  94. // Reference values of RMS-norms of residual.
  95. //---------------------------------------------------------------------
  96. xcrref(1) = 0.1125590409344e+03;
  97. xcrref(2) = 0.1180007595731e+02;
  98. xcrref(3) = 0.2710329767846e+02;
  99. xcrref(4) = 0.2469174937669e+02;
  100. xcrref(5) = 0.2638427874317e+03;
  101. //---------------------------------------------------------------------
  102. // Reference values of RMS-norms of solution error.
  103. //---------------------------------------------------------------------
  104. xceref(1) = 0.4419655736008e+01;
  105. xceref(2) = 0.4638531260002e+00;
  106. xceref(3) = 0.1011551749967e+01;
  107. xceref(4) = 0.9235878729944e+00;
  108. xceref(5) = 0.1018045837718e+02;
  109. //---------------------------------------------------------------------
  110. // reference data for 64X64X64 grids after 200 time steps, with DT = 0.8e-3
  111. //---------------------------------------------------------------------
  112. } else if ( (grid_points(1) == 64) &&
  113. (grid_points(2) == 64) &&
  114. (grid_points(3) == 64) &&
  115. (no_time_steps == 200) ) {
  116. class = 'A';
  117. dtref = 0.8e-3;
  118. //---------------------------------------------------------------------
  119. // Reference values of RMS-norms of residual.
  120. //---------------------------------------------------------------------
  121. xcrref(1) = 1.0806346714637264e+02;
  122. xcrref(2) = 1.1319730901220813e+01;
  123. xcrref(3) = 2.5974354511582465e+01;
  124. xcrref(4) = 2.3665622544678910e+01;
  125. xcrref(5) = 2.5278963211748344e+02;
  126. //---------------------------------------------------------------------
  127. // Reference values of RMS-norms of solution error.
  128. //---------------------------------------------------------------------
  129. xceref(1) = 4.2348416040525025e+00;
  130. xceref(2) = 4.4390282496995698e-01;
  131. xceref(3) = 9.6692480136345650e-01;
  132. xceref(4) = 8.8302063039765474e-01;
  133. xceref(5) = 9.7379901770829278e+00;
  134. //---------------------------------------------------------------------
  135. // reference data for 102X102X102 grids after 200 time steps,
  136. // with DT = 3.0e-04
  137. //---------------------------------------------------------------------
  138. } else if ( (grid_points(1) == 102) &&
  139. (grid_points(2) == 102) &&
  140. (grid_points(3) == 102) &&
  141. (no_time_steps == 200) ) {
  142. class = 'B';
  143. dtref = 3.0e-4;
  144. //---------------------------------------------------------------------
  145. // Reference values of RMS-norms of residual.
  146. //---------------------------------------------------------------------
  147. xcrref(1) = 1.4233597229287254e+03;
  148. xcrref(2) = 9.9330522590150238e+01;
  149. xcrref(3) = 3.5646025644535285e+02;
  150. xcrref(4) = 3.2485447959084092e+02;
  151. xcrref(5) = 3.2707541254659363e+03;
  152. //---------------------------------------------------------------------
  153. // Reference values of RMS-norms of solution error.
  154. //---------------------------------------------------------------------
  155. xceref(1) = 5.2969847140936856e+01;
  156. xceref(2) = 4.4632896115670668e+00;
  157. xceref(3) = 1.3122573342210174e+01;
  158. xceref(4) = 1.2006925323559144e+01;
  159. xceref(5) = 1.2459576151035986e+02;
  160. //---------------------------------------------------------------------
  161. // reference data for 162X162X162 grids after 200 time steps,
  162. // with DT = 1.0e-04
  163. //---------------------------------------------------------------------
  164. } else if ( (grid_points(1) == 162) &&
  165. (grid_points(2) == 162) &&
  166. (grid_points(3) == 162) &&
  167. (no_time_steps == 200) ) {
  168. class = 'C';
  169. dtref = 1.0e-4;
  170. //---------------------------------------------------------------------
  171. // Reference values of RMS-norms of residual.
  172. //---------------------------------------------------------------------
  173. xcrref(1) = 0.62398116551764615e+04;
  174. xcrref(2) = 0.50793239190423964e+03;
  175. xcrref(3) = 0.15423530093013596e+04;
  176. xcrref(4) = 0.13302387929291190e+04;
  177. xcrref(5) = 0.11604087428436455e+05;
  178. //---------------------------------------------------------------------
  179. // Reference values of RMS-norms of solution error.
  180. //---------------------------------------------------------------------
  181. xceref(1) = 0.16462008369091265e+03;
  182. xceref(2) = 0.11497107903824313e+02;
  183. xceref(3) = 0.41207446207461508e+02;
  184. xceref(4) = 0.37087651059694167e+02;
  185. xceref(5) = 0.36211053051841265e+03;
  186. //---------------------------------------------------------------------
  187. // reference data for 408x408x408 grids after 250 time steps,
  188. // with DT = 0.2e-04
  189. //---------------------------------------------------------------------
  190. } else if ( (grid_points(1) == 408) &&
  191. (grid_points(2) == 408) &&
  192. (grid_points(3) == 408) &&
  193. (no_time_steps == 250) ) {
  194. class = 'D';
  195. dtref = 0.2e-4;
  196. //---------------------------------------------------------------------
  197. // Reference values of RMS-norms of residual.
  198. //---------------------------------------------------------------------
  199. xcrref(1) = 0.2533188551738e+05;
  200. xcrref(2) = 0.2346393716980e+04;
  201. xcrref(3) = 0.6294554366904e+04;
  202. xcrref(4) = 0.5352565376030e+04;
  203. xcrref(5) = 0.3905864038618e+05;
  204. //---------------------------------------------------------------------
  205. // Reference values of RMS-norms of solution error.
  206. //---------------------------------------------------------------------
  207. xceref(1) = 0.3100009377557e+03;
  208. xceref(2) = 0.2424086324913e+02;
  209. xceref(3) = 0.7782212022645e+02;
  210. xceref(4) = 0.6835623860116e+02;
  211. xceref(5) = 0.6065737200368e+03;
  212. //---------------------------------------------------------------------
  213. // reference data for 1020x1020x1020 grids after 250 time steps,
  214. // with DT = 0.4e-05
  215. //---------------------------------------------------------------------
  216. } else if ( (grid_points(1) == 1020) &&
  217. (grid_points(2) == 1020) &&
  218. (grid_points(3) == 1020) &&
  219. (no_time_steps == 250) ) {
  220. class = 'E';
  221. dtref = 0.4e-5;
  222. //---------------------------------------------------------------------
  223. // Reference values of RMS-norms of residual.
  224. //---------------------------------------------------------------------
  225. xcrref(1) = 0.9795372484517e+05;
  226. xcrref(2) = 0.9739814511521e+04;
  227. xcrref(3) = 0.2467606342965e+05;
  228. xcrref(4) = 0.2092419572860e+05;
  229. xcrref(5) = 0.1392138856939e+06;
  230. //---------------------------------------------------------------------
  231. // Reference values of RMS-norms of solution error.
  232. //---------------------------------------------------------------------
  233. xceref(1) = 0.4327562208414e+03;
  234. xceref(2) = 0.3699051964887e+02;
  235. xceref(3) = 0.1089845040954e+03;
  236. xceref(4) = 0.9462517622043e+02;
  237. xceref(5) = 0.7765512765309e+03;
  238. } else {
  239. verified = 0;
  240. }
  241. //---------------------------------------------------------------------
  242. // verification test for residuals if gridsize is one of
  243. // the defined grid sizes above (class != 'U')
  244. //---------------------------------------------------------------------
  245. //---------------------------------------------------------------------
  246. // Compute the difference of solution values and the known reference
  247. // values.
  248. //---------------------------------------------------------------------
  249. for (m = 1; m <= 5; m++) {
  250. xcrdif(m) = FABS((xcr(m)-xcrref(m))/xcrref(m)) ;
  251. xcedif(m) = FABS((xce(m)-xceref(m))/xceref(m));
  252. }
  253. //---------------------------------------------------------------------
  254. // Output the comparison of computed results to known cases.
  255. //---------------------------------------------------------------------
  256. if (class != 'U') {
  257. printf(" Verification being performed for class %c\n", class);
  258. printf(" accuracy setting for epsilon = %20.13e\n", epsilon);
  259. verified = (FABS(dt-dtref) <= epsilon);
  260. if (!verified) {
  261. class = 'U';
  262. printf(" DT does not match the reference value of %15.8e\n",
  263. dtref);
  264. }
  265. } else {
  266. printf(" Unknown class\n");
  267. }
  268. if (class != 'U') {
  269. printf(" Comparison of RMS-norms of residual\n");
  270. } else {
  271. printf(" RMS-norms of residual\n");
  272. }
  273. for (m = 1; m <= 5; m++) {
  274. if (class == 'U') {
  275. printf(" %2d %20.13e\n",
  276. m, xcr(m));
  277. } else if (xcrdif(m) <= epsilon) {
  278. printf(" %2d %20.13e %20.13e %20.13e\n",
  279. m,xcr(m),xcrref(m),xcrdif(m));
  280. } else {
  281. verified = 0;
  282. printf(" FAILURE: %2d %20.13e %20.13e %20.13e\n",
  283. m,xcr(m),xcrref(m),xcrdif(m));
  284. }
  285. }
  286. if (class != 'U') {
  287. printf(" Comparison of RMS-norms of solution error\n");
  288. } else {
  289. printf(" RMS-norms of solution error\n");
  290. }
  291. for (m = 1; m <= 5; m++) {
  292. if (class == 'U') {
  293. printf(" %2d %20.13e\n",
  294. m, xce(m));
  295. } else if (xcedif(m) <= epsilon) {
  296. printf(" %2d %20.13e %20.13e %20.13e\n",
  297. m,xce(m),xceref(m),xcedif(m));
  298. } else {
  299. verified = 0;
  300. printf(" FAILURE: %2d %20.13e %20.13e %20.13e\n",
  301. m,xce(m),xceref(m),xcedif(m));
  302. }
  303. }
  304. if (class == 'U') {
  305. printf(" No reference values provided\n");
  306. printf(" No verification performed\n");
  307. } else if (verified) {
  308. printf(" Verification Successful\n");
  309. } else {
  310. printf(" Verification failed\n");
  311. }
  312. *class_r = class;
  313. *verified_r = verified;
  314. return;
  315. }