7#include <vtkSmartPointer.h>
8#include <vtkUnstructuredGrid.h>
9#include <vtkEnSightGoldBinaryReader.h>
10#include <vtkMultiBlockDataSet.h>
12#include <vtkInformation.h>
17#define ErrorReadingFile(fname) \
18std::runtime_error("Failed to open file: " + options.file_name + \
19" in call to " + #fname + ".")
37 reader->SetCaseFileName(options.
file_name.c_str());
39 if (not reader->CanReadFile(options.
file_name.c_str()))
40 throw std::logic_error(
"Unable to read file-type with this routine");
41 reader->UpdateInformation();
45 auto multiblock = reader->GetOutput();
47 std::vector<vtkUGridPtrAndName> grid_blocks;
48 auto iter_a = multiblock->NewIterator();
49 iter_a->GoToFirstItem();
50 while (not iter_a->IsDoneWithTraversal())
52 auto block_a = iter_a->GetCurrentDataObject();
55 iter_a->GetCurrentMetaData()->Get(vtkCompositeDataSet::NAME()));
57 if (block_a->GetDataObjectType() == VTK_UNSTRUCTURED_GRID)
59 grid_blocks.emplace_back(
60 vtkUnstructuredGrid::SafeDownCast(block_a),
62 iter_a->GetCurrentMetaData()->Get(vtkCompositeDataSet::NAME())));
65 <<
"Reading block " << block_name
66 <<
" Number of cells: " << grid_blocks.back().first->GetNumberOfCells()
67 <<
" Number of points: " << grid_blocks.back().first->GetNumberOfPoints();
70 iter_a->GoToNextItem();
76 std::vector<vtkUGridPtrAndName> domain_grid_blocks =
78 std::vector<vtkUGridPtrAndName> bndry_grid_blocks =
93 switch (max_dimension)
109 Chi::log.
Log() <<
"Done reading Ensight-Gold file: "
LogStream Log(LOG_LVL level=LOG_0)
void ComputeCentroidsAndCheckQuality()
void BuildMeshConnectivity()
void CopyUGridCellsAndPoints(vtkUnstructuredGrid &ugrid, double scale, int dimension_to_copy)
void ReadFromEnsightGold(const Options &options)
void SetBoundaryIDsFromBlocks(std::vector< vtkUGridPtrAndName > &bndry_grid_blocks)
MeshAttributes attributes_
vtkUGridPtr ConsolidateGridBlocks(std::vector< vtkUGridPtrAndName > &ugrid_blocks, const std::string &block_id_array_name="BlockID")
void SetBlockIDArrays(std::vector< vtkUGridPtrAndName > &ugrid_blocks)
int FindHighestDimension(std::vector< vtkUGridPtrAndName > &ugrid_blocks)
std::vector< vtkUGridPtrAndName > GetBlocksOfDesiredDimension(std::vector< vtkUGridPtrAndName > &ugrid_blocks, int desired_dimension)
std::string StringTrim(const std::string &s)
#define ErrorReadingFile(fname)