Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions example/advect/t8_advection.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ typedef struct
/** The per element data */
typedef struct
{
t8_3D_point midpoint; /**< coordinates of element midpoint in R^3 */
t8_3D_vec midpoint; /**< coordinates of element midpoint in R^3 */
double vol; /**< Volume of this element */
double phi_new; /**< Value of solution at midpoint in next time step */
double *fluxes[MAX_FACES]; /**< The fluxes to each neighbor at a given face */
Expand Down Expand Up @@ -323,7 +323,7 @@ static double
t8_advect_flux_upwind_1d (const t8_advect_problem_t *problem, const t8_locidx_t el_plus, const t8_locidx_t el_minus,
int face)
{
t8_3D_point x_j_half;
t8_3D_vec x_j_half;
int idim;
t8_3D_vec u_at_x_j_half;
double phi;
Expand Down Expand Up @@ -365,7 +365,7 @@ static double
t8_advect_flux_upwind (const t8_advect_problem_t *problem, double el_plus_phi, double el_minus_phi, t8_locidx_t ltreeid,
const t8_element_t *element_plus, int face)
{
t8_3D_point face_center;
t8_3D_vec face_center;
t8_3D_vec u_at_face_center;
t8_3D_vec normal;
double area, normal_times_u;
Expand Down
4 changes: 2 additions & 2 deletions example/common/t8_example_common.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ int
t8_common_within_levelset (t8_forest_t forest, const t8_locidx_t ltreeid, const t8_element_t *element,
t8_example_level_set_fn levelset, double band_width, double t, void *udata)
{
t8_3D_point elem_midpoint;
t8_3D_vec elem_midpoint;
double elem_diam;
double value;
const t8_eclass_t tree_class = t8_forest_get_eclass (forest, ltreeid);
Expand All @@ -76,7 +76,7 @@ t8_common_within_levelset (t8_forest_t forest, const t8_locidx_t ltreeid, const
/* If bandwidth = 0, we only refine the elements that are intersected by the zero level-set */
const int num_corners = scheme->element_get_num_corners (tree_class, element);
int sign = 1, icorner;
t8_3D_point coords;
t8_3D_vec coords;

/* Compute LS function at first corner */
t8_forest_element_coordinate (forest, ltreeid, element, 0, coords.data ());
Expand Down
32 changes: 16 additions & 16 deletions example/common/t8_example_common.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include <t8_types/t8_vec.hxx>

/** A levelset function in 3+1 space dimensions. */
typedef double (*t8_example_level_set_fn) (const t8_3D_point &, double, void *);
typedef double (*t8_example_level_set_fn) (const t8_3D_vec &, double, void *);

/** Struct to handle refinement around a level-set function. */
typedef struct
Expand All @@ -51,10 +51,10 @@ typedef struct
/** Function pointer for real valued functions from d+1 space dimensions
* functions f: R^d x R -> R */
typedef double (*t8_scalar_function_1d_fn) (double x, double t);
typedef double (*t8_scalar_function_2d_fn) (const t8_point<2> &x, const double t);
typedef double (*t8_scalar_function_3d_fn) (const t8_3D_point &x, const double t);
typedef double (*t8_scalar_function_2d_fn) (const t8_2D_vec &x, const double t);
typedef double (*t8_scalar_function_3d_fn) (const t8_3D_vec &x, const double t);
/** Function pointer for a vector valued function f: R^3 x R -> R */
typedef void (*t8_flow_function_3d_fn) (const t8_3D_point &x_in, const double t, t8_3D_vec &x_out);
typedef void (*t8_flow_function_3d_fn) (const t8_3D_vec &x_in, const double t, t8_3D_vec &x_out);

/* function declarations */

Expand Down Expand Up @@ -103,7 +103,7 @@ t8_common_adapt_level_set (t8_forest_t forest, t8_forest_t forest_from, t8_locid

typedef struct
{
t8_3D_point M;
t8_3D_vec M;
/**< midpoint */
double radius;
/**< radius */
Expand All @@ -114,7 +114,7 @@ typedef struct
* \return dist (x,data->M) - data->radius
*/
double
t8_levelset_sphere (const t8_3D_point &x, double t, void *data);
t8_levelset_sphere (const t8_3D_vec &x, double t, void *data);

/** Returns always 1.
* \return 1
Expand Down Expand Up @@ -200,42 +200,42 @@ t8_scalar3d_sphere_05_0z_midpoint_375_radius (const t8_3D_vec &x, const double t
/** Returns always 1 in each coordinate.
*/
void
t8_flow_constant_one_vec (const t8_3D_point &x, const double t, t8_3D_vec &x_out);
t8_flow_constant_one_vec (const t8_3D_vec &x, const double t, t8_3D_vec &x_out);

/** Sets the first coordinate to 1, all other to 0. */
void
t8_flow_constant_one_x_vec (const t8_3D_point &x, const double t, t8_3D_vec &x_ou);
t8_flow_constant_one_x_vec (const t8_3D_vec &x, const double t, t8_3D_vec &x_ou);

/** Sets the first and second coordinate to 1, the third to 0. */
void
t8_flow_constant_one_xy_vec (const t8_3D_point &x, const double t, t8_3D_vec &x_out);
t8_flow_constant_one_xy_vec (const t8_3D_vec &x, const double t, t8_3D_vec &x_out);

/** Sets all coordinates to a nonzero constant. */
void
t8_flow_constant_one_xyz_vec (const t8_3D_point &x, const double t, t8_3D_vec &x_out);
t8_flow_constant_one_xyz_vec (const t8_3D_vec &x, const double t, t8_3D_vec &x_out);

/** Transform the unit square to [-0.5,0.5]^2 and computes
* x = 2pi*y, y = -2pi*x
*/
void
t8_flow_rotation_2d (const t8_3D_point &x, const double t, t8_3D_vec &x_out);
t8_flow_rotation_2d (const t8_3D_vec &x, const double t, t8_3D_vec &x_out);

void
t8_flow_compressible (const t8_3D_point &x_in, const double t, t8_3D_vec &x_out);
t8_flow_compressible (const t8_3D_vec &x_in, const double t, t8_3D_vec &x_out);
/** Incompressible flow in unit cube */
void
t8_flow_incomp_cube_flow (const t8_3D_point &x, const double t, t8_3D_vec &x_out);
t8_flow_incomp_cube_flow (const t8_3D_vec &x, const double t, t8_3D_vec &x_out);

/** 2d flow around a circle with radius R = 1 and
* constant inflow with x-speed U = 1.
* See https://doi.org/10.13140/RG.2.2.34714.11203 */
void
t8_flow_around_circle (const t8_3D_point &x, const double t, t8_3D_vec &x_out);
t8_flow_around_circle (const t8_3D_vec &x, const double t, t8_3D_vec &x_out);

void
t8_flow_stokes_flow_sphere_shell (const t8_3D_point &x_in, const double t, t8_3D_vec &x_out);
t8_flow_stokes_flow_sphere_shell (const t8_3D_vec &x_in, const double t, t8_3D_vec &x_out);

void
t8_flow_around_circle_with_angular_velocity (const t8_3D_point &x, const double t, t8_3D_vec &x_out);
t8_flow_around_circle_with_angular_velocity (const t8_3D_vec &x, const double t, t8_3D_vec &x_out);

#endif /* !T8_EXAMPLE_COMMON_H */
34 changes: 17 additions & 17 deletions example/common/t8_example_common_functions.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include <t8_types/t8_vec.hxx>

double
t8_levelset_sphere (const t8_3D_point &x, [[maybe_unused]] const double t, void *data)
t8_levelset_sphere (const t8_3D_vec &x, [[maybe_unused]] const double t, void *data)
{
t8_levelset_sphere_data_t *ls_data = (t8_levelset_sphere_data_t *) data;

Expand Down Expand Up @@ -161,36 +161,36 @@ t8_scalar3d_sphere_05_0z_midpoint_375_radius (const t8_3D_vec &x, [[maybe_unused
}

void
t8_flow_constant_one_vec ([[maybe_unused]] const t8_3D_point &x, [[maybe_unused]] const double t, t8_3D_vec &x_out)
t8_flow_constant_one_vec ([[maybe_unused]] const t8_3D_vec &x, [[maybe_unused]] const double t, t8_3D_vec &x_out)
{
x_out[0] = x_out[1] = x_out[2] = 1;
}

void
t8_flow_constant_one_x_vec ([[maybe_unused]] const t8_3D_point &x, [[maybe_unused]] const double t, t8_3D_vec &x_out)
t8_flow_constant_one_x_vec ([[maybe_unused]] const t8_3D_vec &x, [[maybe_unused]] const double t, t8_3D_vec &x_out)
{
x_out[0] = 1;
x_out[1] = x_out[2] = 0;
}

void
t8_flow_constant_one_xy_vec ([[maybe_unused]] const t8_3D_point &x, [[maybe_unused]] const double t, t8_3D_vec &x_out)
t8_flow_constant_one_xy_vec ([[maybe_unused]] const t8_3D_vec &x, [[maybe_unused]] const double t, t8_3D_vec &x_out)
{
x_out[0] = 1;
x_out[1] = 0.8;
x_out[2] = 0;
}

void
t8_flow_constant_one_xyz_vec ([[maybe_unused]] const t8_3D_point &x, [[maybe_unused]] const double t, t8_3D_vec &x_out)
t8_flow_constant_one_xyz_vec ([[maybe_unused]] const t8_3D_vec &x, [[maybe_unused]] const double t, t8_3D_vec &x_out)
{
x_out[0] = 1;
x_out[1] = 0.8;
x_out[2] = 0.9;
}

void
t8_flow_rotation_2d (const t8_3D_point &x_in, [[maybe_unused]] const double t, t8_3D_vec &x_out)
t8_flow_rotation_2d (const t8_3D_vec &x_in, [[maybe_unused]] const double t, t8_3D_vec &x_out)
{
double x = x_in[0], y = x_in[1];

Expand All @@ -205,7 +205,7 @@ t8_flow_rotation_2d (const t8_3D_point &x_in, [[maybe_unused]] const double t, t
}

void
t8_flow_compressible (const t8_3D_point &x_in, [[maybe_unused]] const double t, t8_3D_vec &x_out)
t8_flow_compressible (const t8_3D_vec &x_in, [[maybe_unused]] const double t, t8_3D_vec &x_out)
{
x_out[0] = (1. / 2 - x_in[0]);
x_out[1] = 0;
Expand All @@ -229,7 +229,7 @@ t8_incomp_cube_df_sin (double x)
}

void
t8_flow_incomp_cube_flow (const t8_3D_point &x, const double t, t8_3D_vec &x_out)
t8_flow_incomp_cube_flow (const t8_3D_vec &x, const double t, t8_3D_vec &x_out)
{
double (*f) (double) = t8_incomp_cube_f_sin;
double (*df) (double) = t8_incomp_cube_df_sin;
Expand All @@ -252,7 +252,7 @@ t8_flow_incomp_cube_flow (const t8_3D_point &x, const double t, t8_3D_vec &x_out
* On output: polar[0] = r, polar[1] = phi
*/
static void
t8_flow_2d_polar_coords (const t8_vec<2> &x, t8_vec<2> &polar)
t8_flow_2d_polar_coords (const t8_2D_vec &x, t8_2D_vec &polar)
{
polar[0] = sqrt (SC_SQR (x[0]) + SC_SQR (x[1]));
polar[1] = atan2 (x[1], x[0]);
Expand All @@ -267,7 +267,7 @@ t8_flow_2d_polar_coords (const t8_vec<2> &x, t8_vec<2> &polar)
*
*/
static void
t8_flow_2d_cart_coords (const t8_vec<2> &polar_values, const t8_vec<2> &polar_coords, t8_vec<2> &cart)
t8_flow_2d_cart_coords (const t8_2D_vec &polar_values, const t8_2D_vec &polar_coords, t8_2D_vec &cart)
{
cart[0] = cos (polar_coords[1]) * polar_values[0] - sin (polar_coords[1]) * polar_values[1];
cart[1] = sin (polar_coords[1]) * polar_values[0] + cos (polar_coords[1]) * polar_values[1];
Expand All @@ -276,12 +276,12 @@ t8_flow_2d_cart_coords (const t8_vec<2> &polar_values, const t8_vec<2> &polar_co
/* 2d flow around a circle with radius R = 1 and
* constant inflow with x-speed U = 1. */
void
t8_flow_around_circle (const t8_3D_point &x, [[maybe_unused]] const double t, t8_3D_vec &x_out)
t8_flow_around_circle (const t8_3D_vec &x, [[maybe_unused]] const double t, t8_3D_vec &x_out)
{
t8_vec<2> polar;
t8_vec<2> polar_speed;
const t8_vec<2> x_2D = t8_vec<2> ({ x[0], x[1] });
t8_vec<2> x_out_2D ({ x_out[0], x_out[1] });
t8_2D_vec polar;
t8_2D_vec polar_speed;
const t8_2D_vec x_2D = t8_2D_vec ({ x[0], x[1] });
t8_2D_vec x_out_2D ({ x_out[0], x_out[1] });
const double R = 0.15;

t8_axb (x_2D, x_out_2D, 1, -0.5);
Expand Down Expand Up @@ -335,7 +335,7 @@ t8_flow_stokes_sphere_f_component (double radius, double alpha, double beta, int
}

void
t8_flow_stokes_flow_sphere_shell (const t8_3D_point &x_in, [[maybe_unused]] const double t, t8_3D_vec &x_out)
t8_flow_stokes_flow_sphere_shell (const t8_3D_vec &x_in, [[maybe_unused]] const double t, t8_3D_vec &x_out)
{
double radius;
double theta, phi;
Expand Down Expand Up @@ -375,7 +375,7 @@ t8_flow_stokes_flow_sphere_shell (const t8_3D_point &x_in, [[maybe_unused]] cons
}

void
t8_flow_around_circle_with_angular_velocity (const t8_3D_point &x, [[maybe_unused]] const double t, t8_3D_vec &x_out)
t8_flow_around_circle_with_angular_velocity (const t8_3D_vec &x, [[maybe_unused]] const double t, t8_3D_vec &x_out)
{
const double radius = 0.5;
const double omega = 1.5 * M_PI;
Expand Down
14 changes: 7 additions & 7 deletions example/remove/t8_example_gauss_blob.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ struct t8_adapt_data
const int remove_scope;
const double spheres_radius_inner;
const double spheres_radius_outer;
const t8_3D_point midpoint;
const t8_3D_vec midpoint;
};

static double
t8_gausss_blob (const t8_3D_point &center_elem, const t8_3D_point &center_cube, const double radius)
t8_gausss_blob (const t8_3D_vec &center_elem, const t8_3D_vec &center_cube, const double radius)
{
double expo = 0;
for (int i = 0; i < 3; i++) {
Expand All @@ -49,7 +49,7 @@ t8_gausss_blob (const t8_3D_point &center_elem, const t8_3D_point &center_cube,
}

static double *
t8_create_element_data (t8_forest_t forest, const t8_3D_point &sphere_center, const double sphere_radius)
t8_create_element_data (t8_forest_t forest, const t8_3D_vec &sphere_center, const double sphere_radius)
{
t8_locidx_t num_local_elements;
t8_locidx_t num_ghost_elements;
Expand All @@ -68,7 +68,7 @@ t8_create_element_data (t8_forest_t forest, const t8_3D_point &sphere_center, co
t8_locidx_t num_elements_in_tree = t8_forest_get_tree_num_leaf_elements (forest, itree);
for (t8_locidx_t ielement = 0; ielement < num_elements_in_tree; ++ielement, ++current_index) {
element = t8_forest_get_leaf_element_in_tree (forest, itree, ielement);
t8_3D_point center;
t8_3D_vec center;
t8_forest_element_centroid (forest, itree, element, center.data ());
element_data[current_index] = t8_gausss_blob (center, sphere_center, sphere_radius);
}
Expand Down Expand Up @@ -104,7 +104,7 @@ t8_adapt_refine (t8_forest_t forest, t8_forest_t forest_from, const t8_locidx_t
const struct t8_adapt_data *adapt_data = (const struct t8_adapt_data *) t8_forest_get_user_data (forest);
T8_ASSERT (adapt_data != NULL);

t8_3D_point centroid;
t8_3D_vec centroid;
t8_forest_element_centroid (forest_from, which_tree, elements[0], centroid.data ());

const double dist = t8_dist (adapt_data->midpoint, centroid);
Expand All @@ -124,7 +124,7 @@ t8_adapt_remove (t8_forest_t forest, t8_forest_t forest_from, const t8_locidx_t
const struct t8_adapt_data *adapt_data = (const struct t8_adapt_data *) t8_forest_get_user_data (forest);
T8_ASSERT (adapt_data != NULL);

t8_3D_point centroid;
t8_3D_vec centroid;
t8_forest_element_centroid (forest_from, which_tree, elements[0], centroid.data ());

const double dist = t8_dist (adapt_data->midpoint, centroid);
Expand All @@ -151,7 +151,7 @@ t8_construct_spheres (const int initial_level, const double radius_inner, const
cmesh = t8_cmesh_new_hypercube_hybrid (sc_MPI_COMM_WORLD, 0, 0);
}

t8_3D_point midpoint ({ 0.5, 0.5, 0.5 });
t8_3D_vec midpoint ({ 0.5, 0.5, 0.5 });

/* On each face of a cube, a sphere rises halfway in.
* Its center is therefore the center of the corresponding surface. */
Expand Down
16 changes: 8 additions & 8 deletions example/remove/t8_example_spheres.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct t8_adapt_data
const int num_spheres;
const double spheres_radius_inner;
const double spheres_radius_outer;
std::vector<t8_3D_point> midpoints;
std::vector<t8_3D_vec> midpoints;
};

/* Refine, if element is within a given radius. */
Expand All @@ -47,11 +47,11 @@ t8_adapt_callback_refine (t8_forest_t forest, t8_forest_t forest_from, t8_locidx
const struct t8_adapt_data *adapt_data = (const struct t8_adapt_data *) t8_forest_get_user_data (forest);
T8_ASSERT (adapt_data != NULL);

t8_3D_point centroid;
t8_3D_vec centroid;
t8_forest_element_centroid (forest_from, which_tree, elements[0], centroid.data ());

auto within_radius
= [&] (const t8_3D_point &midpoint) { return t8_dist (midpoint, centroid) < adapt_data->spheres_radius_outer; };
= [&] (const t8_3D_vec &midpoint) { return t8_dist (midpoint, centroid) < adapt_data->spheres_radius_outer; };

if (std::any_of (adapt_data->midpoints.begin (), adapt_data->midpoints.end (), within_radius)) {
return 1;
Expand All @@ -69,11 +69,11 @@ t8_adapt_callback_remove (t8_forest_t forest, t8_forest_t forest_from, t8_locidx
const struct t8_adapt_data *adapt_data = (const struct t8_adapt_data *) t8_forest_get_user_data (forest);
T8_ASSERT (adapt_data != NULL);

t8_3D_point centroid;
t8_3D_vec centroid;
t8_forest_element_centroid (forest_from, which_tree, elements[0], centroid.data ());

auto within_radius
= [&] (const t8_3D_point &midpoint) { return t8_dist (midpoint, centroid) < adapt_data->spheres_radius_inner; };
= [&] (const t8_3D_vec &midpoint) { return t8_dist (midpoint, centroid) < adapt_data->spheres_radius_inner; };

if (std::any_of (adapt_data->midpoints.begin (), adapt_data->midpoints.end (), within_radius)) {
return 1;
Expand Down Expand Up @@ -110,9 +110,9 @@ t8_construct_spheres (const int initial_level, const double radius_inner, const
/* On each face of a cube, a sphere rises halfway in.
* Its center is therefore the center of the corresponding surface. */
const int num_spheres = 6;
std::vector<t8_3D_point> midpoints
= { t8_3D_point ({ 1.0, 0.5, 0.5 }), t8_3D_point ({ 0.5, 1.0, 0.5 }), t8_3D_point ({ 0.5, 0.5, 1.0 }),
t8_3D_point ({ 0.0, 0.5, 0.5 }), t8_3D_point ({ 0.5, 0.0, 0.5 }), t8_3D_point ({ 0.5, 0.5, 0.0 }) };
std::vector<t8_3D_vec> midpoints
= { t8_3D_vec ({ 1.0, 0.5, 0.5 }), t8_3D_vec ({ 0.5, 1.0, 0.5 }), t8_3D_vec ({ 0.5, 0.5, 1.0 }),
t8_3D_vec ({ 0.0, 0.5, 0.5 }), t8_3D_vec ({ 0.5, 0.0, 0.5 }), t8_3D_vec ({ 0.5, 0.5, 0.0 }) };
struct t8_adapt_data adapt_data = { num_spheres, radius_inner, radius_outer, midpoints };

forest = t8_forest_new_uniform (cmesh, t8_scheme_new_default (), initial_level, 0, sc_MPI_COMM_WORLD);
Expand Down
6 changes: 3 additions & 3 deletions mesh_handle/competences.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ struct cache_vertex_coordinates: public t8_crtp_operator<TUnderlying, cache_vert
}

protected:
mutable std::vector<t8_3D_point>
mutable std::vector<t8_3D_vec>
m_vertex_coordinates; /**< Cache for the vector of vertex coordinate arrays. Empty vector if not filled. */
};

Expand All @@ -135,7 +135,7 @@ struct cache_centroid: public t8_crtp_operator<TUnderlying, cache_centroid>
}

protected:
mutable std::optional<t8_3D_point>
mutable std::optional<t8_3D_vec>
m_centroid; /**< Cache for the coordinates of the centroid. Use optional to allow no value if cache is not filled. */
};

Expand Down Expand Up @@ -183,7 +183,7 @@ struct cache_face_centroids: t8_crtp_operator<TUnderlying, cache_face_centroids>
}

protected:
mutable std::vector<std::optional<t8_3D_point>> m_face_centroids; /**< Vector with the face centroid for each face. */
mutable std::vector<std::optional<t8_3D_vec>> m_face_centroids; /**< Vector with the face centroid for each face. */
};

/**
Expand Down
Loading