t8  UNKNOWN
t8code is a C library to manage a forest of adaptive space-trees of general element classes in parallel.
t8_default_quad_cxx.hxx
1 /*
2  This file is part of t8code.
3  t8code is a C library to manage a collection (a forest) of multiple
4  connected adaptive space-trees of general element classes in parallel.
5 
6  Copyright (C) 2015 the developers
7 
8  t8code is free software; you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation; either version 2 of the License, or
11  (at your option) any later version.
12 
13  t8code is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with t8code; if not, write to the Free Software Foundation, Inc.,
20  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 */
22 
31 #ifndef T8_DEFAULT_QUAD_CXX_HXX
32 #define T8_DEFAULT_QUAD_CXX_HXX
33 
34 #include <p4est.h>
35 #include <t8_element_cxx.hxx>
38 #include <t8_schemes/t8_default/t8_default_line/t8_default_line_cxx.hxx>
40 
45 typedef p4est_quadrant_t t8_pquad_t;
46 
48 #define T8_QUAD_GET_TDIM(quad) ((int) (quad)->pad8)
49 
53 #define T8_QUAD_GET_TNORMAL(quad) (T8_ASSERT (T8_QUAD_GET_TDIM (quad) == 3), ((int) (quad)->pad16))
54 
58 #define T8_QUAD_GET_TCOORD(quad) (T8_ASSERT (T8_QUAD_GET_TDIM (quad) == 3), ((int) (quad)->p.user_long))
59 
61 #define T8_QUAD_SET_TDIM(quad, dim) \
62  do { \
63  T8_ASSERT ((dim) == 2 || (dim) == 3); \
64  (quad)->pad8 = (int8_t) (dim); \
65  } while (0)
66 
68 #define T8_QUAD_SET_TNORMAL(quad, normal) \
69  do { \
70  T8_ASSERT ((normal) >= 0 && (normal) < 3); \
71  (quad)->pad16 = (int16_t) (normal); \
72  } while (0)
73 
75 #define T8_QUAD_SET_TCOORD(quad, coord) \
76  do { \
77  (quad)->p.user_long = (long) (coord); \
78  } while (0)
79 
81 {
82  public:
87 
89 
107  virtual void
108  t8_element_new (int length, t8_element_t **elem) const;
109 
127  virtual void
128  t8_element_init (int length, t8_element_t *elem) const;
129 
134  virtual int
135  t8_element_level (const t8_element_t *elem) const;
136 
140  virtual int
141  t8_element_maxlevel (void) const;
142 
150  virtual void
151  t8_element_copy (const t8_element_t *source, t8_element_t *dest) const;
152 
160  virtual int
161  t8_element_compare (const t8_element_t *elem1, const t8_element_t *elem2) const;
162 
169  virtual int
170  t8_element_equal (const t8_element_t *elem1, const t8_element_t *elem2) const;
171 
184  virtual void
185  t8_element_parent (const t8_element_t *elem, t8_element_t *parent) const;
186 
198  virtual void
199  t8_element_sibling (const t8_element_t *elem, int sibid, t8_element_t *sibling) const;
200 
205  virtual int
206  t8_element_num_faces (const t8_element_t *elem) const;
207 
213  virtual int
214  t8_element_max_num_faces (const t8_element_t *elem) const;
215 
220  virtual int
221  t8_element_num_children (const t8_element_t *elem) const;
222 
228  virtual int
229  t8_element_num_face_children (const t8_element_t *elem, int face) const;
236  virtual int
237  t8_element_get_face_corner (const t8_element_t *element, int face, int corner) const;
238 
245  virtual int
246  t8_element_get_corner_face (const t8_element_t *element, int corner, int face) const;
247 
256  virtual void
257  t8_element_child (const t8_element_t *elem, int childid, t8_element_t *child) const;
258 
269  virtual void
270  t8_element_children (const t8_element_t *elem, int length, t8_element_t *c[]) const;
271 
276  virtual int
277  t8_element_child_id (const t8_element_t *elem) const;
278 
285  virtual int
286  t8_element_ancestor_id (const t8_element_t *elem, int level) const;
287 
294  virtual int
295  t8_element_is_family (t8_element_t *const *fam) const;
296 
307  virtual void
308  t8_element_nca (const t8_element_t *elem1, const t8_element_t *elem2, t8_element_t *nca) const;
309 
315  virtual t8_element_shape_t
316  t8_element_face_shape (const t8_element_t *elem, int face) const;
317 
332  virtual void
333  t8_element_children_at_face (const t8_element_t *elem, int face, t8_element_t *children[], int num_children,
334  int *child_indices) const;
335 
356  virtual int
357  t8_element_face_child_face (const t8_element_t *elem, int face, int face_child) const;
358 
369  virtual int
370  t8_element_face_parent_face (const t8_element_t *elem, int face) const;
371 
381  virtual int
382  t8_element_tree_face (const t8_element_t *elem, int face) const;
383 
405  virtual void
406  t8_element_transform_face (const t8_element_t *elem1, t8_element_t *elem2, int orientation, int sign,
407  int is_smaller_face) const;
408 
422  virtual int
423  t8_element_extrude_face (const t8_element_t *face, const t8_eclass_scheme_c *face_scheme, t8_element_t *elem,
424  int root_face) const;
425 
434  virtual void
435  t8_element_first_descendant_face (const t8_element_t *elem, int face, t8_element_t *first_desc, int level) const;
436 
445  virtual void
446  t8_element_last_descendant_face (const t8_element_t *elem, int face, t8_element_t *last_desc, int level) const;
447 
457  virtual void
458  t8_element_boundary_face (const t8_element_t *elem, int face, t8_element_t *boundary,
459  const t8_eclass_scheme_c *boundary_scheme) const;
460 
466  virtual int
467  t8_element_is_root_boundary (const t8_element_t *elem, int face) const;
468 
484  virtual int
485  t8_element_face_neighbor_inside (const t8_element_t *elem, t8_element_t *neigh, int face, int *neigh_face) const;
486 
494  virtual void
495  t8_element_set_linear_id (t8_element_t *elem, int level, t8_linearidx_t id) const;
496 
503  virtual t8_linearidx_t
504  t8_element_get_linear_id (const t8_element_t *elem, int level) const;
505 
512  virtual void
513  t8_element_first_descendant (const t8_element_t *elem, t8_element_t *desc, int level) const;
514 
521  virtual void
522  t8_element_last_descendant (const t8_element_t *elem, t8_element_t *desc, int level) const;
523 
529  virtual void
530  t8_element_successor (const t8_element_t *elem, t8_element_t *succ) const;
531 
542  virtual void
543  t8_element_anchor (const t8_element_t *elem, int anchor[3]) const;
544 
554  virtual void
555  t8_element_vertex_reference_coords (const t8_element_t *elem, const int vertex, double coords[]) const;
556 
567  virtual void
568  t8_element_reference_coords (const t8_element_t *elem, const double *ref_coords, const size_t num_coords,
569  double *out_coords) const;
570 
575  virtual int
576  t8_element_refines_irregular (void) const;
577 
578 #ifdef T8_ENABLE_DEBUG
593  virtual int
594  t8_element_is_valid (const t8_element_t *t) const;
595 
603  virtual void
604  t8_element_to_string (const t8_element_t *elem, char *debug_string, const int string_size) const;
605 #endif
606 
610  void
611  t8_element_root (t8_element_t *elem) const;
612 
621  virtual void
622  t8_element_MPI_Pack (t8_element_t **const elements, const unsigned int count, void *send_buffer, int buffer_size,
623  int *position, sc_MPI_Comm comm) const;
624 
630  virtual void
631  t8_element_MPI_Pack_size (const unsigned int count, sc_MPI_Comm comm, int *pack_size) const;
632 
641  virtual void
642  t8_element_MPI_Unpack (void *recvbuf, const int buffer_size, int *position, t8_element_t **elements,
643  const unsigned int count, sc_MPI_Comm comm) const;
644 };
645 
646 #endif /* !T8_DEFAULT_QUAD_CXX_HXX */
Definition: t8_default_common_cxx.hxx:36
Definition: t8_default_quad_cxx.hxx:81
virtual int t8_element_extrude_face(const t8_element_t *face, const t8_eclass_scheme_c *face_scheme, t8_element_t *elem, int root_face) const
Given a boundary face inside a root tree's face construct the element inside the root tree that has t...
Definition: t8_default_quad_cxx.cxx:487
virtual void t8_element_copy(const t8_element_t *source, t8_element_t *dest) const
Copy all entries of source to dest.
Definition: t8_default_quad_cxx.cxx:64
void t8_element_root(t8_element_t *elem) const
Fills an element with the root element.
Definition: t8_default_quad_cxx.cxx:781
virtual int t8_element_equal(const t8_element_t *elem1, const t8_element_t *elem2) const
Check if two elements are equal.
Definition: t8_default_quad_cxx.cxx:89
virtual void t8_element_init(int length, t8_element_t *elem) const
Initialize an array of allocated quad elements.
Definition: t8_default_quad_cxx.cxx:721
virtual int t8_element_maxlevel(void) const
Return the maximum allowed level for this element class.
Definition: t8_default_quad_cxx.cxx:41
virtual t8_element_shape_t t8_element_face_shape(const t8_element_t *elem, int face) const
Compute the shape of the face of an element.
Definition: t8_default_quad_cxx.cxx:308
virtual void t8_element_boundary_face(const t8_element_t *elem, int face, t8_element_t *boundary, const t8_eclass_scheme_c *boundary_scheme) const
Construct the boundary element at a specific face.
Definition: t8_default_quad_cxx.cxx:585
virtual int t8_element_tree_face(const t8_element_t *elem, int face) const
Given an element and a face of this element.
Definition: t8_default_quad_cxx.cxx:540
virtual void t8_element_successor(const t8_element_t *elem, t8_element_t *succ) const
Construct the successor in a uniform refinement of a given element.
Definition: t8_default_quad_cxx.cxx:284
virtual void t8_element_children_at_face(const t8_element_t *elem, int face, t8_element_t *children[], int num_children, int *child_indices) const
Given an element and a face of the element, compute all children of the element that touch the face.
Definition: t8_default_quad_cxx.cxx:315
virtual void t8_element_children(const t8_element_t *elem, int length, t8_element_t *c[]) const
Construct all children of a given element.
Definition: t8_default_quad_cxx.cxx:196
virtual void t8_element_MPI_Pack(t8_element_t **const elements, const unsigned int count, void *send_buffer, int buffer_size, int *position, sc_MPI_Comm comm) const
Pack multiple elements into contiguous memory, so they can be sent via MPI.
Definition: t8_default_quad_cxx.cxx:789
virtual int t8_element_num_face_children(const t8_element_t *elem, int face) const
Return the number of children of an element's face when the element is refined.
Definition: t8_default_quad_cxx.cxx:139
virtual void t8_element_transform_face(const t8_element_t *elem1, t8_element_t *elem2, int orientation, int sign, int is_smaller_face) const
Suppose we have two trees that share a common face f.
Definition: t8_default_quad_cxx.cxx:409
virtual void t8_element_to_string(const t8_element_t *elem, char *debug_string, const int string_size) const
Print a given element.
Definition: t8_default_quad_cxx.cxx:754
virtual int t8_element_max_num_faces(const t8_element_t *elem) const
Compute the maximum number of faces of a given element and all of its descendants.
Definition: t8_default_quad_cxx.cxx:126
virtual void t8_element_anchor(const t8_element_t *elem, int anchor[3]) const
Get the integer coordinates of the anchor node of an element.
Definition: t8_default_quad_cxx.cxx:655
virtual void t8_element_nca(const t8_element_t *elem1, const t8_element_t *elem2, t8_element_t *nca) const
Compute the nearest common ancestor of two elements.
Definition: t8_default_quad_cxx.cxx:294
virtual void t8_element_last_descendant(const t8_element_t *elem, t8_element_t *desc, int level) const
Compute the last descendant of a given element.
Definition: t8_default_quad_cxx.cxx:274
virtual int t8_element_face_parent_face(const t8_element_t *elem, int face) const
Given a face of an element return the face number of the parent of the element that matches the eleme...
Definition: t8_default_quad_cxx.cxx:390
virtual int t8_element_ancestor_id(const t8_element_t *elem, int level) const
Compute the ancestor id of an element, that is the child id at a given level.
Definition: t8_default_quad_cxx.cxx:226
virtual int t8_element_num_faces(const t8_element_t *elem) const
Compute the number of faces of a given element.
Definition: t8_default_quad_cxx.cxx:119
virtual int t8_element_child_id(const t8_element_t *elem) const
Compute the child id of an element.
Definition: t8_default_quad_cxx.cxx:219
virtual int t8_element_num_children(const t8_element_t *elem) const
Return the number of children of an element when it is refined.
Definition: t8_default_quad_cxx.cxx:132
virtual void t8_element_new(int length, t8_element_t **elem) const
Allocate memory for an array of quadrilaterals and initialize them.
Definition: t8_default_quad_cxx.cxx:705
virtual void t8_element_MPI_Pack_size(const unsigned int count, sc_MPI_Comm comm, int *pack_size) const
Determine an upper bound for the size of the packed message of count elements.
Definition: t8_default_quad_cxx.cxx:807
virtual int t8_element_is_root_boundary(const t8_element_t *elem, int face) const
Compute whether a given element shares a given face with its root tree.
Definition: t8_default_quad_cxx.cxx:614
virtual void t8_element_MPI_Unpack(void *recvbuf, const int buffer_size, int *position, t8_element_t **elements, const unsigned int count, sc_MPI_Comm comm) const
Unpack multiple elements from contiguous memory that was received via MPI.
Definition: t8_default_quad_cxx.cxx:828
virtual int t8_element_level(const t8_element_t *elem) const
Return the refinement level of an element.
Definition: t8_default_quad_cxx.cxx:47
virtual int t8_element_refines_irregular(void) const
Returns true, if there is one element in the tree, that does not refine into 2^dim children.
Definition: t8_default_quad_cxx.cxx:738
virtual int t8_element_is_valid(const t8_element_t *t) const
Query whether a given element can be considered as 'valid' and it is safe to perform any of the above...
Definition: t8_default_quad_cxx.cxx:746
virtual int t8_element_face_child_face(const t8_element_t *elem, int face, int face_child) const
Given a face of an element and a child number of a child of that face, return the face number of the ...
Definition: t8_default_quad_cxx.cxx:382
virtual int t8_element_get_face_corner(const t8_element_t *element, int face, int corner) const
Return the corner number of an element's face corner.
Definition: t8_default_quad_cxx.cxx:146
virtual int t8_element_is_family(t8_element_t *const *fam) const
Query whether a given set of elements is a family or not.
Definition: t8_default_quad_cxx.cxx:232
t8_default_scheme_quad_c()
The virtual table for a particular implementation of an element class.
Definition: t8_default_quad_cxx.cxx:765
virtual void t8_element_reference_coords(const t8_element_t *elem, const double *ref_coords, const size_t num_coords, double *out_coords) const
Convert points in the reference space of an element to points in the reference space of the tree.
Definition: t8_default_quad_cxx.cxx:697
virtual int t8_element_face_neighbor_inside(const t8_element_t *elem, t8_element_t *neigh, int face, int *neigh_face) const
Construct the face neighbor of a given element if this face neighbor is inside the root tree.
Definition: t8_default_quad_cxx.cxx:632
virtual int t8_element_get_corner_face(const t8_element_t *element, int corner, int face) const
Return the face numbers of the faces sharing an element's corner.
Definition: t8_default_quad_cxx.cxx:164
virtual void t8_element_vertex_reference_coords(const t8_element_t *elem, const int vertex, double coords[]) const
Compute the coordinates of a given element vertex inside a reference tree that is embedded into [0,...
Definition: t8_default_quad_cxx.cxx:681
virtual void t8_element_parent(const t8_element_t *elem, t8_element_t *parent) const
Compute the parent of a given element elem and store it in parent.
Definition: t8_default_quad_cxx.cxx:95
virtual void t8_element_child(const t8_element_t *elem, int childid, t8_element_t *child) const
Construct the child element of a given number.
Definition: t8_default_quad_cxx.cxx:173
virtual void t8_element_first_descendant_face(const t8_element_t *elem, int face, t8_element_t *first_desc, int level) const
Construct the first descendant of an element at a given level that touches a given face.
Definition: t8_default_quad_cxx.cxx:550
virtual void t8_element_last_descendant_face(const t8_element_t *elem, int face, t8_element_t *last_desc, int level) const
Construct the last descendant of an element at a given level that touches a given face.
Definition: t8_default_quad_cxx.cxx:568
virtual void t8_element_sibling(const t8_element_t *elem, int sibid, t8_element_t *sibling) const
Compute a specific sibling of a given quad element elem and store it in sibling.
Definition: t8_default_quad_cxx.cxx:107
virtual void t8_element_set_linear_id(t8_element_t *elem, int level, t8_linearidx_t id) const
Initialize the entries of an allocated element according to a given linear id in a uniform refinement...
Definition: t8_default_quad_cxx.cxx:244
virtual t8_linearidx_t t8_element_get_linear_id(const t8_element_t *elem, int level) const
Compute the linear id of a given element in a hypothetical uniform refinement of a given level.
Definition: t8_default_quad_cxx.cxx:255
virtual int t8_element_compare(const t8_element_t *elem1, const t8_element_t *elem2) const
Compare two elements.
Definition: t8_default_quad_cxx.cxx:80
virtual void t8_element_first_descendant(const t8_element_t *elem, t8_element_t *desc, int level) const
Compute the first descendant of a given element.
Definition: t8_default_quad_cxx.cxx:264
This struct holds virtual functions for a particular element class.
Definition: t8_element_cxx.hxx:41
uint64_t t8_linearidx_t
A type for storing SFC indices.
Definition: t8.h:109
We provide some functions that are useful across element classes.
TODO: document this.
Definitions of quad-specific functions.
struct t8_element t8_element_t
Opaque structure for a generic element, only used as pointer.
Definition: t8_element.h:42
This file defines basic operations on an element in a refinement tree.
t8_eclass_t t8_element_shape_t
Type definition for the geometric shape of an element.
Definition: t8_element_shape.h:38