Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/cmake/Setup3rdParty.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,19 @@ if(HDF5_DIR)
endif()
endif()

################################
# Setup CGNS if available
################################
# Search for CGNS.
if(CGNS_DIR)
include(cmake/thirdparty/SetupCGNS.cmake)
include_directories(${CGNS_INCLUDE_DIRS})
# if we don't find CGNS, throw a fatal error
if(NOT CGNS_FOUND)
message(FATAL_ERROR "CGNS_DIR is set, but CGNS wasn't found.")
endif()
endif()

################################
# Setup Silo if available
################################
Expand Down
56 changes: 56 additions & 0 deletions src/cmake/thirdparty/SetupCGNS.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@

# first Check for CGNS_DIR
if(NOT CGNS_DIR)
MESSAGE(FATAL_ERROR "CGNS support needs explicit CGNS_DIR")
endif()

set(CGNS_ROOT ${CGNS_DIR})


find_package(CGNS REQUIRED)

if(TARGET CGNS::cgns_shared)
get_target_property(_inc CGNS::cgns_shared INTERFACE_INCLUDE_DIRECTORIES)
get_target_property(_lib CGNS::cgns_shared IMPORTED_LOCATION_RELEASE)
get_target_property(_link CGNS::cgns_shared INTERFACE_LINK_LIBRARIES)
message(STATUS "CGNS imported target INTERFACE_INCLUDE_DIRECTORIES: ${_inc}")
message(STATUS " INTERFACE_LINK_LIBRARIES: ${_link}")
if(_lib)
get_filename_component(_libdir "${_lib}" DIRECTORY)
message(STATUS "CGNS imported library location: ${_lib}")
message(STATUS "Guessed CGNS lib dir: ${_libdir}")
endif()
blt_register_library(NAME cgns
DEFINES "-DOMPI_SKIP_MPICXX"
INCLUDES ${_inc}
LIBRARIES ${_link} ${_lib}
)
endif()

# Abort CMake here for debugging
# message(FATAL_ERROR "Aborting configuration: reached intentional stop in SetupCGNS.cmake")


# if(TARGET CGNS::cgns_shared)



# message(STATUS "Found imported target CGNS::cgns_shared")
# get_target_property(_inc CGNS::cgns_shared INTERFACE_INCLUDE_DIRECTORIES)
# message(STATUS " INTERFACE_INCLUDE_DIRECTORIES: ${_inc}")
# get_target_property(_link CGNS::cgns_shared INTERFACE_LINK_LIBRARIES)
# message(STATUS " INTERFACE_LINK_LIBRARIES: ${_link}")

# message(STATUS "CGNS_ROOT/include: ${CGNS_ROOT}/include")
# message(STATUS "CGNS_ROOT/lib: ${CGNS_ROOT}/lib")

# blt_register_library(NAME cgns
# INCLUDES ${_inc}
# LIBRARIES ${_link}
# )

# endif()

# message(STATUS "CGNS_INCLUDE_DIRS: ${_inc}")
# message(STATUS "CGNS_LIBRARIES: ${CGNS_LIBRARIES}")

3 changes: 3 additions & 0 deletions src/docs/sphinx/building.rst
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ CMake Options for Third-party Library Paths
* - ``ZLIB_DIR``
- Path to a Zlib install (optional). (Needed for HDF5 support)

* - ``CGNS_DIR``
- Path to a CGNS install (optional). Controls if CGNS I/O support is built into *conduit_relay*.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also requires HDF5 support.


* - ``SILO_DIR``
- Path to a Silo install (optional). Controls if Silo I/O support is built into *conduit_relay*. Requires HDF5.

Expand Down
29 changes: 29 additions & 0 deletions src/libs/relay/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@ if(HDF5_FOUND)
SET(CONDUIT_RELAY_IO_HDF5_ENABLED TRUE)
endif()

if(CGNS_FOUND)
SET(CONDUIT_RELAY_IO_CGNS_ENABLED TRUE)
MESSAGE("CGNS is found. CGNS relay I/O support enabled.")
else()
MESSAGE("CGNS not found. CGNS relay I/O support disabled.")
endif()

if(CGNS_FOUND AND MPI_FOUND)
SET(CONDUIT_RELAY_IO_MPI_CGNS_ENABLED TRUE)
endif()

if(H5ZZFP_FOUND)
SET(CONDUIT_RELAY_IO_H5ZZFP_ENABLED TRUE)
endif()
Expand Down Expand Up @@ -119,6 +130,14 @@ if(HDF5_FOUND)
list(APPEND conduit_relay_sources conduit_relay_io_hdf5.cpp)
endif()

if(CGNS_FOUND)
list(APPEND conduit_relay_headers
conduit_relay_io_cgns.hpp
conduit_relay_io_cgns_api.hpp
)
list(APPEND conduit_relay_sources conduit_relay_io_cgns.cpp)
endif()

