Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
DLR-AMR
GitHub Repository: DLR-AMR/t8code
Path: blob/main/tutorials/general/t8_step3.h
903 views
1
/*
2
This file is part of t8code.
3
t8code is a C library to manage a collection (a forest) of multiple
4
connected adaptive space-trees of general element classes in parallel.
5
6
Copyright (C) 2015 the developers
7
8
t8code is free software; you can redistribute it and/or modify
9
it under the terms of the GNU General Public License as published by
10
the Free Software Foundation; either version 2 of the License, or
11
(at your option) any later version.
12
13
t8code is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
GNU General Public License for more details.
17
18
You should have received a copy of the GNU General Public License
19
along with t8code; if not, write to the Free Software Foundation, Inc.,
20
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21
*/
22
23
/** file t8_step3.h
24
* This is the header file to the step3 example of t8code. It collects
25
* functions of t8_step3 that we reuse in other examples.
26
* In this example we discuss how to adapt a forest.
27
* The main program is t8_step3_main.
28
* See \ref t8_step3_adapt_forest.cxx for more details.
29
*/
30
31
#ifndef T8_STEP3_H
32
#define T8_STEP3_H
33
34
#include <t8.h> /* General t8code header, always include this. */
35
#include <t8_forest/t8_forest_general.h> /* forest definition and basic interface. */
36
37
T8_EXTERN_C_BEGIN ();
38
39
/** This is the main program of this example. It creates a coarse mesh and a forest,
40
* adapts the forest and writes some output.
41
*/
42
int
43
t8_step3_main (int argc, char **argv);
44
45
/* Functions used for other examples are below. */
46
47
/** Print the local and global number of elements of a forest. */
48
void
49
t8_step3_print_forest_information (t8_forest_t forest);
50
51
/* This is our own defined data that we will pass on to the
52
* adaptation callback. */
53
struct t8_step3_adapt_data
54
{
55
double midpoint[3]; /* The midpoint of our sphere. */
56
double refine_if_inside_radius; /* if an element's center is smaller than this value, we refine the element. */
57
double coarsen_if_outside_radius; /* if an element's center is larger this value, we coarsen its family. */
58
};
59
60
/** Adapt a forest according to our t8_step3_adapt_callback function.
61
* Thus, the input forest will get refined inside a sphere
62
* of radius 0.2 around (0.5, 0.5, 0.5) and coarsened outside of radius 0.4.
63
* \param [in] forest A committed forest.
64
* \return A new forest that arises from the input \a forest via adaptation.
65
*/
66
t8_forest_t
67
t8_step3_adapt_forest (t8_forest_t forest);
68
69
/* The adaptation callback function. This will refine elements inside of a given sphere
70
* and coarsen the elements outside of a given sphere.
71
* The necessary input data is of type t8_step3_adapt_data and should be passed to forest
72
* via t8_forest_set_user_data before calling this function.
73
* See t8_step3.cxx for more details.
74
*/
75
int
76
t8_step3_adapt_callback (t8_forest_t forest, t8_forest_t forest_from, t8_locidx_t which_tree, t8_eclass_t tree_class,
77
t8_locidx_t lelement_id, const t8_scheme_c *scheme, const int is_family,
78
const int num_elements, t8_element_t *elements[]);
79
80
T8_EXTERN_C_END ();
81
82
#endif /* !T8_STEP3_H */
83
84