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 true iff the given 3D-point is in the bounding box of this Mesh.
126 * \return true iff the given 3D-point is in the bounding box of this Mesh.
128 bool isInBBox(med_float pX, med_float pY, med_float pZ) const
130 return ((pX >= mMeshBBoxMin[0]) && (pX <= mMeshBBoxMax[0]) &&
131 (pY >= mMeshBBoxMin[1]) && (pY <= mMeshBBoxMax[1]) &&
132 (pZ >= mMeshBBoxMin[2]) && (pZ <= mMeshBBoxMax[2]));
136 * Returns the number of elements.
137 * \return the number of elements.
139 int getNumberOfElements() const;
141 //---------------------------------------------------------------------
143 //---------------------------------------------------------------------
146 * Creates a Mesh from a subset of its elements (cells).
147 * \param pSetOfElements subset of elements to keep.
148 * \param pNewMeshName name of the new Mesh.
149 * \return a new Mesh which is a restriction of this Mesh to the given set of elements.
150 * \throw NullArgumentException if pNewMeshName is NULL.
152 Mesh* createFromSetOfElements(const std::set<med_int>& pSetOfElements, const char* pNewMeshName);
155 * Creates a Mesh from one of its group.
156 * \param pGroup any group of this Mesh.
157 * \param pNewMeshName name of the new Mesh.
158 * \return a new Mesh which is a restriction of this Mesh to pGroup.
159 * \throw NullArgumentException if pGroup or pNewMeshName is NULL.
161 Mesh* createFromGroup(const Group* pGroup, const char* pNewMeshName);
164 * Creates a distributed mesh (MeshDis) by creating a new mesh for each group of elements in this Mesh.
165 * \return a distributed mesh from groups of this Mesh.
167 MeshDis* splitGroupsOfElements();
170 * Creates a new mesh by decimating this one.
171 * \param pFilterName name of the filter to be used for decimation (e.g. Filtre_GradientMoyen); should not be NULL.
172 * \param pArgv all the arguments for filtering as a single string.
173 * \param pNameNewMesh name of the new mesh.
174 * \return the decimated mesh.
175 * \throw NullArgumentException if one of the arguments is NULL.
176 * \throw RuntimeException if any error occurs while decimating data.
179 const char* pFilterName,
181 const char* pNameNewMesh);
184 * Gets all the points in a field. Each point has coordinates and a value.
185 * \param pField any field of this Mesh.
186 * \param pTimeStepIt time step iteration.
187 * \param pPoints (out) list of points.
188 * \throw NullArgumentException if pField is NULL.
189 * \throw IllegalArgumentException if pTimeStepIt is invalid.
191 void getAllPointsOfField(Field* pField, int pTimeStepIt, std::vector<PointOfField>& pPoints);
194 * Returns a default value for neighborhood radius.
195 * Return value is such that, for any point in the field, average number of neighbours is pN.
196 * \param pN average number of neighbours.
197 * \return a default value for neighborhood radius; 1.0 if some error occurs.
199 float evalDefaultRadius(int pN) const;
201 //---------------------------------------------------------------------
203 //---------------------------------------------------------------------
206 * Reads a Mesh from a sequential MED file. Resets the object before.
207 * \param pMEDfilename
209 * \throw IOException if any i/o error occurs.
211 void readSequentialMED(const char* pMEDfilename, const char* pMeshName);
214 * Writes this Mesh and all related things into a MED file.
215 * \param pMEDfilename
216 * \throw IOException if any i/o error occurs.
218 void writeMED(const char* pMEDfilename);
221 * Sets the flag which control the stream operator <<.
222 * \param pFlag new flag value.
224 void setPrintAll(bool pFlag) { mFlagPrintAll = pFlag; }
227 * Dumps any Mesh to the given output stream.
228 * \param pOs any output stream.
229 * \param pM any Mesh.
230 * \return the output stream pOs.
232 friend std::ostream& operator<<(std::ostream& pOs, Mesh& pM);
237 * Reads all Gauss localizations in the current MED file.
238 * \throw IOException if an i/o error occurs.
243 * Reads families in the currentMED file and build groups.
244 * \throw IOException if an i/o error occurs.
249 * Finalizes the constructions of families and groups.
250 * Fill structures with elements.
252 void finalizeFamiliesAndGroups();
255 * Reads fields related to this mesh in the current MED file.
256 * \throw IOException if an i/o error occurs.
263 * Name of the associated MED file.
265 char mMEDfilename[256];
275 char mMeshName[MED_TAILLE_NOM + 1];
278 * Universal name of this mesh.
280 char mMeshUName[MED_TAILLE_DESC + 1];
285 char mMeshDesc[MED_TAILLE_DESC + 1];
293 * Type of mesh (MED_NON_STRUCTURE or MED_STRUCTURE (=grid))
295 med_maillage mMeshType;
298 * Axis aligned bounding box of this mesh.
300 med_float mMeshBBoxMin[3];
301 med_float mMeshBBoxMax[3];
304 * All the nodes used by this mesh.
309 * All the TETRA10 elements used by this mesh.
314 * Table of families used by this mesh.
316 std::vector<Family*> mFamilies;
319 * Map to retrieve a Family from its name.
321 std::map<med_int, Family*> mFamIdToFam;
324 * Table of groups used by this mesh.
326 std::vector<Group*> mGroups;
329 * Map to retrieve a Group from its name.
331 std::map<std::string, Group*> mGroupNameToGroup;
336 std::vector<GaussLoc*> mGaussLoc;
339 * Map to retrieve a Gauss info from its name.
341 std::map<std::string, GaussLoc*> mGaussLocNameToGaussLoc;
344 * Table of fields related to this mesh.
345 * Number of fiels = mFields.size().
347 std::vector<Field*> mFields;
352 std::vector<Profil*> mProfils;
355 * Flag to control the behaviour of the stream operator <<.
361 // do not allow copy constructor
365 Mesh& operator=(const Mesh&);
367 // do not allow operator ==
368 bool operator==(const Mesh&);
373 } // namespace MULTIPR
376 #endif // MULTIPR_MESH_HXX