#SUBDIRS(ParaMEDMEMTest)
SUBDIRS(MEDPartitioner_Swig)
SUBDIRS(RENUMBER_Swig)
+SUBDIRS(PyWrapping)
+
INSTALL(TARGETS _medcoupling DESTINATION ${MEDCOUPLING_INSTALL_PYTHON})
INSTALL(FILES medcoupling.i medcoupling_pycode DESTINATION ${MEDCOUPLING_INSTALL_HEADERS})
SALOME_INSTALL_SCRIPTS(${CMAKE_CURRENT_BINARY_DIR}/medcoupling.py ${MEDCOUPLING_INSTALL_PYTHON})
+
+INCLUDE(tests.set)
+
+FOREACH(test ${BASE_TESTS})
+ GET_FILENAME_COMPONENT(testname ${test} NAME_WE)
+ ADD_TEST(NAME ${testname} COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/${test})
+ SET_TESTS_PROPERTIES(${testname} PROPERTIES ENVIRONMENT "${tests_env}")
+ENDFOREACH()
+
+SET(TEST_INSTALL_DIRECTORY ${MEDCOUPLING_INSTALL_TESTS}/PyWrapping)
+
+INSTALL(FILES CTestTestfileInstall.cmake DESTINATION ${TEST_INSTALL_DIRECTORY} RENAME CTestTestfile.cmake)
+INSTALL(FILES ${BASE_TESTS} DESTINATION ${TEST_INSTALL_DIRECTORY})
+INSTALL(FILES tests.set DESTINATION ${TEST_INSTALL_DIRECTORY})
--- /dev/null
+# Copyright (C) 2017 CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+INCLUDE(tests.set)
+
+FOREACH(tfile ${BASE_TESTS})
+ GET_FILENAME_COMPONENT(BASE_NAME ${tfile} NAME_WE)
+ SET(TEST_NAME ${COMPONENT_NAME}_${BASE_NAME})
+ ADD_TEST(${TEST_NAME} python ${tfile})
+ SET_TESTS_PROPERTIES( ${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME}" TIMEOUT ${TIMEOUT} )
+ENDFOREACH()
--- /dev/null
+# -*- coding: iso-8859-1 -*-
+# Copyright (C) 2017 CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+# Author : Anthony Geay (EDF R&D)
+
+from medcoupling import *
+import unittest
+
+class FileCreator(object):
+ def __init__(self,tester,fname):
+ self._tester=tester
+ self._fname=fname
+ pass
+
+ def fileName(self):
+ return self._fname
+
+ def __enter__(self):
+ import os
+ if os.path.exists(self._fname):
+ os.remove(self._fname)
+ pass
+ return self
+
+ def __exit__(self, type, value, traceback):
+ import os
+ if not os.path.exists(self._fname):
+ self._tester.assertTrue(False)
+ pass
+ else:
+ os.remove(self._fname)
+ pass
+
+class medcouplingTest(unittest.TestCase):
+
+ @unittest.skipUnless(HasMEDFileExt(),"Requires link to MED file")
+ def test1(self):
+ import sys
+ fname="mctest1.med"
+ arr=DataArrayDouble(10) ; arr.iota()
+ m=MEDCouplingCMesh()
+ m.setCoords(arr,arr)
+ m.setName("mesh")
+ with FileCreator(self,fname) as fc:
+ m.write(fc.fileName())
+ m=m.buildUnstructured()
+ with FileCreator(self,fname) as fc:
+ m.write(fc.fileName())
+ f=MEDCouplingFieldDouble(ON_NODES) ; f.setMesh(m) ; f.setArray(m.getCoords()) ; f.setName("field")
+ with FileCreator(self,fname) as fc:
+ f.write(fc.fileName())
+ f=MEDCouplingFieldFloat(ON_NODES) ; f.setMesh(m)
+ d=DataArrayFloat(m.getNumberOfNodes()) ; d.iota()
+ f.setArray(d) ; f.setName("field1")
+ with FileCreator(self,fname) as fc:
+ f.write(fc.fileName())
+ pass
+
+ @unittest.skipUnless(HasRenumberExt(),"Requires Boost or Metis to activate Renumberer")
+ def test2(self):
+ arr=DataArrayDouble(10) ; arr.iota()
+ m=MEDCouplingCMesh() ; m.setCoords(arr,arr)
+ m=m.buildUnstructured() ; m.setName("mesh")
+ #
+ renf=RenumberingFactory("Boost")
+ neigh,neighi=m.computeNeighborsOfCells()
+ n2o,o2n=renf.renumber(neigh,neighi)
+ mRenum=m[n2o]
+ pass
+
+ @unittest.skipUnless(HasPartitionerExt(),"Requires Partitioner activation")
+ def test3(self):
+ arr=DataArrayDouble(10) ; arr.iota()
+ m=MEDCouplingCMesh() ; m.setCoords(arr,arr)
+ m=m.buildUnstructured() ; m.setName("mesh")
+ m.write("all.med")
+ a,b=m.computeNeighborsOfCells()
+ sk=MEDCouplingSkyLineArray(b,a)
+ g=MEDPartitioner.Graph(sk)
+ g.partGraph(4)
+ procIdOnCells=g.getPartition().getValuesArray()
+ m0=m[procIdOnCells.findIdsEqual(0)] ; m0.setName("m0")
+ m0.write("part0.med")
+ pass
+
+ @unittest.skipUnless(HasParallelInterpolatorExt(),"Requires // interpolator activated")
+ def test4(self):
+ interface=CommInterface()
+ pass
+
+ pass
+
+if __name__ == "__main__":
+ unittest.main()
#endif
}
- bool HasParallelInterpolator()
+ bool HasParallelInterpolatorExt()
{
#ifdef WITH_PARALLEL_INTERPOLATOR
return true;
--- /dev/null
+# Copyright (C) 2017 CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+# Author : Anthony Geay (EDF R&D)
+
+SET(BASE_TESTS TestPyWrapGathered_medcoupling.py)
\ No newline at end of file
#endif
#include <iostream>
-
-using namespace std;
+#include <algorithm>
namespace MED_RENUMBER
-{
- Renumbering* RenumberingFactory(const string &s)
+{
+ bool CompareRenumMeth(const std::string& s1, const char *s2)
+ {
+ std::string ss1(s1),ss2(s2);
+ std::transform(ss1.begin(), ss1.end(), ss1.begin(), ::tolower);
+ std::transform(ss2.begin(), ss2.end(), ss2.begin(), ::tolower);
+ return ss1==ss2;
+ }
+
+ Renumbering* RenumberingFactory(const std::string &s)
{
#ifdef MED_ENABLE_METIS
#ifdef ENABLE_BOOST
- if (s==METIS_ALG)
+ if ( CompareRenumMeth(s,METIS_ALG) )
{
return new METISRenumbering;
}
- else if(s==BOOST_ALG)
+ else if( CompareRenumMeth(s,BOOST_ALG) )
{
return new BOOSTRenumbering;
}
}
#endif
#ifndef ENABLE_BOOST
- if (s==METIS_ALG)
+ if ( CompareRenumMeth(s,METIS_ALG) )
{
return new METISRenumbering;
}
#endif
#ifndef MED_ENABLE_METIS
#ifdef ENABLE_BOOST
- if (s==BOOST_ALG)
+ if ( CompareRenumMeth(s,BOOST_ALG) )
{
return new BOOSTRenumbering;
}