SpatialOps
ParticleOperators.h
1 /*
2  * Copyright (c) 2014-2017 The University of Utah
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to
6  * deal in the Software without restriction, including without limitation the
7  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8  * sell copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20  * IN THE SOFTWARE.
21  */
22 #ifndef ParticleOperators_h
23 #define ParticleOperators_h
24 
26 #include <spatialops/particles/ParticlesOperatorHelper.h>
27 #include <spatialops/Nebo.h>
28 
29 #include <stdexcept>
30 #include <cmath>
31 #include <algorithm>
32 
33 namespace SpatialOps{
34  namespace Particle{
35 
44  template< typename CellField >
46  {
47  public:
49  typedef CellField DestFieldType;
50 
60  ParticlesPerCell( const double dx, const double xlo,
61  const double dy=-1, const double ylo =0,
62  const double dz=-1, const double zlo =0,
63  const InterpOptions method=INTERPOLATE);
64 
71  void set_coordinate_information( const ParticleField * const pxcoord,
72  const ParticleField * const pycoord,
73  const ParticleField * const pzcoord,
74  const ParticleField * const psize );
75 
79  void apply_to_field( DestFieldType& dest ) const;
80 
81  private:
82  const double dx_, dy_, dz_;
83  const double xlo_, ylo_, zlo_;
84  const ParticleField *px_, *py_, *pz_, *psize_;
85  const InterpOptions method_;
86  };
87 
88 
98  template< typename CellField >
100  {
101  public:
102  typedef ParticleField SrcFieldType;
103  typedef CellField DestFieldType;
104 
114  ParticleToCell( const double dx, const double xlo,
115  const double dy=-1, const double ylo =0,
116  const double dz=-1, const double zlo =0,
117  const InterpOptions method=INTERPOLATE );
118 
119 
126  void set_coordinate_information( const ParticleField * const pxcoord,
127  const ParticleField * const pycoord,
128  const ParticleField * const pzcoord,
129  const ParticleField * const psize );
130 
135  void apply_to_field( const SrcFieldType& src,
136  DestFieldType& dest ) const;
137 
138 
139  private:
140 
141  const double dx_, dy_, dz_;
142  const double xlo_, ylo_, zlo_;
143  const ParticleField *px_, *py_, *pz_, *psize_;
144  const InterpOptions method_;
145  };
146 
147 
148  //==================================================================
149 
150 
160  template< typename CellField >
162  {
163  public:
164  typedef CellField SrcFieldType;
166 
176  CellToParticle( const double dx, const double xlo,
177  const double dy=-1, const double ylo =0,
178  const double dz=-1, const double zlo =0,
179  const InterpOptions method=INTERPOLATE );
180 
188  void set_coordinate_information( const ParticleField* pxcoord,
189  const ParticleField* pycoord,
190  const ParticleField* pzcoord,
191  const ParticleField* psize );
192 
197  void apply_to_field( const SrcFieldType& src,
198  DestFieldType& dest ) const;
199 
200  void apply_to_field( const SrcFieldType& src,
201  DestFieldType& dest,
202  const std::string& method ) const;
203 
204  private:
205 
206  const double dx_, dy_, dz_;
207  const double xlo_, ylo_, zlo_;
208  const ParticleField *px_, *py_, *pz_, *psize_;
209  const InterpOptions method_;
210  };
211 
212 
213  } // namespace Particle
214 } // namespace SpatialOps
215 
216 #endif // ParticleOperators_h
Computes the number of particles per cell and accounts for fractional contributions.
Operator to interpolate a mesh field onto a particle.
Interpolates an extensive particle field onto an underlying mesh field.Note that this should only be ...
void set_coordinate_information(const ParticleField *const pxcoord, const ParticleField *const pycoord, const ParticleField *const pzcoord, const ParticleField *const psize)
Abstracts a field.
Definition: SpatialField.h:132
ParticlesPerCell(const double dx, const double xlo, const double dy=-1, const double ylo=0, const double dz=-1, const double zlo=0, const InterpOptions method=INTERPOLATE)
construct a ParticlesPerCell operator