1 // Project MULTIPR, IOLS WP1.2.1 - EDF/CS
2 // Partitioning/decimation module for the SALOME v3.2 platform
5 * \file MULTIPR_GaussLoc.hxx
7 * \brief Class MULTIPR_Obj.
8 * This class is used as an interface to implement MULTIPR services in the salome MODULE
9 * as described in the spec/design doc.
11 * \author Olivier LE ROUX - CS, Virtual Reality Dpt
16 #ifndef MULTIPR_OBJ_HXX
17 #define MULTIPR_OBJ_HXX
19 //*****************************************************************************
21 //*****************************************************************************
34 //*****************************************************************************
36 //*****************************************************************************
40 MULTIPR_OBJ_STATE_ERROR,
41 MULTIPR_OBJ_STATE_RESET,
42 MULTIPR_OBJ_STATE_SEQ_INIT,
43 MULTIPR_OBJ_STATE_SEQ,
44 MULTIPR_OBJ_STATE_DIS,
45 MULTIPR_OBJ_STATE_DIS_MEM
54 * Builds an empty Gauss reference (default constructor).
59 * Destructor. Removes everything.
64 * Resets this object in its state by default (empty). Cleans memory.
69 * Associate a MED file (sequential or distributed) with this object.
71 * - reset everything before starting
72 * - determine if the given file is a sequential (SEQ) or a distributed (DIS) MED file
73 * - read the ASCII master file if it is a distributed MED file
76 void create(const char* pMEDfilename);
78 //---------------------------------------------------------------------
79 // Basic accessors/mutators
80 //--------------------------------------------------------------------
83 * Returns true iff this obj represents a valid sequential MED file.
84 * \return true iff this obj represents a valid sequential MED file.
86 bool isValidSequentialMEDFile() const { return (mState == MULTIPR_OBJ_STATE_SEQ) || (mState == MULTIPR_OBJ_STATE_SEQ_INIT); }
89 * Returns true iff this obj represents a valid distributed MED file.
90 * \return true iff this obj represents a valid distributed MED file.
92 bool isValidDistributedMEDFile() const { return (mState == MULTIPR_OBJ_STATE_DIS) || (mState == MULTIPR_OBJ_STATE_DIS_MEM); }
95 * Returns the name of the associated MED file.
96 * \return the name of the associated MED file.
98 std::string getMEDFilename() const { return mMEDfilename; }
101 * Returns the name of the associated sequential MED file.
102 * \return the name of the associated sequential MED file.
104 std::string getSequentialMEDFilename() const;
107 * Defines the mesh to be processed.
108 * \param pMeshName name of the mesh to be partitionned.
110 void setMesh(const char* pMeshName);
113 * Returns the list of meshes contained in the sequential MED file.
114 * Assumes this object encapsulates a sequential MED file.
115 * \return the list of meshes contained in the sequential MED file.
117 std::vector<std::string> getMeshes() const;
120 * Returns the list of fields contained in the sequential MED file.
121 * Assumes this object encapsulates a sequential MED file.
122 * \return the list of fields contained in the sequential MED file.
124 std::vector<std::string> getFields() const;
127 * Returns the number of timestamps for a given field.
128 * Assumes this object encapsulates a sequential MED file.
129 * \param pFieldName name of any field.
130 * \return the number of timestamps for a given field; 0 if field not found.
132 int getTimeStamps(const char* pFieldName) const;
135 * Returns the name of all partitions.
136 * Assumes this object encapsulates a distributed MED file.
137 * \return the name of all partitions.
139 std::vector<std::string> getParts() const;
142 * Returns all information about a part.
143 * \param pPartName name of the part.
144 * \return all information about a part.
146 std::string getPartInfo(const char* pPartName) const;
149 * Removes all the part beginning by pPrefixPartName from the distributed MED file.
150 * Example: if pPrefixPartName="PART_4" => remove "PART_4" and all sub-parts "PART_4_*", but not "PART41".
151 * Assume this object encapsulates a distributed MED file.
152 * \param pPrefixPartName name of the part.
154 void removeParts(const char* pPrefixPartName);
157 //---------------------------------------------------------------------
159 //--------------------------------------------------------------------
162 * Creates a distributed MED file (v2.3) by extracting all the groups from the current mesh of the current MED sequential MED file.
164 * - the file is in MED format and can be read using MED file v2.3.
165 * - the file is sequential (not a distributed MED).
166 * - the file only contains TETRA10 elements (dimension of space and mesh is 3).
167 * - the file have no profil.
168 * \return the name of each part.
169 * \throw RuntimeException if any error occurs.
171 std::vector<std::string> partitionneDomaine();
174 * Creates a distributed MED file (V2.3) by splitting a group of a MED file previously created by partitionneDomaine.
176 * - the file is a distributed MED file, previously created by partitionneDomaine()
177 * (=> each part only contain 1 mesh, TETRA10 elements only)
179 * \param pPartName name of the part to be splitted.
180 * \param pNbParts number of parts; must be > 1.
181 * \param pPartitionner use value 0=MULTIPR_METIS for Metis or 1=MULTIPR_SCOTCH for Scotch.
182 * \return the name of each part.
183 * \throw RuntimeException if any error occurs.
185 std::vector<std::string> partitionneGrain(
186 const char* pPartName,
188 int pPartitionner=0);
191 * Creates 3 resolutions of the given part of a distributed MED file (V2.3).
193 * - the file is a distributed MED file, previously created by partitionneDomaine() or partitionneGrain()
194 * (=> each part only contain 1 mesh, TETRA10 elements only)
195 * \param pPartName name of the part to be decimated.
196 * \param pFieldName name of the field used for decimation.
197 * \param pFieldIt iteration (time step) of the field.
198 * \param pFilterName name of the filter to be used.
199 * \param pTmed threshold used for medium resolution.
200 * \param pTlow threshold used for low resolution; tmed must be less than tlow
201 * \param pTadius radius used to determine the neighbourhood.
202 * \param pBoxing number of cells along each axis; must be >= 1; e.g. if 100 then acceleration grid will have 100*100*100 = 10**6 cells.
203 * \return the name of each part.
204 * \throw RuntimeException if any error occurs.
206 std::vector<std::string> decimePartition(
207 const char* pPartName,
208 const char* pFieldName,
210 const char* pFilterName,
217 * Returns useful information to configure decimation parameters.
218 * Depends on part, field and filter: generic operation.
219 * \param pPartName name of the part.
220 * \param pFieldName name of the field used for decimation.
221 * \param pFieldIt iteration (time step) of the field.
222 * \param pFilterName name of the filter to be used.
223 * \param pFilterParams params to be used with the filter (depends on filter; this string will be parsed).
225 std::string evalDecimationParams(
226 const char* pPartName,
227 const char* pFieldName,
229 const char* pFilterName,
230 const char* pFilterParams);
233 //---------------------------------------------------------------------
235 //---------------------------------------------------------------------
238 * Saves the associated MED file if necessary.
239 * \param pPath path where to save the file.
240 * \throw IOException if any i/o error occurs.
242 void save(const char* pPath);
245 * Dumps any Obj to the given output stream.
246 * \param pOs any output stream.
248 * \return the output stream pOs.
250 friend std::ostream& operator<<(std::ostream& pOs, Obj& pO);
255 * Returns the list of parts contained in the current distributed mesh.
256 * \return the list of parts contained in the current distributed mesh.
257 * \throw IllegalStateException if the distributed mesh does not still exist.
259 std::vector<std::string> getListParts() const;
263 std::string mMEDfilename; /**< Name of the MED file: sequential or distributed. */
264 std::string mMeshName; /**< Mesh to be partitionned. */
265 ObjState mState; /**< State of this object. */
266 MeshDis* mMeshDis; /**< Distributed mesh. */
271 // do not allow copy constructor
275 Obj& operator=(const Obj&);
277 // do not allow operator ==
278 bool operator==(const Obj&);
283 } // namespace MULTIPR
286 #endif // MULTIPR_OBJ_HXX