Commit 7ba7e9f1 authored by Dave Moxey's avatar Dave Moxey

Fix FieldConvert bugs, fix glaring bugs in FieldIO::SetUpOutput and add third-party build support

parent 7cd08f41
MACRO(CONSTRUCT_LIBNAME name)
SET(${name} "${TPDIST}/lib/${CMAKE_SHARED_LIBRARY_PREFIX}${${name}}${CMAKE_SHARED_LIBRARY_SUFFIX}")
ENDMACRO()
MACRO(CHANGE_EXTENSION output var new_ext)
GET_FILENAME_COMPONENT(FileName ${var} NAME_WE)
GET_FILENAME_COMPONENT(Path ${var} PATH)
......
......@@ -10,7 +10,62 @@ OPTION(NEKTAR_USE_HDF5
"Enable HDF5 I/O support." OFF)
IF (NEKTAR_USE_HDF5)
INCLUDE(FindHDF5)
INCLUDE(FindHDF5)
INCLUDE_DIRECTORIES(SYSTEM ${HDF5_INCLUDE_DIRS})
IF (NOT NEKTAR_USE_MPI)
MESSAGE(FATAL_ERROR "HDF5 requires Nektar++ to be compiled using NEKTAR_USE_MPI.")
ENDIF()
IF (HDF5_FOUND)
IF (NOT HDF5_IS_PARALLEL)
MESSAGE(FATAL_ERROR "HDF5 detected but is not compiled in parallel.")
ENDIF()
INCLUDE_DIRECTORIES(SYSTEM ${HDF5_INCLUDE_DIRS})
SET(HDF5_CONFIG_INCLUDE_DIR ${TPINC})
ADD_CUSTOM_TARGET(hdf5-1.8.16 ALL)
ELSE()
IF (NOT CMAKE_VERSION VERSION_GREATER 3.1.0)
MESSAGE(FATAL_ERROR "HDF5 compilation requires CMake 3.1.0 or later.")
ENDIF()
INCLUDE(ExternalProject)
EXTERNALPROJECT_ADD(
hdf5-1.8.16
PREFIX ${TPSRC}
URL http://ae-nektar.ae.ic.ac.uk/~dmoxey/hdf5-1.8.16.tar.bz2
URL_MD5 79c1593573ebddf734eee8d43ecfe483
STAMP_DIR ${TPBUILD}/stamp
DOWNLOAD_DIR ${TPSRC}
SOURCE_DIR ${TPSRC}/hdf5-1.8.16
BINARY_DIR ${TPBUILD}/hdf5-1.8.16
TMP_DIR ${TPBUILD}/hdf5-1.8.16-tmp
INSTALL_DIR ${TPDIST}
CONFIGURE_COMMAND ${CMAKE_COMMAND}
-G ${CMAKE_GENERATOR}
-DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER}
-DCMAKE_INSTALL_PREFIX:PATH=${TPDIST}
-DHDF5_ENABLE_PARALLEL=ON
-DHDF5_BUILD_CPP_LIB=OFF
-DBUILD_TESTING=OFF
-DHDF5_BUILD_TOOLS=OFF
${TPSRC}/hdf5-1.8.16
)
SET(HDF5_LIBRARIES hdf5-shared CACHE FILEPATH
"HDF5 libraries" FORCE)
SET(HDF5_INCLUDE_DIR ${TPDIST}/include CACHE FILEPATH
"HDF5 include directory" FORCE)
CONSTRUCT_LIBNAME(HDF5_LIBRARIES)
MARK_AS_ADVANCED(HDF5_LIBRARIES)
MARK_AS_ADVANCED(HDF5_INCLUDE_DIR)
LINK_DIRECTORIES(${TPDIST}/lib)
MESSAGE(STATUS "Build HDF5: ${HDF5_LIBRARIES}")
SET(HDF5_CONFIG_INCLUDE_DIR ${TPINC})
ENDIF()
ENDIF (NEKTAR_USE_HDF5)
\ No newline at end of file
......@@ -418,10 +418,14 @@ std::string FieldIO::SetUpOutput(const std::string outname, bool perRank)
m_comm->Block();
}
// serial processing just add ending.
if (nprocs == 1 || rank == 0)
if (rank == 0)
{
cout << "Writing: " << specPath << endl;
}
// serial processing just add ending.
if (nprocs == 1)
{
return LibUtilities::PortablePath(specPath);
}
......
......@@ -56,6 +56,7 @@ public:
/// Constructor based on filename.
XmlDataSource(const std::string &fn)
{
m_doc = new TiXmlDocument(fn);
bool loadOkay = m_doc->LoadFile();
std::stringstream errstr;
errstr << "Unable to load file: " << fn << std::endl;
......
......@@ -479,7 +479,9 @@ ENDIF( NEKTAR_USE_PETSC )
# HDF5
IF( NEKTAR_USE_HDF5 )
MESSAGE(STATUS "LOL: ${HDF5_LIBRARIES}")
TARGET_LINK_LIBRARIES(LibUtilities LINK_PRIVATE ${HDF5_LIBRARIES})
ADD_DEPENDENCIES(LibUtilities hdf5-1.8.16)
ENDIF( NEKTAR_USE_HDF5 )
INSTALL(FILES ${ExpressionTemplates} DESTINATION ${NEKTAR_INCLUDE_DIR}/ExpressionTemplates COMPONENT dev)
......
......@@ -110,7 +110,6 @@ struct Field {
MultiRegions::AssemblyMapCGSharedPtr m_locToGlobalMap;
LibUtilities::FieldMetaDataMap m_fieldMetaDataMap;
map<string, LibUtilities::FieldIOSharedPtr> m_fld;
MultiRegions::ExpListSharedPtr SetUpFirstExpList(int NumHomogeneousDir,
bool fldfilegiven = false)
......@@ -399,14 +398,24 @@ struct Field {
return exp;
};
FieldIOSharedPtr FieldIOForFile(string filename)
LibUtilities::FieldIOSharedPtr FieldIOForFile(string filename)
{
string fmt = FieldIO::GetFileType(filename, session->GetComm());
LibUtilities::CommSharedPtr c = m_session ? m_session->GetComm() :
LibUtilities::GetCommFactory().CreateInstance("Serial", 0, 0);
string fmt = LibUtilities::FieldIO::GetFileType(filename, c);
map<string, LibUtilities::FieldIOSharedPtr>::iterator it =
m_fld.find(fmt);
if (it == m_fld.end())
{
LibUtilities::FieldIOSharedPtr fld =
LibUtilities::GetFieldIOFactory().CreateInstance(fmt, c, true);
m_fld[fmt] = fld;
return fld;
}
else
{
return it->second;
}
}
......@@ -700,6 +709,8 @@ struct Field {
return tmp;
}
private:
map<string, LibUtilities::FieldIOSharedPtr> m_fld;
};
typedef boost::shared_ptr<Field> FieldSharedPtr;
......
......@@ -125,24 +125,6 @@ void InputFld::Process(po::variables_map &vm)
ASSERTL0(false,"no input file found");
}
const std::string& filename = m_f->m_inputfiles[fldending][0];
if(m_f->m_session)
{
m_f->m_fld = LibUtilities::MakeFieldIOForFile(
m_f->m_session, filename);
}
else // serial communicator
{
LibUtilities::CommSharedPtr c =
LibUtilities::GetCommFactory().CreateInstance("Serial", 0, 0);
const std::string iofmt =
LibUtilities::FieldIO::GetFileType(
filename, m_f->m_session->GetComm());
m_f->m_fld = LibUtilities::GetFieldIOFactory().CreateInstance(
iofmt, c, false);
}
if(m_f->m_graph) // all for restricted expansion defintion when loading field
{
// currently load all field (possibly could read data from expansion list
......@@ -173,18 +155,20 @@ void InputFld::Process(po::variables_map &vm)
m_f->m_fielddef.clear();
m_f->m_data.clear();
m_f->m_fld->Import(m_f->m_inputfiles[fldending][0],
m_f->m_fielddef,
m_f->m_data,
m_f->m_fieldMetaDataMap,
ElementGIDs);
m_f->FieldIOForFile(m_f->m_inputfiles[fldending][0])->Import(
m_f->m_inputfiles[fldending][0],
m_f->m_fielddef,
m_f->m_data,
m_f->m_fieldMetaDataMap,
ElementGIDs);
}
else // load all data.
{
m_f->m_fld->Import(m_f->m_inputfiles[fldending][0],
m_f->m_fielddef,
m_f->m_data,
m_f->m_fieldMetaDataMap);
m_f->FieldIOForFile(m_f->m_inputfiles[fldending][0])->Import(
m_f->m_inputfiles[fldending][0],
m_f->m_fielddef,
m_f->m_data,
m_f->m_fieldMetaDataMap);
}
......
......@@ -324,18 +324,16 @@ void InputXml::Process(po::variables_map &vm)
Array<OneD,int> ElementGIDs(expansions.size());
SpatialDomains::ExpansionMap::const_iterator expIt;
int i = 0;
int i = 0;
for (expIt = expansions.begin(); expIt != expansions.end(); ++expIt)
{
ElementGIDs[i++] = expIt->second->m_geomShPtr->GetGlobalID();
}
m_f->m_fld = LibUtilities::MakeFieldIOForFile(
m_f->m_session, m_f->m_inputfiles[fldending][0]);
m_f->m_fld->Import(m_f->m_inputfiles[fldending][0], m_f->m_fielddef,
LibUtilities::NullVectorNekDoubleVector,
LibUtilities::NullFieldMetaDataMap,
ElementGIDs);
m_f->FieldIOForFile(m_f->m_inputfiles[fldending][0])->Import(
m_f->m_inputfiles[fldending][0], m_f->m_fielddef,
LibUtilities::NullVectorNekDoubleVector,
LibUtilities::NullFieldMetaDataMap, ElementGIDs);
NumHomogeneousDir = m_f->m_fielddef[0]->m_numHomogeneousDir;
//----------------------------------------------
......
......@@ -56,6 +56,8 @@ ModuleKey OutputFld::m_className[2] = {
OutputFld::OutputFld(FieldSharedPtr f) : OutputModule(f)
{
m_config["format"] = ConfigOption(
false, "Xml", "Output format of field file");
}
OutputFld::~OutputFld()
......@@ -73,6 +75,13 @@ void OutputFld::Process(po::variables_map &vm)
timer.Start();
}
// Set up communicator and FieldIO object.
LibUtilities::CommSharedPtr c = m_f->m_session ? m_f->m_session->GetComm() :
LibUtilities::GetCommFactory().CreateInstance("Serial", 0, 0);
LibUtilities::FieldIOSharedPtr fld =
LibUtilities::GetFieldIOFactory().CreateInstance(
m_config["format"].as<string>(), c, true);
if (m_f->m_writeBndFld)
{
Timer timer;
......@@ -96,7 +105,8 @@ void OutputFld::Process(po::variables_map &vm)
}
// Extract data to boundaryconditions
if (m_f->m_fldToBnd) {
if (m_f->m_fldToBnd)
{
for (int i = 0; i < m_f->m_exp.size(); ++i)
{
m_f->m_exp[i]->FillBndCondFromField();
......@@ -306,9 +316,7 @@ void OutputFld::Process(po::variables_map &vm)
}
}
m_f->m_fld->Write(outname, FieldDef, FieldData,
m_f->m_fieldMetaDataMap);
fld->Write(outname, FieldDef, FieldData, m_f->m_fieldMetaDataMap);
}
}
else
......@@ -350,8 +358,8 @@ void OutputFld::Process(po::variables_map &vm)
if(writefld)
{
m_f->m_fld->Write(filename, m_f->m_fielddef, m_f->m_data,
m_f->m_fieldMetaDataMap);
fld->Write(filename, m_f->m_fielddef, m_f->m_data,
m_f->m_fieldMetaDataMap);
}
// output error for regression checking.
......
......@@ -91,18 +91,15 @@ void ProcessAddFld::Process(po::variables_map &vm)
{
ElementGIDs[i] = m_f->m_exp[0]->GetExp(i)->GetGeom()->GetGlobalID();
}
m_f->m_fld->Import(fromfld,
fromField->m_fielddef,
fromField->m_data,
LibUtilities::NullFieldMetaDataMap,
ElementGIDs);
m_f->FieldIOForFile(fromfld)->Import(
fromfld, fromField->m_fielddef, fromField->m_data,
LibUtilities::NullFieldMetaDataMap, ElementGIDs);
}
else
{
m_f->m_fld->Import(fromfld,
fromField->m_fielddef,
fromField->m_data,
LibUtilities::NullFieldMetaDataMap);
m_f->FieldIOForFile(fromfld)->Import(
fromfld, fromField->m_fielddef, fromField->m_data,
LibUtilities::NullFieldMetaDataMap);
}
bool samelength = true;
......
......@@ -156,11 +156,12 @@ void ProcessInnerProduct::Process(po::variables_map &vm)
for (int f = 0; f < fromfiles.size(); ++f)
{
m_f->m_fld->Import(fromfiles[f],
fromField->m_fielddef,
fromField->m_data,
LibUtilities::NullFieldMetaDataMap,
ElementGIDs);
m_f->FieldIOForFile(fromfiles[f])->Import(
fromfiles[f],
fromField->m_fielddef,
fromField->m_data,
LibUtilities::NullFieldMetaDataMap,
ElementGIDs);
totiprod = IProduct(processFields, fromField, SaveFld);
......@@ -180,11 +181,13 @@ void ProcessInnerProduct::Process(po::variables_map &vm)
for (int i = 0; i < fromfiles.size(); ++i)
{
allFromField[i] = boost::shared_ptr<Field>(new Field());
m_f->m_fld->Import(fromfiles[i],
allFromField[i]->m_fielddef,
allFromField[i]->m_data,
LibUtilities::NullFieldMetaDataMap,
ElementGIDs);
m_f->FieldIOForFile(fromfiles[i])->Import(
fromfiles[i],
allFromField[i]->m_fielddef,
allFromField[i]->m_data,
LibUtilities::NullFieldMetaDataMap,
ElementGIDs);
}
for (int g = 0; g < fromfiles.size(); ++g)
......
......@@ -158,10 +158,9 @@ void ProcessInterpField::Process(po::variables_map &vm)
}
string fromfld = m_config["fromfld"].as<string>();
m_f->m_fld->Import(fromfld,m_fromField->m_fielddef,
m_fromField->m_data,
LibUtilities::NullFieldMetaDataMap,
ElementGIDs);
m_f->FieldIOForFile(fromfld)->Import(
fromfld, m_fromField->m_fielddef, m_fromField->m_data,
LibUtilities::NullFieldMetaDataMap, ElementGIDs);
int NumHomogeneousDir = m_fromField->m_fielddef[0]->m_numHomogeneousDir;
......
......@@ -457,12 +457,9 @@ void ProcessInterpPoints::Process(po::variables_map &vm)
"wihtin the domain given by the xml files?");
string fromfld = m_config["fromfld"].as<string>();
fromField->m_fld = LibUtilities::MakeFieldIOForFile(
fromField->m_session, fromfld);
fromField->m_fld->Import(fromfld,fromField->m_fielddef,
fromField->m_data,
LibUtilities::NullFieldMetaDataMap,
ElementGIDs);
m_f->FieldIOForFile(fromfld)->Import(
fromfld, fromField->m_fielddef, fromField->m_data,
LibUtilities::NullFieldMetaDataMap, ElementGIDs);
int NumHomogeneousDir = fromField->m_fielddef[0]->m_numHomogeneousDir;
......
......@@ -285,9 +285,7 @@ GlobalMapping::MappingSharedPtr ProcessMapping::GetMapping(FieldSharedPtr f)
std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef;
std::vector<std::vector<NekDouble> > FieldData;
f->m_fld->Import(fileName,
FieldDef,
FieldData);
f->FieldIOForFile(fileName)->Import(fileName, FieldDef, FieldData);
for (int j = 0; j < spacedim; ++j)
{
......
......@@ -109,8 +109,6 @@ void ProcessMultiShear::Process(po::variables_map &vm)
m_fromField[i] = boost::shared_ptr<Field>(new Field());
m_fromField[i]->m_session = m_f->m_session;
m_fromField[i]->m_graph = m_f->m_graph;
m_fromField[i]->m_fld = LibUtilities::MakeFieldIOForFile(
m_f->m_session, infiles[i]);
}
//Import all fld files.
......@@ -124,16 +122,15 @@ void ProcessMultiShear::Process(po::variables_map &vm)
{
ElementGIDs[j] = m_f->m_exp[0]->GetExp(j)->GetGeom()->GetGlobalID();
}
m_fromField[i]->m_fld->Import(infiles[i],m_fromField[i]->m_fielddef,
m_fromField[i]->m_data,
LibUtilities::NullFieldMetaDataMap,
ElementGIDs);
m_f->FieldIOForFile(infiles[i])->Import(
infiles[i], m_fromField[i]->m_fielddef, m_fromField[i]->m_data,
LibUtilities::NullFieldMetaDataMap, ElementGIDs);
}
else
{
m_fromField[i]->m_fld->Import(infiles[i],m_fromField[i]->m_fielddef,
m_fromField[i]->m_data,
LibUtilities::NullFieldMetaDataMap);
m_f->FieldIOForFile(infiles[i])->Import(
infiles[i], m_fromField[i]->m_fielddef, m_fromField[i]->m_data,
LibUtilities::NullFieldMetaDataMap);
}
nfields = m_fromField[i]->m_fielddef[0]->m_fields.size();
......
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