v0.16.3
Loading...
Searching...
No Matches
MedInterface.hpp
Go to the documentation of this file.
1/** \file MedInterface.hpp
2 * \brief Med file interface interface
3 *
4 * Interface loading mesh and data on mesh directly to mofem & moab
5 *
6 * \todo Reading higher order entities
7 * \todo Reading fields data
8 *
9 */
10
11#ifdef WITH_MED
12
13#ifndef __MED_INTERFACE_HPP__
14#define __MED_INTERFACE_HPP__
15
16namespace MoFEM {
17
18/** \brief Interface for load MED files
19
20 * \ingroup mofem_med_files
21
22*/
24
25 MoFEMErrorCode query_interface(boost::typeindex::type_index type_index,
26 UnknownInterface **iface) const;
27
28 MedInterface(const MoFEM::Core &core);
29
30 /**
31 * \brief Get MED file name from command line
32 * @param verb verbosity level
33 * @return error code
34 */
36
37 /** \brief Check if file name is given in command line
38 */
39 inline PetscBool getFlgFile() const { return flgFile; }
40
41 /**
42 * \brief Get field names in MED file
43 * @param file file name
44 * @param verb verbosity level
45 * @return error code
46 */
47 MoFEMErrorCode medGetFieldNames(const string &file, int verb = 1);
48
49 /**
50 * \brief get field names in MED file
51 *
52 * File name is get form command line
53 *
54 * @param verb verbosity level
55 * @return error code
56 */
57 MoFEMErrorCode medGetFieldNames(int verb = 1);
58
59 /**
60 * \brief read MED file
61 *
62 * Vertex GLOBAL_ID is the MED node number: the number stored in the file,
63 * or the node's position 1..N when the file stores none. A mesh read into
64 * a database that already has vertices, such as the second mesh of a file,
65 * is offset past the largest vertex ID, so IDs stay unique.
66 *
67 * Elements use stored MED cell numbers, or generated consecutive numbers
68 * when absent. IDs are positive, below INT_MAX and unique within each
69 * dimension. A batch whose numbers collide with existing elements is
70 * offset past the largest existing ID; non-colliding MED numbers are kept.
71 *
72 * @param file field name
73 * @param verb verbosity level
74 * @return error code
75 */
76 MoFEMErrorCode readMed(const string &file, int verb = 1);
77
78 /**
79 * \brief read MED file
80 *
81 * File name is form command line
82 * ////
83 *
84 * @param verb verbosity level
85 * @return error code
86 */
87 MoFEMErrorCode readMed(int verb = 1);
88
89 /**
90 * \brief write MED file
91 *
92 * File name is form command line
93 *
94 * @param verb verbosity level
95 * @return error code
96 */
97 MoFEMErrorCode writeMed(boost::shared_ptr<Range> range_ptr = nullptr, int verb = 1);
98
99 /**
100 * Retrieves the meshsets
101 *
102 * @param meshsets_ptr A pointer to a vector of const CubitMeshSets objects. If provided, the retrieved meshsets will be stored in this vector.
103 * @return A MoFEMErrorCode indicating the success or failure of the operation.
104 */
105 MoFEMErrorCode getMeshsets(boost::shared_ptr<std::vector< const CubitMeshSets * >> &meshsets_ptr);
106 /**
107 * \brief write MED file
108 *
109 * The MED node numbers are the vertices' GLOBAL_ID when every written
110 * vertex has a distinct positive one, else their positions 1..N.
111 *
112 * @param file file name
113 * @param meshsets_ptr meshsets
114 * @param verb verbosity level
115 * @return error code
116 */
117 MoFEMErrorCode writeMed(const string &file,
118 boost::shared_ptr<std::vector<const CubitMeshSets *>> meshsets_ptr,
119 boost::shared_ptr<Range> range_ptr = nullptr, int verb = 1);
120
121 /**
122 * Read fields
123 * @param file_name file name
124 * @param file_index mesh index
125 * @param loadSeries load field into series
126 * @param onlyStep read only one step
127 * @return error code
128 */
129 MoFEMErrorCode readFields(const std::string &file_name,
130 const std::string &field_name,
131 const bool load_series = false,
132 const int only_step = -1, int verb = 1);
133
134 struct FieldData {
135 std::string fieldName;
136 std::string meshName;
138 // Med_field_type fieldType;
139 std::vector<std::string> componentNames;
140 std::vector<std::string> componentUnits;
141 std::string dtUnit;
143 };
144
145 std::vector<std::string> meshNames; ///< list of meshes in MED file
146 std::vector<EntityHandle> meshMeshsets; ///< meshset for each mesh
147 std::map<std::string, FieldData> fieldNames;
148 std::string medFileName; ///< MED file name
149
150private:
151 MoFEM::Core &cOre; ///< core database
152 // std::vector<std::string> fieldNames; ///< list of fields in MED file
153 PetscBool flgFile; ///< true if file name given in command line
154 // cubit
156
157 /**
158 * \brief read mesh from MED file
159 * @param file file name
160 * @param index index of mesh
161 * @param family_elem_map map of families and elements
162 * @param verb verbosity level
163 * @return error code
164 */
165 MoFEMErrorCode readMesh(const string &file, const int index,
166 std::map<int, Range> &family_elem_map, int verb = 1);
167
168 /**
169 * \brief read family and groups
170 * @param file file name
171 * @param index mesh index
172 * @param family_elem_mapint map of families and elements
173 * @param group_elem_map map of groups and elements
174 * @param verb verbosity level
175 * @return error code
176 */
177 MoFEMErrorCode readFamily(const string &file, const int index,
178 const std::map<int, Range> &family_elem_mapint,
179 std::map<string, Range> &group_elem_map,
180 int verb = 1);
181
182 /**
183 * \brief make from groups meshsets
184 * @param group_elem_map map of groups and elements
185 * @param verb verbosity level
186 * @return error code
187 */
188 MoFEMErrorCode makeBlockSets(const std::map<string, Range> &group_elem_map,
189 int verb = 1);
190};
191
192std::ostream &operator<<(std::ostream &os,
193 const MedInterface::FieldData &field_data);
194
195} // namespace MoFEM
196
197#endif // __MED_INTERFACE_HPP__
198#endif // WITH_MED
199
200/***************************************************************************/ /**
201* \defgroup mofem_med_files Reading and writing med files
202* \ingroup mofem
203*
204* \brief Interface for reading and writing med files
205******************************************************************************/
std::map< EntityHandle, int > index
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
implementation of Data Operators for Forces and Sources
Definition Common.hpp:10
std::ostream & operator<<(std::ostream &os, const EntitiesFieldData::EntData &e)
multi_index_container< CubitMeshSets, indexed_by< hashed_unique< tag< Meshset_mi_tag >, member< CubitMeshSets, EntityHandle, &CubitMeshSets::meshset > >, ordered_non_unique< tag< CubitMeshsetType_mi_tag >, const_mem_fun< CubitMeshSets, unsigned long int, &CubitMeshSets::getBcTypeULong > >, ordered_non_unique< tag< CubitMeshsetMaskedType_mi_tag >, const_mem_fun< CubitMeshSets, unsigned long int, &CubitMeshSets::getMaskedBcTypeULong > >, ordered_non_unique< tag< CubitMeshsets_name >, const_mem_fun< CubitMeshSets, std::string, &CubitMeshSets::getName > >, hashed_unique< tag< Composite_Cubit_msId_And_MeshsetType_mi_tag >, composite_key< CubitMeshSets, const_mem_fun< CubitMeshSets, int, &CubitMeshSets::getMeshsetId >, const_mem_fun< CubitMeshSets, unsigned long int, &CubitMeshSets::getMaskedBcTypeULong > > > > > CubitMeshSet_multiIndex
Stores data about meshsets (see CubitMeshSets) storing data about boundary conditions,...
constexpr auto field_name
Core (interface) class.
Definition Core.hpp:83
std::vector< std::string > componentNames
std::vector< std::string > componentUnits
Interface for load MED files.
PetscBool getFlgFile() const
Check if file name is given in command line.
MoFEMErrorCode readMed(const string &file, int verb=1)
read MED file
MoFEMErrorCode writeMed(boost::shared_ptr< Range > range_ptr=nullptr, int verb=1)
write MED file
std::vector< EntityHandle > meshMeshsets
meshset for each mesh
MoFEMErrorCode readFamily(const string &file, const int index, const std::map< int, Range > &family_elem_mapint, std::map< string, Range > &group_elem_map, int verb=1)
read family and groups
MoFEMErrorCode makeBlockSets(const std::map< string, Range > &group_elem_map, int verb=1)
make from groups meshsets
std::map< std::string, FieldData > fieldNames
std::string medFileName
MED file name.
MoFEMErrorCode getMeshsets(boost::shared_ptr< std::vector< const CubitMeshSets * > > &meshsets_ptr)
MoFEMErrorCode getFileNameFromCommandLine(int verb=1)
Get MED file name from command line.
std::vector< std::string > meshNames
list of meshes in MED file
MoFEM::Core & cOre
core database
MoFEMErrorCode readFields(const std::string &file_name, const std::string &field_name, const bool load_series=false, const int only_step=-1, int verb=1)
CubitMeshSet_multiIndex cubitMeshsets
cubit meshsets
MoFEMErrorCode readMesh(const string &file, const int index, std::map< int, Range > &family_elem_map, int verb=1)
read mesh from MED file
PetscBool flgFile
true if file name given in command line
MoFEMErrorCode medGetFieldNames(const string &file, int verb=1)
Get field names in MED file.
MoFEMErrorCode query_interface(boost::typeindex::type_index type_index, UnknownInterface **iface) const
base class for all interface classes