updated on Thu Jan 26 16:09:46 UTC 2012
[aur-mirror.git] / salome-med / salome-med-5.1.4_missing-link.diff
blobb7cc67ed4f3091e33a250ebd70587baeba0f6620
1 diff -Naur MED_SRC_5.1.4.orig//src/MEDSPLITTER/Test/Makefile.am MED_SRC_5.1.4/src/MEDSPLITTER/Test/Makefile.am
2 --- MED_SRC_5.1.4.orig//src/MEDSPLITTER/Test/Makefile.am 2010-07-07 20:06:41.165948208 +0200
3 +++ MED_SRC_5.1.4/src/MEDSPLITTER/Test/Makefile.am 2010-07-09 18:23:02.834077780 +0200
4 @@ -35,6 +35,7 @@
5 -I$(srcdir)/.. -I$(srcdir)/../../MEDWrapper/V2_1/Core -I$(srcdir)/../../MEDMEM \
6 -I$(srcdir)/../../MEDMEMCppTest
7 libMEDSPLITTERTest_la_LDFLAGS= $(MED2_LIBS) @CPPUNIT_LIBS@
8 +libMEDSPLITTERTest_la_LIBADD= ../libmedsplitter.la
10 if MED_ENABLE_KERNEL
11 libMEDSPLITTERTest_la_CPPFLAGS+= ${KERNEL_CXXFLAGS}
12 diff -Naur MED_SRC_5.1.4.orig//src/MEDSPLITTER/Test/Makefile.am.orig MED_SRC_5.1.4/src/MEDSPLITTER/Test/Makefile.am.orig
13 --- MED_SRC_5.1.4.orig//src/MEDSPLITTER/Test/Makefile.am.orig 1970-01-01 01:00:00.000000000 +0100
14 +++ MED_SRC_5.1.4/src/MEDSPLITTER/Test/Makefile.am.orig 2010-07-09 18:22:44.947402733 +0200
15 @@ -0,0 +1,74 @@
16 +# Copyright (C) 2007-2010 CEA/DEN, EDF R&D
18 +# This library is free software; you can redistribute it and/or
19 +# modify it under the terms of the GNU Lesser General Public
20 +# License as published by the Free Software Foundation; either
21 +# version 2.1 of the License.
23 +# This library is distributed in the hope that it will be useful,
24 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
25 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
26 +# Lesser General Public License for more details.
28 +# You should have received a copy of the GNU Lesser General Public
29 +# License along with this library; if not, write to the Free Software
30 +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32 +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
35 +# SALOMELocalTrace : log on local machine
37 +include $(top_srcdir)/adm_local/unix/make_common_starter.am
39 +lib_LTLIBRARIES = libMEDSPLITTERTest.la
41 +dist_libMEDSPLITTERTest_la_SOURCES= \
42 + MEDSPLITTERTest.cxx \
43 + MEDSPLITTERTest_MESHCollection.cxx \
44 + MEDSPLITTERTest_ParallelTopology.cxx
46 +salomeinclude_HEADERS = MEDSPLITTERTest.hxx
48 +libMEDSPLITTERTest_la_CPPFLAGS= @CPPUNIT_INCLUDES@ $(MED2_INCLUDES) \
49 + $(HDF5_INCLUDES) @CXXTMPDPTHFLAGS@ $(BOOST_CPPFLAGS) $(LIBXML_CXXFLAGS) \
50 + -I$(srcdir)/.. -I$(srcdir)/../../MEDWrapper/V2_1/Core -I$(srcdir)/../../MEDMEM \
51 + -I$(srcdir)/../../MEDMEMCppTest
52 +libMEDSPLITTERTest_la_LDFLAGS= $(MED2_LIBS) @CPPUNIT_LIBS@
54 +if MED_ENABLE_KERNEL
55 + libMEDSPLITTERTest_la_CPPFLAGS+= ${KERNEL_CXXFLAGS}
56 + libMEDSPLITTERTest_la_LDFLAGS+= ${KERNEL_LDFLAGS} -lSALOMELocalTrace
57 +endif
59 +if MED_ENABLE_METIS
60 + libMEDSPLITTERTest_la_CPPFLAGS+= $(METIS_CPPFLAGS)
61 + libMEDSPLITTERTest_la_LDFLAGS+= $(METIS_LIBS)
62 +endif
63 +if MED_ENABLE_SCOTCH
64 + libMEDSPLITTERTest_la_CPPFLAGS+= $(SCOTCH_CPPFLAGS)
65 + libMEDSPLITTERTest_la_LDFLAGS+= $(SCOTCH_LIBS)
66 +endif
68 +# Executables targets
69 +bin_PROGRAMS= TestMEDSPLITTER
71 +TestMEDSPLITTER_SOURCES= TestMEDSPLITTER.cxx
73 +TestMEDSPLITTER_CPPFLAGS= $(libMEDSPLITTERTest_la_CPPFLAGS)
74 +TestMEDSPLITTER_LDADD= $(MED2_LIBS) $(libMEDSPLITTERTest_la_LDFLAGS) -lm \
75 + libMEDSPLITTERTest.la ../../MEDWrapper/V2_1/Core/libmed_V2_1.la \
76 + ../../MEDMEM/libmedmem.la ../../INTERP_KERNEL/libinterpkernel.la \
77 + ../libmedsplitter.la
78 +if MED_ENABLE_KERNEL
79 + TestMEDSPLITTER_LDADD+= -lSALOMEBasics
80 +endif
82 +dist_salomescript_DATA = testMEDSPLITTER.py
84 +UNIT_TEST_PROG = TestMEDSPLITTER
86 +check: tests
88 +CLEANFILES = \
89 + UnitTestsResult
90 diff -Naur MED_SRC_5.1.4.orig//src/MEDWrapper/Factory/Makefile.am MED_SRC_5.1.4/src/MEDWrapper/Factory/Makefile.am
91 --- MED_SRC_5.1.4.orig//src/MEDWrapper/Factory/Makefile.am 2010-07-07 20:06:40.709275745 +0200
92 +++ MED_SRC_5.1.4/src/MEDWrapper/Factory/Makefile.am 2010-07-09 18:23:02.834077780 +0200
93 @@ -49,9 +49,9 @@
94 dist_MED_Test_SOURCES= MED_Test.cxx
95 MED_Test_CPPFLAGS= $(libMEDWrapper_la_CPPFLAGS)
96 MED_Test_LDADD= $(libMEDWrapper_la_LDFLAGS) ../Base/libMEDWrapperBase.la ../V2_1/Core/libmed_V2_1.la \
97 - $(BOOST_LIB_THREAD) libMEDWrapper.la
98 + $(BOOST_LIB_THREAD) $(MED2_MT_LIBS) libMEDWrapper.la
100 dist_mprint_version_SOURCES= mprint_version.cxx
101 mprint_version_CPPFLAGS= $(libMEDWrapper_la_CPPFLAGS)
102 mprint_version_LDADD= $(libMEDWrapper_la_LDFLAGS) ../Base/libMEDWrapperBase.la ../V2_1/Core/libmed_V2_1.la \
103 - $(BOOST_LIB_THREAD) libMEDWrapper.la
104 + $(BOOST_LIB_THREAD) $(MED2_MT_LIBS) libMEDWrapper.la
105 diff -Naur MED_SRC_5.1.4.orig//src/MEDWrapper/Factory/Makefile.am.orig MED_SRC_5.1.4/src/MEDWrapper/Factory/Makefile.am.orig
106 --- MED_SRC_5.1.4.orig//src/MEDWrapper/Factory/Makefile.am.orig 1970-01-01 01:00:00.000000000 +0100
107 +++ MED_SRC_5.1.4/src/MEDWrapper/Factory/Makefile.am.orig 2010-07-09 18:22:44.904069119 +0200
108 @@ -0,0 +1,57 @@
109 +# Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
111 +# This library is free software; you can redistribute it and/or
112 +# modify it under the terms of the GNU Lesser General Public
113 +# License as published by the Free Software Foundation; either
114 +# version 2.1 of the License.
116 +# This library is distributed in the hope that it will be useful,
117 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
118 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
119 +# Lesser General Public License for more details.
121 +# You should have received a copy of the GNU Lesser General Public
122 +# License along with this library; if not, write to the Free Software
123 +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
125 +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
128 +# File :
129 +# Author :
130 +# Module :
131 +# $Header: /home/server/cvs/MED/MED_SRC/src/MEDWrapper/Factory/Makefile.am,v 1.3.2.1.10.1 2010-04-21 15:30:33 vsr Exp $
133 +include $(top_srcdir)/adm_local/unix/make_common_starter.am
135 +lib_LTLIBRARIES= libMEDWrapper.la
137 +salomeinclude_HEADERS= \
138 + MED_Factory.hxx \
139 + MED_WrapperFactory.hxx
141 +dist_libMEDWrapper_la_SOURCES= \
142 + MED_Factory.cxx
144 +libMEDWrapper_la_CPPFLAGS= $(BOOST_CPPFLAGS) $(MED2_INCLUDES) \
145 + -I$(srcdir)/../Base
146 +if MED_ENABLE_KERNEL
147 + libMEDWrapper_la_CPPFLAGS+= -I$(KERNEL_ROOT_DIR)/include/salome
148 +else
149 + libMEDWrapper_la_CPPFLAGS+= -I$(top_builddir)/adm_local_without_kernel/unix
150 +endif
151 +libMEDWrapper_la_CPPFLAGS+= -I$(srcdir)/../V2_1/Wrapper -I$(srcdir)/../V2_2
152 +libMEDWrapper_la_LDFLAGS= ../V2_2/libMEDWrapper_V2_2.la ../V2_1/Wrapper/libMEDWrapper_V2_1.la
154 +# Executables targets
155 +bin_PROGRAMS = MED_Test mprint_version
157 +dist_MED_Test_SOURCES= MED_Test.cxx
158 +MED_Test_CPPFLAGS= $(libMEDWrapper_la_CPPFLAGS)
159 +MED_Test_LDADD= $(libMEDWrapper_la_LDFLAGS) ../Base/libMEDWrapperBase.la ../V2_1/Core/libmed_V2_1.la \
160 + $(BOOST_LIB_THREAD) libMEDWrapper.la
162 +dist_mprint_version_SOURCES= mprint_version.cxx
163 +mprint_version_CPPFLAGS= $(libMEDWrapper_la_CPPFLAGS)
164 +mprint_version_LDADD= $(libMEDWrapper_la_LDFLAGS) ../Base/libMEDWrapperBase.la ../V2_1/Core/libmed_V2_1.la \
165 + $(BOOST_LIB_THREAD) libMEDWrapper.la
166 diff -Naur MED_SRC_5.1.4.orig//src/MULTIPR/MULTIPR_API.cxx MED_SRC_5.1.4/src/MULTIPR/MULTIPR_API.cxx
167 --- MED_SRC_5.1.4.orig//src/MULTIPR/MULTIPR_API.cxx 2010-07-07 20:06:41.002664464 +0200
168 +++ MED_SRC_5.1.4/src/MULTIPR/MULTIPR_API.cxx 2010-07-09 18:23:02.861447613 +0200
169 @@ -33,6 +33,11 @@
170 // Includes section
171 //*****************************************************************************
173 +extern "C" {
174 + // #undef MED_H
175 + #include <med.h>
178 #include "MULTIPR_API.hxx"
179 #include "MULTIPR_Globals.hxx"
180 #include "MULTIPR_Mesh.hxx"
181 @@ -40,11 +45,6 @@
182 #include "MULTIPR_Utils.hxx"
183 #include "MULTIPR_Exceptions.hxx"
185 -extern "C"
187 - #include "med.h"
190 #include "MEDSPLITTER_API.hxx"
192 #include <iostream>
193 @@ -53,7 +53,6 @@
195 using namespace std;
198 //*****************************************************************************
199 // Implementation
200 //*****************************************************************************
201 diff -Naur MED_SRC_5.1.4.orig//src/MULTIPR/MULTIPR_API.cxx.orig MED_SRC_5.1.4/src/MULTIPR/MULTIPR_API.cxx.orig
202 --- MED_SRC_5.1.4.orig//src/MULTIPR/MULTIPR_API.cxx.orig 1970-01-01 01:00:00.000000000 +0100
203 +++ MED_SRC_5.1.4/src/MULTIPR/MULTIPR_API.cxx.orig 2010-07-09 18:22:44.934135679 +0200
204 @@ -0,0 +1,278 @@
205 +// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
207 +// This library is free software; you can redistribute it and/or
208 +// modify it under the terms of the GNU Lesser General Public
209 +// License as published by the Free Software Foundation; either
210 +// version 2.1 of the License.
212 +// This library is distributed in the hope that it will be useful,
213 +// but WITHOUT ANY WARRANTY; without even the implied warranty of
214 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
215 +// Lesser General Public License for more details.
217 +// You should have received a copy of the GNU Lesser General Public
218 +// License along with this library; if not, write to the Free Software
219 +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
221 +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
224 +// Partitioning/decimation module for the SALOME v3.2 platform
226 +/**
227 + * \file MULTIPR_API.cxx
229 + * \brief see MULTIPR_API.hxx
231 + * \author Olivier LE ROUX - CS, Virtual Reality Dpt
232 + *
233 + * \date 01/2007
234 + */
236 +//*****************************************************************************
237 +// Includes section
238 +//*****************************************************************************
240 +#include "MULTIPR_API.hxx"
241 +#include "MULTIPR_Globals.hxx"
242 +#include "MULTIPR_Mesh.hxx"
243 +#include "MULTIPR_MeshDis.hxx"
244 +#include "MULTIPR_Utils.hxx"
245 +#include "MULTIPR_Exceptions.hxx"
247 +extern "C"
249 + #include "med.h"
252 +#include "MEDSPLITTER_API.hxx"
254 +#include <iostream>
255 +#include <fstream>
256 +#include <string>
258 +using namespace std;
261 +//*****************************************************************************
262 +// Implementation
263 +//*****************************************************************************
265 +const char* multipr::getVersion()
267 + return "2.0.1";
271 +void multipr::partitionneDomaine(const char* pMEDfilename, const char* pMeshName)
273 + if (pMEDfilename == NULL) throw NullArgumentException("pMEDfilename should not be NULL", __FILE__, __LINE__);
274 + if (pMeshName == NULL) throw NullArgumentException("pMeshName should not be NULL", __FILE__, __LINE__);
276 + //---------------------------------------------------------------------
277 + // Read the sequential mesh
278 + //---------------------------------------------------------------------
279 + cout << "Read sequential MED file: " <<
280 + pMEDfilename << ": please wait... " << endl;
282 + multipr::Mesh mesh;
283 + mesh.readSequentialMED(pMEDfilename, pMeshName, false);
284 + std::vector<Group*>* lGroups = mesh.getGroups();
285 + cout << mesh << endl;
287 + //---------------------------------------------------------------------
288 + // Build distributed mesh from groups
289 + //---------------------------------------------------------------------
290 + cout << "Build distributed mesh: please wait... " << endl;
292 + multipr::MeshDis* meshDis = NULL;
294 + try
296 + GaussIndexList* lGaussList;
297 + meshDis = mesh.splitGroupsOfElements();
298 + lGaussList = mesh.editGaussIndex();
299 + std::vector<Profil*>& lProfils = mesh.getProfils();
300 + //-------------------------------------------------------------
301 + // Write distributed mesh
302 + //-------------------------------------------------------------
303 + cout << "Write distributed mesh: please wait... " << endl;
304 + string strPrefix = removeExtension(pMEDfilename, ".med");
305 + meshDis->writeDistributedMED(strPrefix.c_str());
306 + meshDis->readAndWriteFields(pMeshName, lGroups, lGaussList, lProfils);
307 + // need to delete some garb
308 + lGaussList->clear();
309 + delete meshDis;
311 + catch (RuntimeException& e)
313 + delete meshDis;
314 + throw e;
319 +void multipr::partitionneGroupe(
320 + const char* pMEDfilename,
321 + const char* pGroupName,
322 + int pNbParts,
323 + int pPartitionner)
325 + if (pMEDfilename == NULL) throw NullArgumentException("pMEDfilename should not be NULL", __FILE__, __LINE__);
326 + if (pGroupName == NULL) throw NullArgumentException("pGroupName should not be NULL", __FILE__, __LINE__);
327 + if (pNbParts < 2) throw IllegalArgumentException("pNbParts should be >= 2", __FILE__, __LINE__);
328 + if ((pPartitionner != MULTIPR_METIS) && (pPartitionner != MULTIPR_SCOTCH)) throw NullArgumentException("pPartitionner should be METIS (0) or SCOTCH (1)", __FILE__, __LINE__);
330 + //---------------------------------------------------------------------
331 + // Read the distributed mesh
332 + //---------------------------------------------------------------------
333 + MULTIPR_LOG("Read distributed MED file: " << pMEDfilename << ": please wait... " << endl);
335 + int ret = MEDformatConforme(pMEDfilename);
336 + if (ret == 0) throw IOException("waiting for a distributed MED file (not a sequential one)", __FILE__, __LINE__);
338 + multipr::MeshDis meshDis;
339 + meshDis.readDistributedMED(pMEDfilename);
340 + cout << meshDis << endl;
342 + //---------------------------------------------------------------------
343 + // Split the given part (pGroupName)
344 + //---------------------------------------------------------------------
345 + if (pPartitionner == MULTIPR_METIS)
347 + cout << "Use METIS" << endl;
349 + else if (pPartitionner == MULTIPR_SCOTCH)
351 + cout << "Use SCOTCH" << endl;
354 + meshDis.splitPart(pGroupName, pNbParts, pPartitionner);
355 + cout << meshDis << endl;
357 + //---------------------------------------------------------------------
358 + // Write new distributed mesh
359 + //---------------------------------------------------------------------
360 + string strPrefix = multipr::removeExtension(pMEDfilename, ".med");
361 + meshDis.writeDistributedMED(strPrefix.c_str());
365 +void multipr::decimePartition(
366 + const char* pMEDfilename,
367 + const char* pPartName,
368 + const char* pFieldName,
369 + int pFieldIt,
370 + const char* pFilterName,
371 + const char* pFilterParams)
373 + //---------------------------------------------------------------------
374 + // Check arguments
375 + //---------------------------------------------------------------------
376 + if (pMEDfilename == NULL) throw NullArgumentException("pMEDfilename should not be NULL", __FILE__, __LINE__);
377 + if (pPartName == NULL) throw NullArgumentException("pPartName should not be NULL", __FILE__, __LINE__);
378 + if (pFieldName == NULL) throw NullArgumentException("pFieldName should not be NULL", __FILE__, __LINE__);
379 + if (pFieldIt < 1) throw IllegalArgumentException("pFieldIt: invalid field iteration; should be >= 1", __FILE__, __LINE__);
380 + /*
381 + if (pTMed < 0.0) throw IllegalArgumentException("med res.: threshold must be > 0", __FILE__, __LINE__);
382 + if (pTMed >= pTLow) throw IllegalArgumentException("threshold for med res. must be < threshold for low res.", __FILE__, __LINE__);
383 + if (pRadius <= 0.0) throw IllegalArgumentException("radius should be > 0", __FILE__, __LINE__);
384 + if ((pBoxing < 1) || (pBoxing > 200)) throw IllegalArgumentException("boxing should be in [1..200]", __FILE__, __LINE__);
385 + */
387 + //cout << "--decim file=" << pMEDfilename << " part=" << pPartName << " filter=" << pFilterName << " tmed=" << pTMed << " tlow=" << pTLow << " radius=" << pRadius << endl;
389 + //---------------------------------------------------------------------
390 + // Read the distributed mesh
391 + //---------------------------------------------------------------------
392 + MULTIPR_LOG("Read distributed MED file: " << pMEDfilename << ": please wait... " << endl);
394 + int ret = MEDformatConforme(pMEDfilename);
395 + if (ret == 0) throw IOException("waiting for a distributed MED file (not a sequential one)", __FILE__, __LINE__);
397 + multipr::MeshDis meshDis;
398 + meshDis.readDistributedMED(pMEDfilename);
399 + cout << meshDis << endl;
401 + //---------------------------------------------------------------------
402 + // Create 3 resolutions of the given part
403 + //---------------------------------------------------------------------
404 + meshDis.decimatePart(
405 + pPartName,
406 + pFieldName,
407 + pFieldIt,
408 + pFilterName,
409 + pFilterParams);
410 + cout << meshDis << endl;
412 + //---------------------------------------------------------------------
413 + // Write new distributed mesh
414 + //---------------------------------------------------------------------
415 + string strPrefix = removeExtension(pMEDfilename, ".med"); // get prefix from the original MED filename
416 + meshDis.writeDistributedMED(strPrefix.c_str());
420 +int multipr::merge(
421 + std::vector<std::string> pMEDFilenameSrc,
422 + const char* pMeshName,
423 + const char* pFieldName,
424 + const char* pMEDFilenameDst)
426 + if (pMEDFilenameSrc.size() < 2) throw IllegalArgumentException("list must contain two files at least", __FILE__, __LINE__);
427 + if (pMeshName == NULL) throw NullArgumentException("pMeshName should not be NULL", __FILE__, __LINE__);
428 + if (pMEDFilenameDst == NULL) throw NullArgumentException("pMEDFilenameDst should not be NULL", __FILE__, __LINE__);
430 + //---------------------------------------------------------------------
431 + // Read sources
432 + //---------------------------------------------------------------------
433 + std::vector<multipr::Mesh*> meshes;
434 + for (unsigned i = 0 ; i < pMEDFilenameSrc.size() ; i++)
436 + multipr::Mesh* mesh = new multipr::Mesh();
437 + mesh->readSequentialMED(pMEDFilenameSrc[i].c_str(), 1);
439 + if (mesh->getNumberOfElements() != 0)
441 + meshes.push_back(mesh);
443 + else
445 + delete mesh;
449 + // if no mesh (all meshes are empty) => return
450 + if (meshes.size() == 0) return 0;
452 + // if only one non-empty mesh
453 + if (meshes.size() == 1)
455 + multipr::Mesh* mesh = meshes[0];
456 + mesh->writeMED(pMEDFilenameDst);
457 + delete mesh;
458 + return 1;
461 + //---------------------------------------------------------------------
462 + // Merge sources and write resulting mesh to disk
463 + //---------------------------------------------------------------------
464 + multipr::Mesh* meshFirst = meshes.back();
465 + meshes.pop_back();
466 + multipr::Mesh* meshMerged = meshFirst->mergePartial(meshes, pFieldName, -1);
467 + //meshMerged->setPrintAll(true);
468 + //cout << (*meshMerged) << endl;
470 + meshMerged->writeMED(pMEDFilenameDst, pMeshName);
472 + delete meshMerged;
473 + delete meshFirst;
474 + for (unsigned i = 0 ; i < meshes.size(); i++)
476 + delete meshes[i];
478 + return 1;
482 +// EOF
483 diff -Naur MED_SRC_5.1.4.orig//src/MULTIPR/MULTIPR_Obj.cxx MED_SRC_5.1.4/src/MULTIPR/MULTIPR_Obj.cxx
484 --- MED_SRC_5.1.4.orig//src/MULTIPR/MULTIPR_Obj.cxx 2010-07-07 20:06:41.025925300 +0200
485 +++ MED_SRC_5.1.4/src/MULTIPR/MULTIPR_Obj.cxx 2010-07-09 18:23:02.884493897 +0200
486 @@ -33,6 +33,10 @@
487 // Includes section
488 //*****************************************************************************
490 +extern "C" {
491 +#include <med.h>
494 #include "MULTIPR_Obj.hxx"
495 #include "MULTIPR_Exceptions.hxx"
496 #include "MULTIPR_Mesh.hxx"
497 diff -Naur MED_SRC_5.1.4.orig//src/MULTIPR/MULTIPR_Obj.cxx.orig MED_SRC_5.1.4/src/MULTIPR/MULTIPR_Obj.cxx.orig
498 --- MED_SRC_5.1.4.orig//src/MULTIPR/MULTIPR_Obj.cxx.orig 1970-01-01 01:00:00.000000000 +0100
499 +++ MED_SRC_5.1.4/src/MULTIPR/MULTIPR_Obj.cxx.orig 2010-07-09 18:22:44.937402244 +0200
500 @@ -0,0 +1,757 @@
501 +// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
503 +// This library is free software; you can redistribute it and/or
504 +// modify it under the terms of the GNU Lesser General Public
505 +// License as published by the Free Software Foundation; either
506 +// version 2.1 of the License.
508 +// This library is distributed in the hope that it will be useful,
509 +// but WITHOUT ANY WARRANTY; without even the implied warranty of
510 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
511 +// Lesser General Public License for more details.
513 +// You should have received a copy of the GNU Lesser General Public
514 +// License along with this library; if not, write to the Free Software
515 +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
517 +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
520 +// Partitioning/decimation module for the SALOME v3.2 platform
522 +/**
523 + * \file MULTIPR_Obj.cxx
525 + * \brief see MULTIPR_Obj.hxx
527 + * \author Olivier LE ROUX - CS, Virtual Reality Dpt
528 + *
529 + * \date 01/2007
530 + */
532 +//*****************************************************************************
533 +// Includes section
534 +//*****************************************************************************
536 +#include "MULTIPR_Obj.hxx"
537 +#include "MULTIPR_Exceptions.hxx"
538 +#include "MULTIPR_Mesh.hxx"
539 +#include "MULTIPR_Family.hxx"
540 +#include "MULTIPR_MeshDis.hxx"
541 +#include "MULTIPR_Utils.hxx"
542 +#include "MULTIPR_Profil.hxx"
543 +#include "MED_Factory.hxx"
545 +#include <stdio.h>
546 +#include <iostream>
547 +#include <errno.h>
549 +extern int errno;
551 +using namespace std;
554 +namespace multipr
557 +//*****************************************************************************
558 +// Class Obj implementation
559 +//*****************************************************************************
561 +Obj::Obj()
562 + : mMeshDis(NULL)
564 + reset();
568 +Obj::~Obj()
570 + reset();
574 +void Obj::reset()
576 + mPrevPath = "";
577 + mMEDfilename = "";
578 + mMeshName = "";
579 + mState = MULTIPR_OBJ_STATE_RESET;
580 + mDoReadWriteFields = false;
582 + mGaussList.clear();
583 + for (std::vector<Group*>::iterator it = mGroups.begin(); it != mGroups.end(); ++it)
585 + delete *it;
587 + mGroups.clear();
589 + if (mMeshDis != NULL) {
590 + delete mMeshDis;
591 + mMeshDis = NULL;
596 +void Obj::create(const char* pMEDfilename)
598 + if (pMEDfilename == NULL)
599 + throw multipr::NullArgumentException("file name must not be NULL", __FILE__, __LINE__);
601 + // reset everything before associating a new MED file to this object
602 + reset();
604 + mMEDfilename = pMEDfilename;
606 + // check if file exists
607 + FILE* f = fopen(pMEDfilename, "rb");
609 + // Big file (> 2Go) problem : since the other library may use 32bits off_t we check
610 + // the EFBIG error. Compile with -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
611 + // -D_LARGEFILE64_SOURCE flags to resolve this issue.
612 + if (f == NULL && errno == EFBIG)
614 + mState = MULTIPR_OBJ_STATE_ERROR;
615 + throw IOException("Big file error : please compile with -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE flags.", __FILE__, __LINE__);
617 + if (f == NULL)
619 + // file does not exist
620 + mState = MULTIPR_OBJ_STATE_ERROR;
621 + throw FileNotFoundException("file not found", __FILE__, __LINE__);
623 + fclose(f);
625 + // test whether it is a sequential MED file or a distributed MED file.
626 + MED::EVersion aVersion = MED::GetVersionId(pMEDfilename, true);
627 + if (aVersion != MED::eVUnknown)
629 + // sequential MED file has been sucessfuly openened
631 + // CASE 1: sequential MED file
632 + mState = MULTIPR_OBJ_STATE_SEQ_INIT;
633 + cout << "Sequential MED file " << pMEDfilename << " has been successfuly opened" << endl;
635 + else
637 + // CASE 2: distributed MED file?
638 + try
640 + mMeshDis = new multipr::MeshDis();
641 + mMeshDis->readDistributedMED(pMEDfilename);
643 + mState = MULTIPR_OBJ_STATE_DIS;
644 + cout << "Distributed MED file " << pMEDfilename << " has been successfuly opened" << endl;
646 + catch (RuntimeException& e)
648 + e.dump(cout);
649 + // neither a sequential MED file, nor a distributed MED file => error
650 + mState = MULTIPR_OBJ_STATE_ERROR;
651 + throw IOException("file is nor a sequential MED file, neither a distributed MED file", __FILE__, __LINE__);
657 +std::string Obj::getSequentialMEDFilename() const
659 + // partitionneGroupe() is only available for distributed MED file (not sequential MED file)
660 + if ((mState != MULTIPR_OBJ_STATE_DIS_MEM) &&
661 + (mState != MULTIPR_OBJ_STATE_DIS)) throw IllegalStateException("unexpected operation", __FILE__, __LINE__);
663 + return mMeshDis->getSequentialMEDFilename();
667 +void Obj::setMesh(const char* pMeshName)
669 + // setMesh() is only available for sequential MED file (not distributed MED file)
670 + if ((mState != MULTIPR_OBJ_STATE_SEQ_INIT) &&
671 + (mState != MULTIPR_OBJ_STATE_SEQ)) throw IllegalStateException("expected a sequential MED file", __FILE__, __LINE__);
673 + mMeshName = pMeshName;
675 + // change state to MULTIPR_OBJ_STATE_SEQ (in case of state=MULTIPR_OBJ_STATE_SEQ_INIT)
676 + mState = MULTIPR_OBJ_STATE_SEQ;
680 +vector<string> Obj::getMeshes() const
682 + // test whether it is a sequential MED file or a distributed MED file
683 + if ((mState == MULTIPR_OBJ_STATE_SEQ_INIT) ||
684 + (mState == MULTIPR_OBJ_STATE_SEQ))
686 + // CASE 1: sequential MED file
687 + return multipr::getListMeshes(mMEDfilename.c_str());
689 + else
691 + // CASE 2: distributed MED file
692 + if (mMeshDis == NULL)
694 + throw IllegalStateException("distributed MED file should not be NULL", __FILE__, __LINE__);
697 + return mMeshDis->getMeshes();
702 +vector<string> Obj::getFields(const char* pPartList) const
704 + vector<string> res;
705 + // test whether it is a sequential MED file or a distributed MED file
706 + if ((mState == MULTIPR_OBJ_STATE_SEQ_INIT) ||
707 + (mState == MULTIPR_OBJ_STATE_SEQ))
709 + // CASE 1: sequential MED file
710 + vector<pair<string, int> > tmp;
711 + multipr::getListScalarFields(mMEDfilename.c_str(), tmp, true, mMeshName.c_str());
713 + for (unsigned i = 0 ; i < tmp.size() ; i++)
715 + res.push_back(tmp[i].first);
718 + return res;
720 + else
722 + // CASE 2: distributed MED file
723 + if (mMeshDis == NULL)
724 + throw IllegalStateException("distributed MED file should not be NULL", __FILE__, __LINE__);
725 + if (pPartList != NULL)
727 + return mMeshDis->getFields(pPartList, true);
729 + else
731 + return res;
734 + return res;
738 +int Obj::getTimeStamps(const char* pPartList, const char* pFieldName) const
740 + // test whether it is a sequential MED file or a distributed MED file
741 + if ((mState == MULTIPR_OBJ_STATE_SEQ_INIT) ||
742 + (mState == MULTIPR_OBJ_STATE_SEQ))
744 + // CASE 1: sequential MED file
745 + vector<pair<string, int> > tmp;
746 + multipr::getListScalarFields(mMEDfilename.c_str(), tmp);
747 + for (unsigned i = 0 ; i < tmp.size() ; i++)
749 + if (strcmp(tmp[i].first.c_str(), pFieldName) == 0)
751 + return tmp[i].second;
754 + // pFieldName not found in the list of fields
755 + return 0;
757 + else
759 + // CASE 2: distributed MED file
760 + if (mMeshDis == NULL)
761 + throw IllegalStateException("distributed MED file should not be NULL", __FILE__, __LINE__);
762 + if (pPartList != NULL)
764 + return mMeshDis->getTimeStamps(pPartList, pFieldName);
766 + else
768 + return 0;
771 + return 0;
774 +void Obj::getFieldMinMax(const char* pPartName, const char* pFieldName, float& pMin, float& pMax)
776 + // getFieldMinMax() is only available for distributed MED file (not sequential MED file)
777 + if ((mState != MULTIPR_OBJ_STATE_DIS) &&
778 + (mState != MULTIPR_OBJ_STATE_DIS_MEM)) throw IllegalStateException("expected a distributed MED file", __FILE__, __LINE__);
779 + if (mMeshDis == NULL) throw IllegalStateException("distributed MED file should not be NULL", __FILE__, __LINE__);
781 + pMin = 0.0f;
782 + pMax = 0.0f;
784 + MeshDisPart* part = mMeshDis->findPart(pPartName);
785 + if (part == NULL)
787 + return;
789 + if (part->getMesh() == NULL)
791 + part->readMED();
793 + part->getMesh()->getFieldMinMax(pFieldName, pMin, pMax);
796 +vector<string> Obj::getParts() const
798 + // getParts() is only available for distributed MED file (not sequential MED file)
799 + if ((mState != MULTIPR_OBJ_STATE_DIS) &&
800 + (mState != MULTIPR_OBJ_STATE_DIS_MEM))
802 + throw IllegalStateException("expected a distributed MED file", __FILE__, __LINE__);
804 + return getListParts();
808 +string Obj::getPartInfo(const char* pPartName) const
810 + // getParts() is only available for distributed MED file (not sequential MED file)
811 + if ((mState != MULTIPR_OBJ_STATE_DIS) &&
812 + (mState != MULTIPR_OBJ_STATE_DIS_MEM)) throw IllegalStateException("expected a distributed MED file", __FILE__, __LINE__);
814 + if (mMeshDis == NULL) throw IllegalStateException("distributed MED file should not be NULL", __FILE__, __LINE__);
816 + return mMeshDis->getPartInfo(pPartName);
821 +void Obj::removeParts(const char* pPrefixPartName)
823 + // removePart() is only available for distributed MED file (not sequential MED file)
824 + if ((mState != MULTIPR_OBJ_STATE_DIS) &&
825 + (mState != MULTIPR_OBJ_STATE_DIS_MEM)) throw IllegalStateException("expected a distributed MED file", __FILE__, __LINE__);
827 + if (mMeshDis == NULL) throw IllegalStateException("distributed MED file should not be NULL", __FILE__, __LINE__);
829 + mMeshDis->removeParts(pPrefixPartName);
830 + mState = MULTIPR_OBJ_STATE_DIS_MEM;
834 +vector<string> Obj::partitionneDomaine()
836 + if (mState == MULTIPR_OBJ_STATE_SEQ_INIT) throw IllegalStateException("use setMesh() before", __FILE__, __LINE__);
838 + // partitionneDomaine() is only available for sequential MED file (not distributed MED file)
839 + if (mState != MULTIPR_OBJ_STATE_SEQ) throw IllegalStateException("unexpected operation", __FILE__, __LINE__);
841 + //-------------------------------------------------------------
842 + // Read the sequential mesh
843 + //-------------------------------------------------------------
844 + cout << "Read sequential MED file: " << mMEDfilename << ": please wait... " << endl;
846 + Mesh mesh;
847 + mesh.readSequentialMED(mMEDfilename.c_str(), mMeshName.c_str(), false);
848 + // We need to COPY the groups of the original mesh.
849 + // We delete the mesh at the end of the domain split but we still need
850 + // the groups for the optimized field extraction.
851 + // This data will be used and deleted in the save method.
852 + std::vector<Group*>* lGroups = mesh.getGroups();
853 + std::vector<Group*>::iterator it;
854 + Group* curGroup;
855 + for (it = lGroups->begin(); it != lGroups->end(); ++it)
857 + curGroup = new Group();
858 + curGroup->setName((*it)->getName());
859 + for (int i = 0; i < eMaxMedMesh; ++i)
861 + curGroup->setSetOfElt((eMeshType)i, (*it)->getSetOfElt((eMeshType)i));
863 + curGroup->setIsGroupOfNodes((*it)->isGroupOfNodes());
864 + mGroups.push_back(curGroup);
866 + cout << mesh << endl;
868 + //-------------------------------------------------------------
869 + // Build distributed mesh from groups
870 + //-------------------------------------------------------------
871 + cout << "Build distributed mesh: please wait... " << endl;
872 + try
874 + // We need to COPY the gauss information from the original mesh (look at previous comment).
875 + mMeshDis = mesh.splitGroupsOfElements();
876 + mGaussList = *mesh.editGaussIndex();
877 + mesh.editGaussIndex()->clear();
878 + // We need to COPY the profiles of the original mesh (look at previous comment).
879 + std::vector<Profil*>& lProfils = mesh.getProfils();
880 + for (std::vector<Profil*>::iterator it = lProfils.begin(); it != lProfils.end(); ++it)
882 + mProfils.push_back(new Profil(*(*it)));
884 + mDoReadWriteFields = true;
886 + catch (RuntimeException& e)
888 + e.dump(cout);
889 + delete mMeshDis;
890 + mMeshDis = NULL;
891 + throw e;
894 + mState = MULTIPR_OBJ_STATE_DIS_MEM;
896 + return getListParts();
900 +vector<string> Obj::partitionneGroupe(
901 + const char* pPartName,
902 + int pNbParts,
903 + int pPartitionner)
905 + if (mMeshDis == NULL) throw IllegalStateException("expected a distributed MED file", __FILE__, __LINE__);
906 + if (pPartName == NULL)
907 + throw NullArgumentException("part name is empty", __FILE__, __LINE__);
908 + if (pNbParts < 2)
909 + throw IllegalArgumentException("number of parts must be at least two", __FILE__, __LINE__);
910 + if ((pPartitionner != 0) && (pPartitionner != 1)) throw IllegalArgumentException("partitionner should be 0=METIS or 1=SCOTCH", __FILE__, __LINE__);
912 + // partitionneGroupe() is only available for distributed MED file (not sequential MED file)
913 + if ((mState != MULTIPR_OBJ_STATE_DIS_MEM) &&
914 + (mState != MULTIPR_OBJ_STATE_DIS)) throw IllegalStateException("unexpected operation", __FILE__, __LINE__);
916 + // if distributed MED file is currently in memory,
917 + // then write to disk before performing partitionneGroupe()
918 + // (because MEDSPLIITER starts from a file)
919 + if (mState == MULTIPR_OBJ_STATE_DIS_MEM)
921 + //-----------------------------------------------------
922 + // Write distributed mesh
923 + //-----------------------------------------------------
924 + cout << "Write distributed mesh: please wait... " << endl;
925 + string strPrefix = removeExtension(mMEDfilename.c_str(), ".med");
926 + mMeshDis->writeDistributedMED(strPrefix.c_str());
928 + mMEDfilename = mMeshDis->getDistributedMEDFilename();
930 + delete mMeshDis;
932 + //---------------------------------------------------------------------
933 + // Read the distributed mesh
934 + //---------------------------------------------------------------------
935 + int ret = MEDformatConforme(mMEDfilename.c_str());
936 + if (ret == 0)
937 + throw IOException("waiting for a distributed MED file (not a sequential one)", __FILE__, __LINE__);
939 + mMeshDis = new MeshDis();
940 + mMeshDis->readDistributedMED(mMEDfilename.c_str());
942 + mState = MULTIPR_OBJ_STATE_DIS;
945 + //---------------------------------------------------------------------
946 + // Split the given part (pGroupName)
947 + //---------------------------------------------------------------------
948 + mMeshDis->splitPart(pPartName, pNbParts, pPartitionner);
949 + cout << mMeshDis << endl;
951 + //---------------------------------------------------------------------
952 + // Write new distributed mesh
953 + //---------------------------------------------------------------------
954 + string strPrefix = multipr::removeExtension(mMEDfilename.c_str(), ".med");
955 + mMeshDis->writeDistributedMED(strPrefix.c_str());
957 + //---------------------------------------------------------------------
958 + // Read the distributed mesh
959 + //---------------------------------------------------------------------
960 + delete mMeshDis;
961 + mMeshDis = new MeshDis();
962 + //cout << "read dis MED file: filename=" << mMEDfilename << endl;
963 + mMeshDis->readDistributedMED(mMEDfilename.c_str());
965 + return getListParts();
969 +vector<string> Obj::decimePartition(
970 + const char* pPartName,
971 + const char* pFieldName,
972 + int pFieldIt,
973 + const char* pFilterName,
974 + const char* pFilterParams)
976 + std::list<std::string> pEmptyMeshes;
977 + return decimePartition(pPartName,
978 + pFieldName,
979 + pFieldIt,
980 + pFilterName,
981 + pFilterParams,
982 + pEmptyMeshes);
986 +vector<string> Obj::decimePartition (const char* pPartName,
987 + const char* pFieldName,
988 + int pFieldIt,
989 + const char* pFilterName,
990 + const char* pFilterParams,
991 + std::list<std::string>& pEmptyMeshes)
993 + vector<string> ret;
994 + // decimePartition() is only available for distributed MED file (not sequential MED file)
995 + if ((mState != MULTIPR_OBJ_STATE_DIS_MEM) &&
996 + (mState != MULTIPR_OBJ_STATE_DIS))
997 + throw IllegalStateException("unexpected operation", __FILE__, __LINE__);
999 + if (mMeshDis == NULL) throw IllegalStateException("expected a distributed MED file", __FILE__, __LINE__);
1001 + //---------------------------------------------------------------------
1002 + // Decimate
1003 + //---------------------------------------------------------------------
1004 + std::list<std::string> emptyMeshes = mMeshDis->decimatePart(
1005 + pPartName,
1006 + pFieldName,
1007 + pFieldIt,
1008 + pFilterName,
1009 + pFilterParams);
1011 + std::list<std::string>::iterator it = emptyMeshes.begin(), end = emptyMeshes.end();
1012 + for (; it != end; it++)
1014 + pEmptyMeshes.push_back(*it);
1017 + mState = MULTIPR_OBJ_STATE_DIS_MEM;
1019 + ret = getListParts();
1020 + ret.push_back(mMeshDis->getDecimationStatistics());
1021 + return ret;
1025 +string Obj::evalDecimationParams(
1026 + const char* pPartName,
1027 + const char* pFieldName,
1028 + int pFieldIt,
1029 + const char* pFilterName,
1030 + const char* pFilterParams)
1032 + // decimePartition() is only available for distributed MED file (not sequential MED file)
1033 + if ((mState != MULTIPR_OBJ_STATE_DIS_MEM) &&
1034 + (mState != MULTIPR_OBJ_STATE_DIS)) throw IllegalStateException("unexpected operation", __FILE__, __LINE__);
1036 + if (mMeshDis == NULL) throw IllegalStateException("expected a distributed MED file", __FILE__, __LINE__);
1038 + string res = mMeshDis->evalDecimationParams(
1039 + pPartName,
1040 + pFieldName,
1041 + pFieldIt,
1042 + pFilterName,
1043 + pFilterParams);
1045 + return res;
1048 +void Obj::getMEDInfo(char* pStats, char* pPartName)
1051 + med_idt lMEDfile;
1052 + med_int lRet;
1054 + // Get the mesh path
1055 + MeshDisPart* curMeshDis = this->mMeshDis->findPart(pPartName);
1056 + if (curMeshDis == NULL)
1058 + throw IllegalStateException("Can't find part.", __FILE__, __LINE__);
1059 + return ;
1061 + const char* curMesh = curMeshDis->getMEDFileName();
1062 + if (curMesh == NULL)
1064 + throw IllegalStateException("Can't find mesh.", __FILE__, __LINE__);
1065 + return ;
1068 + // open MED file for reading
1069 + lMEDfile = MEDouvrir(const_cast<char*>(curMesh), MED_LECTURE);
1070 + if (lMEDfile <= 0)
1072 + throw IllegalStateException("Can't open file.", __FILE__, __LINE__);
1073 + return ;
1075 + const char* meshName = curMeshDis->getMeshName();
1076 + if (meshName == 0)
1078 + throw IllegalStateException("Can't find mesh name.", __FILE__, __LINE__);
1079 + }
1080 + // Get the number of cells
1081 + for (int itCell = 0 ; itCell < MED_NBR_GEOMETRIE_MAILLE ; itCell++)
1083 + lRet = MEDnEntMaa(lMEDfile, const_cast<char*>(meshName), MED_CONN, MED_MAILLE, CELL_TYPES[itCell], MED_NOD);
1084 + if (lRet > 0)
1086 + break;
1089 + sprintf(pStats, "%d", lRet);
1092 +vector<string> Obj::getListParts() const
1094 + if (mMeshDis == NULL) throw IllegalStateException("not a distributed mesh", __FILE__, __LINE__);
1096 + vector<string> names;
1098 + int numParts = mMeshDis->getNumParts();
1099 + for (int i = 0 ; i < numParts ; i++)
1101 + names.push_back( mMeshDis->getPart(i)->getPartName() );
1104 + return names;
1108 +void Obj::save(const char* pPath)
1110 + // only save file if it is a distributed MED file currently in memory or path has changed
1111 + if ((mState == MULTIPR_OBJ_STATE_DIS_MEM) || (strcmp(pPath, mPrevPath.c_str()) != 0))
1113 + mPrevPath = pPath;
1115 + //-------------------------------------------------------------
1116 + // Write new distributed mesh
1117 + //-------------------------------------------------------------
1118 + string filename;
1119 + if (strlen(pPath) == 0)
1121 + filename = multipr::removeExtension(mMEDfilename.c_str(), ".med");
1123 + else
1125 + filename = string(pPath) + string("/") + multipr::getFilenameWithoutPath(mMEDfilename.c_str());
1127 + string strPrefix = multipr::removeExtension(filename.c_str(), ".med");
1128 + mMeshDis->writeDistributedMED(strPrefix.c_str());
1129 + if (mDoReadWriteFields == true)
1131 + try
1133 + mMeshDis->readAndWriteFields(mMeshName.c_str(), &mGroups, &mGaussList, mProfils);
1136 + catch (RuntimeException& e)
1138 + e.dump(cout);
1139 + delete mMeshDis;
1140 + mMeshDis = NULL;
1141 + throw e;
1142 + }
1143 + // need to delete some garb
1144 + mGaussList.clear();
1145 + for (std::vector<Group*>::iterator it = mGroups.begin(); it != mGroups.end(); ++it)
1147 + delete *it;
1149 + mGroups.clear();
1150 + mDoReadWriteFields = false;
1152 + mMEDfilename = mMeshDis->getDistributedMEDFilename();
1154 + cout << "Write MED master file: " << mMEDfilename << ": OK" << endl;
1156 + //-------------------------------------------------------------
1157 + // Read the distributed mesh
1158 + //-------------------------------------------------------------
1160 + boost::recursive_mutex::scoped_lock aLock (mWriteMutex);
1161 + delete mMeshDis;
1162 + mMeshDis = new MeshDis();
1164 + mMeshDis->readDistributedMED(mMEDfilename.c_str());
1166 + mState = MULTIPR_OBJ_STATE_DIS;
1168 + boost::recursive_mutex::scoped_lock aLock (mWriteMutex);
1169 + mMeshDis->setProgress(100);
1172 +void Obj::resetProgress()
1174 + boost::recursive_mutex::scoped_lock aLock (mWriteMutex);
1175 + mMeshDis->setProgress(0);
1178 +int Obj::getProgress()
1180 + boost::recursive_mutex::scoped_lock aLock (mWriteMutex);
1181 + return mMeshDis->getProgress();
1184 +void Obj::savePersistent (const char* pPath)
1186 + if (pPath == NULL)
1187 + throw multipr::NullArgumentException("path must not be NULL", __FILE__, __LINE__);
1189 + //-------------------------------------------------------------
1190 + // Write distributed mesh
1191 + //-------------------------------------------------------------
1192 + string filename = string(pPath) + string("/") + multipr::getFilenameWithoutPath(mMEDfilename.c_str());
1193 + string strPrefix = multipr::removeExtension(filename.c_str(), ".med");
1194 + mMeshDis->writeDistributedMED(strPrefix.c_str(), /*pIsPersistence*/true);
1197 +void Obj::restorePersistent (const char* pMEDfilename)
1199 + if (pMEDfilename == NULL)
1200 + throw multipr::NullArgumentException("file name must not be NULL", __FILE__, __LINE__);
1202 + // reset everything before associating a new MED file to this object
1203 + reset();
1205 + mMEDfilename = pMEDfilename;
1206 + mState = MULTIPR_OBJ_STATE_ERROR;
1208 + // check if file exists
1209 + FILE* f = fopen(pMEDfilename, "rb");
1210 + if (f == 0)
1212 + // file does not exist
1213 + mState = MULTIPR_OBJ_STATE_ERROR;
1214 + throw FileNotFoundException("file not found", __FILE__, __LINE__);
1216 + fclose(f);
1218 + // test whether it is a sequential MED file or a distributed MED file
1219 + MED::EVersion aVersion = MED::GetVersionId(pMEDfilename, true);
1220 + if (aVersion != MED::eVUnknown)
1222 + mState = MULTIPR_OBJ_STATE_SEQ_INIT;
1223 + cout << "Sequential MED file " << pMEDfilename << " has been successfuly opened" << endl;
1225 + else
1227 + // CASE 2: distributed MED file?
1228 + try
1230 + mMeshDis = new multipr::MeshDis();
1231 + //mMeshDis.reset(new MeshDis());
1232 + mMeshDis->readPersistentDistributedMED(pMEDfilename);
1234 + mState = MULTIPR_OBJ_STATE_DIS;
1235 + cout << "Distributed MED file " << pMEDfilename << " has been successfuly opened" << endl;
1237 + catch (...)
1239 + // neither a sequential MED file, nor a distributed MED file => error
1240 + mState = MULTIPR_OBJ_STATE_ERROR;
1241 + throw IOException("file is neither a sequential, nor a distributed MED file", __FILE__, __LINE__);
1246 +ostream& operator<<(ostream& pOs, Obj& pO)
1248 + pOs << "Obj:" << endl;
1249 + pOs << " Name:" << pO.mMEDfilename << endl;
1251 + return pOs;
1255 +} // namespace multipr
1257 +// EOF