Commit d81f3380 authored by Michael Bareford's avatar Michael Bareford

Added/improved IO support for SIONlib/HDF5 checkpointing.

parent 2c7ef689
......@@ -202,6 +202,7 @@ ENDIF ()
INCLUDE (ThirdPartyTinyxml)
INCLUDE (ThirdPartyMetis)
INCLUDE (ThirdPartyHDF5)
INCLUDE (ThirdPartySIONLIB)
INCLUDE (ThirdPartyScotch)
INCLUDE (ThirdPartyZlib)
INCLUDE (ThirdPartyBoost)
......
# Module that checks whether SIONLIB is available.
#
# Variables used by this module which you may want to set:
# SIONLIB_ROOTDIR Path list to search for SIONLIB
# SIONLIB_SUFFIX suffix to the library name , e.g. gcc or something
# SIONLIB_INCDIR directory with SIONLIB headers inside
# SIONLIB_LIBDIR directory with SIONLIB libraries inside
#
# Sets the following variables
#
# SIONLIB_INCLUDE_DIR Path to the SIONLIB include dir
# SIONLIB_MPI_LIBRARY
# SIONLIB_GEN_LIBRARY
# SIONLIB_SER_LIBRARY
# SIONLIB_COM_LIBRARY
# SIONLIB_COMLOCKNONE_LIBRARY
# SIONLIB_LIBRARY_DIR
# SIONLIB_FOUND True if SIONLIB was found and usable
# HAVE_SIONLIB True if SIONLIB was found and usable
# SIONLIB_LIBRARIES Names of the SIONLIB libraries
#
set(SIONLIB_ROOTDIR $ENV{SIONLIB_DIR} CACHE PATH "Path list to search for SIONLIB" FORCE)
set(SIONLIB_SUFFIX "_lib64" CACHE STRING "suffix to the library name , e.g. gcc or something")
set(SIONLIB_INCDIR $ENV{SIONLIB_INC} CACHE PATH "directory with SIONLIB headers inside" FORCE)
set(SIONLIB_LIBDIR $ENV{SIONLIB_LIB} CACHE PATH "directory with SIONLIB libraries inside" FORCE)
MESSAGE(STATUS "SIONLIB_ROOTDIR=${SIONLIB_ROOTDIR}")
MESSAGE(STATUS "SIONLIB_INCDIR=${SIONLIB_INCDIR}")
MESSAGE(STATUS "SIONLIB_LIBDIR=${SIONLIB_LIBDIR}")
mark_as_advanced(SIONLIB_ROOTDIR SIONLIB_SUFFIX SIONLIB_INCDIR SIONLIB_LIBDIR)
#look for header files at positions given by the user
find_path(SIONLIB_INCLUDE_DIR
NAMES "sion.h"
PATHS ${SIONLIB_INCDIR}
PATH_SUFFIXES "include"
NO_DEFAULT_PATH
NO_SYSTEM_ENVIRONMENT_PATH
)
MESSAGE(STATUS "SIONLIB_INCLUDE_DIR=${SIONLIB_INCLUDE_DIR}")
# check header usability
include(CMakePushCheckState)
cmake_push_check_state()
set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} ${MPI_COMPILE_FLAGS}")
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${MPI_INCLUDE_PATH} ${SIONLIB_INCLUDE_DIR})
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${MPI_LIBRARIES})
check_include_files(sion.h SIONLIB_HEADER_USABLE)
find_library(SIONLIB_MPI_LIBRARY
NAMES "sionmpi_64"
PATHS ${SIONLIB_LIBDIR}
PATH_SUFFIXES "lib"
NO_DEFAULT_PATH
)
MESSAGE(STATUS "SIONLIB_MPI_LIBRARY=${SIONLIB_MPI_LIBRARY}")
find_library(SIONLIB_GEN_LIBRARY
NAMES "siongen_64"
PATHS ${SIONLIB_LIBDIR}
PATH_SUFFIXES "lib"
NO_DEFAULT_PATH
)
MESSAGE(STATUS "SIONLIB_GEN_LIBRARY=${SIONLIB_GEN_LIBRARY}")
find_library(SIONLIB_SER_LIBRARY
NAMES "sionser_64"
PATHS ${SIONLIB_LIBDIR}
PATH_SUFFIXES "lib"
NO_DEFAULT_PATH
)
MESSAGE(STATUS "SIONLIB_SER_LIBRARY=${SIONLIB_SER_LIBRARY}")
find_library(SIONLIB_COM_LIBRARY
NAMES "sioncom_64"
PATHS ${SIONLIB_LIBDIR}
PATH_SUFFIXES "lib"
NO_DEFAULT_PATH
)
MESSAGE(STATUS "SIONLIB_COM_LIBRARY=${SIONLIB_COM_LIBRARY}")
find_library(SIONLIB_COMLOCKNONE_LIBRARY
NAMES "sioncom_64_lock_none"
PATHS ${SIONLIB_LIBDIR}
PATH_SUFFIXES "lib"
NO_DEFAULT_PATH
)
MESSAGE(STATUS "SIONLIB_COMLOCKNONE_LIBRARY=${SIONLIB_COMLOCKNONE_LIBRARY}")
cmake_pop_check_state()
# behave like a CMake module is supposed to behave
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
"SIONlib"
DEFAULT_MSG
SIONLIB_INCLUDE_DIR
SIONLIB_MPI_LIBRARY
SIONLIB_GEN_LIBRARY
SIONLIB_SER_LIBRARY
SIONLIB_COM_LIBRARY
SIONLIB_COMLOCKNONE_LIBRARY
)
mark_as_advanced(SIONLIB_INCLUDE_DIR SIONLIB_MPI_LIBRARY SIONLIB_GEN_LIBRARY SIONLIB_SER_LIBRARY SIONLIB_COM_LIBRARY SIONLIB_COMLOCKNONE_LIBRARY)
# if both headers and library are found, store results
if(SIONLIB_FOUND)
set(SIONLIB_LIBRARY_DIR ${SIONLIB_LIBDIR})
set(SIONLIB_LIBRARIES ${SIONLIB_MPI_LIBRARY} ${SIONLIB_GEN_LIBRARY} ${SIONLIB_SER_LIBRARY} ${SIONLIB_COM_LIBRARY} ${SIONLIB_COMLOCKNONE_LIBRARY})
# log result
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Determining location of SIONLIB succeded:\n"
"Include directory: ${SIONLIB_INCLUDE_DIR}\n"
"Library directory: ${SIONLIB_LIBRARY_DIR}\n\n")
set(SIONLIB_COMPILE_FLAGS "-I${SIONLIB_INCLUDE_DIR} -D_SION_XT -DSION_MPI"
CACHE STRING "Compile Flags used by Nektar++ when compiling with SIONLIB libraries")
set(SIONLIB_LIBRARIES ${SIONLIB_LIBRARIES}
CACHE STRING "Libraries used by Nektar++ when linking with SIONLIB libraries")
else(SIONLIB_FOUND)
# log errornous result
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Determing location of SIONLIB failed:\n"
"Include directory: ${SIONLIB_INCLUDE_DIR}\n"
"Library directory: ${SIONLIB_LIBRARY_DIR}\n\n")
endif(SIONLIB_FOUND)
MESSAGE(STATUS "SIONLIB_LIBRARIES=${SIONLIB_LIBRARIES}")
#set HAVE_SIONLIB for config.h
set(HAVE_SIONLIB ${SIONLIB_FOUND})
#add all sionlib related flags to ALL_PKG_FLAGS, this must happen regardless of a target using add_sionlib_flags
if(SIONLIB_FOUND)
set_property(GLOBAL APPEND PROPERTY ALL_PKG_FLAGS "${SIONLIB_COMPILE_FLAGS}")
foreach(dir "${SIONLIB_INCLUDE_DIR}")
set_property(GLOBAL APPEND PROPERTY ALL_PKG_FLAGS "-I${dir}")
endforeach()
endif()
\ No newline at end of file
......@@ -8,8 +8,10 @@
#If the user has not set BOOST_ROOT, look in a couple common places first.
MESSAGE(STATUS "Searching for Boost:")
SET(MIN_VER "1.56.0")
SET(NEEDED_BOOST_LIBS thread iostreams filesystem system program_options regex)
SET(MIN_VER "1.60.0")
SET(NEEDED_BOOST_LIBS thread iostreams date_time filesystem system
program_options regex)
SET(Boost_DEBUG 0)
SET(Boost_NO_BOOST_CMAKE ON)
IF( BOOST_ROOT )
SET(Boost_NO_SYSTEM_PATHS ON)
......@@ -164,7 +166,13 @@ IF (THIRDPARTY_BUILD_BOOST)
STRING(TOUPPER ${BOOSTLIB} BOOSTLIB_UPPER)
THIRDPARTY_LIBRARY(Boost_${BOOSTLIB_UPPER}_LIBRARY
SHARED boost_${BOOSTLIB} DESCRIPTION "Boost ${BOOSTLIB} library")
THIRDPARTY_LIBRARY(Boost_${BOOSTLIB_UPPER}_LIBRARY_DEBUG
SHARED boost_${BOOSTLIB} DESCRIPTION "Boost ${BOOSTLIB} library, debug")
THIRDPARTY_LIBRARY(Boost_${BOOSTLIB_UPPER}_LIBRARY_RELEASE
SHARED boost_${BOOSTLIB} DESCRIPTION "Boost ${BOOSTLIB} library, release")
MARK_AS_ADVANCED(Boost_${BOOSTLIB_UPPER}_LIBRARY)
MARK_AS_ADVANCED(Boost_${BOOSTLIB_UPPER}_LIBRARY_DEBUG)
MARK_AS_ADVANCED(Boost_${BOOSTLIB_UPPER}_LIBRARY_RELEASE)
LIST(APPEND Boost_LIBRARIES ${Boost_${BOOSTLIB_UPPER}_LIBRARY})
ENDFOREACH()
......
########################################################################
#
# ThirdParty configuration for Nektar++
#
# SIONlib
#
########################################################################
OPTION(NEKTAR_USE_SIONLIB
"Enable SIONlib I/O support." ON)
IF (NEKTAR_USE_SIONLIB)
INCLUDE (CheckIncludeFiles)
IF (NOT NEKTAR_USE_MPI)
MESSAGE(FATAL_ERROR "SIONlib requires Nektar++ to be configured with NEKTAR_USE_MPI for MPI support.")
ENDIF()
# Try to find SIONlib package.
FIND_PACKAGE(SIONLIB)
IF (NOT SIONLIB_FOUND)
MESSAGE(FATAL_ERROR "SIONlib not detected.")
ENDIF()
SET(BUILD_SIONLIB OFF)
SET(SIONLIB_CONFIG_INCLUDE_DIR ${SIONLIB_INCLUDE_DIR})
MARK_AS_ADVANCED(SIONLIB_LIBRARIES)
MARK_AS_ADVANCED(SIONLIB_INCLUDE_DIR)
INCLUDE_DIRECTORIES(SYSTEM ${SIONLIB_INCLUDE_DIR})
ENDIF()
......@@ -41,6 +41,7 @@
namespace Nektar
{
typedef unsigned char NekByte;
typedef double NekDouble;
typedef std::int32_t NekInt;
......
......@@ -77,7 +77,8 @@ FieldIOFactory &GetFieldIOFactory()
/// Enumerator for auto-detection of FieldIO types.
enum FieldIOType {
eXML,
eHDF5
eHDF5,
eSIONLIB
};
......@@ -97,7 +98,7 @@ const std::string FieldIO::GetFileType(const std::string &filename,
CommSharedPtr comm)
{
FieldIOType ioType = eXML;
int size = comm->GetSize();
int size = comm->GetSize();
bool root = comm->TreatAsRankZero();
if (size == 1 || root)
......@@ -119,22 +120,44 @@ const std::string FieldIO::GetFileType(const std::string &filename,
// Read first 8 bytes. If they correspond with magic bytes below it's an
// HDF5 file. XML is potentially a nightmare with all the different
// encodings so we'll just assume it's OK if it's not HDF.
const unsigned char magic[8] = {
const unsigned char hdf5_magic[8] = {
0x89, 0x48, 0x44, 0x46, 0x0d, 0x0a, 0x1a, 0x0a};
const unsigned char sionlib_magic[8] = {
0x73, 0x69, 0x6f, 0x6e, 0x00, 0x00, 0x00, 0x00};
std::ifstream datafile(datafilename.c_str(), ios_base::binary);
ASSERTL0(datafile.good(), "Unable to open file: " + filename);
ioType = eHDF5;
bool is_hdf5 = true;
bool is_sionlib = true;
for (unsigned i = 0; i < 8 && datafile.good(); ++i)
{
unsigned char byte = datafile.get();
if (byte != magic[i])
if (is_hdf5 && byte != hdf5_magic[i])
{
is_hdf5 = false;
}
if (is_sionlib && byte != sionlib_magic[i])
{
is_sionlib = false;
}
if (!is_hdf5 && !is_sionlib)
{
ioType = eXML;
break;
}
}
ioType = eXML;
if (is_hdf5)
{
ioType = eHDF5;
}
else if (is_sionlib)
{
ioType = eSIONLIB;
}
}
if (size > 1)
......@@ -153,6 +176,10 @@ const std::string FieldIO::GetFileType(const std::string &filename,
{
iofmt = "Hdf5";
}
else if (ioType == eSIONLIB)
{
iofmt = "SIONlib";
}
else
{
// Error
......@@ -187,10 +214,14 @@ FieldIOSharedPtr FieldIO::CreateDefault(
iofmt = session->GetCmdLineArgument<std::string>("io-format");
}
return GetFieldIOFactory().CreateInstance(
FieldIOSharedPtr fieldio = GetFieldIOFactory().CreateInstance(
iofmt,
session->GetComm(),
session->GetSharedFilesystem());
fieldio->Init(session);
return fieldio;
}
/**
......@@ -210,10 +241,15 @@ FieldIOSharedPtr FieldIO::CreateForFile(
{
const std::string iofmt =
FieldIO::GetFileType(filename, session->GetComm());
return GetFieldIOFactory().CreateInstance(
FieldIOSharedPtr fieldio = GetFieldIOFactory().CreateInstance(
iofmt,
session->GetComm(),
session->GetSharedFilesystem());
fieldio->Init(session);
return fieldio;
}
/**
......@@ -226,12 +262,13 @@ FieldIOSharedPtr FieldIO::CreateForFile(
* @param fielddata Binary field data that stores the output corresponding
* to @p fielddefs.
* @param fieldinfomap Associated field metadata map.
* @return The number of bytes written.
*/
void Write(const std::string &outFile,
std::vector<FieldDefinitionsSharedPtr> &fielddefs,
std::vector<std::vector<NekDouble> > &fielddata,
const FieldMetaDataMap &fieldinfomap,
const bool backup)
uint64_t Write(const std::string &outFile,
std::vector<FieldDefinitionsSharedPtr> &fielddefs,
std::vector<std::vector<NekDouble> > &fielddata,
const FieldMetaDataMap &fieldinfomap,
const bool backup)
{
#ifdef NEKTAR_USE_MPI
int size;
......@@ -253,7 +290,7 @@ void Write(const std::string &outFile,
#endif
CommSharedPtr c = GetCommFactory().CreateInstance("Serial", 0, 0);
FieldIOSharedPtr f = GetFieldIOFactory().CreateInstance("Xml", c, false);
f->Write(outFile, fielddefs, fielddata, fieldinfomap, backup);
return f->Write(outFile, fielddefs, fielddata, fieldinfomap, backup);
}
/**
......@@ -270,8 +307,9 @@ void Write(const std::string &outFile,
* @param ElementIDs Element IDs that lie on this processor, which can be
* optionally supplied to avoid reading the entire file on
* each processor.
* @return The number of bytes read.
*/
LIB_UTILITIES_EXPORT void Import(
LIB_UTILITIES_EXPORT uint64_t Import(
const std::string &infilename,
std::vector<FieldDefinitionsSharedPtr> &fielddefs,
std::vector<std::vector<NekDouble> > &fielddata,
......@@ -299,7 +337,7 @@ LIB_UTILITIES_EXPORT void Import(
CommSharedPtr c = GetCommFactory().CreateInstance("Serial", 0, 0);
const std::string iofmt = FieldIO::GetFileType(infilename, c);
FieldIOSharedPtr f = GetFieldIOFactory().CreateInstance(iofmt, c, false);
f->Import(infilename, fielddefs, fielddata, fieldinfomap, ElementIDs);
return f->Import(infilename, fielddefs, fielddata, fieldinfomap, ElementIDs);
}
/**
......@@ -393,7 +431,7 @@ std::string FieldIO::SetUpOutput(const std::string outname, bool perRank, bool b
ASSERTL0(!outname.empty(), "Empty path given to SetUpOutput()");
int nprocs = m_comm->GetSize();
bool root = m_comm->TreatAsRankZero();
bool root = m_comm->TreatAsRankZero();
// Path to output: will be directory if parallel, normal file if
// serial.
......@@ -501,7 +539,7 @@ std::string FieldIO::SetUpOutput(const std::string outname, bool perRank, bool b
if (root)
{
cout << "Writing: " << specPath;
//cout << "Writing: " << specPath << std::endl;
}
// serial processing just add ending.
......
......@@ -53,6 +53,9 @@ namespace LibUtilities
typedef std::map<std::string, std::string> FieldMetaDataMap;
static FieldMetaDataMap NullFieldMetaDataMap;
typedef std::map<std::string, std::string> IOSettings;
typedef std::shared_ptr<IOSettings> IOSettingsSharedPtr;
/**
* @brief Base class for writing hierarchical data (XML or HDF5).
*/
......@@ -179,13 +182,14 @@ struct FieldDefinitions
typedef std::shared_ptr<FieldDefinitions> FieldDefinitionsSharedPtr;
LIB_UTILITIES_EXPORT void Write(
LIB_UTILITIES_EXPORT uint64_t Write(
const std::string &outFile,
std::vector<FieldDefinitionsSharedPtr> &fielddefs,
std::vector<std::vector<NekDouble> > &fielddata,
const FieldMetaDataMap &fieldinfomap = NullFieldMetaDataMap,
const bool backup = false);
LIB_UTILITIES_EXPORT void Import(
LIB_UTILITIES_EXPORT uint64_t Import(
const std::string &infilename,
std::vector<FieldDefinitionsSharedPtr> &fielddefs,
std::vector<std::vector<NekDouble> > &fielddata = NullVectorNekDoubleVector,
......@@ -230,14 +234,20 @@ public:
{
}
LIB_UTILITIES_EXPORT inline void Write(
LIB_UTILITIES_EXPORT inline void Init(
const LibUtilities::SessionReaderSharedPtr session);
LIB_UTILITIES_EXPORT inline void InitFromBenchmarker(
const LibUtilities::IOSettingsSharedPtr iosettings);
LIB_UTILITIES_EXPORT inline uint64_t Write(
const std::string &outFile,
std::vector<FieldDefinitionsSharedPtr> &fielddefs,
std::vector<std::vector<NekDouble> > &fielddata,
const FieldMetaDataMap &fieldinfomap = NullFieldMetaDataMap,
const bool backup = false);
LIB_UTILITIES_EXPORT inline void Import(
LIB_UTILITIES_EXPORT inline uint64_t Import(
const std::string &infilename,
std::vector<FieldDefinitionsSharedPtr> &fielddefs,
std::vector<std::vector<NekDouble> > &fielddata =
......@@ -249,6 +259,12 @@ public:
const std::string &filename,
FieldMetaDataMap &fieldmetadatamap);
LIB_UTILITIES_EXPORT void ImportMultiFldFileIDs(
const std::string &inFile,
std::vector<std::string> &fileNames,
std::vector<std::vector<unsigned int> > &elementList,
FieldMetaDataMap &fieldmetadatamap);
LIB_UTILITIES_EXPORT static const std::string GetFileType(
const std::string &filename, CommSharedPtr comm);
LIB_UTILITIES_EXPORT virtual const std::string &GetClassName() const = 0;
......@@ -282,8 +298,16 @@ protected:
LIB_UTILITIES_EXPORT std::string SetUpOutput(
const std::string outname, bool perRank, bool backup = false);
/// @copydoc FieldIO::Init
LIB_UTILITIES_EXPORT virtual void v_Init(
const LibUtilities::SessionReaderSharedPtr session) {};
/// @copydoc FieldIO::InitFromBenchmarker
LIB_UTILITIES_EXPORT virtual void v_InitFromBenchmarker(
const LibUtilities::IOSettingsSharedPtr iosettings) {};
/// @copydoc FieldIO::Write
LIB_UTILITIES_EXPORT virtual void v_Write(
LIB_UTILITIES_EXPORT virtual uint64_t v_Write(
const std::string &outFile,
std::vector<FieldDefinitionsSharedPtr> &fielddefs,
std::vector<std::vector<NekDouble> > &fielddata,
......@@ -291,7 +315,7 @@ protected:
const bool backup = false) = 0;
/// @copydoc FieldIO::Import
LIB_UTILITIES_EXPORT virtual void v_Import(
LIB_UTILITIES_EXPORT virtual uint64_t v_Import(
const std::string &infilename,
std::vector<FieldDefinitionsSharedPtr> &fielddefs,
std::vector<std::vector<NekDouble> >
......@@ -302,10 +326,37 @@ protected:
/// @copydoc FieldIO::ImportFieldMetaData
LIB_UTILITIES_EXPORT virtual DataSourceSharedPtr v_ImportFieldMetaData(
const std::string &filename, FieldMetaDataMap &fieldmetadatamap) = 0;
LIB_UTILITIES_EXPORT virtual void v_ImportMultiFldFileIDs(
const std::string &inFile,
std::vector<std::string> &fileNames,
std::vector<std::vector<unsigned int> > &elementList,
FieldMetaDataMap &fieldmetadatamap) {};
};
typedef std::shared_ptr<FieldIO> FieldIOSharedPtr;
/**
* @brief Allow the FieldIO class an opportunity for further initialisation.
*
* @param pointer to session configuration
*/
inline void FieldIO::Init(const LibUtilities::SessionReaderSharedPtr session)
{
return v_Init(session);
}
/**
* @brief Allow the FieldIO class an opportunity for further initialisation
* from outside a usual Nektar++ session, e.g., a benchmarker.
*
* @param pointer to stl map containing extra io settings
*/
inline void FieldIO::InitFromBenchmarker(const LibUtilities::IOSettingsSharedPtr iosettings)
{
return v_InitFromBenchmarker(iosettings);
}
/**
* @brief Write out the field information to the file @p outFile.
*
......@@ -314,14 +365,15 @@ typedef std::shared_ptr<FieldIO> FieldIOSharedPtr;
* @param fielddata Binary field data that stores the output corresponding
* to @p fielddefs.
* @param fieldinfomap Associated field metadata map.
* @return The number of bytes written.
*/
inline void FieldIO::Write(const std::string &outFile,
std::vector<FieldDefinitionsSharedPtr> &fielddefs,
std::vector<std::vector<NekDouble> > &fielddata,
const FieldMetaDataMap &fieldinfomap,
const bool backup)
inline uint64_t FieldIO::Write(const std::string &outFile,
std::vector<FieldDefinitionsSharedPtr> &fielddefs,
std::vector<std::vector<NekDouble> > &fielddata,
const FieldMetaDataMap &fieldinfomap,
const bool backup)
{
v_Write(outFile, fielddefs, fielddata, fieldinfomap, backup);
return v_Write(outFile, fielddefs, fielddata, fieldinfomap, backup);
}
/**
......@@ -336,14 +388,15 @@ inline void FieldIO::Write(const std::string &outFile,
* @param ElementIDs Element IDs that lie on this processor, which can be
* optionally supplied to avoid reading the entire file on
* each processor.
* @return The number of bytes read.
*/
inline void FieldIO::Import(const std::string &infilename,
std::vector<FieldDefinitionsSharedPtr> &fielddefs,
std::vector<std::vector<NekDouble> > &fielddata,
FieldMetaDataMap &fieldinfo,
const Array<OneD, int> &ElementIDs)
inline uint64_t FieldIO::Import(const std::string &infilename,
std::vector<FieldDefinitionsSharedPtr> &fielddefs,
std::vector<std::vector<NekDouble> > &fielddata,
FieldMetaDataMap &fieldinfo,
const Array<OneD, int> &ElementIDs)
{
v_Import(infilename, fielddefs, fielddata, fieldinfo, ElementIDs);
return v_Import(infilename, fielddefs, fielddata, fieldinfo, ElementIDs);
}
/**
......@@ -359,6 +412,24 @@ inline DataSourceSharedPtr FieldIO::ImportFieldMetaData(
return v_ImportFieldMetaData(filename, fieldmetadatamap);
}
/**
* @brief Read file containing element ID to partition mapping.
*
* @param inFile Input multi-field file name.
* @param fileNames List of partition filenames.
* @param elementList Vector of element IDs that lie on each process.
* @param fieldmetadatamap Field metadata map that is read from @p inFile.
*/
inline void FieldIO::ImportMultiFldFileIDs(
const std::string &inFile,
std::vector<std::string> &fileNames,
std::vector<std::vector<unsigned int> > &elementList,
FieldMetaDataMap &fieldmetadatamap)
{
v_ImportMultiFldFileIDs(inFile, fileNames, elementList, fieldmetadatamap);
}
}
}
#endif
......@@ -227,55 +227,55 @@ public:
private:
struct OffsetHelper {
OffsetHelper() : data(0), order(0), homy(0), homz(0), homs(0) {}
OffsetHelper() : ids(0), data(0), order(0), homy(0), homz(0), homs(0) {}
OffsetHelper(const OffsetHelper &in) :
data(in.data), order(in.order), homy(in.homy), homz(in.homz),
homs(in.homs)
ids(in.ids), data(in.data), order(in.order),
homy(in.homy), homz(in.homz), homs(in.homs)
{
}
uint64_t data, order, homy, homz, homs;
uint64_t ids, data, order, homy, homz, homs;
};
LIB_UTILITIES_EXPORT virtual void v_Write(
LIB_UTILITIES_EXPORT virtual uint64_t v_Write(
const std::string &outFile,
std::vector<FieldDefinitionsSharedPtr> &fielddefs,
std::vector<std::vector<NekDouble> > &fielddata,
const FieldMetaDataMap &fieldinfomap = NullFieldMetaDataMap,
const bool backup = false);
LIB_UTILITIES_EXPORT virtual void v_Import(
const std::string &infilename,
template <class T>
LIB_UTILITIES_EXPORT uint64_t WriteFieldDataInd(std::size_t nFields,
H5::DataSpaceSharedPtr &fspace, H5::DataSetSharedPtr &dset,
uint64_t data_i, std::vector<std::vector<T> > &data);
template <class T>
LIB_UTILITIES_EXPORT uint64_t WriteFieldData(std::size_t nMinFields, std::size_t nFields,
H5::DataSpaceSharedPtr &fspace, H5::DataSetSharedPtr &dset,
uint64_t data_i, std::vector<std::vector<T> > &data);
LIB_UTILITIES_EXPORT virtual uint64_t v_Import(const std::string &infilename,
std::vector<FieldDefinitionsSharedPtr> &fielddefs,
std::vector<std::vector<NekDouble> > &fielddata =
NullVectorNekDoubleVector,
std::vector<std::vector<NekDouble> > &fielddata = NullVectorNekDoubleVector,
FieldMetaDataMap &fieldinfomap = NullFieldMetaDataMap,
const Array<OneD, int> &ElementIDs = NullInt1DArray);
template <class T>
LIB_UTILITIES_EXPORT uint64_t ImportFieldDataInd(H5::GroupSharedPtr root,
std::string dsetName, std::string dataTag, uint64_t nDataItems,
uint64_t offset, std::vector<T> &data);
LIB_UTILITIES_EXPORT uint64_t ImportFieldDef(H5::GroupSharedPtr root,
std::string group,
FieldDefinitionsSharedPtr def);
LIB_UTILITIES_EXPORT virtual DataSourceSharedPtr v_ImportFieldMetaData(
const std::string &filename, FieldMetaDataMap &fieldmetadatamap);
LIB_UTILITIES_EXPORT void ImportHDF5FieldMetaData(
DataSourceSharedPtr dataSource, FieldMetaDataMap &fieldmetadatamap);
LIB_UTILITIES_EXPORT void ImportFieldDef(
H5::PListSharedPtr readPL,
H5::GroupSharedPtr root,
std::vector<uint64_t> &decomps,
uint64_t decomp,
OffsetHelper offset,
std::string group,
FieldDefinitionsSharedPtr def);
LIB_UTILITIES_EXPORT void ImportFieldData(
H5::PListSharedPtr readPL,
H5::DataSetSharedPtr data_dset,
H5::DataSpaceSharedPtr data_fspace,
uint64_t data_i,
std::vector<uint64_t> &decomps,
uint64_t decomp,
const FieldDefinitionsSharedPtr fielddef,
std::vector<NekDouble> &fielddata);
};
}
}
......
This diff is collapsed.
///////////////////////////////////////////////////////////////////////////////
//
// File FieldIOSIONlib.h
//
// For more information, please see: http://www.nektar.info
//
// The MIT License
//
// Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
// Department of Aeronautics, Imperial College London (UK), and Scientific
// Computing and Imaging Institute, University of Utah (USA).
//
// License for the specific language governing rights and limitations under
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//