Skip to content

Commit

Permalink
Merge pull request libMesh#3185 from roystgnr/exodus_dg_offset
Browse files Browse the repository at this point in the history
Factor out push_node, respect offset
  • Loading branch information
roystgnr authored Mar 9, 2022
2 parents 416a9b8 + 8c8ee05 commit bbb582f
Showing 1 changed file with 17 additions and 22 deletions.
39 changes: 17 additions & 22 deletions src/mesh/exodusII_io_helper.C
Original file line number Diff line number Diff line change
Expand Up @@ -2118,6 +2118,21 @@ void ExodusII_IO_Helper::write_nodal_coordinates(const MeshBase & mesh, bool use
y.reserve(num_nodes);
z.reserve(num_nodes);

auto push_node = [this](const Point & p) {
x.push_back(p(0) + _coordinate_offset(0));

#if LIBMESH_DIM > 1
y.push_back(p(1) + _coordinate_offset(1));
#else
y.push_back(0.);
#endif
#if LIBMESH_DIM > 2
z.push_back(p(2) + _coordinate_offset(2));
#else
z.push_back(0.);
#endif
};

// And in the node_num_map - since the nodes aren't organized in
// blocks, libmesh will always write out the identity map
// here... unless there has been some refinement and coarsening, or
Expand All @@ -2135,18 +2150,8 @@ void ExodusII_IO_Helper::write_nodal_coordinates(const MeshBase & mesh, bool use
{
const Node & node = *node_ptr;

x.push_back(node(0) + _coordinate_offset(0));
push_node(node);

#if LIBMESH_DIM > 1
y.push_back(node(1) + _coordinate_offset(1));
#else
y.push_back(0.);
#endif
#if LIBMESH_DIM > 2
z.push_back(node(2) + _coordinate_offset(2));
#else
z.push_back(0.);
#endif

// Fill in node_num_map entry with the proper (1-based) node id
node_num_map.push_back(node.id() + 1);
Expand All @@ -2162,17 +2167,7 @@ void ExodusII_IO_Helper::write_nodal_coordinates(const MeshBase & mesh, bool use
for (const auto & elem : mesh.active_element_ptr_range())
for (const Node & node : elem->node_ref_range())
{
x.push_back(node(0));
#if LIBMESH_DIM > 1
y.push_back(node(1));
#else
y.push_back(0.);
#endif
#if LIBMESH_DIM > 2
z.push_back(node(2));
#else
z.push_back(0.);
#endif
push_node(node);

// Let's skip the node_num_map in the discontinuous
// case, since we're effectively duplicating nodes for
Expand Down

0 comments on commit bbb582f

Please sign in to comment.