SpatialOps
Grid.h
1 /*
2  * Copyright (c) 2014 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 
23 #ifndef SpatialOps_structured_Grid_h
24 #define SpatialOps_structured_Grid_h
25 
28 
29 namespace SpatialOps{
30 
36  class Grid
37  {
38  const IntVec npts_;
39  const DoubleVec length_, spacing_, origin_;
40  public:
46  Grid( const IntVec& npts,
47  const DoubleVec length,
48  const DoubleVec origin = DoubleVec(0,0,0) );
49 
53  template< typename CoordT > double spacing() const;
54  inline const DoubleVec& spacing() const{ return spacing_; }
55 
56  inline const IntVec& extent() const{ return npts_; }
57 
58  inline int extent( const size_t i ) const{ assert(i<3); return npts_[i]; }
59 
60  inline const DoubleVec& length() const{ return length_; }
61  inline double length( const size_t i ) const{ assert(i<3); return length_[i]; }
62 
77  template< typename CoordT, typename FieldT >
78  void set_coord( FieldT& f ) const;
79  };
80 
81 } // namespace SpatialOps
82 
83 #endif // SpatialOps_structured_Grid_h
double spacing() const
obtain the grid spacing in the requested direction
Definition: Grid.cpp:53
void set_coord(FieldT &f) const
set the coordinates on the given field.
Definition: Grid.cpp:61
Provides a simple interface to set coordinate fields.
Definition: Grid.h:36
Grid(const IntVec &npts, const DoubleVec length, const DoubleVec origin=DoubleVec(0, 0, 0))
Definition: Grid.cpp:36