Skip to content

Commit

Permalink
filter output name is matset name, fix zero copy, rework discrete to …
Browse files Browse the repository at this point in the history
…a color_table pseudocolor param
  • Loading branch information
nicolemarsaglia committed Jul 18, 2024
1 parent 26bc850 commit 25e15b7
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 96 deletions.
8 changes: 0 additions & 8 deletions src/libs/ascent/runtimes/ascent_vtkh_data_adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,6 @@ vtkm::cont::Field GetField(const conduit::Node &node,
// base case is naturally stride data
if(element_stride == 1)
{
std::cerr << " In element_stride==1 for field: " << field_name << std::endl;
std::cerr << "vtkm_assoc: " << assoc_str << std::endl;
std::cerr << "num_vals: " << num_vals << std::endl;
std::cerr << "copy: " << zero_copy << std::endl;
field = vtkm::cont::make_Field(field_name,
vtkm_assoc,
values_ptr,
Expand All @@ -285,7 +281,6 @@ vtkm::cont::Field GetField(const conduit::Node &node,
}
else
{
std::cerr << "not in element_stride==1" << std::endl;
//
// use ArrayHandleStride to create new field
//
Expand Down Expand Up @@ -2099,12 +2094,9 @@ VTKHDataAdapter::AddMatSets(const std::string &matset_name,

if(!n_matset.has_child("volume_fractions"))
ASCENT_ERROR("No volume fractions were defined for matset: " << matset_name);
std::cerr << "zero copy going into AddMatSets: " << zero_copy << std::endl;
//TODO: zero_copy = true segfaulting in vtkm mir filter
//zero_copy = false;

//std::cerr << " after setting zero copy to true or false: " << zero_copy << std::endl;


std::string assoc_str = "element";
//fields required from VTK-m MIR filter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ check_color_table_surprises(const conduit::Node &color_table)
valid_paths.push_back("name");
valid_paths.push_back("reverse");
valid_paths.push_back("annotation");
valid_paths.push_back("discrete");

std::vector<std::string> ignore_paths;
ignore_paths.push_back("control_points");
Expand Down Expand Up @@ -360,7 +361,6 @@ vtkh::Render parse_render(const conduit::Node &render_node,
// render create a default camera. Now get it and check for
// values that override the default view
//

if(render_node.has_path("camera"))
{
vtkm::rendering::Camera camera = render.GetCamera();
Expand Down Expand Up @@ -1169,10 +1169,10 @@ DefaultRender::execute()

std::string output_path = default_dir();

if(render_node.has_path("output_path"))
{
if(render_node.has_path("output_path"))
{
output_path = render_node["output_path"].as_string();
int rank = 0;
int rank = 0;
#ifdef ASCENT_MPI_ENABLED
MPI_Comm mpi_comm = MPI_Comm_f2c(Workspace::default_mpi_comm());
MPI_Comm_rank(mpi_comm, &rank);
Expand All @@ -1182,7 +1182,7 @@ DefaultRender::execute()
{
conduit::utils::create_directory(output_path);
}
}
}

if(!render_node.has_path("db_name"))
{
Expand Down Expand Up @@ -1243,104 +1243,106 @@ DefaultRender::execute()
"'image_prefix' parameter");
}

if(render_node.has_path("dataset_bounds"))
{
float64_accessor d_bounds = render_node["dataset_bounds"].value();
int num_bounds = d_bounds.number_of_elements();

if(num_bounds != 6)
if(render_node.has_path("dataset_bounds"))
{
float64_accessor d_bounds = render_node["dataset_bounds"].value();
int num_bounds = d_bounds.number_of_elements();

if(num_bounds != 6)
{
std::string render_name = renders_node.child_names()[i];
std::string fpath = filter_to_path(this->name());
ASCENT_ERROR("Render ("<<fpath<<"/"<<render_name<<")"<<
" only provided " << num_bounds <<
" dataset_bounds when 6 are required:" <<
" [xMin,xMax,yMin,yMax,zMin,zMax]");
}

if(scene_bounds.X.Min > d_bounds[0])
scene_bounds.X.Min = d_bounds[0];
if(scene_bounds.X.Max < d_bounds[1])
scene_bounds.X.Max = d_bounds[1];
if(scene_bounds.Y.Min > d_bounds[2])
scene_bounds.Y.Min = d_bounds[2];
if(scene_bounds.Y.Max < d_bounds[3])
scene_bounds.Y.Max = d_bounds[3];
if(scene_bounds.Z.Min > d_bounds[4])
scene_bounds.Z.Min = d_bounds[4];
if(scene_bounds.Z.Max < d_bounds[5])
scene_bounds.Z.Max = d_bounds[5];
}

if(is_auto_camera)
{
" dataset_bounds when 6 are required:" <<
" [xMin,xMax,yMin,yMax,zMin,zMax]");
}
if(scene_bounds.X.Min > d_bounds[0])
scene_bounds.X.Min = d_bounds[0];
if(scene_bounds.X.Max < d_bounds[1])
scene_bounds.X.Max = d_bounds[1];
if(scene_bounds.Y.Min > d_bounds[2])
scene_bounds.Y.Min = d_bounds[2];
if(scene_bounds.Y.Max < d_bounds[3])
scene_bounds.Y.Max = d_bounds[3];
if(scene_bounds.Z.Min > d_bounds[4])
scene_bounds.Z.Min = d_bounds[4];
if(scene_bounds.Z.Max < d_bounds[5])
scene_bounds.Z.Max = d_bounds[5];
}

if(is_auto_camera)
{
DataObject *source
= graph().workspace().registry().fetch<DataObject>("source_object");

= graph().workspace().registry().fetch<DataObject>("source_object");
std::shared_ptr<VTKHCollection> collection = source->as_vtkh_collection();

if(!render_node.has_path("auto_camera/field"))
if(!render_node.has_path("auto_camera/field"))
ASCENT_ERROR("Auto Camera must specify a 'field'");
if(!render_node.has_path("auto_camera/metric"))
if(!render_node.has_path("auto_camera/metric"))
ASCENT_ERROR("Auto Camera must specify a 'metric'");
if(!render_node.has_path("auto_camera/samples"))
if(!render_node.has_path("auto_camera/samples"))
ASCENT_ERROR("Auto Camera must specify number of 'samples'");

std::string field_name = render_node["auto_camera/field"].as_string();
std::string metric = render_node["auto_camera/metric"].as_string();
int samples = render_node["auto_camera/samples"].to_int64();

int samples = render_node["auto_camera/samples"].as_int32();
if(!collection->has_field(field_name))
{
ASCENT_ERROR("Unknown field '"<<field_name<<"' in Auto Camera");
}

std::string topo_name = collection->field_topology(field_name);
vtkh::DataSet &dataset = collection->dataset_by_topology(topo_name);

vtkh::AutoCamera auto_cam;

int height = 1024;
int width = 1024;
int height = 1024;
int width = 1024;
if(render_node.has_path("auto_camera/bins"))
{
int bins = render_node["auto_camera/bins"].to_int64();
int bins = render_node["auto_camera/bins"].as_int32();
auto_cam.SetNumBins(bins);
}
if(render_node.has_path("auto_camera/height"))
{
height = render_node["auto_camera/height"].to_int64();
height = render_node["auto_camera/height"].as_int32();
auto_cam.SetHeight(height);
}
if(render_node.has_path("auto_camera/width"))
{
width = render_node["auto_camera/width"].to_int64();
width = render_node["auto_camera/width"].as_int32();
auto_cam.SetWidth(width);
}

auto_cam.SetInput(&dataset);
auto_cam.SetField(field_name);
auto_cam.SetMetric(metric);
auto_cam.SetNumSamples(samples);
auto_cam.Update();

vtkm::rendering::Camera *camera = new vtkm::rendering::Camera;
*camera = auto_cam.GetCamera();
vtkh::Render render = vtkh::MakeRender(width,
height,
scene_bounds,
*camera,
image_name);
vtkh::Render render = vtkh::MakeRender(width,
height,
scene_bounds,
*camera,
image_name);
renders->push_back(render);
delete camera;
}
else
{
delete camera;

}
else
{

vtkh::Render render = detail::parse_render(render_node,
scene_bounds,
image_name);
renders->push_back(render);
}
}
}
}
}
Expand All @@ -1351,7 +1353,6 @@ DefaultRender::execute()
if(params().has_path("image_name"))
{
image_name = params()["image_name"].as_string();
image_name = output_dir(image_name);
}
else
{
Expand Down Expand Up @@ -1433,7 +1434,7 @@ VTKHBounds::execute()
std::shared_ptr<VTKHCollection> collection = data_object->as_vtkh_collection();
bounds->Include(collection->global_bounds());
}

set_output<vtkm::Bounds>(bounds);
}

Expand Down Expand Up @@ -1743,10 +1744,20 @@ CreatePlot::execute()
{
if(plot_params["color_table"].has_path("annotation"))
{
if(plot_params["color_table/annotation"].as_string() == "false")
{
renderer->DisableColorBar();
}
if(plot_params["color_table/annotation"].as_string() == "false")
{
renderer->DisableColorBar();
}
}
if(type != "volume")
{
if(plot_params["color_table"].has_path("discrete"))
{
if(plot_params["color_table/discrete"].as_string() == "true")
{
renderer->SetDiscrete();
}
}
}
}
renderer->SetColorTable(color_table);
Expand All @@ -1771,15 +1782,7 @@ CreatePlot::execute()
}


if(graph().workspace().registry().has_entry("is_discrete"))
{

int *is_discrete;
is_discrete = graph().workspace().registry().fetch<int>("is_discrete");
//make sure we set the discrete only for mir output field
if(is_discrete && field_name == "cellMat")
renderer->SetDiscrete();
}


if(type == "mesh")
{
Expand Down Expand Up @@ -1918,16 +1921,14 @@ ExecScene::execute()
image_data["camera/up"].set(&renders->at(i).GetCamera().GetViewUp()[0],3);
image_data["camera/zoom"] = renders->at(i).GetCamera().GetZoom();
image_data["camera/fov"] = renders->at(i).GetCamera().GetFieldOfView();
image_data["camera/near_plane"] = renders->at(i).GetCamera().GetClippingRange().Min;
image_data["camera/far_plane"] = renders->at(i).GetCamera().GetClippingRange().Max;

vtkm::Bounds bounds= renders->at(i).GetSceneBounds();
double coord_bounds [6] = {bounds.X.Min,
bounds.Y.Min,
bounds.Z.Min,
bounds.X.Max,
bounds.Y.Max,
bounds.Z.Max};

image_data["scene_bounds"].set(coord_bounds, 6);

image_list->append() = image_data;
Expand Down
7 changes: 0 additions & 7 deletions src/libs/vtkh/filters/MIR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,6 @@ void MIR::DoExecute()
mir.SetScalingDecay(vtkm::Float64(m_scaling_decay));
mir.SetMaxIterations(vtkm::IdComponent(m_iterations));
mir.SetMaxPercentError(vtkm::Float64(m_max_error));
std::cerr <<"data of domain: " << i << " and domain_id: " << domain_id << std::endl;
std::cerr << "DATA START" << std::endl;
dom.PrintSummary(std::cerr);
std::cerr << "DATA END" << std::endl;
std::cerr << "DATA START AGAIN" << std::endl;
dom.PrintSummary(std::cerr);
std::cerr << "END AGAIN" << std::endl;
vtkm::cont::DataSet output = mir.Execute(dom);
//cast and call error if cellMat stays as ints
vtkm::cont::UnknownArrayHandle float_field = output.GetField("cellMat").GetDataAsDefaultFloat();
Expand Down
Binary file modified src/tests/_baseline_images/tout_mir_venn_full100.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/tests/_baseline_images/tout_mir_venn_sparse_by_element100.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/tests/_baseline_images/tout_mir_venn_sparse_by_material100.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 8 additions & 5 deletions src/tests/ascent/t_ascent_mir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ TEST(ascent_mir, venn_vtkm_mir_full)
conduit::Node scenes;
scenes["s1/plots/p1/type"] = "pseudocolor";
// scenes["s1/plots/p1/matset"] = "matset";
scenes["s1/plots/p1/field"] = "cellMat";
scenes["s1/plots/p1/field"] = "matset";
scenes["s1/plots/p1/color_table/discrete"] = "true";
// scenes["s1/plots/p1/field"] = "circle_b";
scenes["s1/plots/p1/pipeline"] = "pl1";
scenes["s1/image_prefix"] = output_file;
Expand Down Expand Up @@ -129,8 +130,8 @@ TEST(ascent_mir, venn_vtkm_mir_full)
ASCENT_ACTIONS_DUMP(actions,output_file,msg);

}

