Commit 029285df authored by Dave Moxey's avatar Dave Moxey

Address Chris' comments, fix missing virtual destructor

parent 10363372
......@@ -11,7 +11,8 @@ OPTION(NEKTAR_USE_HDF5
IF (NEKTAR_USE_HDF5)
IF (NOT NEKTAR_USE_MPI)
MESSAGE(FATAL_ERROR "HDF5 requires Nektar++ to be configured with NEKTAR_USE_MPI for MPI support.")
MESSAGE(FATAL_ERROR "HDF5 requires Nektar++ to be configured with "
"NEKTAR_USE_MPI for MPI support.")
ENDIF()
# Try to find parallel system HDF5 first.
......@@ -32,7 +33,7 @@ IF (NEKTAR_USE_HDF5)
"NEKTAR_USE_HDF5" OFF)
IF(THIRDPARTY_BUILD_HDF5)
IF (NOT CMAKE_VERSION VERSION_GREATER 3.1.0 AND NOT CMAKE_VERSION VERSION_EQUAL 3.1.0)
IF (CMAKE_VERSION VERSION_LESS 3.1.0)
MESSAGE(FATAL_ERROR "HDF5 compilation requires CMake 3.1.0 or later.")
ENDIF()
......
......@@ -75,7 +75,7 @@ parallel execution\\
GSMPI & & & & \cmark & For
parallel execution\\
HDF5 & & \cmark & \cmark & \cmark & For
large-scale parallel I/O\\
large-scale parallel I/O (requires CMake >3.1)\\
PETSc & & & \cmark & \cmark &
Alternative linear solvers\\
Scotch & & \cmark & \cmark & \cmark &
......
......@@ -399,6 +399,17 @@ struct Field
return exp;
};
/**
* @brief Construct a FieldIO object for the file @p filename.
*
* This routine constructs an appropriate FieldIO object for a filename
* through the LibUtilities::FieldIO::GetFileType function to detect the
* file format. The result is then cached in Field::m_fld to avoid needing
* to repeatedly construct the object.
*
* @param filename Filename to open.
* @return Reader for @p filename.
*/
FIELD_UTILS_EXPORT LibUtilities::FieldIOSharedPtr FieldIOForFile(
string filename)
{
......@@ -714,6 +725,8 @@ struct Field
}
private:
/// Map to store FieldIO instances. Key is the reader type, value is the
/// FieldIO object.
map<string, LibUtilities::FieldIOSharedPtr> m_fld;
};
......
......@@ -74,11 +74,17 @@ std::string fldCmdFormat = SessionReader::RegisterCmdLineArgument(
FieldIOFactory &GetFieldIOFactory()
{
typedef Loki::
SingletonHolder<FieldIOFactory, Loki::CreateUsingNew, Loki::NoDestroy>
Type;
SingletonHolder<FieldIOFactory, Loki::CreateUsingNew, Loki::NoDestroy,
Loki::ClassLevelLockable> Type;
return Type::Instance();
}
/// Enumerator for auto-detection of FieldIO types.
enum FieldIOType {
eXML,
eHDF5
};
/**
* @brief Determine file type of given input file.
*
......@@ -94,8 +100,7 @@ FieldIOFactory &GetFieldIOFactory()
const std::string FieldIO::GetFileType(const std::string &filename,
CommSharedPtr comm)
{
// We'll use 0 => XML and 1 => HDF5.
int code = 0;
FieldIOType ioType = eXML;
int size = comm->GetSize();
int rank = comm->GetRank();
......@@ -123,13 +128,13 @@ const std::string FieldIO::GetFileType(const std::string &filename,
std::ifstream datafile(datafilename.c_str(), ios_base::binary);
code = 1;
ioType = eHDF5;
for (unsigned i = 0; i < 8 && datafile.good(); ++i)
{
unsigned char byte = datafile.get();
if (byte != magic[i])
{
code = 0;
ioType = eXML;
break;
}
}
......@@ -137,15 +142,17 @@ const std::string FieldIO::GetFileType(const std::string &filename,
if (size > 1)
{
int code = (int)ioType;
comm->Bcast(code, 0);
ioType = (FieldIOType)code;
}
std::string iofmt;
if (code == 0)
if (ioType == eXML)
{
iofmt = "Xml";
}
else if (code == 1)
else if (ioType == eHDF5)
{
iofmt = "Hdf5";
}
......
......@@ -233,6 +233,10 @@ public:
LIB_UTILITIES_EXPORT FieldIO(
LibUtilities::CommSharedPtr pComm, bool sharedFilesystem);
LIB_UTILITIES_EXPORT virtual ~FieldIO()
{
}
LIB_UTILITIES_EXPORT inline void Write(
const std::string &outFile,
std::vector<FieldDefinitionsSharedPtr> &fielddefs,
......
......@@ -200,6 +200,10 @@ public:
LibUtilities::CommSharedPtr pComm,
bool sharedFilesystem);
LIB_UTILITIES_EXPORT virtual ~FieldIOHdf5()
{
}
/// Get class name
inline virtual const std::string &GetClassName() const
{
......
......@@ -192,6 +192,10 @@ public:
LibUtilities::CommSharedPtr pComm,
bool sharedFilesystem);
LIB_UTILITIES_EXPORT virtual ~FieldIOXml()
{
}
LIB_UTILITIES_EXPORT void ImportFieldDefs(
DataSourceSharedPtr dataSource,
std::vector<FieldDefinitionsSharedPtr> &fielddefs,
......
......@@ -73,6 +73,10 @@ public:
LIB_UTILITIES_EXPORT PtsIO(LibUtilities::CommSharedPtr pComm,
bool sharedFilesystem = false);
LIB_UTILITIES_EXPORT virtual ~PtsIO()
{
}
LIB_UTILITIES_EXPORT void Import(
const string &inFile,
PtsFieldSharedPtr &ptsField,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment