src/Particle/PAssign.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/PAssign.h"
00028 #include "Particle/PAssignDefs.h"
00029 #include "Particle/ParticleAttrib.h"
00030 #include "Particle/ParticleAttribElem.h"
00031 #include "PETE/IpplExpressions.h"
00032 #include "Utility/IpplStats.h"
00033 #include "Profile/Profiler.h"
00034 
00035 
00037 
00038 template<class T, unsigned Dim, class RHS, class OP>
00039 void
00040 assign(const ParticleAttribElem<T,Dim>& ca, RHS b, OP op)
00041 {
00042   TAU_TYPE_STRING(taustr, "void (" + CT(ca) + ", " + CT(b) + ", " 
00043     + CT(op) + " )" );
00044   TAU_PROFILE("assign()", taustr, TAU_ASSIGN | TAU_PARTICLE);
00045 
00046   // Cast away Const-ness.  Aarrgghh!!
00047   ParticleAttribElem<T,Dim>& a = (ParticleAttribElem<T,Dim>&) ca;
00048   typename RHS::Wrapped& bb = b.PETE_unwrap();
00049 
00050   // Begin/End iterators for the ParticleAttribElem on the left hand side.
00051   typename ParticleAttribElem<T,Dim>::iterator pa = a.begin(), aend = a.end();
00052   for ( ; pa != aend ; ++pa) {
00053     PETE_apply( op, *pa, for_each(bb,EvalFunctor_0()) );
00054     for_each(bb,PETE_Increment(),PETE_NullCombiner());
00055   }
00056 
00057   INCIPPLSTAT(incParticleExpressions);
00058 }
00059 
00060 template<class T, class RHS, class OP>
00061 void
00062 assign(const ParticleAttrib<T>& ca, RHS b, OP op)
00063 {
00064   TAU_TYPE_STRING(taustr, "void (" + CT(ca) + ", " + CT(b) + ", " 
00065     + CT(op)  + " )" );
00066   TAU_PROFILE("assign()", taustr, TAU_ASSIGN | TAU_PARTICLE);
00067 
00068   // Cast away Const-ness.  Aarrgghh!!
00069   ParticleAttrib<T>& a = (ParticleAttrib<T>&) ca;
00070   typename RHS::Wrapped& bb = b.PETE_unwrap();
00071 
00072   // Begin and end iterators for the ParticleAttrib on the left hand side.
00073   typename ParticleAttrib<T>::iterator pa = a.begin(), aend = a.end();
00074   for ( ; pa != aend ; ++pa) {
00075     PETE_apply( op, *pa, for_each(bb,EvalFunctor_0()) );
00076     for_each(bb,PETE_Increment(),PETE_NullCombiner());
00077   }
00078 
00079   INCIPPLSTAT(incParticleExpressions);
00080 }
00081 
00083 
00084 /***************************************************************************
00085  * $RCSfile: PAssign.cpp,v $   $Author: adelmann $
00086  * $Revision: 1.1.1.1 $   $Date: 2003/01/23 07:40:28 $
00087  * IPPL_VERSION_ID: $Id: PAssign.cpp,v 1.1.1.1 2003/01/23 07:40:28 adelmann Exp $ 
00088  ***************************************************************************/

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