/*1This file is part of t8code.2t8code is a C library to manage a collection (a forest) of multiple3connected adaptive space-trees of general element classes in parallel.45Copyright (C) 2015 the developers67t8code is free software; you can redistribute it and/or modify8it under the terms of the GNU General Public License as published by9the Free Software Foundation; either version 2 of the License, or10(at your option) any later version.1112t8code is distributed in the hope that it will be useful,13but WITHOUT ANY WARRANTY; without even the implied warranty of14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the15GNU General Public License for more details.1617You should have received a copy of the GNU General Public License18along with t8code; if not, write to the Free Software Foundation, Inc.,1951 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.20*/2122/**23* \file t8_cmesh_examples.h24* We provide example coarse meshes in this file25*/2627#ifndef T8_CMESH_EXAMPLES28#define T8_CMESH_EXAMPLES29#include <t8_cmesh/t8_cmesh.h>30#include <p4est_connectivity.h>31#include <p8est_connectivity.h>3233T8_EXTERN_C_BEGIN ();3435/** Constructs a cmesh from a given p4est_connectivity structure.36* \param[in] conn The p4est connectivity.37* \param[in] comm mpi communicator to be used with the new cmesh.38* \param[in] do_partition Flag whether the cmesh should be partitioned or not.39* \return A t8_cmesh structure that holds the same connectivity information40* as \a conn.41* \note This function requires that p4est is initialized. Make sure to call42* p4est_init before using this routine. If this is not the case, a43* warning is issued and p4est_init is called from within this function.44*/45t8_cmesh_t46t8_cmesh_new_from_p4est (p4est_connectivity_t *conn, sc_MPI_Comm comm, int do_partition);4748/** Constructs a cmesh from a given p8est_connectivity structure.49* \param[in] conn The p8est connectivity.50* \param[in] comm mpi communicator to be used with the new cmesh.51* \param[in] do_partition Flag whether the cmesh should be partitioned or not.52* \return A t8_cmesh structure that holds the same connectivity information53* as \a conn.54* \note This function requires that p4est is initialized. Make sure to call55* p4est_init before using this routine. If this is not the case, a56* warning is issued and p4est_init is called from within this function.57*/58t8_cmesh_t59t8_cmesh_new_from_p8est (p8est_connectivity_t *conn, sc_MPI_Comm comm, int do_partition);6061/** Construct a cmesh that has no trees. We do not know a special use case,62* this function is merely for debugging and to show the possibility.63* \param [in] comm mpi communicator to be used with the new cmesh.64* \param [in] do_partition Flag whether the cmesh should be partitioned or not.65* \param [in] dimension An empty cmesh requires a dimension nevertheless. 0 <= tree dimension <= 3.66* \return A committed t8_cmesh structure that has no trees.67*/68t8_cmesh_t69t8_cmesh_new_empty (sc_MPI_Comm comm, const int do_partition, const int dimension);7071/** Constructs a cmesh that consists only of one tree of a given element class.72* \param [in] eclass The element class.73* \param [in] comm mpi communicator to be used with the new cmesh.74* \return A committed t8_cmesh structure with one tree of class \a eclass.75*/76t8_cmesh_t77t8_cmesh_new_from_class (t8_eclass_t eclass, sc_MPI_Comm comm);7879/** Construct a hypercube forest from one primitive tree class.80* \param [in] eclass This element class determines the dimension and81* the number of trees needed to construct a cube.82* \param [in] comm The mpi communicator to be used.83* \param [in] do_bcast If this flag is nonzero the cmesh is only constructed84* on processor 0 and then broadcasted to the other85* processors in \a comm.86* TODO: this parameter will be moved to internal.87* \param [in] do_partition Create a partitioned cmesh.88* \param [in] periodic If true, the coarse mesh will be periodic in each direction.89* Not possible with \a eclass pyramid.90*/91t8_cmesh_t92t8_cmesh_new_hypercube (t8_eclass_t eclass, sc_MPI_Comm comm, int do_bcast, int do_partition, int periodic);9394/** Construct a hypercube forest from one primitive tree class.95* \param [in] eclass This element class determines the dimension of the cube.96* \param [in] comm The mpi communicator to be used.97* \param [in] boundary The vertices, that define the hypercube boundary.98* \param [in] polygons_x The number of polygons along the x-axis.99* \param [in] polygons_y The number of polygons along the y-axis.100* Only required if \a eclass is 2D or 3D.101* \param [in] polygons_z The number of polygons along the z-axis.102* Only required if \a eclass is 3D.103* \param [in] use_axis_aligned Use the axis-aligned geometry. If used, only two points per tree are stored.104* \return A committed t8_cmesh structure with105* \a polygons_x * \a polygons_z * \a polygons_y many106* sub-hypercubes of class \a eclass.107*108* \note \a boundary must point to an array with 3*8 (3D), 3*4 (2D), 3*2 (1D), or 3 (0D) entries.109* \note Every sub-hypercube contains different number of trees depending on \a eclass.110* If \a eclass == T8_ECLASS_VERTEX, _LINE, _QUAD or _HEX every sub-hypercube contains111* one tree, if _TRIANGLE or _PRISM two trees and if _TET six trees.112* This is done in the same way as in \see t8_cmesh_new_hypercube.113* Example: let eclass = T8_ECLASS_TRIANGLE114* boundary coordinates = a(0,0,0), b(3,0,0), c(0,2,0), d(3,2,0)115* polygons_x, _y, _z = 3, 1, 0116*117* c--f--h--d The hypercube defined by the boundary coordinates118* | | | | is first split into 3 sub-hypercubes. The sub-hypercubes119* | | | | are ordered from left to right (and top to bottom).120* a--e--g--b Coordinates e,f,g,h are (1,0,0),(1,2,0),(2,0,0),(2,2,0).121*122* c--f--h--d Each sub-hypercube is the split into 2 triangle roots.123* |1/|3/|5/| The ordering is the same as in \see t8_cmesh_new_hypercube.124* |/0|/2|/4| Thus, we get 6 trees, which are ordered as shown in the picture.125* a--e--g--b126*127* See `example/cmesh/t8_cmesh_hypercube_pad.cxx` for a working example.128*/129t8_cmesh_t130t8_cmesh_new_hypercube_pad (const t8_eclass_t eclass, sc_MPI_Comm comm, const double *boundary, t8_locidx_t polygons_x,131t8_locidx_t polygons_y, t8_locidx_t polygons_z, const int use_axis_aligned);132133/** Construct a hypercube forest from one primitive tree class.134* \param [in] eclass This element class determines the dimension of the cube.135* \param [in] comm The mpi communicator to be used.136* \param [in] boundary The vertices, that define the hypercube boundary.137* \param [in] polygons_x The number of polygons along the x-axis.138* \param [in] polygons_y The number of polygons along the y-axis.139* Only required if \a eclass is 2D or 3D.140* \param [in] polygons_z The number of polygons along the z-axis.141* Only required if \a eclass is 3D.142* \param [in] periodic_x Connect opposite sides of the hypercube in x-direction.143* \param [in] periodic_y Connect opposite sides of the hypercube in y-direction.144* \param [in] periodic_z Connect opposite sides of the hypercube in z-direction.145* \param [in] use_axis_aligned Use the axis-aligned geometry. If used, only two points per tree are stored.146* \param [in] set_partition If true, partition the cmesh.147* \param [in] offset Offset of the local tree ids for a given partition.148* \return A committed t8_cmesh structure with149* \a polygons_x * \a polygons_z * \a polygons_y many150* sub-hypercubes of class \a eclass.151* \note \a boundary must point to an array with 3*8 (3D), 3*4 (2D), 3*2 (1D), or 3 (0D) entries.152* Every sub-hypercube contains different number of trees depending on \a eclass.153* \note If \a eclass == T8_ECLASS_VERTEX, _LINE, _QUAD or _HEX every sub-hypercube contains154* one tree, if _TRIANGLE or _PRISM two trees and if _TET six trees.155* This is done in the same way as in \see t8_cmesh_new_hypercube.156* Example: let eclass = T8_ECLASS_TRIANGLE157* boundary coordinates = a(0,0,0), b(3,0,0), c(0,2,0), d(3,2,0)158* polygons_x, _y, _z = 3, 1, 0159*160* c--f--h--d The hypercube defined by the boundary coordinates161* | | | | is first split into 3 sub-hypercubes. The sub-hypercubes162* | | | | are ordered from left to right (and top to bottom).163* a--e--g--b Coordinates e,f,g,h are (1,0,0),(1,2,0),(2,0,0),(2,2,0).164*165* c--f--h--d Each sub-hypercube is the split into 2 triangle roots.166* |1/|3/|5/| The ordering is the same as in \see t8_cmesh_new_hypercube.167* |/0|/2|/4| Thus, we get 6 trees, which are ordered as shown in the picture.168* a--e--g--b169*170*/171t8_cmesh_t172t8_cmesh_new_hypercube_pad_ext (const t8_eclass_t eclass, sc_MPI_Comm comm, const double *boundary,173t8_locidx_t polygons_x, t8_locidx_t polygons_y, t8_locidx_t polygons_z,174const int periodic_x, const int periodic_y, const int periodic_z,175const int use_axis_aligned, const int set_partition, t8_gloidx_t offset);176177/** Hybercube with 6 Tets, 6 Prism, 4 Hex.178* \param [in] comm The mpi communicator to be used.179* \param [in] do_partition If non-zero create a partitioned cmesh.180* \param [in] periodic If non-zero create a periodic cmesh in each direction181* \return A committed cmesh consisting of 6 Tets, 6 prism and 4 hex.182* Together, they form a cube.183*/184t8_cmesh_t185t8_cmesh_new_hypercube_hybrid (sc_MPI_Comm comm, int do_partition, int periodic);186187/** Construct a unit interval/square/cube coarse mesh that is periodic in each direction.188* Element class?189* Hypercube?190* TODO: redundant, remove.191* \param [in] comm The mpi communicator to use.192* \param [in] dim The dimension of the forest, 1, 2 or 3.193* \return A valid cmesh, as if _init and _commit had been called.194*/195t8_cmesh_t196t8_cmesh_new_periodic (sc_MPI_Comm comm, int dim);197198/** Construct a unit square of two triangles that is periodic in x and y.199* \param [in] comm The mpi communicator to use.200* \return A valid cmesh, as if _init and _commit had been called.201*/202t8_cmesh_t203t8_cmesh_new_periodic_tri (sc_MPI_Comm comm);204205/** Construct a unit square of two quads and four triangles that is periodic in x and y.206* \param [in] comm The mpi communicator to use.207* \return A valid cmesh, as if _init and _commit had been called.208*/209t8_cmesh_t210t8_cmesh_new_periodic_hybrid (sc_MPI_Comm comm);211212/** Construct a unit interval coarse mesh that consists of 3 trees and is213* periodic.214* \param [in] comm The mpi communicator to use.215* \return A valid cmesh, as is _init and _commit had been called.216*/217t8_cmesh_t218t8_cmesh_new_periodic_line_more_trees (sc_MPI_Comm comm);219220/** Construct a mesh consisting of a given number of same type trees.221* \param [in] eclass This element class determines the dimension and222* the type trees used.223* \param [in] num_trees The number of trees to use.224* \param [in] comm The MPI_Communicator used to commit the cmesh.225* \return A valid cmesh, as if _init and _commit had been called.226*/227t8_cmesh_t228t8_cmesh_new_bigmesh (t8_eclass_t eclass, int num_trees, sc_MPI_Comm comm);229230/** Construct a forest of three connected askew lines231* \param [in] comm The mpi communicator to use.232* \return A valid cmesh, as if _init and _commit had been called.233*/234t8_cmesh_t235t8_cmesh_new_line_zigzag (sc_MPI_Comm comm);236237/** Construct a forest of num_of_prisms connected prism, all with one edge in 0,238* except for num_of_prisms = 2, then the return is the hypercube mesh239* \param [in] comm The mpi communicator to use.240* \param [in] num_of_prisms The number of prisms to be used.241* \return A valid cmesh, as if _init and _commit had been called.242*/243t8_cmesh_t244t8_cmesh_new_prism_cake (sc_MPI_Comm comm, int num_of_prisms);245246/** Construct a single deformed prism247* \param [in] comm The mpi communicator to use.248* \return A valid cmesh; as if _init and _commit had been called.*/249t8_cmesh_t250t8_cmesh_new_prism_deformed (sc_MPI_Comm comm);251252/** Construct a single deformed pyramid253* \param [in] comm The mpi communicator to use.254* \return A valid cmesh; as if _init and _commit had been called.*/255t8_cmesh_t256t8_cmesh_new_pyramid_deformed (sc_MPI_Comm comm);257258/** Construct a forest of six connected noncannoical oriented prisms259* \param [in] comm The mpi communicator to use.260* \return A valid cmesh, as if _init and _commit had been called.261*/262t8_cmesh_t263t8_cmesh_new_prism_cake_funny_oriented (sc_MPI_Comm comm);264265/** Construct a forest of six connected noncannoical oriented prisms266* \param [in] comm The mpi communicator to use.267* \return A valid cmesh, as if _init and _commit had been called.268*/269t8_cmesh_t270t8_cmesh_new_prism_geometry (sc_MPI_Comm comm);271272/** Create a cmesh of quads whose trees are given by a `num_x * num_y` brick connectivity.273* \param [in] num_x The number of trees in x-direction. Must be >= 0.274* \param [in] num_y The number of trees in y-direction. Must be >= 0.275* \param [in] x_periodic If nonzero, the local brick connectivity is periodic in x direction.276* \param [in] y_periodic If nonzero, the local brick connectivity is periodic in y direction.277* \param [in] comm The MPI communicator used to commit the cmesh.278* \return A committed and partitioned cmesh.279*/280t8_cmesh_t281t8_cmesh_new_brick_2d (t8_gloidx_t num_x, t8_gloidx_t num_y, int x_periodic, int y_periodic, sc_MPI_Comm comm);282283/** Create a cmesh of hexs whose trees are given by a `num_x * num_y * num_z` brick connectivity.284* \param [in] num_x The number of trees in x-direction. Must be >= 0.285* \param [in] num_y The number of trees in y-direction. Must be >= 0.286* \param [in] num_z The number of trees in z-direction. Must be >= 0.287* \param [in] x_periodic If nonzero, the local brick connectivity is periodic in x direction.288* \param [in] y_periodic If nonzero, the local brick connectivity is periodic in y direction.289* \param [in] z_periodic If nonzero, the local brick connectivity is periodic in z direction.290* \param [in] comm The MPI communicator used to commit the cmesh.291* \return A committed and partitioned cmesh.292*/293t8_cmesh_t294t8_cmesh_new_brick_3d (t8_gloidx_t num_x, t8_gloidx_t num_y, t8_gloidx_t num_z, int x_periodic, int y_periodic,295int z_periodic, sc_MPI_Comm comm);296297/** Create a partitioned cmesh of quads whose local trees are given by an298* num_x by num_y brick connectivity from p4est299* or a num_x by num_y by num_z brick connectivity from p8est.300* num_x and num_y and num_z can be different for different MPI ranks.301* \param [in] num_x The number of trees in x direction for this rank. Must be >= 0.302* \param [in] num_y The number of trees in y direction for this rank. Must be >= 0.303* \param [in] num_z The number of trees in z direction for this rank. Must be >= 0.304* If nonzero, the cmesh is 3 dimensional.305* \param [in] x_periodic If nonzero, the local brick connectivity is periodic in x direction.306* \param [in] y_periodic If nonzero, the local brick connectivity is periodic in y direction.307* \param [in] z_periodic If nonzero and \a num_z > 0, the local brick connectivity is periodic in z direction.308* \param [in] comm The MPI communicator used to commit the cmesh.309* \return A committed and partitioned cmesh. The process local trees310* form a \a num_x by \a num_y (by \a num_z) brick.311* It is possible for num_x or num_y to be set to zero. In this case the local part312* of the cmesh will be empty.313* If num_z is set to zero, the cmesh is 2 dimensional.314*/315t8_cmesh_t316t8_cmesh_new_disjoint_bricks (t8_gloidx_t num_x, t8_gloidx_t num_y, t8_gloidx_t num_z, int x_periodic, int y_periodic,317int z_periodic, sc_MPI_Comm comm);318319/** Construct a tetrahedral cmesh that has all possible face to face320* connections and orientations.321* This cmesh is used for testing and debugging.322* \param [in] comm The MPI communicator used to commit the cmesh.323* \return A committed and replicated cmesh of 24 tetrahedron trees324* in which each (face -> face, orientation) face connection325* is set at least once.326* Note that most faces in this cmesh are boundary faces.327*/328t8_cmesh_t329t8_cmesh_new_tet_orientation_test (sc_MPI_Comm comm);330331/** Construct a hybrid cmesh with 2 tets, 2 prism, 1 hex.332* This cmesh is used for testing and debugging.333* \param [in] comm The MPI communicator used to commit the cmesh.334* \return A committed and replicated hybrid cmesh of 5 trees.335*/336t8_cmesh_t337t8_cmesh_new_hybrid_gate (sc_MPI_Comm comm);338339/** Construct a hybrid cmesh with 2 tets, 2 prism, 1 hex and all are deformed.340* This cmesh is used for testing and debugging.341* \param [in] comm The MPI communicator used to commit the cmesh.342* \return A committed and replicated hybrid cmesh of 5 trees.343*/344t8_cmesh_t345t8_cmesh_new_hybrid_gate_deformed (sc_MPI_Comm comm);346347/** Construct a full hybrig cmesh, with 1 hex, 1 pyra, 1 prism and 1 tet348* This cmesh is used for testing and debugging.349* \param [in] comm The MPI communicator used to commit the cmesh.350* \return A committed and replicated hybrid cmesh of 4 trees.351*/352t8_cmesh_t353t8_cmesh_new_full_hybrid (sc_MPI_Comm comm);354355/** Construct a mesh out of num_of_pyra many pyramids. They form a circle, face 0 is356* connected with face 1 of the next pyramid.357* \param [in] comm The MPI communicator used to commit the cmesh358* \param [in] num_of_pyra The number of pyramids to construct. Should be larger than 2359* \return A cmesh with num_of_pyra many pyramids360*/361t8_cmesh_t362t8_cmesh_new_pyramid_cake (sc_MPI_Comm comm, int num_of_pyra);363364/** Construct a bigger mesh, consisting of many cubes made by pyramids365* \param [in] comm The MPI communicator used to commit the cmesh366* \param [in] num_cubes The number of cubes of pyramids367* \return A cmesh with \a num_cubes many hypercubes368* */369t8_cmesh_t370t8_cmesh_new_long_brick_pyramid (sc_MPI_Comm comm, int num_cubes);371372/** Construct \a num_trees many cubes each of length 1 connected along the x-axis373* without any additional attributes than the tree-vertices, or with additional attributes.374* \param [in] num_trees The number of trees along the x-axis375* \param [in] set_attributes If 1, set tree_id and num_trees as additional attribute for each tree.376* \param [in] do_partition Partition the cmesh.377* \param [in] comm The MPI communicator used to commit the cmesh.378* \param [in] package_id The package id to use for the cmesh. Cannot be the t8 or sc package id.379* \return A cmesh with \a num_trees many hexahedrons.380*/381t8_cmesh_t382t8_cmesh_new_row_of_cubes (t8_locidx_t num_trees, const int set_attributes, const int do_partition, sc_MPI_Comm comm,383const int package_id);384385/** Construct a quadrangulated disk of given radius.386* \param [in] radius Radius of the sphere.387* \param [in] comm The MPI communicator used to commit the cmesh388* \return A cmesh representing the spherical surface.389*/390t8_cmesh_t391t8_cmesh_new_quadrangulated_disk (const double radius, sc_MPI_Comm comm);392393/** Construct a triangulated spherical surface of given radius: octahedron version.394* \param [in] radius Radius of the sphere.395* \param [in] comm The MPI communicator used to commit the cmesh396* \return A cmesh representing the spherical surface.397*/398t8_cmesh_t399t8_cmesh_new_triangulated_spherical_surface_octahedron (const double radius, sc_MPI_Comm comm);400401/** Construct a triangulated spherical surface of given radius: icosahedron version.402* \param [in] radius Radius of the sphere.403* \param [in] comm The MPI communicator used to commit the cmesh404* \return A cmesh representing the spherical surface.405*/406t8_cmesh_t407t8_cmesh_new_triangulated_spherical_surface_icosahedron (const double radius, sc_MPI_Comm comm);408409/** Construct a triangulated spherical surface of given radius: cube version.410* \param [in] radius Radius of the sphere.411* \param [in] comm The MPI communicator used to commit the cmesh412* \return A cmesh representing the spherical surface.413*/414t8_cmesh_t415t8_cmesh_new_triangulated_spherical_surface_cube (const double radius, sc_MPI_Comm comm);416417/** Construct a quadrangulated spherical surface of given radius.418* \param [in] radius Radius of the sphere.419* \param [in] comm The MPI communicator used to commit the cmesh420* \return A cmesh representing the spherical surface.421*/422t8_cmesh_t423t8_cmesh_new_quadrangulated_spherical_surface (const double radius, sc_MPI_Comm comm);424425/** Construct a spherical shell discretized by prisms of given inner radius and thickness: octahedron version.426* \param [in] inner_radius Radius of the inner side of the shell.427* \param [in] shell_thickness Thickness of the shell.428* \param [in] num_levels Refinement level per patch in longitudinal and latitudinal direction.429* \param [in] num_layers Number of layers of the shell.430* \param [in] comm The MPI communicator used to commit the cmesh431* \return A cmesh representing the spherical surface.432*/433t8_cmesh_t434t8_cmesh_new_prismed_spherical_shell_octahedron (const double inner_radius, const double shell_thickness,435const int num_levels, const int num_layers, sc_MPI_Comm comm);436437/** Construct a spherical shell discretized by prisms of given inner radius and thickness: icosahedron version.438* \param [in] inner_radius Radius of the inner side of the shell.439* \param [in] shell_thickness Thickness of the shell.440* \param [in] num_levels Refinement level per patch in longitudinal and latitudinal direction.441* \param [in] num_layers Number of layers of the shell.442* \param [in] comm The MPI communicator used to commit the cmesh443* \return A cmesh representing the spherical surface.444*/445t8_cmesh_t446t8_cmesh_new_prismed_spherical_shell_icosahedron (const double inner_radius, const double shell_thickness,447const int num_levels, const int num_layers, sc_MPI_Comm comm);448449/** Construct a cubed spherical shell of given inner radius and thickness.450* \param [in] inner_radius Radius of the inner side of the shell.451* \param [in] shell_thickness Thickness of the shell.452* \param [in] num_trees Number of trees per patch in longitudinal and latitudinal direction.453* \param [in] num_layers Number of layers of the shell.454* \param [in] comm The MPI communicator used to commit the cmesh455* \return A cmesh representing the spherical surface.456*/457t8_cmesh_t458t8_cmesh_new_cubed_spherical_shell (const double inner_radius, const double shell_thickness, const int num_trees,459const int num_layers, sc_MPI_Comm comm);460461/** Construct a cubed sphere of given radius.462* \param [in] radius Radius of the inner side of the shell.463* \param [in] comm The MPI communicator used to commit the cmesh464* \return A cmesh representing the spherical surface.465*/466t8_cmesh_t467t8_cmesh_new_cubed_sphere (const double radius, sc_MPI_Comm comm);468469T8_EXTERN_C_END ();470471#endif /* !T8_CMESH_EXAMPLES */472473474