40 std::string name_node, name_ele, dummy;
46 libmesh_error_msg(
"Cannot open dimension 3 mesh file when configured without 3D support.");
52 if (
name.rfind(
".node") <
name.size())
56 std::size_t position = dummy.rfind(
".node");
57 name_ele = dummy.replace(position, 5,
".ele");
59 else if (
name.rfind(
".ele") <
name.size())
63 std::size_t position = dummy.rfind(
".ele");
64 name_node = dummy.replace(position, 4,
".node");
67 libmesh_error_msg(
"ERROR: Unrecognized file name: " <<
name);
72 std::ifstream node_stream (name_node.c_str());
73 std::ifstream ele_stream (name_ele.c_str());
75 if (!node_stream.good() || !ele_stream.good())
76 libmesh_error_msg(
"Error while opening either " \
81 libMesh::out<<
"TetGenIO found the tetgen files to read " <<std::endl;
89 libMesh::out<<
"TetGenIO read in nodes and elements " <<std::endl;
95 std::istream & ele_stream)
115 libmesh_assert (node_stream.good());
120 unsigned int dimension=0, nAttributes=0, BoundaryMarkers=0;
128 unsigned int node_lab=0;
134 for (
unsigned i=0; i<nAttributes; ++i)
141 libmesh_assert (node_stream.good());
143 node_stream >> node_lab
149 for (
unsigned int j=0; j<nAttributes; j++)
154 if (BoundaryMarkers == 1)
155 node_stream >> dummy;
173 libmesh_assert (ele_stream.good());
179 unsigned int element_lab=0,
n_nodes=0, region_attribute=0;
192 if (region_attribute > 1)
193 libmesh_error_msg(
"Invalid region_attribute " << region_attribute <<
" specified in .ele file.");
199 static const unsigned int assign_elm_nodes[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
203 libmesh_assert (ele_stream.good());
215 libmesh_error_msg(
"Elements with " <<
n_nodes <<
" nodes are not supported in the LibMesh tetgen module.");
221 libmesh_assert(elem);
222 libmesh_assert_equal_to (elem->n_nodes(),
n_nodes);
228 ele_stream >> element_lab;
234 ele_stream >> node_label;
237 elem->set_node(assign_elm_nodes[j]) =
242 if (region_attribute)
245 ele_stream >> region;
249 elem->subdomain_id() = cast_int<subdomain_id_type>(region);
264 if (!(fname.rfind(
".poly") < fname.size()))
265 libmesh_error_msg(
"ERROR: Unrecognized file name: " << fname);
268 std::ofstream out_stream (fname.c_str());
271 if (!out_stream.good())
272 libmesh_file_error(fname.c_str());
280 out_stream <<
"# poly file output generated by libmesh\n" 285 out_stream << v <<
" " 293 out_stream <<
"# Facets:\n" 297 out_stream <<
"1\n3 " 299 << elem->node_id(0) <<
" " 300 << elem->node_id(1) <<
" " 301 << elem->node_id(2) <<
"\n";
306 out_stream <<
"\n\n# end of file\n";
std::string name(const ElemQuality q)
dof_id_type _num_elements
std::map< dof_id_type, dof_id_type > _assign_nodes
virtual void read(const std::string &) override
The base class for all geometric element types.
virtual SimpleRange< element_iterator > active_element_ptr_range()=0
virtual Node * add_point(const Point &p, const dof_id_type id=DofObject::invalid_id, const processor_id_type proc_id=DofObject::invalid_processor_id)=0
const dof_id_type n_nodes
virtual Elem * add_elem(Elem *e)=0
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
A 3D tetrahedral element with 10 nodes.
void read_nodes_and_elem(std::istream &node_stream, std::istream &ele_stream)
virtual void write(const std::string &) override
A 3D tetrahedral element with 4 nodes.
virtual const Point & point(const dof_id_type i) const =0
void node_in(std::istream &node_stream)
void element_in(std::istream &ele_stream)
virtual dof_id_type n_elem() const =0
virtual const Node * node_ptr(const dof_id_type i) const =0
OStreamProxy out(std::cout)
std::vector< std::vector< Real > > node_attributes
A geometric point in (x,y,z) space.
virtual dof_id_type n_nodes() const =0