p4est  2.8.643-dbc7-dirty
p4est is a software library for parallel adaptive mesh refinement.
p4est_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 P4EST_IO_H
36 #define P4EST_IO_H
37 
38 #include <p4est.h>
39 
40 SC_EXTERN_C_BEGIN;
41 
42 #define P4EST_FILE_MAGIC_NUMBER "p4data0"
43 #define P4EST_FILE_METADATA_BYTES 96
44 #define P4EST_FILE_MAGIC_BYTES 8
45 #define P4EST_FILE_VERSION_STR_BYTES 24
46 #define P4EST_FILE_ARRAY_METADATA_BYTES 14
47 /* subtract 2 for '\n' at the beginning and end of the array metadata */
48 #define P4EST_FILE_ARRAY_METADATA_CHARS (P4EST_FILE_ARRAY_METADATA_BYTES - 2)
49 #define P4EST_FILE_BYTE_DIV 16
50 #define P4EST_FILE_MAX_NUM_PAD_BYTES (P4EST_FILE_BYTE_DIV + 1)
57 #define P4EST_FILE_USER_STRING_BYTES 48
58 #define P4EST_FILE_FIELD_HEADER_BYTES (2 + P4EST_FILE_ARRAY_METADATA_BYTES + P4EST_FILE_USER_STRING_BYTES)
60 #define P4EST_FILE_MAX_GLOBAL_QUAD 9999999999999999
61 #define P4EST_FILE_MAX_BLOCK_SIZE 9999999999999
62 #define P4EST_FILE_MAX_FIELD_ENTRY_SIZE 9999999999999
75  sc_array_t ** data);
76 
96  p4est_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  p4est_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 p4est_file_context p4est_file_context_t;
179 
182 typedef enum p4est_file_error
183 {
209 }
211 
256  (p4est_t * p4est, 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 
439  size_t quadrant_size,
440  sc_array_t * quadrant_data,
441  const char *user_string,
442  int *errcode);
443 
499  size_t quadrant_size,
500  sc_array_t * quadrant_data,
501  char *user_string, int *errcode);
502 
506 {
507  char block_type;
508  size_t data_size;
511 }
513 
559 int p4est_file_info (p4est_t * p4est, const char *filename,
560  char *user_string,
561  sc_array_t * data_sections,
562  int *errcode);
563 
573 int p4est_file_error_string (int errclass,
574  char *string, int *resultlen);
575 
617  p4est_t * p4est,
618  const char *quad_string,
619  const char *quad_data_string,
620  int *errcode);
621 
648  p4est_connectivity_t * conn,
649  size_t data_size,
650  p4est_t ** p4est,
651  char *quad_string,
652  char *quad_data_string,
653  int *errcode);
654 
684  fc,
686  conn,
687  const char *conn_string,
688  int *errcode);
689 
713  conn, char *conn_string,
714  int *errcode);
715 
731  int *errcode);
732 
733 SC_EXTERN_C_END;
734 
735 #endif /* !P4EST_IO_H */
The top-level 2D p4est interface.
int64_t p4est_gloidx_t
Typedef for globally unique indexing of quadrants.
Definition: p4est_base.h:118
int p4est_file_info(p4est_t *p4est, const char *filename, char *user_string, sc_array_t *data_sections, int *errcode)
Read metadata information of a file written by a matching forest.
p4est_file_context_t * p4est_file_write_connectivity(p4est_file_context_t *fc, p4est_connectivity_t *conn, const char *conn_string, int *errcode)
Write a connectivity to an opened file.
p4est_file_error
Error values for p4est_file functions.
Definition: p4est_io.h:183
@ P4EST_FILE_ERR_BAD_FILE
invalid file name
Definition: p4est_io.h:190
@ P4EST_FILE_ERR_IN_DATA
input data of file function is invalid
Definition: p4est_io.h:201
@ P4EST_FILE_ERR_QUOTA
quota exceeded
Definition: p4est_io.h:193
@ P4EST_FILE_ERR_IN_USE
file currently open by other process
Definition: p4est_io.h:195
@ P4EST_FILE_ERR_IO
other I/O error
Definition: p4est_io.h:196
@ P4EST_FILE_ERR_LASTCODE
to define own error codes for a higher level application that is using p4est_file functions
Definition: p4est_io.h:205
@ P4EST_FILE_ERR_SECTION_TYPE
a valid non-matching section type
Definition: p4est_io.h:198
@ P4EST_FILE_ERR_P4EST
invalid p4est data
Definition: p4est_io.h:200
@ P4EST_FILE_ERR_FORMAT
read file has a wrong format
Definition: p4est_io.h:197
@ P4EST_FILE_ERR_CONN
invalid serialized connectivity data
Definition: p4est_io.h:199
@ P4EST_FILE_ERR_FILE
invalid file handle
Definition: p4est_io.h:185
@ P4EST_FILE_ERR_AMODE
access mode error
Definition: p4est_io.h:187
@ P4EST_FILE_ERR_FILE_EXIST
file exists already
Definition: p4est_io.h:189
@ P4EST_FILE_ERR_COUNT
read or write count error that was not classified as a format error
Definition: p4est_io.h:202
@ P4EST_FILE_ERR_NOT_SAME
collective arg not identical
Definition: p4est_io.h:186
@ P4EST_FILE_ERR_READ_ONLY
read only file (system)
Definition: p4est_io.h:194
@ P4EST_FILE_ERR_UNKNOWN
unknown error
Definition: p4est_io.h:204
@ P4EST_FILE_ERR_NO_SPACE
not enough space
Definition: p4est_io.h:192
@ P4EST_FILE_ERR_SUCCESS
file function completed with success
Definition: p4est_io.h:184
@ P4EST_FILE_ERR_ACCESS
permission denied
Definition: p4est_io.h:191
@ P4EST_FILE_ERR_NO_SUCH_FILE
file does not exist
Definition: p4est_io.h:188
p4est_file_context_t * p4est_file_read_block(p4est_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.
p4est_t * p4est_inflate_null(sc_MPI_Comm mpicomm, p4est_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.
p4est_file_context_t * p4est_file_open_read(p4est_t *p4est, const char *filename, char *user_string, int *errcode)
Open a file for reading and read its user string on rank zero.
struct p4est_file_context p4est_file_context_t
p4est data file format All p4est data files have 64 bytes file header section at the beginning of the...
Definition: p4est_io.h:178
p4est_file_context_t * p4est_file_write_block(p4est_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.
p4est_file_context_t * p4est_file_open_create(p4est_t *p4est, const char *filename, const char *user_string, int *errcode)
Begin writing file header and saving data blocks into a parallel file.
p4est_file_context_t * p4est_file_write_field(p4est_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.
p4est_file_context_t * p4est_file_write_p4est(p4est_file_context_t *fc, p4est_t *p4est, const char *quad_string, const char *quad_data_string, int *errcode)
Write a p4est to an opened file.
int p4est_file_close(p4est_file_context_t *fc, int *errcode)
Close a file opened for parallel write/read and free the context.
p4est_file_context_t * p4est_file_read_connectivity(p4est_file_context_t *fc, p4est_connectivity_t **conn, char *conn_string, int *errcode)
Read a connectivity from an opened file.
struct p4est_file_section_metadata p4est_file_section_metadata_t
A data type that encodes the metadata of one data block in a p4est data file.
p4est_t * p4est_inflate(sc_MPI_Comm mpicomm, p4est_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.
p4est_file_context_t * p4est_file_read_field(p4est_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.
int p4est_file_error_string(int errclass, char *string, int *resultlen)
Turn p4est_file errcode into a string.
#define P4EST_FILE_USER_STRING_BYTES
number of user string bytes
Definition: p4est_io.h:57
sc_array_t * p4est_deflate_quadrants(p4est_t *p4est, sc_array_t **data)
Extract processor local quadrants' x y level data.
p4est_file_context_t * p4est_file_read_p4est(p4est_file_context_t *fc, p4est_connectivity_t *conn, size_t data_size, p4est_t **p4est, char *quad_string, char *quad_data_string, int *errcode)
Read a p4est to an opened file using the MPI communicator of fc.
enum p4est_file_error p4est_file_error_t
Error values for p4est_file functions.
#define sc_MPI_ERR_LASTCODE
sc3_MPI_Comm_t sc_MPI_Comm
This structure holds the 2D inter-tree connectivity information.
Definition: p4est_connectivity.h:153
A data type that encodes the metadata of one data block in a p4est data file.
Definition: p4est_io.h:506
char user_string[P4EST_FILE_USER_STRING_BYTES]
user string of the data section
Definition: p4est_io.h:510
char block_type
'H' (header) or 'F' (data file)
Definition: p4est_io.h:507
size_t data_size
data size in bytes per array element ('F') or of the header section ('H')
Definition: p4est_io.h:508
The p4est forest datatype.
Definition: p4est.h:136