v0.14.0
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 
16 namespace MoFEM {
17 
18 /** \brief Interface for load MED files
19 
20  * \ingroup mofem_med_files
21 
22 */
23 struct MedInterface : public UnknownInterface {
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;
101  bool localMesh;
102  // Med_field_type fieldType;
103  std::vector<std::string> componentNames;
104  std::vector<std::string> componentUnits;
105  std::string dtUnit;
106  int ncSteps;
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 
114 private:
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 
154 std::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 ******************************************************************************/
MoFEM::MedInterface::query_interface
MoFEMErrorCode query_interface(boost::typeindex::type_index type_index, UnknownInterface **iface) const
Definition: MedInterface.cpp:41
MoFEM::operator<<
std::ostream & operator<<(std::ostream &os, const EntitiesFieldData::EntData &e)
Definition: EntitiesFieldData.cpp:240
MoFEM::CoreTmp< 0 >
Core (interface) class.
Definition: Core.hpp:82
MoFEM::MedInterface
Interface for load MED files.
Definition: MedInterface.hpp:23
MoFEM::MedInterface::makeBlockSets
MoFEMErrorCode makeBlockSets(const std::map< string, Range > &group_elem_map, int verb=1)
make from groups meshsets
Definition: MedInterface.cpp:612
MoFEM::MedInterface::medFileName
std::string medFileName
MED file name.
Definition: MedInterface.hpp:112
MoFEM::MedInterface::meshNames
std::vector< std::string > meshNames
list of meshes in MED file
Definition: MedInterface.hpp:109
MoFEM::Exceptions::MoFEMErrorCode
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:56
MoFEM::MedInterface::FieldData::ncSteps
int ncSteps
Definition: MedInterface.hpp:106
MoFEM::MedInterface::readFamily
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
Definition: MedInterface.cpp:517
MoFEM::MedInterface::readMed
MoFEMErrorCode readMed(const string &file, int verb=1)
read MED file
Definition: MedInterface.cpp:143
MoFEM::MedInterface::fieldNames
std::map< std::string, FieldData > fieldNames
Definition: MedInterface.hpp:111
MoFEM::MedInterface::getFlgFile
PetscBool getFlgFile() const
Check if file name is given in command line.
Definition: MedInterface.hpp:39
MoFEM::MedInterface::FieldData::localMesh
bool localMesh
Definition: MedInterface.hpp:101
MoFEM::MedInterface::FieldData
Definition: MedInterface.hpp:98
MoFEM
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:10
MoFEM::MedInterface::FieldData::dtUnit
std::string dtUnit
Definition: MedInterface.hpp:105
MoFEM::MedInterface::flgFile
PetscBool flgFile
true if file name given in command line
Definition: MedInterface.hpp:117
MoFEM::MedInterface::medGetFieldNames
MoFEMErrorCode medGetFieldNames(const string &file, int verb=1)
Get field names in MED file.
Definition: MedInterface.cpp:80
MoFEM::MedInterface::getFileNameFromCommandLine
MoFEMErrorCode getFileNameFromCommandLine(int verb=1)
Get MED file name from command line.
Definition: MedInterface.cpp:61
MoFEM::MedInterface::readFields
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)
Definition: MedInterface.cpp:664
MoFEM::MedInterface::meshMeshsets
std::vector< EntityHandle > meshMeshsets
meshset for each mesh
Definition: MedInterface.hpp:110
MoFEM::MedInterface::FieldData::fieldName
std::string fieldName
Definition: MedInterface.hpp:99
field_name
constexpr auto field_name
Definition: poisson_2d_homogeneous.cpp:13
MoFEM::UnknownInterface
base class for all interface classes
Definition: UnknownInterface.hpp:34
MoFEM::MedInterface::writeMed
MoFEMErrorCode writeMed(const string &file, int verb=1)
write MED file
Definition: MedInterface.cpp:657
MoFEM::MedInterface::readMesh
MoFEMErrorCode readMesh(const string &file, const int index, std::map< int, Range > &family_elem_map, int verb=1)
read mesh from MED file
Definition: MedInterface.cpp:247
MoFEM::MedInterface::MedInterface
MedInterface(const MoFEM::Core &core)
Definition: MedInterface.cpp:47
MoFEM::MedInterface::FieldData::componentNames
std::vector< std::string > componentNames
Definition: MedInterface.hpp:103
MoFEM::MedInterface::FieldData::componentUnits
std::vector< std::string > componentUnits
Definition: MedInterface.hpp:104
MoFEM::MedInterface::cOre
MoFEM::Core & cOre
core database
Definition: MedInterface.hpp:115
MoFEM::MedInterface::FieldData::meshName
std::string meshName
Definition: MedInterface.hpp:100