7#include <vtkSmartPointer.h>
8#include <vtkUnstructuredGrid.h>
9#include <vtkExodusIIReader.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->SetFileName(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");
42 reader->UpdateInformation();
46 reader->SetAllArrayStatus(reader->NODE_SET, 1);
47 reader->SetAllArrayStatus(reader->NODE_SET_CONN, 1);
48 reader->SetAllArrayStatus(reader->SIDE_SET, 1);
49 reader->SetAllArrayStatus(reader->SIDE_SET_CONN, 1);
59 reader->SetGenerateGlobalNodeIdArray(
true);
60 reader->SetGenerateGlobalElementIdArray(
true);
72 auto multiblock = reader->GetOutput();
74 std::vector<vtkUGridPtrAndName> grid_blocks;
75 auto iter_a = multiblock->NewIterator();
76 iter_a->GoToFirstItem();
77 while (not iter_a->IsDoneWithTraversal())
79 auto block_a = iter_a->GetCurrentDataObject();
82 iter_a->GetCurrentMetaData()->Get(vtkCompositeDataSet::NAME()));
84 if (block_a->GetDataObjectType() == VTK_UNSTRUCTURED_GRID)
86 grid_blocks.emplace_back(
87 vtkUnstructuredGrid::SafeDownCast(block_a),block_name);
90 <<
"Reading block " << block_name
91 <<
" Number of cells: " << grid_blocks.back().first->GetNumberOfCells()
92 <<
" Number of points: " << grid_blocks.back().first->GetNumberOfPoints();
95 iter_a->GoToNextItem();
101 std::vector<vtkUGridPtrAndName> domain_grid_blocks =
103 std::vector<vtkUGridPtrAndName> bndry_grid_blocks =
116 switch (max_dimension)
LogStream Log(LOG_LVL level=LOG_0)
void ComputeCentroidsAndCheckQuality()
void ReadFromExodus(const Options &options)
void BuildMeshConnectivity()
void CopyUGridCellsAndPoints(vtkUnstructuredGrid &ugrid, double scale, int dimension_to_copy)
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)