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" 77 for (
const auto & elem : the_mesh.active_element_ptr_range())
80 libmesh_error_msg_if(elem->type() !=
TRI3,
81 "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.emplace(n0, n1);
145 backward_edges.emplace(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();
169 if (
const auto pos = backward_edges.find(front_node);
170 pos != backward_edges.end())
172 node_list.push_front(pos->second);
173 backward_edges.erase(pos);
177 if (
const auto pos = forward_edges.find(back_node);
178 pos != forward_edges.end())
180 node_list.push_back(pos->second);
181 forward_edges.erase(pos);
185 out_stream << ++bc_id <<
" " << node_list.size() <<
'\n';
187 for (
const auto & node_id : node_list)
188 out_stream << node_id + 1 <<
" \t0\n";
const MeshBase & mesh() const
A Node is like a Point, but with more information.
virtual std::unique_ptr< Elem > build_side_ptr(const unsigned int i)=0
const bool _is_parallel_format
Flag specifying whether this format is parallel-capable.
unsigned int & ascii_precision()
Return/set the precision to use when writing ASCII files.
The libMesh namespace provides an interface to certain functionality in the library.
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
This is the MeshBase class.
std::size_t n_boundary_ids() const
void build_side_list(std::vector< dof_id_type > &element_id_list, std::vector< unsigned short int > &side_list, std::vector< boundary_id_type > &bc_id_list) const
Creates a list of element numbers, sides, and ids for those sides.
virtual void write(const std::string &) override
This method implements writing a mesh to a specified file.
const std::set< boundary_id_type > & get_boundary_ids() const
Temporarily serialize a DistributedMesh for non-distributed-mesh capable code paths.
virtual const Elem & elem_ref(const dof_id_type i) const
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
virtual const Point & point(const dof_id_type i) const =0
virtual dof_id_type n_elem() const =0
virtual dof_id_type n_nodes() const =0