PICurv 0.1.0
A Parallel Particle-In-Cell Solver for Curvilinear LES
|
#include "vtk_io.h"
Go to the source code of this file.
Functions | |
static PetscErrorCode | WriteVTKAppendedBlock (FILE *fp, const void *data, PetscInt num_elements, size_t element_size) |
static PetscErrorCode | WriteVTSXMLHeader (FILE *fp, const VTKMetaData *meta, PetscInt *boffset) |
static PetscErrorCode | WriteVTPXMLHeader (FILE *fp, const VTKMetaData *meta, PetscInt *boffset) |
static PetscErrorCode | WriteVTKFileHeader (FILE *fp, const VTKMetaData *meta, PetscInt *boffset) |
static PetscErrorCode | WriteVTKFileFooter (FILE *fp, const VTKMetaData *meta) |
PetscErrorCode | CreateVTKFileFromMetadata (const char *filename, const VTKMetaData *meta, MPI_Comm comm) |
Creates and writes a VTK file (either .vts or .vtp) from a populated metadata struct. | |
PetscErrorCode | PrepareOutputCoordinates (UserCtx *user, PetscScalar **out_coords, PetscInt *out_nx, PetscInt *out_ny, PetscInt *out_nz, PetscInt *out_npoints) |
Creates a C array of coordinates corresponding to a subsampled (legacy-style) grid. | |
PetscErrorCode | PrepareOutputEulerianFieldData (UserCtx *user, Vec field_vec, PetscInt num_components, PetscScalar **out_data) |
Creates a C array of field data corresponding to a subsampled (legacy-style) grid. | |
PetscErrorCode | PrepareOutputParticleData (UserCtx *user, PostProcessParams *pps, VTKMetaData *meta, PetscInt *p_n_total) |
Gathers, merges, subsamples, and prepares particle data for VTK output. | |
|
static |
Definition at line 17 of file vtk_io.c.
|
static |
Definition at line 24 of file vtk_io.c.
|
static |
Definition at line 60 of file vtk_io.c.
|
static |
Definition at line 106 of file vtk_io.c.
|
static |
PetscErrorCode CreateVTKFileFromMetadata | ( | const char * | filename, |
const VTKMetaData * | meta, | ||
MPI_Comm | comm | ||
) |
Creates and writes a VTK file (either .vts or .vtp) from a populated metadata struct.
[in] | filename | The output file name. |
[in] | meta | Pointer to a VTKMetaData structure containing all necessary fields. |
[in] | comm | The MPI communicator. |
Definition at line 128 of file vtk_io.c.
PetscErrorCode PrepareOutputCoordinates | ( | UserCtx * | user, |
PetscScalar ** | out_coords, | ||
PetscInt * | out_nx, | ||
PetscInt * | out_ny, | ||
PetscInt * | out_nz, | ||
PetscInt * | out_npoints | ||
) |
Creates a C array of coordinates corresponding to a subsampled (legacy-style) grid.
This function gathers the full, distributed grid coordinates onto rank 0. On rank 0, it then allocates a new, smaller C array and copies only the coordinates for the nodes within the range [0..IM-2, 0..JM-2, 0..KM-2]. This produces a contiguous array of points for a grid of size (IM-1)x(JM-1)x(KM-1), matching the legacy output. The output arrays are only allocated and valid on rank 0.
[in] | user | The UserCtx containing the grid information (DM, IM/JM/KM). |
[out] | out_coords | On rank 0, a pointer to the newly allocated C array for coordinate data. NULL on other ranks. |
[out] | out_nx | The number of points in the x-dimension for the new grid (IM-1). |
[out] | out_ny | The number of points in the y-dimension for the new grid (JM-1). |
[out] | out_nz | The number of points in the z-dimension for the new grid (KM-1). |
[out] | out_npoints | The total number of points in the new grid. |
Definition at line 223 of file vtk_io.c.
PetscErrorCode PrepareOutputEulerianFieldData | ( | UserCtx * | user, |
Vec | field_vec, | ||
PetscInt | num_components, | ||
PetscScalar ** | out_data | ||
) |
Creates a C array of field data corresponding to a subsampled (legacy-style) grid.
This function gathers a full, distributed PETSc vector to rank 0. On rank 0, it then allocates a new, smaller C array and copies only the data components for nodes within the range [0..IM-2, 0..JM-2, 0..KM-2]. This produces a contiguous data array that perfectly matches the point ordering of the subsampled coordinates. The output array is only allocated and valid on rank 0.
[in] | user | The UserCtx for grid information. |
[in] | field_vec | The full-sized PETSc vector containing the field data (e.g., user->P_nodal). |
[in] | num_components | The number of components for this field (1 for scalar, 3 for vector). |
[out] | out_data | On rank 0, a pointer to the newly allocated C array for the field data. NULL on other ranks. |
Definition at line 287 of file vtk_io.c.
PetscErrorCode PrepareOutputParticleData | ( | UserCtx * | user, |
PostProcessParams * | pps, | ||
VTKMetaData * | meta, | ||
PetscInt * | p_n_total | ||
) |
Gathers, merges, subsamples, and prepares particle data for VTK output.
Gathers, subsamples, and prepares all particle data for VTK output.
This function orchestrates the preparation of particle data for writing. It is a COLLECTIVE operation that all MPI ranks must enter, though the primary work of data aggregation and preparation is performed on rank 0.
The function follows a "merge-and-prepare" strategy:
user->swarm
as the read-only source of primary data (e.g., positions, velocity) that was loaded from disk.user->pp_swarm
as the source of derived data (e.g., specific_ke) that was computed by the post-processing pipeline.pps->particle_fields
list. For each requested field, it determines whether to source it from user->swarm
or user->pp_swarm
. c. It gathers the full data for each requested field from its appropriate source into a generic buffer. d. It performs strided subsampling. During this step, any integer fields (like pid, CellID) are CAST to PetscScalar, so that all output arrays are of the same floating-point type. e. It populates the VTKMetaData struct with the final, subsampled, scalar-only data arrays, making it ready for the file writer.[in] | user | The UserCtx, containing both user->swarm and user->pp_swarm. |
[in] | pps | The PostProcessParams struct for configuration (field list, frequency). |
[out] | meta | A pointer to the VTKMetaData struct to be populated (on rank 0). |
[out] | p_n_total | A pointer to store the total number of particles before subsampling (on rank 0). |
Definition at line 421 of file vtk_io.c.