SpatialOps
BoundaryCellInfo.h
Go to the documentation of this file.
1 
31 #ifndef SpatialOps_BOUNDARYCELLINFO_H_
32 #define SpatialOps_BOUNDARYCELLINFO_H_
33 
36 
37 namespace SpatialOps {
38 
47  {
48  IntVec minus_, plus_;
49  IntVec nExtra_;
50 
57  inline BoundaryCellInfo( const IntVec bcm,
58  const IntVec bcp,
59  const IntVec nExtra )
60  : minus_( bcm ),
61  plus_ ( bcp ),
62  nExtra_( plus_ * nExtra ) // only extras if there is a BC present
63  {}
64 
65  public:
66 
77  template<typename FieldT>
79  static inline build( const bool bcmx, const bool bcpx,
80  const bool bcmy, const bool bcpy,
81  const bool bcmz, const bool bcpz )
82  {
83  return BoundaryCellInfo( IntVec(bcmx,bcmy,bcmz), IntVec(bcpx,bcpy,bcpz), FieldT::Location::BCExtra::int_vec() );
84  }
85 
92  template<typename FieldT>
94  static inline build( const IntVec& bcm, const IntVec& bcp ){
95  return BoundaryCellInfo( bcm, bcp, FieldT::Location::BCExtra::int_vec() );
96  }
97 
103  template<typename FieldT>
105  static inline build(){
106  return BoundaryCellInfo( IntVec(false,false,false), IntVec(false,false,false), FieldT::Location::BCExtra::int_vec() );
107  }
108 
113  minus_ = bc.minus_;
114  plus_ = bc.plus_;
115  nExtra_ = bc.nExtra_;
116  return *this;
117  }
118 
122  inline BoundaryCellInfo( const BoundaryCellInfo& bc ) : minus_(bc.minus_), plus_(bc.plus_), nExtra_(bc.nExtra_) {}
123 
124  inline ~BoundaryCellInfo(){}
125 
129  inline bool has_bc( const int dir, const BCSide side ) const{ return side==MINUS_SIDE ? minus_[dir] : plus_[dir]; }
130 
134  inline IntVec has_bc( const BCSide side ) const{ return side==MINUS_SIDE ? minus_ : plus_; }
135 
140  inline int num_extra( const int dir ) const{ assert(dir<3 && dir>=0); return nExtra_[dir]; }
141 
145  inline IntVec num_extra() const{ return nExtra_; }
146 
151  inline int has_extra( const int dir ) const{ assert(dir<3 && dir>=0); return has_bc(dir,PLUS_SIDE) ? num_extra(dir) : 0; }
152 
156  inline IntVec has_extra() const{ return IntVec(has_extra(0), has_extra(1), has_extra(2)); }
157 
161  inline BoundaryCellInfo limit_by_extent( const IntVec& extent ) const{
162  return BoundaryCellInfo( minus_, plus_,
163  IntVec( extent[0] == 1 ? 0 : has_extra(0),
164  extent[1] == 1 ? 0 : has_extra(1),
165  extent[2] == 1 ? 0 : has_extra(2) ) );
166  }
167 
171  inline bool operator==( const BoundaryCellInfo& other ) const{
172  return minus_ == other.minus_ && plus_ == other.plus_ && nExtra_ == other.nExtra_;
173  }
174  };
175 
176  inline std::ostream& operator<<( std::ostream& out, const BoundaryCellInfo& bc ){
177  out << "BC flags: minus: " << bc.has_bc(MINUS_SIDE)
178  << " plus: " << bc.has_bc(PLUS_SIDE)
179  << " #extra: " << bc.num_extra() << " has_extra: " << bc.has_extra();
180  return out;
181  }
182 
183 } /* namespace SpatialOps */
184 
185 #endif /* SpatialOps_BOUNDARYCELLINFO_H_ */
static BoundaryCellInfo build()
obtain a BoundaryCellInfo object for the requested field type, assuming that there is no physical bou...
int num_extra(const int dir) const
obtain the number of extra cells potentially present on this field due to presence of physical bounda...
static BoundaryCellInfo build(const IntVec &bcm, const IntVec &bcp)
obtain a BoundaryCellInfo object for the requested field type
IntVec has_extra() const
obtain the number of extra cells actually present on this field due to presence of physical boundarie...
bool has_bc(const int dir, const BCSide side) const
query to see if a physical boundary is present in the given direction (0=x, 1=y, 2=z) and the specifi...
IntVec num_extra() const
obtain the number of extra cells present on this field due to presence of physical boundaries...
IntVec has_bc(const BCSide side) const
obtain an IntVec indicating the presence of physical boundaries on the (+) faces
BoundaryCellInfo & operator=(const BoundaryCellInfo &bc)
assignment operator
int has_extra(const int dir) const
obtain the number of extra cells actually present on this field due to presence of physical boundarie...
bool operator==(const BoundaryCellInfo &other) const
compare for equality
static BoundaryCellInfo build(const bool bcmx, const bool bcpx, const bool bcmy, const bool bcpy, const bool bcmz, const bool bcpz)
obtain a BoundaryCellInfo object for the requested field type
BoundaryCellInfo limit_by_extent(const IntVec &extent) const
limit extra cells to dimensions with extents > 1
BoundaryCellInfo(const BoundaryCellInfo &bc)
copy constructor
BCSide
Allows identification of whether we are setting the BC on the right or left side when using an operat...
Provides information about boundary cells for various fields.