t8  UNKNOWN
t8code is a C library to manage a forest of adaptive space-trees of general element classes in parallel.
t8_element_cxx.hxx
Go to the documentation of this file.
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 
30 #ifndef T8_ELEMENT_CXX_HXX
31 #define T8_ELEMENT_CXX_HXX
32 
33 #include <sc_refcount.h>
34 #include <t8_eclass.h>
35 #include <t8_element.h>
36 
37 T8_EXTERN_C_BEGIN ();
38 
41 {
42  protected:
43  size_t element_size;
44  void *ts_context;
46  public:
55  virtual ~t8_eclass_scheme ()
56  {
57  }
58 
66  virtual size_t
67  t8_element_size (void) const;
68 
73  virtual int
75  = 0;
76 
80  virtual int
81  t8_element_maxlevel (void) const
82  = 0;
83 
88  virtual int
89  t8_element_level (const t8_element_t *elem) const
90  = 0;
91 
99  virtual void
100  t8_element_copy (const t8_element_t *source, t8_element_t *dest) const
101  = 0;
102 
110  virtual int
111  t8_element_compare (const t8_element_t *elem1, const t8_element_t *elem2) const
112  = 0;
113 
120  virtual int
121  t8_element_equal (const t8_element_t *elem1, const t8_element_t *elem2) const
122  = 0;
123 
136  virtual void
137  t8_element_parent (const t8_element_t *elem, t8_element_t *parent) const
138  = 0;
139 
146  virtual int
148  = 0;
149 
161  virtual void
162  t8_element_sibling (const t8_element_t *elem, int sibid, t8_element_t *sibling) const
163  = 0;
164 
169  virtual int
171  = 0;
172 
177  virtual int
178  t8_element_num_faces (const t8_element_t *elem) const
179  = 0;
180 
186  virtual int
188  = 0;
189 
194  virtual int
196  = 0;
197 
203  virtual int
204  t8_element_num_face_children (const t8_element_t *elem, int face) const
205  = 0;
206 
219  virtual int
220  t8_element_get_face_corner (const t8_element_t *element, int face, int corner) const
221  = 0;
222 
235  virtual int
236  t8_element_get_corner_face (const t8_element_t *element, int corner, int face) const
237  = 0;
238 
246  virtual void
247  t8_element_child (const t8_element_t *elem, int childid, t8_element_t *child) const
248  = 0;
249 
259  virtual void
260  t8_element_children (const t8_element_t *elem, int length, t8_element_t *c[]) const
261  = 0;
262 
267  virtual int
268  t8_element_child_id (const t8_element_t *elem) const
269  = 0;
270 
277  virtual int
278  t8_element_ancestor_id (const t8_element_t *elem, int level) const
279  = 0;
280 
287  virtual int
288  t8_element_is_family (t8_element_t *const *fam) const
289  = 0;
290 
301  virtual void
302  t8_element_nca (const t8_element_t *elem1, const t8_element_t *elem2, t8_element_t *nca) const
303  = 0;
304 
313  virtual t8_element_shape_t
314  t8_element_face_shape (const t8_element_t *elem, int face) const
315  = 0;
316 
331  virtual void
332  t8_element_children_at_face (const t8_element_t *elem, int face, t8_element_t *children[], int num_children,
333  int *child_indices) const
334  = 0;
335 
356  virtual int
357  t8_element_face_child_face (const t8_element_t *elem, int face, int face_child) const
358  = 0;
359 
370  virtual int
371  t8_element_face_parent_face (const t8_element_t *elem, int face) const
372  = 0;
373 
387  virtual int
388  t8_element_tree_face (const t8_element_t *elem, int face) const
389  = 0;
390 
412  virtual void
413  t8_element_transform_face (const t8_element_t *elem1, t8_element_t *elem2, int orientation, int sign,
414  int is_smaller_face) const
415  = 0;
416 
430  virtual int
431  t8_element_extrude_face (const t8_element_t *face, const t8_eclass_scheme_c *face_scheme, t8_element_t *elem,
432  int root_face) const
433  = 0;
434 
446  virtual void
447  t8_element_boundary_face (const t8_element_t *elem, int face, t8_element_t *boundary,
448  const t8_eclass_scheme_c *boundary_scheme) const
449  = 0;
450 
459  virtual void
460  t8_element_first_descendant_face (const t8_element_t *elem, int face, t8_element_t *first_desc, int level) const
461  = 0;
462 
471  virtual void
472  t8_element_last_descendant_face (const t8_element_t *elem, int face, t8_element_t *last_desc, int level) const
473  = 0;
474 
481  virtual int
482  t8_element_is_root_boundary (const t8_element_t *elem, int face) const
483  = 0;
484 
500  virtual int
501  t8_element_face_neighbor_inside (const t8_element_t *elem, t8_element_t *neigh, int face, int *neigh_face) const
502  = 0;
509  virtual t8_element_shape_t
510  t8_element_shape (const t8_element_t *elem) const
511  = 0;
512 
520  virtual void
522  = 0;
523 
530  virtual t8_linearidx_t
531  t8_element_get_linear_id (const t8_element_t *elem, int level) const
532  = 0;
533 
540  virtual void
541  t8_element_first_descendant (const t8_element_t *elem, t8_element_t *desc, int level) const
542  = 0;
543 
550  virtual void
551  t8_element_last_descendant (const t8_element_t *elem, t8_element_t *desc, int level) const
552  = 0;
553 
558  virtual void
560  = 0;
561 
571  virtual void
572  t8_element_vertex_reference_coords (const t8_element_t *t, const int vertex, double coords[]) const
573  = 0;
574 
585  virtual void
586  t8_element_reference_coords (const t8_element_t *elem, const double *ref_coords, const size_t num_coords,
587  double *out_coords) const
588  = 0;
589 
601  virtual t8_gloidx_t
602  t8_element_count_leaves (const t8_element_t *t, int level) const
603  = 0;
604 
613  virtual t8_gloidx_t
615  = 0;
616 
617 #ifdef T8_ENABLE_DEBUG
634  virtual int
635  t8_element_is_valid (const t8_element_t *elem) const
636  = 0;
637 
645  virtual void
647  = 0;
648 
655  virtual void
656  t8_element_to_string (const t8_element_t *elem, char *debug_string, const int string_size) const
657  = 0;
658 #endif
659 
681  virtual void
682  t8_element_new (int length, t8_element_t **elem) const
683  = 0;
684 
699  virtual void
700  t8_element_init (int length, t8_element_t *elem) const
701  = 0;
702 
711  virtual void
712  t8_element_deinit (int length, t8_element_t *elem) const
713  = 0;
714 
723  virtual void
724  t8_element_destroy (int length, t8_element_t **elem) const
725  = 0;
726 
730  virtual void
732  = 0;
733 
742  virtual void
743  t8_element_MPI_Pack (t8_element_t **const elements, const unsigned int count, void *send_buffer, int buffer_size,
744  int *position, sc_MPI_Comm comm) const
745  = 0;
746 
752  virtual void
753  t8_element_MPI_Pack_size (const unsigned int count, sc_MPI_Comm comm, int *pack_size) const
754  = 0;
755 
764  virtual void
765  t8_element_MPI_Unpack (void *recvbuf, const int buffer_size, int *position, t8_element_t **elements,
766  const unsigned int count, sc_MPI_Comm comm) const
767  = 0;
768 };
769 
772 void
774 
775 T8_EXTERN_C_END ();
776 
777 #endif /* !T8_ELEMENT_CXX_HXX */
This struct holds virtual functions for a particular element class.
Definition: t8_element_cxx.hxx:41
virtual void t8_element_first_descendant_face(const t8_element_t *elem, int face, t8_element_t *first_desc, int level) const =0
Construct the first descendant of an element at a given level that touches a given face.
virtual void t8_element_root(t8_element_t *elem) const =0
create the root element
virtual int t8_element_num_face_children(const t8_element_t *elem, int face) const =0
Return the number of children of an element's face when the element is refined.
virtual t8_gloidx_t t8_element_count_leaves(const t8_element_t *t, int level) const =0
Count how many leaf descendants of a given uniform level an element would produce.
virtual t8_gloidx_t t8_element_count_leaves_from_root(int level) const =0
Count how many leaf descendants of a given uniform level the root element will produce.
virtual void t8_element_transform_face(const t8_element_t *elem1, t8_element_t *elem2, int orientation, int sign, int is_smaller_face) const =0
Suppose we have two trees that share a common face f.
virtual void t8_element_last_descendant_face(const t8_element_t *elem, int face, t8_element_t *last_desc, int level) const =0
Construct the last descendant of an element at a given level that touches a given face.
virtual size_t t8_element_size(void) const
The virtual table for a particular implementation of an element class.
Definition: t8_element_cxx.cxx:48
virtual void t8_element_init(int length, t8_element_t *elem) const =0
Initialize an array of allocated elements.
t8_eclass_t eclass
The element class.
Definition: t8_element_cxx.hxx:47
virtual int t8_element_compare(const t8_element_t *elem1, const t8_element_t *elem2) const =0
Compare two elements.
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 =0
Construct the boundary element at a specific face.
virtual int t8_element_child_id(const t8_element_t *elem) const =0
Compute the child id of an element.
virtual int t8_element_num_faces(const t8_element_t *elem) const =0
Compute the number of faces of a given element.
virtual void t8_element_destroy(int length, t8_element_t **elem) const =0
Deallocate an array of elements.
virtual void t8_element_deinit(int length, t8_element_t *elem) const =0
Deinitialize an array of allocated elements.
virtual t8_element_shape_t t8_element_face_shape(const t8_element_t *elem, int face) const =0
Compute the shape of the face of an element.
virtual int t8_element_equal(const t8_element_t *elem1, const t8_element_t *elem2) const =0
Check if two elements are equal.
virtual int t8_element_level(const t8_element_t *elem) const =0
Return the level of a particular element.
virtual int t8_element_num_children(const t8_element_t *elem) const =0
Return the number of children of an element when it is refined.
virtual int t8_element_face_parent_face(const t8_element_t *elem, int face) const =0
Given a face of an element return the face number of the parent of the element that matches the eleme...
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 =0
Pack multiple elements into contiguous memory, so they can be sent via MPI.
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 =0
Given a boundary face inside a root tree's face construct the element inside the root tree that has t...
virtual int t8_element_refines_irregular(void) const =0
Returns true, if there is one element in the tree, that does not refine into 2^dim children.
size_t element_size
The size in bytes of an element of class eclass.
Definition: t8_element_cxx.hxx:43
virtual int t8_element_is_valid(const t8_element_t *elem) const =0
Query whether a given element can be considered as 'valid' and it is safe to perform any of the above...
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 =0
Given an element and a face of the element, compute all children of the element that touch the face.
virtual void t8_element_children(const t8_element_t *elem, int length, t8_element_t *c[]) const =0
Construct all children of a given element.
virtual void t8_element_MPI_Pack_size(const unsigned int count, sc_MPI_Comm comm, int *pack_size) const =0
Determine an upper bound for the size of the packed message of count elements.
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 =0
Unpack multiple elements from contiguous memory that was received via MPI.
virtual void t8_element_first_descendant(const t8_element_t *elem, t8_element_t *desc, int level) const =0
Compute the first descendant of a given element.
virtual int t8_element_maxlevel(void) const =0
Return the maximum allowed level for any element of a given class.
virtual void t8_element_last_descendant(const t8_element_t *elem, t8_element_t *desc, int level) const =0
Compute the last descendant of a given element.
virtual void t8_element_set_linear_id(t8_element_t *elem, int level, t8_linearidx_t id) const =0
Initialize the entries of an allocated element according to a given linear id in a uniform refinement...
virtual int t8_element_get_corner_face(const t8_element_t *element, int corner, int face) const =0
Return the face numbers of the faces sharing an element's corner.
virtual int t8_element_max_num_faces(const t8_element_t *elem) const =0
Compute the maximum number of faces of a given element and all of its descendants.
virtual int t8_element_get_face_corner(const t8_element_t *element, int face, int corner) const =0
Return the corner number of an element's face corner.
virtual int t8_element_is_family(t8_element_t *const *fam) const =0
Query whether a given set of elements is a family or not.
virtual int t8_element_ancestor_id(const t8_element_t *elem, int level) const =0
Compute the ancestor id of an element, that is the child id at a given level.
virtual void t8_element_child(const t8_element_t *elem, int childid, t8_element_t *child) const =0
Construct the child element of a given number.
virtual int t8_element_num_corners(const t8_element_t *elem) const =0
Compute the number of corners of a given element.
virtual void t8_element_parent(const t8_element_t *elem, t8_element_t *parent) const =0
Compute the parent of a given element elem and store it in parent.
virtual void t8_element_to_string(const t8_element_t *elem, char *debug_string, const int string_size) const =0
Fill a string with readable information about the element.
void * ts_context
Anonymous implementation context.
Definition: t8_element_cxx.hxx:44
virtual int t8_element_face_child_face(const t8_element_t *elem, int face, int face_child) const =0
Given a face of an element and a child number of a child of that face, return the face number of the ...
virtual ~t8_eclass_scheme()
The destructor.
Definition: t8_element_cxx.hxx:55
virtual t8_element_shape_t t8_element_shape(const t8_element_t *elem) const =0
Return the shape of an allocated element according its type.
virtual int t8_element_num_siblings(const t8_element_t *elem) const =0
Compute the number of siblings of an element.
virtual void t8_element_sibling(const t8_element_t *elem, int sibid, t8_element_t *sibling) const =0
Compute a specific sibling of a given element elem and store it in sibling.
virtual void t8_element_copy(const t8_element_t *source, t8_element_t *dest) const =0
Copy all entries of source to dest.
virtual void t8_element_vertex_reference_coords(const t8_element_t *t, const int vertex, double coords[]) const =0
Compute the coordinates of a given element vertex inside a reference tree that is embedded into [0,...
virtual void t8_element_debug_print(const t8_element_t *elem) const =0
Print a given element.
virtual t8_linearidx_t t8_element_get_linear_id(const t8_element_t *elem, int level) const =0
Compute the linear id of a given element in a hypothetical uniform refinement of a given level.
virtual int t8_element_face_neighbor_inside(const t8_element_t *elem, t8_element_t *neigh, int face, int *neigh_face) const =0
Construct the face neighbor of a given element if this face neighbor is inside the root tree.
virtual void t8_element_reference_coords(const t8_element_t *elem, const double *ref_coords, const size_t num_coords, double *out_coords) const =0
Convert points in the reference space of an element to points in the reference space of the tree.
virtual void t8_element_successor(const t8_element_t *t, t8_element_t *s) const =0
Construct the successor in a uniform refinement of a given element.
virtual void t8_element_new(int length, t8_element_t **elem) const =0
Allocate memory for length many elements of a given class and initialize them, and put pointers to th...
virtual int t8_element_is_root_boundary(const t8_element_t *elem, int face) const =0
Compute whether a given element shares a given face with its root tree.
virtual int t8_element_tree_face(const t8_element_t *elem, int face) const =0
Given an element and a face of this element.
virtual void t8_element_nca(const t8_element_t *elem1, const t8_element_t *elem2, t8_element_t *nca) const =0
Compute the nearest common ancestor of two elements.
The scheme holds implementations for one or more element classes.
Definition: t8_element.h:51
int64_t t8_gloidx_t
A type for global indexing that holds really big numbers.
Definition: t8.h:100
uint64_t t8_linearidx_t
A type for storing SFC indices.
Definition: t8.h:109
We define all possible element classes that occur in hybrid meshes.
enum t8_eclass t8_eclass_t
This enumeration contains all possible element classes.
This file defines basic operations on an element in a refinement tree.
struct t8_element t8_element_t
Opaque structure for a generic element, only used as pointer.
Definition: t8_element.h:42
void t8_scheme_cxx_destroy(t8_scheme_cxx_t *s)
Destroy an implementation of a particular element class.
Definition: t8_element_cxx.cxx:31
t8_eclass_t t8_element_shape_t
Type definition for the geometric shape of an element.
Definition: t8_element_shape.h:38