v0.14.0
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 * @param file filed name
62 * @param verb verbosity level
63 * @return error code
64 */
65 MoFEMErrorCode readMed(const string &file, int verb = 1);
66
67 /**
68 * \brief read MED file
69 *
70 * File name is form command line
71 *
72 * @param verb verbosity level
73 * @return error code
74 */
75 MoFEMErrorCode readMed(int verb = 1);
76
77 /**
78 * \brief write MED file
79 * @param file file name
80 * @param verb verbosity level
81 * @return error code
82 */
83 MoFEMErrorCode writeMed(const string &file, int verb = 1);
84
85 /**
86 * Read fields
87 * @param file_name file name
88 * @param file_index mesh index
89 * @param loadSeries load field into series
90 * @param onlyStep read only one step
91 * @return error code
92 */
93 MoFEMErrorCode readFields(const std::string &file_name,
94 const std::string &field_name,
95 const bool load_series = false,
96 const int only_step = -1, int verb = 1);
97
98 struct FieldData {
99 std::string fieldName;
100 std::string meshName;
102 // Med_field_type fieldType;
103 std::vector<std::string> componentNames;
104 std::vector<std::string> componentUnits;
105 std::string dtUnit;
107 };
108
109 std::vector<std::string> meshNames; ///< list of meshes in MED file
110 std::vector<EntityHandle> meshMeshsets; ///< meshset for each mesh
111 std::map<std::string, FieldData> fieldNames;
112 std::string medFileName; ///< MED file name
113
114private:
115 MoFEM::Core &cOre; ///< core database
116 // std::vector<std::string> fieldNames; ///< list of fields in MED file
117 PetscBool flgFile; ///< true if file name given in command line
118
119 /**
120 * \brief read mesh from MED file
121 * @param file file name
122 * @param index index of mesh
123 * @param family_elem_map map of families and elements
124 * @param verb verbosity level
125 * @return error code
126 */
127 MoFEMErrorCode readMesh(const string &file, const int index,
128 std::map<int, Range> &family_elem_map, int verb = 1);
129
130 /**
131 * \brief read family and groups
132 * @param file file name
133 * @param index mesh index
134 * @param family_elem_mapint map of families and elements
135 * @param group_elem_map map of groups and elements
136 * @param verb verbosity level
137 * @return error code
138 */
139 MoFEMErrorCode readFamily(const string &file, const int index,
140 const std::map<int, Range> &family_elem_mapint,
141 std::map<string, Range> &group_elem_map,
142 int verb = 1);
143
144 /**
145 * \brief make from groups meshsets
146 * @param group_elem_map map of groups and elements
147 * @param verb verbosity level
148 * @return error code
149 */
150 MoFEMErrorCode makeBlockSets(const std::map<string, Range> &group_elem_map,
151 int verb = 1);
152};
153
154std::ostream &operator<<(std::ostream &os,
155 const MedInterface::FieldData &field_data);
156
157} // namespace MoFEM
158
159#endif // __MED_INTERFACE_HPP__
160#endif // WITH_MED
161
162/***************************************************************************/ /**
163* \defgroup mofem_med_files Reading and writing med files
164* \ingroup mofem
165*
166* \brief Interface for reading and writing med files
167******************************************************************************/
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)
constexpr auto field_name
Core (interface) class.
Definition Core.hpp:82
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
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 getFileNameFromCommandLine(int verb=1)
Get MED file name from command line.
MedInterface(const MoFEM::Core &core)
std::vector< std::string > meshNames
list of meshes in MED file
MoFEM::Core & cOre
core database
MoFEMErrorCode writeMed(const string &file, int verb=1)
write MED file
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)
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