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
|
// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
// SPDX-License-Identifier: BSD-3-Clause
/*
* vtkADIOS2VTXReader.cxx
*
* Created on: May 1, 2019
* Author: William F Godoy godoywf@ornl.gov
*/
#include "vtkADIOS2VTXReader.h"
#include "VTX/VTXSchemaManager.h"
#include "VTX/common/VTXHelper.h"
#include "vtkIndent.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
#include "vtkMultiProcessController.h"
#include "vtkObjectFactory.h"
#include "vtkStreamingDemandDrivenPipeline.h"
VTK_ABI_NAMESPACE_BEGIN
vtkStandardNewMacro(vtkADIOS2VTXReader);
vtkADIOS2VTXReader::vtkADIOS2VTXReader()
: FileName(nullptr)
, SchemaManager(new vtx::VTXSchemaManager)
{
this->SetNumberOfInputPorts(0);
this->SetNumberOfOutputPorts(1);
}
vtkADIOS2VTXReader::~vtkADIOS2VTXReader()
{
this->SetFileName(nullptr);
}
int vtkADIOS2VTXReader::RequestInformation(vtkInformation* vtkNotUsed(inputVector),
vtkInformationVector** vtkNotUsed(inputVector), vtkInformationVector* outputVector)
{
try
{
this->SchemaManager->Update(FileName); // check if FileName changed
// set time info
const std::vector<double> vTimes =
vtx::helper::MapKeysToVector(this->SchemaManager->Reader->Times);
vtkInformation* info = outputVector->GetInformationObject(0);
info->Set(vtkStreamingDemandDrivenPipeline::TIME_STEPS(), vTimes.data(),
static_cast<int>(vTimes.size()));
const std::vector<double> timeRange = { vTimes.front(), vTimes.back() };
info->Set(vtkStreamingDemandDrivenPipeline::TIME_RANGE(), timeRange.data(),
static_cast<int>(timeRange.size()));
}
catch (std::exception& e)
{
vtkErrorMacro("Error loading ADIOS2 schema: " << e.what());
return 0;
}
return 1;
}
int vtkADIOS2VTXReader::RequestUpdateExtent(
vtkInformation*, vtkInformationVector**, vtkInformationVector* outputVector)
{
try
{
vtkInformation* info = outputVector->GetInformationObject(0);
const double newTime = info->Get(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP());
this->SchemaManager->Step = this->SchemaManager->Reader->Times[newTime];
this->SchemaManager->Time = newTime;
}
catch (std::exception& e)
{
vtkErrorMacro("Error loading ADIOS2 schema: " << e.what());
return 0;
}
return 1;
}
int vtkADIOS2VTXReader::RequestData(vtkInformation* vtkNotUsed(inputVector),
vtkInformationVector** vtkNotUsed(inputVector), vtkInformationVector* outputVector)
{
try
{
vtkInformation* info = outputVector->GetInformationObject(0);
vtkDataObject* output = info->Get(vtkDataObject::DATA_OBJECT());
vtkMultiBlockDataSet* multiBlock = vtkMultiBlockDataSet::SafeDownCast(output);
output->GetInformation()->Set(vtkDataObject::DATA_TIME_STEP(), this->SchemaManager->Time);
this->SchemaManager->Fill(multiBlock, this->SchemaManager->Step);
}
catch (std::exception& e)
{
vtkErrorMacro("Error loading ADIOS2 schema: " << e.what());
return 0;
}
return 1;
}
void vtkADIOS2VTXReader::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
os << indent << "File Name: " << (this->FileName ? this->FileName : "(none)") << "\n";
}
VTK_ABI_NAMESPACE_END
|