# HG changeset patch # User Stephen Skory # Date 1247629738 25200 # Branch hopwrap # Node ID 7098c3bac6551b9e89ebdf10799d328c1624c2fd # Parent be5dd4b53fe3503cc73c672e9c6b82312230e90e About to write the function to update chain_densest_n to consider cross-task chains. diff -r be5dd4b53fe3503cc73c672e9c6b82312230e90e -r 7098c3bac6551b9e89ebdf10799d328c1624c2fd yt/lagos/HaloFinding.py --- a/yt/lagos/HaloFinding.py Tue Jul 14 18:38:30 2009 -0700 +++ b/yt/lagos/HaloFinding.py Tue Jul 14 20:48:58 2009 -0700 @@ -454,12 +454,12 @@ self.particle_index_map = self._mpi_catarray(self.particle_index_map) if len(self.particle_index_map) == 0: # none of the chains cross the boundaries, so we're done here. - mylog.info("No groups need to be merged.") + mylog.info("No chains need to be merged.") return # but if there are crossings, move forward. # On each processor, if one of the particles it owns (in the real - # region!) is in the map, add an entry to the task_group_map - self.task_group_map = [] + # region!) is in the map, add an entry to the task_chain_map + self.task_chain_map = [] particle_map_column = self.particle_index_map[:,0] for index,ownPart in enumerate(self.particle_fields["particle_index"]): if ownPart in particle_map_column: @@ -469,33 +469,72 @@ if self.is_inside[index]: #mylog.info('point %s bound %s ownPart %s' % \ #(str(point),str(self.bounds),str(ownPart))) - # find out which local group this particle lives in - local_groupID = self.particle_fields["tags"][index] + # find out which local chain this particle lives in + local_chainID = self.particle_fields["tags"][index] # add a mapping, if it isn't already there # put lower-indexed task ID first if self.particle_index_map[remote_index][1] < self.mine: map = [self.particle_index_map[remote_index][1],\ self.particle_index_map[remote_index][2], \ - self.mine, local_groupID] + self.mine, local_chainID] else: - map = [self.mine, local_groupID, \ + map = [self.mine, local_chainID, \ self.particle_index_map[remote_index][1],\ self.particle_index_map[remote_index][2] ] #mylog.info("map %s" % str(map)) - if map not in self.task_group_map: - self.task_group_map.append(map) - # concatenate the task_group_map on all tasks - self.task_group_map = self._mpi_catlist(self.task_group_map) - #mylog.info("end %s" % str(self.task_group_map)) + if map not in self.task_chain_map: + self.task_chain_map.append(map) + # concatenate the task_chain_map on all tasks + self.task_chain_map = self._mpi_catlist(self.task_chain_map) + #mylog.info("end %s" % str(self.task_chain_map)) def _build_task_densest_in_chain(self): """ 'Upgrade' self.densest_in_chain to include the task each chain is on. + The result will be accessed: self.densest_in_chain[task][chainID]. """ temp = {} temp[self.mine] = self.densest_in_chain self._mpi_joindict(temp) - self.densest_in_chain = temp.copy() + self.densest_in_chain = temp + + def _build_task_chain_densest_n(self): + """ + 'Upgrade' self.chain_densest_n to include the task each chain is on. + For now we'll be cheap and make the keys into strings, with the form + 'taskID,chainID' + """ + temp = {} + for chain_high in self.chain_densest_n: + h = '%d,%d' % (self.mine, chain_high) + temp[h] = {} + for chain_low in self.chain_densest_n[chain_high]: + l = '%d,%d' % (self.mine, chain_low) + temp[h][l] = self.chain_densest_n[chain_high][chain_low] + self._mpi_joindict(temp) + self.chain_densest_n = temp + + def _update_chain_densest_n(self): + """ + Update chain_densest_n to reflect the potential neighbors from + chain_potential_n. This involves figuring out the real + particle_index for each of the potential partcles, and communicating + this to the neighboring task. Then, if that task finds that particle + is in a chain on in its domain, adding that information to a list which + is then communicated back to the first. chain_densest_n is updated to + consider the neighboring chains, taking note of identified chains in + task_chain_map. + """ + + def _update_chain_densest_n(self): + """ + Using chain_potential_n as a source of potential mergings between + chains, update chain_densest_n while refering to self.task_chain_map + as to not merge chains that are already identified as being + connected. + """ + + def _run_finder(self): xt = self.particle_fields["particle_position_x"] - 0.961 @@ -518,6 +557,7 @@ self.padded_particles = obj.padded_particles self.is_inside = obj.is_inside self.densest_in_chain = obj.densest_in_chain + self.chain_densest_n = obj.chain_densest_n self.particle_fields["densities"] = self.densities self.particle_fields["tags"] = self.tags if self._distributed: @@ -525,6 +565,7 @@ #nhalos = sum(halo_info.values()) self._build_task_chain_map() self._build_task_densest_in_chain() + self._build_task_chain_densest_n() def write_out(self, filename="chainHopAnalysis.out"): HaloList.write_out(self, filename)