Vlasiator ebf0dd394 on dev (v5.4.0 + 1054 commits)
Loading...
Searching...
No Matches
iowrite.cpp File Reference
#include <cstddef>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <sstream>
#include <ctime>
#include <cstring>
#include <array>
#include <algorithm>
#include <limits>
#include <initializer_list>
#include "object_wrapper.h"
#include "datareduction/datareductionoperator.h"
#include "iowrite.h"
#include "vdf_compression/compression.h"
#include "math.h"
#include "grid.h"
#include "phiprof.hpp"
#include "parameters.h"
#include "logger.h"
#include "vlasovsolver/vlasovmover.h"
#include "velocity_mesh_parameters.h"
#include "sysboundary/ionosphere.h"
#include "fieldtracing/fieldtracing.h"
Include dependency graph for iowrite.cpp:

Go to the source code of this file.

Functions

bool writeVelocityDistributionData (const uint popID, Writer &vlsvWriter, const dccrg::Dccrg< SpatialCell, dccrg::Cartesian_Geometry > &mpiGrid, const std::vector< CellID > &cells, MPI_Comm comm)
bool writeVelocityDistributionDataAsterix (const uint popID, Writer &vlsvWriter, dccrg::Dccrg< SpatialCell, dccrg::Cartesian_Geometry > &mpiGrid, const std::vector< CellID > &cells, std::vector< std::vector< char > > &mpl_bytes, MPI_Comm comm)
bool updateLocalIds (dccrg::Dccrg< SpatialCell, dccrg::Cartesian_Geometry > &mpiGrid, const std::vector< CellID > &local_cells, MPI_Comm comm)
bool globalSuccess (bool success, const string &errorMessage, MPI_Comm comm)
bool writeVelocityDistributionData (Writer &vlsvWriter, const dccrg::Dccrg< SpatialCell, dccrg::Cartesian_Geometry > &mpiGrid, const vector< CellID > &cells, MPI_Comm comm)
bool writeVelocityDistributionDataAsterix (Writer &vlsvWriter, dccrg::Dccrg< SpatialCell, dccrg::Cartesian_Geometry > &mpiGrid, const vector< CellID > &cells, std::vector< std::vector< char > > &mlp_bytes, MPI_Comm comm)
bool writeVspaceDataCompressionNone (const uint popID, Writer &vlsvWriter, dccrg::Dccrg< SpatialCell, dccrg::Cartesian_Geometry > &mpiGrid, const std::vector< CellID > &cells, std::size_t totalBlocks, MPI_Comm comm)
bool writeDataReducer (const dccrg::Dccrg< SpatialCell, dccrg::Cartesian_Geometry > &mpiGrid, const std::vector< CellID > &cells, const FieldSolverData &fieldSolverData, const bool writeAsFloat, const bool writeFsGrid, DataReducer &dataReducer, cint dataReducerIndex, Writer &vlsvWriter)
bool writeCommonGridData (Writer &vlsvWriter, const dccrg::Dccrg< SpatialCell, dccrg::Cartesian_Geometry > &mpiGrid, const vector< uint64_t > &local_cells, const uint &fileIndex, MPI_Comm comm)
bool writeGhostZoneDomainAndLocalIdNumbers (const dccrg::Dccrg< SpatialCell, dccrg::Cartesian_Geometry > &mpiGrid, Writer &vlsvWriter, const string &meshName, const vector< uint64_t > &ghost_cells)
bool writeDomainSizes (Writer &vlsvWriter, const string &meshName, const unsigned int &numberOfLocalZones, const unsigned int &numberOfGhostZones)
bool writeDomainExtents (Writer &vlsvWriter, const string &meshName, const std::vector< CellID > &local_cells, const dccrg::Dccrg< SpatialCell, dccrg::Cartesian_Geometry > &mpiGrid)
bool writeZoneGlobalIdNumbers (const dccrg::Dccrg< SpatialCell, dccrg::Cartesian_Geometry > &mpiGrid, Writer &vlsvWriter, const string &meshName, const vector< uint64_t > &local_cells, const vector< uint64_t > &ghost_cells)
bool writeBoundingBoxNodeCoordinates (Writer &vlsvWriter, const string &meshName, const int masterRank, MPI_Comm comm)
bool writeMeshBoundingBox (Writer &vlsvWriter, const string &meshName, const int masterRank, MPI_Comm comm)
bool writeVersionInfo (const std::string &version, vlsv::Writer &vlsvWriter, MPI_Comm comm)
bool writeConfigInfo (const std::string &config, vlsv::Writer &vlsvWriter, MPI_Comm comm)
bool writeFsGridMetadata (FieldSolverGrid &fsgrid, fsgrids::consttechnicalspan technical, vlsv::Writer &vlsvWriter, bool writeIDs=false)
bool writeIonosphereGridMetadata (vlsv::Writer &vlsvWriter)
bool writeVelocitySpace (dccrg::Dccrg< SpatialCell, dccrg::Cartesian_Geometry > &mpiGrid, Writer &vlsvWriter, int index, const vector< uint64_t > &cells)
bool checkForSameMembers (const vector< uint64_t > &local_cells, const vector< uint64_t > &ghost_cells)
bool writeGrid (dccrg::Dccrg< SpatialCell, dccrg::Cartesian_Geometry > &mpiGrid, const FieldSolverData &fieldSolverData, fsgrids::consttechnicalspan technical, const std::string &versionInfo, const std::string &configInfo, DataReducer *dataReducer, const uint &outputFileTypeIndex, const int &stripe, const bool writeGhosts, bool compress_vdfs)
 Write out system into a vlsv file.
bool writeRestart (dccrg::Dccrg< SpatialCell, dccrg::Cartesian_Geometry > &mpiGrid, const FieldSolverData &fieldSolverData, fsgrids::consttechnicalspan technical, const std::string &versionInfo, const std::string &configInfo, DataReducer &dataReducer, const string &name, const uint &fileIndex, const bool dateInFileName, const int &stripe, bool compress_vdfs)
 Write out a restart of the simulation into a vlsv file. All block data in remote cells will be reset.
bool writeDiagnostic (const dccrg::Dccrg< SpatialCell, dccrg::Cartesian_Geometry > &mpiGrid, DataReducer &dataReducer)
 Write out simulation diagnostics into diagnostic.txt.

Variables

Logger logFile
Logger diagnostic
char * IObuffer = 0

Function Documentation

◆ checkForSameMembers()

bool checkForSameMembers ( const vector< uint64_t > & local_cells,
const vector< uint64_t > & ghost_cells )

This function makes sure that local cells and ghost cells do not have any identical members (used for error checking)

Parameters
local_cellsList of local cells within this process
ghost_cellsList of ghost cells within this process (cells on the process boundary)

Definition at line 1800 of file iowrite.cpp.

Here is the call graph for this function:

◆ globalSuccess()

bool globalSuccess ( bool success,
const string & errorMessage,
MPI_Comm comm )

Checks the success of write IO

Parameters
successParameter for determining whether the IO has been successful
errorMessageThe message to be shown if global success is false
commThe MPI comm
Returns
Returns true if all of the processes running this function had success value of true, false otherwise

Definition at line 110 of file iowrite.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateLocalIds()

bool updateLocalIds ( dccrg::Dccrg< SpatialCell, dccrg::Cartesian_Geometry > & mpiGrid,
const std::vector< CellID > & local_cells,
MPI_Comm comm )

Updates local ids across MPI to let other processes know in which order this process saves the local cell ids

Parameters
mpiGridVlasiator's MPI grid
local_cellslocal cells on in the current process (no ghost cells included)
commThe MPi comm
Returns
Returns true if operation was successful

Definition at line 79 of file iowrite.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeBoundingBoxNodeCoordinates()

bool writeBoundingBoxNodeCoordinates ( Writer & vlsvWriter,
const string & meshName,
const int masterRank,
MPI_Comm comm )

Writes the node coordinates. This means basically every cell's node (Corner of each cell). Note: The grid is a structured one, so writing the nodes means starting from the corner of the grid and writing coordinates per every cell length until reaching the other corner of the grid

Parameters
vlsvWriterSome vlsv writer with a file open
meshNameName of the mesh (SpatialGrid used in writeGrid and should be the default)
masterRankThe master rank (Vlasiator uses 0)
commThe MPI comm
Returns
Returns true if the operation was successful

Definition at line 1225 of file iowrite.cpp.

Here is the caller graph for this function:

◆ writeCommonGridData()

bool writeCommonGridData ( Writer & vlsvWriter,
const dccrg::Dccrg< SpatialCell, dccrg::Cartesian_Geometry > & mpiGrid,
const vector< uint64_t > & local_cells,
const uint & fileIndex,
MPI_Comm comm )

Writes common grid data such as parameters (time steps, x_min, ..) as well as local cell ids as variables

Parameters
vlsvWriterSome vlsv writer with a file open
mpiGridVlasiator's grid
local_cellsThe local cell ids in this process
fileIndexFile index, file will be called "name.index.vlsv"
commThe MPI comm
Returns
Returns true if operation was successful

Definition at line 926 of file iowrite.cpp.

Here is the caller graph for this function:

◆ writeConfigInfo()

bool writeConfigInfo ( const std::string & config,
vlsv::Writer & vlsvWriter,
MPI_Comm comm )

Definition at line 1378 of file iowrite.cpp.

Here is the caller graph for this function:

◆ writeDataReducer()

bool writeDataReducer ( const dccrg::Dccrg< SpatialCell, dccrg::Cartesian_Geometry > & mpiGrid,
const std::vector< CellID > & cells,
const FieldSolverData & fieldSolverData,
const bool writeAsFloat,
const bool writeFsGrid,
DataReducer & dataReducer,
cint dataReducerIndex,
Writer & vlsvWriter )

Writes info received from data reducer. This function writes out the variable arrays into the file

Parameters
mpiGridThe Vlasiator's grid
cellsList of local cells (no ghost cells included)
writeAsFloatIf true, the data reducer writes variable arrays as float instead of double
dataReducerThe data reducer which contains the necessary functions for calculating variables
dataReducerIndexIndex in the data reducer (determines which variable to read) Note: size of the data reducer can be retrieved with dataReducer.size()
vlsvWriterSome vlsv writer with a file open
Returns
Returns true if operation was successful

Definition at line 790 of file iowrite.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeDiagnostic()

bool writeDiagnostic ( const dccrg::Dccrg< SpatialCell, dccrg::Cartesian_Geometry > & mpiGrid,
DataReducer & dataReducer )

Write out simulation diagnostics into diagnostic.txt.

Parameters
mpiGridThe DCCRG grid with spatial cells
dataReducerContains datareductionoperators that are used to compute diagnostic data

Definition at line 2422 of file iowrite.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeDomainExtents()

bool writeDomainExtents ( Writer & vlsvWriter,
const string & meshName,
const std::vector< CellID > & local_cells,
const dccrg::Dccrg< SpatialCell, dccrg::Cartesian_Geometry > & mpiGrid )

Writes domain extents into the vlsv file, so a box that contains all the cells in this process

Parameters
vlsvWriterSome vlsv writer with a file open
meshNameName of the mesh (SpatialGrid used in the writeGrid function)
local_cellsCells that are local to current process
mpiGridVlaisator's MPI grid
Returns
Returns true if operation was successful

Definition at line 1080 of file iowrite.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeDomainSizes()

bool writeDomainSizes ( Writer & vlsvWriter,
const string & meshName,
const unsigned int & numberOfLocalZones,
const unsigned int & numberOfGhostZones )

Writes domain sizes into the vlsv file, so the number of ghost and local cell ids in this process

Parameters
vlsvWriterSome vlsv writer with a file open
meshNameName of the mesh (SpatialGrid used in the writeGrid function)
numberOfLocalZonesNumber of local cells in this process
numberOfGhostZonesNumber of ghost cells in this process ( Cells on the process boundary )
Returns
Returns true if operation was successful

Definition at line 1050 of file iowrite.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeFsGridMetadata()

bool writeFsGridMetadata ( FieldSolverGrid & fsgrid,
fsgrids::consttechnicalspan technical,
vlsv::Writer & vlsvWriter,
bool writeIDs = false )

Writes the mesh metadata for Visit to read FSGrid variable data.

