<a href="v__compute_8cc.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span> <span class="comment">// Voro++, a 3D cell-based Voronoi library</span></div>
<div class="line"><a name="l00008"></a><span class="lineno"> 8</span> <span class="comment"> * \brief Function implementantions for the voro_compute template. */</span></div>
<div class="line"><a name="l00010"></a><span class="lineno"> 10</span> <span class="preprocessor">#include "<a class="code" href="worklist_8hh.html" title="Header file for setting constants used in the block worklists that are used during cell computation...">worklist.hh</a>"</span></div>
<div class="line"><a name="l00011"></a><span class="lineno"> 11</span> <span class="preprocessor">#include "<a class="code" href="v__compute_8hh.html" title="Header file for the voro_compute template and related classes.">v_compute.hh</a>"</span></div>
<div class="line"><a name="l00012"></a><span class="lineno"> 12</span> <span class="preprocessor">#include "<a class="code" href="rad__option_8hh.html" title="Header file for the classes encapsulating functionality for the regular and radical Voronoi tessellat...">rad_option.hh</a>"</span></div>
<div class="line"><a name="l00013"></a><span class="lineno"> 13</span> <span class="preprocessor">#include "<a class="code" href="container_8hh.html" title="Header file for the container_base and related classes.">container.hh</a>"</span></div>
<div class="line"><a name="l00014"></a><span class="lineno"> 14</span> <span class="preprocessor">#include "<a class="code" href="container__prd_8hh.html" title="Header file for the container_periodic_base and related classes.">container_prd.hh</a>"</span></div>
<div class="line"><a name="l00018"></a><span class="lineno"> 18</span> <span class="comment">/** The class constructor initializes constants from the container class, and</span></div>
<div class="line"><a name="l00019"></a><span class="lineno"> 19</span> <span class="comment"> * sets up the mask and queue used for Voronoi computations.</span></div>
<div class="line"><a name="l00020"></a><span class="lineno"> 20</span> <span class="comment"> * \param[in] con_ a reference to the container class to use.</span></div>
<div class="line"><a name="l00021"></a><span class="lineno"> 21</span> <span class="comment"> * \param[in] (hx_,hy_,hz_) the size of the mask to use. */</span></div>
<div class="line"><a name="l00033"></a><span class="lineno"> 33</span> <span class="comment">/** Scans all of the particles within a block to see if any of them have a</span></div>
<div class="line"><a name="l00034"></a><span class="lineno"> 34</span> <span class="comment"> * smaller distance to the given test vector. If one is found, the routine</span></div>
<div class="line"><a name="l00035"></a><span class="lineno"> 35</span> <span class="comment"> * updates the minimum distance and store information about this particle.</span></div>
<div class="line"><a name="l00036"></a><span class="lineno"> 36</span> <span class="comment"> * \param[in] ijk the index of the block.</span></div>
<div class="line"><a name="l00037"></a><span class="lineno"> 37</span> <span class="comment"> * \param[in] (x,y,z) the test vector to consider (which may have already had a</span></div>
<div class="line"><a name="l00039"></a><span class="lineno"> 39</span> <span class="comment"> * \param[in] (di,dj,dk) the coordinates of the current block, to store if the</span></div>
<div class="line"><a name="l00040"></a><span class="lineno"> 40</span> <span class="comment"> * particle record is updated.</span></div>
<div class="line"><a name="l00041"></a><span class="lineno"> 41</span> <span class="comment"> * \param[in,out] w a reference to a particle record in which to store</span></div>
<div class="line"><a name="l00042"></a><span class="lineno"> 42</span> <span class="comment"> * information about the particle whose Voronoi cell the</span></div>
<div class="line"><a name="l00043"></a><span class="lineno"> 43</span> <span class="comment"> * vector is within.</span></div>
<div class="line"><a name="l00044"></a><span class="lineno"> 44</span> <span class="comment"> * \param[in,out] mrs the current minimum distance, that may be updated if a</span></div>
<div class="line"><a name="l00059"></a><span class="lineno"> 59</span> <span class="comment">/** Finds the Voronoi cell that given vector is within. For containers that are</span></div>
<div class="line"><a name="l00060"></a><span class="lineno"> 60</span> <span class="comment"> * not radially dependent, this corresponds to findig the particle that is</span></div>
<div class="line"><a name="l00061"></a><span class="lineno"> 61</span> <span class="comment"> * closest to the vector; for the radical tessellation containers, this</span></div>
<div class="line"><a name="l00062"></a><span class="lineno"> 62</span> <span class="comment"> * corresponds to a finding the minimum weighted distance.</span></div>
<div class="line"><a name="l00063"></a><span class="lineno"> 63</span> <span class="comment"> * \param[in] (x,y,z) the vector to consider.</span></div>
<div class="line"><a name="l00064"></a><span class="lineno"> 64</span> <span class="comment"> * \param[in] (ci,cj,ck) the coordinates of the block that the test particle is</span></div>
<div class="line"><a name="l00065"></a><span class="lineno"> 65</span> <span class="comment"> * in relative to the container data structure.</span></div>
<div class="line"><a name="l00066"></a><span class="lineno"> 66</span> <span class="comment"> * \param[in] ijk the index of the block that the test particle is in.</span></div>
<div class="line"><a name="l00067"></a><span class="lineno"> 67</span> <span class="comment"> * \param[out] w a reference to a particle record in which to store information</span></div>
<div class="line"><a name="l00068"></a><span class="lineno"> 68</span> <span class="comment"> * about the particle whose Voronoi cell the vector is within.</span></div>
<div class="line"><a name="l00082"></a><span class="lineno"> 82</span>  <span class="comment">// Test all particles in the particle's local region first</span></div>
<div class="line"><a name="l00085"></a><span class="lineno"> 85</span>  <span class="comment">// Now compute the fractional position of the particle within its</span></div>
<div class="line"><a name="l00086"></a><span class="lineno"> 86</span>  <span class="comment">// region and store it in (fx,fy,fz). We use this to compute an index</span></div>
<div class="line"><a name="l00087"></a><span class="lineno"> 87</span>  <span class="comment">// (di,dj,dk) of which subregion the particle is within.</span></div>
<div class="line"><a name="l00092"></a><span class="lineno"> 92</span>  <span class="comment">// The indices (di,dj,dk) tell us which worklist to use, to test the</span></div>
<div class="line"><a name="l00093"></a><span class="lineno"> 93</span>  <span class="comment">// blocks in the optimal order. But we only store worklists for the</span></div>
<div class="line"><a name="l00094"></a><span class="lineno"> 94</span>  <span class="comment">// eighth of the region where di, dj, and dk are all less than half the</span></div>
<div class="line"><a name="l00095"></a><span class="lineno"> 95</span>  <span class="comment">// full grid. The rest of the cases are handled by symmetry. In this</span></div>
<div class="line"><a name="l00096"></a><span class="lineno"> 96</span>  <span class="comment">// section, we detect for these cases, by reflecting high values of di,</span></div>
<div class="line"><a name="l00097"></a><span class="lineno"> 97</span>  <span class="comment">// dj, and dk. For these cases, a mask is constructed in m1 and m2</span></div>
<div class="line"><a name="l00098"></a><span class="lineno"> 98</span>  <span class="comment">// which is used to flip the worklist information when it is loaded.</span></div>
<div class="line"><a name="l00112"></a><span class="lineno"> 112</span>  <span class="comment">// Do a quick test to account for the case when the minimum radius is</span></div>
<div class="line"><a name="l00113"></a><span class="lineno"> 113</span>  <span class="comment">// small enought that no other blocks need to be considered</span></div>
<div class="line"><a name="l00117"></a><span class="lineno"> 117</span>  <span class="comment">// Now compute which worklist we are going to use, and set radp and e to</span></div>
<div class="line"><a name="l00118"></a><span class="lineno"> 118</span>  <span class="comment">// point at the right offsets</span></div>
<div class="line"><a name="l00123"></a><span class="lineno"> 123</span>  <span class="comment">// Read in how many items in the worklist can be tested without having to</span></div>
<div class="line"><a name="l00124"></a><span class="lineno"> 124</span>  <span class="comment">// worry about writing to the mask</span></div>
<div class="line"><a name="l00128"></a><span class="lineno"> 128</span>  <span class="comment">// If mrs is less than the minimum distance to any untested</span></div>
<div class="line"><a name="l00129"></a><span class="lineno"> 129</span>  <span class="comment">// block, then we are done</span></div>
<div class="line"><a name="l00133"></a><span class="lineno"> 133</span>  <span class="comment">// Load in a block off the worklist, permute it with the</span></div>
<div class="line"><a name="l00134"></a><span class="lineno"> 134</span>  <span class="comment">// symmetry mask, and decode its position. These are all</span></div>
<div class="line"><a name="l00135"></a><span class="lineno"> 135</span>  <span class="comment">// integer bit operations so they should run very fast.</span></div>
<div class="line"><a name="l00141"></a><span class="lineno"> 141</span>  <span class="comment">// Check that the worklist position is in range</span></div>
<div class="line"><a name="l00146"></a><span class="lineno"> 146</span>  <span class="comment">// Call the compute_min_max_radius() function. This returns</span></div>
<div class="line"><a name="l00147"></a><span class="lineno"> 147</span>  <span class="comment">// true if the minimum distance to the block is bigger than the</span></div>
<div class="line"><a name="l00148"></a><span class="lineno"> 148</span>  <span class="comment">// current mrs, in which case we skip this block and move on.</span></div>
<div class="line"><a name="l00149"></a><span class="lineno"> 149</span>  <span class="comment">// Otherwise, it computes the maximum distance to the block and</span></div>
<div class="line"><a name="l00150"></a><span class="lineno"> 150</span>  <span class="comment">// returns it in crs.</span></div>
<div class="line"><a name="l00153"></a><span class="lineno"> 153</span>  <span class="comment">// Now compute which region we are going to loop over, adding a</span></div>
<div class="line"><a name="l00154"></a><span class="lineno"> 154</span>  <span class="comment">// displacement for the periodic cases</span></div>
<div class="line"><a name="l00157"></a><span class="lineno"> 157</span>  <span class="comment">// If mrs is bigger than the maximum distance to the block,</span></div>
<div class="line"><a name="l00158"></a><span class="lineno"> 158</span>  <span class="comment">// then we have to test all particles in the block for</span></div>
<div class="line"><a name="l00159"></a><span class="lineno"> 159</span>  <span class="comment">// intersections. Otherwise, we do additional checks and skip</span></div>
<div class="line"><a name="l00160"></a><span class="lineno"> 160</span>  <span class="comment">// those particles which can't possibly intersect the block.</span></div>
<div class="line"><a name="l00171"></a><span class="lineno"> 171</span>  <span class="comment">// If mrs is less than the minimum distance to any untested</span></div>
<div class="line"><a name="l00172"></a><span class="lineno"> 172</span>  <span class="comment">// block, then we are done</span></div>
<div class="line"><a name="l00176"></a><span class="lineno"> 176</span>  <span class="comment">// Load in a block off the worklist, permute it with the</span></div>
<div class="line"><a name="l00177"></a><span class="lineno"> 177</span>  <span class="comment">// symmetry mask, and decode its position. These are all</span></div>
<div class="line"><a name="l00178"></a><span class="lineno"> 178</span>  <span class="comment">// integer bit operations so they should run very fast.</span></div>
<div class="line"><a name="l00184"></a><span class="lineno"> 184</span>  <span class="comment">// Compute the position in the mask of the current block. If</span></div>
<div class="line"><a name="l00185"></a><span class="lineno"> 185</span>  <span class="comment">// this lies outside the mask, then skip it. Otherwise, mark</span></div>
<div class="line"><a name="l00193"></a><span class="lineno"> 193</span>  <span class="comment">// Skip this block if it is further away than the current</span></div>
<div class="line"><a name="l00197"></a><span class="lineno"> 197</span>  <span class="comment">// Now compute which region we are going to loop over, adding a</span></div>
<div class="line"><a name="l00198"></a><span class="lineno"> 198</span>  <span class="comment">// displacement for the periodic cases</span></div>
<div class="line"><a name="l00206"></a><span class="lineno"> 206</span>  <span class="comment">// Do a check to see if we've reached the radius cutoff</span></div>
<div class="line"><a name="l00209"></a><span class="lineno"> 209</span>  <span class="comment">// We were unable to completely compute the cell based on the blocks in</span></div>
<div class="line"><a name="l00210"></a><span class="lineno"> 210</span>  <span class="comment">// the worklist, so now we have to go block by block, reading in items</span></div>
<div class="line"><a name="l00211"></a><span class="lineno"> 211</span>  <span class="comment">// off the list</span></div>
<div class="line"><a name="l00223"></a><span class="lineno"> 223</span>  <span class="comment">// Test the neighbors of the current block, and add them to the</span></div>
<div class="line"><a name="l00224"></a><span class="lineno"> 224</span>  <span class="comment">// block list if they haven't already been tested</span></div>
<div class="line"><a name="l00230"></a><span class="lineno"> 230</span> <span class="comment">/** Scans the six orthogonal neighbors of a given block and adds them to the</span></div>
<div class="line"><a name="l00231"></a><span class="lineno"> 231</span> <span class="comment"> * queue if they haven't been considered already. It assumes that the queue</span></div>
<div class="line"><a name="l00232"></a><span class="lineno"> 232</span> <span class="comment"> * will definitely have enough memory to add six entries at the end.</span></div>
<div class="line"><a name="l00233"></a><span class="lineno"> 233</span> <span class="comment"> * \param[in] (ei,ej,ek) the block to consider.</span></div>
<div class="line"><a name="l00234"></a><span class="lineno"> 234</span> <span class="comment"> * \param[in,out] qu_e a pointer to the end of the queue. */</span></div>
<div class="line"><a name="l00246"></a><span class="lineno"> 246</span> <span class="comment">/** Scans a worklist entry and adds any blocks to the queue</span></div>
<div class="line"><a name="l00247"></a><span class="lineno"> 247</span> <span class="comment"> * \param[in] (ei,ej,ek) the block to consider.</span></div>
<div class="line"><a name="l00248"></a><span class="lineno"> 248</span> <span class="comment"> * \param[in,out] qu_e a pointer to the end of the queue. */</span></div>
<div class="line"><a name="l00266"></a><span class="lineno"> 266</span> <span class="comment">/** This routine computes a Voronoi cell for a single particle in the</span></div>
<div class="line"><a name="l00267"></a><span class="lineno"> 267</span> <span class="comment"> * container. It can be called by the user, but is also forms the core part of</span></div>
<div class="line"><a name="l00268"></a><span class="lineno"> 268</span> <span class="comment"> * several of the main functions, such as store_cell_volumes(), print_all(),</span></div>
<div class="line"><a name="l00269"></a><span class="lineno"> 269</span> <span class="comment"> * and the drawing routines. The algorithm constructs the cell by testing over</span></div>
<div class="line"><a name="l00270"></a><span class="lineno"> 270</span> <span class="comment"> * the neighbors of the particle, working outwards until it reaches those</span></div>
<div class="line"><a name="l00271"></a><span class="lineno"> 271</span> <span class="comment"> * particles which could not possibly intersect the cell. For maximum</span></div>
<div class="line"><a name="l00272"></a><span class="lineno"> 272</span> <span class="comment"> * efficiency, this algorithm is divided into three parts. In the first</span></div>
<div class="line"><a name="l00273"></a><span class="lineno"> 273</span> <span class="comment"> * section, the algorithm tests over the blocks which are in the immediate</span></div>
<div class="line"><a name="l00274"></a><span class="lineno"> 274</span> <span class="comment"> * vicinity of the particle, by making use of one of the precomputed worklists.</span></div>
<div class="line"><a name="l00275"></a><span class="lineno"> 275</span> <span class="comment"> * The code then continues to test blocks on the worklist, but also begins to</span></div>
<div class="line"><a name="l00276"></a><span class="lineno"> 276</span> <span class="comment"> * construct a list of neighboring blocks outside the worklist which may need</span></div>
<div class="line"><a name="l00277"></a><span class="lineno"> 277</span> <span class="comment"> * to be test. In the third section, the routine starts testing these</span></div>
<div class="line"><a name="l00278"></a><span class="lineno"> 278</span> <span class="comment"> * neighboring blocks, evaluating whether or not a particle in them could</span></div>
<div class="line"><a name="l00279"></a><span class="lineno"> 279</span> <span class="comment"> * possibly intersect the cell. For blocks that intersect the cell, it tests</span></div>
<div class="line"><a name="l00280"></a><span class="lineno"> 280</span> <span class="comment"> * the particles in that block, and then adds the block neighbors to the list</span></div>
<div class="line"><a name="l00281"></a><span class="lineno"> 281</span> <span class="comment"> * of potential places to consider.</span></div>
<div class="line"><a name="l00282"></a><span class="lineno"> 282</span> <span class="comment"> * \param[in,out] c a reference to a voronoicell object.</span></div>
<div class="line"><a name="l00283"></a><span class="lineno"> 283</span> <span class="comment"> * \param[in] ijk the index of the block that the test particle is in.</span></div>
<div class="line"><a name="l00284"></a><span class="lineno"> 284</span> <span class="comment"> * \param[in] s the index of the particle within the test block.</span></div>
<div class="line"><a name="l00285"></a><span class="lineno"> 285</span> <span class="comment"> * \param[in] (ci,cj,ck) the coordinates of the block that the test particle is</span></div>
<div class="line"><a name="l00286"></a><span class="lineno"> 286</span> <span class="comment"> * in relative to the container data structure.</span></div>
<div class="line"><a name="l00287"></a><span class="lineno"> 287</span> <span class="comment"> * \return False if the Voronoi cell was completely removed during the</span></div>
<div class="line"><a name="l00288"></a><span class="lineno"> 288</span> <span class="comment"> * computation and has zero volume, true otherwise. */</span></div>
<div class="line"><a name="l00302"></a><span class="lineno"> 302</span>  <span class="comment">// Initialize the Voronoi cell to fill the entire container</span></div>
<div class="line"><a name="l00307"></a><span class="lineno"> 307</span>  <span class="comment">// Test all particles in the particle's local region first</span></div>
<div class="line"><a name="l00325"></a><span class="lineno"> 325</span>  <span class="comment">// Now compute the maximum distance squared from the cell center to a</span></div>
<div class="line"><a name="l00326"></a><span class="lineno"> 326</span>  <span class="comment">// vertex. This is used to cut off the calculation since we only need</span></div>
<div class="line"><a name="l00327"></a><span class="lineno"> 327</span>  <span class="comment">// to test out to twice this range.</span></div>
<div class="line"><a name="l00330"></a><span class="lineno"> 330</span>  <span class="comment">// Now compute the fractional position of the particle within its</span></div>
<div class="line"><a name="l00331"></a><span class="lineno"> 331</span>  <span class="comment">// region and store it in (fx,fy,fz). We use this to compute an index</span></div>
<div class="line"><a name="l00332"></a><span class="lineno"> 332</span>  <span class="comment">// (di,dj,dk) of which subregion the particle is within.</span></div>
<div class="line"><a name="l00337"></a><span class="lineno"> 337</span>  <span class="comment">// The indices (di,dj,dk) tell us which worklist to use, to test the</span></div>
<div class="line"><a name="l00338"></a><span class="lineno"> 338</span>  <span class="comment">// blocks in the optimal order. But we only store worklists for the</span></div>
<div class="line"><a name="l00339"></a><span class="lineno"> 339</span>  <span class="comment">// eighth of the region where di, dj, and dk are all less than half the</span></div>
<div class="line"><a name="l00340"></a><span class="lineno"> 340</span>  <span class="comment">// full grid. The rest of the cases are handled by symmetry. In this</span></div>
<div class="line"><a name="l00341"></a><span class="lineno"> 341</span>  <span class="comment">// section, we detect for these cases, by reflecting high values of di,</span></div>
<div class="line"><a name="l00342"></a><span class="lineno"> 342</span>  <span class="comment">// dj, and dk. For these cases, a mask is constructed in m1 and m2</span></div>
<div class="line"><a name="l00343"></a><span class="lineno"> 343</span>  <span class="comment">// which is used to flip the worklist information when it is loaded.</span></div>
<div class="line"><a name="l00358"></a><span class="lineno"> 358</span>  <span class="comment">// Now compute which worklist we are going to use, and set radp and e to</span></div>
<div class="line"><a name="l00359"></a><span class="lineno"> 359</span>  <span class="comment">// point at the right offsets</span></div>
<div class="line"><a name="l00364"></a><span class="lineno"> 364</span>  <span class="comment">// Read in how many items in the worklist can be tested without having to</span></div>
<div class="line"><a name="l00365"></a><span class="lineno"> 365</span>  <span class="comment">// worry about writing to the mask</span></div>
<div class="line"><a name="l00369"></a><span class="lineno"> 369</span>  <span class="comment">// At the intervals specified by count_list, we recompute the</span></div>
<div class="line"><a name="l00370"></a><span class="lineno"> 370</span>  <span class="comment">// maximum radius squared</span></div>
<div class="line"><a name="l00376"></a><span class="lineno"> 376</span>  <span class="comment">// If mrs is less than the minimum distance to any untested</span></div>
<div class="line"><a name="l00377"></a><span class="lineno"> 377</span>  <span class="comment">// block, then we are done</span></div>
<div class="line"><a name="l00381"></a><span class="lineno"> 381</span>  <span class="comment">// Load in a block off the worklist, permute it with the</span></div>
<div class="line"><a name="l00382"></a><span class="lineno"> 382</span>  <span class="comment">// symmetry mask, and decode its position. These are all</span></div>
<div class="line"><a name="l00383"></a><span class="lineno"> 383</span>  <span class="comment">// integer bit operations so they should run very fast.</span></div>
<div class="line"><a name="l00389"></a><span class="lineno"> 389</span>  <span class="comment">// Check that the worklist position is in range</span></div>
<div class="line"><a name="l00394"></a><span class="lineno"> 394</span>  <span class="comment">// Call the compute_min_max_radius() function. This returns</span></div>
<div class="line"><a name="l00395"></a><span class="lineno"> 395</span>  <span class="comment">// true if the minimum distance to the block is bigger than the</span></div>
<div class="line"><a name="l00396"></a><span class="lineno"> 396</span>  <span class="comment">// current mrs, in which case we skip this block and move on.</span></div>
<div class="line"><a name="l00397"></a><span class="lineno"> 397</span>  <span class="comment">// Otherwise, it computes the maximum distance to the block and</span></div>
<div class="line"><a name="l00398"></a><span class="lineno"> 398</span>  <span class="comment">// returns it in crs.</span></div>
<div class="line"><a name="l00401"></a><span class="lineno"> 401</span>  <span class="comment">// Now compute which region we are going to loop over, adding a</span></div>
<div class="line"><a name="l00402"></a><span class="lineno"> 402</span>  <span class="comment">// displacement for the periodic cases</span></div>
<div class="line"><a name="l00405"></a><span class="lineno"> 405</span>  <span class="comment">// If mrs is bigger than the maximum distance to the block,</span></div>
<div class="line"><a name="l00406"></a><span class="lineno"> 406</span>  <span class="comment">// then we have to test all particles in the block for</span></div>
<div class="line"><a name="l00407"></a><span class="lineno"> 407</span>  <span class="comment">// intersections. Otherwise, we do additional checks and skip</span></div>
<div class="line"><a name="l00408"></a><span class="lineno"> 408</span>  <span class="comment">// those particles which can't possibly intersect the block.</span></div>
<div class="line"><a name="l00433"></a><span class="lineno"> 433</span>  <span class="comment">// If we reach here, we were unable to compute the entire cell using</span></div>
<div class="line"><a name="l00434"></a><span class="lineno"> 434</span>  <span class="comment">// the first part of the worklist. This section of the algorithm</span></div>
<div class="line"><a name="l00435"></a><span class="lineno"> 435</span>  <span class="comment">// continues the worklist, but it now starts preparing the mask that we</span></div>
<div class="line"><a name="l00436"></a><span class="lineno"> 436</span>  <span class="comment">// need if we end up going block by block. We do the same as before,</span></div>
<div class="line"><a name="l00437"></a><span class="lineno"> 437</span>  <span class="comment">// but we put a mark down on the mask for every block that's tested.</span></div>
<div class="line"><a name="l00438"></a><span class="lineno"> 438</span>  <span class="comment">// The worklist also contains information about which neighbors of each</span></div>
<div class="line"><a name="l00439"></a><span class="lineno"> 439</span>  <span class="comment">// block are not also on the worklist, and we start storing those</span></div>
<div class="line"><a name="l00440"></a><span class="lineno"> 440</span>  <span class="comment">// points in a list in case we have to go block by block. Update the</span></div>
<div class="line"><a name="l00441"></a><span class="lineno"> 441</span>  <span class="comment">// mask counter, and if it wraps around then reset the whole mask; that</span></div>
<div class="line"><a name="l00442"></a><span class="lineno"> 442</span>  <span class="comment">// will only happen once every 2^32 tries.</span></div>
<div class="line"><a name="l00451"></a><span class="lineno"> 451</span>  <span class="comment">// At the intervals specified by count_list, we recompute the</span></div>
<div class="line"><a name="l00452"></a><span class="lineno"> 452</span>  <span class="comment">// maximum radius squared</span></div>
<div class="line"><a name="l00458"></a><span class="lineno"> 458</span>  <span class="comment">// If mrs is less than the minimum distance to any untested</span></div>
<div class="line"><a name="l00459"></a><span class="lineno"> 459</span>  <span class="comment">// block, then we are done</span></div>
<div class="line"><a name="l00463"></a><span class="lineno"> 463</span>  <span class="comment">// Load in a block off the worklist, permute it with the</span></div>
<div class="line"><a name="l00464"></a><span class="lineno"> 464</span>  <span class="comment">// symmetry mask, and decode its position. These are all</span></div>
<div class="line"><a name="l00465"></a><span class="lineno"> 465</span>  <span class="comment">// integer bit operations so they should run very fast.</span></div>
<div class="line"><a name="l00471"></a><span class="lineno"> 471</span>  <span class="comment">// Compute the position in the mask of the current block. If</span></div>
<div class="line"><a name="l00472"></a><span class="lineno"> 472</span>  <span class="comment">// this lies outside the mask, then skip it. Otherwise, mark</span></div>
<div class="line"><a name="l00480"></a><span class="lineno"> 480</span>  <span class="comment">// Call the compute_min_max_radius() function. This returns</span></div>
<div class="line"><a name="l00481"></a><span class="lineno"> 481</span>  <span class="comment">// true if the minimum distance to the block is bigger than the</span></div>
<div class="line"><a name="l00482"></a><span class="lineno"> 482</span>  <span class="comment">// current mrs, in which case we skip this block and move on.</span></div>
<div class="line"><a name="l00483"></a><span class="lineno"> 483</span>  <span class="comment">// Otherwise, it computes the maximum distance to the block and</span></div>
<div class="line"><a name="l00484"></a><span class="lineno"> 484</span>  <span class="comment">// returns it in crs.</span></div>
<div class="line"><a name="l00487"></a><span class="lineno"> 487</span>  <span class="comment">// Now compute which region we are going to loop over, adding a</span></div>
<div class="line"><a name="l00488"></a><span class="lineno"> 488</span>  <span class="comment">// displacement for the periodic cases</span></div>
<div class="line"><a name="l00491"></a><span class="lineno"> 491</span>  <span class="comment">// If mrs is bigger than the maximum distance to the block,</span></div>
<div class="line"><a name="l00492"></a><span class="lineno"> 492</span>  <span class="comment">// then we have to test all particles in the block for</span></div>
<div class="line"><a name="l00493"></a><span class="lineno"> 493</span>  <span class="comment">// intersections. Otherwise, we do additional checks and skip</span></div>
<div class="line"><a name="l00494"></a><span class="lineno"> 494</span>  <span class="comment">// those particles which can't possibly intersect the block.</span></div>
<div class="line"><a name="l00518"></a><span class="lineno"> 518</span>  <span class="comment">// If there might not be enough memory on the list for these</span></div>
<div class="line"><a name="l00522"></a><span class="lineno"> 522</span>  <span class="comment">// Test the parts of the worklist element which tell us what</span></div>
<div class="line"><a name="l00523"></a><span class="lineno"> 523</span>  <span class="comment">// neighbors of this block are not on the worklist. Store them</span></div>
<div class="line"><a name="l00524"></a><span class="lineno"> 524</span>  <span class="comment">// on the block list, and mark the mask.</span></div>
<div class="line"><a name="l00528"></a><span class="lineno"> 528</span>  <span class="comment">// Do a check to see if we've reached the radius cutoff</span></div>
<div class="line"><a name="l00531"></a><span class="lineno"> 531</span>  <span class="comment">// We were unable to completely compute the cell based on the blocks in</span></div>
<div class="line"><a name="l00532"></a><span class="lineno"> 532</span>  <span class="comment">// the worklist, so now we have to go block by block, reading in items</span></div>
<div class="line"><a name="l00533"></a><span class="lineno"> 533</span>  <span class="comment">// off the list</span></div>
<div class="line"><a name="l00536"></a><span class="lineno"> 536</span>  <span class="comment">// If we reached the end of the list memory loop back to the</span></div>
<div class="line"><a name="l00540"></a><span class="lineno"> 540</span>  <span class="comment">// Read in a block off the list, and compute the upper and lower</span></div>
<div class="line"><a name="l00541"></a><span class="lineno"> 541</span>  <span class="comment">// coordinates in each of the three dimensions</span></div>
<div class="line"><a name="l00547"></a><span class="lineno"> 547</span>  <span class="comment">// Carry out plane tests to see if any particle in this block</span></div>
<div class="line"><a name="l00548"></a><span class="lineno"> 548</span>  <span class="comment">// could possibly intersect the cell</span></div>
<div class="line"><a name="l00593"></a><span class="lineno"> 593</span>  <span class="comment">// Now compute the region that we are going to test over, and</span></div>
<div class="line"><a name="l00594"></a><span class="lineno"> 594</span>  <span class="comment">// set a displacement vector for the periodic cases</span></div>
<div class="line"><a name="l00597"></a><span class="lineno"> 597</span>  <span class="comment">// Loop over all the elements in the block to test for cuts. It</span></div>
<div class="line"><a name="l00598"></a><span class="lineno"> 598</span>  <span class="comment">// would be possible to exclude some of these cases by testing</span></div>
<div class="line"><a name="l00599"></a><span class="lineno"> 599</span>  <span class="comment">// against mrs, but this will probably not save time.</span></div>
<div class="line"><a name="l00612"></a><span class="lineno"> 612</span>  <span class="comment">// If there's not much memory on the block list then add more</span></div>
<div class="line"><a name="l00615"></a><span class="lineno"> 615</span>  <span class="comment">// Test the neighbors of the current block, and add them to the</span></div>
<div class="line"><a name="l00616"></a><span class="lineno"> 616</span>  <span class="comment">// block list if they haven't already been tested</span></div>
<div class="line"><a name="l00623"></a><span class="lineno"> 623</span> <span class="comment">/** This function checks to see whether a particular block can possibly have</span></div>
<div class="line"><a name="l00624"></a><span class="lineno"> 624</span> <span class="comment"> * any intersection with a Voronoi cell, for the case when the closest point</span></div>
<div class="line"><a name="l00625"></a><span class="lineno"> 625</span> <span class="comment"> * from the cell center to the block is at a corner.</span></div>
<div class="line"><a name="l00626"></a><span class="lineno"> 626</span> <span class="comment"> * \param[in,out] c a reference to a Voronoi cell.</span></div>
<div class="line"><a name="l00627"></a><span class="lineno"> 627</span> <span class="comment"> * \param[in] (xl,yl,zl) the relative coordinates of the corner of the block</span></div>
<div class="line"><a name="l00628"></a><span class="lineno"> 628</span> <span class="comment"> * closest to the cell center.</span></div>
<div class="line"><a name="l00629"></a><span class="lineno"> 629</span> <span class="comment"> * \param[in] (xh,yh,zh) the relative coordinates of the corner of the block</span></div>
<div class="line"><a name="l00630"></a><span class="lineno"> 630</span> <span class="comment"> * furthest away from the cell center.</span></div>
<div class="line"><a name="l00631"></a><span class="lineno"> 631</span> <span class="comment"> * \return False if the block may intersect, true if does not. */</span></div>
<div class="line"><a name="l00645"></a><span class="lineno"> 645</span> <span class="comment">/** This function checks to see whether a particular block can possibly have</span></div>
<div class="line"><a name="l00646"></a><span class="lineno"> 646</span> <span class="comment"> * any intersection with a Voronoi cell, for the case when the closest point</span></div>
<div class="line"><a name="l00647"></a><span class="lineno"> 647</span> <span class="comment"> * from the cell center to the block is on an edge which points along the x</span></div>
<div class="line"><a name="l00649"></a><span class="lineno"> 649</span> <span class="comment"> * \param[in,out] c a reference to a Voronoi cell.</span></div>
<div class="line"><a name="l00650"></a><span class="lineno"> 650</span> <span class="comment"> * \param[in] (x0,x1) the minimum and maximum relative x coordinates of the</span></div>
<div class="line"><a name="l00652"></a><span class="lineno"> 652</span> <span class="comment"> * \param[in] (yl,zl) the relative y and z coordinates of the corner of the</span></div>
<div class="line"><a name="l00653"></a><span class="lineno"> 653</span> <span class="comment"> * block closest to the cell center.</span></div>
<div class="line"><a name="l00654"></a><span class="lineno"> 654</span> <span class="comment"> * \param[in] (yh,zh) the relative y and z coordinates of the corner of the</span></div>
<div class="line"><a name="l00655"></a><span class="lineno"> 655</span> <span class="comment"> * block furthest away from the cell center.</span></div>
<div class="line"><a name="l00656"></a><span class="lineno"> 656</span> <span class="comment"> * \return False if the block may intersect, true if does not. */</span></div>
<div class="line"><a name="l00670"></a><span class="lineno"> 670</span> <span class="comment">/** This function checks to see whether a particular block can possibly have</span></div>
<div class="line"><a name="l00671"></a><span class="lineno"> 671</span> <span class="comment"> * any intersection with a Voronoi cell, for the case when the closest point</span></div>
<div class="line"><a name="l00672"></a><span class="lineno"> 672</span> <span class="comment"> * from the cell center to the block is on an edge which points along the y</span></div>
<div class="line"><a name="l00674"></a><span class="lineno"> 674</span> <span class="comment"> * \param[in,out] c a reference to a Voronoi cell.</span></div>
<div class="line"><a name="l00675"></a><span class="lineno"> 675</span> <span class="comment"> * \param[in] (y0,y1) the minimum and maximum relative y coordinates of the</span></div>
<div class="line"><a name="l00677"></a><span class="lineno"> 677</span> <span class="comment"> * \param[in] (xl,zl) the relative x and z coordinates of the corner of the</span></div>
<div class="line"><a name="l00678"></a><span class="lineno"> 678</span> <span class="comment"> * block closest to the cell center.</span></div>
<div class="line"><a name="l00679"></a><span class="lineno"> 679</span> <span class="comment"> * \param[in] (xh,zh) the relative x and z coordinates of the corner of the</span></div>
<div class="line"><a name="l00680"></a><span class="lineno"> 680</span> <span class="comment"> * block furthest away from the cell center.</span></div>
<div class="line"><a name="l00681"></a><span class="lineno"> 681</span> <span class="comment"> * \return False if the block may intersect, true if does not. */</span></div>
<div class="line"><a name="l00695"></a><span class="lineno"> 695</span> <span class="comment">/** This function checks to see whether a particular block can possibly have</span></div>
<div class="line"><a name="l00696"></a><span class="lineno"> 696</span> <span class="comment"> * any intersection with a Voronoi cell, for the case when the closest point</span></div>
<div class="line"><a name="l00697"></a><span class="lineno"> 697</span> <span class="comment"> * from the cell center to the block is on an edge which points along the z</span></div>
<div class="line"><a name="l00699"></a><span class="lineno"> 699</span> <span class="comment"> * \param[in,out] c a reference to a Voronoi cell.</span></div>
<div class="line"><a name="l00700"></a><span class="lineno"> 700</span> <span class="comment"> * \param[in] (z0,z1) the minimum and maximum relative z coordinates of the block.</span></div>
<div class="line"><a name="l00701"></a><span class="lineno"> 701</span> <span class="comment"> * \param[in] (xl,yl) the relative x and y coordinates of the corner of the</span></div>
<div class="line"><a name="l00702"></a><span class="lineno"> 702</span> <span class="comment"> * block closest to the cell center.</span></div>
<div class="line"><a name="l00703"></a><span class="lineno"> 703</span> <span class="comment"> * \param[in] (xh,yh) the relative x and y coordinates of the corner of the</span></div>
<div class="line"><a name="l00704"></a><span class="lineno"> 704</span> <span class="comment"> * block furthest away from the cell center.</span></div>
<div class="line"><a name="l00705"></a><span class="lineno"> 705</span> <span class="comment"> * \return False if the block may intersect, true if does not. */</span></div>
<div class="line"><a name="l00719"></a><span class="lineno"> 719</span> <span class="comment">/** This function checks to see whether a particular block can possibly have</span></div>
<div class="line"><a name="l00720"></a><span class="lineno"> 720</span> <span class="comment"> * any intersection with a Voronoi cell, for the case when the closest point</span></div>
<div class="line"><a name="l00721"></a><span class="lineno"> 721</span> <span class="comment"> * from the cell center to the block is on a face aligned with the x direction.</span></div>
<div class="line"><a name="l00722"></a><span class="lineno"> 722</span> <span class="comment"> * \param[in,out] c a reference to a Voronoi cell.</span></div>
<div class="line"><a name="l00723"></a><span class="lineno"> 723</span> <span class="comment"> * \param[in] xl the minimum distance from the cell center to the face.</span></div>
<div class="line"><a name="l00724"></a><span class="lineno"> 724</span> <span class="comment"> * \param[in] (y0,y1) the minimum and maximum relative y coordinates of the</span></div>
<div class="line"><a name="l00726"></a><span class="lineno"> 726</span> <span class="comment"> * \param[in] (z0,z1) the minimum and maximum relative z coordinates of the</span></div>
<div class="line"><a name="l00728"></a><span class="lineno"> 728</span> <span class="comment"> * \return False if the block may intersect, true if does not. */</span></div>
<div class="line"><a name="l00740"></a><span class="lineno"> 740</span> <span class="comment">/** This function checks to see whether a particular block can possibly have</span></div>
<div class="line"><a name="l00741"></a><span class="lineno"> 741</span> <span class="comment"> * any intersection with a Voronoi cell, for the case when the closest point</span></div>
<div class="line"><a name="l00742"></a><span class="lineno"> 742</span> <span class="comment"> * from the cell center to the block is on a face aligned with the y direction.</span></div>
<div class="line"><a name="l00743"></a><span class="lineno"> 743</span> <span class="comment"> * \param[in,out] c a reference to a Voronoi cell.</span></div>
<div class="line"><a name="l00744"></a><span class="lineno"> 744</span> <span class="comment"> * \param[in] yl the minimum distance from the cell center to the face.</span></div>
<div class="line"><a name="l00745"></a><span class="lineno"> 745</span> <span class="comment"> * \param[in] (x0,x1) the minimum and maximum relative x coordinates of the</span></div>
<div class="line"><a name="l00747"></a><span class="lineno"> 747</span> <span class="comment"> * \param[in] (z0,z1) the minimum and maximum relative z coordinates of the</span></div>
<div class="line"><a name="l00749"></a><span class="lineno"> 749</span> <span class="comment"> * \return False if the block may intersect, true if does not. */</span></div>
<div class="line"><a name="l00761"></a><span class="lineno"> 761</span> <span class="comment">/** This function checks to see whether a particular block can possibly have</span></div>
<div class="line"><a name="l00762"></a><span class="lineno"> 762</span> <span class="comment"> * any intersection with a Voronoi cell, for the case when the closest point</span></div>
<div class="line"><a name="l00763"></a><span class="lineno"> 763</span> <span class="comment"> * from the cell center to the block is on a face aligned with the z direction.</span></div>
<div class="line"><a name="l00764"></a><span class="lineno"> 764</span> <span class="comment"> * \param[in,out] c a reference to a Voronoi cell.</span></div>
<div class="line"><a name="l00765"></a><span class="lineno"> 765</span> <span class="comment"> * \param[in] zl the minimum distance from the cell center to the face.</span></div>
<div class="line"><a name="l00766"></a><span class="lineno"> 766</span> <span class="comment"> * \param[in] (x0,x1) the minimum and maximum relative x coordinates of the</span></div>
<div class="line"><a name="l00768"></a><span class="lineno"> 768</span> <span class="comment"> * \param[in] (y0,y1) the minimum and maximum relative y coordinates of the</span></div>
<div class="line"><a name="l00770"></a><span class="lineno"> 770</span> <span class="comment"> * \return False if the block may intersect, true if does not. */</span></div>
<div class="line"><a name="l00783"></a><span class="lineno"> 783</span> <span class="comment">/** This routine checks to see whether a point is within a particular distance</span></div>
<div class="line"><a name="l00784"></a><span class="lineno"> 784</span> <span class="comment"> * of a nearby region. If the point is within the distance of the region, then</span></div>
<div class="line"><a name="l00785"></a><span class="lineno"> 785</span> <span class="comment"> * the routine returns true, and computes the maximum distance from the point</span></div>
<div class="line"><a name="l00786"></a><span class="lineno"> 786</span> <span class="comment"> * to the region. Otherwise, the routine returns false.</span></div>
<div class="line"><a name="l00787"></a><span class="lineno"> 787</span> <span class="comment"> * \param[in] (di,dj,dk) the position of the nearby region to be tested,</span></div>
<div class="line"><a name="l00788"></a><span class="lineno"> 788</span> <span class="comment"> * relative to the region that the point is in.</span></div>
<div class="line"><a name="l00789"></a><span class="lineno"> 789</span> <span class="comment"> * \param[in] (fx,fy,fz) the displacement of the point within its region.</span></div>
<div class="line"><a name="l00790"></a><span class="lineno"> 790</span> <span class="comment"> * \param[in] (gxs,gys,gzs) the maximum squared distances from the point to the</span></div>
<div class="line"><a name="l00791"></a><span class="lineno"> 791</span> <span class="comment"> * sides of its region.</span></div>
<div class="line"><a name="l00792"></a><span class="lineno"> 792</span> <span class="comment"> * \param[out] crs a reference in which to return the maximum distance to the</span></div>
<div class="line"><a name="l00793"></a><span class="lineno"> 793</span> <span class="comment"> * region (only computed if the routine returns false).</span></div>
<div class="line"><a name="l00794"></a><span class="lineno"> 794</span> <span class="comment"> * \param[in] mrs the distance to be tested.</span></div>
<div class="line"><a name="l00795"></a><span class="lineno"> 795</span> <span class="comment"> * \return True if the region is further away than mrs, false if the region in</span></div>
<div class="line"><a name="l00796"></a><span class="lineno"> 796</span> <span class="comment"> * within mrs. */</span></div>
<div class="line"><a name="l00938"></a><span class="lineno"> 938</span>  voro_fatal_error(<span class="stringliteral">"Min/max radius function called for central block, which should never\nhappen."</span>,<a class="code" href="config_8hh.html#ad8e0de9d48da06e86dd87884e4a2d47e">VOROPP_INTERNAL_ERROR</a>);</div>
<div class="line"><a name="l00964"></a><span class="lineno"> 964</span> <span class="comment">/** Adds memory to the queue.</span></div>
<div class="line"><a name="l00965"></a><span class="lineno"> 965</span> <span class="comment"> * \param[in,out] qu_s a reference to the queue start pointer.</span></div>
<div class="line"><a name="l00966"></a><span class="lineno"> 966</span> <span class="comment"> * \param[in,out] qu_e a reference to the queue end pointer. */</span></div>