Advanced Multi-Physics (AMP)
On-Line Documentation
Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
AMP::IO::SiloIO Class Reference

A class used to abstract away reading/writing files for visualization. More...

#include <SiloWriter.h>

Inheritance diagram for AMP::IO::SiloIO:
Inheritance graph
[legend]

Public Types

enum class  DecompositionType : uint8_t { SINGLE , MULTIPLE }
 
enum class  VectorType : uint8_t { DOUBLE , SINGLE , INT }
 

Public Member Functions

std::string getExtension () const
 Function to return the file extension.
 
WriterProperties getProperties () const override
 Function to get the writer properties.
 
void readFile (const std::string &fname) override
 Function to read a file.
 
void registerMatrix (std::shared_ptr< AMP::LinearAlgebra::Matrix > mat, const std::string &name="")
 Function to register a matrix.
 
void registerMesh (std::shared_ptr< AMP::Mesh::Mesh > mesh, int level=1, const std::string &path=std::string())
 Function to register a mesh.
 
void registerVector (std::shared_ptr< AMP::LinearAlgebra::Vector > vec, const std::string &name="")
 Function to register a vector.
 
virtual void registerVector (std::shared_ptr< AMP::LinearAlgebra::Vector > vec, std::shared_ptr< AMP::Mesh::Mesh > mesh, AMP::Mesh::GeomType type, const std::string &name="", VectorType precision=VectorType::DOUBLE, bool isStatic=false)
 Function to register a vector.
 
virtual void setDecomposition (int decomposition)
 Function to set the file decomposition.
 
 SiloIO ()
 Default constructor.
 
void writeFile (const std::string &fname, size_t iteration, double time=0) override
 Function to write a file.
 
virtual ~SiloIO ()
 Default destructor.
 

Static Public Member Functions

static std::shared_ptr< AMP::IO::WriterbuildWriter (std::shared_ptr< AMP::Database > db)
 Function to build a writer.
 
static std::shared_ptr< AMP::IO::WriterbuildWriter (std::string type, AMP_MPI comm=AMP_COMM_WORLD)
 Function to build a writer.
 

Protected Types

using GeomType = AMP::Mesh::GeomType
 

Protected Member Functions

void createDirectories (const std::string &filename)
 
GlobalID getID (const AMP_MPI &comm) const
 
void registerMesh2 (std::shared_ptr< AMP::Mesh::Mesh > mesh, int level, const std::string &path, std::set< GlobalID > &base_ids)
 
template<class TYPE >
void syncData (std::vector< TYPE > &data, int root) const
 
std::tuple< std::vector< multiMeshData >, std::map< GlobalID, baseMeshData > > syncMultiMeshData (int root=-1) const
 
void syncVectors ()
 

Static Protected Member Functions

static std::vector< AMP::Mesh::MeshIDgetMeshIDs (std::shared_ptr< AMP::Mesh::Mesh > mesh)
 
static void getNodeElemList (std::shared_ptr< const AMP::Mesh::Mesh > mesh, const AMP::Mesh::MeshIterator &elements, AMP::Array< double > *x, AMP::Array< int > &nodelist, std::vector< AMP::Mesh::MeshElementID > &nodelist_ids)
 

Protected Attributes

std::map< GlobalID, baseMeshDatad_baseMeshes
 
AMP_MPI d_comm = AMP_COMM_WORLD
 
DecompositionType d_decomposition = DecompositionType::MULTIPLE
 
std::map< GlobalID, MatrixDatad_matrices
 
std::map< GlobalID, multiMeshDatad_multiMeshes
 
std::map< GlobalID, VectorDatad_vectors
 
std::vector< std::shared_ptr< AMP::LinearAlgebra::Vector > > d_vectorsMesh
 

Private Member Functions

void writeSummary (const std::string &filename, int cycle, double time)
 

Private Attributes

int d_dim
 

Detailed Description

A class used to abstract away reading/writing files for visualization.

This class provides routines for reading, accessing and writing meshes and vectors using silo.

Definition at line 28 of file SiloWriter.h.

Member Typedef Documentation

◆ GeomType

using AMP::IO::Writer::GeomType = AMP::Mesh::GeomType
protectedinherited

Definition at line 219 of file Writer.h.

Member Enumeration Documentation

◆ DecompositionType

enum class AMP::IO::Writer::DecompositionType : uint8_t
stronginherited
Enumerator
SINGLE 
MULTIPLE 

Definition at line 51 of file Writer.h.

