verify.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  1. //
  2. // Copyright 2010 Intel Corporation
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. //
  16. #include <stdio.h>
  17. #include <math.h>
  18. #include "applu_share.h"
  19. #define class _class_
  20. #define FABS(x) ((x)>0 ? (x) : -(x))
  21. #define xcr(m) xcr[m-1]
  22. #define xce(m) xce[m-1]
  23. #define xcrref(m) xcrref[m-1]
  24. #define xceref(m) xceref[m-1]
  25. #define xcrdif(m) xcrdif[m-1]
  26. #define xcedif(m) xcedif[m-1]
  27. void verify(double *xcr, double *xce, double *xcip, char *classp) {
  28. double xcrref[5],xceref[5],xciref, xcrdif[5], xcedif[5], xcidif,
  29. epsilon, dtref;
  30. int m;
  31. //c tolerance level
  32. double xci = *xcip;
  33. epsilon = 1.0e-8;
  34. char class = 'U';
  35. int verified = 1;
  36. for (m=1; m<=5; m++) {
  37. xcrref(m) = 1.0;
  38. xceref(m) = 1.0;
  39. }
  40. xciref = 1.0;
  41. if ((nx0 == 12) && (ny0 == 12) && (nz0 == 12) && (itmax == 50 )) {
  42. class = 'S';
  43. dtref = 5.0e-1;
  44. //c---------------------------------------------------------------------
  45. //c Reference values of RMS-norms of residual, for the (12X12X12) grid,
  46. //c after 50 time steps, with DT = 5.0d-01
  47. //---------------------------------------------------------------------
  48. xcrref(1) = 1.6196343210976702e-02;
  49. xcrref(2) = 2.1976745164821318e-03;
  50. xcrref(3) = 1.5179927653399185e-03;
  51. xcrref(4) = 1.5029584435994323e-03;
  52. xcrref(5) = 3.4264073155896461e-02;
  53. //c---------------------------------------------------------------------
  54. //c Reference values of RMS-norms of solution error, for the (12X12X12) grid,
  55. //c after 50 time steps, with DT = 5.0e-01;
  56. //c---------------------------------------------------------------------
  57. xceref(1) = 6.4223319957960924e-04;
  58. xceref(2) = 8.4144342047347926e-05;
  59. xceref(3) = 5.8588269616485186e-05;
  60. xceref(4) = 5.8474222595157350e-05;
  61. xceref(5) = 1.3103347914111294e-03;
  62. //c---------------------------------------------------------------------
  63. //c Reference value of surface integral, for the (12X12X12) grid,
  64. //c after 50 time steps, with DT = 5.0d-01
  65. //c---------------------------------------------------------------------
  66. xciref = 7.8418928865937083;
  67. } else
  68. if ((nx0 == 33) && (ny0 == 33) && (nz0 == 33) && (itmax == 300)) {
  69. class = 'W';
  70. dtref = 1.5e-3;
  71. //c---------------------------------------------------------------------
  72. //c Reference values of RMS-norms of residual, for the (33x33x33) grid,
  73. //c after 300 time steps, with DT = 1.5d-3
  74. //c---------------------------------------------------------------------
  75. xcrref(1) = 0.1236511638192e+02;
  76. xcrref(2) = 0.1317228477799e+01;
  77. xcrref(3) = 0.2550120713095e+01;
  78. xcrref(4) = 0.2326187750252e+01;
  79. xcrref(5) = 0.2826799444189e+02;
  80. //c---------------------------------------------------------------------
  81. //c Reference values of RMS-norms of solution error, for the (33X33X33) grid,
  82. //c---------------------------------------------------------------------
  83. xceref(1) = 0.4867877144216e+00;
  84. xceref(2) = 0.5064652880982e-01;
  85. xceref(3) = 0.9281818101960e-01;
  86. xceref(4) = 0.8570126542733e-01;
  87. xceref(5) = 0.1084277417792e+01;
  88. //c---------------------------------------------------------------------
  89. //c Reference value of surface integral, for the (33X33X33) grid,
  90. //c after 300 time steps, with DT = 1.5e-3;
  91. //c---------------------------------------------------------------------
  92. xciref = 0.1161399311023e+02;
  93. } else
  94. if ((nx0 == 64) && (ny0 == 64) && (nz0 == 64) && (itmax == 250)) {
  95. class = 'A';
  96. dtref = 2.0e+0;
  97. //c---------------------------------------------------------------------
  98. //c Reference values of RMS-norms of residual, for the (64X64X64) grid,
  99. //c after 250 time steps, with DT = 2.0e+00;
  100. //c---------------------------------------------------------------------
  101. xcrref(1) = 7.7902107606689367e+02;
  102. xcrref(2) = 6.3402765259692870e+01;
  103. xcrref(3) = 1.9499249727292479e+02;
  104. xcrref(4) = 1.7845301160418537e+02;
  105. xcrref(5) = 1.8384760349464247e+03;
  106. //c---------------------------------------------------------------------
  107. //c Reference values of RMS-norms of solution error, for the (64X64X64) grid,
  108. //c after 250 time steps, with DT = 2.0e+00;
  109. //c---------------------------------------------------------------------
  110. xceref(1) = 2.9964085685471943e+01;
  111. xceref(2) = 2.8194576365003349e+00;
  112. xceref(3) = 7.3473412698774742e+00;
  113. xceref(4) = 6.7139225687777051e+00;
  114. xceref(5) = 7.0715315688392578e+01;
  115. //c---------------------------------------------------------------------
  116. //c Reference value of surface integral, for the (64X64X64) grid,
  117. //c after 250 time steps, with DT = 2.0e+00;
  118. //c---------------------------------------------------------------------
  119. xciref = 2.6030925604886277e+01;
  120. } else
  121. if ((nx0 == 102) && (ny0 == 102) && (nz0 == 102) && (itmax == 250)) {
  122. class = 'B';
  123. dtref = 2.0e+0;
  124. //c---------------------------------------------------------------------
  125. //c Reference values of RMS-norms of residual, for the (102X102X102) grid,
  126. //c after 250 time steps, with DT = 2.0e+00;
  127. //c---------------------------------------------------------------------
  128. xcrref(1) = 3.5532672969982736e+03;
  129. xcrref(2) = 2.6214750795310692e+02;
  130. xcrref(3) = 8.8333721850952190e+02;
  131. xcrref(4) = 7.7812774739425265e+02;
  132. xcrref(5) = 7.3087969592545314e+03;
  133. //c---------------------------------------------------------------------
  134. //c Reference values of RMS-norms of solution error, for the (102X102X102)
  135. //c grid, after 250 time steps, with DT = 2.0e+00;
  136. //c---------------------------------------------------------------------
  137. xceref(1) = 1.1401176380212709e+02;
  138. xceref(2) = 8.1098963655421574e+00;
  139. xceref(3) = 2.8480597317698308e+01;
  140. xceref(4) = 2.5905394567832939e+01;
  141. xceref(5) = 2.6054907504857413e+02;
  142. //c---------------------------------------------------------------------
  143. //c Reference value of surface integral, for the (102X102X102) grid,
  144. //c after 250 time steps, with DT = 2.0e+00;
  145. //c---------------------------------------------------------------------
  146. xciref = 4.7887162703308227e+01;
  147. } else
  148. if ((nx0 == 162) && (ny0 == 162) && (nz0 == 162) && (itmax == 250)) {
  149. class = 'C';
  150. dtref = 2.0e+0;
  151. //c---------------------------------------------------------------------
  152. //c Reference values of RMS-norms of residual, for the (162X162X162) grid,
  153. //c after 250 time steps, with DT = 2.0e+00;
  154. //c---------------------------------------------------------------------
  155. xcrref(1) = 1.03766980323537846e+04;
  156. xcrref(2) = 8.92212458801008552e+02;
  157. xcrref(3) = 2.56238814582660871e+03;
  158. xcrref(4) = 2.19194343857831427e+03;
  159. xcrref(5) = 1.78078057261061185e+04;
  160. //c---------------------------------------------------------------------
  161. //c Reference values of RMS-norms of solution error, for the (162X162X162)
  162. //c grid, after 250 time steps, with DT = 2.0e+00;
  163. //c---------------------------------------------------------------------
  164. xceref(1) = 2.15986399716949279e+02;
  165. xceref(2) = 1.55789559239863600e+01;
  166. xceref(3) = 5.41318863077207766e+01;
  167. xceref(4) = 4.82262643154045421e+01;
  168. xceref(5) = 4.55902910043250358e+02;
  169. //c---------------------------------------------------------------------
  170. //c Reference value of surface integral, for the (162X162X162) grid,
  171. //c after 250 time steps, with DT = 2.0e+00;
  172. //c---------------------------------------------------------------------
  173. xciref = 6.66404553572181300e+01;
  174. } else
  175. if ((nx0 == 408) && (ny0 == 408) && (nz0 == 408) && (itmax == 300)) {
  176. class = 'D';
  177. dtref = 1.0e+0;
  178. //c---------------------------------------------------------------------
  179. //c Reference values of RMS-norms of residual, for the (408X408X408) grid,
  180. //c after 300 time steps, with DT = 1.0e+00;
  181. //c---------------------------------------------------------------------
  182. xcrref(1) = 0.4868417937025e+05;
  183. xcrref(2) = 0.4696371050071e+04;
  184. xcrref(3) = 0.1218114549776e+05;
  185. xcrref(4) = 0.1033801493461e+05;
  186. xcrref(5) = 0.7142398413817e+05;
  187. //c---------------------------------------------------------------------
  188. //c Reference values of RMS-norms of solution error, for the (408X408X408)
  189. //c grid, after 300 time steps, with DT = 1.0e+00;
  190. //c---------------------------------------------------------------------
  191. xceref(1) = 0.3752393004482e+03;
  192. xceref(2) = 0.3084128893659e+02;
  193. xceref(3) = 0.9434276905469e+02;
  194. xceref(4) = 0.8230686681928e+02;
  195. xceref(5) = 0.7002620636210e+03;
  196. //c---------------------------------------------------------------------
  197. //c Reference value of surface integral, for the (408X408X408) grid,
  198. //c after 300 time steps, with DT = 1.0e+00;
  199. //c---------------------------------------------------------------------
  200. xciref = 0.8334101392503e+02;
  201. } else
  202. if ((nx0 == 1020) && (ny0 == 1020) && (nz0 == 1020) && (itmax == 300) ) {
  203. class = 'E';
  204. dtref = 0.5e+0;
  205. //c---------------------------------------------------------------------
  206. //c Reference values of RMS-norms of residual, for the (1020X1020X1020) grid,
  207. //c after 300 time steps, with DT = 0.5e+00;
  208. //c---------------------------------------------------------------------
  209. xcrref(1) = 0.2099641687874e+06;
  210. xcrref(2) = 0.2130403143165e+05;
  211. xcrref(3) = 0.5319228789371e+05;
  212. xcrref(4) = 0.4509761639833e+05;
  213. xcrref(5) = 0.2932360006590e+06;
  214. //c---------------------------------------------------------------------
  215. //c Reference values of RMS-norms of solution error, for the (1020X1020X1020)
  216. //c grid, after 300 time steps, with DT = 0.5e+00;
  217. //c---------------------------------------------------------------------
  218. xceref(1) = 0.4800572578333e+03;
  219. xceref(2) = 0.4221993400184e+02;
  220. xceref(3) = 0.1210851906824e+03;
  221. xceref(4) = 0.1047888986770e+03;
  222. xceref(5) = 0.8363028257389e+03;
  223. //c---------------------------------------------------------------------
  224. //c Reference value of surface integral, for the (1020X1020X1020) grid,
  225. //c after 300 time steps, with DT = 0.5e+00;
  226. //c---------------------------------------------------------------------
  227. // xciref = 0.9512163272273e+02;
  228. } else verified = 0;
  229. //c---------------------------------------------------------------------
  230. //c verification test for residuals if gridsize is one of
  231. //c the defined grid sizes above (class != 'U')
  232. //c---------------------------------------------------------------------
  233. //c---------------------------------------------------------------------
  234. //c Compute the difference of solution values and the known reference values.
  235. //c---------------------------------------------------------------------
  236. for (m=1; m<=5; m++) {
  237. xcrdif(m) = FABS((xcr(m)-xcrref(m))/xcrref(m));
  238. xcedif(m) = FABS((xce(m)-xceref(m))/xceref(m));
  239. }
  240. xcidif = FABS((xci - xciref)/xciref);
  241. //c---------------------------------------------------------------------
  242. //c Output the comparison of computed results to known cases.
  243. //c---------------------------------------------------------------------
  244. if (class != 'U') {
  245. printf(" Verification being performed for class %c\n", class);
  246. printf(" Accuracy setting for epsilon = %20.13e\n", epsilon);
  247. verified = (FABS(dt-dtref) <= epsilon);
  248. if (!verified) {
  249. class = 'U';
  250. printf(" DT does not match the reference value of %15.8e\n",
  251. dtref);
  252. }
  253. } else printf(" Unknown class\n");
  254. if (class != 'U') printf(" Comparison of RMS-norms of residual\n");
  255. else printf(" RMS-norms of residual\n");
  256. for (m=1; m<=5; m++) {
  257. if (class == 'U')
  258. printf(" %2d %20.13e\n", m, xcr(m));
  259. else if (xcrdif(m) <= epsilon) {
  260. printf(" %2d %20.13e %20.13e %20.13e\n",
  261. m,xcr(m),xcrref(m),xcrdif(m));
  262. } else {
  263. verified = 0;
  264. printf("FAILURE: %2d %20.13e %20.13e %20.13e\n",
  265. m,xcr(m),xcrref(m),xcrdif(m));
  266. }
  267. }
  268. if (class != 'U') printf(" Comparison of RMS-norms of solution error\n");
  269. else printf(" RMS-norms of solution error\n");
  270. for (m=1; m<=5; m++) {
  271. if (class == 'U')
  272. printf(" %2d %20.13e\n", m, xce(m));
  273. else if (xcedif(m) <= epsilon) {
  274. printf(" %2d %20.13e %20.13e %20.13e\n",
  275. m,xce(m),xceref(m),xcedif(m));
  276. } else {
  277. verified = 0;
  278. printf("FAILURE: %2d %20.13e %20.13e %20.13e\n",
  279. m,xce(m),xceref(m),xcedif(m));
  280. }
  281. }
  282. if (class != 'U') printf(" Comparison of surface integral\n");
  283. else printf(" Surface integral\n");
  284. if (class == 'U') {
  285. printf(" %20.13e\n", xci);
  286. } else if (xcidif <= epsilon) {
  287. printf(" %20.13e %20.13e %20.13e\n", xci, xciref, xcidif);
  288. } else {
  289. verified = 0;
  290. printf("FAILURE: %20.13e %20.13e %20.13e\n", xci, xciref, xcidif);
  291. }
  292. if (class == 'U') {
  293. printf(" No reference values provided\n");
  294. printf(" No verification performed\n");
  295. } else if (verified) {
  296. printf(" Verification Successful\n");
  297. } else {
  298. printf(" Verification failed\n");
  299. }
  300. *classp = class;
  301. return;
  302. }