SpatialOps
BoundaryCellInfo.h
Go to the documentation of this file.
1 
31 #ifndef SpatialOps_BOUNDARYCELLINFO_H_
32 #define SpatialOps_BOUNDARYCELLINFO_H_
33 
35 
36 namespace SpatialOps {
37 
46  {
47  IntVec isbc_;
48  IntVec nExtra_;
49 
57  inline BoundaryCellInfo( const bool bcx,
58  const bool bcy,
59  const bool bcz,
60  const IntVec nExtra )
61  : isbc_(bcx, bcy, bcz ),
62  nExtra_( isbc_ * nExtra ) // only extras if there is a BC present
63  {}
64 
65  public:
66 
74  template<typename FieldT>
76  static inline build( const bool bcx, const bool bcy, const bool bcz ){
77  return BoundaryCellInfo( bcx,bcy,bcz, FieldT::Location::BCExtra::int_vec() );
78  }
79 
85  template<typename FieldT>
87  static inline build( const IntVec& bc ){
88  return BoundaryCellInfo( bc[0],bc[1],bc[2], FieldT::Location::BCExtra::int_vec() );
89  }
90 
96  template<typename FieldT>
98  static inline build(){
99  return BoundaryCellInfo( false, false, false, FieldT::Location::BCExtra::int_vec() );
100  }
101 
106  isbc_ = bc.isbc_;
107  nExtra_ = bc.nExtra_;
108  return *this;
109  }
110 
114  inline BoundaryCellInfo( const BoundaryCellInfo& bc ) : isbc_(bc.isbc_), nExtra_(bc.nExtra_) {}
115 
116  inline ~BoundaryCellInfo(){}
117 
121  inline bool has_bc( const int dir ) const{ return isbc_[dir]; }
122 
126  inline IntVec has_bc() const{ return isbc_; }
127 
132  inline int num_extra( const int dir ) const{ assert(dir<3 && dir>=0); return nExtra_[dir]; }
133 
137  inline IntVec num_extra() const{ return nExtra_; }
138 
143  inline int has_extra( const int dir ) const{ assert(dir<3 && dir>=0); return has_bc(dir) ? num_extra(dir) : 0; }
144 
148  inline IntVec has_extra() const{ return IntVec(has_extra(0), has_extra(1), has_extra(2)); }
149 
153  inline BoundaryCellInfo limit_by_extent( const IntVec& extent ) const{
154  return BoundaryCellInfo( has_bc(0), has_bc(1), has_bc(2),
155  IntVec( extent[0] == 1 ? 0 : has_extra(0),
156  extent[1] == 1 ? 0 : has_extra(1),
157  extent[2] == 1 ? 0 : has_extra(2) ) );
158  }
159 
163  inline bool operator==( const BoundaryCellInfo& other ) const{
164  return isbc_ == other.isbc_ && nExtra_ == other.nExtra_;
165  }
166  };
167 
168  inline std::ostream& operator<<( std::ostream& out, const BoundaryCellInfo& bc ){
169  out << "BC flags: " << bc.has_bc() << " #extra: " << bc.num_extra() << " has_extra: " << bc.has_extra();
170  return out;
171  }
172 
173 } /* namespace SpatialOps */
174 
175 #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 bool bcx, const bool bcy, const bool bcz)
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...
static BoundaryCellInfo build(const IntVec &bc)
obtain a BoundaryCellInfo object for the requested field type
IntVec num_extra() const
obtain the number of extra cells present on this field due to presence of physical boundaries...
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
BoundaryCellInfo limit_by_extent(const IntVec &extent) const
limit extra cells to dimensions with extents > 1
BoundaryCellInfo(const BoundaryCellInfo &bc)
copy constructor
IntVec has_bc() const
obtain an IntVec indicating the presence of physical boundaries on the (+) faces
bool has_bc(const int dir) const
query to see if a physical boundary is present in the given direction (0=x, 1=y, 2=z) ...
Provides information about boundary cells for various fields.