v0.15.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 field 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 *
73 * @param verb verbosity level
74 * @return error code
75 */
76 MoFEMErrorCode readMed(int verb = 1);
77
78 /**
79 * \brief write MED file
80 *
81 * File name is form command line
82 *
83 * @param verb verbosity level
84 * @return error code
85 */
86 MoFEMErrorCode writeMed(boost::shared_ptr<Range> range_ptr = nullptr, int verb = 1);
87
88 /**
89 * Retrieves the meshsets
90 *
91 * @param meshsets_ptr A pointer to a vector of const CubitMeshSets objects. If provided, the retrieved meshsets will be stored in this vector.
92 * @return A MoFEMErrorCode indicating the success or failure of the operation.
93 */
94 MoFEMErrorCode getMeshsets(boost::shared_ptr<std::vector< const CubitMeshSets * >> &meshsets_ptr);
95 /**
96 * \brief write MED file
97 * @param file file name
98 * @param meshsets_ptr meshsets
99 * @param verb verbosity level
100 * @return error code
101 */
102 MoFEMErrorCode writeMed(const string &file,
103 boost::shared_ptr<std::vector<const CubitMeshSets *>> meshsets_ptr,
104 boost::shared_ptr<Range> range_ptr = nullptr, int verb = 1);
105
106 /**
107 * Read fields
108 * @param file_name file name
109 * @param file_index mesh index
110 * @param loadSeries load field into series
111 * @param onlyStep read only one step
112 * @return error code
113 */
114 MoFEMErrorCode readFields(const std::string &file_name,
115 const std::string &field_name,
116 const bool load_series = false,
117 const int only_step = -1, int verb = 1);
118
119 struct FieldData {
120 std::string fieldName;
121 std::string meshName;
123 // Med_field_type fieldType;
124 std::vector<std::string> componentNames;
125 std::vector<std::string> componentUnits;
126 std::string dtUnit;
128 };
129
130 std::vector<std::string> meshNames; ///< list of meshes in MED file
131 std::vector<EntityHandle> meshMeshsets; ///< meshset for each mesh
132 std::map<std::string, FieldData> fieldNames;
133 std::string medFileName; ///< MED file name
134
135private:
136 MoFEM::Core &cOre; ///< core database
137 // std::vector<std::string> fieldNames; ///< list of fields in MED file
138 PetscBool flgFile; ///< true if file name given in command line
139 // cubit
141
142 /**
143 * \brief read mesh from MED file
144 * @param file file name
145 * @param index index of mesh
146 * @param family_elem_map map of families and elements
147 * @param verb verbosity level
148 * @return error code
149 */
150 MoFEMErrorCode readMesh(const string &file, const int index,
151 std::map<int, Range> &family_elem_map, int verb = 1);
152
153 /**
154 * \brief read family and groups
155 * @param file file name
156 * @param index mesh index
157 * @param family_elem_mapint map of families and elements
158 * @param group_elem_map map of groups and elements
159 * @param verb verbosity level
160 * @return error code
161 */
162 MoFEMErrorCode readFamily(const string &file, const int index,
163 const std::map<int, Range> &family_elem_mapint,
164 std::map<string, Range> &group_elem_map,
165 int verb = 1);
166
167 /**
168 * \brief make from groups meshsets
169 * @param group_elem_map map of groups and elements
170 * @param verb verbosity level
171 * @return error code
172 */
173 MoFEMErrorCode makeBlockSets(const std::map<string, Range> &group_elem_map,
174 int verb = 1);
175};
176
177std::ostream &operator<<(std::ostream &os,
178 const MedInterface::FieldData &field_data);
179
180} // namespace MoFEM
181
182#endif // __MED_INTERFACE_HPP__
183#endif // WITH_MED
184
185/***************************************************************************/ /**
186* \defgroup mofem_med_files Reading and writing med files
187* \ingroup mofem
188*
189* \brief Interface for reading and writing med files
190******************************************************************************/
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
implementation of Data Operators for Forces and Sources
Definition Common.hpp:10
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,...
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
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.
MedInterface(const MoFEM::Core &core)
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