Skip to content

Commit

Permalink
Merge pull request #1172 from LLNL/bugfix/whitlock/enhance_conduit_re…
Browse files Browse the repository at this point in the history
…lay_io_convert

Enhance conduit_relay_io_convert so it can make files for VisIt.
  • Loading branch information
BradWhitlock authored Oct 3, 2023
2 parents d012d0c + 52cbcb3 commit 9007e8b
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 17 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ and this project aspires to adhere to [Semantic Versioning](https://semver.org/s

#### General
- Improved the efficiency of json parsing logic.
- The `conduit_relay_io_convert` program was enhanced so it can read/write Blueprint root files by passing _"blueprint"_ for the read or write protocols.

#### Blueprint
- The `conduit::blueprint::mpi::mesh::partition_map_back()` function was enhanced so it accepts a "field_prefix" value in its options. The prefix is used when looking for the `global_vertex_ids` field, which could have been created with a prefix by the same option in the `conduit::blueprint::mpi::mesh::generate_partition_field()` function.
Expand Down
67 changes: 50 additions & 17 deletions src/libs/relay/conduit_relay_io_convert_exe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#ifdef CONDUIT_RELAY_IO_HDF5_ENABLED
#include "conduit_relay_io_hdf5.hpp"
#endif
#include "conduit_relay_io_blueprint.hpp"
#include <iostream>
#include <stdlib.h>

Expand All @@ -24,20 +25,24 @@ using namespace conduit::relay;
void
usage()
{
std::cout << "usage: conduit_relay_io_convert {input file} {output file}"
std::cout << "usage: conduit_relay_io_convert {input file} {output file} [--read-protocol protocol] [--write-protocol protocol] [--opts filename] [--help]"
<< std::endl << std::endl
<< " optional arguments:"
<< std::endl
<< " --read-proto {relay protocol string used to read data file}"
<< " --read-protocol {relay protocol} Protocol used to read data file, e.g. \"hdf5\""
<< std::endl
<< " --write-proto {relay protocol string used to read data file}"
<< " --opts {options file}"
<< std::endl << std::endl ;
<< " --write-protocol {relay protocol} Protocol used to write data file"
<< std::endl
<< " --opts {options file} Set options file used to initialize program."
<< std::endl
<< " --help/-h Print usage and exit."
<< std::endl
<< std::endl;

}

//-----------------------------------------------------------------------------
void
int
parse_args(int argc,
char *argv[],
std::string &input_file,
Expand All @@ -46,10 +51,16 @@ parse_args(int argc,
std::string &write_proto,
std::string &opts_file)
{
int retval = 0;
for(int i=1; i < argc ; i++)
{
std::string arg_str(argv[i]);
if(arg_str == "--read-protocol")
if(arg_str == "-h" || arg_str == "--help")
{
retval = -1;
break;
}
else if(arg_str == "--read-protocol")
{
if(i+1 >= argc )
{
Expand Down Expand Up @@ -88,6 +99,7 @@ parse_args(int argc,
output_file = arg_str;
}
}
return retval;
}


Expand All @@ -108,13 +120,17 @@ main(int argc, char* argv[])
std::string write_proto("");
std::string opts_file("");

parse_args(argc,
argv,
input_file,
output_file,
read_proto,
write_proto,
opts_file);
if(parse_args(argc,
argv,
input_file,
output_file,
read_proto,
write_proto,
opts_file) < 0)
{
usage();
return -2;
}

if(opts_file != "")
{
Expand Down Expand Up @@ -144,6 +160,16 @@ main(int argc, char* argv[])
{
relay::io::load(input_file,data);
}
else if(read_proto == "blueprint")
{
// NOTE: "blueprint" is not technically a protocol for Conduit but it
// does require a different function to read.
#ifdef CONDUIT_RELAY_IO_HDF5_ENABLED
relay::io::blueprint::load_mesh(input_file, data);
#else
std::cout << "A Blueprint root file cannot be read without HDF5." << std::endl;
#endif
}
else
{
relay::io::load(input_file, read_proto, data);
Expand All @@ -153,13 +179,20 @@ main(int argc, char* argv[])
{
relay::io::save(data,output_file);
}
else if(write_proto == "blueprint")
{
// NOTE: "blueprint" is not technically a protocol for Conduit but it
// does require a different function to write.
#ifdef CONDUIT_RELAY_IO_HDF5_ENABLED
relay::io::blueprint::save_mesh(data, output_file, "hdf5");
#else
std::cout << "A Blueprint root file cannot be written without HDF5." << std::endl;
#endif
}
else
{
relay::io::save(data, output_file, write_proto);
}

return 0;
}



0 comments on commit 9007e8b

Please sign in to comment.