adaptive_refinement_mesh_wrapper.h
Go to the documentation of this file.
1 /*
2 This file is part of the Ristra Wonton project.
3 Please see the license file at the root of this repository, or at:
4  https://github.com/laristra/wonton/blob/master/LICENSE
5 */
6 
7 #ifndef WONTON_ADAPTIVE_REFINEMENT_MESH_WRAPPER_H_
8 #define WONTON_ADAPTIVE_REFINEMENT_MESH_WRAPPER_H_
9 
11 
12 #include <vector>
13 #include <algorithm>
14 
15 #include "wonton/support/wonton.h"
17 #include "wonton/support/Point.h"
18 
24 namespace Wonton {
25 
36 template<int D, class CoordSys=DefaultCoordSys>
38 
39  public:
40 
41  // ==========================================================================
42  // Constructors
43 
46 
53 
57 
61 
62 
63  // ==========================================================================
64  // Accessors
65 
67  int space_dimension() const;
68 
70  int num_owned_cells() const;
71 
73  int num_ghost_cells() const;
74 
76  void cell_get_bounds(const int id, Point<D> *plo, Point<D> *phi) const;
77 
79  counting_iterator begin(Entity_kind const entity,
80  Entity_type const etype = Entity_type::ALL) const;
81 
83  counting_iterator end(Entity_kind const entity,
84  Entity_type const etype = Entity_type::ALL) const;
85 
86 
87  private:
88 
89  // ==========================================================================
90  // Class data
91 
94 
95 }; // class Adaptive_Refinement_Mesh_Wrapper
96 
97 
98 // ============================================================================
99 // Constructors
100 
101 // ____________________________________________________________________________
102 // constructor
103 template<int D, class CoordSys>
106  mesh_(mesh) {
107 }
108 
109 
110 // ============================================================================
111 // Accessors
112 
113 // ____________________________________________________________________________
114 // Get dimensionality of the mesh.
115 template<int D, class CoordSys>
117  return mesh_.space_dimension();
118 }
119 
120 // ____________________________________________________________________________
121 // Get number of cells owned by this processing element.
122 template<int D, class CoordSys>
124  return mesh_.num_cells();
125 }
126 
127 // ____________________________________________________________________________
128 // Get number of ghost cells on this processing element.
129 template<int D, class CoordSys>
131  return 0;
132 }
133 
134 // ____________________________________________________________________________
135 // Get lower and upper corners of cell bounding box
136 template<int D, class CoordSys>
138  const int id, Point<D> *plo, Point<D> *phi) const {
139  auto bounding_box = mesh_.cell_get_bounds(id);
140  for (int d = 0; d < D; ++d) {
141  (*plo)[d] = bounding_box[d][LO];
142  (*phi)[d] = bounding_box[d][HI];
143  }
144 }
145 
146 // ____________________________________________________________________________
147 // Iterators on mesh entity - begin
148 template<int D, class CoordSys>
150  Entity_kind const entity, Entity_type const etype) const {
151  // Currently only valid for cells
152  assert(entity == Wonton::Entity_kind::CELL);
153  // Currently only valid for owned cells
154  assert(etype == Wonton::Entity_type::PARALLEL_OWNED);
155  // Return iterator
156  int start_index = 0;
157  return(make_counting_iterator(start_index));
158 }
159 
160 // ____________________________________________________________________________
161 // Iterator on mesh entity - end
162 template<int D, class CoordSys>
164  Entity_kind const entity, Entity_type const etype) const {
165  // Currently only valid for cells
166  assert(entity == Wonton::Entity_kind::CELL);
167  // Currently only valid for owned cells
168  assert(etype == Wonton::Entity_type::PARALLEL_OWNED);
169  // Return iterator
170  int start_index = 0;
171  return(make_counting_iterator(start_index) + num_owned_cells());
172 }
173 
174 } // namespace Wonton
175 
176 #endif // WONTON_ADAPTIVE_REFINEMENT_MESH_WRAPPER_H_
void cell_get_bounds(const int id, Point< D > *plo, Point< D > *phi) const
Get lower and upper corners of cell bounding box.
Definition: adaptive_refinement_mesh_wrapper.h:137
counting_iterator begin(Entity_kind const entity, Entity_type const etype=Entity_type::ALL) const
Iterators on mesh entity - begin.
Definition: adaptive_refinement_mesh_wrapper.h:149
Definition: wonton.h:130
int num_owned_cells() const
Get number of cells owned by this processing element.
Definition: adaptive_refinement_mesh_wrapper.h:123
A thin wrapper that implements Portage-relevant methods for Adaptive_Refinement_Mesh.
Definition: adaptive_refinement_mesh_wrapper.h:37
Factorize a number N into D equal (or nearly equal) factors.
Definition: adaptive_refinement_mesh.h:31
Entity_type
The parallel type of a given entity.
Definition: wonton.h:124
boost::counting_iterator< int > counting_iterator
Definition: wonton.h:290
A simple mesh that mimics a cell-by-cell AMR mesh.
Definition: adaptive_refinement_mesh.h:51
Definition: wonton.h:88
Represents a point in an N-dimensional space.
Definition: Point.h:50
counting_iterator make_counting_iterator(int const i)
Definition: wonton.h:291
Entity_kind
The type of mesh entity.
Definition: wonton.h:81
Definition of the Adaptive_Refinement_Mesh class.
counting_iterator end(Entity_kind const entity, Entity_type const etype=Entity_type::ALL) const
Iterator on mesh entity - end.
Definition: adaptive_refinement_mesh_wrapper.h:163
const int HI
Definition: BoundingBox.h:24
Definition: wonton.h:127
int num_ghost_cells() const
Get number of ghost cells on this processing element.
Definition: adaptive_refinement_mesh_wrapper.h:130
Adaptive_Refinement_Mesh_Wrapper & operator=(Adaptive_Refinement_Mesh_Wrapper< D, CoordSys > const &)=delete
Assignment operator (disabled).
Adaptive_Refinement_Mesh_Wrapper()=delete
Default constructor (disabled)
int space_dimension() const
Get dimensionality of the mesh.
Definition: adaptive_refinement_mesh_wrapper.h:116
const int LO
Definition: BoundingBox.h:23