src/Particle/IntNGP.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 INT_NGP_H
00012 #define INT_NGP_H
00013 
00014 /* IntNGP.h -- Definition of simple class to perform nearest-grid-point
00015    interpolation of data for a single particle to or from IPPL Field. */
00016 
00017 // include files
00018 #include "Particle/Interpolator.h"
00019 #include "Field/Field.h"
00020 
00021 
00022 // forward declaration
00023 class IntNGP;
00024 
00025 // specialization of InterpolatorTraits
00026 
00027 template <class T, unsigned Dim>
00028 struct InterpolatorTraits<T,Dim,IntNGP> {
00029   typedef NDIndex<Dim> Cache_t;
00030 };
00031 
00032 
00033 // IntNGP class definition
00034 class IntNGP : public Interpolator {
00035 
00036 public:
00037   // constructor/destructor
00038   IntNGP() {}
00039   ~IntNGP() {}
00040 
00041   // gather/scatter functions
00042 
00043   // scatter particle data into Field using particle position and mesh
00044   template <class FT, unsigned Dim, class M, class C, class PT>
00045   static
00046   void scatter(const FT& pdata, Field<FT,Dim,M,C>& f,
00047                const Vektor<PT,Dim>& ppos, const M& mesh) {
00048     // find nearest-grid-point for particle position, store in NDIndex obj
00049     NDIndex<Dim> ngp = FindNGP(mesh, ppos, CenteringTag<C>());
00050     // scatter data value to Field ... this assumes that the Field
00051     // data point is local to this processor, if not an error will be printed.
00052 
00053     CompressedBrickIterator<FT,Dim> fiter = getFieldIter(f,ngp);
00054     *fiter += pdata;
00055 
00056     return;
00057   }
00058 
00059   // scatter particle data into Field using particle position and mesh
00060   // and cache mesh information for reuse
00061   template <class FT, unsigned Dim, class M, class C, class PT>
00062   static
00063   void scatter(const FT& pdata, Field<FT,Dim,M,C>& f,
00064                const Vektor<PT,Dim>& ppos, const M& mesh,
00065                NDIndex<Dim>& ngp) {
00066     // find nearest-grid-point for particle position, store in NDIndex obj
00067     ngp = FindNGP(mesh, ppos, CenteringTag<C>());
00068     // scatter data value to Field ... this assumes that the Field
00069     // data point is local to this processor, if not an error will be printed.
00070 
00071     CompressedBrickIterator<FT,Dim> fiter = getFieldIter(f,ngp);
00072     *fiter += pdata;
00073 
00074     return;
00075   }
00076 
00077   // scatter particle data into Field using cached mesh information
00078   template <class FT, unsigned Dim, class M, class C>
00079   static
00080   void scatter(const FT& pdata, Field<FT,Dim,M,C>& f,
00081                const NDIndex<Dim>& ngp) {
00082     // scatter data value to Field ... this assumes that the Field
00083     // data point is local to this processor, if not an error will be printed.
00084 
00085     CompressedBrickIterator<FT,Dim> fiter = getFieldIter(f,ngp);
00086     *fiter += pdata;
00087 
00088     return;
00089   }
00090 
00091   // gather particle data from Field using particle position and mesh
00092   template <class FT, unsigned Dim, class M, class C, class PT>
00093   static
00094   void gather(FT& pdata, const Field<FT,Dim,M,C>& f,
00095               const Vektor<PT,Dim>& ppos, const M& mesh) {
00096     // find nearest-grid-point for particle position, store in NDIndex obj
00097     NDIndex<Dim> ngp = FindNGP(mesh, ppos, CenteringTag<C>());
00098     // gather Field value to particle data ... this assumes that the Field
00099     // data point is local to this processor, if not an error will be printed.
00100 
00101     CompressedBrickIterator<FT,Dim> fiter = getFieldIter(f,ngp);
00102     pdata = *fiter;
00103 
00104     return;
00105   }
00106 
00107   // gather particle data from Field using particle position and mesh
00108   // and cache mesh information for reuse
00109   template <class FT, unsigned Dim, class M, class C, class PT>
00110   static
00111   void gather(FT& pdata, const Field<FT,Dim,M,C>& f,
00112               const Vektor<PT,Dim>& ppos, const M& mesh,
00113               NDIndex<Dim>& ngp) {
00114     // find nearest-grid-point for particle position, store in NDIndex obj
00115     ngp = FindNGP(mesh, ppos, CenteringTag<C>());
00116     // gather Field value to particle data ... this assumes that the Field
00117     // data point is local to this processor, if not an error will be printed.
00118 
00119     CompressedBrickIterator<FT,Dim> fiter = getFieldIter(f,ngp);
00120     pdata = *fiter;
00121 
00122     return;
00123   }
00124 
00125   // gather particle data from Field using cached mesh information
00126   template <class FT, unsigned Dim, class M, class C>
00127   static
00128   void gather(FT& pdata, const Field<FT,Dim,M,C>& f,
00129               const NDIndex<Dim>& ngp) {
00130     // gather Field value to particle data ... this assumes that the Field
00131     // data point is local to this processor, if not an error will be printed.
00132 
00133     CompressedBrickIterator<FT,Dim> fiter = getFieldIter(f,ngp);
00134     pdata = *fiter;
00135 
00136     return;
00137   }
00138 
00139 };
00140 
00141 #endif // INT_NGP_H
00142 
00143 /***************************************************************************
00144  * $RCSfile: IntNGP.h,v $   $Author: adelmann $
00145  * $Revision: 1.1.1.1 $   $Date: 2003/01/23 07:40:28 $
00146  * IPPL_VERSION_ID: $Id: IntNGP.h,v 1.1.1.1 2003/01/23 07:40:28 adelmann Exp $ 
00147  ***************************************************************************/
00148 

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