VTK  9.1.0
vtkDIYUtilities.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkDIYUtilities.h
5
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13
14=========================================================================*/
22#ifndef vtkDIYUtilities_h
23#define vtkDIYUtilities_h
24
25#include "vtkDeprecation.h" // for VTK_DEPRECATED_IN_9_1_0
26#include "vtkObject.h"
27#include "vtkParallelDIYModule.h" // for export macros
28#include "vtkSmartPointer.h" // needed for vtkSmartPointer
29
30#include <map> // For Link
31#include <set> // For Link
32#include <vector> // For GetDataSets
33
34// clang-format off
35#include "vtk_diy2.h" // needed for DIY
36#include VTK_DIY2(diy/master.hpp)
37#include VTK_DIY2(diy/mpi.hpp)
38#include VTK_DIY2(diy/serialization.hpp)
39#include VTK_DIY2(diy/types.hpp)
40// clang-format on
41
42class vtkDataArray;
43class vtkBoundingBox;
44class vtkDataObject;
45class vtkDataSet;
46class vtkFieldData;
48class vtkPoints;
49class vtkStringArray;
50
51class VTKPARALLELDIY_EXPORT vtkDIYUtilities : public vtkObject
52{
53public:
54 vtkTypeMacro(vtkDIYUtilities, vtkObject);
55 void PrintSelf(ostream& os, vtkIndent indent) override;
56
62
68 static diy::mpi::communicator GetCommunicator(vtkMultiProcessController* controller);
69
71
74 static void Save(diy::BinaryBuffer& bb, vtkDataSet*);
75 static void Load(diy::BinaryBuffer& bb, vtkDataSet*&);
77
79
82 static void Save(diy::BinaryBuffer& bb, vtkFieldData*);
83 static void Load(diy::BinaryBuffer& bb, vtkFieldData*&);
85
87
90 static void Save(diy::BinaryBuffer& bb, vtkStringArray*);
91 static void Load(diy::BinaryBuffer& bb, vtkStringArray*&);
93
95
98 static void Save(diy::BinaryBuffer& bb, vtkDataArray*);
99 static void Load(diy::BinaryBuffer& bb, vtkDataArray*&);
101
105 static void AllReduce(diy::mpi::communicator& comm, vtkBoundingBox& bbox);
106
113 static diy::ContinuousBounds Convert(const vtkBoundingBox& bbox);
114
121 static vtkBoundingBox Convert(const diy::ContinuousBounds& bds);
122
127 static void Broadcast(
128 diy::mpi::communicator& comm, std::vector<vtkBoundingBox>& boxes, int source);
129
136 template <class DataSetT = vtkDataSet>
137 VTK_DEPRECATED_IN_9_1_0("Use vtkCompositeDataSet::GetDataSets instead")
138 static std::vector<DataSetT*> GetDataSets(vtkDataObject* dobj);
139
141
147 static std::vector<vtkSmartPointer<vtkPoints>> ExtractPoints(
148 const std::vector<vtkDataSet*>& datasets, bool use_cell_centers);
150
154 static vtkBoundingBox GetLocalBounds(vtkDataObject* dobj);
155
164 template <class DummyT>
165 static void Link(diy::Master& master, const diy::Assigner& assigner,
166 const std::vector<std::map<int, DummyT>>& linksMap);
167
168 static void Link(
169 diy::Master& master, const diy::Assigner& assigner, const std::vector<std::set<int>>& linksMap);
170
171protected:
173 ~vtkDIYUtilities() override;
174
175private:
176 vtkDIYUtilities(const vtkDIYUtilities&) = delete;
177 void operator=(const vtkDIYUtilities&) = delete;
178};
179
180namespace diy
181{
182template <>
184{
185 static void save(BinaryBuffer& bb, vtkDataSet* const& p) { vtkDIYUtilities::Save(bb, p); }
186 static void load(BinaryBuffer& bb, vtkDataSet*& p) { vtkDIYUtilities::Load(bb, p); }
187};
188
189template <>
191{
192 static void save(BinaryBuffer& bb, vtkDataArray* const& da) { vtkDIYUtilities::Save(bb, da); }
193 static void load(BinaryBuffer& bb, vtkDataArray*& da) { vtkDIYUtilities::Load(bb, da); }
194};
195
196template <>
198{
199 static void save(BinaryBuffer& bb, vtkFieldData* const& fd) { vtkDIYUtilities::Save(bb, fd); }
200 static void load(BinaryBuffer& bb, vtkFieldData*& fd) { vtkDIYUtilities::Load(bb, fd); }
201};
202}
203
204// Implementation detail for Schwarz counter idiom.
205class VTKPARALLELDIY_EXPORT vtkDIYUtilitiesCleanup
206{
207public:
210
211private:
213 void operator=(const vtkDIYUtilitiesCleanup&) = delete;
214};
216
217#include "vtkDIYUtilities.txx" // for template implementations
218
219#endif
Fast, simple class for representing and operating on 3D bounds.
collection of helper functions for working with DIY
static void Broadcast(diy::mpi::communicator &comm, std::vector< vtkBoundingBox > &boxes, int source)
Broadcast a vector of bounding boxes.
static void Load(diy::BinaryBuffer &bb, vtkFieldData *&)
Load/Save a vtkFieldData in a diy::BinaryBuffer.
static void Load(diy::BinaryBuffer &bb, vtkStringArray *&)
Load/Save a vtkStringArray in a diy::BinaryBuffer.
static void InitializeEnvironmentForDIY()
In MPI-enabled builds, DIY filters need MPI to be initialized.
static vtkBoundingBox Convert(const diy::ContinuousBounds &bds)
Convert diy::ContinuousBounds to vtkBoundingBox.
static void Save(diy::BinaryBuffer &bb, vtkFieldData *)
Load/Save a vtkFieldData in a diy::BinaryBuffer.
static void Save(diy::BinaryBuffer &bb, vtkDataArray *)
Load/Save a vtkDataArray in a diy::BinaryBuffer.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
static void Save(diy::BinaryBuffer &bb, vtkStringArray *)
Load/Save a vtkStringArray in a diy::BinaryBuffer.
static void Load(diy::BinaryBuffer &bb, vtkDataSet *&)
Load/Save a vtkDataSet in a diy::BinaryBuffer.
static void Load(diy::BinaryBuffer &bb, vtkDataArray *&)
Load/Save a vtkDataArray in a diy::BinaryBuffer.
static diy::ContinuousBounds Convert(const vtkBoundingBox &bbox)
Convert vtkBoundingBox to diy::ContinuousBounds.
static void Save(diy::BinaryBuffer &bb, vtkDataSet *)
Load/Save a vtkDataSet in a diy::BinaryBuffer.
static void AllReduce(diy::mpi::communicator &comm, vtkBoundingBox &bbox)
Reduce bounding box.
static diy::mpi::communicator GetCommunicator(vtkMultiProcessController *controller)
Converts a vtkMultiProcessController to a diy::mpi::communicator.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:159
general representation of visualization data
abstract class to specify dataset behavior
Definition: vtkDataSet.h:166
represent and manipulate fields of data
Definition: vtkFieldData.h:164
a simple class to control print indentation
Definition: vtkIndent.h:113
Multiprocessing communication superclass.
abstract base class for most VTK objects
Definition: vtkObject.h:73
represent and manipulate 3D points
Definition: vtkPoints.h:143
Hold a reference to a vtkObjectBase instance.
a vtkAbstractArray subclass for strings
@ vector
Definition: vtkX3D.h:243
static void save(BinaryBuffer &bb, vtkDataArray *const &da)
static void load(BinaryBuffer &bb, vtkDataArray *&da)
static void save(BinaryBuffer &bb, vtkDataSet *const &p)
static void load(BinaryBuffer &bb, vtkDataSet *&p)
static void load(BinaryBuffer &bb, vtkFieldData *&fd)
static void save(BinaryBuffer &bb, vtkFieldData *const &fd)
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
static vtkDIYUtilitiesCleanup vtkDIYUtilitiesCleanupInstance
#define VTK_DEPRECATED_IN_9_1_0(reason)