Skip to content

Commit

Permalink
wire up scalar rendering fields option
Browse files Browse the repository at this point in the history
  • Loading branch information
cyrush committed Feb 4, 2025
1 parent 2563f6d commit ceb9089
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ and this project aspires to adhere to [Semantic Versioning](https://semver.org/s
- Added `add_mpi_ranks` and `add_domain_ids` filters for adding rank and domain fields to a mesh
- Added `transform` filter, which allows you to rotate, scale, translate, mesh coordinates
- Added python script in src/utilities/visit_session_converters to convert VisIt color table to Ascent actions color table
- Added `fields` option to the project 2d to support scalar rendering of specific fields.

### Changed
- Changed the replay utility's binary names such that `replay_ser` is now `ascent_replay` and `raplay_mpi` is now `ascent_replay_mpi`. This will help prevent potential name collisions with other tools that also have replay utilities.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4018,13 +4018,21 @@ VTKHProject2d::verify_params(const conduit::Node &params,
res &= check_numeric("image_width",params, info, false);
res &= check_numeric("image_height",params, info, false);

if(params.has_child("fields") && !params["fields"].dtype().is_list())
{
res = false;
info["errors"].append() = "fields is not a list";
}

std::vector<std::string> valid_paths;
std::vector<std::string> ignore_paths;
valid_paths.push_back("topology");
valid_paths.push_back("image_width");
valid_paths.push_back("image_height");
valid_paths.push_back("camera");
ignore_paths.push_back("camera");
valid_paths.push_back("fields");
ignore_paths.push_back("fields");
valid_paths.push_back("camera");

std::string surprises = surprise_check(valid_paths, ignore_paths, params);

Expand Down Expand Up @@ -4074,11 +4082,35 @@ VTKHProject2d::execute()
vtkm::rendering::Camera camera;
camera.ResetToBounds(bounds);

std::vector<std::string> field_names;

if(params().has_path("camera"))
{
parse_camera(params()["camera"], camera);
}

if(params().has_path("fields"))
{

const conduit::Node &flist = params()["fields"];
const int num_fields = flist.number_of_children();

if(num_fields == 0)
{
ASCENT_ERROR("'fields' list must be non-empty");
}

for(int i = 0; i < num_fields; i++)
{
const conduit::Node &f = flist.child(i);
if(!f.dtype().is_string())
{
ASCENT_ERROR("'fields' list values must be a string");
}
field_names.push_back(f.as_string());
}
}

int width = 512;
int height = 512;
if(params().has_path("image_width"))
Expand All @@ -4096,7 +4128,7 @@ VTKHProject2d::execute()
tracer.SetHeight(height);
tracer.SetInput(&data);
tracer.SetCamera(camera);

tracer.SetFields(field_names);
tracer.Update();

vtkh::DataSet *output = tracer.GetOutput();
Expand Down
82 changes: 80 additions & 2 deletions src/tests/ascent/t_ascent_scalar_renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ TEST(ascent_scalar_rendering, test_scalar_rendering)

EXPECT_TRUE(conduit::blueprint::mesh::verify(data,verify_info));

ASCENT_INFO("Testing scalar Rendering");
ASCENT_INFO("Testing Scalar Rendering");


string output_path = prepare_output_dir();
Expand Down Expand Up @@ -98,7 +98,6 @@ TEST(ascent_scalar_rendering, test_scalar_rendering)
//

Ascent ascent;

Node ascent_opts;
ascent_opts["runtime/type"] = "ascent";
ascent.open(ascent_opts);
Expand All @@ -111,6 +110,85 @@ TEST(ascent_scalar_rendering, test_scalar_rendering)
ASCENT_ACTIONS_DUMP(actions,output_file,msg);
}


//-----------------------------------------------------------------------------
TEST(ascent_scalar_rendering, test_scalar_rendering_fields_specified)
{
// the vtkm runtime is currently our only rendering runtime
Node n;
ascent::about(n);
// only run this test if ascent was built with vtkm support
if(n["runtimes/ascent/vtkm/status"].as_string() == "disabled")
{
ASCENT_INFO("Ascent support disabled, skipping test");
return;
}


//
// Create an example mesh.
//
Node data, verify_info;
conduit::blueprint::mesh::examples::braid("hexs",
EXAMPLE_MESH_SIDE_DIM,
EXAMPLE_MESH_SIDE_DIM,
EXAMPLE_MESH_SIDE_DIM,
data);

EXPECT_TRUE(conduit::blueprint::mesh::verify(data,verify_info));

ASCENT_INFO("Testing Scalar Rendering with fields specified");


string output_path = prepare_output_dir();
string output_file = conduit::utils::join_file_path(output_path,"tout_scalar_rendering_fields_specified");

//
// Create the actions.
//

conduit::Node pipelines;
// pipeline 1
pipelines["pl1/f1/type"] = "project_2d";
// filter knobs
conduit::Node &params = pipelines["pl1/f1/params"];
params["image_width"] = 512;
params["image_height"] = 512;
params["fields"].append() = "braid";

conduit::Node extracts;
extracts["e1/type"] = "relay";
extracts["e1/pipeline"] = "pl1";

extracts["e1/params/path"] = output_file;
extracts["e1/params/protocol"] = "blueprint/mesh/hdf5";

conduit::Node actions;
// add the extracts
conduit::Node &add_extracts = actions.append();
add_extracts["action"] = "add_extracts";
add_extracts["extracts"] = extracts;
// add the pipeline
conduit::Node &add_pipelines= actions.append();
add_pipelines["action"] = "add_pipelines";
add_pipelines["pipelines"] = pipelines;

//
// Run Ascent
//

Ascent ascent;
Node ascent_opts;
ascent.open(ascent_opts);
ascent.publish(data);
ascent.execute(actions);
ascent.close();

// check that we created an image
std::string msg = "An example of scalar rendering of specific fields";
ASCENT_ACTIONS_DUMP(actions,output_file,msg);
}

//-----------------------------------------------------------------------------
int main(int argc, char* argv[])
{
Expand Down

0 comments on commit ceb9089

Please sign in to comment.