if(SILO_FOUND)
list(APPEND conduit_relay_headers
conduit_relay_silo.hpp
Expand Down Expand Up @@ -193,6 +212,10 @@ if(HDF5_FOUND)
endif()
endif()

if(CGNS_FOUND)
list(APPEND conduit_relay_deps cgns)
endif()

if(H5ZZFP_FOUND)
list(APPEND conduit_relay_deps h5zzfp)
endif()
Expand Down Expand Up @@ -389,6 +412,12 @@ if(SILO_FOUND)
list(APPEND conduit_relay_mpi_io_deps silo)
endif()

if(CGNS_FOUND)
list(APPEND conduit_relay_mpi_io_headers conduit_relay_mpi_io_cgns.hpp)
list(APPEND conduit_relay_mpi_io_sources conduit_relay_io_cgns.cpp)
list(APPEND conduit_relay_mpi_io_deps cgns)
endif()

if(HDF5_FOUND)
list(APPEND conduit_relay_mpi_io_headers conduit_relay_mpi_io_hdf5.hpp)
list(APPEND conduit_relay_mpi_io_sources conduit_relay_io_hdf5.cpp)
Expand Down
2 changes: 2 additions & 0 deletions src/libs/relay/conduit_relay_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

#cmakedefine CONDUIT_RELAY_IO_HDF5_ENABLED

#cmakedefine CONDUIT_RELAY_IO_CGNS_ENABLED

#cmakedefine CONDUIT_RELAY_IO_H5ZZFP_ENABLED

#cmakedefine CONDUIT_RELAY_IO_SILO_ENABLED
Expand Down
28 changes: 28 additions & 0 deletions src/libs/relay/conduit_relay_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
#include "conduit_relay_io_silo.hpp"
#endif

#ifdef CONDUIT_RELAY_IO_CGNS_ENABLED
#include "conduit_relay_io_cgns.hpp"
#endif

#ifdef CONDUIT_RELAY_IO_ADIOS_ENABLED
#include "conduit_relay_io_adios.hpp"
#endif
Expand Down Expand Up @@ -98,6 +102,12 @@ about(Node &n)
io_protos["sidre_hdf5"] = "enabled";
#endif

#ifdef CONDUIT_RELAY_IO_CGNS_ENABLED
io_protos["cgns"] = "enabled";
#else
io_protos["cgns"] = "disabled";
#endif

#ifdef CONDUIT_RELAY_IO_H5ZZFP_ENABLED
io_protos["h5z-zfp"] = "enabled";
#else
Expand Down Expand Up @@ -318,6 +328,9 @@ save(const Node &node,
const std::string &protocol_,
const Node &options)
{
std::cout << "save: " << path << " protocol: " << protocol_ << std::endl;
std::cout << "options: " << std::endl;
options.print();
// we expect options to unused if all 3rd party i/o options are disabled
// avoid warning using CONDUIT_UNUSED macro.
CONDUIT_UNUSED(options);
Expand Down Expand Up @@ -392,6 +405,16 @@ save(const Node &node,
#else
CONDUIT_ERROR("conduit_relay lacks Silo support: " <<
"Failed to save conduit node to path " << path);
#endif
}
else if( protocol == "cgns")
{
#ifdef CONDUIT_RELAY_IO_CGNS_ENABLED
// Node
cgns_write(node,path);
#else
CONDUIT_ERROR("conduit_relay lacks CGNS support: " <<
"Failed to save conduit node to path " << path);
#endif
}
else if( protocol == "adios")
Expand Down Expand Up @@ -548,6 +571,11 @@ save_merged(const Node &node,
"Failed to save conduit node to path " << path);
#endif
}
else if( protocol == "cgns")
{
CONDUIT_ERROR("conduit_relay_io::save_merged lacks CGNS support: " <<
"Failed to save conduit node to path " << path);
}
else
{
CONDUIT_ERROR("unknown conduit_relay protocol: " << protocol);
Expand Down
30 changes: 29 additions & 1 deletion src/libs/relay/conduit_relay_io_blueprint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
#ifdef CONDUIT_RELAY_IO_SILO_ENABLED
#include "conduit_relay_mpi_io_silo.hpp"
#endif
#ifdef CONDUIT_RELAY_IO_CGNS_ENABLED
#include "conduit_relay_mpi_io_cgns.hpp"
#endif
#else
#include "conduit_relay_io_blueprint.hpp"
#endif
Expand All @@ -29,6 +32,10 @@
#include "conduit_relay_io_silo.hpp"
#endif

#ifdef CONDUIT_RELAY_IO_CGNS_ENABLED
#include "conduit_relay_io_cgns.hpp"
#endif

#ifdef CONDUIT_RELAY_IO_MPI_ENABLED
// Define an argument macro that adds the communicator argument.
#define CONDUIT_RELAY_COMMUNICATOR_ARG(ARG) ,ARG
Expand Down Expand Up @@ -603,7 +610,9 @@ identify_protocol(const std::string &path)
std::string("."),
file_name_ext,
file_name_base);

std::cout << "identify_protocol: file_path = " << file_path << std::endl;
std::cout << "identify_protocol: file_name_base = " << file_name_base << std::endl;
std::cout << "identify_protocol: file_name_ext = " << file_name_ext << std::endl;
// default
std::string io_type = "bin";

Expand Down Expand Up @@ -911,6 +920,25 @@ void write_mesh(const Node &mesh,
<< "conduit build lacks silo support\n");
#endif
}

if(file_protocol == "cgns")
{
#ifdef CONDUIT_RELAY_IO_CGNS_ENABLED
#ifdef CONDUIT_RELAY_IO_MPI_ENABLED
return conduit::relay::mpi::io::cgns::write_mesh(mesh,
path,
opts,
mpi_comm);
#else
return conduit::relay::io::cgns::write_mesh(mesh,
path,
opts);
#endif
#else
CONDUIT_ERROR("write_mesh invalid protocol option: `cgns`"
<< "conduit build lacks CGNS support\n");
#endif
}

// The assumption here is that everything is multi domain

Expand Down
Loading