Proto
Proto_ProblemDomain.H
1 #ifdef CH_LANG_CC
2 /*
3  * _______ __
4  * / ___/ / ___ __ _ / / ___
5  * / /__/ _ \/ _ \/ V \/ _ \/ _ \
6  * \___/_//_/\___/_/_/_/_.__/\___/
7  * Please refer to Copyright.txt, in Chombo's root directory.
8  */
9 #endif
10 #ifndef _PROTO_PROBLEMDOMAIN_H_
11 #define _PROTO_PROBLEMDOMAIN_H_
12 #include <array>
13 #include "Proto.H"
14 
15 using namespace std;
16 namespace Proto
17 {
19 
23  {
24  protected:
25  Box m_bx;
26  array<bool,DIM> m_isPeriodic;
27  bool m_isDefined;
28  public:
29  ProblemDomain(){};
30  //~ProblemDomain(){};
32  ProblemDomain(const Box& a_bx,const array<bool,DIM> a_isPeriodic)
33  {
34  define(a_bx,a_isPeriodic);
35  };
37 
38  inline void define(const Box& a_bx,const array<bool,DIM> a_isPeriodic)
39  {
40  m_isDefined = true;
41  m_isPeriodic = a_isPeriodic;
42  m_bx = a_bx;
43  PROTO_ASSERT(m_bx.low() == Point::Zeros(),"Low corner of the problem domain not zero");
44  // For the time being, we are assuming that the low corner of the problem domain is zero.
45  // We can come back and fix this if necessary.
46  };
47 
49 
50  inline Box operator&(Box a_bx) const
51  {
52  Point lowCorner = a_bx.low();
53  Point highCorner = a_bx.high();
54  for (int dir = 0; dir < DIM; dir++)
55  {
56  if (!m_isPeriodic[dir])
57  {
58  lowCorner[dir] = max(lowCorner[dir],m_bx.low()[dir]);
59  highCorner[dir] = min(highCorner[dir],m_bx.high()[dir]);
60  }
61  }
62  return Box(lowCorner,highCorner);
63  };
64  inline Point shifted(const Point& a_pt) const
65  {
66  PR_assert( !( (*this) & Box(a_pt,a_pt) ).empty() );
67  return a_pt % (Point::Ones()*(m_bx.high() + 1));//Warning :: assumes low corner is set to zero
68  };
70 
73  inline bool coarsenable(Point a_boxSize) const
74  {
75  return m_bx.coarsenable(a_boxSize);
76  };
77  inline Point size() const{return m_bx.high()+Point::Ones();}; //FIXME: This only works of low = (0,...,0)
78  inline bool operator==(const ProblemDomain& a_input) const
79  {
80  return (m_bx== a_input.m_bx)&&(m_isPeriodic==a_input.m_isPeriodic)
81  &&(m_isDefined==a_input.m_isDefined);
82  };
84  inline Box box() const {return m_bx;};
86  inline array<bool,DIM> periodicflags() const{return m_isPeriodic;};
88 
90  inline ProblemDomain coarsen(Point a_refRatio) const
91  {
92  PR_assert(this->coarsenable(a_refRatio));
93  ProblemDomain retval;
94  retval.m_bx = m_bx.coarsen(a_refRatio);
95  retval.m_isPeriodic = m_isPeriodic;
96  retval.m_isDefined = m_isDefined;
97  PR_assert(m_isDefined);
98  return retval;
99  };
101  inline ProblemDomain refine(Point a_refRatio) const
102  {
103  ProblemDomain retval;
104  retval.m_bx = m_bx.refine(a_refRatio);
105  retval.m_isPeriodic = m_isPeriodic;
106  retval.m_isDefined = m_isDefined;
107  return retval;
108  };
109  };
111  inline std::ostream& operator<< (std::ostream& os, const ProblemDomain& a_pd)
112  {
113  os << "ProblemDomain: Box = " << a_pd.box() <<
114  " , periodicity = [" ;
115  for (int d = 0; d < DIM; d++)
116  {
117  os<< a_pd.periodicflags()[d] ;
118  if (d < DIM-1) os << " , ";
119  }
120  os << "]";
121  return os;
122  }
123  // end Proto namespace.
124 }
125 #endif
Point high() const
Access High Corner.
Definition: Proto_Box.H:174
Point low() const
Access Low Corner.
Definition: Proto_Box.H:168
Box box() const
Returns Box that defines the *this.
Definition: Proto_ProblemDomain.H:84
std::ostream & operator<<(std::ostream &a_os, const CInterval &a_int)
CInterval IOStream Operator.
Definition: Proto_BoxData.H:259
Box refine(const Point &a_pt) const
Anisotropic Refine Operation.
Definition: Proto_Box.H:477
An interval in DIM dimensional space.
Definition: Proto_Box.H:26
ProblemDomain refine(Point a_refRatio) const
Returns a ProblemDomain with a Box given by this->box.coarsen(a_refRatio).
Definition: Proto_ProblemDomain.H:101
Definition: Proto_Box.H:11
Integer Valued Vector.
Definition: Proto_Point.H:21
ProblemDomain coarsen(Point a_refRatio) const
Returns a ProblemDomain with a box given by this->box.coarsen(a_refRatio).
Definition: Proto_ProblemDomain.H:90
ProblemDomain(const Box &a_bx, const array< bool, DIM > a_isPeriodic)
Constructor constructs a ProblemDomain with Box a_bx, and periodic directions given by a_periodic...
Definition: Proto_ProblemDomain.H:32
array< bool, DIM > periodicflags() const
Returns the array of bools defining the periodic directions.
Definition: Proto_ProblemDomain.H:86
Box coarsen(unsigned int a_ratio) const
Isotropic Coarsen Operation.
Definition: Proto_Box.H:387
bool coarsenable(const int &a_ratio) const
(Isotropic) Coarsenable Query
Definition: Proto_Box.H:455
void define(const Box &a_bx, const array< bool, DIM > a_isPeriodic)
Define - same arguments as constructor, but allows weak construction.
Definition: Proto_ProblemDomain.H:38
Represents a rectangular domain over which a problem can be defined, including periodic images...
Definition: Proto_ProblemDomain.H:22
bool coarsenable(Point a_boxSize) const
Checks to see whether the ProblemDomain Box is coarsenable by a_boxsize.
Definition: Proto_ProblemDomain.H:73