src/SubParticle/SubParticleAssign.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 /***************************************************************************
00003  *
00004  * The IPPL Framework
00005  * 
00006  *
00007  * Visit http://people.web.psi.ch/adelmann/ for more details
00008  *
00009  ***************************************************************************/
00010 
00011 #ifndef SUB_PARTICLE_ASSIGN_H
00012 #define SUB_PARTICLE_ASSIGN_H
00013 
00014 // include files
00015 #include "Field/Assign.h"
00016 #include "SubParticle/SubParticleAttrib.h"
00017 
00018 
00019 /***************************************************************************
00020  Versions of the assign function used to assign values to a SubParticleAttrib
00021  in an expression.  SubParticleAssign uses information in SubParticleAssignDefs
00022  for specific definitions of for_each operations used in assign.
00023 
00024  This assignment is used to gather values from an expression at selected
00025  points into a ParticleAttrib.  The points used are stored in an SIndex
00026  object, and only the local points are gathered.  So, at the end, you will
00027  have a ParticleAttrib on each processor with a length equal to the number
00028  of points in the SIndex object.  The syntax for this looks like
00029 
00030    SIndex<Dim> S = (some expression)
00031    ParticleAttrib<T> P;
00032    BareField<T,Dim> A, B, C;
00033    P[S] = A[S] * B[S] + C[S];
00034 
00035  Or, you can use +=, -=, etc, which requires that the attribute already
00036  be of the right length.
00037 
00038  ***************************************************************************/
00039 
00040 
00042 // SubParticleAttrib op Expression 
00043 template<class PA, class T, unsigned Dim, class RHS, class OP>
00044 void
00045 assign(SubParticleAttrib<PA,T,Dim> a, RHS b, OP op, ExprTag<true>);
00046 
00047 
00049 // SubBareField op constant
00050 template<class PA, class T, unsigned Dim, class OP>
00051 inline void
00052 assign(SubParticleAttrib<PA,T,Dim> a, const T& b, OP op, ExprTag<true>) {
00053   assign(a, PETE_Scalar<T>(b), op, ExprTag<true>());
00054 }
00055 
00056 
00058 // SubParticleAttrib op constant
00059 #define SUBPARTICLE_ASSIGNMENT_OPERATORS(FUNC,OP)               \
00060                                                                 \
00061 template<class PA, class T, unsigned Dim>                       \
00062 inline void                                                     \
00063 FUNC(const SubParticleAttrib<PA,T,Dim>& lhs, const T& rhs)      \
00064 {                                                               \
00065   assign(lhs, PETE_Scalar<T>(rhs), OP(), ExprTag<true>());      \
00066 }
00067 
00068 
00069 SUBPARTICLE_ASSIGNMENT_OPERATORS(assign,OpAssign)
00070 SUBPARTICLE_ASSIGNMENT_OPERATORS(operator<<,OpAssign)
00071 SUBPARTICLE_ASSIGNMENT_OPERATORS(operator+=,OpAddAssign)
00072 SUBPARTICLE_ASSIGNMENT_OPERATORS(operator-=,OpSubtractAssign)
00073 SUBPARTICLE_ASSIGNMENT_OPERATORS(operator*=,OpMultipplyAssign)
00074 SUBPARTICLE_ASSIGNMENT_OPERATORS(operator/=,OpDivideAssign)
00075 SUBPARTICLE_ASSIGNMENT_OPERATORS(mineq,OpMinAssign)
00076 SUBPARTICLE_ASSIGNMENT_OPERATORS(maxeq,OpMaxAssign)
00077 
00078 #include "SubParticle/SubParticleAssign.cpp"
00079 
00080 #endif
00081 
00082 /***************************************************************************
00083  * $RCSfile: SubParticleAssign.h,v $   $Author: adelmann $
00084  * $Revision: 1.1.1.1 $   $Date: 2003/01/23 07:40:33 $
00085  * IPPL_VERSION_ID: $Id: SubParticleAssign.h,v 1.1.1.1 2003/01/23 07:40:33 adelmann Exp $ 
00086  ***************************************************************************/

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