37 _data_descriptor (
""),
38 _node_id_map_closed (false),
39 _node_data_closed (false),
40 _elem_id_map_closed (false),
41 _elem_data_closed (false),
43 _compatibility_mode (false),
68 libMesh::err <<
"WARNING: MeshData was in compatibility mode, now being activated."
99 libMesh::err <<
"WARNING: MeshData was in compatibility mode, now being activated."
123 const bool elem_id_map)
152 libMesh::err <<
"WARNING: No need for MeshData::slim() in compatibility mode." << std::endl;
161 std::vector<Number> & values,
162 std::vector<std::string> & names)
const
166 LOG_SCOPE(
"translate()",
"MeshData");
175 values.reserve(n_comp*out_mesh.
n_nodes());
184 for (; nodes_it != nodes_end; ++nodes_it)
186 const Node * node = *nodes_it;
188 for (
unsigned int c= 0; c<n_comp; c++)
189 values.push_back(this->operator()(node, c));
199 names.reserve(n_comp);
203 libmesh_assert_less (n_comp, 100);
205 for (
unsigned int n=0; n<n_comp; n++)
207 std::ostringstream name_buf;
208 name_buf <<
"bc_" << n;
209 names.push_back(name_buf.str());
237 LOG_SCOPE(
"read()",
"MeshData");
247 libMesh::err <<
"WARNING: MeshData in compatibility mode, node and element ids" << std::endl
248 <<
" stored in file may be totally different from libMesh ids!" << std::endl;
256 if (name.rfind(
".xta") < name.size())
259 else if (name.rfind(
".xtr") < name.size())
262 else if (name.rfind(
".unv") < name.size())
265 else if ((name.rfind(
".node") < name.size()) ||
266 (name.rfind(
".ele") < name.size()))
270 libmesh_error_msg(
" ERROR: Unrecognized file extension: " << name \
271 <<
"\n I understand the following:\n\n" \
272 <<
" *.xta -- Internal ASCII data format\n" \
273 <<
" *.xtr -- Internal binary data format\n" \
274 <<
" *.unv -- I-deas format");
284 LOG_SCOPE(
"write()",
"MeshData");
294 libMesh::err <<
"WARNING: MeshData in compatibility mode. Node and element ids" << std::endl
295 <<
" written to file may differ from libMesh numbering" << std::endl
296 <<
" next time this file is read!" << std::endl;
301 if (name.rfind(
".xta") < name.size())
304 else if (name.rfind(
".xtr") < name.size())
307 else if (name.rfind(
".unv") < name.size())
311 libmesh_error_msg(
" ERROR: Unrecognized file extension: " << name \
312 <<
"\n I understand the following:\n\n" \
313 <<
" *.xta -- Internal ASCII data format\n" \
314 <<
" *.xtr -- Internal binary data format\n" \
315 <<
" *.unv -- I-deas format");
324 std::ostringstream oss;
328 oss <<
" MeshData Information:\n";
330 oss <<
" object activated.\n";
332 oss <<
" object in compatibility mode.\n";
336 oss <<
" Element associated data initialized.\n"
338 <<
" n_elem_data()=" << this->
n_elem_data() <<
'\n';
340 oss <<
" Node associated data initialized.\n"
342 <<
" n_node_data()=" << this->
n_node_data() <<
'\n';
345 oss <<
" MeshData neither active nor in compatibility mode.\n";
376 std::map<
unsigned int,
380 libmesh_error_msg(
"ERROR: Have no Node * associated with the foreign id = " << fid);
391 libmesh_error_msg(
"We'll never get here!");
409 std::map<
const Node *,
410 unsigned int>::const_iterator pos =
_node_id.find(n);
413 libmesh_error_msg(
"ERROR: No foreign id stored for the node with the libMesh id = " << n->
id());
423 libmesh_error_msg(
"We'll never get here!");
441 std::map<
unsigned int,
445 libmesh_error_msg(
"ERROR: Have no Elem * associated with the foreign id = " << fid);
455 libmesh_error_msg(
"We'll never get here!");
473 std::map<
const Elem *,
474 unsigned int>::const_iterator pos =
_elem_id.find(e);
477 libmesh_error_msg(
"ERROR: No foreign id stored for the element with the libMesh id = " << e->
id());
487 libmesh_error_msg(
"We'll never get here!");
498 std::vector<Number> > & nd,
499 const bool close_elem_data)
506 libmesh_error_msg(
"ERROR: Nodal data already closed! Use clear() first!");
511 std::map<
const Node *,
512 std::vector<Number> >::const_iterator nd_pos = nd.begin();
513 std::map<
const Node *,
514 std::vector<Number> >::const_iterator nd_end = nd.end();
522 const std::size_t reference_length = (*nd_pos).second.size();
527 for (; nd_pos != nd_end; ++nd_pos)
528 if ( (*nd_pos).second.size() != reference_length)
529 libmesh_error_msg(
"ERROR: Size mismatch.");
554 std::vector<Number> > & ed,
555 const bool close_node_data)
562 libmesh_error_msg(
"ERROR: Element data already closed! Use clear() first!");
567 std::map<
const Elem *,
568 std::vector<Number> >::const_iterator ed_pos = ed.begin();
569 std::map<
const Elem *,
570 std::vector<Number> >::const_iterator ed_end = ed.end();
574 const std::size_t reference_length = (*ed_pos).second.size();
577 for (; ed_pos != ed_end; ++ed_pos)
578 if ( (*ed_pos).second.size() != reference_length)
579 libmesh_error_msg(
"ERROR: Size mismatch.");
610 std::map<
const Node *,
611 std::vector<Number> >::const_iterator pos =
_node_data.begin();
613 return cast_int<unsigned int>(pos->second.size());
627 return cast_int<dof_id_type>(this->
_node_data.size());
640 std::map<
const Elem *,
641 std::vector<Number> >::const_iterator pos =
_elem_data.begin();
643 return cast_int<unsigned int>(pos->second.size());
657 return cast_int<dof_id_type>(
_elem_data.size());
697 for (; elem_it != elem_end; ++elem_it)
699 const Elem * elem = *elem_it;
std::string name(const ElemQuality q)
A geometric point in (x,y,z) space associated with a DOF.
unsigned int n_val_per_elem() const
libmesh_assert(remote_elem)
void insert_node_data(std::map< const Node *, std::vector< Number > > &nd, const bool close_elem_data=true)
The base class for all geometric element types.
const class libmesh_nullptr_t libmesh_nullptr
void write_xdr(const std::string &name, const XdrMODE mode=WRITE)
void slim(const bool node_id_map=true, const bool elem_id_map=true)
void print_info(std::ostream &os=libMesh::out) const
std::map< unsigned int, const Node * > _id_node
bool elem_initialized() const
virtual node_iterator nodes_begin()=0
virtual element_iterator elements_begin()=0
void translate(const MeshBase &out_mesh, std::vector< Number > &data_values, std::vector< std::string > &data_names) const
unsigned int node_to_foreign_id(const Node *n) const
std::string get_info() const
virtual element_iterator elements_end()=0
MeshData(const MeshBase &m)
const Elem * foreign_id_to_elem(const unsigned int fid) const
void read_unv(const std::string &file_name)
OStreamProxy err(std::cerr)
void read_xdr(const std::string &name, const XdrMODE mode=READ)
std::string _data_descriptor
void write(const std::string &name)
virtual const Elem * elem_ptr(const dof_id_type i) const =0
dof_id_type n_elem_data() const
unsigned int elem_to_foreign_id(const Elem *n) const
std::map< const Elem *, unsigned int > _elem_id
virtual node_iterator nodes_end()=0
void read(const std::string &name)
void write_unv(const std::string &file_name)
MeshDataUnvHeader * _unv_header
void activate(const std::string &descriptor="")
void insert_elem_data(std::map< const Elem *, std::vector< Number > > &ed, const bool close_node_data=true)
void close_foreign_id_maps()
void enable_compatibility_mode(const std::string &descriptor="")
dof_id_type n_node_data() const
std::map< unsigned int, const Elem * > _id_elem
void add_foreign_elem_id(const Elem *elem, const unsigned int foreign_elem_id)
std::map< const Node *, unsigned int > _node_id
void assign(const MeshData &omd)
unsigned int n_val_per_node() const
const Node * foreign_id_to_node(const unsigned int fid) const
std::map< const Node *, std::vector< Number > > _node_data
virtual const Node * node_ptr(const dof_id_type i) const =0
void read_tetgen(const std::string &name)
std::map< const Elem *, std::vector< Number > > _elem_data
std::ostream & operator<<(std::ostream &os, const FEAbstract &fe)
bool compatibility_mode() const
virtual dof_id_type n_nodes() const =0
bool node_initialized() const