Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature puma patches [7/x] Batch processing of element ref_coords #661

Merged
merged 10 commits into from
Sep 11, 2023
12 changes: 7 additions & 5 deletions src/t8_element_cxx.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -617,16 +617,18 @@ struct t8_eclass_scheme
t8_element_vertex_reference_coords (const t8_element_t *t, const int vertex, double coords[]) const
= 0;

/** Convert a point in the reference space of an element to a point in the
/** Convert points in the reference space of an element to points in the
* reference space of the tree.
*
* \param [in] elem The element.
* \param [in] coords_input The coordinates of the point in the reference space of the element.
* \param [in] user_data User data.
* \param [out] out_coords The coordinates of the point in the reference space of the tree.
* \param [in] coords_input The coordinates \f$ [0,1]^\mathrm{dim} \f$ of the point
* in the reference space of the element.
* \param [in] num_coords Number of \f$ dim\f$-sized coordinates to evaluate.
* \param [out] out_coords The coordinates of the points in the
* reference space of the tree.
*/
virtual void
t8_element_reference_coords (const t8_element_t *elem, const double *ref_coords, const void *user_data,
t8_element_reference_coords (const t8_element_t *elem, const double *ref_coords, const size_t num_coords,
double *out_coords) const
= 0;

Expand Down
2 changes: 1 addition & 1 deletion src/t8_forest/t8_forest_cxx.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ t8_forest_element_from_ref_coords (t8_forest_t forest, t8_locidx_t ltreeid, cons
double tree_ref_coords[3] = { 0 };
const t8_eclass_t tree_class = t8_forest_get_tree_class (forest, ltreeid);
const t8_eclass_scheme_c *scheme = t8_forest_get_eclass_scheme (forest, tree_class);
scheme->t8_element_reference_coords (element, ref_coords, NULL, tree_ref_coords);
scheme->t8_element_reference_coords (element, ref_coords, 1, tree_ref_coords);
const t8_cmesh_t cmesh = t8_forest_get_cmesh (forest);
const t8_gloidx_t gtreeid = t8_forest_global_tree_id (forest, ltreeid);
t8_geometry_evaluate (cmesh, gtreeid, tree_ref_coords, coords_out);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,18 @@ class t8_default_scheme_common_c: public t8_eclass_scheme_c {
t8_element_vertex_coords (const t8_element_t *elem, int vertex, int coords[]) const
= 0;

/** Convert a point in the reference space of an element to a point in the
/** Convert points in the reference space of an element to points in the
* reference space of the tree.
*
* \param [in] elem The element.
* \param [in] coords_input The coordinates of the point in the reference space of the element.
* \param [in] user_data User data.
* \param [out] out_coords The coordinates of the point in the reference space of the tree.
* \param [in] coords_input The coordinates \f$ [0,1]^\mathrm{dim} \f$ of the point
* in the reference space of the element.
* \param [in] num_coords Number of \f$ dim\f$-sized coordinates to evaluate.
* \param [out] out_coords The coordinates of the points in the
* reference space of the tree.
*/
virtual void
t8_element_reference_coords (const t8_element_t *elem, const double *ref_coords, const void *user_data,
t8_element_reference_coords (const t8_element_t *elem, const double *ref_coords, const size_t num_coords,
double *out_coords) const
= 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -585,10 +585,10 @@ t8_default_scheme_hex_c::t8_element_vertex_reference_coords (const t8_element_t

void
t8_default_scheme_hex_c::t8_element_reference_coords (const t8_element_t *elem, const double *ref_coords,
const void *user_data, double *out_coords) const
const size_t num_coords, double *out_coords) const
{
T8_ASSERT (t8_element_is_valid (elem));
t8_dhex_compute_reference_coords ((const t8_dhex_t *) elem, ref_coords, out_coords);
t8_dhex_compute_reference_coords ((const t8_dhex_t *) elem, ref_coords, num_coords, out_coords);
}

int
Expand Down
12 changes: 7 additions & 5 deletions src/t8_schemes/t8_default/t8_default_hex/t8_default_hex_cxx.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -547,16 +547,18 @@ struct t8_default_scheme_hex_c: public t8_default_scheme_common_c
virtual void
t8_element_vertex_reference_coords (const t8_element_t *elem, const int vertex, double coords[]) const;

/** Convert a point in the reference space of an element to a point in the
/** Convert points in the reference space of an element to points in the
* reference space of the tree.
*
* \param [in] elem The element.
* \param [in] coords_input The coordinates of the point in the reference space of the element.
* \param [in] user_data User data.
* \param [out] out_coords The coordinates of the point in the reference space of the tree.
* \param [in] coords_input The coordinates \f$ [0,1]^\mathrm{dim} \f$ of the point
* in the reference space of the element.
* \param [in] num_coords Number of \f$ dim\f$-sized coordinates to evaluate.
* \param [out] out_coords The coordinates of the points in the
* reference space of the tree.
*/
virtual void
t8_element_reference_coords (const t8_element_t *elem, const double *ref_coords, const void *user_data,
t8_element_reference_coords (const t8_element_t *elem, const double *ref_coords, const size_t num_coords,
double *out_coords) const;

/** Returns true, if there is one element in the tree, that does not refine into 2^dim children.
Expand Down
28 changes: 16 additions & 12 deletions src/t8_schemes/t8_default/t8_default_hex/t8_dhex_bits.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,26 @@
#include <p8est_bits.h>

void
t8_dhex_compute_reference_coords (const t8_dhex_t *elem, const double *ref_coords, double *out_coords)
t8_dhex_compute_reference_coords (const t8_dhex_t *elem, const double *ref_coords, const size_t num_coords,
double *out_coords)
{
const p8est_quadrant_t *q1 = (const p8est_quadrant_t *) elem;

/* Get the length of the quadrant */
const p4est_qcoord_t len = P8EST_QUADRANT_LEN (q1->level);

/* Compute the x, y and z coordinates of the point depending on the
* reference coordinates */
out_coords[0] = q1->x + ref_coords[0] * len;
out_coords[1] = q1->y + ref_coords[1] * len;
out_coords[2] = q1->z + ref_coords[2] * len;

/* We divide the integer coordinates by the root length of the hex
* to obtain the reference coordinates. */
out_coords[0] /= (double) P8EST_ROOT_LEN;
out_coords[1] /= (double) P8EST_ROOT_LEN;
out_coords[2] /= (double) P8EST_ROOT_LEN;
for (size_t coord = 0; coord < num_coords; ++coord) {
const size_t offset = 3 * coord;
/* Compute the x, y and z coordinates of the point depending on the
* reference coordinates */
out_coords[offset + 0] = q1->x + ref_coords[offset + 0] * len;
out_coords[offset + 1] = q1->y + ref_coords[offset + 1] * len;
out_coords[offset + 2] = q1->z + ref_coords[offset + 2] * len;

/* We divide the integer coordinates by the root length of the hex
* to obtain the reference coordinates. */
out_coords[offset + 0] /= (double) P8EST_ROOT_LEN;
out_coords[offset + 1] /= (double) P8EST_ROOT_LEN;
out_coords[offset + 2] /= (double) P8EST_ROOT_LEN;
}
}
13 changes: 8 additions & 5 deletions src/t8_schemes/t8_default/t8_default_hex/t8_dhex_bits.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,19 @@

T8_EXTERN_C_BEGIN ();

/** Convert a point in the reference space of a hex element to a point in the
/** Convert points in the reference space of a hex element to points in the
* reference space of the tree (level 0) embedded in \f$ [0,1]^3 \f$.
* \param [in] elem Input hex.
* \param [in] ref_coords The reference coordinate on the hex \f$ [0,1]^3 \f$
* \param [out] out_coords An array of 1 double that
* \param [in] ref_coords The reference coordinates in the hex
* (\a num_coords times \f$ [0,1]^3 \f$)
* \param [in] num_coords Number of coordinates to evaluate
* \param [out] out_coords An array of \a num_coords x 3 x double that
* will be filled with the reference coordinates
* of the point on the hex.
* of the points on the hex.
*/
void
t8_dhex_compute_reference_coords (const t8_dhex_t *elem, const double *ref_coords, double *out_coords);
t8_dhex_compute_reference_coords (const t8_dhex_t *elem, const double *ref_coords, const size_t num_coords,
double *out_coords);

T8_EXTERN_C_END ();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,11 +297,11 @@ t8_default_scheme_line_c::t8_element_vertex_reference_coords (const t8_element_t

void
t8_default_scheme_line_c::t8_element_reference_coords (const t8_element_t *elem, const double *ref_coords,
const void *user_data, double *out_coords) const
const size_t num_coords, double *out_coords) const
{
T8_ASSERT (t8_element_is_valid (elem));
T8_ASSERT (ref_coords != NULL);
t8_dline_compute_reference_coords ((const t8_dline_t *) elem, ref_coords, out_coords);
t8_dline_compute_reference_coords ((const t8_dline_t *) elem, ref_coords, num_coords, 0, out_coords);
}

int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -565,16 +565,18 @@ struct t8_default_scheme_line_c: public t8_default_scheme_common_c
virtual void
t8_element_vertex_reference_coords (const t8_element_t *elem, const int vertex, double coords[]) const;

/** Convert a point in the reference space of an element to a point in the
/** Convert points in the reference space of an element to points in the
* reference space of the tree.
*
* \param [in] elem The element.
* \param [in] coords_input The coordinates of the point in the reference space of the element.
* \param [in] user_data User data.
* \param [out] out_coords The coordinates of the point in the reference space of the tree.
* \param [in] coords_input The coordinates \f$ [0,1]^\mathrm{dim} \f$ of the point
* in the reference space of the element.
* \param [in] num_coords Number of \f$ dim\f$-sized coordinates to evaluate.
* \param [out] out_coords The coordinates of the points in the
* reference space of the tree.
*/
virtual void
t8_element_reference_coords (const t8_element_t *elem, const double *ref_coords, const void *user_data,
t8_element_reference_coords (const t8_element_t *elem, const double *ref_coords, const size_t num_coords,
double *out_coords) const;

/** Returns true, if there is one element in the tree, that does not refine into 2^dim children.
Expand Down
12 changes: 8 additions & 4 deletions src/t8_schemes/t8_default/t8_default_line/t8_dline_bits.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,12 +340,16 @@ t8_dline_vertex_ref_coords (const t8_dline_t *elem, const int vertex, double coo
}

void
t8_dline_compute_reference_coords (const t8_dline_t *elem, const double *ref_coords, double *out_coords)
t8_dline_compute_reference_coords (const t8_dline_t *elem, const double *ref_coords, const size_t num_coords,
const size_t skip_coords, double *out_coords)
{
T8_ASSERT (t8_dline_is_valid (elem));
out_coords[0] = elem->x;
out_coords[0] += T8_DLINE_LEN (elem->level) * ref_coords[0];
out_coords[0] /= (double) T8_DLINE_ROOT_LEN;
for (size_t coord = 0; coord < num_coords; ++coord) {
const size_t offset = coord * skip_coords;
out_coords[offset] = elem->x;
out_coords[offset] += T8_DLINE_LEN (elem->level) * ref_coords[coord];
out_coords[offset] /= (double) T8_DLINE_ROOT_LEN;
}
}

t8_linearidx_t
Expand Down
17 changes: 12 additions & 5 deletions src/t8_schemes/t8_default/t8_default_line/t8_dline_bits.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,16 +247,23 @@ t8_dline_vertex_coords (const t8_dline_t *elem, const int vertex, int coords[]);
void
t8_dline_vertex_ref_coords (const t8_dline_t *elem, const int vertex, double coordinates[1]);

/** Convert a point in the reference space of a line element to a point in the
/** Convert points in the reference space of a line element to points in the
* reference space of the tree (level 0) embedded in [0,1]^1.
* \param [in] elem Input line.
* \param [in] ref_coords The reference coordinate on the line \f$ [0,1]^1 \f$
* \param [out] out_coords An array of 1 double that
* \param [in] ref_coords The reference coordinates in the line
* (\a num_coords times \f$ [0,1]^1 \f$)
* \param [in] num_coords Number of coordinates to evaluate
* \param [in] skip_coords Only used for batch computation of prisms.
* In all other cases 0.
* Skip coordinates in the \a ref_coords and
* \a out_coords array.
* \param [out] out_coords An array of \a num_coords x 1 x double that
* will be filled with the reference coordinates
* of the point on the line.
* of the points on the line.
*/
void
t8_dline_compute_reference_coords (const t8_dline_t *elem, const double *ref_coords, double *out_coords);
t8_dline_compute_reference_coords (const t8_dline_t *elem, const double *ref_coords, const size_t num_coords,
const size_t skip_coords, double *out_coords);

/** Computes the linear position of a line in an uniform grid.
* \param [in] line Line whose id will be computed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -405,10 +405,10 @@ t8_default_scheme_prism_c::t8_element_vertex_reference_coords (const t8_element_

void
t8_default_scheme_prism_c::t8_element_reference_coords (const t8_element_t *elem, const double *ref_coords,
const void *user_data, double *out_coords) const
const size_t num_coords, double *out_coords) const
{
T8_ASSERT (t8_element_is_valid (elem));
t8_dprism_compute_reference_coords ((const t8_dprism_t *) elem, ref_coords, out_coords);
t8_dprism_compute_reference_coords ((const t8_dprism_t *) elem, ref_coords, num_coords, out_coords);
}

void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -543,14 +543,18 @@ struct t8_default_scheme_prism_c: public t8_default_scheme_common_c
virtual void
t8_element_vertex_reference_coords (const t8_element_t *elem, const int vertex, double coords[]) const;

/** Convert a point in the reference space of an element to a point in the reference space of the tree.
/** Convert points in the reference space of an element to points in the
* reference space of the tree.
*
* \param [in] elem The element.
* \param [in] coords_input The coordinates of the point in the reference space of the element.
* \param [in] user_data User data.
* \param [out] out_coords The coordinates of the point in the reference space of the tree.
* \param [in] coords_input The coordinates \f$ [0,1]^\mathrm{dim} \f$ of the point
* in the reference space of the element.
* \param [in] num_coords Number of \f$ dim\f$-sized coordinates to evaluate.
* \param [out] out_coords The coordinates of the points in the
* reference space of the tree.
*/
virtual void
t8_element_reference_coords (const t8_element_t *elem, const double *ref_coords, const void *user_data,
t8_element_reference_coords (const t8_element_t *elem, const double *ref_coords, const size_t num_coords,
double *out_coords) const;

/** Returns true, if there is one element in the tree, that does not refine into 2^dim children.
Expand Down
7 changes: 4 additions & 3 deletions src/t8_schemes/t8_default/t8_default_prism/t8_dprism_bits.c
Original file line number Diff line number Diff line change
Expand Up @@ -562,14 +562,15 @@ t8_dprism_vertex_ref_coords (const t8_dprism_t *elem, const int vertex, double c
}

void
t8_dprism_compute_reference_coords (const t8_dprism_t *elem, const double *ref_coords, double *out_coords)
t8_dprism_compute_reference_coords (const t8_dprism_t *elem, const double *ref_coords, const size_t num_coords,
double *out_coords)
{
T8_ASSERT (t8_dprism_is_valid (elem));
T8_ASSERT (elem->line.level == elem->tri.level);
/*Compute x and y coordinate */
t8_dtri_compute_reference_coords (&elem->tri, ref_coords, out_coords);
t8_dtri_compute_reference_coords (&elem->tri, ref_coords, num_coords, 1, out_coords);
/*Compute z coordinate */
t8_dline_compute_reference_coords (&elem->line, ref_coords + 2, out_coords + 2);
t8_dline_compute_reference_coords (&elem->line, ref_coords + 2, num_coords, 2, out_coords + 2);
}

t8_linearidx_t
Expand Down
16 changes: 9 additions & 7 deletions src/t8_schemes/t8_default/t8_default_prism/t8_dprism_bits.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,16 +299,18 @@ t8_dprism_vertex_coords (const t8_dprism_t *elem, int vertex, int coords[3]);
void
t8_dprism_vertex_ref_coords (const t8_dprism_t *elem, int vertex, double coords[3]);

/** Convert a point in the reference space of a prism element to a point in the
/** Convert points in the reference space of a prism element to points in the
* reference space of the tree (level 0) embedded in \f$ [0,1]^3 \f$.
* \param [in] elem Input prism.
* \param [in] ref_coords The reference coordinates inside the
* prism element \f$ [0,1]^3 \f$
* \param [out] out_coords An array of 3 doubles that will be filled with the
* reference coordinates in the tree of the prism.
* \param [in] ref_coords The reference coordinates in the prism
* (\a num_coords times \f$ [0,1]^3 \f$)
* \param [in] num_coords Number of coordinates to evaluate
* \param [out] out_coords An array of \a num_coords x 3 x double that
* will be filled with the reference coordinates
* of the points on the prism.
*/
void
t8_dprism_compute_reference_coords (const t8_dprism_t *elem, const double *ref_coords, double *out_coords);
t8_dprism_compute_reference_coords (const t8_dprism_t *elem, const double *ref_coords, const size_t num_coords,
double *out_coords);

/** Computes the linear position of a prism in an uniform grid.
* \param [in] p Prism whose id will be computed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,10 +383,10 @@ t8_default_scheme_pyramid_c::t8_element_vertex_reference_coords (const t8_elemen

void
t8_default_scheme_pyramid_c::t8_element_reference_coords (const t8_element_t *elem, const double *ref_coords,
const void *user_data, double *out_coords) const
const size_t num_coords, double *out_coords) const
{
T8_ASSERT (t8_element_is_valid (elem));
t8_dpyramid_compute_reference_coords ((const t8_dpyramid_t *) elem, ref_coords, out_coords);
t8_dpyramid_compute_reference_coords ((const t8_dpyramid_t *) elem, ref_coords, num_coords, out_coords);
}

int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -535,14 +535,18 @@ struct t8_default_scheme_pyramid_c: public t8_default_scheme_common_c
virtual void
t8_element_vertex_reference_coords (const t8_element_t *elem, const int vertex, double coords[]) const;

/** Convert a point in the reference space of an element to a point in thereference space of the tree.
/** Convert points in the reference space of an element to points in the
* reference space of the tree.
*
* \param [in] elem The element.
* \param [in] coords_input The coordinates of the point in the reference space of the element.
* \param [in] user_data User data.
* \param [out] out_coords The coordinates of the point in the reference space of the tree.
* \param [in] coords_input The coordinates \f$ [0,1]^\mathrm{dim} \f$ of the point
* in the reference space of the element.
* \param [in] num_coords Number of \f$ dim\f$-sized coordinates to evaluate.
* \param [out] out_coords The coordinates of the points in the
* reference space of the tree.
*/
virtual void
t8_element_reference_coords (const t8_element_t *elem, const double *ref_coords, const void *user_data,
t8_element_reference_coords (const t8_element_t *elem, const double *ref_coords, const size_t num_coords,
double *out_coords) const;

/** Returns true, if there is one element in the tree, that does not refine into 2^dim children.
Expand Down
Loading