Skip to content

Commit

Permalink
Example: 3d drop in simple - initial
Browse files Browse the repository at this point in the history
There is still a problem during balancing.
  • Loading branch information
SAutum committed Sep 7, 2023
1 parent 39573fe commit 0556942
Show file tree
Hide file tree
Showing 4 changed files with 184 additions and 2 deletions.
10 changes: 9 additions & 1 deletion example/simple/simple3.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ typedef enum
P8EST_CONFIG_BRICK,
P8EST_CONFIG_PERIODIC,
P8EST_CONFIG_ROTWRAP,
P8EST_CONFIG_DROP,
P8EST_CONFIG_TWOCUBES,
P8EST_CONFIG_TWOWRAP,
P8EST_CONFIG_ROTCUBES,
Expand Down Expand Up @@ -102,6 +103,7 @@ static const simple_regression_t regression[] =
{ P8EST_CONFIG_ROTWRAP, 1, 5, 0xe4d123b2U },
{ P8EST_CONFIG_ROTWRAP, 3, 5, 0xe4d123b2U },
{ P8EST_CONFIG_ROTWRAP, 5, 6, 0x81c22cc6U },
{ P8EST_CONFIG_DROP, 1, 5, 0x81c22cc6U },
{ P8EST_CONFIG_ROTCUBES, 1, 5, 0x5c497bdaU },
{ P8EST_CONFIG_ROTCUBES, 3, 5, 0x5c497bdaU },
{ P8EST_CONFIG_ROTCUBES, 5, 6, 0x00530556U },
Expand Down Expand Up @@ -196,7 +198,7 @@ main (int argc, char **argv)
usage =
"Arguments: <configuration> <level>\n"
" Configuration can be any of\n"
" unit|brick|periodic|rotwrap|twocubes|twowrap|rotcubes|shell|sphere|torus\n"
" unit|brick|periodic|rotwrap|drop|twocubes|twowrap|rotcubes|shell|sphere|torus\n"
" Level controls the maximum depth of refinement\n";
wrongusage = 0;
config = P8EST_CONFIG_NULL;
Expand All @@ -216,6 +218,9 @@ main (int argc, char **argv)
else if (!strcmp (argv[1], "rotwrap")) {
config = P8EST_CONFIG_ROTWRAP;
}
else if (!strcmp (argv[1], "drop")) {
config = P8EST_CONFIG_DROP;
}
else if (!strcmp (argv[1], "twocubes")) {
config = P8EST_CONFIG_TWOCUBES;
}
Expand Down Expand Up @@ -262,6 +267,9 @@ main (int argc, char **argv)
else if (config == P8EST_CONFIG_ROTWRAP) {
connectivity = p8est_connectivity_new_rotwrap ();
}
else if (config == P8EST_CONFIG_DROP) {
connectivity = p8est_connectivity_new_drop ();
}
else if (config == P8EST_CONFIG_TWOCUBES) {
connectivity = p8est_connectivity_new_twocubes ();
refine_fn = refine_sparse_fn;
Expand Down
75 changes: 75 additions & 0 deletions src/p4est_connectivity.c
Original file line number Diff line number Diff line change
Expand Up @@ -1527,6 +1527,81 @@ p4est_connectivity_new_drop (void)
corner_to_tree, corner_to_corner);
}

p4est_connectivity_t *
p4est_connectivity_new_drop3d (void)
{
const p4est_topidx_t num_vertices = 22;
const p4est_topidx_t num_trees = 5;
const p4est_topidx_t num_ctt = 1;
const double vertices[22 * 3] = {
0, 0, 0,
1, 0, 0,
0, 1, 0,
1, 1, 0,
3, 1, 0,
1, 2, 0,
3, 2, 0,
0, 0, 1,
1, 0, 1,
0, 1, 1,
1, 1, 1,
2, 1, 1,
1, 2, 1,
2, 2, 1,
1, 0, 2,
1, 1, 2,
2, 1, 2,
2, 2, 2,
0, 0, 3,
0, 1, 3,
3, 1, 3,
3, 2, 3,
};
const p4est_topidx_t tree_to_vertex[5 * 8] = {
0, 1, 2, 3, 7, 8, 9, 10,
3, 4, 5, 6, 10, 11, 12, 13,
11, 4, 13, 6, 16, 20, 17, 21,
14, 16, 15, 17, 18, 20, 19, 21,
7, 8, 9, 10, 18, 14, 19, 15,
};
const p4est_topidx_t tree_to_tree[5 * 6] = {
0, 0, 0, 0, 0, 4,
1, 2, 1, 1, 1, 1,
2, 2, 1, 3, 2, 2,
4, 2, 3, 3, 3, 3,
4, 4, 4, 4, 0, 3,
};
const int8_t tree_to_face[5 * 6] = {
0,0,2,2,
1,2,2,3,
0,1,1,1,
3,3,2,3,
0,1,3,0,
};

const p4est_topidx_t tree_to_corner[5 * 4] = {
-1, -1, -1, 0,
-1, -1, 0, -1,
-1, -1, -1, -1,
-1, -1, -1, -1,
-1, 0, -1, -1,
};
const p4est_topidx_t ctt_offset[1 + 1] = {
0, 3
};
const p4est_topidx_t corner_to_tree[3] = {
0, 1, 4,
};
const int8_t corner_to_corner[3] = {
3, 2, 1,
};
return p4est_connectivity_new_copy (num_vertices, num_trees, num_ctt,
vertices, tree_to_vertex,
tree_to_tree, tree_to_face,
tree_to_corner, ctt_offset,
corner_to_tree, corner_to_corner);
}

p4est_connectivity_t *
p4est_connectivity_new_corner (void)
{
Expand Down
95 changes: 94 additions & 1 deletion src/p8est_connectivity.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,100 @@ p8est_connectivity_new_rotwrap (void)
corner_to_tree, corner_to_corner);
}

p4est_connectivity_t *
p8est_connectivity_new_drop (void)
{
const p4est_topidx_t num_vertices = 24;
const p4est_topidx_t num_trees = 5;
const p4est_topidx_t num_ett = 2;
const p4est_topidx_t num_ctt = 1;
const double vertices[24 * 3] = {
0, 0, 0,
1, 0, 0,
0, 1, 0,
1, 1, 0,
3, 1, 0,
1, 2, 0,
3, 2, 0,
0, 0, 1,
1, 0, 1,
0, 1, 1,
1, 1, 1,
2, 1, 1,
1, 2, 1,
2, 2, 1,
1, 0, 2,
1, 1, 2,
2, 1, 2,
2, 2, 2,
0, 0, 3,
0, 1, 3,
3, 1, 3,
3, 2, 3,
0, 2, 3,
1, 2, 2,
};
const p4est_topidx_t tree_to_vertex[5 * 8] = {
0, 1, 2, 3, 7, 8, 9, 10,
3, 4, 5, 6, 10, 11, 12, 13,
11, 4, 13, 6, 16, 20, 17, 21,
15, 16, 23, 17, 19, 20, 22, 21,
7, 8, 9, 10, 18, 14, 19, 15,
};
const p4est_topidx_t tree_to_tree[5 * 6] = {
0, 0, 0, 0, 0, 4,
1, 2, 1, 1, 1, 1,
2, 2, 2, 2, 1, 3,
3, 2, 3, 3, 3, 3,
4, 4, 4, 4, 0, 4,
};
const int8_t tree_to_face[5 * 6] = {
0, 1, 2, 3, 4, 4,
0,10, 2, 3, 4, 5,
0, 1, 2, 3, 7, 1,
0, 5, 2, 3, 4, 5,
0, 1, 2, 3, 5, 5,
};
const p4est_topidx_t tree_to_edge[5 * 12] = {
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0,
-1, -1, -1, -1, -1, -1, -1, -1, 0, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1,
-1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1,
};
const p4est_topidx_t ett_offset[2 + 1] = { 0, 2, 4};
const p4est_topidx_t edge_to_tree[4] = {
0, 1, 3, 4
};
const int8_t edge_to_edge[4] = {
11, 8, 8, 15
};
const p4est_topidx_t tree_to_corner[5 * 8] = {
-1, -1, -1, -1, -1, -1, -1, 0,
-1, -1, -1, -1, 0, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, 0, -1, -1, -1, -1,
};
const p4est_topidx_t ctt_offset[1 + 1] = {
0, 3
};
const p4est_topidx_t corner_to_tree[3] = {
0, 1, 4
};
const int8_t corner_to_corner[3] = {
7, 4, 3
};
return p4est_connectivity_new_copy (num_vertices, num_trees,
num_ett, num_ctt,
vertices, tree_to_vertex,
tree_to_tree, tree_to_face,
tree_to_edge, ett_offset,
edge_to_tree, edge_to_edge,
tree_to_corner, ctt_offset,
corner_to_tree, corner_to_corner);
}

p4est_connectivity_t *
p8est_connectivity_new_twocubes (void)
{
Expand Down Expand Up @@ -354,7 +448,6 @@ p8est_connectivity_new_twocubes (void)
0, 0, 2, 3, 4, 5,
1, 1, 2, 3, 4, 5,
};

return p4est_connectivity_new_copy (num_vertices, num_trees, 0, 0,
vertices, tree_to_vertex,
tree_to_tree, tree_to_face,
Expand Down
6 changes: 6 additions & 0 deletions src/p8est_connectivity.h
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,12 @@ p8est_connectivity_t *p8est_connectivity_new_periodic (void);
*/
p8est_connectivity_t *p8est_connectivity_new_rotwrap (void);

/** Create a connectivity structure for a five-trees geometry with a
* hole. The geometry is a 3D extrusion of the two drop example, and
* covers [0, 3]*[0, 2]*[0, 3]. The additional dimension is Y.
*/
p8est_connectivity_t *p8est_connectivity_new_drop (void);

/** Create a connectivity structure that contains two cubes.
*/
p8est_connectivity_t *p8est_connectivity_new_twocubes (void);
Expand Down

0 comments on commit 0556942

Please sign in to comment.