Proto  3.2
Proto_ProblemDomain.H
Go to the documentation of this file.
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 
13 namespace Proto
14 {
15  /// Represents a rectangular domain over which a problem can be defined, including periodic images.
16  /**
17  A ProblemDomain is specified by a Box defining the rectangular set of Points over which a
18  problem may be defined, plus an Array<bool,DIM> specifying whether or not each of the
19  coordinate directions is periodic. The Box is assumed to have the low corner to be all Zeros,
20  and specifies the overall range of indices that contain all the boxes in a DisjointBoxLayout.
21  */
23  {
24  public:
25 
27 
28  /// Anisotropic Constructor
29  /**
30  Constructs a ProblemDomain with Box a_bx, and periodic directions given by a_periodic.
31 
32  \param a_box Domain Box
33  \param a_isPeriodic Periodic flags
34  */
35  inline ProblemDomain(const Box& a_box,const Array<bool,DIM> a_isPeriodic);
36 
37  /// Isotropic Constructor
38  /**
39  Isotropic overload of the main constructor. Creates a ProblemDomain that is periodic
40  or non-periodic in every direction
41 
42  \param a_box Domain Box
43  \param a_isPeriodic Periodic flag
44  */
45  inline ProblemDomain(const Box& a_box, bool a_isPeriodic);
46 
47  /// Define
48  /**
49  Lazily constructs a ProblemDomain with Box a_bx, and periodic directions given
50  by a_periodic.
51 
52  \param a_box Domain Box
53  \param a_isPeriodic Periodic flags
54  */
55  inline void define(const Box& a_box,const Array<bool,DIM> a_isPeriodic);
56 
57  /// Box Intersection
58  /**
59  Returns the Box that is the intersection of a_bx with this->box()
60  and all of its periodic images. Points in a_box which have no periodic
61  image in the ProblemDomain are truncated.
62 
63  This function does no periodic shifting. See <code>image</code> for that functionality.
64 
65  \param a_box A Box
66  */
67  inline Box operator&(Box a_box) const;
68 
69  /// Contains Point
70  /**
71  Checks if a_pt or any of it's periodic images are contained in this ProblemDomain.
72 
73  \param a_pt A Point
74  */
75  inline bool contains(const Point& a_pt) const;
76 
77  /// Periodic Image
78  /**
79  Computes the periodic image of a Point. This function results in an error if
80  the input does not have a periodic image, so one should call
81  <code>contains(Point)</code> first.
82 
83  \param a_pt A Point with a valid periodic image
84  */
85  inline Point image(const Point& a_pt) const;
86 
87  /// Periodic Image
88  /**
89  Computes the periodic image of a Box. Points with no periodic image are truncated.
90  If <code>a_box</code> contains a periodic boundary in its interior, this function
91  fails by assertion.
92 
93  \param a_pt A Point with a valid periodic image
94  */
95  inline Box image(const Box& a_box) const;
96 
97  /// Check If Coarsenable
98  /**
99  Returns true if *this can be tiled by boxes of size <code>a_boxSize</code>.
100  This is a requirement for using *this to construct a DisjointBoxLayout with
101  Boxes of this size.
102 
103  \param a_boxSize A possibly anisotropic Box size
104  */
105  inline bool coarsenable(Point a_boxSize) const;
106 
107  /// Query Size
108  /**
109  Size in number of points in each direction.
110  */
111  inline Point sizes() const { return m_box.sizes(); }
112 
113  /// Equality
114  /**
115  Two ProblemDomain objects are "==" if they have the same
116  Box domain and periodicity.
117 
118  \param a_domain A ProblemDomain
119  */
120  inline bool operator==(const ProblemDomain& a_domain) const;
121 
122  /// Inequality
123  /**
124  Two ProblemDomain objects are "==" if they have the same
125  Box domain and periodicity.
126 
127  \param a_domain A ProblemDomain
128  */
129  inline bool operator!=(const ProblemDomain& a_domain) const;
131  /// Get Box
132  inline Box box() const {return m_box;};
133 
134  /// Get Periodicity
135  inline Array<bool,DIM> periodicity() const { return m_isPeriodic; }
136 
137  /// Check Periodic Direction
138  /**
139  Check if this domain is periodic in direction a_dir.
140 
141  \param a_dir A coordinate direction in [0,DIM)
142  */
143  inline bool isPeriodic(int a_dir) const {return m_isPeriodic[a_dir]; }
144 
145  /// Coarsen (Anisotropic)
146  /**
147  Returns a ProblemDomain with a box given by this->box.coarsen(a_refRatio).
148  Fails if this->coarsenable(a_refRatio) is false.
149 
150  \param a_refRatio A vector of refinement ratios
151  */
152  inline ProblemDomain coarsen(Point a_refRatio) const;
153 
154  /// Coarsen (Isotropic)
155  /**
156  Returns a ProblemDomain with a box given by this->box.coarsen(a_refRatio).
157  Fails if this->coarsenable(a_refRatio) is false
158 
159  \param a_refRatio An isotropic refinement ratio
160  */
161  inline ProblemDomain coarsen(int a_refRatio) const;
162 
163  /// Refine (Anisotropic)
164  /**
165  Returns a ProblemDomain with a box given by this->box.refine(a_refRatio).
166 
167  \param a_refRatio A vector of refinement ratios
168  */
169  inline ProblemDomain refine(Point a_refRatio) const;
170 
171  /// Refine (Isotropic)
172  /**
173  Returns a ProblemDomain with a box given by this->box.refine(a_refRatio).
174 
175  \param a_refRatio An isotropic refinement ratio
176  */
177  inline ProblemDomain refine(int a_refRatio) const;
178 
179  protected:
180 
184 
185  }; // end class ProblemDomain
186 
187  /// Stream output for ProblemDomain.
188  inline std::ostream& operator<< (std::ostream& os, const ProblemDomain& a_pd);
189 #include "implem/Proto_ProblemDomainImplem.H"
190 } // end namespace Proto
191 #endif //end include guard
bool isPeriodic(int a_dir) const
Check Periodic Direction.
Definition: Proto_ProblemDomain.H:143
Box operator &(Box a_box) const
Box Intersection.
Box box() const
Get Box.
Definition: Proto_ProblemDomain.H:132
Point sizes() const
Query Size.
Definition: Proto_ProblemDomain.H:111
ProblemDomain()
Definition: Proto_ProblemDomain.H:26
bool contains(const Point &a_pt) const
Contains Point.
Definition: Proto_ProblemDomain.H:43
Array< bool, DIM > m_isPeriodic
Definition: Proto_ProblemDomain.H:182
An interval in DIM dimensional space.
Definition: Proto_Box.H:29
ProblemDomain refine(Point a_refRatio) const
Refine (Anisotropic)
Definition: Proto_ProblemDomain.H:116
Point image(const Point &a_pt) const
Periodic Image.
Definition: Proto_ProblemDomain.H:62
bool m_isDefined
Definition: Proto_ProblemDomain.H:183
Definition: Proto_Array.H:17
ACCEL_DECORATION Point sizes() const
All Sizes.
bool operator!=(const ProblemDomain &a_domain) const
Inequality.
Definition: Proto_ProblemDomain.H:95
bool operator==(const ProblemDomain &a_domain) const
Equality.
Definition: Proto_ProblemDomain.H:88
std::ostream & operator<<(std::ostream &stream, const Array< T, N > &arr)
Ostream operator.
void define(const Box &a_box, const Array< bool, DIM > a_isPeriodic)
Define.
Definition: Proto_ProblemDomain.H:15
Integer Valued Vector.
Definition: Proto_Point.H:24
ProblemDomain coarsen(Point a_refRatio) const
Coarsen (Anisotropic)
Definition: Proto_ProblemDomain.H:100
Array< bool, DIM > periodicity() const
Get Periodicity.
Definition: Proto_ProblemDomain.H:135
Box m_box
Definition: Proto_ProblemDomain.H:181
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
Check If Coarsenable.
Definition: Proto_ProblemDomain.H:83