src/FieldLayout/ConejoBalancer.cpp

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 /***************************************************************************
00003  *
00004  * The IPPL Framework
00005  * 
00006  * This program was prepared by PSI. 
00007  * All rights in the program are reserved by PSI.
00008  * Neither PSI nor the author(s)
00009  * makes any warranty, express or implied, or assumes any liability or
00010  * responsibility for the use of this software
00011  *
00012  * Visit http://www.acl.lanl.gov/POOMS for more details
00013  *
00014  ***************************************************************************/
00015 
00016 // -*- C++ -*-
00017 /***************************************************************************
00018  *
00019  * The IPPL Framework
00020  * 
00021  *
00022  * Visit http://people.web.psi.ch/adelmann/ for more details
00023  *
00024  ***************************************************************************/
00025 
00026 // include files
00027 #include "FieldLayout/ConejoBalancer.h"
00028 #include "FieldLayout/MultiBalancer.h"
00029 #include "Utility/IpplInfo.h"
00030 
00032 
00033 //
00034 // reduceLocalWeights
00035 //
00036 // Input: 
00037 //   BareField<T,D> with weights
00038 //   bool dropCompressed, which is true if compressed vnodes in weights
00039 //        should have the weight of a single element instead of multipplied
00040 //        by the number of elements.
00041 // Outout: a container of doubles.
00042 //
00043 // Given a BareField and a container,
00044 // loop over each vnode, finding the maximum weight
00045 // on each vnode.
00046 // Put those reduced weights in the container.
00047 //
00048 // This is a bare function, since it does not depend on anything
00049 // in the class ConejoBalancer.
00050 // This is an inline function so it does not generate an additional
00051 // prelink step.
00052 //
00053 
00054 template<class T, unsigned int D>
00055 inline void
00056 reduceLocalWeights(BareField<T,D>& weights, 
00057                    vector<double>& vnodeWeights,
00058                    bool dropCompressed)
00059 {
00060   // Get an iterator and loop over the LFields of the BareField.
00061   typename BareField<T,D>::iterator_if lf = weights.begin_if(); 
00062   for ( ; lf != weights.end_if() ; ++lf )
00063     {
00064       // Get an iterator and loop over the contents of this LField.
00065       typename LField<T,D>::iterator lp = (*lf).second->begin(); 
00066 
00067       // A place to record the total weight.
00068       // Start with just the first element.
00069       double x = *lp;
00070 
00071       // If the LField is compressed and and dropCompressed is true,
00072       // then the weight from this vnode comes from just the one element.
00073       if ( !(dropCompressed && (*lf).second->IsCompressed()) )
00074         {
00075           // Add up all the values in the vnode.
00076           for ( ++lp ; lp != (*lf).second->end() ; ++lp )
00077             x += *lp;
00078         }
00079 
00080       // Append the largest value to the container.
00081       vnodeWeights.push_back( x );
00082     }
00083 }
00084 
00086 //
00087 // PRIVATE member functions
00088 //
00090 //mwerks Moved into class definition (.h file).
00091 
00092 
00093 /***************************************************************************
00094  * $RCSfile: ConejoBalancer.cpp,v $   $Author: adelmann $
00095  * $Revision: 1.1.1.1 $   $Date: 2003/01/23 07:40:27 $
00096  * IPPL_VERSION_ID: $Id: ConejoBalancer.cpp,v 1.1.1.1 2003/01/23 07:40:27 adelmann Exp $ 
00097  ***************************************************************************/

Generated on Mon Jan 16 13:23:46 2006 for IPPL by  doxygen 1.4.6