Commit ab244c3e authored by David E. DeMarle's avatar David E. DeMarle Committed by David E. DeMarle

A new reader for GE/LANL's TRUCHAS simulation files

Truchas is a 3D Multiphysics Simulation of Metal Casting and Processing
Read about it here: https://github.com/truchas

fill out boilerplate to begin a reader
hook in hdf5 and read actual geometry
read in real topology
start on time and attributes
hook up temporal dimension
hook up block segregation
start to cleanup
caching hdf5 fd, timesteps, and geometry now.
cache blockids and topology array
cleanup cell and block construction
  reorder loop to traverse longest (cells) once and shortest
  (blocks) repeatedly
clean up access to timestep and check array types
get array names early and reuse
  will allow GUI to select which to load
  also simplifies heavy data reading code
start to hook up array and block selection, fix a point array bug
hook up block selection
take a swipe at comp warnings
fix garbage arrays
correct point arrays
   Essentially I forgot before that point data doesn't have to be
   split up into various block.
   In next optimization pass I will do this much more cleanly.
optimize by caching blocks and topology
remove the onerous string compares on every cell to optimize
fix bug where skipping blocks resulted in no blocks being loaded
keep one master set of point aligned arrays and share it
let arrays be either double or int
fix comp warnings
prevent stale arrays from hanging around once unselected
run the doxy and spacing scripts to modernize style
parent 913c8953
set(Module_SRCS
vtkTRUCHASReader.cxx
)
vtk_module_library(vtkIOTRUCHAS ${Module_SRCS})
vtk_add_test_cxx(${vtk-module}CxxTests tests
TestTRUCHASReader.cxx,NO_VALID
)
vtk_test_cxx_executable(${vtk-module}CxxTests tests
RENDERING_FACTORY
)
/*=========================================================================
Program: Visualization Toolkit
Module: TestTRUCHASReader.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// Input test to validate ability to read GE TRUCHAS files
#include "vtkMultiBlockDataSet.h"
#include "vtkNew.h"
#include "vtkTesting.h"
#include "vtkTRUCHASReader.h"
#include "vtkUnstructuredGrid.h"
int TestTRUCHASReader(int argc, char *argv[])
{
// Load the initial dataset:
vtkNew<vtkTesting> testing;
testing->AddArguments(argc, argv);
std::string filename = testing->GetDataRoot();
filename = "/home/demarle/Downloads/moving_rod/moving_rod.h5";
vtkNew<vtkTRUCHASReader> reader;
reader->SetFileName(filename.c_str());
reader->Update();
vtkUnstructuredGrid *grid = vtkUnstructuredGrid::SafeDownCast
(reader->GetOutput()->GetBlock(0));
if (!grid || grid->GetNumberOfPoints()==0)
{
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
vtk_module(vtkIOTRUCHAS
DEPENDS
vtkCommonExecutionModel
PRIVATE_DEPENDS
vtkhdf5
TEST_DEPENDS
vtkTestingCore
vtkTestingRendering
)
This diff is collapsed.
/*=========================================================================
Program: Visualization Toolkit
Module: vtkTRUCHASReader.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
/**
* @class vtkTRUCHASReader
* @brief read GE TRUCHAS format HDF5 files
*
* vtkTRUCHASReader is a source object that reads TRUCHAS simulation
* data from HDF5 files.
*/
#ifndef vtkTRUCHASReader_h
#define vtkTRUCHASReader_h
#include "vtkIOTRUCHASModule.h" // For export macro
#include "vtkMultiBlockDataSetAlgorithm.h"
class vtkDataArraySelection;
class VTKIOTRUCHAS_EXPORT vtkTRUCHASReader
: public vtkMultiBlockDataSetAlgorithm
{
public:
static vtkTRUCHASReader *New();
vtkTypeMacro(vtkTRUCHASReader,vtkMultiBlockDataSetAlgorithm);
void PrintSelf(ostream& os, vtkIndent indent);
//@{
/**
* Specify file name of vtk data file to read.
*/
vtkSetStringMacro(FileName);
vtkGetStringMacro(FileName);
//@}
/**
* A simple, non-exhaustive check to see if a file is a valid truchas file.
*/
static int CanReadFile(const char *filename);
//@{
/**
* Get/Set information about blocks. As is typical with readers this is valid
* only after the filename as been set and UpdateInformation() has been
* called.
*/
int GetNumberOfBlockArrays();
const char* GetBlockArrayName(int index);
void SetBlockArrayStatus(const char* gridname, int status);
int GetBlockArrayStatus(const char* gridname);
//@}
/**
* Get information about point-based arrays. As is typical with readers this
* in only valid after the filename is set and UpdateInformation() has been
* called.
*/
int GetNumberOfPointArrays();
/**
* Returns the name of point array at the give index. Returns NULL if index is
* invalid.
*/
const char* GetPointArrayName(int index);
//@{
/**
* Get/Set the point array status.
*/
int GetPointArrayStatus(const char* name);
void SetPointArrayStatus(const char* name, int status);
//@}
/**
* Get information about cell-based arrays. As is typical with readers this
* in only valid after the filename is set and UpdateInformation() has been
* called.
*/
int GetNumberOfCellArrays();
/**
* Returns the name of cell array at the give index. Returns NULL if index is
* invalid.
*/
const char* GetCellArrayName(int index);
//@{
/**
* Get/Set the cell array status.
*/
int GetCellArrayStatus(const char* name);
void SetCellArrayStatus(const char* name, int status);
//@}
protected:
vtkTRUCHASReader();
~vtkTRUCHASReader();
/**
* Overridden to announce timesteps we can produce
*/
virtual int RequestInformation(vtkInformation *, vtkInformationVector **,
vtkInformationVector *);
/**
* Overridden to read the file and parse into an output
*/
virtual int RequestData(vtkInformation *, vtkInformationVector **,
vtkInformationVector *);
char *FileName;
class Internal;
Internal * Internals;
friend class Internal;
vtkDataArraySelection* BlockChoices;
vtkDataArraySelection* PointArrayChoices;
vtkDataArraySelection* CellArrayChoices;
private:
vtkTRUCHASReader(const vtkTRUCHASReader&) VTK_DELETE_FUNCTION;
void operator=(const vtkTRUCHASReader&) VTK_DELETE_FUNCTION;
};
#endif
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