◆ VectorType

enum class AMP::IO::Writer::VectorType : uint8_t
stronginherited
Enumerator
DOUBLE 
SINGLE 
INT 

Definition at line 50 of file Writer.h.

Constructor & Destructor Documentation

◆ SiloIO()

AMP::IO::SiloIO::SiloIO ( )

Default constructor.

◆ ~SiloIO()

virtual AMP::IO::SiloIO::~SiloIO ( )
virtual

Default destructor.

Member Function Documentation

◆ buildWriter() [1/2]

static std::shared_ptr< AMP::IO::Writer > AMP::IO::Writer::buildWriter ( std::shared_ptr< AMP::Database db)
staticinherited

Function to build a writer.

This function will build a default writer for use.

Parameters
[in]dbInput database for the writer

◆ buildWriter() [2/2]

static std::shared_ptr< AMP::IO::Writer > AMP::IO::Writer::buildWriter ( std::string  type,
AMP_MPI  comm = AMP_COMM_WORLD 
)
staticinherited

Function to build a writer.

This function will build a default writer for use.

Parameters
[in]typeWriter type: "None" - An empty writer will be created "Silo" - A silo writer will be created if silo is configured, otherwise an empty writer will be created. "Ascii" - A simple ascii writer "HDF5" - A simple HDF5 writer "auto" - Choose the writer based on the comm size and compiled packages
[in]commCommunicator to use

◆ createDirectories()

void AMP::IO::Writer::createDirectories ( const std::string &  filename)
protectedinherited

◆ getExtension()

std::string AMP::IO::Writer::getExtension ( ) const
inherited

Function to return the file extension.

◆ getID()

GlobalID AMP::IO::Writer::getID ( const AMP_MPI comm) const
protectedinherited

◆ getMeshIDs()

static std::vector< AMP::Mesh::MeshID > AMP::IO::Writer::getMeshIDs ( std::shared_ptr< AMP::Mesh::Mesh mesh)
staticprotectedinherited

◆ getNodeElemList()

static void AMP::IO::Writer::getNodeElemList ( std::shared_ptr< const AMP::Mesh::Mesh mesh,
const AMP::Mesh::MeshIterator elements,
AMP::Array< double > *  x,
AMP::Array< int > &  nodelist,
std::vector< AMP::Mesh::MeshElementID > &  nodelist_ids 
)
staticprotectedinherited

◆ getProperties()

WriterProperties AMP::IO::SiloIO::getProperties ( ) const
overridevirtual

Function to get the writer properties.

Implements AMP::IO::Writer.

◆ readFile()

void AMP::IO::SiloIO::readFile ( const std::string &  fname)
overridevirtual

Function to read a file.

Implements AMP::IO::Writer.

◆ registerMatrix()

void AMP::IO::Writer::registerMatrix ( std::shared_ptr< AMP::LinearAlgebra::Matrix mat,
const std::string &  name = "" 
)
inherited

Function to register a matrix.

This function will register a matrix with the writer. This version of registerMatrix only stores the raw data.. It is not associated with a mesh.

Parameters
[in]matThe matrix we want to write
[in]nameOptional name for the vector.

◆ registerMesh()

void AMP::IO::Writer::registerMesh ( std::shared_ptr< AMP::Mesh::Mesh mesh,
int  level = 1,
const std::string &  path = std::string() 
)
inherited

Function to register a mesh.

This function will register a mesh with the writer. Note: if mesh is a MultiMesh, it will register all sub meshes.

Parameters
[in]meshThe mesh to register
[in]levelHow many sub meshes do we want? 0: Only register the local base meshes (advanced users only) 1: Register current mesh only (default) 2: Register all meshes (do not separate for the ranks) 3: Register all mesh pieces including the individual ranks
[in]pathThe directory path for the mesh. Default is an empty string.

◆ registerMesh2()

void AMP::IO::Writer::registerMesh2 ( std::shared_ptr< AMP::Mesh::Mesh mesh,
int  level,
const std::string &  path,
std::set< GlobalID > &  base_ids 
)
protectedinherited

◆ registerVector() [1/2]

void AMP::IO::Writer::registerVector ( std::shared_ptr< AMP::LinearAlgebra::Vector vec,
const std::string &  name = "" 
)
inherited

Function to register a vector.

This function will register a vector with the writer. This version of registerVector only stores the raw data. It is not associated with a mesh.

Parameters
[in]vecThe vector we want to write
[in]nameOptional name for the vector.

