📄 mesh_data.h
字号:
/** * Record 3. The dataset location (e.g. data at nodes, * data on elements, etc.). */ unsigned int dataset_location; /** * Record 4 trough 8 are ID lines. */ std::vector<std::string> id_lines_1_to_5; /** * Record 9, first part. This record contains data specifying * the model type (e.g. unknown, structural, etc.), * the analysis type (e.g. unknown, static, transient, * normal mode, etc.), * the data characteristics (such as scalar, 3 dof global * translation vector, etc.), * the result type (e.g. stress, strain, velocity, etc.). */ unsigned int model_type, analysis_type, data_characteristic, result_type; /** * Record 9, second part. See first part, then we have: * the data type (currently supported: 2,4 for \p Real, * and 5,6 for \p Complex. other possibilities: e.g. integer), */ unsigned int data_type; /** * Record 9, third and last part. See first and second part, * then we have: the number of data values for the mesh data. */ unsigned int nvaldc; /** * Record 10 and 11 are analysis specific data of * type integer. */ std::vector<int> record_10, record_11; /** * Record 12 and 13 are analysis specific data of * type Real. */ std::vector<Real> record_12, record_13;protected: /** * @returns \p true when this dataset is the one * that the user wants, \p false otherwise. When * no desired dataset is given, always returns * \p true. Aside from this return value, this method * also reads the header information from the * stream \p in_file. */ bool read (std::istream& in_file); /** * Write the header information to the stream \p out_file. */ void write (std::ostream& out_file);private: /** * the desired dataset label. defaults to -1 * if not given */ unsigned int _desired_dataset_label; /** * @returns \p true when the string \p number * has a 'D' that needs to be replaced by 'e', * \p false otherwise. Also actually replaces * the 'D' by an 'e'. */ static bool need_D_to_e (std::string& number); /** * Make the \p MeshData class a friend. */ friend class MeshData;};// ------------------------------------------------------------// MeshData inline methods//-------------------------------------------------------------// element data inline methodsinlineNumber MeshData::operator() (const Node* node, const unsigned int i) const{ libmesh_assert (_active || _compatibility_mode); libmesh_assert (_node_data_closed); std::map<const Node*, std::vector<Number> >::const_iterator pos = _node_data.find(node); if (pos == _node_data.end()) return libMesh::zero; // we only get here when pos != _node_data.end() libmesh_assert (i < pos->second.size()); return pos->second[i];}inlinebool MeshData::has_data (const Node* node) const{ libmesh_assert (_active || _compatibility_mode); libmesh_assert (_node_data_closed); std::map<const Node*, std::vector<Number> >::const_iterator pos = _node_data.find(node); return (pos != _node_data.end());}inlineconst std::vector<Number>& MeshData::get_data (const Node* node) const{ libmesh_assert (_active || _compatibility_mode); libmesh_assert (_node_data_closed); std::map<const Node*, std::vector<Number> >::const_iterator pos = _node_data.find(node);#ifdef DEBUG if (pos == _node_data.end()) { std::cerr << "ERROR: No data for this node. Use has_data() first!" << std::endl; libmesh_error(); }#endif return pos->second;}inlinevoid MeshData::set_data (const Node* node, const std::vector<Number> &val){ this->_node_data[node] = val;}inlineMeshData::const_node_data_iterator MeshData::node_data_begin () const{ return _node_data.begin();}inlineMeshData::const_node_data_iterator MeshData::node_data_end () const{ return _node_data.end();}//-------------------------------------------------------------// element data inline methodsinlineNumber MeshData::operator() (const Elem* elem, const unsigned int i) const{ libmesh_assert (_active || _compatibility_mode); libmesh_assert (_elem_data_closed); std::map<const Elem*, std::vector<Number> >::const_iterator pos = _elem_data.find(elem); if (pos == _elem_data.end()) return libMesh::zero; // we only get here when pos != _elem_data.end() libmesh_assert (i < pos->second.size()); return pos->second[i];}inlinebool MeshData::has_data (const Elem* elem) const{ libmesh_assert (_active || _compatibility_mode); libmesh_assert (_elem_data_closed); std::map<const Elem*, std::vector<Number> >::const_iterator pos = _elem_data.find(elem); return (pos != _elem_data.end());}inlineconst std::vector<Number>& MeshData::get_data (const Elem* elem) const{ libmesh_assert (_active || _compatibility_mode); libmesh_assert (_elem_data_closed); std::map<const Elem*, std::vector<Number> >::const_iterator pos = _elem_data.find(elem);#ifdef DEBUG if (pos == _elem_data.end()) { std::cerr << "ERROR: No data for this element. Use has_data() first!" << std::endl; libmesh_error(); }#endif return pos->second;}inlinevoid MeshData::set_data (const Elem* elem, const std::vector<Number> &val){ this->_elem_data[elem] = val;}inlineMeshData::const_elem_data_iterator MeshData::elem_data_begin () const{ return _elem_data.begin();}inlineMeshData::const_elem_data_iterator MeshData::elem_data_end () const{ return _elem_data.end();}//-------------------------------------------------------------// other inline methodsinlinebool MeshData::active() const{ return _active;}inlinebool MeshData::compatibility_mode() const{ return _compatibility_mode;}inlinebool MeshData::elem_initialized() const{ return (_active && _elem_data_closed);}inlinebool MeshData::node_initialized() const{ return (_active && _node_data_closed);}inline void MeshData::add_foreign_node_id (const Node* node, const unsigned int foreign_node_id){ if (_active) { libmesh_assert (!_node_id_map_closed); libmesh_assert (node != NULL); libmesh_assert (_node_id.find(node) == _node_id.end()); libmesh_assert (_id_node.find(foreign_node_id) == _id_node.end()); /* * _always_ insert in _id_node and _node_id. If we would * use the mesh.node(unsigned int) method or the node.id() * to get Node* and unsigned int, respectively, we would not * be safe any more when the mesh gets refined or re-numbered * within libMesh. And we could get in big trouble that would * be hard to find when importing data _after_ having refined... */ _node_id.insert(std::make_pair(node, foreign_node_id)); _id_node.insert(std::make_pair(foreign_node_id, node)); }}inline void MeshData::add_foreign_elem_id (const Elem* elem, const unsigned int foreign_elem_id){ if (_active) { libmesh_assert (!_elem_id_map_closed); libmesh_assert (elem != NULL); libmesh_assert (_elem_id.find(elem) == _elem_id.end()); libmesh_assert (_id_elem.find(foreign_elem_id) == _id_elem.end()); _elem_id.insert(std::make_pair(elem, foreign_elem_id)); _id_elem.insert(std::make_pair(foreign_elem_id, elem)); }}inlineconst MeshDataUnvHeader & MeshData::get_unv_header () const{ libmesh_assert (this->_unv_header != NULL); return *this->_unv_header;}inlinevoid MeshData::set_unv_header (MeshDataUnvHeader* unv_header){ libmesh_assert (unv_header != NULL); this->_unv_header = unv_header;}//-----------------------------------------------------------// MeshDataUnvHeader inline methods#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -