Skip to content
This repository was archived by the owner on Jul 14, 2022. It is now read-only.

Commit be86a73

Browse files
cyrushjameskressgoodbadwolf
authored
update to support new vtk-m (#229)
* Updating threshold to match new vtkm * try vtk-m 1.7.0 rc * heal * adjust for new vtk-m * Fixing DataSetWriter warning. * retest release branch * remove patch * Add calls to text and line annotation batching vtk-m API VTK-m introduced new APIs to batch text and line annotation rendering. This speeds up the rendering of the annotations, but requires calling: - `Canvas::BeginTextRenderingBatch()` and `Canvas::EndTextRenderingBatch()` for batched text rendering. - `WorldAnnotator::BeginLineRenderingBatch()` and `WorldAnnotator::EndLineRenderingBatch()` for batched line rendering * update to new vtk-m hash * add vtkh init function * build using released 1.7.0 vtk-m * fix typo and use newer configs * add missing include * update hashes to point to vtk-m 1.7.0 Co-authored-by: James <[email protected]> Co-authored-by: Manish Mathai <[email protected]>
1 parent 62a923e commit be86a73

File tree

13 files changed

+467
-9
lines changed

13 files changed

+467
-9
lines changed

hashes.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
blt branch='develop' commit='86a7d6b5ee93d8b7b3233a3e54a4f06f8d8308d3'
2-
vtkm branch='master' commit='d2d1c854adc8c0518802f153b48afd17646b6252'
2+
vtkm branch='release' commit='d5143ad7ed2e55025cec2f49fb3f0ab46045a8e2'
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
diff --git a/vtkm/worklet/Contour.h b/vtkm/worklet/Contour.h
2+
index c28c5ec09..70737777f 100644
3+
--- a/vtkm/worklet/Contour.h
4+
+++ b/vtkm/worklet/Contour.h
5+
@@ -46,7 +46,8 @@ struct DeduceCoordType
6+
vtkm::cont::CellSetSingleType<>& result,
7+
Args&&... args) const
8+
{
9+
- result = flying_edges::execute(cells, coords, std::forward<Args>(args)...);
10+
+ result = marching_cells::execute(cells, coords, std::forward<Args>(args)...);
11+
+ //result = flying_edges::execute(cells, coords, std::forward<Args>(args)...);
12+
}
13+
};
14+

scripts/uberenv_configs/packages/vtk-m/package.py

Lines changed: 385 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
diff --git a/vtkm/thirdparty/diy/vtkmdiy/CMakeLists.txt b/vtkm/thirdparty/diy/vtkmdiy/CMakeLists.txt
2+
index 5211330..3e991f3 100644
3+
--- a/vtkm/thirdparty/diy/vtkmdiy/CMakeLists.txt
4+
+++ b/vtkm/thirdparty/diy/vtkmdiy/CMakeLists.txt
5+
@@ -139,6 +139,7 @@ function(add_diy_mpi_library use_mpi)
6+
endif()
7+
8+
add_library(${lib_name} ${sources})
9+
+ set_property(TARGET ${lib_name} PROPERTY POSITION_INDEPENDENT_CODE ON)
10+
target_compile_features(${lib_name} PRIVATE cxx_std_11)
11+
target_compile_definitions(${lib_name}
12+
PRIVATE -DVTKMDIY_HAS_MPI=${has_mpi_val}

src/tests/vtkh/t_vtk-h_particle_advection_par.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include <vtkh/DataSet.hpp>
1111
#include <vtkh/filters/ParticleAdvection.hpp>
1212
#include <vtkh/filters/Streamline.hpp>
13-
#include <vtkm/io/writer/VTKDataSetWriter.h>
13+
#include <vtkm/io/VTKDataSetWriter.h>
1414
#include <vtkm/cont/DataSet.h>
1515
#include <vtkm/cont/DataSetFieldAdd.h>
1616
#include <vtkm/cont/CellSetSingleType.h>
@@ -52,7 +52,7 @@ void writeDataSet(vtkh::DataSet *data, std::string fName, int rank)
5252
{
5353
char fileNm[128];
5454
sprintf(fileNm, "%s.rank%d.domain%d.vtk", fName.c_str(), rank, i);
55-
vtkm::io::writer::VTKDataSetWriter write(fileNm);
55+
vtkm::io::VTKDataSetWriter write(fileNm);
5656
write.WriteDataSet(data->GetDomain(i));
5757
}
5858
}

src/vtkh/filters/Threshold.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ Threshold::SetField(const std::string &field_name)
3838
m_field_name = field_name;
3939
}
4040

41+
void
42+
Threshold::SetAllInRange(const bool &value)
43+
{
44+
m_return_all_in_range = value;
45+
}
46+
4147
double
4248
Threshold::GetUpperThreshold() const
4349
{
@@ -50,6 +56,12 @@ Threshold::GetLowerThreshold() const
5056
return m_range.Min;
5157
}
5258

59+
bool
60+
Threshold::GetAllInRange() const
61+
{
62+
return m_return_all_in_range;
63+
}
64+
5365
std::string
5466
Threshold::GetField() const
5567
{
@@ -89,7 +101,8 @@ void Threshold::DoExecute()
89101
m_field_name,
90102
m_range.Min,
91103
m_range.Max,
92-
this->GetFieldSelection());
104+
this->GetFieldSelection(),
105+
m_return_all_in_range);
93106

94107
temp_data.AddDomain(data_set, domain_id);
95108
}

src/vtkh/filters/Threshold.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,19 @@ class VTKH_API Threshold: public Filter
2121
void SetUpperThreshold(const double &value);
2222
void SetLowerThreshold(const double &value);
2323
void SetField(const std::string &field_name);
24+
void SetAllInRange(const bool &value);
2425