◆ registerVector() [2/2]

virtual void AMP::IO::Writer::registerVector ( std::shared_ptr< AMP::LinearAlgebra::Vector vec,
std::shared_ptr< AMP::Mesh::Mesh mesh,
AMP::Mesh::GeomType  type,
const std::string &  name = "",
VectorType  precision = VectorType::DOUBLE,
bool  isStatic = false 
)
virtualinherited

Function to register a vector.

This function will register a vector with the writer and register it with the given mesh. This version of registerVector allows the data to be "stored" on the mesh for visualization or mesh-based operations.

Parameters
[in]vecThe vector we want to write
[in]meshThe mesh we want to write the vector over. Note: any writers require the vector to completely cover the mesh. Note: mesh does not have to be previously registered with registerMesh.
[in]typeThe entity type we want to save (vertex, face, cell, etc.) Note: some writers only supports writing one entity type. If the vector spans multiple entity type (eg cell+vertex) the user should register the vector multiple times (one for each entity type).
[in]nameOptional name for the vector.
[in]precisionDesired precision in output file. Note: not all types are supported by all writers.
[in]isStaticIs the vectors static (constant vs time)

◆ setDecomposition()

virtual void AMP::IO::Writer::setDecomposition ( int  decomposition)
virtualinherited

Function to set the file decomposition.

This function will set the method used for file IO. When writing files, there are different decompositions that affect the performance and usability of the output files. By default, this writer will generate a single file.

Parameters
[in]decompositionDecomposition method to use: 1: This will write all of the data to a single file. Note that this requires a serial write and will have the worst performance 2: Each processor will write a separate file and a separate summary file will be written. Note that this will have better performance at large scale, but will write many files simultaneously.

◆ syncData()

template<class TYPE >
void AMP::IO::Writer::syncData ( std::vector< TYPE > &  data,
int  root 
) const
protectedinherited

◆ syncMultiMeshData()

std::tuple< std::vector< multiMeshData >, std::map< GlobalID, baseMeshData > > AMP::IO::Writer::syncMultiMeshData ( int  root = -1) const
protectedinherited

◆ syncVectors()

void AMP::IO::Writer::syncVectors ( )
protectedinherited

◆ writeFile()

void AMP::IO::SiloIO::writeFile ( const std::string &  fname,
size_t  iteration,
double  time = 0 
)
overridevirtual

Function to write a file.

This function will write a file with all mesh/vector data that was registered. If the filename included a relative or absolute path, the directory structure will be created.

Parameters
fnameThe filename to use
iterationThe iteration number
timeThe current simulation time

Implements AMP::IO::Writer.

◆ writeSummary()

void AMP::IO::SiloIO::writeSummary ( const std::string &  filename,
int  cycle,
double  time 
)
private

Member Data Documentation

◆ d_baseMeshes

std::map<GlobalID, baseMeshData> AMP::IO::Writer::d_baseMeshes
protectedinherited

Definition at line 323 of file Writer.h.

◆ d_comm

AMP_MPI AMP::IO::Writer::d_comm = AMP_COMM_WORLD
protectedinherited

Definition at line 317 of file Writer.h.

◆ d_decomposition

DecompositionType AMP::IO::Writer::d_decomposition = DecompositionType::MULTIPLE
protectedinherited

Definition at line 320 of file Writer.h.

◆ d_dim

int AMP::IO::SiloIO::d_dim
private

Definition at line 65 of file SiloWriter.h.

◆ d_matrices

std::map<GlobalID, MatrixData> AMP::IO::Writer::d_matrices
protectedinherited

Definition at line 330 of file Writer.h.

◆ d_multiMeshes

std::map<GlobalID, multiMeshData> AMP::IO::Writer::d_multiMeshes
protectedinherited

Definition at line 324 of file Writer.h.

◆ d_vectors

std::map<GlobalID, VectorData> AMP::IO::Writer::d_vectors
protectedinherited

Definition at line 327 of file Writer.h.

◆ d_vectorsMesh

std::vector<std::shared_ptr<AMP::LinearAlgebra::Vector> > AMP::IO::Writer::d_vectorsMesh
protectedinherited

Definition at line 333 of file Writer.h.


The documentation for this class was generated from the following file:



Advanced Multi-Physics (AMP)
Oak Ridge National Laboratory
Idaho National Laboratory
Los Alamos National Laboratory
This page automatically produced from the
source code by doxygen
Last updated: Tue Mar 10 2026 13:06:42.
Comments on this page