Skip to content

Commit

Permalink
add support for bp implicit points topo
Browse files Browse the repository at this point in the history
  • Loading branch information
cyrush committed Oct 31, 2023
1 parent 7545109 commit 2e656c4
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 0 deletions.
66 changes: 66 additions & 0 deletions src/libs/ascent/runtimes/ascent_vtkh_data_adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,16 @@ VTKHDataAdapter::BlueprintToVTKmDataSet(const Node &node,
nverts,
zero_copy);
}
else if( mesh_type == "points")
{
result = PointsImplicitBlueprintToVTKmDataSet(coords_name,
n_coords,
topo_name,
n_topo,
neles,
nverts,
zero_copy);
}
else if( mesh_type == "unstructured")
{
result = UnstructuredBlueprintToVTKmDataSet(coords_name,
Expand Down Expand Up @@ -1186,6 +1196,62 @@ VTKHDataAdapter::StructuredBlueprintToVTKmDataSet
return result;
}

//-----------------------------------------------------------------------------

vtkm::cont::DataSet *
VTKHDataAdapter::PointsImplicitBlueprintToVTKmDataSet
(const std::string &coords_name, // input string with coordset name
const Node &n_coords, // input mesh bp coordset (assumed unstructured)
const std::string &topo_name, // input string with topo name
const Node &n_topo, // input mesh bp topo
int &neles, // output, number of eles (will be the same as nverts)
int &nverts, // output, number of verts (will be the same as neles)
bool zero_copy) // attempt to zero copy
{
vtkm::cont::DataSet *result = new vtkm::cont::DataSet();

nverts = n_coords["values/x"].dtype().number_of_elements();

int32 ndims;
vtkm::cont::CoordinateSystem coords;
if(n_coords["values/x"].dtype().is_float64())
{
coords = detail::GetExplicitCoordinateSystem<float64>(n_coords,
coords_name,
ndims,
zero_copy);
}
else if(n_coords["values/x"].dtype().is_float32())
{
coords = detail::GetExplicitCoordinateSystem<float32>(n_coords,
coords_name,
ndims,
zero_copy);
}
else
{
ASCENT_ERROR("Coordinate system must be floating point values");
}

result->AddCoordinateSystem(coords);

vtkm::UInt8 shape_id = 1;
vtkm::IdComponent indices_per = 1;
vtkm::cont::CellSetSingleType<> cellset;
// alloc conn to nverts, fill with 0 --> nverts-1)
vtkm::cont::ArrayHandle<vtkm::Id> connectivity;
connectivity.Allocate(nverts);
auto conn_portal = connectivity.WritePortal();
for(int i = 0; i < nverts; ++i)
{
conn_portal.Set(i, i);
}
cellset.Fill(nverts, shape_id, indices_per, connectivity);
neles = cellset.GetNumberOfCells();
result->SetCellSet(cellset);
return result;
}



//-----------------------------------------------------------------------------
Expand Down
8 changes: 8 additions & 0 deletions src/libs/ascent/runtimes/ascent_vtkh_data_adapter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@ class ASCENT_API VTKHDataAdapter
int &nverts,
bool zero_copy);

static vtkm::cont::DataSet *PointsImplicitBlueprintToVTKmDataSet(const std::string &coords_name,
const conduit::Node &n_coords,
const std::string &topo_name,
const conduit::Node &n_topo,
int &neles,
int &nverts,
bool zero_copy);

static vtkm::cont::DataSet *UnstructuredBlueprintToVTKmDataSet(const std::string &coords_name,
const conduit::Node &n_coords,
const std::string &topo_name,
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
63 changes: 63 additions & 0 deletions src/tests/ascent/t_ascent_render_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2510,6 +2510,69 @@ TEST(ascent_render_3d, test_render_3d_supported_conn_dtypes)
ascent.close();
}


//-----------------------------------------------------------------------------
TEST(ascent_render_3d, test_render_3d_points_implicit_topo)
{
// the ascent 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 3D default"
"Pipeline test");

return;
}

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


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

ASCENT_INFO("Testing 3D Rendering of implicit points topology");

//
// Create the actions.
//
conduit::Node actions;
conduit::Node &add_plots = actions.append();
add_plots["action"] = "add_scenes";
conduit::Node &scenes = add_plots["scenes"];
scenes["s1/plots/p1/type"] = "pseudocolor";
scenes["s1/plots/p1/field"] = "braid";


string output_path = prepare_output_dir();


string output_file = conduit::utils::join_file_path(output_path,
"tout_render_3d_braid_points_implicit");
// remove old images before rendering
remove_test_image(output_file);

Ascent ascent;
ascent.open();
ascent.publish(data);
scenes["s1/image_prefix"] = output_file;
ascent.execute(actions);
ascent.close();

// check that we created an image
EXPECT_TRUE(check_test_image(output_file));

}


// //-----------------------------------------------------------------------------
TEST(ascent_render_3d, test_render_3d_extreme_extents)
{
Expand Down

0 comments on commit 2e656c4

Please sign in to comment.