Skip to content

Commit

Permalink
Merge pull request #259 from ljcarlin/develop-geometry
Browse files Browse the repository at this point in the history
Geometry API change
  • Loading branch information
cburstedde authored Dec 6, 2023
2 parents 4377b52 + ecca31e commit 436780c
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 27 deletions.
22 changes: 2 additions & 20 deletions src/p4est_geometry.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,25 +107,7 @@ p4est_geometry_destroy (p4est_geometry_t * geom)
}
}

/**
* Geometric coordinate transformation for geometry created with
* \ref p4est_geometry_new_connectivity. This is defined by
* tri/binlinear interpolation from vertex coordinates.
*
* May also be used as a building block in custom geometric coordinate transforms.
* See for example \ref p4est_geometry_sphere2d_X or \ref p4est_geometry_disk2d_X.
*
* \param[in] geom associated geometry
* \param[in] which_tree tree id inside forest
* \param[in] abc tree-local reference coordinates : [0,1]^d.
* Note: abc[2] is only accessed by the P4_TO_P8 version
* \param[out] xyz Cartesian coordinates in physical space after geometry
*
* \warning The associated geometry is assumed to have a connectivity
* as its *user field, and this connectivity is assumed to have vertex
* information in its *tree_to_vertex field.
*/
static void
void
p4est_geometry_connectivity_X (p4est_geometry_t * geom,
p4est_topidx_t which_tree,
const double abc[3], double xyz[3])
Expand Down Expand Up @@ -623,7 +605,7 @@ p4est_geometry_new_sphere2d (p4est_connectivity_t * conn, double R)
builtin = P4EST_ALLOC_ZERO (p4est_geometry_builtin_t, 1);

sphere2d = &builtin->p.sphere2d;
sphere2d->type = P4EST_GEOMETRY_BUILTIN_DISK2D;
sphere2d->type = P4EST_GEOMETRY_BUILTIN_SPHERE2D;
sphere2d->R = R;

builtin->geom.name = "p4est_sphere2d";
Expand Down
28 changes: 25 additions & 3 deletions src/p4est_geometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,10 @@ typedef void (*p4est_geometry_destroy_t) (p4est_geometry_t * geom);
/** Encapsulates a custom transformation from tree-local coordinates to
* user defined physical space.
*
* \warning Used in \ref p4est_vtk.h to write global-coordinate meshes.
* In this case *user is assumed to point to a \ref p4est_connectivity.
* In general it can be used however the user likes.
* Used in \ref p4est_vtk.h to write global-coordinate meshes.
*
* Some internal p4est functions assume that *user points to a
* \ref p4est_connectivity. However, in general it can be used as the user wishes.
*
* This structure can be filled or allocated by the user.
* p4est will never change its contents.
Expand Down Expand Up @@ -106,6 +107,27 @@ void p4est_geometry_destroy (p4est_geometry_t * geom);
p4est_geometry_t *p4est_geometry_new_connectivity (p4est_connectivity_t *
conn);

/** Geometric coordinate transformation for geometry created with
* \ref p4est_geometry_new_connectivity. This is defined by
* tri/binlinear interpolation from vertex coordinates.
*
* May also be used as a building block in custom geometric coordinate transforms.
* See for example \ref p4est_geometry_sphere2d_X or \ref p4est_geometry_disk2d_X.
*
* \param[in] geom associated geometry
* \param[in] which_tree tree id inside forest
* \param[in] abc tree-local reference coordinates : [0,1]^3.
* Note: abc[2] is only accessed by the P4_TO_P8 version
* \param[out] xyz Cartesian coordinates in physical space after geometry
*
* \warning The associated geometry is assumed to have a connectivity
* as its *user field, and this connectivity is assumed to have vertex
* information in its *tree_to_vertex field.
*/
void p4est_geometry_connectivity_X (p4est_geometry_t * geom,
p4est_topidx_t which_tree,
const double abc[3], double xyz[3]);

