Hermes2D  2.0
neighbor.h
1 #ifndef __H2D_NEIGHBOR_H
2 #define __H2D_NEIGHBOR_H
3 
4 #include "mesh/mesh.h"
5 #include "quadrature/quad.h"
6 #include "function/solution.h"
7 #include "forms.h"
8 #include "mesh/refmap.h"
9 #include "asmlist.h"
10 #include "space/space.h"
11 namespace Hermes
12 {
13  namespace Hermes2D
14  {
15  /*** Class NeighborSearch. ***/
16 
67  template<typename Scalar>
68  class HERMES_API NeighborSearch
69  {
70  public:
71 
77  NeighborSearch(Element* el, const Mesh* mesh);
78  NeighborSearch(const NeighborSearch& ns);
79 
81  ~NeighborSearch();
82 
83  /*** Methods for changing active state for further calculations. ***/
84 
105  void set_active_edge(int edge);
106 
108  bool set_active_edge_multimesh(const int& edge);
109 
111  Hermes::vector<unsigned int> get_transforms(uint64_t sub_idx) const;
112 
114  bool is_inter_edge(const int& edge, const Hermes::vector<unsigned int>& transformations) const;
115 
117  void update_according_to_sub_idx(const Hermes::vector<unsigned int>& transformations);
118 
120  void handle_sub_idx_way_down(const Hermes::vector<unsigned int>& transformations);
121 
124  bool compatible_transformations(unsigned int a, unsigned int b, int edge) const;
125 
128  void clear_initial_sub_idx();
129 
131  void delete_neighbor(unsigned int position);
132 
140 
142  ExtendedShapeset *supported_shapes;
143 
144 
155  ExtendedShapeset* create_extended_asmlist(const Space<Scalar>* space, AsmList<Scalar>* al);
156  ExtendedShapeset* create_extended_asmlist_multicomponent(const Space<Scalar>* space, AsmList<Scalar>* al);
157 
158  /*** Methods for working with quadrature on the active edge. ***/
159 
164  void set_quad_order(int order);
165 
171  int get_quad_eo(bool on_neighbor = false) const;
172 
173  /*** Methods for retrieving additional information about the neighborhood. ***/
174 
179  int get_num_neighbors() const;
180 
185  const Hermes::vector<Element*>* get_neighbors() const;
186 
188  void clear_supported_shapes();
189 
191  void set_ignore_errors(bool value);
192 
196  {
197  public:
204  ExtendedShapeset(NeighborSearch<Scalar>* neighborhood, AsmList<Scalar>* central_al, const Space<Scalar>*space);
205 
206  ExtendedShapeset(const ExtendedShapeset & other);
207 
209  ~ExtendedShapeset();
210 
211  void free_central_al();
212 
214  void combine_assembly_lists();
215 
221  void update(NeighborSearch* neighborhood, const Space<Scalar>* space);
222 
223  public:
224  int cnt;
225  int *dof;
226 
227  bool has_support_on_neighbor(unsigned int index) const;
228 
231 
232  friend class NeighborSearch; // Only a NeighborSearch is allowed to create an ExtendedShapeset.
233  };
234 
235  /*** Neighborhood information. ***/
238  {
239  public:
240  NeighborEdgeInfo() : local_num_of_edge(-1), orientation(-1) {};
241 
242  int local_num_of_edge;
243  int orientation;
244 
245  };
246 
250 
252  int get_active_segment() const;
253 
255  void set_active_segment(unsigned int index);
256 
258  Element* get_neighb_el() const;
259 
261  NeighborEdgeInfo get_neighbor_edge() const;
262 
264  unsigned int get_central_n_trans(unsigned int index) const;
265 
267  unsigned int get_central_transformations(unsigned int index_1, unsigned int index_2) const;
268 
270  unsigned int get_neighbor_n_trans(unsigned int index) const;
271 
273  unsigned int get_neighbor_transformations(unsigned int index_1, unsigned int index_2) const;
274 
277  {
278  public:
279  static const int max_level = Transformable::H2D_MAX_TRN_LEVEL;
280 
281 
282  unsigned int transf[max_level];
283  unsigned int num_levels;
284 
285  Transformations();
287  Transformations(const Hermes::vector<unsigned int>& t);
288 
289  void copy_from(const Hermes::vector<unsigned int>& t);
290 
291  void copy_from(const Transformations* t);
292 
293  void copy_to(Hermes::vector<unsigned int>* t);
294 
295  void reset();
296 
297  void strip_initial_transformations(unsigned int number_of_stripped);
298 
299  void apply_on(Transformable* tr) const;
300 
301  void apply_on(const Hermes::vector<Transformable*>& tr) const;
302 
303  template<typename T> friend class NeighborSearch;
304  template<typename T> friend class KellyTypeAdapt;
305  template<typename T> friend class Adapt;
306  template<typename T> friend class Func;
307  template<typename T> friend class DiscontinuousFunc;
308  template<typename T> friend class DiscreteProblem;
309  template<typename T> friend class DiscreteProblemLinear;
310  };
311 
312  private:
313 
314  const Mesh* mesh;
315 
316  /*** Transformations. ***/
317 
318  LightArray< Transformations* > central_transformations;
319 
320 
321  LightArray< Transformations* > neighbor_transformations;
322 
323  uint64_t original_central_el_transform;
324 
325 
326  /*** Significant objects of the neighborhood. ***/
327  Element* central_el;
328  Element* neighb_el;
329 
330  int active_edge;
331  NeighborEdgeInfo neighbor_edge;
332  int active_segment;
333 
334  Hermes::vector<NeighborEdgeInfo> neighbor_edges;
335  Hermes::vector<Element*> neighbors;
336  unsigned int n_neighbors;
337 
341  enum NeighborhoodType
342  {
343  H2D_DG_NOT_INITIALIZED = -1,
344  H2D_DG_NO_TRANSF = 0,
345 
346  H2D_DG_GO_DOWN = 1,
347 
348  H2D_DG_GO_UP = 2
349 
350  };
351  NeighborhoodType neighborhood_type;
352 
368  void find_act_elem_up( Element* elem, int* orig_vertex_id, Node** par_mid_vertices, int n_parents);
369 
386  void find_act_elem_down( Node* vertex, int* bounding_verts_id, int* sons, unsigned int n_sons);
387 
406  int neighbor_edge_orientation(int bounding_vert1, int bounding_vert2, int segment) const;
407 
409  void reset_neighb_info();
410 
411  /*** Quadrature on the active edge. ***/
412  Quad2D* quad;
413 
414  int central_quad_order;
415  int neighb_quad_order;
416 
417  template<typename T> friend class KellyTypeAdapt;
418  template<typename T> friend class Adapt;
419  template<typename T> friend class Func;
420  template<typename T> friend class DiscontinuousFunc;
421  template<typename T> friend class DiscreteProblem;
422  template<typename T> friend class DiscreteProblemLinear;
423  };
424  }
425 }
426 #endif