Skip to content

Commit eccc876

Browse files
committed
Prototype CGNS blueprint mesh relay output
1 parent 2eec1ad commit eccc876

11 files changed

+656
-0
lines changed

src/cmake/Setup3rdParty.cmake

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,19 @@ if(HDF5_DIR)
123123
endif()
124124
endif()
125125

126+
################################
127+
# Setup CGNS if available
128+
################################
129+
# Search for CGNS.
130+
if(CGNS_DIR)
131+
include(cmake/thirdparty/SetupCGNS.cmake)
132+
include_directories(${CGNS_INCLUDE_DIRS})
133+
# if we don't find CGNS, throw a fatal error
134+
if(NOT CGNS_FOUND)
135+
message(FATAL_ERROR "CGNS_DIR is set, but CGNS wasn't found.")
136+
endif()
137+
endif()
138+
126139
################################
127140
# Setup Silo if available
128141
################################

src/cmake/thirdparty/SetupCGNS.cmake

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
# first Check for CGNS_DIR
3+
if(NOT CGNS_DIR)
4+
MESSAGE(FATAL_ERROR "CGNS support needs explicit CGNS_DIR")
5+
endif()
6+
7+
set(CGNS_ROOT ${CGNS_DIR})
8+
9+
find_package(CGNS REQUIRED)
10+
11+
get_target_property(CGNS_INCLUDE_DIRS CGNS::cgns_shared INTERFACE_INCLUDE_DIRECTORIES)
12+
message(STATUS "CGNS Include Directory: ${CGNS_INCLUDE_DIRS}")

src/docs/sphinx/building.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@ CMake Options for Third-party Library Paths
143143
* - ``ZLIB_DIR``
144144
- Path to a Zlib install (optional). (Needed for HDF5 support)
145145

146+
* - ``CGNS_DIR``
147+
- Path to a CGNS install (optional). Controls if CGNS I/O support is built into *conduit_relay*.
148+
146149
* - ``SILO_DIR``
147150
- Path to a Silo install (optional). Controls if Silo I/O support is built into *conduit_relay*. Requires HDF5.
148151

src/libs/relay/CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ if(HDF5_FOUND)
1616
SET(CONDUIT_RELAY_IO_HDF5_ENABLED TRUE)
1717
endif()
1818

19+
if(CGNS_FOUND)
20+
SET(CONDUIT_RELAY_IO_CGNS_ENABLED TRUE)
21+
endif()
22+
1923
if(H5ZZFP_FOUND)
2024
SET(CONDUIT_RELAY_IO_H5ZZFP_ENABLED TRUE)
2125
endif()
@@ -119,6 +123,13 @@ if(HDF5_FOUND)
119123
list(APPEND conduit_relay_sources conduit_relay_io_hdf5.cpp)
120124
endif()
121125

126+
if(CGNS_FOUND)
127+
list(APPEND conduit_relay_headers
128+
conduit_relay_io_cgns.hpp
129+
)
130+
list(APPEND conduit_relay_sources conduit_relay_io_cgns.cpp)
131+
endif()
132+
122133
if(SILO_FOUND)
123134
list(APPEND conduit_relay_headers
124135
conduit_relay_silo.hpp
@@ -193,6 +204,10 @@ if(HDF5_FOUND)
193204
endif()
194205
endif()
195206

207+
if(CGNS_FOUND)
208+
list(APPEND conduit_relay_deps CGNS::cgns_shared)
209+
endif()
210+
196211
if(H5ZZFP_FOUND)
197212
list(APPEND conduit_relay_deps h5zzfp)
198213
endif()

src/libs/relay/conduit_relay_config.h.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
#cmakedefine CONDUIT_RELAY_IO_HDF5_ENABLED
2424

25+
#cmakedefine CONDUIT_RELAY_IO_CGNS_ENABLED
26+
2527
#cmakedefine CONDUIT_RELAY_IO_H5ZZFP_ENABLED
2628

2729
#cmakedefine CONDUIT_RELAY_IO_SILO_ENABLED

src/libs/relay/conduit_relay_io.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ about(Node &n)
9898
io_protos["sidre_hdf5"] = "enabled";
9999
#endif
100100

101+
#ifdef CONDUIT_RELAY_IO_CGNS_ENABLED
102+
io_protos["cgns"] = "enabled";
103+
#else
104+
io_protos["cgns"] = "disabled";
105+
#endif
106+
101107
#ifdef CONDUIT_RELAY_IO_H5ZZFP_ENABLED
102108
io_protos["h5z-zfp"] = "enabled";
103109
#else
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#include "conduit_relay_io_cgns.hpp"
2+
3+
//-----------------------------------------------------------------------------
4+
// external lib includes
5+
//-----------------------------------------------------------------------------
6+
#include <cgnslib.h>
7+
8+
//-----------------------------------------------------------------------------
9+
// -- begin conduit:: --
10+
//-----------------------------------------------------------------------------
11+
namespace conduit {
12+
13+
//-----------------------------------------------------------------------------
14+
// -- begin conduit::relay --
15+
//-----------------------------------------------------------------------------
16+
namespace relay {
17+
18+
//-----------------------------------------------------------------------------
19+
// -- begin conduit::relay::io --
20+
//-----------------------------------------------------------------------------
21+
namespace io {
22+
23+
void cgns_save(const Node &node, const std::string &path) {
24+
int index_file;
25+
26+
if (cg_open("grid_c.cgns", CG_MODE_WRITE, &index_file))
27+
cg_error_exit();
28+
29+
std::cout << "wrote grid_c.cgns\n";
30+
31+
32+
cg_close(index_file);
33+
}
34+
35+
}
36+
// namespace io
37+
//-----------------------------------------------------------------------------
38+
// -- end conduit::relay::io --
39+
//-----------------------------------------------------------------------------
40+
41+
}
42+
// namespace relay
43+
//-----------------------------------------------------------------------------
44+
// -- end conduit::relay --
45+
//-----------------------------------------------------------------------------
46+
47+
}
48+
// namespace conduit
49+
//-----------------------------------------------------------------------------
50+
// -- end conduit:: --
51+
//-----------------------------------------------------------------------------
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// Copyright (c) Lawrence Livermore National Security, LLC and other Conduit
2+
// Project developers. See top-level LICENSE AND COPYRIGHT files for dates and
3+
// other details. No copyright assignment is required to contribute to Conduit.
4+
5+
//-----------------------------------------------------------------------------
6+
///
7+
/// file: conduit_relay_io_cgns.hpp
8+
///
9+
//-----------------------------------------------------------------------------
10+
11+
#ifndef CONDUIT_RELAY_IO_CGNS_HPP
12+
#define CONDUIT_RELAY_IO_CGNS_HPP
13+
14+
//-----------------------------------------------------------------------------
15+
// conduit lib include
16+
//-----------------------------------------------------------------------------
17+
#include "conduit.hpp"
18+
#include "conduit_relay_config.h"
19+
#include "conduit_relay_exports.h"
20+
21+
//-----------------------------------------------------------------------------
22+
// -- begin conduit:: --
23+
//-----------------------------------------------------------------------------
24+
namespace conduit {
25+
26+
//-----------------------------------------------------------------------------
27+
// -- begin conduit::relay --
28+
//-----------------------------------------------------------------------------
29+
namespace relay {
30+
31+
//-----------------------------------------------------------------------------
32+
// -- begin conduit::relay::io --
33+
//-----------------------------------------------------------------------------
34+
namespace io {
35+
36+
//-----------------------------------------------------------------------------
37+
/// Save node data to a given path.
38+
///
39+
/// Save Semantics: Existing file will be overwritten
40+
//-----------------------------------------------------------------------------
41+
void CONDUIT_RELAY_API cgns_save(const Node &node,
42+
const std::string &path);
43+
}
44+
//-----------------------------------------------------------------------------
45+
// -- end conduit::relay::io --
46+
//-----------------------------------------------------------------------------
47+
48+
}
49+
// namespace relay
50+
//-----------------------------------------------------------------------------
51+
// -- end conduit::relay --
52+
//-----------------------------------------------------------------------------
53+
54+
} // namespace conduit
55+
//-----------------------------------------------------------------------------
56+
// -- end conduit:: --
57+
//-----------------------------------------------------------------------------
58+
59+
#endif

0 commit comments

Comments
 (0)