/** Create a geometry for mapping the sphere using 2d connectivity icosahedron.
*
* \param[in] conn The result of \ref p4est_connectivity_new_icosahedron.
Expand Down
1 change: 1 addition & 0 deletions src/p4est_to_p8est.h
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@
/* functions in p4est_geometry */
#define p4est_geometry_destroy p8est_geometry_destroy
#define p4est_geometry_new_connectivity p8est_geometry_new_connectivity
#define p4est_geometry_connectivity_X p8est_geometry_connectivity_X

/* functions in p4est_vtk */
#define p4est_vtk_context_new p8est_vtk_context_new
Expand Down
2 changes: 1 addition & 1 deletion src/p8est_connectivity.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
* Please see the documentation of \ref p8est_connectivity_t for the exact
* encoding convention.
*
* We provide various predefined connectivitys by dedicated constructors,
* We provide various predefined connectivities by dedicated constructors,
* such as
*
* * \ref p8est_connectivity_new_unitcube for the unit square,
Expand Down
6 changes: 3 additions & 3 deletions src/p8est_geometry.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ p8est_geometry_shell_X (p8est_geometry_t * geom,
double abc[3];

/* transform from the reference cube into vertex space */
p4est_geometry_connectivity_X (geom, which_tree, rst, abc);
p8est_geometry_connectivity_X (geom, which_tree, rst, abc);

/* assert that input points are in the expected range */
P4EST_ASSERT (shell->type == P8EST_GEOMETRY_BUILTIN_SHELL);
Expand Down Expand Up @@ -184,7 +184,7 @@ p8est_geometry_sphere_X (p8est_geometry_t * geom,
double abc[3];

/* transform from the reference cube into vertex space */
p4est_geometry_connectivity_X (geom, which_tree, rst, abc);
p8est_geometry_connectivity_X (geom, which_tree, rst, abc);

/* assert that input points are in the expected range */
P4EST_ASSERT (sphere->type == P8EST_GEOMETRY_BUILTIN_SPHERE);
Expand Down Expand Up @@ -341,7 +341,7 @@ p8est_geometry_torus_X (p8est_geometry_t * geom,

/* transform from the reference cube [0,1]^3 into logical vertex space
using bi/trilinear transformation */
p4est_geometry_connectivity_X (geom, which_tree, rst, abc);
p8est_geometry_connectivity_X (geom, which_tree, rst, abc);

/*
* assert that input points are in the expected range
Expand Down
20 changes: 20 additions & 0 deletions src/p8est_geometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,26 @@ void p8est_geometry_destroy (p8est_geometry_t * geom);
p8est_geometry_t *p8est_geometry_new_connectivity (p8est_connectivity_t *
conn);

/** Geometric coordinate transformation for geometry created with
* \ref p8est_geometry_new_connectivity. This is defined by
* tri/binlinear interpolation from vertex coordinates.
*
* May also be used as a building block in custom geometric coordinate transforms.
* See for example \ref p8est_geometry_shell_X or \ref p8est_geometry_sphere_X.
*
* \param[in] geom associated geometry
* \param[in] which_tree tree id inside forest
* \param[in] abc tree-local reference coordinates : [0,1]^3.
* \param[out] xyz Cartesian coordinates in physical space after geometry
*
* \warning The associated geometry is assumed to have a connectivity
* as its *user field, and this connectivity is assumed to have vertex
* information in its *tree_to_vertex field.
*/
void p8est_geometry_connectivity_X (p8est_geometry_t * geom,
p4est_topidx_t which_tree,
const double abc[3], double xyz[3]);

/** Create a geometry structure for the spherical shell of 24 trees.
* \param [in] conn Result of p8est_connectivity_new_shell or equivalent.
* We do NOT take ownership and expect it to stay alive.
Expand Down

0 comments on commit 436780c

Please sign in to comment.