Parameters
fsgridAn fsgrid instance used to extract metadata info.
vlsvWriterfile object to write into.

Definition at line 1400 of file iowrite.cpp.

Here is the caller graph for this function:

◆ writeGhostZoneDomainAndLocalIdNumbers()

bool writeGhostZoneDomainAndLocalIdNumbers ( const dccrg::Dccrg< SpatialCell, dccrg::Cartesian_Geometry > & mpiGrid,
Writer & vlsvWriter,
const string & meshName,
const vector< uint64_t > & ghost_cells )

Writes ghost cell ids into the file

Parameters
mpiGridVlasiator's grid
vlsvWriterSome vlsv writer with a file open
meshNameName of the mesh (If unsure, put SpatialGrid)
ghost_cellsList of cell ids on the process boundary (Ghost cells)
Returns
Returns true if operation was successful
See also
updateLocalIds

Definition at line 986 of file iowrite.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeGrid()

bool writeGrid ( dccrg::Dccrg< SpatialCell, dccrg::Cartesian_Geometry > & mpiGrid,
const FieldSolverData & fieldSolverData,
fsgrids::consttechnicalspan technical,
const std::string & versionInfo,
const std::string & configInfo,
DataReducer * dataReducer,
const uint & outputFileTypeIndex,
const int & stripe,
const bool writeGhosts,
bool compress_vdfs )

Write out system into a vlsv file.

