IJKSubzoneInfo.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. #pragma once
  2. #include "ThirdPartyHeadersBegin.h"
  3. #include <algorithm>
  4. #include "ThirdPartyHeadersEnd.h"
  5. #include "SzlFileLoader.h"
  6. #include "IJK.h"
  7. namespace tecplot
  8. {
  9. namespace ___3933
  10. {
  11. class IJKSubzoneInfo
  12. {
  13. private:
  14. ___1844 m_zoneIJKDim;
  15. ___1844 m_zoneLastIJKIndex;
  16. ___1844 m_subzoneItemsMaxIJKDim;
  17. ___2090::___2980 m_partition;
  18. ___1844 m_subzoneTilingIJKDim;
  19. ___1844 m_subzoneTilingIJKShift;
  20. ___2090::SubzoneOffset_t m_numSubzones;
  21. #if !defined NO_ASSERTS
  22. bool ___2492;
  23. #endif
  24. public:
  25. IJKSubzoneInfo(___1844 const &zoneIJKDim, ___1844 const &subzoneMaxIJKDim, ___2090::___2980 ___2977, bool minimizeNumSubzones) : m_zoneIJKDim(zoneIJKDim), m_zoneLastIJKIndex(zoneIJKDim.maxOp(1) - 1), m_subzoneItemsMaxIJKDim(subzoneMaxIJKDim), m_partition(___2977), m_subzoneTilingIJKDim(numSubzonesForDirection(zoneIJKDim.i(), ___2090::ItemOffset_t(subzoneMaxIJKDim.i()), minimizeNumSubzones), numSubzonesForDirection(zoneIJKDim.___2105(), ___2090::ItemOffset_t(subzoneMaxIJKDim.___2105()), minimizeNumSubzones), numSubzonesForDirection(zoneIJKDim.___2134(), ___2090::ItemOffset_t(subzoneMaxIJKDim.___2134()), minimizeNumSubzones)), m_subzoneTilingIJKShift(subzoneShiftForDirection(zoneIJKDim.i(), ___2090::ItemOffset_t(subzoneMaxIJKDim.i()), minimizeNumSubzones), subzoneShiftForDirection(zoneIJKDim.___2105(), ___2090::ItemOffset_t(subzoneMaxIJKDim.___2105()), minimizeNumSubzones), subzoneShiftForDirection(zoneIJKDim.___2134(), ___2090::ItemOffset_t(subzoneMaxIJKDim.___2134()), minimizeNumSubzones)), m_numSubzones(___2090::SubzoneOffset_t(m_subzoneTilingIJKDim.blockSize()))
  26. #if !defined NO_ASSERTS
  27. ,
  28. ___2492(minimizeNumSubzones)
  29. #endif
  30. {
  31. REQUIRE(zoneIJKDim > 0);
  32. REQUIRE(subzoneMaxIJKDim > 0);
  33. }
  34. IJKSubzoneInfo() : m_zoneIJKDim(0, 0, 0), m_zoneLastIJKIndex(0, 0, 0), m_subzoneItemsMaxIJKDim(0, 0, 0), m_subzoneTilingIJKDim(0, 0, 0), m_subzoneTilingIJKShift(0, 0, 0), m_numSubzones(0) {}
  35. ~IJKSubzoneInfo() {}
  36. inline void swap(IJKSubzoneInfo &___2888)
  37. {
  38. using std::swap;
  39. swap(m_zoneIJKDim, ___2888.m_zoneIJKDim);
  40. swap(m_zoneLastIJKIndex, ___2888.m_zoneLastIJKIndex);
  41. swap(m_subzoneItemsMaxIJKDim, ___2888.m_subzoneItemsMaxIJKDim);
  42. swap(m_subzoneTilingIJKDim, ___2888.m_subzoneTilingIJKDim);
  43. swap(m_subzoneTilingIJKShift, ___2888.m_subzoneTilingIJKShift);
  44. swap(m_numSubzones, ___2888.m_numSubzones);
  45. }
  46. inline void reset(___1844 const &zoneIJKSize, ___1844 const &subzoneIJKMax, bool minimizeNumSubzones = DEFAULT_MINIMIZE_IJK_NUM_SUBZONES)
  47. {
  48. REQUIRE(zoneIJKSize > 0);
  49. REQUIRE(subzoneIJKMax > 0);
  50. REQUIRE(minimizeNumSubzones == DEFAULT_MINIMIZE_IJK_NUM_SUBZONES);
  51. m_zoneIJKDim = zoneIJKSize;
  52. m_zoneLastIJKIndex = zoneIJKSize.maxOp(1) - 1;
  53. m_subzoneItemsMaxIJKDim = subzoneIJKMax;
  54. m_subzoneTilingIJKDim = ___1844(numSubzonesForDirection(zoneIJKSize.i(), ___2090::ItemOffset_t(subzoneIJKMax.i()), minimizeNumSubzones), numSubzonesForDirection(zoneIJKSize.___2105(), ___2090::ItemOffset_t(subzoneIJKMax.___2105()), minimizeNumSubzones), numSubzonesForDirection(zoneIJKSize.___2134(), ___2090::ItemOffset_t(subzoneIJKMax.___2134()), minimizeNumSubzones));
  55. m_subzoneTilingIJKShift = ___1844(subzoneShiftForDirection(zoneIJKSize.i(), ___2090::ItemOffset_t(subzoneIJKMax.i()), minimizeNumSubzones), subzoneShiftForDirection(zoneIJKSize.___2105(), ___2090::ItemOffset_t(subzoneIJKMax.___2105()), minimizeNumSubzones), subzoneShiftForDirection(zoneIJKSize.___2134(), ___2090::ItemOffset_t(subzoneIJKMax.___2134()), minimizeNumSubzones));
  56. m_numSubzones = ___2090::SubzoneOffset_t(m_subzoneTilingIJKDim.blockSize());
  57. }
  58. inline bool ___2067() const { return m_zoneIJKDim > 0 && m_subzoneItemsMaxIJKDim > 0; }
  59. inline bool validSubzone(___2090::SubzoneOffset_t ___3880) const { return ___3880 < getNumSzs(); }
  60. inline bool validSzAddress(___2090::SubzoneAddress szAddress) const { return validSubzone(szAddress.subzoneOffset()) && szAddress.___2977() == m_partition; }
  61. inline bool validItemAddress(___2090 ___2089) const { return validSzAddress(___2089.subzoneAddress()) && ___2089.itemOffset() < numItemsInSz(___2089.subzoneOffset()); }
  62. ___81 getNumItems(void) const { return m_zoneIJKDim.blockSize(); }
  63. ___1844 const &ijkDim(void) const { return m_zoneIJKDim; }
  64. ___1844 const &ijkLastIndex(void) const
  65. {
  66. ___478(m_zoneLastIJKIndex == m_zoneIJKDim.maxOp(1) - 1);
  67. return m_zoneLastIJKIndex;
  68. }
  69. ___2090::SubzoneOffset_t getNumSzs(void) const
  70. {
  71. ENSURE(m_numSubzones == ___2090::SubzoneOffset_t(m_subzoneTilingIJKDim.blockSize()));
  72. ENSURE(m_numSubzones == calcNumSubzones(m_zoneIJKDim, m_subzoneItemsMaxIJKDim, ___2492));
  73. return m_numSubzones;
  74. }
  75. static inline ___2090::SubzoneOffset_t numSubzonesForDirection(___81 itemIndexDim, ___2090::ItemOffset_t subzoneIndexMax, bool minimizeNumSubzones = DEFAULT_MINIMIZE_IJK_NUM_SUBZONES)
  76. {
  77. REQUIRE(itemIndexDim > 0);
  78. REQUIRE(subzoneIndexMax <= ___2090::MAX_ITEM_OFFSET + 1);
  79. ___2090::SubzoneOffset_t numSubzonesForDir;
  80. if (minimizeNumSubzones)
  81. {
  82. numSubzonesForDir = ___2090::SubzoneOffset_t((itemIndexDim + subzoneIndexMax - 1) / subzoneIndexMax);
  83. }
  84. else
  85. {
  86. numSubzonesForDir = ___2090::SubzoneOffset_t(1 + (itemIndexDim / subzoneIndexMax));
  87. }
  88. ENSURE(numSubzonesForDir > 0);
  89. ENSURE((___81)numSubzonesForDir * subzoneIndexMax >= itemIndexDim);
  90. ENSURE(IMPLICATION(minimizeNumSubzones, ___81(numSubzonesForDir - 1) * subzoneIndexMax < itemIndexDim));
  91. return numSubzonesForDir;
  92. }
  93. static ___2090::SubzoneOffset_t calcNumSubzones(___1844 const &zoneIJKDim, ___1844 const &subzoneIJKMax, bool minimizeIJKNumSubzones)
  94. {
  95. REQUIRE(zoneIJKDim > 0);
  96. REQUIRE(subzoneIJKMax > 0);
  97. ___1844 const subzoneTilingIJK(numSubzonesForDirection(zoneIJKDim.i(), ___2090::ItemOffset_t(subzoneIJKMax.i()), minimizeIJKNumSubzones), numSubzonesForDirection(zoneIJKDim.___2105(), ___2090::ItemOffset_t(subzoneIJKMax.___2105()), minimizeIJKNumSubzones), numSubzonesForDirection(zoneIJKDim.___2134(), ___2090::ItemOffset_t(subzoneIJKMax.___2134()), minimizeIJKNumSubzones));
  98. ___2090::SubzoneOffset_t const numSubzones = ___2090::SubzoneOffset_t(subzoneTilingIJK.blockSize());
  99. ENSURE(numSubzones > 0 && numSubzones <= zoneIJKDim.blockSize());
  100. return numSubzones;
  101. }
  102. static inline ___2090::ItemOffset_t subzoneShiftForDirection(___81 itemIndexDim, ___2090::ItemOffset_t subzoneIndexMax, bool minimizeNumSubzones = DEFAULT_MINIMIZE_IJK_NUM_SUBZONES)
  103. {
  104. REQUIRE(itemIndexDim > 0);
  105. REQUIRE(subzoneIndexMax >= 3 && subzoneIndexMax <= ___2090::MAX_ITEM_OFFSET + 1);
  106. ___2090::ItemOffset_t const remainder = ___2090::ItemOffset_t(itemIndexDim % subzoneIndexMax);
  107. ___2090::ItemOffset_t subzoneShift = (subzoneIndexMax - remainder) / 2;
  108. if (minimizeNumSubzones && remainder == 0)
  109. subzoneShift = 0;
  110. ENSURE(subzoneShift < subzoneIndexMax);
  111. return subzoneShift;
  112. }
  113. public:
  114. ___1844 itemIJKStart(___1844 const &szIJK) const
  115. {
  116. INVARIANT(m_subzoneTilingIJKShift < m_subzoneItemsMaxIJKDim);
  117. ___1844 const indexStart = m_subzoneTilingIJKShift.maxOp(szIJK * m_subzoneItemsMaxIJKDim) - m_subzoneTilingIJKShift;
  118. ENSURE(indexStart >= 0);
  119. return indexStart;
  120. }
  121. ___1844 itemIJKEnd(___1844 const &szIJK) const
  122. {
  123. INVARIANT(m_subzoneTilingIJKShift < m_subzoneItemsMaxIJKDim);
  124. ___1844 const indexEnd = m_zoneIJKDim.minOp((szIJK + 1) * m_subzoneItemsMaxIJKDim - m_subzoneTilingIJKShift) - 1;
  125. ENSURE(indexEnd < m_zoneIJKDim);
  126. return indexEnd;
  127. }
  128. ___1844 szIJKAtSzIndex(___2090::SubzoneOffset_t ___3880) const
  129. {
  130. REQUIRE(validSubzone(___3880));
  131. ___1844 const subzoneIJK = m_subzoneTilingIJKDim.ijkAtOffset(___3880);
  132. ENSURE(subzoneIJK < m_subzoneTilingIJKDim);
  133. return subzoneIJK;
  134. }
  135. ___2090::SubzoneAddress szAddressAtSzIJK(___1844 const &szIJK) const
  136. {
  137. REQUIRE(szIJK < m_subzoneTilingIJKDim);
  138. ___2090::SubzoneAddress const szAddress(m_partition, static_cast<___2090::SubzoneOffset_t>(m_subzoneTilingIJKDim.offsetAtIJK(szIJK)));
  139. ENSURE(validSzAddress(szAddress));
  140. ENSURE(szIJKAtSzIndex(szAddress.subzoneOffset()) == szIJK);
  141. return szAddress;
  142. }
  143. void subzoneIJKStartAndEnd(___2090::SubzoneOffset_t ___3880, ___1844 &___1880, ___1844 &___1852) const
  144. {
  145. REQUIRE(___3880 < getNumSzs());
  146. ___1844 const szIJK = szIJKAtSzIndex(___3880);
  147. ___1880 = itemIJKStart(szIJK);
  148. ___1852 = itemIJKEnd(szIJK);
  149. ENSURE(___1880 < m_zoneIJKDim);
  150. ENSURE(___1852 < m_zoneIJKDim);
  151. ENSURE(szAddressAtItemIJK(___1880).subzoneOffset() == ___3880);
  152. ENSURE(szAddressAtItemIJK(___1852).subzoneOffset() == ___3880);
  153. }
  154. ___1844 subzoneIJKStart(___2090::SubzoneOffset_t ___3880) const
  155. {
  156. REQUIRE(___3880 < getNumSzs());
  157. ___1844 const szIJK = szIJKAtSzIndex(___3880);
  158. ___1844 const ___1880 = itemIJKStart(szIJK);
  159. ENSURE(___1880 < m_zoneIJKDim);
  160. ENSURE(szAddressAtItemIJK(___1880).subzoneOffset() == ___3880);
  161. return ___1880;
  162. }
  163. ___1844 subzoneIJKEnd(___2090::SubzoneOffset_t ___3880) const
  164. {
  165. REQUIRE(___3880 < getNumSzs());
  166. ___1844 const szIJK = szIJKAtSzIndex(___3880);
  167. ___1844 const ___1852 = itemIJKEnd(szIJK);
  168. ENSURE(___1852 < m_zoneIJKDim);
  169. ENSURE(szAddressAtItemIJK(___1852).subzoneOffset() == ___3880);
  170. return ___1852;
  171. }
  172. ___1844 szIJKAtItemIJK(___1844 const &itemIJK) const
  173. {
  174. REQUIRE(itemIJK < m_zoneIJKDim);
  175. ___1844 const szIJK = (itemIJK + m_subzoneTilingIJKShift) / m_subzoneItemsMaxIJKDim;
  176. ENSURE(szIJK < m_subzoneTilingIJKDim);
  177. return szIJK;
  178. }
  179. ___2090::SubzoneAddress szAddressAtItemIJK(___1844 const &itemIJK) const
  180. {
  181. REQUIRE(itemIJK < m_zoneIJKDim);
  182. ___1844 const subzoneIJK = szIJKAtItemIJK(itemIJK);
  183. ___2090::SubzoneAddress const szAddress(m_partition, static_cast<___2090::SubzoneOffset_t>(m_subzoneTilingIJKDim.offsetAtIJK(subzoneIJK)));
  184. ENSURE(validSzAddress(szAddress));
  185. return szAddress;
  186. }
  187. ___2090::SubzoneAddress szAddressAtItemIndex(___81 itemIndex) const
  188. {
  189. REQUIRE(itemIndex < getNumItems());
  190. ___1844 const itemIJK = m_zoneIJKDim.ijkAtOffset(itemIndex);
  191. ___2090::SubzoneAddress const szAddress = szAddressAtItemIJK(itemIJK);
  192. ENSURE(validSzAddress(szAddress));
  193. return szAddress;
  194. }
  195. ___2090 itemAddressAtItemIJK(___1844 const &itemIJK, ___1844 const &szIJK) const
  196. {
  197. REQUIRE(itemIJK < m_zoneIJKDim);
  198. REQUIRE(szIJK < m_subzoneTilingIJKDim);
  199. ___2090::SubzoneOffset_t const szOffset = static_cast<___2090::SubzoneOffset_t>(m_subzoneTilingIJKDim.offsetAtIJK(szIJK));
  200. ___1844 const ___1880 = itemIJKStart(szIJK);
  201. ___1844 const ___1852 = itemIJKEnd(szIJK);
  202. ___1844 const localMax = ___1852 - ___1880 + 1;
  203. ___1844 const localIJK = itemIJK - ___1880;
  204. ___478(localIJK <= localMax);
  205. ___2090::ItemOffset_t const itemOffset = ___2090::ItemOffset_t(localMax.offsetAtIJK(localIJK));
  206. ENSURE(itemOffset < localMax.blockSize());
  207. return ___2090(m_partition, szOffset, itemOffset);
  208. }
  209. ___1844 subzoneIJKDim(___2090::SubzoneOffset_t ___3880) const
  210. {
  211. REQUIRE(validSubzone(___3880));
  212. ___1844 szIJKStart, szIJKEnd;
  213. subzoneIJKStartAndEnd(___3880, szIJKStart, szIJKEnd);
  214. ___1844 const szIJKDim = szIJKEnd - szIJKStart + 1;
  215. return szIJKDim;
  216. }
  217. ___2090::ItemOffset_t numItemsInSz(___2090::SubzoneOffset_t ___3880) const
  218. {
  219. REQUIRE(validSubzone(___3880));
  220. return ___2090::ItemOffset_t(subzoneIJKDim(___3880).blockSize());
  221. }
  222. ___2090 itemAddressAtItemIJK(___1844 const &itemIJK) const
  223. {
  224. REQUIRE(itemIJK < m_zoneIJKDim);
  225. ___1844 const szIJK = szIJKAtItemIJK(itemIJK);
  226. return itemAddressAtItemIJK(itemIJK, szIJK);
  227. }
  228. ___1844 itemIJKAtItemAddress(___2090 ___2089) const
  229. {
  230. REQUIRE(validItemAddress(___2089));
  231. ___2090::SubzoneOffset_t const ___3880 = ___2089.subzoneOffset();
  232. ___1844 ___1880, ___1852;
  233. subzoneIJKStartAndEnd(___3880, ___1880, ___1852);
  234. ___2090::ItemOffset_t const ___2865 = ___2089.itemOffset();
  235. ___1844 const ijkRange = ___1852 - ___1880 + 1;
  236. ___1844 const ___1862 = ijkRange.ijkAtOffset(___2865);
  237. ___1844 const itemIJK = ___1880 + ___1862;
  238. ENSURE(itemIJK < m_zoneIJKDim);
  239. ENSURE(itemAddressAtItemIJK(itemIJK) == ___2089);
  240. return itemIJK;
  241. }
  242. inline ___2090 itemAddressAtItemIndex(___81 itemIndex) const
  243. {
  244. REQUIRE(itemIndex < getNumItems());
  245. ___1844 const itemIJK = itemIJKAtItemIndex(itemIndex);
  246. ___2090 const ___2089 = itemAddressAtItemIJK(itemIJK);
  247. return ___2089;
  248. }
  249. inline ___81 itemIndexAtItemAddress(___2090 ___2089) const
  250. {
  251. REQUIRE(validItemAddress(___2089));
  252. ___1844 const itemIJK = itemIJKAtItemAddress(___2089);
  253. ___81 const itemIndex = itemIndexAtItemIJK(itemIJK);
  254. ENSURE(itemIndex < getNumItems());
  255. ENSURE(itemAddressAtItemIndex(itemIndex) == ___2089);
  256. return itemIndex;
  257. }
  258. inline ___81 itemIndexAtItemIJK(___1844 const &itemIJK) const
  259. {
  260. REQUIRE(itemIJK < m_zoneIJKDim);
  261. ___81 const itemIndex = m_zoneIJKDim.offsetAtIJK(itemIJK);
  262. ENSURE(itemIndex < getNumItems());
  263. return itemIndex;
  264. }
  265. ___1844 itemIJKAtItemIndex(___81 itemIndex) const
  266. {
  267. REQUIRE(itemIndex < getNumItems());
  268. ___1844 const itemIJK = m_zoneIJKDim.ijkAtOffset(itemIndex);
  269. ENSURE(itemIJK < m_zoneIJKDim);
  270. ENSURE(itemIndexAtItemIJK(itemIJK) == itemIndex);
  271. return itemIJK;
  272. }
  273. ___372 getSubzonesOnIndexPlane(IJKPlanes_e whichPlane, ___81 planeIndex, ___3269<___2090::SubzoneAddress> &szAddresses) const;
  274. ___372 getSubzonesOnIndexLine(IJKLines_e whichLine, ___81 mIndex, ___81 nIndex, ___3269<___2090::SubzoneAddress> &szAddresses) const;
  275. };
  276. }
  277. }