//-----------------------------------------------------------------------------
//
////-----------------------------------------------------------------------------
TEST(ascent_mir, venn_vtkm_mir_sparse_by_element)
{
Node n;
Expand Down Expand Up @@ -182,7 +183,8 @@ TEST(ascent_mir, venn_vtkm_mir_sparse_by_element)
conduit::Node scenes;
scenes["s1/plots/p1/type"] = "pseudocolor";
// scenes["s1/plots/p1/matset"] = "matset";
scenes["s1/plots/p1/field"] = "cellMat";
scenes["s1/plots/p1/field"] = "matset";
scenes["s1/plots/p1/color_table/discrete"] = "true";
// scenes["s1/plots/p1/field"] = "circle_b";
scenes["s1/plots/p1/pipeline"] = "pl1";
scenes["s1/image_prefix"] = output_file;
Expand Down Expand Up @@ -278,7 +280,8 @@ TEST(ascent_mir, venn_vtkm_mir_sparse_by_material)
conduit::Node scenes;
scenes["s1/plots/p1/type"] = "pseudocolor";
// scenes["s1/plots/p1/matset"] = "matset";
scenes["s1/plots/p1/field"] = "cellMat";
scenes["s1/plots/p1/color_table/discrete"] = "true";
scenes["s1/plots/p1/field"] = "matset";
// scenes["s1/plots/p1/field"] = "circle_b";
scenes["s1/plots/p1/pipeline"] = "pl1";
scenes["s1/image_prefix"] = output_file;
Expand Down

0 comments on commit 25e15b7

Please sign in to comment.