Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance conduit_relay_io_convert so it can make files for VisIt. #1172

Merged
Merged
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
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;
}



Loading