1 #ifndef __GRAPE_ELDESC_H__
2 #define __GRAPE_ELDESC_H__
13 typedef HELEMENT3D HELEMENT;
14 typedef ELEMENT3D ELEMENT;
15 typedef HMESH3D HMESH;
16 typedef HMESH GRAPEMESH;
17 typedef GENMESH3D GENMESHnD;
18 typedef HELEMENT3D_DESCRIPTION H_ELEMENT_DESCRIPTION;
19 typedef ELEMENT3D_DESCRIPTION ELEMENT_DESCRIPTION;
20 typedef F_HDATA3D F_DATA;
21 typedef F_HEL_INFO3D F_EL_INFO;
23 #define GenMesh GenMesh3d
24 #define GrapeMesh HMesh
26 typedef HELEMENT2D HELEMENT;
27 typedef ELEMENT2D ELEMENT;
28 typedef GENMESH2D GENMESHnD;
29 typedef HELEMENT2D_DESCRIPTION H_ELEMENT_DESCRIPTION;
30 typedef ELEMENT2D_DESCRIPTION ELEMENT_DESCRIPTION;
31 typedef F_HEL_INFO2D F_EL_INFO;
34 typedef HPMESH2D HMESH;
35 typedef F_HPDATA2D F_DATA;
36 #define HMesh HPMesh2d
43 typedef HMESH GRAPEMESH;
44 #define GenMesh GenMesh2d
45 #define GrapeMesh HMesh
51 {gr_vertex=6,gr_line=7,
54 gr_triangle=0, gr_quadrilateral=1,gr_tetrahedron=2,
55 gr_pyramid=3, gr_prism=4, gr_hexahedron=5,
56 gr_iso_triangle=8, gr_iso_quadrilateral=9,
58 enum { numberOfUsedGrapeElementTypes = 6 };
65 static HELEMENT2D_DESCRIPTION triangle_description;
67 static double triangle_local_coordinate_vector_0[3] = {0.,0.,0.};
68 static double triangle_local_coordinate_vector_1[3] = {1.,0.,0.};
69 static double triangle_local_coordinate_vector_2[3] = {0.,1.,0.};
71 static G_CONST
double *triangle_local_coordinate_system[3] = {triangle_local_coordinate_vector_0,
72 triangle_local_coordinate_vector_1,
73 triangle_local_coordinate_vector_2};
85 static VINHERIT inheritance_rule_in_child_0[3];
86 static VINHERIT inheritance_rule_in_child_1[3];
88 static double pweight_point_0_or_1[1] = {1.0};
90 static int pindex_point_0_in_child_0[1] = {2};
91 static VINHERIT vinherit_point_0_in_child_0 = {1,
92 pindex_point_0_in_child_0,
93 pweight_point_0_or_1};
96 static int pindex_point_1_in_child_0[1] = {0};
97 static VINHERIT vinherit_point_1_in_child_0 = {1,
98 pindex_point_1_in_child_0,
99 pweight_point_0_or_1};
101 static int pindex_point_0_in_child_1[1] = {1};
102 static VINHERIT vinherit_point_0_in_child_1 = {1,
103 pindex_point_0_in_child_1,
104 pweight_point_0_or_1};
106 static int pindex_point_1_in_child_1[1] = {2};
107 static VINHERIT vinherit_point_1_in_child_1 = {1,
108 pindex_point_1_in_child_1,
109 pweight_point_0_or_1};
111 static int pindex_point_2[2] = {0 ,1 };
112 static double pweight_point_2[2] = {0.5,0.5};
113 static VINHERIT vinherit_point_2 = {2,pindex_point_2,pweight_point_2};
125 inline static HELEMENT2D * triangle_neighbour(HELEMENT2D *el,
int np,
int flag,
127 double * coord,
double * xyz, MESH_ELEMENT_FLAGS p) {
128 printf(
" neighbour nicht implementiert \n");
132 inline int triangle_boundary(HELEMENT2D * el,
int np) {
133 return ((DUNE_ELEM *)el->user_data)->bnd[np] ;
144 inline int el_check_inside(HELEMENT2D * e,
const double * coord)
146 DUNE_DAT * dat = (DUNE_DAT *) ((HMESH2D *) e->mesh)->user_data;
147 return dat->check_inside((DUNE_ELEM *) e->user_data, coord);
150 inline int world2coord(HELEMENT2D * e,
const double * xyz,
double * coord)
152 DUNE_DAT * dat = (DUNE_DAT *) ((HMESH2D *) e->mesh)->user_data;
153 return dat->wtoc((DUNE_ELEM *) e->user_data, xyz, coord);
156 inline void coord2world(HELEMENT2D * e,
const double * coord,
double * xyz)
158 DUNE_DAT * dat = (DUNE_DAT *) ((HMESH2D *) e->mesh)->user_data;
159 dat->ctow((DUNE_ELEM *) e->user_data, coord, xyz);
163 inline int el_check_inside_3d(HELEMENT3D * e,
double * coord)
165 DUNE_DAT * dat = (DUNE_DAT *) ((HMESH3D *) e->mesh)->user_data;
166 return dat->check_inside((DUNE_ELEM *) e->user_data, coord);
169 inline static int world2coord_3d(HELEMENT3D * e,
const double * xyz,
172 DUNE_DAT * dat = (DUNE_DAT *) ((HMESH3D *) e->mesh)->user_data;
173 return dat->wtoc((DUNE_ELEM *) e->user_data, xyz, coord);
176 inline static void coord2world_3d(HELEMENT3D * e,
const double * coord,
179 DUNE_DAT * dat = (DUNE_DAT *) ((HMESH3D *) e->mesh)->user_data;
180 dat->ctow((DUNE_ELEM *) e->user_data, coord, xyz);
202 static bool Grape_ReferenceElementsInitialized = false ;
204 static HELEMENT2D_DESCRIPTION quadrilateral_description;
206 static double quadrilateral_local_coordinate_vector_0[3] = {0.,0.,0.};
207 static double quadrilateral_local_coordinate_vector_1[3] = {1.,0.,0.};
208 static double quadrilateral_local_coordinate_vector_2[3] = {1.,1.,0.};
209 static double quadrilateral_local_coordinate_vector_3[3] = {0.,1.,0.};
211 static G_CONST
double *quadrilateral_local_coordinate_system[4] = {quadrilateral_local_coordinate_vector_0,
212 quadrilateral_local_coordinate_vector_1,quadrilateral_local_coordinate_vector_2,
213 quadrilateral_local_coordinate_vector_3};
221 static HELEMENT3D_DESCRIPTION tetra_description;
224 static int t_v0_e[3] = {1,3,2}, t_v1_e[3] = {0,2,3};
225 static int t_v2_e[3] = {0,3,1}, t_v3_e[3] = {0,1,2};
228 static int t_p0_e[3] = {2,1,3}, t_p1_e[3] = {3,0,2};
229 static int t_p2_e[3] = {1,0,3}, t_p3_e[3] = {2,0,1};
236 static double t_c0[3] = {0.,0.,0.}, t_c1[3] = {1.,0.,0.};
237 static double t_c2[3] = {0.,1.,0.}, t_c3[3] = {0.,0.,1.};
239 static int tetra_polygon_length[4] = {3, 3, 3, 3};
240 static G_CONST
int *tetra_vertex_e[4] = {t_v0_e,t_v1_e,t_v2_e,t_v3_e};
241 static G_CONST
int *tetra_next_polygon_e[4] = {t_p0_e,t_p1_e,t_p2_e,t_p3_e};
242 static G_CONST
double *tetra_local_coordinate_system[4] = {t_c0,t_c1,t_c2,t_c3};
253 inline static HELEMENT3D * dummy_neighbour(HELEMENT3D *el,
int np,
int flag,
255 double * coord,
double * xyz, MESH_ELEMENT_FLAGS p) {
257 printf(
" neighbour nicht implementiert \n");
262 inline static int wrap_boundary(HELEMENT3D * el,
int np)
264 return ((DUNE_ELEM *)el->user_data)->bnd[np] ;
304 static HELEMENT3D_DESCRIPTION cube_description;
307 static VEC3 cc1={0.,0.,0.},cc2={1.,0.,0.},cc3={1.,1.,0.},cc4={0.,1.,0.},
308 cc5={0.,0.,1.},cc6={1.,0.,1.},cc7={1.,1.,1.},cc8={0.,1.,1.};
309 static G_CONST
double *cube_local_coordinate_system[8] = {cc1,cc2,cc3,cc4,cc5,cc6,cc7,cc8};
311 static int cube_polygon_length[6] = {4,4,4,4,4,4};
313 static int cv1[4]={0,3,2,1},cv2[4]={4,5,6,7},cv3[4]={0,1,5,4},
314 cv4[4]={1,2,6,5},cv5[4]={2,3,7,6},cv6[4]={0,4,7,3};
315 static G_CONST
int *cube_polygon_vertex[6] = {cv1,cv2,cv3,cv4,cv5,cv6};
316 static int cn1[4]={5,4,3,2},cn2[4]={2,3,4,5},cn3[4]={0,3,1,5},
317 cn4[4]={0,4,1,2},cn5[4]={0,5,1,3},cn6[4]={2,1,4,0};
318 static G_CONST
int *cube_polygon_neighbour[6] = {cn1,cn2,cn3,cn4,cn5,cn6};
329 static HELEMENT3D_DESCRIPTION pyra_description;
331 static VEC3 pyc1={0.,0.,0.},pyc2={1.,0.,0.},pyc3={1.,1.,0.},
332 pyc4={0.,1.,0.},pyc5={0.,0.,1.};
333 static G_CONST
double *pyra_local_coordinate_system[5] = {pyc1,pyc2,pyc3,pyc4,pyc5};
335 static int pyra_polygon_length[5] = {4,3,3,3,3};
336 static int pyv1[4]={0,1,2,3},pyv2[3]={0,4,1},pyv3[3]={1,4,2},
337 pyv4[3]={2,4,3} ,pyv5[3]={0,3,4};
338 static G_CONST
int *pyra_polygon_vertex[5] = {pyv1,pyv2,pyv3,pyv4,pyv5};
340 static int pyn1[4]={5,4,3,2},pyn2[3]={0,2,4},pyn3[3]={0,3,1},
341 pyn4[3]={0,4,2} ,pyn5[3]={0,1,3};
342 static G_CONST
int *pyra_polygon_neighbour[5] = {pyn1,pyn2,pyn3,pyn4,pyn5};
353 static HELEMENT3D_DESCRIPTION prism_description;
355 static VEC3 prc1={0.,0.,0.},prc2={1.,0.,0.},prc3={0.,1.,0.},
356 prc4={0.,0.,1.},prc5={1.,0.,1.},prc6={0.,1.,1.};
357 static G_CONST
double *prism_local_coordinate_system[6] = {prc1,prc2,prc3,prc4,prc5,prc6};
360 static int prism_polygon_length[5] = {3,4,4,4,3};
363 static int prv1[3]={0,1,2}, prv2[4]={0,1,4,3},prv3[4]={1,2,5,4},
364 prv4[4]={2,0,3,5},prv5[3]={3,4,5};
366 static G_CONST
int *prism_polygon_vertex[5] = {prv1,prv2,prv3,prv4,prv5};
368 static int prn1[4]={5,4,3,2},prn2[4]={2,3,4,5},prn3[4]={0,3,1,5},
369 prn4[4]={0,4,1,2},prn5[4]={0,5,1,3},prn6[4]={2,1,4,0};
370 static G_CONST
int *prism_polygon_neighbour[6] = {prn1,prn2,prn3,prn4,prn5,prn6};
375 inline void setupReferenceElements()
377 if( ! Grape_ReferenceElementsInitialized )
381 triangle_description.dindex = gr_triangle;
382 triangle_description.number_of_vertices = 3;
384 triangle_description.dimension_of_coord = GRAPE_DIM;
385 triangle_description.coord = triangle_local_coordinate_system;
386 triangle_description.parametric_degree = 1;
387 triangle_description.world_to_coord = world2coord;
388 triangle_description.coord_to_world = coord2world;
389 triangle_description.check_inside = el_check_inside;
390 triangle_description.neighbour = triangle_neighbour;
391 triangle_description.boundary = triangle_boundary;
394 quadrilateral_description.dindex = gr_quadrilateral;
395 quadrilateral_description.number_of_vertices = 4;
396 quadrilateral_description.dimension_of_coord = GRAPE_DIM;
397 quadrilateral_description.coord = quadrilateral_local_coordinate_system;
398 quadrilateral_description.parametric_degree = 1;
399 quadrilateral_description.world_to_coord = world2coord;
400 quadrilateral_description.coord_to_world = coord2world;
401 quadrilateral_description.check_inside = el_check_inside;
402 quadrilateral_description.neighbour = triangle_neighbour;
403 quadrilateral_description.boundary = triangle_boundary;
407 tetra_description.dindex = gr_tetrahedron;
408 tetra_description.number_of_vertices = 4;
409 tetra_description.number_of_polygons = 4;
410 tetra_description.polygon_length = tetra_polygon_length;
411 tetra_description.polygon_vertex = tetra_vertex_e;
412 tetra_description.polygon_neighbour = tetra_next_polygon_e;
413 tetra_description.dimension_of_coord = 3;
414 tetra_description.coord = tetra_local_coordinate_system;
415 tetra_description.parametric_degree = 1;
416 tetra_description.world_to_coord = world2coord_3d;
417 tetra_description.coord_to_world = coord2world_3d;
418 tetra_description.check_inside = el_check_inside_3d;
419 tetra_description.neighbour = dummy_neighbour;
420 tetra_description.boundary = wrap_boundary;
421 tetra_description.get_boundary_vertex_estimate = NULL;
422 tetra_description.get_boundary_face_estimate = NULL;
423 tetra_description.coord_of_parent = NULL;
426 pyra_description.dindex = gr_pyramid;
427 pyra_description.number_of_vertices = 5;
428 pyra_description.number_of_polygons = 5;
429 pyra_description.polygon_length = pyra_polygon_length;
430 pyra_description.polygon_vertex = pyra_polygon_vertex;
431 pyra_description.polygon_neighbour = pyra_polygon_neighbour;
432 pyra_description.dimension_of_coord = 3;
433 pyra_description.coord = pyra_local_coordinate_system;
434 pyra_description.parametric_degree = 1;
435 pyra_description.world_to_coord = world2coord_3d;
436 pyra_description.coord_to_world = coord2world_3d;
437 pyra_description.check_inside = el_check_inside_3d;
438 pyra_description.neighbour = dummy_neighbour;
439 pyra_description.boundary = wrap_boundary;
440 pyra_description.get_boundary_vertex_estimate = NULL;
441 pyra_description.get_boundary_face_estimate = NULL;
442 pyra_description.coord_of_parent = NULL;
445 prism_description.dindex = gr_prism;
446 prism_description.number_of_vertices = 6;
447 prism_description.number_of_polygons = 5;
448 prism_description.polygon_length = prism_polygon_length;
449 prism_description.polygon_vertex = prism_polygon_vertex;
450 prism_description.polygon_neighbour = prism_polygon_neighbour;
451 prism_description.dimension_of_coord = 3;
452 prism_description.coord = prism_local_coordinate_system;
453 prism_description.parametric_degree = 1;
454 prism_description.world_to_coord = world2coord_3d;
455 prism_description.coord_to_world = coord2world_3d;
456 prism_description.check_inside = el_check_inside_3d;
457 prism_description.neighbour = dummy_neighbour;
458 prism_description.boundary = wrap_boundary;
459 prism_description.get_boundary_vertex_estimate = NULL;
460 prism_description.get_boundary_face_estimate = NULL;
461 prism_description.coord_of_parent = NULL;
464 cube_description.dindex = gr_hexahedron;
465 cube_description.number_of_vertices = 8;
466 cube_description.number_of_polygons = 6;
467 cube_description.polygon_length = cube_polygon_length;
468 cube_description.polygon_vertex = cube_polygon_vertex;
469 cube_description.polygon_neighbour = cube_polygon_neighbour;
470 cube_description.dimension_of_coord = 3;
471 cube_description.coord = cube_local_coordinate_system;
472 cube_description.parametric_degree = 1;
473 cube_description.world_to_coord = world2coord_3d;
474 cube_description.coord_to_world = coord2world_3d;
475 cube_description.check_inside = el_check_inside_3d;
476 cube_description.neighbour = dummy_neighbour;
477 cube_description.boundary = wrap_boundary;
478 cube_description.get_boundary_vertex_estimate = NULL;
479 cube_description.get_boundary_face_estimate = NULL;
480 cube_description.coord_of_parent = NULL;
484 inheritance_rule_in_child_0[0] = vinherit_point_0_in_child_0;
485 inheritance_rule_in_child_0[1] = vinherit_point_1_in_child_0;
486 inheritance_rule_in_child_0[2] = vinherit_point_2;
488 inheritance_rule_in_child_1[0] = vinherit_point_0_in_child_1;
489 inheritance_rule_in_child_1[1] = vinherit_point_1_in_child_1;
490 inheritance_rule_in_child_1[2] = vinherit_point_2;
492 Grape_ReferenceElementsInitialized = true ;
498 elementDescriptions[numberOfUsedGrapeElementTypes] = {
499 (
void *) &triangle_description,
500 (
void *) &quadrilateral_description,
501 (
void *) &tetra_description,
502 (
void *) &pyra_description,
503 (
void *) &prism_description,
504 (
void *) &cube_description
508 static const int dune2GrapeDefaultMap[MAX_EL_DOF] = {0,1,2,3,4,5,6,7};
509 static const int * dune2GrapeTriangle = dune2GrapeDefaultMap;
510 static const int * dune2GrapeTetrahedron = dune2GrapeDefaultMap;
511 static const int * dune2GrapePrism = dune2GrapeDefaultMap;
514 static const int dune2GrapeQuadrilateral[MAX_EL_DOF] = {0,1,3,2,4,5,6,7};
516 static const int dune2GrapeHexahedron[MAX_EL_DOF] = {0,1,3,2,4,5,7,6};
519 static const int dune2GrapePyramid[ MAX_EL_DOF ] = {0,1,3,2,4,5,6,7};
523 dune2GrapeVertex[numberOfUsedGrapeElementTypes] = {
525 dune2GrapeQuadrilateral ,
526 dune2GrapeTetrahedron,
536 static const int dune2GrapeDefaultFace[MAX_EL_FACE] = {0,1,2,3,4,5};
539 static const int dune2GrapeTriangleFace[MAX_EL_FACE] = {2,1,0,3,4,5};
542 static const int dune2GrapeTetrahedronFace[MAX_EL_FACE] = {3,2,1,0,4,5};
545 static const int dune2GrapeHexahedronFace[MAX_EL_FACE] = {5,3,2,4,0,1};
548 static const int * dune2GrapeQuadrilateralFace = dune2GrapeDefaultFace;
549 static const int * dune2GrapePrismFace = dune2GrapeDefaultFace;
550 static const int * dune2GrapePyramidFace = dune2GrapeDefaultFace;
554 dune2GrapeFace[numberOfUsedGrapeElementTypes] = {
555 dune2GrapeTriangleFace ,
556 dune2GrapeQuadrilateralFace ,
557 dune2GrapeTetrahedronFace,
558 dune2GrapePyramidFace ,
559 dune2GrapePrismFace ,
560 dune2GrapeHexahedronFace
563 static H_ELEMENT_DESCRIPTION * getElementDescription(
int type )
566 assert( type < numberOfUsedGrapeElementTypes );
567 return (H_ELEMENT_DESCRIPTION * )elementDescriptions[type];