Commit e5e7b88a authored by Utkarsh Ayachit's avatar Utkarsh Ayachit

Add Catalyst analysis to parallel3d.

parallel3d now uses cell-data for passing arrays since they are more
like cells in vtk image data than points.
parent b3377d47
......@@ -14,10 +14,12 @@
=========================================================================*/
#include "vtkInsituDataAdaptor.h"
#include "vtkObjectFactory.h"
#include "vtkInformation.h"
#include "vtkDataObject.h"
#include "vtkInformation.h"
#include "vtkInformationIntegerKey.h"
#include "vtkObjectFactory.h"
vtkInformationKeyMacro(vtkInsituDataAdaptor, DATA_TIME_STEP_INDEX, Integer);
//----------------------------------------------------------------------------
vtkInsituDataAdaptor::vtkInsituDataAdaptor()
{
......@@ -43,6 +45,34 @@ void vtkInsituDataAdaptor::SetDataTime(vtkInformation* info, double time)
info->Set(vtkDataObject::DATA_TIME_STEP(), time);
}
//----------------------------------------------------------------------------
int vtkInsituDataAdaptor::GetDataTimeStep(vtkInformation* info)
{
return info->Has(vtkInsituDataAdaptor::DATA_TIME_STEP_INDEX())?
info->Get(vtkInsituDataAdaptor::DATA_TIME_STEP_INDEX()) : 0;
}
//----------------------------------------------------------------------------
void vtkInsituDataAdaptor::SetDataTimeStep(vtkInformation* info, int index)
{
info->Set(vtkInsituDataAdaptor::DATA_TIME_STEP_INDEX(), index);
}
//----------------------------------------------------------------------------
vtkDataObject* vtkInsituDataAdaptor::GetCompleteMesh()
{
vtkDataObject* mesh = this->GetMesh();
for (int attr=vtkDataObject::FIELD_ASSOCIATION_POINTS;
attr < vtkDataObject::NUMBER_OF_ASSOCIATIONS; ++attr)
{
for (unsigned int cc=0, max=this->GetNumberOfArrays(attr); cc < max; ++cc)
{
this->AddArray(mesh, attr, this->GetArrayName(attr, cc));
}
}
return mesh;
}
//----------------------------------------------------------------------------
void vtkInsituDataAdaptor::PrintSelf(ostream& os, vtkIndent indent)
{
......
......@@ -25,9 +25,11 @@
#include "vtkObjectBase.h"
#include "vtkSetGet.h"
class vtkInformation;
class vtkDataObject;
class vtkAbstractArray;
class vtkDataObject;
class vtkInformation;
class vtkInformationIntegerKey;
class vtkInsituDataAdaptor : public vtkObjectBase
{
public:
......@@ -105,6 +107,25 @@ public:
/// @brief Convenience methods to set the time information.
static void SetDataTime(vtkInformation*, double time);
/// @brief Convenience method to get the time index information.
int GetDataTimeStep() { return this->GetDataTimeStep(this->Information); }
/// @brief Convenience method to get the time information.
static int GetDataTimeStep(vtkInformation*);
/// @brief Convenience methods to set the time information.
void SetDataTimeStep(int index) { this->SetDataTimeStep(this->Information, index); }
/// @brief Convenience methods to set the time information.
static void SetDataTimeStep(vtkInformation*, int index);
/// @brief convenience method to get full mesh will all arrays added to the
/// mesh.
vtkDataObject* GetCompleteMesh();
/// @brief Key to store the timestep index.
static vtkInformationIntegerKey* DATA_TIME_STEP_INDEX();
protected:
vtkInsituDataAdaptor();
~vtkInsituDataAdaptor();
......
......@@ -48,6 +48,7 @@ void initialize(MPI_Comm world,
int* to_x, int* to_y, int* to_z)
{
GlobalDataAdaptor->Initialize(nblocks);
GlobalDataAdaptor->SetDataTimeStep(-1);
for (size_t cc=0; cc < n_local_blocks; ++cc)
{
GlobalDataAdaptor->SetBlockExtent(gid[cc],
......@@ -95,6 +96,7 @@ void set_data(int gid, float* data)
void analyze(float time)
{
GlobalDataAdaptor->SetDataTime(time);
GlobalDataAdaptor->SetDataTimeStep(GlobalDataAdaptor->GetDataTimeStep() + 1);
ExecuteGlobalAnalyses();
GlobalDataAdaptor->ReleaseData();
}
......
......@@ -8,6 +8,15 @@
#ifdef ENABLE_HISTOGRAM
#include "HistogramAnalysisAdaptor.h"
#endif
#ifdef ENABLE_ADIOS
#include <vtkADIOSAnalysisAdaptor.h>
#endif
#ifdef ENABLE_CATALYST
#include <vtkCatalystAnalysisAdaptor.h>
# ifdef ENABLE_CATALYST_SLICE
#include <vtkCatalystSlicePipeline.h>
# endif
#endif
#include <vector>
namespace BridgeInternals
......@@ -52,14 +61,31 @@ void bridge_initialize(MPI_Comm comm,
#ifdef ENABLE_HISTOGRAM
vtkNew<HistogramAnalysisAdaptor> histogram[3];
histogram[0]->Initialize(comm, bins, vtkDataObject::FIELD_ASSOCIATION_POINTS, "pressure");
histogram[1]->Initialize(comm, bins, vtkDataObject::FIELD_ASSOCIATION_POINTS, "temperature");
histogram[2]->Initialize(comm, bins, vtkDataObject::FIELD_ASSOCIATION_POINTS, "density");
histogram[0]->Initialize(comm, bins, vtkDataObject::FIELD_ASSOCIATION_CELLS, "pressure");
histogram[1]->Initialize(comm, bins, vtkDataObject::FIELD_ASSOCIATION_CELLS, "temperature");
histogram[2]->Initialize(comm, bins, vtkDataObject::FIELD_ASSOCIATION_CELLS, "density");
BridgeInternals::GlobalAnalyses.push_back(histogram[0].GetPointer());
BridgeInternals::GlobalAnalyses.push_back(histogram[1].GetPointer());
BridgeInternals::GlobalAnalyses.push_back(histogram[2].GetPointer());
#endif
#ifdef ENABLE_ADIOS
vtkNew<vtkADIOSAnalysisAdaptor> adios;
BridgeInternals::GlobalAnalyses.push_back(adios.GetPointer());
#endif
#ifdef ENABLE_CATALYST
vtkNew<vtkCatalystAnalysisAdaptor> catalyst;
BridgeInternals::GlobalAnalyses.push_back(catalyst.GetPointer());
# ifdef ENABLE_CATALYST_SLICE
vtkNew<vtkCatalystSlicePipeline> slicePipeline;
slicePipeline->SetSliceOrigin(g_x/2.0, g_y/2.0, g_z/2.0);
slicePipeline->SetSliceNormal(0, 0, 1);
slicePipeline->ColorBy(vtkDataObject::FIELD_ASSOCIATION_CELLS, "pressure");
catalyst->AddPipeline(slicePipeline.GetPointer());
# endif
#endif
}
//-----------------------------------------------------------------------------
......
......@@ -21,3 +21,9 @@ endif()
if(ENABLE_HISTOGRAM)
target_link_libraries(3D_Grid PRIVATE histogram)
endif()
if(ENABLE_ADIOS)
target_link_libraries(3D_Grid PRIVATE adios)
endif()
if(ENABLE_CATALYST)
target_link_libraries(3D_Grid PRIVATE catalyst)
endif()
#include "DataAdaptor.h"
#include "vtkCellData.h"
#include "vtkDataObject.h"
#include "vtkDoubleArray.h"
#include "vtkImageData.h"
#include "vtkInformation.h"
#include "vtkObjectFactory.h"
#include "vtkPointData.h"
namespace parallel3d
{
......@@ -29,12 +30,22 @@ void DataAdaptor::Initialize(
{
// we only really need to save the local extents for our current example. So
// we'll just save that.
this->Extent[0] = start_extents_x;
this->Extent[1] = start_extents_x + l_x - 1;
this->Extent[2] = start_extents_y;
this->Extent[3] = start_extents_y + l_y - 1;
this->Extent[4] = start_extents_z;
this->Extent[5] = start_extents_z + l_z - 1;
this->CellExtent[0] = start_extents_x;
this->CellExtent[1] = start_extents_x + l_x - 1;
this->CellExtent[2] = start_extents_y;
this->CellExtent[3] = start_extents_y + l_y - 1;
this->CellExtent[4] = start_extents_z;
this->CellExtent[5] = start_extents_z + l_z - 1;
// This is point-based.
this->WholeExtent[0] = 0;
this->WholeExtent[1] = g_x;
this->WholeExtent[2] = 0;
this->WholeExtent[3] = g_y;
this->WholeExtent[4] = 0;
this->WholeExtent[5] = g_z;
this->GetInformation()->Set(vtkDataObject::DATA_EXTENT(),
this->WholeExtent, 6);
}
//-----------------------------------------------------------------------------
......@@ -60,7 +71,10 @@ vtkDataObject* DataAdaptor::GetMesh(bool vtkNotUsed(structure_only))
if (!this->Mesh)
{
this->Mesh = vtkSmartPointer<vtkImageData>::New();
this->Mesh->SetExtent(this->Extent);
this->Mesh->SetExtent(
this->CellExtent[0], this->CellExtent[1] + 1,
this->CellExtent[2], this->CellExtent[3] + 1,
this->CellExtent[4], this->CellExtent[5] + 1);
}
return this->Mesh;
}
......@@ -68,7 +82,7 @@ vtkDataObject* DataAdaptor::GetMesh(bool vtkNotUsed(structure_only))
//-----------------------------------------------------------------------------
bool DataAdaptor::AddArray(vtkDataObject* mesh, int association, const char* name)
{
if (association != vtkDataObject::FIELD_ASSOCIATION_POINTS || name == NULL)
if (association != vtkDataObject::FIELD_ASSOCIATION_CELLS || name == NULL)
{
return false;
}
......@@ -79,17 +93,21 @@ bool DataAdaptor::AddArray(vtkDataObject* mesh, int association, const char* nam
return false;
}
vtkImageData* image = vtkImageData::SafeDownCast(mesh);
assert(image != NULL);
ArraysType::iterator iterA = this->Arrays.find(iterV->first);
if (iterA == this->Arrays.end())
{
vtkSmartPointer<vtkDoubleArray>& vtkarray = this->Arrays[iterV->first];
vtkarray = vtkSmartPointer<vtkDoubleArray>::New();
vtkarray->SetName(name);
const vtkIdType size = (this->Extent[1] - this->Extent[0] + 1) *
(this->Extent[3] - this->Extent[2] + 1) *
(this->Extent[5] - this->Extent[4] + 1);
const vtkIdType size = (this->CellExtent[1] - this->CellExtent[0] + 1) *
(this->CellExtent[3] - this->CellExtent[2] + 1) *
(this->CellExtent[5] - this->CellExtent[4] + 1);
assert(size == image->GetNumberOfCells());
vtkarray->SetArray(iterV->second, size, 1);
vtkImageData::SafeDownCast(mesh)->GetPointData()->SetScalars(vtkarray);
vtkImageData::SafeDownCast(mesh)->GetCellData()->SetScalars(vtkarray);
return true;
}
return true;
......@@ -98,14 +116,14 @@ bool DataAdaptor::AddArray(vtkDataObject* mesh, int association, const char* nam
//-----------------------------------------------------------------------------
unsigned int DataAdaptor::GetNumberOfArrays(int association)
{
return (association == vtkDataObject::FIELD_ASSOCIATION_POINTS)?
return (association == vtkDataObject::FIELD_ASSOCIATION_CELLS)?
static_cast<unsigned int>(this->Variables.size()): 0;
}
//-----------------------------------------------------------------------------
const char* DataAdaptor::GetArrayName(int association, unsigned int index)
{
if (association != vtkDataObject::FIELD_ASSOCIATION_POINTS)
if (association != vtkDataObject::FIELD_ASSOCIATION_CELLS)
{
return NULL;
}
......
......@@ -51,7 +51,8 @@ protected:
ArraysType Arrays;
vtkSmartPointer<vtkImageData> Mesh;
int Extent[6];
int CellExtent[6];
int WholeExtent[6];
private:
DataAdaptor(const DataAdaptor&); // not implemented.
void operator=(const DataAdaptor&); // not implemented.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment