Program Listing for File constructor_wrappers.hxx
↰ Return to documentation for file (mesh_handle/constructor_wrappers.hxx)
/*
This file is part of t8code.
t8code is a C library to manage a collection (a forest) of multiple
connected adaptive space-trees of general element classes in parallel.
Copyright (C) 2026 the developers
t8code is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
t8code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with t8code; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#pragma once
#include <t8.h>
#include <t8_forest/t8_forest_general.h>
#include <t8_cmesh/t8_cmesh.h>
#include <t8_schemes/t8_default/t8_default.hxx>
#include <t8_cmesh/t8_cmesh_examples.h>
#include "concepts.hxx"
#include <memory>
namespace t8_mesh_handle
{
template <T8MeshType TMeshClass>
std::unique_ptr<TMeshClass>
handle_new_uniform (const t8_cmesh_t cmesh, const t8_scheme *scheme, const int level, const sc_MPI_Comm comm,
const bool do_face_ghost = false)
{
t8_forest_t forest = t8_forest_new_uniform (cmesh, scheme, level, do_face_ghost, comm);
return std::make_unique<TMeshClass> (forest);
}
template <T8MeshType TMeshClass>
std::unique_ptr<TMeshClass>
handle_new_uniform_default (const t8_cmesh_t cmesh, const int level, const sc_MPI_Comm comm,
const bool do_face_ghost = false)
{
return handle_new_uniform<TMeshClass> (cmesh, t8_scheme_new_default (), level, comm, do_face_ghost);
}
// --- A very small fraction of example coarse meshes is wrapped here for easy access and for the use in tests. ---
template <T8MeshType TMeshClass>
std::unique_ptr<TMeshClass>
handle_hypercube_hybrid_uniform_default (const int level, const sc_MPI_Comm comm, const bool do_partition = false,
const bool do_face_ghost = false, const bool periodic = false)
{
t8_cmesh_t cmesh = t8_cmesh_new_hypercube_hybrid (comm, do_partition, periodic);
return handle_new_uniform_default<TMeshClass> (cmesh, level, comm, do_face_ghost);
}
template <T8MeshType TMeshClass>
std::unique_ptr<TMeshClass>
handle_hypercube_uniform_default (t8_eclass_t eclass, const int level, const sc_MPI_Comm comm,
const bool do_partition = false, const bool do_face_ghost = false,
const bool periodic = false)
{
// Broadcast option is hidden from the user.
t8_cmesh_t cmesh = t8_cmesh_new_hypercube (eclass, comm, 0, do_partition, periodic);
return handle_new_uniform_default<TMeshClass> (cmesh, level, comm, do_face_ghost);
}
} // namespace t8_mesh_handle