Parameters
mpiGridThe DCCRG grid with spatial cells
dataReducerContains datareductionoperators that are used to compute data that is added into file
indexIndex to call the correct member of the various parameter vectors
writeGhostsIf true, writes out ghost cells (cells that exist on the process boundary so other process' cells)

Definition at line 1829 of file iowrite.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeIonosphereGridMetadata()

bool writeIonosphereGridMetadata ( vlsv::Writer & vlsvWriter)

Writes the mesh metadata for Visit to read the Ionosphere grid and its variables.

Definition at line 1496 of file iowrite.cpp.

Here is the caller graph for this function:

◆ writeMeshBoundingBox()

bool writeMeshBoundingBox ( Writer & vlsvWriter,
const string & meshName,
const int masterRank,
MPI_Comm comm )

Function for writing the bounding box. This writes only if the process running it is the master rank. This array contains info on the boundaries of the grid so for example the number of cells in x, y, z direction. Note that this is not the physical coordinate bounding box, but the computational domain bounding box, measured in blocks and cells.

Parameters
vlsvWriterSome vlsv writer with a file open
meshNameName of the mesh to write ("SpatialGrid" is used in writeGrid and it should be the default)
masterRankThe master process' id. Vlasiator uses 0 as the master process id, so by default should be 0
commMPI comm
Returns
Returns true if operation was successful

Definition at line 1311 of file iowrite.cpp.

Here is the caller graph for this function:

◆ writeRestart()

bool writeRestart ( dccrg::Dccrg< SpatialCell, dccrg::Cartesian_Geometry > & mpiGrid,
const FieldSolverData & fieldSolverData,
fsgrids::consttechnicalspan technical,
const std::string & versionInfo,
const std::string & configInfo,
DataReducer & dataReducer,
const string & name,
const uint & fileIndex,
const bool dateInFileName,
const int & stripe,
bool compress_vdfs )

Write out a restart of the simulation into a vlsv file. All block data in remote cells will be reset.

Parameters
mpiGridThe DCCRG grid with spatial cells
dataReducerContains datareductionoperators that are used to compute data that is added into file
nameFile name prefix, file will be called "name.index.vlsv"
fileIndexFile index, file will be called "name.index.vlsv"

Definition at line 2048 of file iowrite.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeVelocityDistributionData() [1/2]

bool writeVelocityDistributionData ( const uint popID,
Writer & vlsvWriter,
const dccrg::Dccrg< SpatialCell, dccrg::Cartesian_Geometry > & mpiGrid,
const std::vector< CellID > & cells,
MPI_Comm comm )

Writes the velocity distribution of specified population into the file.

Parameters
vlsvWriterSome vlsv writer with a file open.
mpiGridVlasiator's grid.
cellsVector of local cells within this process (no ghost cells).
commThe MPI communicator.
Returns
Returns true if operation was successful.

Definition at line 161 of file iowrite.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeVelocityDistributionData() [2/2]

bool writeVelocityDistributionData ( Writer & vlsvWriter,
const dccrg::Dccrg< SpatialCell, dccrg::Cartesian_Geometry > & mpiGrid,
const vector< CellID > & cells,
MPI_Comm comm )

Writes the velocity distribution into the file.

Parameters
vlsvWriterSome vlsv writer with a file open.
mpiGridVlasiator's grid.
cellsVector of local cells within this process (no ghost cells).
commThe MPI communicator.
Returns
Returns true if operation was successful.

Definition at line 135 of file iowrite.cpp.

Here is the call graph for this function:

◆ writeVelocityDistributionDataAsterix() [1/2]

bool writeVelocityDistributionDataAsterix ( const uint popID,
Writer & vlsvWriter,
dccrg::Dccrg< SpatialCell, dccrg::Cartesian_Geometry > & mpiGrid,
const std::vector< CellID > & cells,
std::vector< std::vector< char > > & mpl_bytes,
MPI_Comm comm )

Definition at line 634 of file iowrite.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeVelocityDistributionDataAsterix() [2/2]

bool writeVelocityDistributionDataAsterix ( Writer & vlsvWriter,
dccrg::Dccrg< SpatialCell, dccrg::Cartesian_Geometry > & mpiGrid,
const vector< CellID > & cells,
std::vector< std::vector< char > > & mlp_bytes,
MPI_Comm comm )

Definition at line 145 of file iowrite.cpp.

Here is the call graph for this function:

◆ writeVelocitySpace()

bool writeVelocitySpace ( dccrg::Dccrg< SpatialCell, dccrg::Cartesian_Geometry > & mpiGrid,
Writer & vlsvWriter,
int index,
const vector< uint64_t > & cells )

This function writes the velocity space.

Parameters
mpiGridVlasiator's grid.
vlsvWritersome vlsv writer with a file open.
indexIndex to call the correct member of the various parameter vectors.
cellsVector containing local cells of this process.
Returns
Returns true if the operation was successful.
See also
writeVelocityDistributionData.

Definition at line 1603 of file iowrite.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeVersionInfo()

bool writeVersionInfo ( const std::string & version,
vlsv::Writer & vlsvWriter,
MPI_Comm comm )

Definition at line 1355 of file iowrite.cpp.

Here is the caller graph for this function:

◆ writeVspaceDataCompressionNone()

bool writeVspaceDataCompressionNone ( const uint popID,
Writer & vlsvWriter,
dccrg::Dccrg< SpatialCell, dccrg::Cartesian_Geometry > & mpiGrid,
const std::vector< CellID > & cells,
std::size_t totalBlocks,
MPI_Comm comm )

Definition at line 342 of file iowrite.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeZoneGlobalIdNumbers()

bool writeZoneGlobalIdNumbers ( const dccrg::Dccrg< SpatialCell, dccrg::Cartesian_Geometry > & mpiGrid,
Writer & vlsvWriter,
const string & meshName,
const vector< uint64_t > & local_cells,
const vector< uint64_t > & ghost_cells )

Writes the zone global id numbers into the file. The vlsv file needs to know in which order the local cells + ghost cells are written. Local cells are first appended to a vector called global ids, after which the ghost cells are appended. The global ids vector will then be saved into a vlsv file

Parameters
mpiGridVlasiator's MPI grid
vlsvWriterSome vlsv writer with a file open
meshNameName of the mesh ("SpatialGrid" used in the writeGrid function and it should be the default)
local_cellsVector containing the local cells of this process
ghost_cellsVector containing the ghost cells of this process ( The cells on process boundary )
Returns
Returns true if the operation was successful

Definition at line 1141 of file iowrite.cpp.

Here is the caller graph for this function:

Variable Documentation

◆ diagnostic

Logger diagnostic

Definition at line 59 of file iowrite.cpp.

◆ IObuffer

char* IObuffer = 0

Definition at line 61 of file iowrite.cpp.

◆ logFile

Logger logFile
extern

Definition at line 25 of file main.cpp.