On Wed, 28 Oct 2009, Derek Gaston wrote: > On Oct 28, 2009, at 11:16 AM, Roy Stogner wrote: > >> If only for backwards compatibility's sake, I'd rather not remove it. >> But since that seems to be a popular option, why not avoid caching it >> and just make it an O(N) operation? Instead of looping over elements >> and counting unique subdomains during prepare_for_use(), we could do >> so during MeshBase::n_subdomains(). Then if nobody really uses that >> function they don't incur any cost, but if someone does need it it's >> there. > > The one time I know that everyone's code calls n_subdomains() is in > mesh->print_info().... so we would incur an O(N) hit for that function. I'm > personally not worried by that (our current codes call that about once per > timestep depending on adaptivitiy)... just thought I would point it out.
Like I mentioned in a previous message, print_info() is already O(N_elem). But now I'm worried: I don't want to inadvertently make n_subdomains() into anything *worse* than O(N_elem). I don't write any new mesh code without making sure it's ParallelMesh compatible, but the communication issue here has me wary. Does MPI have any good way to do global set unions? If not, how do I write Parallel::union(std::set<T>&)? My best idea so far: Processor 2*N+1 sends its set to Processor 2*N, which unions it with its own set. Processor 4*N+2 sends its set to Processor 4*N, which unions it with its own set. (repeat until you run out of processors) Processor 0 broadcasts its (now complete) set to everyone else. For this particular application, we'd instead use Parallel::union(std::set<T>&, unsigned int root_id=0), which applies an offset to get the complete set on root_id, but then skips the broadcast (since for n_subdomains() we only need to broadcast the set size, not its contents). --- Roy ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ Libmesh-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/libmesh-devel
