Skip to content
Draft
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
2 changes: 1 addition & 1 deletion examples/compressible_euler/main.cu
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ int main(int argc, char* argv[]) {
{
size_t dim = 3;
sc_MPI_Comm comm = MPI_COMM_WORLD;
t8_scheme_cxx_t* scheme = t8_scheme_new_default_cxx();
t8_scheme* scheme = t8_scheme_new_default();
t8_cmesh_t cmesh = t8_cmesh_new_prismed_spherical_shell_icosahedron(0.8, 0.2, 2, 1, comm);
t8_forest_t forest = t8_forest_new_uniform(cmesh, scheme, 2, true, comm);

Expand Down
8 changes: 4 additions & 4 deletions examples/compressible_euler/solver.cu
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

using namespace t8gpu;

CompressibleEulerSolver::CompressibleEulerSolver(sc_MPI_Comm comm,
t8_scheme_cxx_t* scheme,
t8_cmesh_t cmesh,
t8_forest_t forest)
CompressibleEulerSolver::CompressibleEulerSolver(sc_MPI_Comm comm,
t8_scheme* scheme,
t8_cmesh_t cmesh,
t8_forest_t forest)
: m_comm{comm},
m_mesh_manager{comm, scheme, cmesh, forest},
m_device_face_speed_estimate(m_mesh_manager.get_num_local_faces() +
Expand Down
2 changes: 1 addition & 1 deletion examples/compressible_euler/solver.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace t8gpu {
/// This class takes ownership of the cmesh and forest given and
/// the constructor computes the necessary face information and
/// allocates space to store all of the variables.
CompressibleEulerSolver(sc_MPI_Comm comm, t8_scheme_cxx_t* scheme, t8_cmesh_t cmesh, t8_forest_t forest);
CompressibleEulerSolver(sc_MPI_Comm comm, t8_scheme* scheme, t8_cmesh_t cmesh, t8_forest_t forest);

/// @brief Destructor.
///
Expand Down
2 changes: 1 addition & 1 deletion examples/subgrid/kernels_2d.cu
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#define KERNELS_INCLUDE_IMPLEMENTATION
#include "kernels.h"

using SubgridType = t8gpu::Subgrid<4, 4>;
using SubgridType = t8gpu::Subgrid<16, 16>;

// We explicitely instantiate the kernel functions for the 2D subgrid
// in a separate compilation unit for better compilation speed
Expand Down
13 changes: 7 additions & 6 deletions examples/subgrid/main_2d.cu
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

#include <cstdio>
#include <string>

Expand All @@ -21,18 +22,18 @@ int main(int argc, char* argv[]) {
// We create a dummy frame so that destructors of solver class are
// called before MPI finalize.
{
using SubgridType = Subgrid<4, 4>;
using SubgridType = Subgrid<16, 16>;
using float_type = typename SubgridCompressibleEulerSolver<SubgridType>::float_type;

float_type delta_t =
static_cast<float_type>(0.1 * pow(0.5,
static_cast<float_type>(0.05 * pow(0.5,
SubgridMeshManager<VariableList, StepList, SubgridType>::max_level +
t8gpu::meta::log2_v<SubgridType::template extent<0>>));

sc_MPI_Comm comm = MPI_COMM_WORLD;
t8_scheme_cxx_t* scheme = t8_scheme_new_default_cxx();
t8_cmesh_t cmesh = t8_cmesh_new_periodic(comm, SubgridType::rank);
t8_forest_t forest = t8_forest_new_uniform(cmesh, scheme, 4, true, comm);
sc_MPI_Comm comm = MPI_COMM_WORLD;
t8_scheme* scheme = t8_scheme_new_default();
t8_cmesh_t cmesh = t8_cmesh_new_periodic(comm, SubgridType::rank);
t8_forest_t forest = t8_forest_new_uniform(cmesh, scheme, 8, true, comm);

SubgridCompressibleEulerSolver<SubgridType> solver{comm, scheme, cmesh, forest};

Expand Down
9 changes: 4 additions & 5 deletions examples/subgrid/main_3d.cu
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,10 @@ int main(int argc, char* argv[]) {
SubgridMeshManager<VariableList, StepList, SubgridType>::max_level +
t8gpu::meta::log2_v<SubgridType::template extent<0>>));

sc_MPI_Comm comm = MPI_COMM_WORLD;
t8_scheme_cxx_t* scheme = t8_scheme_new_default_cxx();
t8_cmesh_t cmesh = t8_cmesh_new_periodic(comm, SubgridType::rank);
t8_forest_t forest = t8_forest_new_uniform(cmesh, scheme, 4, true, comm);
// t8_forest_t forest = t8_forest_new_uniform(cmesh, scheme, 2, true, comm);
sc_MPI_Comm comm = MPI_COMM_WORLD;
t8_scheme* scheme = t8_scheme_new_default();
t8_cmesh_t cmesh = t8_cmesh_new_periodic(comm, SubgridType::rank);
t8_forest_t forest = t8_forest_new_uniform(cmesh, scheme, 4, true, comm);

SubgridCompressibleEulerSolver<SubgridType> solver{comm, scheme, cmesh, forest};

Expand Down
2 changes: 1 addition & 1 deletion examples/subgrid/solver.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class SubgridCompressibleEulerSolver {
/// This class takes ownership of the cmesh and forest given and
/// the constructor computes the necessary face information and
/// allocates space to store all of the variables.
SubgridCompressibleEulerSolver(sc_MPI_Comm comm, t8_scheme_cxx_t* scheme, t8_cmesh_t cmesh, t8_forest_t forest);
SubgridCompressibleEulerSolver(sc_MPI_Comm comm, t8_scheme* scheme, t8_cmesh_t cmesh, t8_forest_t forest);

/// @brief Destructor.
///
Expand Down
14 changes: 7 additions & 7 deletions examples/subgrid/solver.inl
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ __global__ std::enable_if_t<SubgridType::rank == 2, void> initialize_variables(
}

template<typename SubgridType>
SubgridCompressibleEulerSolver<SubgridType>::SubgridCompressibleEulerSolver(sc_MPI_Comm comm,
t8_scheme_cxx_t* scheme,
t8_cmesh_t cmesh,
t8_forest_t forest)
SubgridCompressibleEulerSolver<SubgridType>::SubgridCompressibleEulerSolver(sc_MPI_Comm comm,
t8_scheme* scheme,
t8_cmesh_t cmesh,
t8_forest_t forest)
: m_comm{comm},
m_mesh_manager{comm, scheme, cmesh, forest},
m_device_face_speed_estimate(m_mesh_manager.get_num_local_faces() +
Expand All @@ -119,8 +119,8 @@ SubgridCompressibleEulerSolver<SubgridType>::SubgridCompressibleEulerSolver(sc_M

t8_locidx_t element_idx = 0;
for (t8_locidx_t tree_idx = 0; tree_idx < num_local_trees; tree_idx++) {
t8_eclass_t tree_class{t8_forest_get_tree_class(forest, tree_idx)};
t8_eclass_scheme_c* eclass_scheme{t8_forest_get_eclass_scheme(forest, tree_class)};
t8_eclass_t tree_class{t8_forest_get_tree_class(forest, tree_idx)};
t8_scheme* scheme{t8_forest_get_scheme(forest)};

t8_locidx_t num_elements_in_tree{t8_forest_get_tree_num_elements(forest, tree_idx)};
for (t8_locidx_t tree_element_idx = 0; tree_element_idx < num_elements_in_tree; tree_element_idx++) {
Expand All @@ -132,7 +132,7 @@ SubgridCompressibleEulerSolver<SubgridType>::SubgridCompressibleEulerSolver(sc_M
centers[3 * element_idx + 1] = static_cast<float_type>(center[1]);
centers[3 * element_idx + 2] = static_cast<float_type>(center[2]);

levels[element_idx] = eclass_scheme->t8_element_level(element);
levels[element_idx] = scheme->element_get_level(tree_class, element);

element_idx++;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/subgrid/solver_2d.cu
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#define SOLVER_INCLUDE_IMPLEMENTATION
#include "solver.h"

using SubgridType = t8gpu::Subgrid<4, 4>;
using SubgridType = t8gpu::Subgrid<16, 16>;

// We explicitely instantiate the solver type for the 2D subgrid in a
// separate compilation unit for better compilation speed (instead of
Expand Down
31 changes: 16 additions & 15 deletions t8gpu/mesh/mesh_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ namespace t8gpu {
///
/// This constructor initializes a MeshManager class taking
/// ownership of the coarse mesh cmesh and forest.
MeshManager(sc_MPI_Comm comm, t8_scheme_cxx_t* scheme, t8_cmesh_t cmesh, t8_forest_t forest);
MeshManager(sc_MPI_Comm comm, t8_scheme* scheme, t8_cmesh_t cmesh, t8_forest_t forest);

/// @brief Destructor of the MeshManager class.
///
Expand Down Expand Up @@ -424,12 +424,12 @@ namespace t8gpu {
/// We make the base class resize member function private.
using MemoryManager<VariableType, StepType>::resize;

sc_MPI_Comm m_comm;
int m_rank;
int m_nb_ranks;
t8_scheme_cxx_t* m_scheme;
t8_cmesh_t m_cmesh;
t8_forest_t m_forest;
sc_MPI_Comm m_comm;
int m_rank;
int m_nb_ranks;
t8_scheme* m_scheme;
t8_cmesh_t m_cmesh;
t8_forest_t m_forest;

t8_locidx_t m_num_local_elements;
t8_locidx_t m_num_ghost_elements;
Expand All @@ -454,14 +454,15 @@ namespace t8gpu {
thrust::host_vector<float_type>* element_refinement_criteria;
};

static int adapt_callback_iteration(t8_forest_t forest,
t8_forest_t forest_from,
t8_locidx_t which_tree,
t8_locidx_t lelement_id,
t8_eclass_scheme_c* ts,
int const is_family,
int const num_elements,
t8_element_t* elements[]);
static int adapt_callback_iteration(t8_forest_t forest,
t8_forest_t forest_from,
t8_locidx_t which_tree,
t8_eclass_t const tree_class,
t8_locidx_t lelement_id,
t8_scheme_c const* ts,
int const is_family,
int const num_elements,
t8_element_t* elements[]);
};
} // namespace t8gpu

Expand Down
75 changes: 39 additions & 36 deletions t8gpu/mesh/mesh_manager.inl
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@
#include <t8.h>
#include <t8_cmesh.h>
#include <t8_cmesh/t8_cmesh_examples.h>
#include <t8_element_c_interface.h>
#include <t8_schemes/t8_scheme.h>
#include <t8_forest/t8_forest.h>
#include <t8_forest/t8_forest_io.h>
#include <t8_forest/t8_forest_iterate.h>
#include <t8_forest/t8_forest_partition.h>
#include <t8_schemes/t8_default/t8_default.hxx>

template<typename VariableType, typename StepType, size_t dim>
t8gpu::MeshManager<VariableType, StepType, dim>::MeshManager(sc_MPI_Comm comm,
t8_scheme_cxx_t* scheme,
t8_cmesh_t cmesh,
t8_forest_t forest)
t8gpu::MeshManager<VariableType, StepType, dim>::MeshManager(sc_MPI_Comm comm,
t8_scheme* scheme,
t8_cmesh_t cmesh,
t8_forest_t forest)
: m_comm{comm},
m_scheme{scheme},
m_cmesh{cmesh},
Expand Down Expand Up @@ -91,8 +91,7 @@ void t8gpu::MeshManager<VariableType, StepType, dim>::initialize_variables(Func
t8_locidx_t num_local_trees = t8_forest_get_num_local_trees(m_forest);
t8_locidx_t element_idx = 0;
for (t8_locidx_t tree_idx = 0; tree_idx < num_local_trees; tree_idx++) {
t8_eclass_t tree_class{t8_forest_get_tree_class(m_forest, tree_idx)};
t8_eclass_scheme_c* eclass_scheme{t8_forest_get_eclass_scheme(m_forest, tree_class)};
t8_scheme* eclass_scheme{t8_forest_get_scheme(m_forest)};

t8_locidx_t num_elements_in_tree{t8_forest_get_tree_num_elements(m_forest, tree_idx)};
for (t8_locidx_t tree_element_idx = 0; tree_element_idx < num_elements_in_tree; tree_element_idx++) {
Expand Down Expand Up @@ -122,19 +121,20 @@ void t8gpu::MeshManager<VariableType, StepType, dim>::initialize_variables(Func
}

template<typename VariableType, typename StepType, size_t dim>
int t8gpu::MeshManager<VariableType, StepType, dim>::adapt_callback_iteration(t8_forest_t forest,
t8_forest_t forest_from,
t8_locidx_t which_tree,
t8_locidx_t lelement_id,
t8_eclass_scheme_c* ts,
int const is_family,
int const num_elements,
t8_element_t* elements[]) {
int t8gpu::MeshManager<VariableType, StepType, dim>::adapt_callback_iteration(t8_forest_t forest,
t8_forest_t forest_from,
t8_locidx_t which_tree,
t8_eclass_t const tree_class,
t8_locidx_t lelement_id,
t8_scheme_c const* ts,
int const is_family,
int const num_elements,
t8_element_t* elements[]) {
t8gpu::MeshManager<VariableType, StepType, dim>::UserData* forest_user_data =
static_cast<t8gpu::MeshManager<VariableType, StepType, dim>::UserData*>(t8_forest_get_user_data(forest_from));
assert(forest_user_data != nullptr);

t8_locidx_t element_level{ts->t8_element_level(elements[0])};
t8_locidx_t element_level{ts->element_get_level(tree_class, elements[0])};

t8_locidx_t tree_offset = t8_forest_get_tree_element_offset(forest_from, which_tree);

Expand Down Expand Up @@ -229,28 +229,29 @@ void t8gpu::MeshManager<VariableType, StepType, dim>::adapt(

t8_locidx_t current_idx = 0;
for (t8_locidx_t tree_idx = 0; tree_idx < num_old_local_trees; tree_idx++) {
t8_eclass_t old_tree_class{t8_forest_get_tree_class(m_forest, tree_idx)};
t8_eclass_scheme_c* old_scheme = {t8_forest_get_eclass_scheme(m_forest, old_tree_class)};
t8_scheme* old_scheme = {t8_forest_get_scheme(m_forest)};
t8_eclass_t old_tree_class = t8_forest_get_tree_class(m_forest, tree_idx);

t8_locidx_t num_elements_in_tree{t8_forest_get_tree_num_elements(m_forest, tree_idx)};

for (t8_locidx_t elem_idx = 0; elem_idx < num_elements_in_tree; elem_idx++) {
t8_element_t const* element{t8_forest_get_element_in_tree(m_forest, tree_idx, elem_idx)};
old_levels[current_idx] = old_scheme->t8_element_level(element);
t8_eclass_t tree_class = t8_forest_get_tree_class(m_forest, tree_idx);
old_levels[current_idx] = old_scheme->element_get_level(old_tree_class, element);
current_idx++;
}
}

current_idx = 0;
for (t8_locidx_t tree_idx = 0; tree_idx < num_new_local_trees; tree_idx++) {
t8_eclass_t new_tree_class{t8_forest_get_tree_class(adapted_forest, tree_idx)};
t8_eclass_scheme_c* new_scheme = {t8_forest_get_eclass_scheme(adapted_forest, new_tree_class)};
t8_scheme* new_scheme = {t8_forest_get_scheme(adapted_forest)};
t8_eclass_t new_tree_class = t8_forest_get_tree_class(adapted_forest, tree_idx);

t8_locidx_t num_elements_in_tree{t8_forest_get_tree_num_elements(adapted_forest, tree_idx)};

for (t8_locidx_t elem_idx = 0; elem_idx < num_elements_in_tree; elem_idx++) {
t8_element_t const* element{t8_forest_get_element_in_tree(adapted_forest, tree_idx, elem_idx)};
new_levels[current_idx] = new_scheme->t8_element_level(element);
new_levels[current_idx] = new_scheme->element_get_level(new_tree_class, element);
current_idx++;
}
}
Expand Down Expand Up @@ -368,20 +369,20 @@ void t8gpu::MeshManager<VariableType, StepType, dim>::compute_connectivity_infor
t8_locidx_t num_local_trees{t8_forest_get_num_local_trees(m_forest)};
t8_locidx_t element_idx = 0;
for (t8_locidx_t tree_idx = 0; tree_idx < num_local_trees; tree_idx++) {
t8_eclass_t tree_class = t8_forest_get_tree_class(m_forest, tree_idx);
t8_eclass_scheme_c* eclass_scheme{t8_forest_get_eclass_scheme(m_forest, tree_class)};
t8_eclass_t tree_class = t8_forest_get_tree_class(m_forest, tree_idx);
t8_scheme* scheme{t8_forest_get_scheme(m_forest)};

t8_locidx_t num_elements_in_tree{t8_forest_get_tree_num_elements(m_forest, tree_idx)};
for (t8_locidx_t tree_element_idx = 0; tree_element_idx < num_elements_in_tree; tree_element_idx++) {
t8_element_t const* element{t8_forest_get_element_in_tree(m_forest, tree_idx, tree_element_idx)};

t8_locidx_t num_faces{eclass_scheme->t8_element_num_faces(element)};
t8_locidx_t num_faces{scheme->element_get_num_faces(tree_class, element)};
for (t8_locidx_t face_idx = 0; face_idx < num_faces; face_idx++) {
int num_neighbors{};
int* dual_faces{};
t8_locidx_t* neighbor_ids{};
t8_element_t** neighbors{};
t8_eclass_scheme_c* neigh_scheme{};
int num_neighbors{};
int* dual_faces{};
t8_locidx_t* neighbor_ids{};
t8_element_t** neighbors{};
t8_eclass_t neigh_eclass{};
t8_forest_leaf_face_neighbors(m_forest,
tree_idx,
element,
Expand All @@ -390,7 +391,7 @@ void t8gpu::MeshManager<VariableType, StepType, dim>::compute_connectivity_infor
&dual_faces,
&num_neighbors,
&neighbor_ids,
&neigh_scheme,
&neigh_eclass,
true);

for (int i = 0; i < num_neighbors; i++) {
Expand All @@ -411,7 +412,7 @@ void t8gpu::MeshManager<VariableType, StepType, dim>::compute_connectivity_infor
if ((num_neighbors == 1) && (neighbor_ids[0] < m_num_local_elements) &&
((neighbor_ids[0] > element_idx) ||
(neighbor_ids[0] < element_idx &&
neigh_scheme[0].t8_element_level(neighbors[0]) < eclass_scheme->t8_element_level(element)))) {
scheme->element_get_level(neigh_eclass, neighbors[0]) < scheme->element_get_level(tree_class, element)))) {
face_neighbors.push_back(element_idx);
face_neighbors.push_back(neighbor_ids[0]);
double face_normal[dim];
Expand All @@ -422,11 +423,13 @@ void t8gpu::MeshManager<VariableType, StepType, dim>::compute_connectivity_infor
face_area.push_back(
static_cast<float_type>(t8_forest_element_face_area(m_forest, tree_idx, element, face_idx)));
}
neigh_scheme->t8_element_destroy(num_neighbors, neighbors);
T8_FREE(neighbors);

T8_FREE(dual_faces);
T8_FREE(neighbor_ids);
if (num_neighbors > 0) {
scheme->element_destroy(neigh_eclass, num_neighbors, neighbors);
T8_FREE(neighbors);
T8_FREE(neighbor_ids);
T8_FREE(dual_faces);
}

if (num_neighbors == 0) {
boundary_face_neighbors.push_back(element_idx);
Expand Down
Loading