/*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/** file t8_step3.h23* This is the header file to the step3 example of t8code. It collects24* functions of t8_step3 that we reuse in other examples.25* In this example we discuss how to adapt a forest.26* The main program is t8_step3_main.27* See \ref t8_step3_adapt_forest.cxx for more details.28*/2930#ifndef T8_STEP3_H31#define T8_STEP3_H3233#include <t8.h> /* General t8code header, always include this. */34#include <t8_forest/t8_forest_general.h> /* forest definition and basic interface. */3536T8_EXTERN_C_BEGIN ();3738/** This is the main program of this example. It creates a coarse mesh and a forest,39* adapts the forest and writes some output.40*/41int42t8_step3_main (int argc, char **argv);4344/* Functions used for other examples are below. */4546/** Print the local and global number of elements of a forest. */47void48t8_step3_print_forest_information (t8_forest_t forest);4950/* This is our own defined data that we will pass on to the51* adaptation callback. */52struct t8_step3_adapt_data53{54double midpoint[3]; /* The midpoint of our sphere. */55double refine_if_inside_radius; /* if an element's center is smaller than this value, we refine the element. */56double coarsen_if_outside_radius; /* if an element's center is larger this value, we coarsen its family. */57};5859/** Adapt a forest according to our t8_step3_adapt_callback function.60* Thus, the input forest will get refined inside a sphere61* of radius 0.2 around (0.5, 0.5, 0.5) and coarsened outside of radius 0.4.62* \param [in] forest A committed forest.63* \return A new forest that arises from the input \a forest via adaptation.64*/65t8_forest_t66t8_step3_adapt_forest (t8_forest_t forest);6768/* The adaptation callback function. This will refine elements inside of a given sphere69* and coarsen the elements outside of a given sphere.70* The necessary input data is of type t8_step3_adapt_data and should be passed to forest71* via t8_forest_set_user_data before calling this function.72* See t8_step3.cxx for more details.73*/74int75t8_step3_adapt_callback (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_tree, t8_eclass_t tree_class,76t8_locidx_t lelement_id, const t8_scheme_c *scheme, const int is_family,77const int num_elements, t8_element_t *elements[]);7879T8_EXTERN_C_END ();8081#endif /* !T8_STEP3_H */828384