Skip to content

Commit

Permalink
create hex copy function
Browse files Browse the repository at this point in the history
  • Loading branch information
ole-alb committed Oct 18, 2024
1 parent aabd814 commit c98c3a8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ t8_default_scheme_hex_c::t8_element_copy (const t8_element_t *source, t8_element
{
T8_ASSERT (t8_element_is_valid (source));
T8_ASSERT (t8_element_is_valid (dest));
*(p8est_quadrant_t *) dest = *(const p8est_quadrant_t *) source;
t8_dhex_copy ((const t8_dhex_t *) source, (t8_dhex_t *) dest);
}

int
Expand Down
11 changes: 11 additions & 0 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 @@ -47,3 +47,14 @@ t8_dhex_compute_reference_coords (const t8_dhex_t *elem, const double *ref_coord
out_coords[offset + 2] /= (double) P8EST_ROOT_LEN;
}
}

/*Copies a hexahedra from source to dest*/
void
t8_dhex_copy (const t8_dhex_t *source, t8_dhex_t *dest)
{
T8_ASSERT (source != NULL && dest != NULL);
if (source == dest) {
return;
}
memcpy (dest, source, sizeof (t8_dhex_t));
}
7 changes: 7 additions & 0 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 @@ -46,6 +46,13 @@ void
t8_dhex_compute_reference_coords (const t8_dhex_t *elem, const double *ref_coords, const size_t num_coords,
double *out_coords);

/** Copy the data from source to dest
* \param[in] source The source-hex
* \param[in,out] dest The destination
*/
void
t8_dhex_copy (const t8_dhex_t *source, t8_dhex_t *dest);

T8_EXTERN_C_END ();

#endif /* T8_DHEX_BITS_H */

0 comments on commit c98c3a8

Please sign in to comment.