next up previous contents
Next: Routines to Traverse the Up: An Interface Recipe Previous: Data Structures of the

get_new_hmesh()

The initialization routine of the interface mask gets a new instance of HMESH2D and fills in the neccessary data. In the interface mask it looks like that:

HMESH2D* get_new_hmesh(USER_MESH* user_mesh,...)
{
  HMESH2D* hmesh;
  
  hmesh = (HMESH2D*)GRAPE(HMesh2d,"new-instance")("name of hmesh");
  ASSURE(hmesh,"get_new_hmesh: can't get new hmesh instance",return NULL);
 
  hmesh->first_macro          = interface_first_macro;
  hmesh->next_macro           = interface_next_macro;
  hmesh->first_child          = interface_first_child;
  hmesh->next_child           = interface_next_child;
  hmesh->select_child         = interface_select_child;
  hmesh->first_element        = interface_first_element;
  hmesh->next_element         = interface_next_element;
 
  hmesh->max_level              = ...; 
  hmesh->max_vindex             = ...;
  hmesh->level_of_interest      = ...;
  hmesh->dimension_of_world     = ...;
  hmesh->max_dimension_of_coord = ...;
  hmesh->max_number_of_vertices = MAX_NUMBER_OF_VERTICES_PER_ELEMENT;
  hmesh->geometry_data          = (void*)...;  /* 2D-case only */


  /* in 2D-case */

  hmesh->get_geometry_vertex_estimate  = 
    interface_get_geometry_vertex_estimate;

  hmesh->get_geometry_element_estimate = 
    interface_get_geometry_element_estimate;


  /* fill the helement description */

  helement_description->number_of_vertices = ...;
  helement_description->dimension_of_coord = ...;
  helement_description->coord              = ...;
  helement_description->parametric_degree  = ...;
  helement_description->world_to_coord     = ...;
  helement_description->coord_to_world     = ...;

  helement_description->check_inside    = helement_description_check_inside;
  helement_description->neighbour       = helement_description_neighbour;
  helement_description->boundary        = helement_description_boundary;
  helement_description->coord_of_parent = helement_description_coord_of_parent;
  
  /* inheritance rules */

  inheritance_rule[0]->np      = ...; /* number of parent points */
  inheritance_rule[0]->pindex  = ...;
  inheritance_rule[0]->pweight = ...;

  ...

  inheritance_rule[n]->np      = ...; /* number of parent points */
  inheritance_rule[n]->pindex  = ...;
  inheritance_rule[n]->pweight = ...;

  return hmesh;
}

In our example this becomes:

HMESH2D* get_new_hmesh(BISMESH* bismesh)
{
  HMESH2D* hmesh;
  
  hmesh = (HMESH2D*)GRAPE(HMesh2d,"new-instance")("my sample bismesh");
  ASSURE(hmesh,"get_new_hmesh: can't get new hmesh instance",return NULL);
 
  hmesh->first_macro          = interface_first_macro;
  hmesh->next_macro           = interface_next_macro;
  hmesh->first_child          = interface_first_child;
  hmesh->next_child           = interface_next_child;
  hmesh->select_child         = interface_select_child;
  hmesh->first_element        = interface_first_element;
  hmesh->next_element         = interface_next_element;

  hmesh->max_level              = bismesh->max_level; 
  hmesh->max_vindex             = bismesh->number_points;
  hmesh->user_data              = (void*)bismesh;
  hmesh->level_of_interest      = 1; /* can be changed interactively later */
  hmesh->dimension_of_world     = 3;
  hmesh->max_dimension_of_coord = 3;
  hmesh->max_number_of_vertices = MAX_NUMBER_OF_VERTICES_PER_ELEMENT;
  hmesh->geometry_data          = NULL;


  /* in 2D-case, see I.5 */

  hmesh->get_geometry_vertex_estimate  = 
    get_geometry_vertex_estimate;

  hmesh->get_geometry_element_estimate = 
    get_geometry_element_estimate;


  /* fill the helement description */

  helement_description.number_of_vertices = 3;
  helement_description.dimension_of_coord = 3; /* number of local coords 
                                                  on an element */
  helement_description.coord              = local_coordinate_system;
  helement_description.parametric_degree  = 1;
  helement_description.world_to_coord     = triangle_world_to_coord;
  helement_description.coord_to_world     = triangle_coord_to_world;
  helement_description.check_inside       = triangle_check_inside;

  helement_description.neighbour       = helement_description_neighbour;
  helement_description.boundary        = helement_description_boundary;
  helement_description.coord_of_parent = helement_description_coord_of_parent;
  
  /* inheritance rules */

  inheritance_rule_in_child_0[0] = vinherit_point_0;
  inheritance_rule_in_child_0[1] = vinherit_point_1_in_child_0;
  inheritance_rule_in_child_0[2] = vinherit_point_2_in_child_0;

  inheritance_rule_in_child_1[0] = vinherit_point_0;
  inheritance_rule_in_child_1[1] = vinherit_point_1_in_child_1;
  inheritance_rule_in_child_1[2] = vinherit_point_2_in_child_1;

  return hmesh;
}
The inheritance rules defined at the bottom describe how points in a child element can be expressed as a convex combination of points in the parent element.

figure896


For the bisection of triangles there are the following six inheritance rules:

static VINHERIT inheritance_rule_in_child_0[3]; 
static VINHERIT inheritance_rule_in_child_1[3];

static int        pindex_point_0[2] = {1  ,2  };
static double    pweight_point_0[2] = {0.5,0.5};
static VINHERIT vinherit_point_0    = {2,pindex_point_0,pweight_point_0};

static double pweight_point_1_or_2[1] = {1.0};

static int        pindex_point_1_in_child_0[1] = {2};
static VINHERIT vinherit_point_1_in_child_0    = 
        {1,pindex_point_1_in_child_0,pweight_point_1_or_2};

static int        pindex_point_2_in_child_0[1] = {0};
static VINHERIT vinherit_point_2_in_child_0    = 
        {1,pindex_point_2_in_child_0,pweight_point_1_or_2};

static int        pindex_point_1_in_child_1[1] = {0};
static VINHERIT vinherit_point_1_in_child_1    = 
        {1,pindex_point_1_in_child_1,pweight_point_1_or_2};

static int        pindex_point_2_in_child_1[1] = {1};
static VINHERIT vinherit_point_2_in_child_1    = 
        {1,pindex_point_2_in_child_1,pweight_point_1_or_2};
The meaning of the VINHERIT are discussed in detail in 1.
next up previous contents
Next: Routines to Traverse the Up: An Interface Recipe Previous: Data Structures of the

SFB 256 Universität Bonn and IAM Universität Freiburg

Copyright © by the Sonderforschungsbereich 256 at the Institut für Angewandte Mathematik, Universität Bonn.