//
#include "ICoCoMEDField.hxx"
-//#include "ProcessorGroup.hxx"
-#include "MEDCouplingUMesh.hxx"
#include "MEDCouplingFieldDouble.hxx"
-#include "NormalizedUnstructuredMesh.hxx"
namespace ICoCo
{
if(_field)
_field->incrRef();
}
- MEDField::MEDField(const MEDField& field):_field(field.getField())
+ MEDField::MEDField(const MEDField& field):_field(field.getMCField())
{
if(_field)
_field->incrRef();
{
if (_field)
_field->decrRef();
-
- _field=field.getField();
+
+ _field=field.getMCField();
if(_field)
_field->incrRef();
return *this;
}
+
+ void MEDField::setMCField(MEDCoupling::MEDCouplingFieldDouble * f)
+ {
+ if(_field)
+ _field->decrRef();
+ _field = f;
+ if(f)
+ _field->incrRef();
+ }
+
}
MEDField(const MEDField& field);
MEDField& operator=(const MEDField& field);
virtual ~MEDField();
- MEDCoupling::MEDCouplingFieldDouble *getField() const { return _field; }
- const MEDCoupling::MEDCouplingMesh *getMesh() const { return _field->getMesh(); }
+ MEDCoupling::MEDCouplingFieldDouble *getMCField() const { return _field; }
+ void setMCField(MEDCoupling::MEDCouplingFieldDouble * f);
+
private:
MEDCoupling::MEDCouplingFieldDouble *_field;
};
--- /dev/null
+// Copyright (C) 2017-2019 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 : Adrien Bruneton (CEA)
+
+
+%{
+#include "ICoCoMEDField.hxx"
+
+using namespace MEDCoupling;
+%}
+
+namespace ICoCo
+{
+ class MEDField
+ {
+ public:
+ MEDField();
+ MEDField(MEDCoupling::MEDCouplingFieldDouble* field);
+ MEDField(const MEDField& field);
+ MEDField& operator=(const MEDField& field);
+ MEDCoupling::MEDCouplingFieldDouble *getMCField() const;
+ void setMCField(MEDCoupling::MEDCouplingFieldDouble * f);
+ };
+}
+
+
TARGET_LINK_LIBRARIES(medcouplingremapper medcouplingcpp)
INSTALL(TARGETS medcouplingremapper EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${MEDCOUPLING_INSTALL_LIBS})
-FILE(GLOB medcoupling_HEADERS_HXX "${CMAKE_CURRENT_SOURCE_DIR}/*.hxx")
+FILE(GLOB medcoupling_HEADERS_HXX "${CMAKE_CURRENT_SOURCE_DIR}/*.hxx" "${CMAKE_CURRENT_SOURCE_DIR}/../ICoCo/*.hxx")
FILE(GLOB medcoupling_HEADERS_TXX "${CMAKE_CURRENT_SOURCE_DIR}/*.txx")
FILE(GLOB icoco_HEADERS_HXX "${CMAKE_CURRENT_SOURCE_DIR}/../ICoCo/*.hxx")
INSTALL(FILES ${medcoupling_HEADERS_HXX} ${medcoupling_HEADERS_TXX} ${icoco_HEADERS_HXX} MEDCouplingNatureOfFieldEnum DESTINATION ${MEDCOUPLING_INSTALL_HEADERS})
MEDCouplingMemArray.i
MEDCouplingFieldDiscretization.i
MEDCouplingFinalize.i
- MEDCouplingTypemaps.i)
+ MEDCouplingTypemaps.i
+ ../ICoCo/Swig/ICoCoMEDField.i
+)
SET (MC_pyTestFiles
${ALL_TESTS}
MEDCouplingTypemaps.i
MEDCouplingDataArrayTypemaps.i
MEDCouplingDataArrayTraits.hxx
+ ../ICoCo/Swig/ICoCoMEDField.i
)
INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_SOURCE_DIR}/../INTERP_KERNEL/Geometric2D
${CMAKE_CURRENT_SOURCE_DIR}/../INTERP_KERNEL/ExprEval
${CMAKE_CURRENT_SOURCE_DIR}/../INTERP_KERNEL/GaussPoints
+ ${CMAKE_CURRENT_SOURCE_DIR}/../ICoCo
+ ${CMAKE_CURRENT_SOURCE_DIR}/../ICoCo/Swig
${PROJECT_BINARY_DIR}/doc
)
--- /dev/null
+# -*- coding: iso-8859-1 -*-
+# Copyright (C) 2007-2019 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
+#
+
+
+import sys
+if sys.platform == "win32":
+ from MEDCouplingCompat import *
+else:
+ from medcoupling import *
+
+import unittest
+
+class ICoCoMEDFieldTest(unittest.TestCase):
+ def generate_fields(self):
+ ## Dummy MCFieldDouble
+ msh = MEDCouplingCMesh()
+ msh.setCoords(DataArrayDouble([0.,1.,2.]))
+ msh = msh.buildUnstructured()
+ f1 = MEDCouplingFieldDouble(ON_CELLS, ONE_TIME)
+ f1.setMesh(msh)
+ f1.setArray(DataArrayDouble([0.,1.,2.,3.]))
+
+ f2 = f1.deepCopy()
+ da = f2.getArray()
+ da += 3.0
+ da2 = f2.getArray()
+ return f1, f2
+
+ def test1(self):
+ f1, f2 = self.generate_fields()
+ mf = MEDField()
+ mfd = mf.getMCField()
+ self.assertTrue(mfd is None)
+ mf.setMCField(f1)
+ f11 = mf.getMCField()
+ self.assertEqual(f1.getHiddenCppPointer(), f11.getHiddenCppPointer()) # strictly the same
+ mf.setMCField(f2)
+ f22 = mf.getMCField()
+ self.assertEqual(f2.getHiddenCppPointer(), f22.getHiddenCppPointer()) # strictly the same
+
+ mf = MEDField(f1) # ctor with MC object
+ mfd = mf.getMCField()
+ self.assertEqual(mfd.getHiddenCppPointer(), f1.getHiddenCppPointer()) # strictly the same
+
+ mf.setMCField(None)
+ mfd = mf.getMCField()
+ self.assertTrue(mfd is None)
+
+ mf.setMCField(f2)
+ f22 = mf.getMCField()
+ self.assertEqual(f2.getHiddenCppPointer(), f22.getHiddenCppPointer()) # strictly the same
+
+ mf2 = MEDField(mf) # copy ctor
+ f22 = mf2.getMCField()
+ self.assertEqual(f2.getHiddenCppPointer(), f22.getHiddenCppPointer()) # strictly the same
+
+ mf2 = mf # assignement op
+ f22 = mf2.getMCField()
+ self.assertEqual(f2.getHiddenCppPointer(), f22.getHiddenCppPointer()) # strictly the same
+
+if __name__ == '__main__':
+ unittest.main()
#endif
%include "MEDCouplingCommon.i"
+%include "ICoCoMEDField.i"
%pythoncode %{
def MEDCouplingDataArrayDoubleIadd(self,*args):
MEDCouplingExamplesTest.py
MEDCouplingRemapperTest.py
UsersGuideExamplesTest.py
+ ICoCoMEDFieldTest.py
)
# if numpy is used
${CMAKE_CURRENT_SOURCE_DIR}/../MEDPartitioner
${CMAKE_CURRENT_SOURCE_DIR}/../MEDPartitioner_Swig
${CMAKE_CURRENT_SOURCE_DIR}/../ICoCo
+ ${CMAKE_CURRENT_SOURCE_DIR}/../ICoCo/Swig
${CMAKE_CURRENT_SOURCE_DIR}/../ParaMEDMEM
${CMAKE_CURRENT_SOURCE_DIR}/../ParaMEDMEM_Swig
${PROJECT_BINARY_DIR}/doc
%include "MEDCouplingRemapperCommon.i"
+%include "ICoCoMEDField.i"
+
#ifdef WITH_MED_FILE
%include "MEDLoaderCommon.i"
#endif