t8  1.2.0
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 
39 /* TODO: Implement a set of rules that have to hold between different eclass,
40  * i.e. lines must have a greater or equal maxlevel than quads and triangles.
41  * Check whether this rules are fulfilled in the construction of a scheme.
42  */
43 /* TODO: Implement a test that boundary and extrude leads to the original element. */
44 
47 {
49 protected:
50  size_t element_size;
51  void *ts_context;
53 public:
62  virtual ~ t8_eclass_scheme ()
63  {
64  }
65 
73  virtual size_t t8_element_size (void) const;
74 
79  virtual int t8_element_refines_irregular (void) const = 0;
80 
84  virtual int t8_element_maxlevel (void) const = 0;
85 
91  virtual t8_eclass_t t8_element_child_eclass (int childid) const = 0;
92 
97  virtual int t8_element_level (const t8_element_t *elem) const = 0;
98 
106  virtual void t8_element_copy (const t8_element_t *source,
107  t8_element_t *dest) const = 0;
108 
116  virtual int t8_element_compare (const t8_element_t *elem1,
117  const t8_element_t *elem2) const =
118  0;
119 
132  virtual void t8_element_parent (const t8_element_t *elem,
133  t8_element_t *parent) const = 0;
134 
141  virtual int t8_element_num_siblings (const t8_element_t *elem) const
142  = 0;
143 
155  virtual void t8_element_sibling (const t8_element_t *elem,
156  int sibid,
157  t8_element_t *sibling) const = 0;
158 
163  virtual int t8_element_num_corners (const t8_element_t *elem) const
164  = 0;
165 
170  virtual int t8_element_num_faces (const t8_element_t *elem) const =
171  0;
172 
178  virtual int t8_element_max_num_faces (const t8_element_t *elem)
179  const = 0;
180 
185  virtual int t8_element_num_children (const t8_element_t *elem) const
186  = 0;
187 
193  virtual int t8_element_num_face_children (const t8_element_t *elem,
194  int face) const = 0;
195 
214  /* TODO: Prism order, Pyramid order. */
215  virtual int t8_element_get_face_corner (const t8_element_t *element,
216  int face,
217  int corner) const = 0;
218 
231  virtual int t8_element_get_corner_face (const t8_element_t *element,
232  int corner,
233  int face) const = 0;
234 
247  virtual void t8_element_child (const t8_element_t *elem,
248  int childid,
249  t8_element_t *child) const = 0;
250 
262  virtual void t8_element_children (const t8_element_t *elem,
263  int length,
264  t8_element_t *c[]) const = 0;
265 
270  virtual int t8_element_child_id (const t8_element_t *elem) const =
271  0;
272 
279  virtual int t8_element_ancestor_id (const t8_element_t *elem,
280  int level) const = 0;
281 
288  virtual int t8_element_is_family (t8_element_t **fam) const = 0;
289 
290  /* TODO: This could be problematic for pyramids, since elem1 and elem2
291  * could be of different classes. Would need two eclass_schemes as input */
302  virtual void t8_element_nca (const t8_element_t *elem1,
303  const t8_element_t *elem2,
304  t8_element_t *nca) const = 0;
305 
315  int face) const = 0;
316 
331  virtual void t8_element_children_at_face (const t8_element_t *elem,
332  int face,
333  t8_element_t *children[],
334  int num_children,
335  int *child_indices) const =
336  0;
337 
358  virtual int t8_element_face_child_face (const t8_element_t *elem,
359  int face,
360  int face_child) const = 0;
361 
372  virtual int t8_element_face_parent_face (const t8_element_t *elem,
373  int face) const = 0;
374 
388  virtual int t8_element_tree_face (const t8_element_t *elem,
389  int face) const = 0;
390 
412  virtual void t8_element_transform_face (const t8_element_t *elem1,
413  t8_element_t *elem2,
414  int orientation,
415  int sign,
416  int is_smaller_face) const =
417  0;
418 
432  virtual int t8_element_extrude_face (const t8_element_t *face,
433  const t8_eclass_scheme_c
434  *face_scheme,
435  t8_element_t *elem,
436  int root_face) const = 0;
437 
449  virtual void t8_element_boundary_face (const t8_element_t *elem,
450  int face,
451  t8_element_t *boundary,
452  const t8_eclass_scheme_c
453  *boundary_scheme) const = 0;
454 
464  *elem, int face,
466  *first_desc,
467  int level) const = 0;
468 
478  *elem, int face,
480  *last_desc,
481  int level) const = 0;
482 
483  /* TODO: Do we need this function at all?
484  * If not remove it. If so, what to do with prisms and pyramids?
485  * Here the boundary elements are of different eclasses, so we cannot
486  * store them in an array...
487  */
493  virtual void t8_element_boundary (const t8_element_t *elem,
494  int min_dim, int length,
495  t8_element_t **boundary) const = 0;
496 
503  virtual int t8_element_is_root_boundary (const t8_element_t *elem,
504  int face) const = 0;
505 
522  *elem,
523  t8_element_t *neigh,
524  int face,
525  int *neigh_face) const
526  = 0;
534  = 0;
535 
544  int level,
545  t8_linearidx_t id) const = 0;
546 
554  t8_element_t *elem,
555  int level) const = 0;
556 
563  virtual void t8_element_first_descendant (const t8_element_t *elem,
564  t8_element_t *desc,
565  int level) const = 0;
566 
573  virtual void t8_element_last_descendant (const t8_element_t *elem,
574  t8_element_t *desc,
575  int level) const = 0;
576 
582  virtual void t8_element_successor (const t8_element_t *t,
583  t8_element_t *s,
584  int level) const = 0;
585 
586 /* TODO: This function should be removed, since root length is not a general concept that exists for all possible elements. */
592  virtual int t8_element_root_len (const t8_element_t *elem) const =
593  0;
594 
603  *t,
604  const int vertex,
605  double coords[])
606  const = 0;
607 
616  virtual void t8_element_reference_coords (const t8_element_t *elem,
617  const double *ref_coords,
618  const void *user_data,
619  double *out_coords)
620  const = 0;
621 
622  /* TODO: deactivate */
630  virtual t8_element_t *t8_element_array_index (sc_array_t *array,
631  size_t it) const;
632 
645  int level) const = 0;
646 
655  virtual t8_gloidx_t t8_element_count_leafs_from_root (int level) const = 0;
656 
668  virtual void t8_element_general_function (const t8_element_t *elem,
669  const void *indata,
670  void *outdata) const = 0;
671 
672 #ifdef T8_ENABLE_DEBUG
689  virtual int t8_element_is_valid (const t8_element_t *elem) const =
690  0;
691 
699  virtual void t8_element_debug_print (const t8_element_t *elem) const
700  = 0;
701 #endif
702 
720  /* TODO: would it be better to directly allocate an array of elements,
721  * not element pointers? */
722  virtual void t8_element_new (int length, t8_element_t **elem) const =
723  0;
724 
742  virtual void t8_element_init (int length, t8_element_t *elem,
743  int called_new) const = 0;
744 
752  virtual void t8_element_destroy (int length,
753  t8_element_t **elem) const = 0;
754 };
755 
759 
760 T8_EXTERN_C_END ();
761 
762 #endif /* !T8_ELEMENT_CXX_HXX */
This struct holds virtual functions for a particular element class.
Definition: t8_element_cxx.hxx:47
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 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 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:49
virtual int t8_element_is_family(t8_element_t **fam) const =0
Query whether a given set of elements is a family or not.
t8_eclass_t eclass
The element class.
Definition: t8_element_cxx.hxx:54
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 t8_eclass_t t8_element_child_eclass(int childid) const =0
Return the type of each child in the ordering of the implementation.
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_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 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 t8_gloidx_t t8_element_count_leafs_from_root(int level) const =0
Count how many leaf descendants of a given uniform level the root element will produce.
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
This scheme defines the operations for a particular element class.
Definition: t8_element_cxx.hxx:50
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 t8_element_t * t8_element_array_index(sc_array_t *array, size_t it) const
Return a pointer to a t8_element in an array indexed by a size_t.
Definition: t8_element_cxx.cxx:57
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 int t8_element_root_len(const t8_element_t *elem) const =0
Compute the root length of a given element, that is the length of its level 0 ancestor.
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 void t8_element_successor(const t8_element_t *t, t8_element_t *s, int level) const =0
Construct the successor in a uniform refinement of a given element.
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 void t8_element_general_function(const t8_element_t *elem, const void *indata, void *outdata) const =0
This function has no defined effect but each implementation is free to provide its own meaning of it.
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_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 ~ t8_eclass_scheme()
The destructor.
Definition: t8_element_cxx.hxx:62
virtual void t8_element_reference_coords(const t8_element_t *elem, const double *ref_coords, const void *user_data, double *out_coords) const =0
Convert a point in the reference space of an element to a point in the reference space of the tree.
void * ts_context
Anonymous implementation context.
Definition: t8_element_cxx.hxx:51
virtual void t8_element_init(int length, t8_element_t *elem, int called_new) const =0
Initialize an array of allocated elements.
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_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_boundary(const t8_element_t *elem, int min_dim, int length, t8_element_t **boundary) const =0
Construct all codimension-one boundary elements of a given element.
virtual t8_gloidx_t t8_element_count_leafs(const t8_element_t *t, int level) const =0
Count how many leaf descendants of a given uniform level an element would produce.
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 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_new(int length, t8_element_t **elem) const =0
Allocate memory for an array of elements of a given class and initialize them.
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:105
uint64_t t8_linearidx_t
A type for storing SFC indices.
Definition: t8.h:114
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