3 #ifndef __GRAPE_ELDESC_H__ 4 #define __GRAPE_ELDESC_H__ 15 typedef HELEMENT3D HELEMENT;
16 typedef ELEMENT3D ELEMENT;
17 typedef HMESH3D HMESH;
18 typedef HMESH GRAPEMESH;
19 typedef GENMESH3D GENMESHnD;
20 typedef HELEMENT3D_DESCRIPTION H_ELEMENT_DESCRIPTION;
21 typedef ELEMENT3D_DESCRIPTION ELEMENT_DESCRIPTION;
22 typedef F_HDATA3D F_DATA;
23 typedef F_HEL_INFO3D F_EL_INFO;
25 #define GenMesh GenMesh3d 26 #define GrapeMesh HMesh 28 typedef HELEMENT2D HELEMENT;
29 typedef ELEMENT2D ELEMENT;
30 typedef GENMESH2D GENMESHnD;
31 typedef HELEMENT2D_DESCRIPTION H_ELEMENT_DESCRIPTION;
32 typedef ELEMENT2D_DESCRIPTION ELEMENT_DESCRIPTION;
33 typedef F_HEL_INFO2D F_EL_INFO;
36 typedef HPMESH2D HMESH;
37 typedef F_HPDATA2D F_DATA;
38 #define HMesh HPMesh2d 45 typedef 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,
60 enum { numberOfUsedGrapeElementTypes = 6 };
67 static HELEMENT2D_DESCRIPTION triangle_description;
69 static double triangle_local_coordinate_vector_0[3] = {0.,0.,0.};
70 static double triangle_local_coordinate_vector_1[3] = {1.,0.,0.};
71 static double triangle_local_coordinate_vector_2[3] = {0.,1.,0.};
73 static 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};
87 static VINHERIT inheritance_rule_in_child_0[3];
88 static VINHERIT inheritance_rule_in_child_1[3];
90 static double pweight_point_0_or_1[1] = {1.0};
92 static int pindex_point_0_in_child_0[1] = {2};
93 static VINHERIT vinherit_point_0_in_child_0 = {1,
94 pindex_point_0_in_child_0,
95 pweight_point_0_or_1};
98 static int pindex_point_1_in_child_0[1] = {0};
99 static VINHERIT vinherit_point_1_in_child_0 = {1,
100 pindex_point_1_in_child_0,
101 pweight_point_0_or_1};
103 static int pindex_point_0_in_child_1[1] = {1};
104 static VINHERIT vinherit_point_0_in_child_1 = {1,
105 pindex_point_0_in_child_1,
106 pweight_point_0_or_1};
108 static int pindex_point_1_in_child_1[1] = {2};
109 static VINHERIT vinherit_point_1_in_child_1 = {1,
110 pindex_point_1_in_child_1,
111 pweight_point_0_or_1};
113 static int pindex_point_2[2] = {0 ,1 };
114 static double pweight_point_2[2] = {0.5,0.5};
115 static VINHERIT vinherit_point_2 = {2,pindex_point_2,pweight_point_2};
127 inline 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");
134 inline int triangle_boundary(HELEMENT2D * el,
int np) {
135 return ((DUNE_ELEM *)el->user_data)->bnd[np] ;
146 inline 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);
152 inline 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);
158 inline 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);
165 inline 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);
171 inline 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);
178 inline 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);
204 static bool Grape_ReferenceElementsInitialized = false ;
206 static HELEMENT2D_DESCRIPTION quadrilateral_description;
208 static double quadrilateral_local_coordinate_vector_0[3] = {0.,0.,0.};
209 static double quadrilateral_local_coordinate_vector_1[3] = {1.,0.,0.};
210 static double quadrilateral_local_coordinate_vector_2[3] = {1.,1.,0.};
211 static double quadrilateral_local_coordinate_vector_3[3] = {0.,1.,0.};
213 static 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};
223 static HELEMENT3D_DESCRIPTION tetra_description;
226 static int t_v0_e[3] = {1,3,2}, t_v1_e[3] = {0,2,3};
227 static int t_v2_e[3] = {0,3,1}, t_v3_e[3] = {0,1,2};
230 static int t_p0_e[3] = {2,1,3}, t_p1_e[3] = {3,0,2};
231 static int t_p2_e[3] = {1,0,3}, t_p3_e[3] = {2,0,1};
238 static double t_c0[3] = {0.,0.,0.}, t_c1[3] = {1.,0.,0.};
239 static double t_c2[3] = {0.,1.,0.}, t_c3[3] = {0.,0.,1.};
241 static int tetra_polygon_length[4] = {3, 3, 3, 3};
242 static G_CONST
int *tetra_vertex_e[4] = {t_v0_e,t_v1_e,t_v2_e,t_v3_e};
243 static G_CONST
int *tetra_next_polygon_e[4] = {t_p0_e,t_p1_e,t_p2_e,t_p3_e};
244 static G_CONST
double *tetra_local_coordinate_system[4] = {t_c0,t_c1,t_c2,t_c3};
255 inline 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");
264 inline static int wrap_boundary(HELEMENT3D * el,
int np)
266 return ((DUNE_ELEM *)el->user_data)->bnd[np] ;
306 static HELEMENT3D_DESCRIPTION cube_description;
309 static 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.};
311 static G_CONST
double *cube_local_coordinate_system[8] = {cc1,cc2,cc3,cc4,cc5,cc6,cc7,cc8};
313 static int cube_polygon_length[6] = {4,4,4,4,4,4};
315 static 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};
317 static G_CONST
int *cube_polygon_vertex[6] = {cv1,cv2,cv3,cv4,cv5,cv6};
318 static 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};
320 static G_CONST
int *cube_polygon_neighbour[6] = {cn1,cn2,cn3,cn4,cn5,cn6};
331 static HELEMENT3D_DESCRIPTION pyra_description;
333 static VEC3 pyc1={0.,0.,0.},pyc2={1.,0.,0.},pyc3={1.,1.,0.},
334 pyc4={0.,1.,0.},pyc5={0.,0.,1.};
335 static G_CONST
double *pyra_local_coordinate_system[5] = {pyc1,pyc2,pyc3,pyc4,pyc5};
337 static int pyra_polygon_length[5] = {4,3,3,3,3};
338 static 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};
340 static G_CONST
int *pyra_polygon_vertex[5] = {pyv1,pyv2,pyv3,pyv4,pyv5};
342 static 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};
344 static G_CONST
int *pyra_polygon_neighbour[5] = {pyn1,pyn2,pyn3,pyn4,pyn5};
355 static HELEMENT3D_DESCRIPTION prism_description;
357 static 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.};
359 static G_CONST
double *prism_local_coordinate_system[6] = {prc1,prc2,prc3,prc4,prc5,prc6};
362 static int prism_polygon_length[5] = {3,4,4,4,3};
365 static 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};
368 static G_CONST
int *prism_polygon_vertex[5] = {prv1,prv2,prv3,prv4,prv5};
370 static 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};
372 static G_CONST
int *prism_polygon_neighbour[6] = {prn1,prn2,prn3,prn4,prn5,prn6};
377 inline 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 ;
500 elementDescriptions[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
510 static const int dune2GrapeDefaultMap[MAX_EL_DOF] = {0,1,2,3,4,5,6,7};
511 static const int * dune2GrapeTriangle = dune2GrapeDefaultMap;
512 static const int * dune2GrapeTetrahedron = dune2GrapeDefaultMap;
513 static const int * dune2GrapePrism = dune2GrapeDefaultMap;
516 static const int dune2GrapeQuadrilateral[MAX_EL_DOF] = {0,1,3,2,4,5,6,7};
518 static const int dune2GrapeHexahedron[MAX_EL_DOF] = {0,1,3,2,4,5,7,6};
521 static const int dune2GrapePyramid[ MAX_EL_DOF ] = {0,1,3,2,4,5,6,7};
525 dune2GrapeVertex[numberOfUsedGrapeElementTypes] = {
527 dune2GrapeQuadrilateral ,
528 dune2GrapeTetrahedron,
538 static const int dune2GrapeDefaultFace[MAX_EL_FACE] = {0,1,2,3,4,5};
541 static const int dune2GrapeTriangleFace[MAX_EL_FACE] = {2,1,0,3,4,5};
544 static const int dune2GrapeTetrahedronFace[MAX_EL_FACE] = {3,2,1,0,4,5};
547 static const int dune2GrapeHexahedronFace[MAX_EL_FACE] = {5,3,2,4,0,1};
550 static const int * dune2GrapeQuadrilateralFace = dune2GrapeDefaultFace;
551 static const int * dune2GrapePrismFace = dune2GrapeDefaultFace;
552 static const int * dune2GrapePyramidFace = dune2GrapeDefaultFace;
556 dune2GrapeFace[numberOfUsedGrapeElementTypes] = {
557 dune2GrapeTriangleFace ,
558 dune2GrapeQuadrilateralFace ,
559 dune2GrapeTetrahedronFace,
560 dune2GrapePyramidFace ,
561 dune2GrapePrismFace ,
562 dune2GrapeHexahedronFace
565 static H_ELEMENT_DESCRIPTION * getElementDescription(
int type )
568 assert( type < numberOfUsedGrapeElementTypes );
569 return (H_ELEMENT_DESCRIPTION * )elementDescriptions[type];