2526
double GetUpperThreshold() const;
2627
double GetLowerThreshold() const;
28+
bool GetAllInRange() const;
2729
std::string GetField() const;
2830
protected:
2931
void PreExecute() override;
3032
void PostExecute() override;
3133
void DoExecute() override;
3234
vtkm::Range m_range;
3335
std::string m_field_name;
36+
bool m_return_all_in_range = false;
3437
};
3538

3639
} //namespace vtkh

src/vtkh/rendering/Annotator.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ Annotator::RenderScreenAnnotations(const std::vector<std::string> &field_names,
3737
m_canvas.SetViewToScreenSpace(m_camera, true);
3838
// currently we only support 4 color bars, so grab the first 4
3939
int num_bars = std::min(int(field_names.size()),4);
40+
m_canvas.BeginTextRenderingBatch();
41+
m_world_annotator->BeginLineRenderingBatch();
4042
for(int i = 0; i < num_bars; ++i)
4143
{
4244
this->m_color_bar_annotation.SetRange(ranges[i], 5);
@@ -45,19 +47,24 @@ Annotator::RenderScreenAnnotations(const std::vector<std::string> &field_names,
4547
this->m_color_bar_annotation.SetColorTable(color_tables[i]);
4648
this->m_color_bar_annotation.Render(m_camera, *m_world_annotator, m_canvas);
4749
}
50+
m_world_annotator->EndLineRenderingBatch();
51+
m_canvas.EndTextRenderingBatch();
4852
}
4953

5054
void Annotator::RenderWorldAnnotations(vtkm::Vec<float,3> axis_scale)
5155
{
5256
if(!m_is_3d) return;
5357
m_canvas.SetViewToWorldSpace(m_camera, false);
58+
59+
m_canvas.BeginTextRenderingBatch();
5460
vtkm::Float64 xmin = m_bounds.X.Min, xmax = m_bounds.X.Max;
5561
vtkm::Float64 ymin = m_bounds.Y.Min, ymax = m_bounds.Y.Max;
5662
vtkm::Float64 zmin = m_bounds.Z.Min, zmax = m_bounds.Z.Max;
5763
vtkm::Float64 dx = xmax - xmin, dy = ymax - ymin, dz = zmax - zmin;
5864
vtkm::Float64 size = vtkm::Sqrt(dx * dx + dy * dy + dz * dz);
5965

6066
//TODO: get forground color
67+
m_world_annotator->BeginLineRenderingBatch();
6168
this->m_box_annotation.SetColor(m_canvas.GetForegroundColor());
6269
this->m_box_annotation.SetExtents(m_bounds);
6370
this->m_box_annotation.Render(m_camera, *m_world_annotator);
@@ -66,6 +73,7 @@ void Annotator::RenderWorldAnnotations(vtkm::Vec<float,3> axis_scale)
6673
bool xtest = lookAt[0] > position[0];
6774
bool ytest = lookAt[1] > position[1];
6875
bool ztest = lookAt[2] > position[2];
76+
m_world_annotator->EndLineRenderingBatch();
6977

7078
const bool outsideedges = true; // if false, do closesttriad
7179
if (outsideedges)
@@ -79,6 +87,8 @@ void Annotator::RenderWorldAnnotations(vtkm::Vec<float,3> axis_scale)
7987
vtkm::Float64 zrel = vtkm::Abs(dz) / size;
8088
float major_tick_size = size / 40.f;
8189
float minor_tick_size = size / 80.f;
90+
91+
m_world_annotator->BeginLineRenderingBatch();
8292
this->m_x_axis_annotation.SetAxis(0);
8393
this->m_x_axis_annotation.SetColor(m_canvas.GetForegroundColor());
8494
this->m_x_axis_annotation.SetTickInvert(xtest, ytest, ztest);
@@ -117,7 +127,9 @@ void Annotator::RenderWorldAnnotations(vtkm::Vec<float,3> axis_scale)
117127
//this->m_z_axis_annotation.SetMoreOrLessTickAdjustment(zrel < .3 ? -1 : 0);
118128
this->m_z_axis_annotation.SetMoreOrLessTickAdjustment(-1);
119129
this->m_z_axis_annotation.Render(m_camera, *m_world_annotator, m_canvas);
130+
m_world_annotator->EndLineRenderingBatch();
120131

132+
m_canvas.EndTextRenderingBatch();
121133
}
122134

123135
} //namespace vtkh

src/vtkh/vtkh.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
#include "Error.hpp"
33
#include <vtkh/Logger.hpp>
44

5+
#include <vtkm/cont/Initialize.h>
56
#include <vtkm/cont/RuntimeDeviceInformation.h>
67
#include <vtkm/cont/RuntimeDeviceTracker.h>
7-
#include <vtkm/cont/DeviceAdapterListTag.h>
8+
89

910
#ifdef VTKM_CUDA
1011
#include <cuda.h>
@@ -19,7 +20,8 @@
1920
namespace vtkh
2021
{
2122

22-
static int g_mpi_comm_id = -1;
23+
static int g_mpi_comm_id = -1;
24+
static bool g_vtkm_inited = false;
2325

2426

2527
//---------------------------------------------------------------------------//
@@ -133,6 +135,18 @@ GetMPISize()
133135
#endif
134136
//---------------------------------------------------------------------------//
135137

138+
//---------------------------------------------------------------------------//
139+
void
140+
Initialize()
141+
{
142+
// call vtk-m init, if we haven't already
143+
if(!g_vtkm_inited)
144+
{
145+
vtkm::cont::Initialize();
146+
g_vtkm_inited = true;
147+
}
148+
}
149+
136150
//---------------------------------------------------------------------------//
137151
bool
138152
IsMPIEnabled()

0 commit comments

Comments
 (0)