src/Particle/ParticleInteractAttrib.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 "Particle/ParticleInteractAttrib.h"
00028 #include "Message/Message.h"
00029 #include "Profile/Profiler.h"
00030 
00031 
00033 // put the data for M particles into a message, starting from index I.
00034 // This will either put in local or ghost particle data, but not both.
00035 template<class T>
00036 size_t
00037 ParticleInteractAttrib<T>::putMessage(Message& msg,
00038                                       size_t M, size_t I) {
00039   TAU_PROFILE("ParticleInteractAttrib::putMessage()", 
00040     "unsigned (Message, unsigned, unsigned)", TAU_PARTICLE); 
00041 
00042   if (I >= this->size()) {
00043     // put in ghost particles
00044     typename ParticleList_t::iterator currp = GhostList.begin() + (I - this->size());
00045     typename ParticleList_t::iterator endp = currp + M;
00046     ::putMessage(msg, currp, endp);
00047   }
00048   else {
00049     typename ParticleList_t::iterator currp = this->ParticleList.begin() + I;
00050     typename ParticleList_t::iterator endp = currp + M;
00051     ::putMessage(msg, currp, endp);
00052   }
00053   return M;
00054 }
00055 
00056 
00058 // Delete the ghost attrib storage for M particles, starting at pos I.
00059 // Items from the end of the list are moved up to fill in the space.
00060 // Return the number of items actually destroyed.
00061 template<class T>
00062 size_t
00063 ParticleInteractAttrib<T>::ghostDestroy(size_t M, size_t I) {
00064   TAU_PROFILE("ParticleInteractAttrib::ghostDestroy()", 
00065     "unsigned (unsigned, unsigned)", TAU_PARTICLE); 
00066 
00067   if (M > 0) {
00068     // get iterators for where the data to be deleted begins, and where
00069     // the data we copy from the end begins
00070     typename ParticleList_t::iterator putloc = GhostList.begin() + I;
00071     typename ParticleList_t::iterator getloc = GhostList.end() - M;
00072     typename ParticleList_t::iterator endloc = GhostList.end();
00073 
00074     // make sure we do not copy too much
00075     if ((I + M) > (GhostList.size() - M))
00076       getloc = putloc + M;
00077 
00078     // copy over the data
00079     while (getloc != endloc)
00080       *putloc++ = *getloc++;
00081 
00082     // delete the last M items
00083     GhostList.erase(GhostList.end() - M, GhostList.end());
00084   }
00085 
00086   return M;
00087 }
00088 
00089 
00091 // Get ghost data out of a Message containing M particle's attribute data,
00092 // and store it here.  Data is appended to the end of the list.  Return
00093 // the number of particles retrieved.
00094 template<class T>
00095 size_t
00096 ParticleInteractAttrib<T>::ghostGetMessage(Message& msg, size_t M) {
00097   TAU_PROFILE("ParticleInteractAttrib::ghostGetMessage()", 
00098     "unsigned (Message, unsigned)", TAU_PARTICLE); 
00099 
00100   size_t currsize = GhostList.size();
00101   GhostList.insert(GhostList.end(), M, T());
00102   ::getMessage_iter(msg, GhostList.begin() + currsize);
00103   return M;
00104 }
00105 
00106 
00108 // Print out information for debugging purposes.  This version just
00109 // prints out static information, so it is static
00110 template<class T>
00111 void ParticleInteractAttrib<T>::printDebug(Inform& o) {
00112   TAU_PROFILE("ParticleInteractAttrib::printDebug()", 
00113     "void (Inform)", TAU_PARTICLE | TAU_IO); 
00114 
00115   o << "PAttr: size = " << this->ParticleList.size()
00116     << ", capacity = " << this->ParticleList.capacity()
00117     << ", ghosts = " << GhostList.size();
00118 }
00119 
00120 
00121 /***************************************************************************
00122  * $RCSfile: ParticleInteractAttrib.cpp,v $   $Author: adelmann $
00123  * $Revision: 1.1.1.1 $   $Date: 2003/01/23 07:40:29 $
00124  * IPPL_VERSION_ID: $Id: ParticleInteractAttrib.cpp,v 1.1.1.1 2003/01/23 07:40:29 adelmann Exp $ 
00125  ***************************************************************************/

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