p4est  2.8.643-dbc7-dirty
p4est is a software library for parallel adaptive mesh refinement.
p8est_io.h
Go to the documentation of this file.
1 /*
2  This file is part of p4est.
3  p4est is a C library to manage a collection (a forest) of multiple
4  connected adaptive quadtrees or octrees in parallel.
5 
6  Copyright (C) 2010 The University of Texas System
7  Additional copyright (C) 2011 individual authors
8  Written by Carsten Burstedde, Lucas C. Wilcox, and Tobin Isaac
9 
10  p4est is free software; you can redistribute it and/or modify
11  it under the terms of the GNU General Public License as published by
12  the Free Software Foundation; either version 2 of the License, or
13  (at your option) any later version.
14 
15  p4est is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with p4est; if not, write to the Free Software Foundation, Inc.,
22  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 */
24 
35 #ifndef P8EST_IO_H
36 #define P8EST_IO_H
37 
38 #include <p8est.h>
39 
40 SC_EXTERN_C_BEGIN;
41 
42 #define P8EST_FILE_MAGIC_NUMBER "p8data0"
43 #define P8EST_FILE_METADATA_BYTES 96
44 #define P8EST_FILE_MAGIC_BYTES 8
45 #define P8EST_FILE_VERSION_STR_BYTES 24
46 #define P8EST_FILE_ARRAY_METADATA_BYTES 14
47 /* subtract 2 for '\n' at the beginning and end of the array metadata */
48 #define P8EST_FILE_ARRAY_METADATA_CHARS (P8EST_FILE_ARRAY_METADATA_BYTES - 2)
49 #define P8EST_FILE_BYTE_DIV 16
50 #define P8EST_FILE_MAX_NUM_PAD_BYTES (P8EST_FILE_BYTE_DIV + 1)
57 #define P8EST_FILE_USER_STRING_BYTES 48
58 #define P8EST_FILE_FIELD_HEADER_BYTES (2 + P8EST_FILE_ARRAY_METADATA_BYTES + P8EST_FILE_USER_STRING_BYTES)
60 #define P8EST_FILE_MAX_GLOBAL_QUAD 9999999999999999
61 #define P8EST_FILE_MAX_BLOCK_SIZE 9999999999999
62 #define P8EST_FILE_MAX_FIELD_ENTRY_SIZE 9999999999999
75  sc_array_t ** data);
76 
96  p8est_connectivity_t * connectivity,
97  const p4est_gloidx_t *
98  global_first_quadrant,
99  const p4est_gloidx_t * pertree,
100  sc_array_t * quadrants, sc_array_t * data,
101  void *user_pointer);
102 
126  p8est_connectivity_t * connectivity,
127  const p4est_gloidx_t *
128  global_first_quadrant,
129  const p4est_gloidx_t * pertree,
130  sc_array_t * quadrants,
131  sc_array_t * data,
132  void *user_pointer);
133 
178 typedef struct p8est_file_context p8est_file_context_t;
179 
182 typedef enum p8est_file_error
183 {
209 }
211 
256  (p8est_t * p8est, const char *filename,
257  const char *user_string, int *errcode);
258 
290  const char *filename,
291  char *user_string, int *errcode);
292 
334  size_t block_size,
335  sc_array_t * block_data,
336  const char *user_string,
337  int *errcode);
338 
388  size_t header_size,
389  sc_array_t * header_data,
390  char *user_string, int *errcode);
391 
441  size_t quadrant_size,
442  sc_array_t * quadrant_data,
443  const char *user_string,
444  int *errcode);
445 
500  size_t quadrant_size,
501  sc_array_t * quadrant_data,
502  char *user_string, int *errcode);
503 
507 {
508  char block_type;
509  size_t data_size;
512 }
514 
560 int p8est_file_info (p8est_t * p8est, const char *filename,
561  char *user_string,
562  sc_array_t * data_sections,
563  int *errcode);
564 
574 int p8est_file_error_string (int errclass,
575  char *string, int *resultlen);
576 
618  p8est_t * p8est,
619  const char *quad_string,
620  const char *quad_data_string,
621  int *errcode);
622 
649  p8est_connectivity_t * conn,
650  size_t data_size,
651  p8est_t ** p8est,
652  char *quad_string,
653  char *quad_data_string,
654  int *errcode);
655 
685  fc,
687  conn,
688  const char *conn_string,
689  int *errcode);
690 
714  conn, char *conn_string,
715  int *errcode);
716 
732  int *errcode);
733 
734 SC_EXTERN_C_END;
735 
736 #endif /* !P8EST_IO_H */
int64_t p4est_gloidx_t
Typedef for globally unique indexing of quadrants.
Definition: p4est_base.h:118
The top-level 3D p8est interface.
#define P8EST_FILE_USER_STRING_BYTES
number of user string bytes
Definition: p8est_io.h:57
int p8est_file_error_string(int errclass, char *string, int *resultlen)
Turn p8est_file errcode into a string.
p8est_file_context_t * p8est_file_read_p8est(p8est_file_context_t *fc, p8est_connectivity_t *conn, size_t data_size, p8est_t **p8est, char *quad_string, char *quad_data_string, int *errcode)
Read a p8est to an opened file using the MPI communicator of fc.
int p8est_file_info(p8est_t *p8est, const char *filename, char *user_string, sc_array_t *data_sections, int *errcode)
Read metadata information of a file written by a matching forest.
p8est_file_context_t * p8est_file_write_connectivity(p8est_file_context_t *fc, p8est_connectivity_t *conn, const char *conn_string, int *errcode)
Write a connectivity to an opened file.
p8est_file_context_t * p8est_file_write_p8est(p8est_file_context_t *fc, p8est_t *p8est, const char *quad_string, const char *quad_data_string, int *errcode)
Write a p8est to an opened file.
p8est_file_error
Error values for p4est_file functions.
Definition: p8est_io.h:183
@ P8EST_FILE_ERR_BAD_FILE
invalid file name
Definition: p8est_io.h:190
@ P8EST_FILE_ERR_CONN
invalid serialized connectivity data
Definition: p8est_io.h:199
@ P8EST_FILE_ERR_UNKNOWN
unknown error
Definition: p8est_io.h:204
@ P8EST_FILE_ERR_P8EST
invalid p8est data
Definition: p8est_io.h:200
@ P8EST_FILE_ERR_FILE
invalid file handle
Definition: p8est_io.h:185
@ P8EST_FILE_ERR_IO
other I/O error
Definition: p8est_io.h:196
@ P8EST_FILE_ERR_LASTCODE
to define own error codes for a higher level application that is using p4est_file functions
Definition: p8est_io.h:205
@ P8EST_FILE_ERR_NO_SPACE
not enough space
Definition: p8est_io.h:192
@ P8EST_FILE_ERR_AMODE
access mode error
Definition: p8est_io.h:187
@ P8EST_FILE_ERR_QUOTA
quota exceeded
Definition: p8est_io.h:193
@ P8EST_FILE_ERR_COUNT
read or write count error that was not classified as a format error
Definition: p8est_io.h:202
@ P8EST_FILE_ERR_IN_USE
file currently open by other process
Definition: p8est_io.h:195
@ P8EST_FILE_ERR_READ_ONLY
read only file (system)
Definition: p8est_io.h:194
@ P8EST_FILE_ERR_NO_SUCH_FILE
file does not exist
Definition: p8est_io.h:188
@ P8EST_FILE_ERR_SUCCESS
file function completed with success
Definition: p8est_io.h:184
@ P8EST_FILE_ERR_NOT_SAME
collective arg not identical
Definition: p8est_io.h:186
@ P8EST_FILE_ERR_SECTION_TYPE
a valid non-matching section type
Definition: p8est_io.h:198
@ P8EST_FILE_ERR_IN_DATA
input data of file function is invalid
Definition: p8est_io.h:201
@ P8EST_FILE_ERR_ACCESS
permission denied
Definition: p8est_io.h:191
@ P8EST_FILE_ERR_FORMAT
read file has a wrong format
Definition: p8est_io.h:197
@ P8EST_FILE_ERR_FILE_EXIST
file exists already
Definition: p8est_io.h:189
sc_array_t * p8est_deflate_quadrants(p8est_t *p8est, sc_array_t **data)
Extract processor local quadrants' x y z level data.
p8est_file_context_t * p8est_file_open_create(p8est_t *p8est, const char *filename, const char *user_string, int *errcode)
Begin writing file header and saving data blocks into a parallel file.
p8est_file_context_t * p8est_file_read_connectivity(p8est_file_context_t *fc, p8est_connectivity_t **conn, char *conn_string, int *errcode)
Read a connectivity from an opened file.
p8est_file_context_t * p8est_file_open_read(p8est_t *p8est, const char *filename, char *user_string, int *errcode)
Open a file for reading and read its user string on rank zero.
struct p8est_file_section_metadata p8est_file_section_metadata_t
A data type that encodes the metadata of one data block in a p4est data file.
p8est_file_context_t * p8est_file_write_block(p8est_file_context_t *fc, size_t block_size, sc_array_t *block_data, const char *user_string, int *errcode)
Write a block section to an opened file.
p8est_t * p8est_inflate_null(sc_MPI_Comm mpicomm, p8est_connectivity_t *connectivity, const p4est_gloidx_t *global_first_quadrant, const p4est_gloidx_t *pertree, sc_array_t *quadrants, sc_array_t *data, void *user_pointer)
Create a new p4est based on serialized data.
struct p8est_file_context p8est_file_context_t
p8est data file format All p4est data files have 64 bytes file header section at the beginning of the...
Definition: p8est_io.h:178
p8est_file_context_t * p8est_file_read_block(p8est_file_context_t *fc, size_t header_size, sc_array_t *header_data, char *user_string, int *errcode)
Read a header block from an opened file.
p8est_file_context_t * p8est_file_write_field(p8est_file_context_t *fc, size_t quadrant_size, sc_array_t *quadrant_data, const char *user_string, int *errcode)
Write one (more) per-quadrant data set to a parallel output file.
p8est_file_context_t * p8est_file_read_field(p8est_file_context_t *fc, size_t quadrant_size, sc_array_t *quadrant_data, char *user_string, int *errcode)
Read one (more) per-quadrant data set from a parallel input file.
p8est_t * p8est_inflate(sc_MPI_Comm mpicomm, p8est_connectivity_t *connectivity, const p4est_gloidx_t *global_first_quadrant, const p4est_gloidx_t *pertree, sc_array_t *quadrants, sc_array_t *data, void *user_pointer)
Create a new p4est based on serialized data.
enum p8est_file_error p8est_file_error_t
Error values for p4est_file functions.
int p8est_file_close(p8est_file_context_t *fc, int *errcode)
Close a file opened for parallel write/read and free the context.
#define sc_MPI_ERR_LASTCODE
sc3_MPI_Comm_t sc_MPI_Comm
This structure holds the 3D inter-tree connectivity information.
Definition: p8est_connectivity.h:174
A data type that encodes the metadata of one data block in a p4est data file.
Definition: p8est_io.h:507
size_t data_size
data size in bytes per array element ('F') or of the header section ('H')
Definition: p8est_io.h:509
char user_string[P8EST_FILE_USER_STRING_BYTES]
user string of the data section
Definition: p8est_io.h:511
char block_type
'H' (header) or 'F' (data file)
Definition: p8est_io.h:508
The p8est forest datatype.
Definition: p8est.h:132