3#ifndef __GRAPE_ELDESC_H__
4#define __GRAPE_ELDESC_H__
15typedef HELEMENT3D HELEMENT;
16typedef ELEMENT3D ELEMENT;
18typedef HMESH GRAPEMESH;
19typedef GENMESH3D GENMESHnD;
20typedef HELEMENT3D_DESCRIPTION H_ELEMENT_DESCRIPTION;
21typedef ELEMENT3D_DESCRIPTION ELEMENT_DESCRIPTION;
22typedef F_HDATA3D F_DATA;
23typedef F_HEL_INFO3D F_EL_INFO;
25#define GenMesh GenMesh3d
26#define GrapeMesh HMesh
28typedef HELEMENT2D HELEMENT;
29typedef ELEMENT2D ELEMENT;
30typedef GENMESH2D GENMESHnD;
31typedef HELEMENT2D_DESCRIPTION H_ELEMENT_DESCRIPTION;
32typedef ELEMENT2D_DESCRIPTION ELEMENT_DESCRIPTION;
33typedef F_HEL_INFO2D F_EL_INFO;
36typedef HPMESH2D HMESH;
37typedef F_HPDATA2D F_DATA;
45typedef HMESH GRAPEMESH;
46#define GenMesh GenMesh2d
47#define GrapeMesh HMesh
53{gr_vertex=6,gr_line=7,
56 gr_triangle=0, gr_quadrilateral=1,gr_tetrahedron=2,
57 gr_pyramid=3, gr_prism=4, gr_hexahedron=5,
58 gr_iso_triangle=8, gr_iso_quadrilateral=9,
60enum { numberOfUsedGrapeElementTypes = 6 };
67static HELEMENT2D_DESCRIPTION triangle_description;
69static double triangle_local_coordinate_vector_0[3] = {0.,0.,0.};
70static double triangle_local_coordinate_vector_1[3] = {1.,0.,0.};
71static double triangle_local_coordinate_vector_2[3] = {0.,1.,0.};
73static G_CONST
double *triangle_local_coordinate_system[3] = {triangle_local_coordinate_vector_0,
74 triangle_local_coordinate_vector_1,
75 triangle_local_coordinate_vector_2};
87static VINHERIT inheritance_rule_in_child_0[3];
88static VINHERIT inheritance_rule_in_child_1[3];
90static double pweight_point_0_or_1[1] = {1.0};
92static int pindex_point_0_in_child_0[1] = {2};
93static VINHERIT vinherit_point_0_in_child_0 = {1,
94 pindex_point_0_in_child_0,
95 pweight_point_0_or_1};
98static int pindex_point_1_in_child_0[1] = {0};
99static VINHERIT vinherit_point_1_in_child_0 = {1,
100 pindex_point_1_in_child_0,
101 pweight_point_0_or_1};
103static int pindex_point_0_in_child_1[1] = {1};
104static VINHERIT vinherit_point_0_in_child_1 = {1,
105 pindex_point_0_in_child_1,
106 pweight_point_0_or_1};
108static int pindex_point_1_in_child_1[1] = {2};
109static VINHERIT vinherit_point_1_in_child_1 = {1,
110 pindex_point_1_in_child_1,
111 pweight_point_0_or_1};
113static int pindex_point_2[2] = {0 ,1 };
114static double pweight_point_2[2] = {0.5,0.5};
115static VINHERIT vinherit_point_2 = {2,pindex_point_2,pweight_point_2};
127inline static HELEMENT2D * triangle_neighbour(HELEMENT2D *el,
int np,
int flag,
129 double * coord,
double * xyz, MESH_ELEMENT_FLAGS p) {
130 printf(
" neighbour nicht implementiert \n");
134inline int triangle_boundary(HELEMENT2D * el,
int np) {
135 return ((DUNE_ELEM *)el->user_data)->bnd[np] ;
146inline int el_check_inside(HELEMENT2D * e,
const double * coord)
148 DUNE_DAT * dat = (DUNE_DAT *) ((HMESH2D *) e->mesh)->user_data;
149 return dat->check_inside((DUNE_ELEM *) e->user_data, coord);
152inline int world2coord(HELEMENT2D * e,
const double * xyz,
double * coord)
154 DUNE_DAT * dat = (DUNE_DAT *) ((HMESH2D *) e->mesh)->user_data;
155 return dat->wtoc((DUNE_ELEM *) e->user_data, xyz, coord);
158inline void coord2world(HELEMENT2D * e,
const double * coord,
double * xyz)
160 DUNE_DAT * dat = (DUNE_DAT *) ((HMESH2D *) e->mesh)->user_data;
161 dat->ctow((DUNE_ELEM *) e->user_data, coord, xyz);
165inline int el_check_inside_3d(HELEMENT3D * e,
double * coord)
167 DUNE_DAT * dat = (DUNE_DAT *) ((HMESH3D *) e->mesh)->user_data;
168 return dat->check_inside((DUNE_ELEM *) e->user_data, coord);
171inline static int world2coord_3d(HELEMENT3D * e,
const double * xyz,
174 DUNE_DAT * dat = (DUNE_DAT *) ((HMESH3D *) e->mesh)->user_data;
175 return dat->wtoc((DUNE_ELEM *) e->user_data, xyz, coord);
178inline static void coord2world_3d(HELEMENT3D * e,
const double * coord,
181 DUNE_DAT * dat = (DUNE_DAT *) ((HMESH3D *) e->mesh)->user_data;
182 dat->ctow((DUNE_ELEM *) e->user_data, coord, xyz);
204static bool Grape_ReferenceElementsInitialized = false ;
206static HELEMENT2D_DESCRIPTION quadrilateral_description;
208static double quadrilateral_local_coordinate_vector_0[3] = {0.,0.,0.};
209static double quadrilateral_local_coordinate_vector_1[3] = {1.,0.,0.};
210static double quadrilateral_local_coordinate_vector_2[3] = {1.,1.,0.};
211static double quadrilateral_local_coordinate_vector_3[3] = {0.,1.,0.};
213static G_CONST
double *quadrilateral_local_coordinate_system[4] = {quadrilateral_local_coordinate_vector_0,
214 quadrilateral_local_coordinate_vector_1,quadrilateral_local_coordinate_vector_2,
215 quadrilateral_local_coordinate_vector_3};
223static HELEMENT3D_DESCRIPTION tetra_description;
226static int t_v0_e[3] = {1,3,2}, t_v1_e[3] = {0,2,3};
227static int t_v2_e[3] = {0,3,1}, t_v3_e[3] = {0,1,2};
230static int t_p0_e[3] = {2,1,3}, t_p1_e[3] = {3,0,2};
231static int t_p2_e[3] = {1,0,3}, t_p3_e[3] = {2,0,1};
238static double t_c0[3] = {0.,0.,0.}, t_c1[3] = {1.,0.,0.};
239static double t_c2[3] = {0.,1.,0.}, t_c3[3] = {0.,0.,1.};
241static int tetra_polygon_length[4] = {3, 3, 3, 3};
242static G_CONST
int *tetra_vertex_e[4] = {t_v0_e,t_v1_e,t_v2_e,t_v3_e};
243static G_CONST
int *tetra_next_polygon_e[4] = {t_p0_e,t_p1_e,t_p2_e,t_p3_e};
244static G_CONST
double *tetra_local_coordinate_system[4] = {t_c0,t_c1,t_c2,t_c3};
255inline static HELEMENT3D * dummy_neighbour(HELEMENT3D *el,
int np,
int flag,
257 double * coord,
double * xyz, MESH_ELEMENT_FLAGS p) {
259 printf(
" neighbour nicht implementiert \n");
264inline static int wrap_boundary(HELEMENT3D * el,
int np)
266 return ((DUNE_ELEM *)el->user_data)->bnd[np] ;
306static HELEMENT3D_DESCRIPTION cube_description;
309static VEC3 cc1={0.,0.,0.},cc2={1.,0.,0.},cc3={1.,1.,0.},cc4={0.,1.,0.},
310 cc5={0.,0.,1.},cc6={1.,0.,1.},cc7={1.,1.,1.},cc8={0.,1.,1.};
311static G_CONST
double *cube_local_coordinate_system[8] = {cc1,cc2,cc3,cc4,cc5,cc6,cc7,cc8};
313static int cube_polygon_length[6] = {4,4,4,4,4,4};
315static int cv1[4]={0,3,2,1},cv2[4]={4,5,6,7},cv3[4]={0,1,5,4},
316 cv4[4]={1,2,6,5},cv5[4]={2,3,7,6},cv6[4]={0,4,7,3};
317static G_CONST
int *cube_polygon_vertex[6] = {cv1,cv2,cv3,cv4,cv5,cv6};
318static int cn1[4]={5,4,3,2},cn2[4]={2,3,4,5},cn3[4]={0,3,1,5},
319 cn4[4]={0,4,1,2},cn5[4]={0,5,1,3},cn6[4]={2,1,4,0};
320static G_CONST
int *cube_polygon_neighbour[6] = {cn1,cn2,cn3,cn4,cn5,cn6};
331static HELEMENT3D_DESCRIPTION pyra_description;
333static VEC3 pyc1={0.,0.,0.},pyc2={1.,0.,0.},pyc3={1.,1.,0.},
334 pyc4={0.,1.,0.},pyc5={0.,0.,1.};
335static G_CONST
double *pyra_local_coordinate_system[5] = {pyc1,pyc2,pyc3,pyc4,pyc5};
337static int pyra_polygon_length[5] = {4,3,3,3,3};
338static int pyv1[4]={0,1,2,3},pyv2[3]={0,4,1},pyv3[3]={1,4,2},
339 pyv4[3]={2,4,3} ,pyv5[3]={0,3,4};
340static G_CONST
int *pyra_polygon_vertex[5] = {pyv1,pyv2,pyv3,pyv4,pyv5};
342static int pyn1[4]={5,4,3,2},pyn2[3]={0,2,4},pyn3[3]={0,3,1},
343 pyn4[3]={0,4,2} ,pyn5[3]={0,1,3};
344static G_CONST
int *pyra_polygon_neighbour[5] = {pyn1,pyn2,pyn3,pyn4,pyn5};
355static HELEMENT3D_DESCRIPTION prism_description;
357static VEC3 prc1={0.,0.,0.},prc2={1.,0.,0.},prc3={0.,1.,0.},
358 prc4={0.,0.,1.},prc5={1.,0.,1.},prc6={0.,1.,1.};
359static G_CONST
double *prism_local_coordinate_system[6] = {prc1,prc2,prc3,prc4,prc5,prc6};
362static int prism_polygon_length[5] = {3,4,4,4,3};
365static int prv1[3]={0,1,2}, prv2[4]={0,1,4,3},prv3[4]={1,2,5,4},
366 prv4[4]={2,0,3,5},prv5[3]={3,4,5};
368static G_CONST
int *prism_polygon_vertex[5] = {prv1,prv2,prv3,prv4,prv5};
370static int prn1[4]={5,4,3,2},prn2[4]={2,3,4,5},prn3[4]={0,3,1,5},
371 prn4[4]={0,4,1,2},prn5[4]={0,5,1,3},prn6[4]={2,1,4,0};
372static G_CONST
int *prism_polygon_neighbour[6] = {prn1,prn2,prn3,prn4,prn5,prn6};
377inline void setupReferenceElements()
379 if( ! Grape_ReferenceElementsInitialized )
383 triangle_description.dindex = gr_triangle;
384 triangle_description.number_of_vertices = 3;
386 triangle_description.dimension_of_coord = GRAPE_DIM;
387 triangle_description.coord = triangle_local_coordinate_system;
388 triangle_description.parametric_degree = 1;
389 triangle_description.world_to_coord = world2coord;
390 triangle_description.coord_to_world = coord2world;
391 triangle_description.check_inside = el_check_inside;
392 triangle_description.neighbour = triangle_neighbour;
393 triangle_description.boundary = triangle_boundary;
396 quadrilateral_description.dindex = gr_quadrilateral;
397 quadrilateral_description.number_of_vertices = 4;
398 quadrilateral_description.dimension_of_coord = GRAPE_DIM;
399 quadrilateral_description.coord = quadrilateral_local_coordinate_system;
400 quadrilateral_description.parametric_degree = 1;
401 quadrilateral_description.world_to_coord = world2coord;
402 quadrilateral_description.coord_to_world = coord2world;
403 quadrilateral_description.check_inside = el_check_inside;
404 quadrilateral_description.neighbour = triangle_neighbour;
405 quadrilateral_description.boundary = triangle_boundary;
409 tetra_description.dindex = gr_tetrahedron;
410 tetra_description.number_of_vertices = 4;
411 tetra_description.number_of_polygons = 4;
412 tetra_description.polygon_length = tetra_polygon_length;
413 tetra_description.polygon_vertex = tetra_vertex_e;
414 tetra_description.polygon_neighbour = tetra_next_polygon_e;
415 tetra_description.dimension_of_coord = 3;
416 tetra_description.coord = tetra_local_coordinate_system;
417 tetra_description.parametric_degree = 1;
418 tetra_description.world_to_coord = world2coord_3d;
419 tetra_description.coord_to_world = coord2world_3d;
420 tetra_description.check_inside = el_check_inside_3d;
421 tetra_description.neighbour = dummy_neighbour;
422 tetra_description.boundary = wrap_boundary;
423 tetra_description.get_boundary_vertex_estimate = NULL;
424 tetra_description.get_boundary_face_estimate = NULL;
425 tetra_description.coord_of_parent = NULL;
428 pyra_description.dindex = gr_pyramid;
429 pyra_description.number_of_vertices = 5;
430 pyra_description.number_of_polygons = 5;
431 pyra_description.polygon_length = pyra_polygon_length;
432 pyra_description.polygon_vertex = pyra_polygon_vertex;
433 pyra_description.polygon_neighbour = pyra_polygon_neighbour;
434 pyra_description.dimension_of_coord = 3;
435 pyra_description.coord = pyra_local_coordinate_system;
436 pyra_description.parametric_degree = 1;
437 pyra_description.world_to_coord = world2coord_3d;
438 pyra_description.coord_to_world = coord2world_3d;
439 pyra_description.check_inside = el_check_inside_3d;
440 pyra_description.neighbour = dummy_neighbour;
441 pyra_description.boundary = wrap_boundary;
442 pyra_description.get_boundary_vertex_estimate = NULL;
443 pyra_description.get_boundary_face_estimate = NULL;
444 pyra_description.coord_of_parent = NULL;
447 prism_description.dindex = gr_prism;
448 prism_description.number_of_vertices = 6;
449 prism_description.number_of_polygons = 5;
450 prism_description.polygon_length = prism_polygon_length;
451 prism_description.polygon_vertex = prism_polygon_vertex;
452 prism_description.polygon_neighbour = prism_polygon_neighbour;
453 prism_description.dimension_of_coord = 3;
454 prism_description.coord = prism_local_coordinate_system;
455 prism_description.parametric_degree = 1;
456 prism_description.world_to_coord = world2coord_3d;
457 prism_description.coord_to_world = coord2world_3d;
458 prism_description.check_inside = el_check_inside_3d;
459 prism_description.neighbour = dummy_neighbour;
460 prism_description.boundary = wrap_boundary;
461 prism_description.get_boundary_vertex_estimate = NULL;
462 prism_description.get_boundary_face_estimate = NULL;
463 prism_description.coord_of_parent = NULL;
466 cube_description.dindex = gr_hexahedron;
467 cube_description.number_of_vertices = 8;
468 cube_description.number_of_polygons = 6;
469 cube_description.polygon_length = cube_polygon_length;
470 cube_description.polygon_vertex = cube_polygon_vertex;
471 cube_description.polygon_neighbour = cube_polygon_neighbour;
472 cube_description.dimension_of_coord = 3;
473 cube_description.coord = cube_local_coordinate_system;
474 cube_description.parametric_degree = 1;
475 cube_description.world_to_coord = world2coord_3d;
476 cube_description.coord_to_world = coord2world_3d;
477 cube_description.check_inside = el_check_inside_3d;
478 cube_description.neighbour = dummy_neighbour;
479 cube_description.boundary = wrap_boundary;
480 cube_description.get_boundary_vertex_estimate = NULL;
481 cube_description.get_boundary_face_estimate = NULL;
482 cube_description.coord_of_parent = NULL;
486 inheritance_rule_in_child_0[0] = vinherit_point_0_in_child_0;
487 inheritance_rule_in_child_0[1] = vinherit_point_1_in_child_0;
488 inheritance_rule_in_child_0[2] = vinherit_point_2;
490 inheritance_rule_in_child_1[0] = vinherit_point_0_in_child_1;
491 inheritance_rule_in_child_1[1] = vinherit_point_1_in_child_1;
492 inheritance_rule_in_child_1[2] = vinherit_point_2;
494 Grape_ReferenceElementsInitialized = true ;
500elementDescriptions[numberOfUsedGrapeElementTypes] = {
501 (
void *) &triangle_description,
502 (
void *) &quadrilateral_description,
503 (
void *) &tetra_description,
504 (
void *) &pyra_description,
505 (
void *) &prism_description,
506 (
void *) &cube_description
510static const int dune2GrapeDefaultMap[MAX_EL_DOF] = {0,1,2,3,4,5,6,7};
511static const int * dune2GrapeTriangle = dune2GrapeDefaultMap;
512static const int * dune2GrapeTetrahedron = dune2GrapeDefaultMap;
513static const int * dune2GrapePrism = dune2GrapeDefaultMap;
516static const int dune2GrapeQuadrilateral[MAX_EL_DOF] = {0,1,3,2,4,5,6,7};
518static const int dune2GrapeHexahedron[MAX_EL_DOF] = {0,1,3,2,4,5,7,6};
521static const int dune2GrapePyramid[ MAX_EL_DOF ] = {0,1,3,2,4,5,6,7};
525dune2GrapeVertex[numberOfUsedGrapeElementTypes] = {
527 dune2GrapeQuadrilateral ,
528 dune2GrapeTetrahedron,
538static const int dune2GrapeDefaultFace[MAX_EL_FACE] = {0,1,2,3,4,5};
541static const int dune2GrapeTriangleFace[MAX_EL_FACE] = {2,1,0,3,4,5};
544static const int dune2GrapeTetrahedronFace[MAX_EL_FACE] = {3,2,1,0,4,5};
547static const int dune2GrapeHexahedronFace[MAX_EL_FACE] = {5,3,2,4,0,1};
550static const int * dune2GrapeQuadrilateralFace = dune2GrapeDefaultFace;
551static const int * dune2GrapePrismFace = dune2GrapeDefaultFace;
552static const int * dune2GrapePyramidFace = dune2GrapeDefaultFace;
556dune2GrapeFace[numberOfUsedGrapeElementTypes] = {
557 dune2GrapeTriangleFace ,
558 dune2GrapeQuadrilateralFace ,
559 dune2GrapeTetrahedronFace,
560 dune2GrapePyramidFace ,
561 dune2GrapePrismFace ,
562 dune2GrapeHexahedronFace
565static H_ELEMENT_DESCRIPTION * getElementDescription(
int type )
568 assert( type < numberOfUsedGrapeElementTypes );
569 return (H_ELEMENT_DESCRIPTION * )elementDescriptions[type];