Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
DLR-AMR
GitHub Repository: DLR-AMR/t8code
Path: blob/main/src/t8_vtk/t8_vtk_writer.h
901 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) 2024 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
/**
24
* \file t8_vtk_writer.h
25
* This file contains wrappers for the vtk writer functions.
26
*/
27
28
#ifndef T8_VTK_WRITER_C_INTERFACE_H
29
#define T8_VTK_WRITER_C_INTERFACE_H
30
31
#include <t8.h>
32
#include <t8_vtk.h>
33
#include <t8_forest/t8_forest_types.h>
34
35
#if T8_ENABLE_VTK
36
#include <vtkUnstructuredGrid.h>
37
#endif
38
39
T8_EXTERN_C_BEGIN ();
40
41
#if T8_ENABLE_VTK
42
/**
43
* Translate a forest into a vtkUnstructuredGrid with respect to the given flags.
44
* This function uses the vtk library. t8code must be configured with
45
* "-DT8CODE_ENABLE_VTK=ON" in order to use it.
46
* \param [in] forest The forest.
47
* \param[in, out] unstructuredGrid
48
* \param [in] write_treeid If true, the global tree id is written for each element.
49
* \param [in] write_mpirank If true, the mpirank is written for each element.
50
* \param [in] write_level If true, the refinement level is written for each element.
51
* \param [in] write_element_id If true, the global element id is written for each element.
52
* \param [in] curved_flag If true, write the elements as curved element types from vtk.
53
* \param [in] write_ghosts If true, write out ghost elements as well.
54
* \param [in] num_data Number of user defined double valued data fields to write.
55
* \param [in] data Array of t8_vtk_data_field_t of length \a num_data
56
* providing the user defined per element data.
57
* If scalar and vector fields are used, all scalar fields
58
* must come first in the array.
59
*/
60
void
61
t8_forest_to_vtkUnstructuredGrid (t8_forest_t forest, vtkSmartPointer<vtkUnstructuredGrid> unstructuredGrid,
62
const int write_treeid, const int write_mpirank, const int write_level,
63
const int write_element_id, const int write_ghosts, const int curved_flag,
64
const int num_data, t8_vtk_data_field_t *data);
65
#endif
66
67
/** Write the forest in .pvtu file format. Writes one .vtu file per
68
* process and a meta .pvtu file.
69
* This function uses the vtk library. t8code must be configured with
70
* "-DT8CODE_ENABLE_VTK=ON" in order to use it.
71
* Currently does not support pyramid elements.
72
* \param [in] forest The forest.
73
* \param [in] fileprefix The prefix of the output files. The meta file will be named \a fileprefix.pvtu .
74
* \param [in] write_treeid If true, the global tree id is written for each element.
75
* \param [in] write_mpirank If true, the mpirank is written for each element.
76
* \param [in] write_level If true, the refinement level is written for each element.
77
* \param [in] write_element_id If true, the global element id is written for each element.
78
* \param [in] curved_flag If true, write the elements as curved element types from vtk.
79
* \param [in] write_ghosts If true, write out ghost elements as well.
80
* \param [in] num_data Number of user defined double valued data fields to write.
81
* \param [in] data Array of t8_vtk_data_field_t of length \a num_data
82
* providing the user defined per element data.
83
* If scalar and vector fields are used, all scalar fields
84
* must come first in the array.
85
* \return True if successful, false if not (process local).
86
* \note If t8code was not configured with vtk, use \ref t8_forest_vtk_write_file
87
*/
88
int
89
t8_forest_vtk_write_file_via_API (t8_forest_t forest, const char *fileprefix, const int write_treeid,
90
const int write_mpirank, const int write_level, const int write_element_id,
91
const int curved_flag, const int write_ghosts, const int num_data,
92
t8_vtk_data_field_t *data);
93
94
/** Write the forest in .pvtu file format. Writes one .vtu file per
95
* process and a meta .pvtu file.
96
* This function writes ASCII files and can be used when
97
* t8code is not configured with "-DT8CODE_ENABLE_VTK=ON" and
98
* \ref t8_forest_vtk_write_file_via_API is not available.
99
* \param [in] forest The forest.
100
* \param [in] fileprefix The prefix of the output files.
101
* \param [in] write_treeid If true, the global tree id is written for each element.
102
* \param [in] write_mpirank If true, the mpirank is written for each element.
103
* \param [in] write_level If true, the refinement level is written for each element.
104
* \param [in] write_element_id If true, the global element id is written for each element.
105
* \param [in] write_ghosts If true, each process additionally writes its ghost elements.
106
* For ghost element the treeid is -1.
107
* \param [in] num_data Number of user defined double valued data fields to write.
108
* \param [in] data Array of t8_vtk_data_field_t of length \a num_data
109
* providing the used defined per element data.
110
* If scalar and vector fields are used, all scalar fields
111
* must come first in the array.
112
* \return True if successful, false if not (process local).
113
*/
114
int
115
t8_forest_vtk_write_file (t8_forest_t forest, const char *fileprefix, const int write_treeid, const int write_mpirank,
116
const int write_level, const int write_element_id, int write_ghosts, const int num_data,
117
t8_vtk_data_field_t *data);
118
119
/**
120
* Write the cmesh in .pvtu file format. Writes one .vtu file per
121
* process and a meta .pvtu file.
122
* This function uses the vtk library. t8code must be configured with
123
* "-DT8CODE_ENABLE_VTK=ON" in order to use it.
124
*
125
* \param[in] cmesh The cmesh
126
* \param[in] fileprefix The prefix of the output files
127
* \param[in] comm The communicator to use
128
* \return int
129
* \note If t8code was not configured with vtk, use \ref t8_cmesh_vtk_write_file
130
*/
131
int
132
t8_cmesh_vtk_write_file_via_API (t8_cmesh_t cmesh, const char *fileprefix, sc_MPI_Comm comm);
133
134
/**
135
* Write the cmesh in .pvtu file format. Writes one .vtu file per
136
* process and a meta .pvtu file.
137
* This function writes ASCII files and can be used when
138
* t8code is not configured with "-DT8CODE_ENABLE_VTK=ON" and
139
* \ref t8_cmesh_vtk_write_file_via_API is not available.
140
*
141
* \param[in] cmesh The cmesh
142
* \param[in] fileprefix The prefix of the output files
143
* \return 0 if successful, non-zero otherwise
144
*/
145
int
146
t8_cmesh_vtk_write_file (t8_cmesh_t cmesh, const char *fileprefix);
147
148
T8_EXTERN_C_END ();
149
#endif /* T8_VTK_WRITER_C_INTERFACE_H */
150
151