28 #include "libmesh/libmesh_config.h"
29 #include "libmesh/fro_io.h"
30 #include "libmesh/mesh_base.h"
31 #include "libmesh/boundary_info.h"
32 #include "libmesh/elem.h"
47 if (this->
mesh().processor_id() == 0)
50 std::ofstream out_stream (fname.c_str());
54 if (!out_stream.good())
55 libmesh_file_error(fname.c_str());
61 out_stream << the_mesh.
n_elem() <<
" "
68 out_stream << n+1 <<
" \t"
71 << the_mesh.
point(n)(0) <<
" \t"
72 << the_mesh.
point(n)(1) <<
" \t"
80 if (elem->type() !=
TRI3)
81 libmesh_error_msg(
"ERROR: .fro format only valid for triangles!\n" \
82 <<
" writing of " << fname <<
" aborted.");
84 out_stream << ++e <<
" \t";
86 for (
const Node & node : elem->node_ref_range())
87 out_stream << node.id()+1 <<
" \t";
99 const std::set<boundary_id_type> & bc_ids =
108 for (
const auto &
id : bc_ids)
110 std::deque<dof_id_type> node_list;
112 std::map<dof_id_type, dof_id_type>
113 forward_edges, backward_edges;
116 for (
const auto & t : bc_triples)
117 if (std::get<2>(t) ==
id)
134 std::unique_ptr<const Elem> side =
138 n0 = side->node_id(0),
139 n1 = side->node_id(1);
142 forward_edges.insert (std::make_pair(n0, n1));
145 backward_edges.insert (std::make_pair(n1, n0));
149 if (node_list.empty())
151 node_list.push_front(n0);
152 node_list.push_back (n1);
160 const std::size_t n_edges = forward_edges.size();
162 while (node_list.size() != (n_edges+1))
165 front_node = node_list.front(),
166 back_node = node_list.back();
170 auto pos = backward_edges.find(front_node);
172 if (pos != backward_edges.end())
174 node_list.push_front(pos->second);
176 backward_edges.erase(pos);
182 auto pos = forward_edges.find(back_node);
184 if (pos != forward_edges.end())
186 node_list.push_back(pos->second);
188 forward_edges.erase(pos);
193 out_stream << ++bc_id <<
" " << node_list.size() <<
'\n';
195 for (
const auto & node_id : node_list)
196 out_stream << node_id + 1 <<
" \t0\n";