1 // Project MULTIPR, IOLS WP1.2.1 - EDF/CS
2 // Partitioning/decimation module for the SALOME v3.2 platform
5 * \file MULTIPR_Mesh.hxx
7 * \brief Class Mesh used by the MULTIPR API; used to wrap MED file meshes.
9 * \author Olivier LE ROUX - CS, Virtual Reality Dpt
14 #ifndef MULTIPR_MESH_HXX
15 #define MULTIPR_MESH_HXX
17 //*****************************************************************************
19 //*****************************************************************************
37 //*****************************************************************************
39 //*****************************************************************************
52 //*****************************************************************************
54 //*****************************************************************************
58 * - 3D mesh in a 3D space
59 * - Unstructured mesh (not a grid)
60 * - Nodal connectivity
61 * - Cartesian coordinates system
62 * Always use FULL_INTERLACE arrays
69 * Builds an empty Mesh (default constructor).
74 * Destructor. Removes everything.
79 * Resets this object in its state by default (empty). Cleans memory.
83 //---------------------------------------------------------------------
84 // Basic accessors/mutators
85 //---------------------------------------------------------------------
88 * Returns the name of this Mesh.
89 * \return the name of this Mesh.
91 const char* getName() const { return mMeshName; }
94 * Returns the name of all the scalar fields.
95 * \return the name of all the scalar fields.
97 std::vector<std::string> getNameScalarFields() const;
100 * Returns the number of iteration for a given field.
101 * \return the number of iteration for a given field.
103 int getTimeStamps(const char* pFieldName) const;
106 * Returns a Field from its name; NULL if it does not exist.
107 * \param pFieldName name of the field to be retrieved.
108 * \return the Field pFieldName of it exists, NULL otherwise.
109 * \throw NullArgumentException if pFieldName is NULL.
111 Field* getFieldByName(const char* pFieldName) const;
114 * Returns a GaussLoc from its name; NULL if it does not exist.
115 * \param pGaussLocName name of the GaussLoc to be retrieved.
116 * \return the GaussLoc pGaussLocName if it exists, NULL otherwise.
117 * \throw NullArgumentException if pGaussLocName is NULL.
119 GaussLoc* getGaussLocByName(const char* pGaussLocName) const;
122 * Returns the number of elements.
123 * \return the number of elements.
125 int getNumberOfElements() const;
127 //---------------------------------------------------------------------
129 //---------------------------------------------------------------------
132 * Creates a Mesh from a subset of its elements (cells).
133 * \param pSetOfElements subset of elements to keep.
134 * \param pNewMeshName name of the new Mesh.
135 * \return a new Mesh which is a restriction of this Mesh to the given set of elements.
136 * \throw NullArgumentException if pNewMeshName is NULL.
138 Mesh* createFromSetOfElements(const std::set<med_int>& pSetOfElements, const char* pNewMeshName);
141 * Creates a Mesh from one of its group.
142 * \param pGroup any group of this Mesh.
143 * \param pNewMeshName name of the new Mesh.
144 * \return a new Mesh which is a restriction of this Mesh to pGroup.
145 * \throw NullArgumentException if pGroup or pNewMeshName is NULL.
147 Mesh* createFromGroup(const Group* pGroup, const char* pNewMeshName);
150 * Creates a distributed mesh (MeshDis) by creating a new mesh for each group of elements in this Mesh.
151 * \return a distributed mesh from groups of this Mesh.
153 MeshDis* splitGroupsOfElements();
156 * Creates a new mesh by decimating this one.
157 * \param pFilterName name of the filter to be used for decimation (e.g. Filtre_GradientMoyen); should not be NULL.
158 * \param pArgv all the arguments for filtering as a single string.
159 * \param pNameNewMesh name of the new mesh.
160 * \return the decimated mesh.
161 * \throw NullArgumentException if one of the arguments is NULL.
162 * \throw RuntimeException if any error occurs while decimating data.
165 const char* pFilterName,
167 const char* pNameNewMesh);
170 * Gets all the points in a field. Each point has coordinates and a value.
171 * \param pField any field of this Mesh.
172 * \param pTimeStepIt time step iteration.
173 * \param pPoints (out) list of points.
174 * \throw NullArgumentException if pField is NULL.
175 * \throw IllegalArgumentException if pTimeStepIt is invalid.
177 void getAllPointsOfField(Field* pField, int pTimeStepIt, std::vector<PointOfField>& pPoints);
180 * Returns a default value for neighborhood radius.
181 * Return value is such that, for any point in the field, average number of neighbours is pN.
182 * \param pN average number of neighbours.
183 * \return a default value for neighborhood radius; 1.0 if some error occurs.
185 float evalDefaultRadius(int pN) const;
187 //---------------------------------------------------------------------
189 //---------------------------------------------------------------------
192 * Reads a Mesh from a sequential MED file. Resets the object before.
193 * \param pMEDfilename
195 * \throw IOException if any i/o error occurs.
197 void readSequentialMED(const char* pMEDfilename, const char* pMeshName);
200 * Writes this Mesh and all related things into a MED file.
201 * \param pMEDfilename
202 * \throw IOException if any i/o error occurs.
204 void writeMED(const char* pMEDfilename);
207 * Sets the flag which control the stream operator <<.
208 * \param pFlag new flag value.
210 void setPrintAll(bool pFlag) { mFlagPrintAll = pFlag; }
213 * Dumps any Mesh to the given output stream.
214 * \param pOs any output stream.
215 * \param pM any Mesh.
216 * \return the output stream pOs.
218 friend std::ostream& operator<<(std::ostream& pOs, Mesh& pM);
223 * Reads all Gauss localizations in the current MED file.
224 * \throw IOException if an i/o error occurs.
229 * Reads families in the currentMED file and build groups.
230 * \throw IOException if an i/o error occurs.
235 * Finalizes the constructions of families and groups.
236 * Fill structures with elements.
238 void finalizeFamiliesAndGroups();
241 * Reads fields related to this mesh in the current MED file.
242 * \throw IOException if an i/o error occurs.
249 * Name of the associated MED file.
251 char mMEDfilename[256];
261 char mMeshName[MED_TAILLE_NOM + 1];
264 * Universal name of this mesh.
266 char mMeshUName[MED_TAILLE_DESC + 1];
271 char mMeshDesc[MED_TAILLE_DESC + 1];
279 * Type of mesh (MED_NON_STRUCTURE or MED_STRUCTURE (=grid))
281 med_maillage mMeshType;
284 * Axis aligned bounding box of this mesh.
286 med_float mMeshBBoxMin[3];
287 med_float mMeshBBoxMax[3];
290 * All the nodes used by this mesh.
295 * All the TETRA10 elements used by this mesh.
300 * Table of families used by this mesh.
302 std::vector<Family*> mFamilies;
305 * Map to retrieve a Family from its name.
307 std::map<med_int, Family*> mFamIdToFam;
310 * Table of groups used by this mesh.
312 std::vector<Group*> mGroups;
315 * Map to retrieve a Group from its name.
317 std::map<std::string, Group*> mGroupNameToGroup;
322 std::vector<GaussLoc*> mGaussLoc;
325 * Map to retrieve a Gauss info from its name.
327 std::map<std::string, GaussLoc*> mGaussLocNameToGaussLoc;
330 * Table of fields related to this mesh.
331 * Number of fiels = mFields.size().
333 std::vector<Field*> mFields;
338 std::vector<Profil*> mProfils;
341 * Flag to control the behaviour of the stream operator <<.
347 // do not allow copy constructor
351 Mesh& operator=(const Mesh&);
353 // do not allow operator ==
354 bool operator==(const Mesh&);
359 } // namespace MULTIPR
362 #endif // MULTIPR_MESH_HXX