From 753a6f849d73ce83114c90ea86d1ef4d7e98dbeb Mon Sep 17 00:00:00 2001 From: Maximilian Bergbauer Date: Mon, 7 Jun 2021 16:59:12 +0200 Subject: [PATCH] Add grid reordering to read_exodusii function --- source/grid/grid_in.cc | 15 +++++++++++++++ ..._exodusii.with_trilinos_with_seacas=on.output | 16 ++++++++-------- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/source/grid/grid_in.cc b/source/grid/grid_in.cc index 1edbd5263b..a49a6af20f 100644 --- a/source/grid/grid_in.cc +++ b/source/grid/grid_in.cc @@ -3251,6 +3251,8 @@ GridIn::read_exodusii( ierr = ex_get_ids(ex_id, EX_ELEM_BLOCK, element_block_ids.data()); AssertThrowExodusII(ierr); + bool is_only_quad_or_hex = true; + std::vector> cells; // Elements are grouped together by same reference cell type in element // blocks. There may be multiple blocks for a single reference cell type, @@ -3278,6 +3280,9 @@ GridIn::read_exodusii( const ReferenceCell type = exodusii_name_to_type(string_temp.data(), n_nodes_per_element); + if (type.is_simplex()) + is_only_quad_or_hex = false; + // The number of nodes per element may be larger than what we want to // read - for example, if the Exodus file contains a QUAD9 element, we // only want to read the first four values and ignore the rest. @@ -3312,6 +3317,16 @@ GridIn::read_exodusii( ierr = ex_close(ex_id); AssertThrowExodusII(ierr); + if (is_only_quad_or_hex) + { + // do some clean-up on vertices... + GridTools::delete_unused_vertices(vertices, cells, pair.first); + // ... and cells + if (dim == spacedim) + GridTools::invert_all_negative_measure_cells(vertices, cells); + GridTools::consistently_order_cells(cells); + } + tria->create_triangulation(vertices, cells, pair.first); ExodusIIData out; out.id_to_sideset_ids = std::move(pair.second); diff --git a/tests/grid/grid_in_exodusii.with_trilinos_with_seacas=on.output b/tests/grid/grid_in_exodusii.with_trilinos_with_seacas=on.output index 82867988ed..95fdbf3a5c 100644 --- a/tests/grid/grid_in_exodusii.with_trilinos_with_seacas=on.output +++ b/tests/grid/grid_in_exodusii.with_trilinos_with_seacas=on.output @@ -27,14 +27,14 @@ POINTS 8 double 7.0 7.0 0 CELLS 8 34 -4 0 1 2 3 -4 2 1 7 6 -4 4 6 7 5 -4 0 3 4 5 -4 3 2 6 4 -2 0 1 -2 0 5 -2 1 7 +4 2 3 0 1 +4 6 2 1 7 +4 6 7 5 4 +4 4 5 0 3 +4 6 4 3 2 +2 1 0 +2 5 0 +2 7 1 CELL_TYPES 8 9 9 9 9 9 -- 2.39.5