DataAdaptor.h 2.11 KB
Newer Older
1 2 3
#ifndef PARALLEL3D_DATAADAPTOR_H
#define PARALLEL3D_DATAADAPTOR_H

Burlen Loring's avatar
Burlen Loring committed
4 5 6
#include "sensei/DataAdaptor.h"

#include <vtkSmartPointer.h>
7 8
#include <map>
#include <string>
Utkarsh Ayachit's avatar
Utkarsh Ayachit committed
9
#include <cstdint>
10 11

class vtkDoubleArray;
12
class vtkImageData;
13 14 15 16 17 18

namespace parallel3d
{
/// DataAdaptor is an adaptor for the parallel_3d simulation (miniapp).
/// Its purpose is to map the simulation datastructures to VTK
/// data model.
19
class DataAdaptor : public sensei::DataAdaptor
20 21 22
{
public:
  static DataAdaptor* New();
Burlen Loring's avatar
Burlen Loring committed
23
  senseiTypeMacro(DataAdaptor, sensei::DataAdaptor);
24 25

  /// Initialize the data adaptor.
Burlen Loring's avatar
Burlen Loring committed
26
  void Initialize(int g_x, int g_y, int g_z, int l_x, int l_y, int l_z,
27 28 29 30 31 32 33 34 35 36
    uint64_t start_extents_x, uint64_t start_extents_y, uint64_t start_extents_z,
    int tot_blocks_x, int tot_blocks_y, int tot_blocks_z,
    int block_id_x, int block_id_y, int block_id_z);

  /// Set the pointers to simulation memory.
  void AddArray(const std::string& name, double* data);

  /// Clear all arrays.
  void ClearArrays();

Burlen Loring's avatar
Burlen Loring committed
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
  // SENSEI API
  int GetNumberOfMeshes(unsigned int &numMeshes) override;

  int GetMeshName(unsigned int id, std::string &meshName) override;

  int GetMesh(const std::string &meshName, bool structureOnly,
    vtkDataObject *&mesh) override;

  int AddArray(vtkDataObject* mesh, const std::string &meshName,
    int association, const std::string &arrayName) override;

  int GetNumberOfArrays(const std::string &meshName, int association,
    unsigned int &numberOfArrays) override;

  int GetArrayName(const std::string &meshName, int association,
    unsigned int index, std::string &arrayName) override;

  int ReleaseData() override;
55 56 57

protected:
  DataAdaptor();
Burlen Loring's avatar
Burlen Loring committed
58
  ~DataAdaptor();
59

Burlen Loring's avatar
Burlen Loring committed
60 61 62 63
  using VariablesType = std::map<std::string, double*>;
  using ArraysType = std::map<std::string, vtkSmartPointer<vtkDoubleArray>>;
  using vtkImageDataPtr = vtkSmartPointer<vtkImageData>;
  using vtkDoubleArrayPtr = vtkSmartPointer<vtkDoubleArray>;
64

Burlen Loring's avatar
Burlen Loring committed
65
  VariablesType Variables;
66
  ArraysType Arrays;
Burlen Loring's avatar
Burlen Loring committed
67
  vtkImageDataPtr Mesh;
68 69
  int CellExtent[6];
  int WholeExtent[6];
Burlen Loring's avatar
Burlen Loring committed
70

71
private:
Burlen Loring's avatar
Burlen Loring committed
72 73
  DataAdaptor(const DataAdaptor&) = delete;
  void operator=(const DataAdaptor&) = delete;
74 75 76 77 78
};

}

#endif