File: vtkMultiTimeStepAlgorithm.h

package info (click to toggle)
vtk9 9.5.2%2Bdfsg3-4
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 205,916 kB
  • sloc: cpp: 2,336,565; ansic: 327,116; python: 111,200; yacc: 4,104; java: 3,977; sh: 3,032; xml: 2,771; perl: 2,189; lex: 1,787; makefile: 178; javascript: 165; objc: 153; tcl: 59
file content (128 lines) | stat: -rw-r--r-- 4,229 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
// SPDX-License-Identifier: BSD-3-Clause
/**
 * @class vtkMultiTimeStepAlgorithm
 * @brief Superclass for algorithms that would like to make multiple time requests
 *
 * This class can be inherited by any algorithm that wishes to make multiple
 * time requests upstream.
 *
 * A subclass should override `RequestUpdateExtent` and use
 * `vtkMultiTimeStepAlgorithm::UPDATE_TIME_STEPS` key to indicate which
 * timesteps are to be requested. This class will then take care of executing
 * the upstream pipeline to obtain the requested timesteps.
 *
 * Subclasses can then override `Execute` which is provided a vector of input
 * data objects corresponding to the requested timesteps.
 *
 * In VTK 9.1 and earlier, subclasses overrode `RequestData` instead of
 * `Execute`. RequestData was passed a `vtkMultiBlockDataSet` with blocks corresponding
 * to the input timesteps. However, with addition of vtkPartitionedDataSet and
 * vtkPartitionedDataSetCollection in VTK 9.2, it is not possible to package all
 * input data types into a multiblock dataset. Hence, the method is deprecated
 * and only used when `Execute` is not overridden.
 */

#ifndef vtkMultiTimeStepAlgorithm_h
#define vtkMultiTimeStepAlgorithm_h

#include "vtkAlgorithm.h"
#include "vtkCommonExecutionModelModule.h" // For export macro
#include "vtkSmartPointer.h"               //needed for a private variable

#include "vtkDataObject.h" // needed for the smart pointer
#include <vector>          //needed for a private variable

VTK_ABI_NAMESPACE_BEGIN
class vtkInformationDoubleVectorKey;
class vtkMultiBlockDataSet;
class VTKCOMMONEXECUTIONMODEL_EXPORT vtkMultiTimeStepAlgorithm : public vtkAlgorithm
{
public:
  static vtkMultiTimeStepAlgorithm* New();
  vtkTypeMacro(vtkMultiTimeStepAlgorithm, vtkAlgorithm);
  void PrintSelf(ostream& os, vtkIndent indent) override;

protected:
  vtkMultiTimeStepAlgorithm();

  ~vtkMultiTimeStepAlgorithm() override = default;

  /**
   * This is filled by the child class to request multiple time steps
   */
  static vtkInformationDoubleVectorKey* UPDATE_TIME_STEPS();

  ///@{
  /**
   * This is called by the superclass.
   * This is the method you should override.
   */
  virtual int RequestDataObject(vtkInformation*, vtkInformationVector**, vtkInformationVector*)
  {
    return 1;
  }
  ///@}

  ///@{
  /**
   * This is called by the superclass.
   * This is the method you should override.
   */
  virtual int RequestInformation(vtkInformation*, vtkInformationVector**, vtkInformationVector*)
  {
    return 1;
  }
  ///@}

  /**
   * Subclasses should override this method to do the actual execution.
   * For backwards compatibility, the default implementation returns -1. If -1
   * is returned, its assumed that this method is not overridden and the
   * `RequestData` must be called, if possible. However, `RequestData` is only
   * supported if input type is not vtkPartitionedDataSetCollection or
   * vtkPartitionedDataSet.
   */
  virtual int Execute(vtkInformation* vtkNotUsed(request),
    const std::vector<vtkSmartPointer<vtkDataObject>>& vtkNotUsed(inputs),
    vtkInformationVector* vtkNotUsed(outputVector))
  {
    return -1;
  }

  /**
   * This is called by the superclass.
   * This is the method you should override.
   */
  virtual int RequestUpdateExtent(vtkInformation*, vtkInformationVector**, vtkInformationVector*)
  {
    return 1;
  }

  vtkTypeBool ProcessRequest(
    vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;

  bool CacheData;
  unsigned int NumberOfCacheEntries;

private:
  vtkMultiTimeStepAlgorithm(const vtkMultiTimeStepAlgorithm&) = delete;
  void operator=(const vtkMultiTimeStepAlgorithm&) = delete;
  int RequestUpdateIndex;              // keep track of the time looping index
  std::vector<double> UpdateTimeSteps; // store the requested time steps
  bool IsInCache(double time, size_t& idx);
  struct TimeCache
  {
    TimeCache(double time, vtkDataObject* data)
      : TimeValue(time)
      , Data(data)
    {
    }
    double TimeValue;
    vtkSmartPointer<vtkDataObject> Data;
  };
  std::vector<TimeCache> Cache;
};

VTK_ABI_NAMESPACE_END
#endif