Field3D
|
Provides writing of .f3d (internally, hdf5) files. More...
#include <Field3DFileHDF5.h>
Public Types | |
enum | CreateMode { OverwriteMode, FailOnExisting } |
![]() | |
typedef std::map< std::string, std::string > | GroupMembershipMap |
Public Member Functions | |
bool | create (const std::string &filename, CreateMode cm=OverwriteMode) |
Creates a .f3d file on disk. More... | |
template<class Data_T > | |
FileHDF5::Partition::Ptr | createNewPartition (const std::string &partitionName, const std::string &layerName, typename Field< Data_T >::Ptr field) |
create newPartition given the input config More... | |
std::string | incrementPartitionName (std::string &pname) |
increment the partition or make it zero if there's not an integer suffix More... | |
bool | writeGlobalMetadata () |
This routine is call if you want to write out global metadata to disk. More... | |
bool | writeGroupMembership () |
This routine is called just before closing to write out any group membership to disk. More... | |
Constructors & destructor | |
Field3DOutputFileHDF5 () | |
virtual | ~Field3DOutputFileHDF5 () |
Writing layer to disk | |
template<class Data_T > | |
bool | writeScalarLayer (const std::string &layerName, typename Field< Data_T >::Ptr layer) |
Writes a scalar layer to the "Default" partition. More... | |
template<class Data_T > | |
bool | writeVectorLayer (const std::string &layerName, typename Field< FIELD3D_VEC3_T< Data_T > >::Ptr layer) |
Writes a vector layer to the "Default" partition. More... | |
template<class Data_T > | |
bool | writeScalarLayer (const std::string &partitionName, const std::string &layerName, typename Field< Data_T >::Ptr layer) |
Writes a layer to a specific partition. The partition will be created if not specified. More... | |
template<class Data_T > | |
bool | writeScalarLayer (typename Field< Data_T >::Ptr layer) |
Writes a layer to a specific partition. The field name and attribute name are used for partition and layer, respectively. More... | |
template<class Data_T > | |
bool | writeVectorLayer (const std::string &partitionName, const std::string &layerName, typename Field< FIELD3D_VEC3_T< Data_T > >::Ptr layer) |
Writes a layer to a specific partition. The partition will be created if not specified. More... | |
template<class Data_T > | |
bool | writeVectorLayer (typename Field< FIELD3D_VEC3_T< Data_T > >::Ptr layer) |
Writes a layer to a specific partition. The field name and attribute name are used for partition and layer, respectively. More... | |
![]() | |
void | clear () |
Clear the data structures and close the file. More... | |
bool | close () |
Closes the file. No need to call this unless you specifically want to close the file early. It will close once the FileHDF5 object goes out of scope. More... | |
FieldMetadata & | metadata () |
accessor to the m_metadata class More... | |
const FieldMetadata & | metadata () const |
Read only access to the m_metadata class. More... | |
virtual void | metadataHasChanged (const std::string &) |
This function should implemented by concrete classes to get the callback when metadata changes. More... | |
Field3DFileHDF5Base () | |
virtual | ~Field3DFileHDF5Base ()=0 |
Pure virtual destructor to ensure we never instantiate this class. More... | |
void | getPartitionNames (std::vector< std::string > &names) const |
Gets the names of all the partitions in the file. More... | |
void | getScalarLayerNames (std::vector< std::string > &names, const std::string &partitionName) const |
Gets the names of all the scalar layers in a given partition. More... | |
void | getVectorLayerNames (std::vector< std::string > &names, const std::string &partitionName) const |
Gets the names of all the vector layers in a given partition. More... | |
FileHDF5::Partition::Ptr | getPartition (const std::string &partitionName) const |
Returns a pointer to the given partition. More... | |
std::string | intPartitionName (const std::string &partitionName, const std::string &layerName, FieldRes::Ptr field) |
Returns a unique partition name given the requested name. This ensures that partitions with matching mappings get the same name but each subsequent differing mapping gets a new, separate name. More... | |
std::string | removeUniqueId (const std::string &partitionName) const |
Strips any unique identifiers from the partition name and returns the original name. More... | |
void | addGroupMembership (const GroupMembershipMap &groupMembers) |
Add to the group membership. More... | |
void | printHierarchy () const |
Private Member Functions | |
template<class Data_T > | |
bool | writeLayer (const std::string &partitionName, const std::string &layerName, bool isVectorLayer, typename Field< Data_T >::Ptr layer) |
Performs the actual writing of the layer to disk. More... | |
bool | writeMapping (hid_t partitionLocation, FieldMapping::Ptr mapping) |
Writes the mapping to the given hdf5 node. Mappings are assumed to be light-weight enough to be stored as plain attributes under a group. More... | |
bool | writeMetadata (hid_t metadataGroup) |
Writes metadata for this file. More... | |
bool | writeMetadata (hid_t metadataGroup, FieldBase::Ptr layer) |
Writes metadata for this layer. More... | |
Friends | |
class | Field3DInputFile |
class | Field3DOutputFile |
Additional Inherited Members | |
![]() | |
typedef std::map< std::string, int > | PartitionCountMap |
typedef std::vector< FileHDF5::Partition::Ptr > | PartitionList |
![]() | |
void | closeInternal () |
Closes the file if open. More... | |
FileHDF5::Partition::Ptr | partition (const std::string &partitionName) |
Returns a pointer to the given partition. More... | |
FileHDF5::Partition::Ptr | partition (const std::string &partitionName) const |
Returns a pointer to the given partition. More... | |
void | getIntPartitionNames (std::vector< std::string > &names) const |
Gets the names of all the -internal- partitions in the file. More... | |
void | getIntScalarLayerNames (std::vector< std::string > &names, const std::string &intPartitionName) const |
Gets the names of all the scalar layers in a given partition, but assumes that partition name is the -internal- partition name. More... | |
void | getIntVectorLayerNames (std::vector< std::string > &names, const std::string &intPartitionName) const |
Gets the names of all the vector layers in a given partition, but assumes that partition name is the -internal- partition name. More... | |
int | numIntPartitions (const std::string &partitionName) const |
Returns the number of internal partitions for a given partition name. More... | |
std::string | makeIntPartitionName (const std::string &partitionsName, int i) const |
Makes an internal partition name given the external partition name. Effectively just tacks on .X to the name, where X is the number. More... | |
![]() | |
hid_t | m_file |
The hdf5 id of the current file. Will be -1 if no file is open. More... | |
GroupMembershipMap | m_groupMembership |
Keeps track of group membership for each layer of partition name. The key is the "group" and the value is a space separated list of "partitionName.0:Layer1 partitionName.1:Layer0 ..." More... | |
std::vector< LayerInfo > | m_layerInfo |
This stores layer info. More... | |
FieldMetadata | m_metadata |
metadata More... | |
PartitionCountMap | m_partitionCount |
Contains a counter for each partition name. This is used to keep multiple fields with the same name unique in the file. More... | |
std::vector< std::string > | m_partitionNames |
This stores partition names. More... | |
PartitionList | m_partitions |
Vector of partitions. More... | |
Provides writing of .f3d (internally, hdf5) files.
Refer to using_files for examples of how to use this in your code.
Definition at line 764 of file Field3DFileHDF5.h.
Enumerator | |
---|---|
OverwriteMode | |
FailOnExisting |
Definition at line 773 of file Field3DFileHDF5.h.
Field3DOutputFileHDF5::Field3DOutputFileHDF5 | ( | ) |
Definition at line 1223 of file Field3DFileHDF5.cpp.
|
virtual |
Definition at line 1230 of file Field3DFileHDF5.cpp.
|
inline |
Writes a scalar layer to the "Default" partition.
Definition at line 795 of file Field3DFileHDF5.h.
|
inline |
Writes a vector layer to the "Default" partition.
Definition at line 801 of file Field3DFileHDF5.h.
bool Field3DOutputFileHDF5::writeScalarLayer | ( | const std::string & | partitionName, |
const std::string & | layerName, | ||
typename Field< Data_T >::Ptr | layer | ||
) |
Writes a layer to a specific partition. The partition will be created if not specified.
Definition at line 1579 of file Field3DFileHDF5.h.
bool Field3DOutputFileHDF5::writeScalarLayer | ( | typename Field< Data_T >::Ptr | layer | ) |
Writes a layer to a specific partition. The field name and attribute name are used for partition and layer, respectively.
Definition at line 1590 of file Field3DFileHDF5.h.
References FieldBase::attribute, FieldBase::name, Msg::print(), and Msg::SevWarning.
bool Field3DOutputFileHDF5::writeVectorLayer | ( | const std::string & | partitionName, |
const std::string & | layerName, | ||
typename Field< FIELD3D_VEC3_T< Data_T > >::Ptr | layer | ||
) |
Writes a layer to a specific partition. The partition will be created if not specified.
Definition at line 1609 of file Field3DFileHDF5.h.
bool Field3DOutputFileHDF5::writeVectorLayer | ( | typename Field< FIELD3D_VEC3_T< Data_T > >::Ptr | layer | ) |
Writes a layer to a specific partition. The field name and attribute name are used for partition and layer, respectively.
Definition at line 1622 of file Field3DFileHDF5.h.
References Msg::print(), and Msg::SevWarning.
bool Field3DOutputFileHDF5::create | ( | const std::string & | filename, |
CreateMode | cm = OverwriteMode |
||
) |
Creates a .f3d file on disk.
Definition at line 1239 of file Field3DFileHDF5.cpp.
References Field3DFileHDF5Base::closeInternal(), g_hdf5Mutex, Field3DFileHDF5Base::m_file, Msg::print(), Msg::SevWarning, and Hdf5Util::writeAttribute().
bool Field3DOutputFileHDF5::writeGlobalMetadata | ( | ) |
This routine is call if you want to write out global metadata to disk.
Definition at line 1483 of file Field3DFileHDF5.cpp.
References g_hdf5Mutex, Hdf5Util::H5Base::id(), Field3DFileHDF5Base::m_file, Msg::print(), and Msg::SevWarning.
bool Field3DOutputFileHDF5::writeGroupMembership | ( | ) |
This routine is called just before closing to write out any group membership to disk.
Definition at line 1504 of file Field3DFileHDF5.cpp.
References g_hdf5Mutex, Field3DFileHDF5Base::m_file, Field3DFileHDF5Base::m_groupMembership, Msg::print(), Msg::SevWarning, and Hdf5Util::writeAttribute().
std::string Field3DOutputFileHDF5::incrementPartitionName | ( | std::string & | pname | ) |
increment the partition or make it zero if there's not an integer suffix
Definition at line 1546 of file Field3DFileHDF5.cpp.
References Field3DFileHDF5Base::m_partitionCount, Field3DFileHDF5Base::makeIntPartitionName(), and Field3DFileHDF5Base::removeUniqueId().
FileHDF5::Partition::Ptr Field3DOutputFileHDF5::createNewPartition | ( | const std::string & | partitionName, |
const std::string & | layerName, | ||
typename Field< Data_T >::Ptr | field | ||
) |
create newPartition given the input config
Definition at line 1381 of file Field3DFileHDF5.h.
References g_hdf5Mutex, Hdf5Util::H5Base::id(), Field3DFileHDF5Base::m_file, Field3DFileHDF5Base::m_partitions, FieldRes::mapping(), Field3DFileHDF5Base::partition(), Msg::print(), Msg::SevWarning, and Hdf5Util::writeAttribute().
|
private |
Writes the mapping to the given hdf5 node. Mappings are assumed to be light-weight enough to be stored as plain attributes under a group.
Definition at line 1297 of file Field3DFileHDF5.cpp.
References g_hdf5Mutex, Hdf5Util::H5Base::id(), Msg::print(), Msg::SevWarning, and writeFieldMapping().
|
private |
Performs the actual writing of the layer to disk.
Definition at line 1447 of file Field3DFileHDF5.h.
References g_hdf5Mutex, Hdf5Util::H5Base::id(), Field3DFileHDF5Base::intPartitionName(), Field3DFileHDF5Base::m_file, FieldRes::mapping(), FileHDF5::Layer::name, FileHDF5::Layer::parent, Field3DFileHDF5Base::partition(), Msg::print(), Msg::SevWarning, Hdf5Util::writeAttribute(), and writeField().
|
private |
Writes metadata for this layer.
Definition at line 1320 of file Field3DFileHDF5.cpp.
References Msg::print(), Msg::SevWarning, and Hdf5Util::writeAttribute().
|
private |
Writes metadata for this file.
Definition at line 1401 of file Field3DFileHDF5.cpp.
References FieldMetadata::floatMetadata(), FieldMetadata::intMetadata(), Field3DFileHDF5Base::metadata(), Msg::print(), Msg::SevWarning, FieldMetadata::strMetadata(), FieldMetadata::vecFloatMetadata(), FieldMetadata::vecIntMetadata(), and Hdf5Util::writeAttribute().
|
friend |
Definition at line 768 of file Field3DFileHDF5.h.
|
friend |
Definition at line 769 of file Field3DFileHDF5.h.