From b6a7a8c4935c9864f4926540076f70f9099bc3de Mon Sep 17 00:00:00 2001 From: abn Date: Wed, 21 Aug 2019 15:17:44 +0200 Subject: [PATCH] [ICoCo] ICoCo interface version 2 + renamed MEDField into MEDDoubleField. + added MEDIntField. + rename getField() into getMCField() into MED*Field class for clarity + proper field name management + proper doc --- doc/developer/doxygen/Doxyfile_med_dev.in | 20 ++-- .../doxygen/doxfiles/appendix/appendix.dox | 1 + .../doxfiles/appendix/porting_icoco.dox | 18 +++ .../doxygen/doxfiles/reference/misc/icoco.dox | 18 ++- .../doxygen/doxfiles/reference/reference.dox | 1 + src/ICoCo/{ICoCoField.cxx => ICoCoField.cpp} | 41 +++---- src/ICoCo/ICoCoField.h | 25 ++++ src/ICoCo/ICoCoField.hxx | 45 +++++--- ...CoMEDField.cxx => ICoCoMEDDoubleField.cxx} | 54 ++++++--- src/ICoCo/ICoCoMEDDoubleField.h | 25 ++++ src/ICoCo/ICoCoMEDDoubleField.hxx | 101 +++++++++++++++++ src/ICoCo/ICoCoMEDIntField.cxx | 88 ++++++++++++++ src/ICoCo/ICoCoMEDIntField.h | 25 ++++ src/ICoCo/ICoCoMEDIntField.hxx | 101 +++++++++++++++++ src/ICoCo/Readme.txt | 15 ++- .../ICoCoMEDField.i} | 38 +++---- src/MEDCoupling/CMakeLists.txt | 12 +- src/MEDCoupling_Swig/CMakeLists.txt | 7 +- src/MEDCoupling_Swig/ICoCoMEDFieldTest.py | 107 ++++++++++++++++++ src/MEDCoupling_Swig/MEDCoupling.i | 1 + src/MEDCoupling_Swig/tests.set | 1 + src/ParaMEDMEM/DEC.cxx | 3 +- src/ParaMEDMEM/DisjointDEC.cxx | 10 +- src/ParaMEDMEM/DisjointDEC.hxx | 6 +- src/ParaMEDMEM/OverlapDEC.cxx | 10 +- src/ParaMEDMEM/OverlapDEC.hxx | 6 +- .../ParaMEDMEMTest_InterpKernelDEC.cxx | 21 ++-- ...ParaMEDMEMTest_StructuredCoincidentDEC.cxx | 3 +- src/ParaMEDMEMTest/test_perf.cxx | 10 +- src/ParaMEDMEM_Swig/CMakeLists.txt | 1 + src/ParaMEDMEM_Swig/ParaMEDMEM.i | 1 + src/ParaMEDMEM_Swig/ParaMEDMEMCommon.i | 7 +- src/ParaMEDMEM_Swig/test_InterpKernelDEC.py | 4 +- src/ParaMEDMEM_Swig/test_NonCoincidentDEC.py | 4 +- .../test_StructuredCoincidentDEC.py | 4 +- src/PyWrapping/CMakeLists.txt | 1 + src/PyWrapping/medcoupling.i | 2 + 37 files changed, 701 insertions(+), 136 deletions(-) create mode 100644 doc/developer/doxygen/doxfiles/appendix/porting_icoco.dox rename src/ICoCo/{ICoCoField.cxx => ICoCoField.cpp} (63%) create mode 100644 src/ICoCo/ICoCoField.h rename src/ICoCo/{ICoCoMEDField.cxx => ICoCoMEDDoubleField.cxx} (55%) create mode 100644 src/ICoCo/ICoCoMEDDoubleField.h create mode 100644 src/ICoCo/ICoCoMEDDoubleField.hxx create mode 100644 src/ICoCo/ICoCoMEDIntField.cxx create mode 100644 src/ICoCo/ICoCoMEDIntField.h create mode 100644 src/ICoCo/ICoCoMEDIntField.hxx rename src/ICoCo/{ICoCoMEDField.hxx => Swig/ICoCoMEDField.i} (53%) create mode 100755 src/MEDCoupling_Swig/ICoCoMEDFieldTest.py diff --git a/doc/developer/doxygen/Doxyfile_med_dev.in b/doc/developer/doxygen/Doxyfile_med_dev.in index f5eda6db5..0aca55f7d 100644 --- a/doc/developer/doxygen/Doxyfile_med_dev.in +++ b/doc/developer/doxygen/Doxyfile_med_dev.in @@ -75,6 +75,7 @@ INPUT = @CMAKE_CURRENT_SOURCE_DIR@/doxfiles/index.dox \ @PROJECT_SOURCE_DIR@/src/INTERP_KERNEL/Bases \ @PROJECT_SOURCE_DIR@/src/INTERP_KERNEL/Geometric2D \ @PROJECT_SOURCE_DIR@/src/MEDCoupling \ + @PROJECT_SOURCE_DIR@/src/ICoCo \ @PROJECT_SOURCE_DIR@/src/MEDLoader FILE_PATTERNS = InterpKernelDEC.*xx \ @@ -121,8 +122,8 @@ FILE_PATTERNS = InterpKernelDEC.*xx \ MEDCouplingCurveLinearMesh.*xx \ MEDCouplingMappedExtrudedMesh.*xx \ MEDCouplingFieldDouble.*xx \ - MEDCouplingFieldInt.*xx \ - MEDCouplingFieldT.*xx \ + MEDCouplingFieldInt.*xx \ + MEDCouplingFieldT.*xx \ MEDCouplingField.*xx \ MEDCouplingNatureOfFieldEnum \ MEDCouplingNatureOfField.hxx \ @@ -140,18 +141,19 @@ FILE_PATTERNS = InterpKernelDEC.*xx \ MEDFileData.*xx \ MEDFileParameter.*xx \ MEDFileMesh.*xx \ - MEDFileFieldGlobs.*xx \ - MEDFileFieldInternal.*xx \ - MEDFileField1TS.*xx \ - MEDFileFieldMultiTS.*xx \ + MEDFileFieldGlobs.*xx \ + MEDFileFieldInternal.*xx \ + MEDFileField1TS.*xx \ + MEDFileFieldMultiTS.*xx \ MEDFileField.*xx \ - MEDFileFieldVisitor.hxx \ - *Servant.*xx \ + MEDFileFieldVisitor.hxx \ + *Servant.*xx \ + ICoCo*.hxx \ *.dox RECURSIVE = YES EXCLUDE = CVS EXCLUDE_PATTERNS = *~ -EXCLUDE_SYMBOLS = ICoCo +EXCLUDE_SYMBOLS = EXAMPLE_PATH = @PROJECT_SOURCE_DIR@/src/ParaMEDMEM \ @PROJECT_SOURCE_DIR@/src/MEDCoupling/Test \ @PROJECT_SOURCE_DIR@/src/MEDCoupling_Swig \ diff --git a/doc/developer/doxygen/doxfiles/appendix/appendix.dox b/doc/developer/doxygen/doxfiles/appendix/appendix.dox index 333eed612..f8aece8db 100644 --- a/doc/developer/doxygen/doxfiles/appendix/appendix.dox +++ b/doc/developer/doxygen/doxfiles/appendix/appendix.dox @@ -5,6 +5,7 @@ Some useful complementary resources: - \subpage porting +- \subpage porting_icoco - \subpage glossary - \subpage med-file - \subpage install diff --git a/doc/developer/doxygen/doxfiles/appendix/porting_icoco.dox b/doc/developer/doxygen/doxfiles/appendix/porting_icoco.dox new file mode 100644 index 000000000..6b852062e --- /dev/null +++ b/doc/developer/doxygen/doxfiles/appendix/porting_icoco.dox @@ -0,0 +1,18 @@ +/*! + +\page porting_icoco Porting ICoCo code/scripts from version 9.6 to version 9.7 (and above) + +From version 9.7 of MEDCoupling +- the C++ class ICoCo::MEDField has been renamed into +ICoCo::MEDDoubleField. This is to make a clear distinction with the newly created ICoCo::MEDIntField. +- the method ICoCo::MEDDoubleField::getField() has been renamed into ICoCo::MEDDoubleField::getMCField() and +a new method ICoCo::MEDDoubleField::setMCField() has been added. + +In Python, we keep the namespace in front of the name, and hence the two classes +are respectively called ICoCoMEDDoubleField and ICoCoMEDIntField. + +The APIs of the various \ref para-dec have also been updated accordingly. + +See also the page \ref icoco. +*/ + diff --git a/doc/developer/doxygen/doxfiles/reference/misc/icoco.dox b/doc/developer/doxygen/doxfiles/reference/misc/icoco.dox index b48ec73a9..f10292696 100644 --- a/doc/developer/doxygen/doxfiles/reference/misc/icoco.dox +++ b/doc/developer/doxygen/doxfiles/reference/misc/icoco.dox @@ -2,10 +2,22 @@ \page icoco The ICoCo API -ICoCo stands for Interface for COde COupling. +ICoCo stands for Interface for COde COupling. -It is a pure abstract API defining a standard way for two physical codes to exchange information between them. +It is a pure abstract API defining a standard way for two physical codes to exchange +information between them. -TODO: complete this section. +The full definition of this interface is held in the opensource TRUST plaform repository +(sub-folder Outils/src/LIBICOCOAPI) that can be found here: +https://sourceforge.net/projects/trust-platform +The MEDCoupling library provides the implementation of the ICoCo::MEDDoubleField and +ICoCo::MEDIntField classes used in some of the field exchange methods. We also provide +the sequential and parallel interpolation tools which are often needed in such coupling (see +\ref interpolation and \ref para-dec respectively) + +WARNING: currently, no implementation of the ICoCo::MEDStringField object is provided yet, you are welcome +to propose one if you need it. + +Note: some class names have been changed in version 9.7, take a look at \ref porting_icoco */ diff --git a/doc/developer/doxygen/doxfiles/reference/reference.dox b/doc/developer/doxygen/doxfiles/reference/reference.dox index d6419583d..6547673b8 100644 --- a/doc/developer/doxygen/doxfiles/reference/reference.dox +++ b/doc/developer/doxygen/doxfiles/reference/reference.dox @@ -18,6 +18,7 @@ You can also take a look at the numerous \ref examples "code examples" provided - \subpage interpolation - \subpage cpp - \subpage distrib +- \subpage icoco - \subpage misc */ diff --git a/src/ICoCo/ICoCoField.cxx b/src/ICoCo/ICoCoField.cpp similarity index 63% rename from src/ICoCo/ICoCoField.cxx rename to src/ICoCo/ICoCoField.cpp index 9682b8ff6..5b9bde8f4 100644 --- a/src/ICoCo/ICoCoField.cxx +++ b/src/ICoCo/ICoCoField.cpp @@ -17,33 +17,36 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// ICoCo file common to several codes -// ICoCoField.cxx -// version 1.2 10/05/2010 +// WARNING: this file is part of the official ICoCo API and should not be modified. +// The official version can be found at the following URL: +// +// https://github.com/cea-trust-platform/icoco-coupling #include "ICoCoField.hxx" #include -using namespace ICoCo; -using std::string; +namespace ICoCo +{ -Field::Field() { - _name=new string; -} + Field::Field() { + _name = new std::string; + } -Field::~Field() { - delete _name; -} + Field::~Field() { + delete _name; + } -void Field::setName(const string& name) { - *_name=name; -} + void Field::setName(const std::string& name) { + *_name = name; + } -const string& Field::getName() const { - return *_name; -} + const std::string& Field::getName() const { + return *_name; + } + + const char* Field::getCharName() const { + return _name->c_str(); + } -const char* Field::getCharName() const { - return _name->c_str(); } diff --git a/src/ICoCo/ICoCoField.h b/src/ICoCo/ICoCoField.h new file mode 100644 index 000000000..232200aba --- /dev/null +++ b/src/ICoCo/ICoCoField.h @@ -0,0 +1,25 @@ +// Copyright (C) 2007-2020 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 +// + +// WARNING: this file is part of the official ICoCo API and should not be modified. +// The official version can be found at the following URL: +// +// https://github.com/cea-trust-platform/icoco-coupling + +#include diff --git a/src/ICoCo/ICoCoField.hxx b/src/ICoCo/ICoCoField.hxx index f04cb58ae..579ee0f28 100644 --- a/src/ICoCo/ICoCoField.hxx +++ b/src/ICoCo/ICoCoField.hxx @@ -17,27 +17,46 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// ICoCo file common to several codes -// ICoCoField.h -// version 1.2 10/05/2010 +// WARNING: this file is part of the official ICoCo API and should not be modified. +// The official version can be found at the following URL: +// +// https://github.com/cea-trust-platform/icoco-coupling -#ifndef _ICoCoField_included_ -#define _ICoCoField_included_ +#ifndef ICoCoField_included +#define ICoCoField_included #include - -namespace ICoCo { - - class Field { +namespace ICoCo +{ + /*! @brief Top abstract class defining field objects that can be exchanged via the ICoCo interface. + * + * The Field class holds the name of the field. + */ + class Field + { public: - Field(); - virtual ~Field(); + /*! @brief Set the name of the field. + * @param name name of the field + */ void setName(const std::string& name); + + /*! @brief Retrieves the name of the field. + * @return name of the field. + */ const std::string& getName() const; + + /*! + * @brief Retrieves the name of the field as a char * + * @return name of the field. + */ const char* getCharName() const; - + + protected: + Field(); + virtual ~Field(); + private: std::string* _name; }; -} +} // namespace ICoCo #endif diff --git a/src/ICoCo/ICoCoMEDField.cxx b/src/ICoCo/ICoCoMEDDoubleField.cxx similarity index 55% rename from src/ICoCo/ICoCoMEDField.cxx rename to src/ICoCo/ICoCoMEDDoubleField.cxx index ba670b41b..af0efa31f 100644 --- a/src/ICoCo/ICoCoMEDField.cxx +++ b/src/ICoCo/ICoCoMEDDoubleField.cxx @@ -17,46 +17,66 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -#include "ICoCoMEDField.hxx" -//#include "ProcessorGroup.hxx" -#include "MEDCouplingUMesh.hxx" +#include "ICoCoMEDDoubleField.hxx" #include "MEDCouplingFieldDouble.hxx" -#include "NormalizedUnstructuredMesh.hxx" namespace ICoCo { + MEDDoubleField::MEDDoubleField() : _field(0) {} - /*! Constructor directly attaching a MEDCouplingFieldDouble - the object does not take the control the objects pointed by - \a field. - */ - - MEDField::MEDField(MEDCoupling::MEDCouplingFieldDouble *field):_field(field) + MEDDoubleField::MEDDoubleField(MEDCoupling::MEDCouplingFieldDouble *field):_field(field) { if(_field) - _field->incrRef(); + { + _field->incrRef(); + setName(_field->getName()); + } + else + setName(""); } - MEDField::MEDField(const MEDField& field):_field(field.getField()) + + MEDDoubleField::MEDDoubleField(const MEDDoubleField& field):_field(field.getMCField()) { if(_field) _field->incrRef(); + setName(field.getName()); } - MEDField::~MEDField() + MEDDoubleField::~MEDDoubleField() { if(_field) _field->decrRef(); } - - MEDField& MEDField::operator=(const MEDField& field) + MEDDoubleField& MEDDoubleField::operator=(const MEDDoubleField& field) { if (_field) _field->decrRef(); - - _field=field.getField(); + + _field=field.getMCField(); if(_field) _field->incrRef(); + setName(field.getName()); return *this; } + + MEDCoupling::MEDCouplingFieldDouble *MEDDoubleField::getMCField() const + { + return _field; + } + + void MEDDoubleField::setMCField(MEDCoupling::MEDCouplingFieldDouble * f) + { + if(_field) + _field->decrRef(); + _field = f; + if(f != nullptr) + { + _field->incrRef(); + setName(_field->getName()); + } + else + setName(""); + } + } diff --git a/src/ICoCo/ICoCoMEDDoubleField.h b/src/ICoCo/ICoCoMEDDoubleField.h new file mode 100644 index 000000000..2833e2b02 --- /dev/null +++ b/src/ICoCo/ICoCoMEDDoubleField.h @@ -0,0 +1,25 @@ +// Copyright (C) 2007-2020 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 +// + +// WARNING: this file is part of the official ICoCo API and should not be modified. +// The official version can be found at the following URL: +// +// https://github.com/cea-trust-platform/icoco-coupling + +#include "ICoCoMEDDoubleField.hxx" diff --git a/src/ICoCo/ICoCoMEDDoubleField.hxx b/src/ICoCo/ICoCoMEDDoubleField.hxx new file mode 100644 index 000000000..57596ebf0 --- /dev/null +++ b/src/ICoCo/ICoCoMEDDoubleField.hxx @@ -0,0 +1,101 @@ +// Copyright (C) 2007-2021 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 +// + +// WARNING: this file is part of the official ICoCo API and should not be modified. +// The official version can be found at the following URL: +// +// https://github.com/cea-trust-platform/icoco-coupling + +#ifndef ICoCoMEDDoubleField_included +#define ICoCoMEDDoubleField_included + +#include "ICoCoField.hxx" + +namespace MEDCoupling +{ + class MEDCouplingFieldDouble; +} + +namespace ICoCo +{ + /*! @brief Field data stored internally as a MEDCoupling object. + * + * This class is a wrapper around a MEDCoupling::MEDCouplingFieldDouble object, which holds the field data. + * In version 2 of ICoCo, MEDCoupling::MEDCouplingFieldDouble objects are not anymore exposed directly into the API + * of ICoCo::Problem. The rationale is to make the interface ICoCo::Problem free of external dependencies + * (MEDCoupling particularly). + * + * @sa the MEDCoupling documentation, notably the reference counter mechanism used to manage the lifecycle of + * MEDCoupling objects. + */ + class MEDDoubleField : public ICoCo::Field + { + public: + /*! Builds an empty field (internal MEDCoupling object not set). + */ + MEDDoubleField(); + + /*! @brief Builds a field and assign its internal MEDCouplingField object. + * + * The name of 'this' is also automatically set the name of the MEDCouplingField object. If 'field' is null + * the name is set to the empty string. + * + * @param field MEDCoupling field instance to use for field data. The field reference counter is incremented. + */ + MEDDoubleField(MEDCoupling::MEDCouplingFieldDouble* field); + + /*! @brief Copy construcotr. + */ + MEDDoubleField(const MEDDoubleField& field); + + /*! @brief Assignement operator. + * @param field another MEDDoubleField instance. The previous internal MEDCoupling field reference (if any) has + * its counter decremented. + */ + MEDDoubleField& operator=(const MEDDoubleField& field); + + /*! @brief Destructor. + */ + virtual ~MEDDoubleField(); + + /*! @brief Get the internal MEDCoupling field object. + * @return a pointer to the MEDCouplingField object detained by this instance. Note that the corresponding + * object should not be deleted, or its reference counter should not be decreased! Doing so will result in an + * invalid instance of the current MEDField. + */ + MEDCoupling::MEDCouplingFieldDouble *getMCField() const; + + /*! @brief Set the internal MEDCoupling field object. + * + * Any previously set field is discarded (its reference counter is decreased) and the reference counter of the + * field being set is increased. + * + * The name of 'this' is also automatically set the name of the MEDCouplingField object. If 'field' is nullptr + * the name is reset to the empty string. + * + * @param field MEDCouplingFieldDouble object to be used. + */ + void setMCField(MEDCoupling::MEDCouplingFieldDouble * field); + + private: + MEDCoupling::MEDCouplingFieldDouble *_field; + }; +} // namespace ICoCo + +#endif diff --git a/src/ICoCo/ICoCoMEDIntField.cxx b/src/ICoCo/ICoCoMEDIntField.cxx new file mode 100644 index 000000000..fd9450978 --- /dev/null +++ b/src/ICoCo/ICoCoMEDIntField.cxx @@ -0,0 +1,88 @@ +// Copyright (C) 2007-2020 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 "ICoCoMEDIntField.h" +#include "MEDCouplingFieldInt32.hxx" + +namespace ICoCo +{ + + MEDIntField::MEDIntField() : _field(0) {} + + /*! Constructor directly attaching a MEDCouplingFieldInt + the object does not take the control the objects pointed by + \a field. + */ + MEDIntField::MEDIntField(MEDCoupling::MEDCouplingFieldInt32 *field):_field(field) + { + if(_field) + { + _field->incrRef(); + setName(_field->getName()); + } + else + setName(""); + } + + MEDIntField::MEDIntField(const MEDIntField& field):_field(field.getMCField()) + { + if(_field) + _field->incrRef(); + setName(field.getName()); + } + + MEDIntField::~MEDIntField() + { + if(_field) + _field->decrRef(); + } + + + MEDIntField& MEDIntField::operator=(const MEDIntField& field) + { + if (_field) + _field->decrRef(); + + _field=field.getMCField(); + if(_field) + _field->incrRef(); + setName(field.getName()); + return *this; + } + + MEDCoupling::MEDCouplingFieldInt32 *MEDIntField::getMCField() const + { + return _field; + } + + void MEDIntField::setMCField(MEDCoupling::MEDCouplingFieldInt32 * f) + { + if(_field) + _field->decrRef(); + _field = f; + if(f != nullptr) + { + _field->incrRef(); + setName(_field->getName()); + } + else + setName(""); + } + +} diff --git a/src/ICoCo/ICoCoMEDIntField.h b/src/ICoCo/ICoCoMEDIntField.h new file mode 100644 index 000000000..02f39713c --- /dev/null +++ b/src/ICoCo/ICoCoMEDIntField.h @@ -0,0 +1,25 @@ +// Copyright (C) 2007-2020 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 +// + +// WARNING: this file is part of the official ICoCo API and should not be modified. +// The official version can be found at the following URL: +// +// https://github.com/cea-trust-platform/icoco-coupling + +#include "ICoCoMEDIntField.hxx" diff --git a/src/ICoCo/ICoCoMEDIntField.hxx b/src/ICoCo/ICoCoMEDIntField.hxx new file mode 100644 index 000000000..b348217d2 --- /dev/null +++ b/src/ICoCo/ICoCoMEDIntField.hxx @@ -0,0 +1,101 @@ +// 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 +// + +// WARNING: this file is part of the official ICoCo API and should not be modified. +// The official version can be found at the following URL: +// +// https://github.com/cea-trust-platform/icoco-coupling + +#ifndef ICoCoMEDIntField_included +#define ICoCoMEDIntField_included + +#include "ICoCoField.hxx" + +namespace MEDCoupling +{ + class MEDCouplingFieldInt32; +} + +namespace ICoCo +{ + /*! @brief Field data stored internally as a MEDCoupling object. + * + * This class is a wrapper around a MEDCoupling::MEDCouplingFieldInt32 object, which holds the field data. + * In version 2 of ICoCo, MEDCoupling objects are not anymore exposed directly into the API + * of ICoCo::Problem. The rationale is to make the interface ICoCo::Problem free of external dependencies + * (MEDCoupling particularly). + * + * @sa the MEDCoupling documentation, notably the reference counter mechanism used to manage the lifecycle of + * MEDCoupling objects. + */ + class MEDIntField : public ICoCo::Field + { + public: + /*! Builds an empty field (internal MEDCoupling object not set). + */ + MEDIntField(); + + /*! @brief Builds a field and assign its internal MEDCouplingField object. + * + * The name of 'this' is also automatically set the name of the MEDCouplingField object. If 'field' is null + * the name is set to the empty string. + * + * @param field MEDCoupling field instance to use for field data. The field reference counter is incremented. + */ + MEDIntField(MEDCoupling::MEDCouplingFieldInt32* field); + + /*! @brief Copy construcotr. + */ + MEDIntField(const MEDIntField& field); + + /*! @brief Assignement operator. + * @param field another MEDDoubleField instance. The previous internal MEDCoupling field reference (if any) has + * its counter decremented. + */ + MEDIntField& operator=(const MEDIntField& field); + + /*! @brief Destructor. + */ + virtual ~MEDIntField(); + + /*! @brief Get the internal MEDCoupling field object. + * @return a pointer to the MEDCouplingField object detained by this instance. Note that the corresponding + * object should not be deleted, or its reference counter should not be decreased! Doing so will result in an + * invalid instance of the current MEDField. + */ + MEDCoupling::MEDCouplingFieldInt32 *getMCField() const; + + /*! @brief Set the internal MEDCoupling field object. + * + * Any previously set field is discarded (its reference counter is decreased) and the reference counter of the + * field being set is increased. + * + * The name of 'this' is also automatically set the name of the MEDCouplingField object. If 'field' is nullptr + * the name is reset to the empty string. + * + * @param field MEDCouplingFieldDouble object to be used. + */ + void setMCField(MEDCoupling::MEDCouplingFieldInt32 * f); + + private: + MEDCoupling::MEDCouplingFieldInt32 *_field; + }; +} // namespace ICoCo + +#endif diff --git a/src/ICoCo/Readme.txt b/src/ICoCo/Readme.txt index 5117faae3..0880fd3d1 100644 --- a/src/ICoCo/Readme.txt +++ b/src/ICoCo/Readme.txt @@ -1 +1,14 @@ -Linked into target 'medcoupling' library. +Linked into target 'paramedmem' library. + +The files below are part of the official ICoCo API and should NOT be modified: + - ICoCoField.h + - ICoCoField.hxx + - ICoCoField.cxx + - ICoCoMEDDoubleField.h + - ICoCoMEDDoubleField.hxx + - ICoCoMEDIntField.h + - ICoCoMEDIntField.hxx + +Their official version can be found in the TRUST repository: + + https://sourceforge.net/projects/trust/ diff --git a/src/ICoCo/ICoCoMEDField.hxx b/src/ICoCo/Swig/ICoCoMEDField.i similarity index 53% rename from src/ICoCo/ICoCoMEDField.hxx rename to src/ICoCo/Swig/ICoCoMEDField.i index 6e7f32ea7..f12c210d8 100644 --- a/src/ICoCo/ICoCoMEDField.hxx +++ b/src/ICoCo/Swig/ICoCoMEDField.i @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2021 CEA/DEN, EDF R&D +// 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 @@ -16,31 +16,19 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +// Author : Adrien Bruneton (CEA) -#ifndef __ICOCOMEDFIELD_HXX__ -#define __ICOCOMEDFIELD_HXX__ +%{ +#include "ICoCoMEDDoubleField.hxx" +#include "ICoCoMEDIntField.hxx" +%} -#include "MEDCouplingUMesh.hxx" -#include "MEDCouplingFieldDouble.hxx" +%include "std_string.i" +%include "ICoCoField.hxx" -#include -#include "ICoCoField.hxx" +// %rename has to be before %include ... !! +%rename (ICoCoMEDDoubleField) ICoCo::MEDDoubleField; +%rename (ICoCoMEDIntField) ICoCo::MEDIntField; -namespace ICoCo -{ - class MEDField : public ICoCo::Field - { - public: - MEDField():_field(0) { } - MEDField(MEDCoupling::MEDCouplingFieldDouble* field); - 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(); } - private: - MEDCoupling::MEDCouplingFieldDouble *_field; - }; -} - -#endif +%include "ICoCoMEDDoubleField.hxx" +%include "ICoCoMEDIntField.hxx" diff --git a/src/MEDCoupling/CMakeLists.txt b/src/MEDCoupling/CMakeLists.txt index a56190e56..2bc6b1bba 100644 --- a/src/MEDCoupling/CMakeLists.txt +++ b/src/MEDCoupling/CMakeLists.txt @@ -37,6 +37,7 @@ 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 ) SET(medcoupling_SOURCES @@ -77,9 +78,10 @@ SET(medcoupling_SOURCES MEDCouplingPartDefinition.cxx MEDCouplingSkyLineArray.cxx MEDCouplingVoronoi.cxx - ../ICoCo/ICoCoField.cxx - ../ICoCo/ICoCoMEDField.cxx - ) + ../ICoCo/ICoCoField.cpp # [ABN] Yes, .cpp, this is imposed by ICoCo. + ../ICoCo/ICoCoMEDDoubleField.cxx + ../ICoCo/ICoCoMEDIntField.cxx +) SET(medcouplingremapper_SOURCES MEDCouplingRemapper.cxx @@ -94,7 +96,9 @@ ADD_LIBRARY(medcouplingremapper ${medcouplingremapper_SOURCES}) 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" + "${CMAKE_CURRENT_SOURCE_DIR}/../ICoCo/*.h") 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}) diff --git a/src/MEDCoupling_Swig/CMakeLists.txt b/src/MEDCoupling_Swig/CMakeLists.txt index e795e98c3..84e2beff7 100644 --- a/src/MEDCoupling_Swig/CMakeLists.txt +++ b/src/MEDCoupling_Swig/CMakeLists.txt @@ -44,7 +44,9 @@ SET (MEDCoupling_SWIG_DPYS_FILES DataArrayInt.i MEDCouplingFieldDiscretization.i MEDCouplingFinalize.i - MEDCouplingTypemaps.i) + MEDCouplingTypemaps.i + ../ICoCo/Swig/ICoCoMEDField.i +) SET (MC_pyTestFiles ${ALL_TESTS} @@ -65,6 +67,7 @@ SET (MC_Swig_interf MEDCouplingTypemaps.i MEDCouplingDataArrayTypemaps.i MEDCouplingDataArrayTraits.hxx + ../ICoCo/Swig/ICoCoMEDField.i ) INCLUDE_DIRECTORIES( @@ -79,6 +82,8 @@ 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 ) diff --git a/src/MEDCoupling_Swig/ICoCoMEDFieldTest.py b/src/MEDCoupling_Swig/ICoCoMEDFieldTest.py new file mode 100755 index 000000000..2297b3d09 --- /dev/null +++ b/src/MEDCoupling_Swig/ICoCoMEDFieldTest.py @@ -0,0 +1,107 @@ +# -*- 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 +# + +from medcoupling import * + +import unittest + +class ICoCoICoCoMEDDoubleFieldTest(unittest.TestCase): + def generate_fields_double(self): + """ Dummy MCFieldDouble """ + msh = MEDCouplingCMesh("toto_mesh") + msh.setCoords(DataArrayDouble([0.,1.,2.])) + msh = msh.buildUnstructured() + f1 = MEDCouplingFieldDouble(ON_CELLS, ONE_TIME) + f1.setMesh(msh) + f1.setName("toto") + f1.setArray(DataArrayDouble([0.,1.,2.,3.])) + + f2 = f1.deepCopy() + da = f2.getArray() + da += 3.5 + da2 = f2.getArray() + return f1, f2 + + def generate_fields_int(self): + """ Dummy MCFieldDouble """ + msh = MEDCouplingCMesh("toto_mesh") + msh.setCoords(DataArrayDouble([0.,1.,2.])) + msh = msh.buildUnstructured() + f1 = MEDCouplingFieldInt32(ON_CELLS, ONE_TIME) + f1.setMesh(msh) + f1.setName("toto") + f1.setArray(DataArrayInt32([0,1,2,3])) + + f2 = f1.deepCopy() + da = f2.getArray() + da += 3 + da2 = f2.getArray() + return f1, f2 + + def test1(self): + lst_typ = [ICoCoMEDDoubleField, ICoCoMEDIntField] + f1d, f2d = self.generate_fields_double() + f1i, f2i = self.generate_fields_int() + fld1_lst = [f1d, f1i] + fld2_lst = [f2d, f2i] + for ICoCoMED_T_Field, f1, f2 in zip(lst_typ, fld1_lst, fld2_lst): + mf = ICoCoMED_T_Field() + mf.setName("titi") + self.assertEqual(mf.getName(), "titi") + mfd = mf.getMCField() + self.assertTrue(mfd is None) + mf.setMCField(f1) + f11 = mf.getMCField() + self.assertEqual(f1.getHiddenCppPointer(), f11.getHiddenCppPointer()) # strictly the same + self.assertEqual(mf.getName(), "toto") # name is taken from MC object + mf.setMCField(f2) + f22 = mf.getMCField() + self.assertEqual(f2.getHiddenCppPointer(), f22.getHiddenCppPointer()) # strictly the same + + mf = ICoCoMED_T_Field(f1) # ctor with MC object + mfd = mf.getMCField() + self.assertEqual(mfd.getHiddenCppPointer(), f1.getHiddenCppPointer()) # strictly the same + self.assertEqual(mf.getName(), "toto") # name is taken from MC object + + mf.setMCField(None) + mfd = mf.getMCField() + self.assertTrue(mfd is None) + self.assertEqual(mf.getName(), "") # name is reset + + mf.setMCField(f2) + f22 = mf.getMCField() + self.assertEqual(f2.getHiddenCppPointer(), f22.getHiddenCppPointer()) # strictly the same + + mf.setName("aa") + mf2 = ICoCoMED_T_Field(mf) # copy ctor + f22 = mf2.getMCField() + self.assertEqual(f2.getHiddenCppPointer(), f22.getHiddenCppPointer()) # strictly the same + self.assertEqual(mf2.getName(), "aa") + + mf2 = mf # assignement op + f22 = mf2.getMCField() + self.assertEqual(f2.getHiddenCppPointer(), f22.getHiddenCppPointer()) # strictly the same + self.assertEqual(mf2.getName(), "aa") + + mf2.setMCField(None) + self.assertEqual(mf2.getName(), "") + +if __name__ == '__main__': + unittest.main() diff --git a/src/MEDCoupling_Swig/MEDCoupling.i b/src/MEDCoupling_Swig/MEDCoupling.i index 8f938325e..4405b92c6 100644 --- a/src/MEDCoupling_Swig/MEDCoupling.i +++ b/src/MEDCoupling_Swig/MEDCoupling.i @@ -24,6 +24,7 @@ #endif %include "MEDCouplingCommon.i" +%include "ICoCoMEDField.i" %pythoncode %{ def MEDCouplingDataArrayDoubleIadd(self,*args): diff --git a/src/MEDCoupling_Swig/tests.set b/src/MEDCoupling_Swig/tests.set index 182197c86..149ce0fb0 100644 --- a/src/MEDCoupling_Swig/tests.set +++ b/src/MEDCoupling_Swig/tests.set @@ -29,6 +29,7 @@ SET(BASE_TESTS MEDCouplingExamplesTest.py MEDCouplingRemapperTest.py UsersGuideExamplesTest.py + ICoCoMEDFieldTest.py ) # if numpy is used diff --git a/src/ParaMEDMEM/DEC.cxx b/src/ParaMEDMEM/DEC.cxx index 4cd1cf9f8..95dfe5a29 100644 --- a/src/ParaMEDMEM/DEC.cxx +++ b/src/ParaMEDMEM/DEC.cxx @@ -24,8 +24,7 @@ #include "ParaFIELD.hxx" #include "ParaMESH.hxx" #include "DEC.hxx" -#include "ICoCoField.hxx" -#include "ICoCoMEDField.hxx" +#include "ICoCoMEDDoubleField.hxx" #include "MPIProcessorGroup.hxx" #include diff --git a/src/ParaMEDMEM/DisjointDEC.cxx b/src/ParaMEDMEM/DisjointDEC.cxx index 7d62ca109..12931c696 100644 --- a/src/ParaMEDMEM/DisjointDEC.cxx +++ b/src/ParaMEDMEM/DisjointDEC.cxx @@ -25,7 +25,7 @@ #include "ParaFIELD.hxx" #include "ParaMESH.hxx" #include "ICoCoField.hxx" -#include "ICoCoMEDField.hxx" +#include "ICoCoMEDDoubleField.hxx" #include "MPIProcessorGroup.hxx" #include @@ -269,16 +269,16 @@ namespace MEDCoupling will be updated by a recvData() call. Reversely, if the processor is on the sending end, the field will be read, possibly transformed, and sent appropriately to the other side. The field type is a generic ICoCo Field, so that the DEC can couple a number of different fields : - - a ICoCo::MEDField, that is created from a MEDCoupling structure + - a ICoCo::MEDDoubleField, that is created from a MEDCoupling structure */ - void DisjointDEC::attachLocalField(const ICoCo::MEDField *field) + void DisjointDEC::attachLocalField(const ICoCo::MEDDoubleField *field) { if(!isInUnion()) return ; if(!field) - throw INTERP_KERNEL::Exception("DisjointDEC::attachLocalField : ICoCo::MEDField pointer is NULL !"); - attachLocalField(field->getField()); + throw INTERP_KERNEL::Exception("DisjointDEC::attachLocalField : ICoCo::MEDDoubleField pointer is NULL !"); + attachLocalField(field->getMCField()); } /*! diff --git a/src/ParaMEDMEM/DisjointDEC.hxx b/src/ParaMEDMEM/DisjointDEC.hxx index b925a1c3f..989f3a78e 100644 --- a/src/ParaMEDMEM/DisjointDEC.hxx +++ b/src/ParaMEDMEM/DisjointDEC.hxx @@ -29,7 +29,7 @@ namespace ICoCo { - class MEDField; + class MEDDoubleField; } namespace MEDCoupling @@ -84,8 +84,8 @@ namespace MEDCoupling void setNature(NatureOfField nature); void attachLocalField( MEDCouplingFieldDouble *field); void attachLocalField(const ParaFIELD *field, bool ownPt=false); - void attachLocalField(const ICoCo::MEDField *field); - + void attachLocalField(const ICoCo::MEDDoubleField *field); + virtual void prepareSourceDE() = 0; virtual void prepareTargetDE() = 0; virtual void recvData() = 0; diff --git a/src/ParaMEDMEM/OverlapDEC.cxx b/src/ParaMEDMEM/OverlapDEC.cxx index 45aa2dee7..8ee39a40c 100644 --- a/src/ParaMEDMEM/OverlapDEC.cxx +++ b/src/ParaMEDMEM/OverlapDEC.cxx @@ -25,7 +25,7 @@ #include "MPIProcessorGroup.hxx" #include "OverlapElementLocator.hxx" #include "OverlapInterpolationMatrix.hxx" -#include "ICoCoMEDField.hxx" +#include "ICoCoMEDDoubleField.hxx" namespace MEDCoupling { @@ -189,14 +189,14 @@ namespace MEDCoupling attachTargetLocalField(tmpField,true); } - void OverlapDEC::attachSourceLocalField(ICoCo::MEDField *field) + void OverlapDEC::attachSourceLocalField(ICoCo::MEDDoubleField *field) { - attachSourceLocalField(field->getField()); + attachSourceLocalField(field->getMCField()); } - void OverlapDEC::attachTargetLocalField(ICoCo::MEDField *field) + void OverlapDEC::attachTargetLocalField(ICoCo::MEDDoubleField *field) { - attachTargetLocalField(field->getField()); + attachTargetLocalField(field->getMCField()); } bool OverlapDEC::isInGroup() const diff --git a/src/ParaMEDMEM/OverlapDEC.hxx b/src/ParaMEDMEM/OverlapDEC.hxx index 85288cafa..75eb644dd 100644 --- a/src/ParaMEDMEM/OverlapDEC.hxx +++ b/src/ParaMEDMEM/OverlapDEC.hxx @@ -28,7 +28,7 @@ #include namespace ICoCo { - class MEDField; + class MEDDoubleField; } namespace MEDCoupling @@ -234,8 +234,8 @@ namespace MEDCoupling void attachTargetLocalField(ParaFIELD *field, bool ownPt=false); void attachSourceLocalField(MEDCouplingFieldDouble *field); void attachTargetLocalField(MEDCouplingFieldDouble *field); - void attachSourceLocalField(ICoCo::MEDField *field); - void attachTargetLocalField(ICoCo::MEDField *field); + void attachSourceLocalField(ICoCo::MEDDoubleField *field); + void attachTargetLocalField(ICoCo::MEDDoubleField *field); ProcessorGroup *getGroup() { return _group; } bool isInGroup() const; diff --git a/src/ParaMEDMEMTest/ParaMEDMEMTest_InterpKernelDEC.cxx b/src/ParaMEDMEMTest/ParaMEDMEMTest_InterpKernelDEC.cxx index 45e7d07ff..c61718d0e 100644 --- a/src/ParaMEDMEMTest/ParaMEDMEMTest_InterpKernelDEC.cxx +++ b/src/ParaMEDMEMTest/ParaMEDMEMTest_InterpKernelDEC.cxx @@ -30,9 +30,10 @@ #include "ParaMESH.hxx" #include "ParaFIELD.hxx" #include "ComponentTopology.hxx" -#include "ICoCoMEDField.hxx" #include "ParaMEDLoader.hxx" +#include "ICoCoMEDDoubleField.hxx" #include "MEDLoader.hxx" +#include "MEDCouplingUMesh.hxx" #include "TestInterpKernelUtils.hxx" @@ -495,7 +496,7 @@ void ParaMEDMEMTest::testInterpKernelDEC_2D_(const char *srcMeth, const char *ta MEDCoupling::MEDCouplingUMesh* mesh = nullptr; MEDCoupling::ParaMESH* paramesh = nullptr; MEDCoupling::ParaFIELD* parafield = nullptr; - ICoCo::MEDField* icocofield = nullptr; + ICoCo::MEDDoubleField* icocofield = nullptr; string filename_xml1 = "square1_split"; string filename_xml2 = "square2_split"; @@ -541,7 +542,7 @@ void ParaMEDMEMTest::testInterpKernelDEC_2D_(const char *srcMeth, const char *ta value[ielem]=1.0; // ICoCo::Field* icocofield=new ICoCo::MEDField(paramesh,parafield); - icocofield=new ICoCo::MEDField(parafield->getField()); + icocofield=new ICoCo::MEDDoubleField(parafield->getField()); dec.setMethod(srcMeth); dec.attachLocalField(icocofield); } @@ -577,7 +578,7 @@ void ParaMEDMEMTest::testInterpKernelDEC_2D_(const char *srcMeth, const char *ta for(int ielem=0; ielemgetField()); + icocofield=new ICoCo::MEDDoubleField(parafield->getField()); dec.setMethod(targetMeth); dec.attachLocalField(icocofield); } @@ -862,7 +863,7 @@ void ParaMEDMEMTest::testInterpKernelDEC_3D_(const char *srcMeth, const char *ta MEDCoupling::MEDCouplingUMesh* mesh = nullptr; MEDCoupling::ParaMESH* paramesh = nullptr; MEDCoupling::ParaFIELD* parafield = nullptr; - ICoCo::MEDField* icocofield = nullptr; + ICoCo::MEDDoubleField* icocofield = nullptr; char * tmp_dir_c = getenv("TMP"); string tmp_dir; @@ -914,7 +915,7 @@ void ParaMEDMEMTest::testInterpKernelDEC_3D_(const char *srcMeth, const char *ta value[ielem]=1.0; // ICoCo::Field* icocofield=new ICoCo::MEDField(paramesh,parafield); - icocofield=new ICoCo::MEDField(parafield->getField()); + icocofield=new ICoCo::MEDDoubleField(parafield->getField()); dec.setMethod(srcMeth); dec.attachLocalField(icocofield); } @@ -950,7 +951,7 @@ void ParaMEDMEMTest::testInterpKernelDEC_3D_(const char *srcMeth, const char *ta for(int ielem=0; ielemgetField()); + icocofield=new ICoCo::MEDDoubleField(parafield->getField()); dec.setMethod(targetMeth); dec.attachLocalField(icocofield); } @@ -2116,7 +2117,7 @@ void ParaMEDMEMTest::testAsynchronousInterpKernelDEC_2D(double dtA, double tmaxA MEDCoupling::MEDCouplingUMesh* mesh = nullptr; MEDCoupling::ParaMESH* paramesh = nullptr; MEDCoupling::ParaFIELD* parafield = nullptr; - ICoCo::MEDField* icocofield = nullptr; + ICoCo::MEDDoubleField* icocofield = nullptr; char * tmp_dir_c = getenv("TMP"); string tmp_dir; @@ -2169,7 +2170,7 @@ void ParaMEDMEMTest::testAsynchronousInterpKernelDEC_2D(double dtA, double tmaxA value[ielem]=0.0; // ICoCo::Field* icocofield=new ICoCo::MEDField(paramesh,parafield); - icocofield=new ICoCo::MEDField(parafield->getField()); + icocofield=new ICoCo::MEDDoubleField(parafield->getField()); dec.attachLocalField(icocofield); @@ -2209,7 +2210,7 @@ void ParaMEDMEMTest::testAsynchronousInterpKernelDEC_2D(double dtA, double tmaxA for(int ielem=0; ielemgetField()); + icocofield=new ICoCo::MEDDoubleField(parafield->getField()); dec.attachLocalField(icocofield); } diff --git a/src/ParaMEDMEMTest/ParaMEDMEMTest_StructuredCoincidentDEC.cxx b/src/ParaMEDMEMTest/ParaMEDMEMTest_StructuredCoincidentDEC.cxx index 56176d1d5..2940e77df 100644 --- a/src/ParaMEDMEMTest/ParaMEDMEMTest_StructuredCoincidentDEC.cxx +++ b/src/ParaMEDMEMTest/ParaMEDMEMTest_StructuredCoincidentDEC.cxx @@ -29,8 +29,9 @@ #include "ParaMESH.hxx" #include "ParaFIELD.hxx" #include "ComponentTopology.hxx" -#include "ICoCoMEDField.hxx" +#include "ICoCoMEDDoubleField.hxx" #include "MEDLoader.hxx" +#include "MEDCouplingUMesh.hxx" #include "TestInterpKernelUtils.hxx" #include diff --git a/src/ParaMEDMEMTest/test_perf.cxx b/src/ParaMEDMEMTest/test_perf.cxx index f8de637da..81c8d55f0 100644 --- a/src/ParaMEDMEMTest/test_perf.cxx +++ b/src/ParaMEDMEMTest/test_perf.cxx @@ -33,12 +33,14 @@ #include "ParaMESH.hxx" #include "ParaFIELD.hxx" #include "ComponentTopology.hxx" -#include "ICoCoMEDField.hxx" #include "MEDLoader.hxx" +#include "ICoCoMEDDoubleField.hxx" +#include "MEDCouplingUMesh.hxx" #include #include + // use this define to enable lines, execution of which leads to Segmentation Fault #define ENABLE_FAULTS @@ -149,7 +151,7 @@ void testInterpKernelDEC_2D(const string& filename_xml1, const string& meshname1 MEDCoupling::MEDCouplingUMesh* mesh = nullptr; MEDCoupling::ParaMESH* paramesh = nullptr; MEDCoupling::ParaFIELD* parafield = nullptr; - ICoCo::MEDField* icocofield = nullptr; + ICoCo::MEDDoubleField* icocofield = nullptr; // To remove tmp files from disk ParaMEDMEMTest_TmpFilesRemover aRemover; @@ -187,7 +189,7 @@ void testInterpKernelDEC_2D(const string& filename_xml1, const string& meshname1 for(int ielem=0; ielemgetField()); + icocofield=new ICoCo::MEDDoubleField(parafield->getField()); dec.attachLocalField(icocofield); } @@ -219,7 +221,7 @@ void testInterpKernelDEC_2D(const string& filename_xml1, const string& meshname1 double *value=parafield->getField()->getArray()->getPointer(); for(int ielem=0; ielemgetField()); + icocofield=new ICoCo::MEDDoubleField(parafield->getField()); dec.attachLocalField(icocofield); } diff --git a/src/ParaMEDMEM_Swig/CMakeLists.txt b/src/ParaMEDMEM_Swig/CMakeLists.txt index 4552f79f7..7a55bc574 100644 --- a/src/ParaMEDMEM_Swig/CMakeLists.txt +++ b/src/ParaMEDMEM_Swig/CMakeLists.txt @@ -45,6 +45,7 @@ INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/../ParaMEDMEM ${CMAKE_CURRENT_SOURCE_DIR}/../ParaMEDMEM/MPIAccess ${CMAKE_CURRENT_SOURCE_DIR}/../ICoCo + ${CMAKE_CURRENT_SOURCE_DIR}/../ICoCo/Swig ${CMAKE_CURRENT_SOURCE_DIR}/../MEDCoupling_Swig ${CMAKE_CURRENT_SOURCE_DIR}/../MEDCoupling ${CMAKE_CURRENT_SOURCE_DIR}/../INTERP_KERNEL diff --git a/src/ParaMEDMEM_Swig/ParaMEDMEM.i b/src/ParaMEDMEM_Swig/ParaMEDMEM.i index c9b887521..40d0bd8db 100644 --- a/src/ParaMEDMEM_Swig/ParaMEDMEM.i +++ b/src/ParaMEDMEM_Swig/ParaMEDMEM.i @@ -25,6 +25,7 @@ #define INTERPKERNEL_EXPORT %include "MEDCouplingCommon.i" +%include "ICoCoMEDField.i" %include "ParaMEDMEMCommon.i" diff --git a/src/ParaMEDMEM_Swig/ParaMEDMEMCommon.i b/src/ParaMEDMEM_Swig/ParaMEDMEMCommon.i index cacfcfe04..49526b5a1 100644 --- a/src/ParaMEDMEM_Swig/ParaMEDMEMCommon.i +++ b/src/ParaMEDMEM_Swig/ParaMEDMEMCommon.i @@ -33,7 +33,8 @@ #include "OverlapDEC.hxx" #include "ParaMESH.hxx" #include "ParaFIELD.hxx" -#include "ICoCoMEDField.hxx" +#include "ICoCoMEDDoubleField.hxx" +#include "ICoCoMEDIntField.hxx" #include "ComponentTopology.hxx" #include "ParaUMesh.hxx" #include "ParaSkyLineArray.hxx" @@ -57,10 +58,6 @@ using namespace ICoCo; %include "StructuredCoincidentDEC.hxx" %include "OverlapDEC.hxx" -%include "ICoCoField.hxx" -%rename(ICoCoMEDField) ICoCo::MEDField; -%include "ICoCoMEDField.hxx" - %newobject MEDCoupling::ParaUMesh::New; %newobject MEDCoupling::ParaUMesh::getMesh; %newobject MEDCoupling::ParaUMesh::getGlobalCellIds; diff --git a/src/ParaMEDMEM_Swig/test_InterpKernelDEC.py b/src/ParaMEDMEM_Swig/test_InterpKernelDEC.py index 7664b8c35..d6e0ccb52 100755 --- a/src/ParaMEDMEM_Swig/test_InterpKernelDEC.py +++ b/src/ParaMEDMEM_Swig/test_InterpKernelDEC.py @@ -181,7 +181,7 @@ class ParaMEDMEM_IK_DEC_Tests(unittest.TestCase): nb_local=mesh.getNumberOfCells() value = [1.0]*nb_local parafield.getField().setValues(value) - icocofield = ICoCoMEDField(parafield.getField()) + icocofield = ICoCoMEDDoubleField(parafield.getField()) dec.attachLocalField(icocofield) pass else: @@ -195,7 +195,7 @@ class ParaMEDMEM_IK_DEC_Tests(unittest.TestCase): nb_local=mesh.getNumberOfCells() value = [0.0]*nb_local parafield.getField().setValues(value) - icocofield = ICoCoMEDField(parafield.getField()) + icocofield = ICoCoMEDDoubleField(parafield.getField()) dec.attachLocalField(icocofield) pass diff --git a/src/ParaMEDMEM_Swig/test_NonCoincidentDEC.py b/src/ParaMEDMEM_Swig/test_NonCoincidentDEC.py index 767001835..7be5f973e 100755 --- a/src/ParaMEDMEM_Swig/test_NonCoincidentDEC.py +++ b/src/ParaMEDMEM_Swig/test_NonCoincidentDEC.py @@ -73,7 +73,7 @@ class ParaMEDMEM_DEC_Tests(unittest.TestCase): value = [1.0]*nb_local parafield.getField().setValue(value) - icocofield = ICoCo_MEDField(paramesh,parafield) + icocofield = ICoCoMEDDoubleField(paramesh,parafield) dec.attachLocalField(icocofield,'P0') pass @@ -93,7 +93,7 @@ class ParaMEDMEM_DEC_Tests(unittest.TestCase): value = [0.0]*nb_local parafield.getField().setValue(value) - icocofield = ICoCo_MEDField(paramesh,parafield) + icocofield = ICoCoMEDDoubleField(paramesh,parafield) dec.attachLocalField(icocofield, 'P0') pass diff --git a/src/ParaMEDMEM_Swig/test_StructuredCoincidentDEC.py b/src/ParaMEDMEM_Swig/test_StructuredCoincidentDEC.py index 275a40c1a..a72a75817 100755 --- a/src/ParaMEDMEM_Swig/test_StructuredCoincidentDEC.py +++ b/src/ParaMEDMEM_Swig/test_StructuredCoincidentDEC.py @@ -182,7 +182,7 @@ class ParaMEDMEM_SC_DEC_Tests(unittest.TestCase): for icomp in range(6): value.append(global_numbering[ielem]*6.0+icomp); parafield.getField().setValues(value) - icocofield = ICoCoMEDField(parafield.getField()) + icocofield = ICoCoMEDDoubleField(parafield.getField()) dec.setMethod("P0") dec.attachLocalField(parafield) dec.synchronize() @@ -198,7 +198,7 @@ class ParaMEDMEM_SC_DEC_Tests(unittest.TestCase): nb_local=mesh.getNumberOfCells() value = [0.0]*(nb_local*comptopo.nbLocalComponents()) parafield.getField().setValues(value) - icocofield = ICoCoMEDField(parafield.getField()) + icocofield = ICoCoMEDDoubleField(parafield.getField()) dec.setMethod("P0") dec.attachLocalField(parafield) dec.synchronize() diff --git a/src/PyWrapping/CMakeLists.txt b/src/PyWrapping/CMakeLists.txt index 7002289f3..f9c96dfc9 100644 --- a/src/PyWrapping/CMakeLists.txt +++ b/src/PyWrapping/CMakeLists.txt @@ -59,6 +59,7 @@ INCLUDE_DIRECTORIES( ${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/MPIAccess ${CMAKE_CURRENT_SOURCE_DIR}/../ParaMEDMEM_Swig diff --git a/src/PyWrapping/medcoupling.i b/src/PyWrapping/medcoupling.i index 6997381ef..3c7a0e6d1 100644 --- a/src/PyWrapping/medcoupling.i +++ b/src/PyWrapping/medcoupling.i @@ -30,6 +30,8 @@ %include "MEDCouplingRemapperCommon.i" +%include "ICoCoMEDField.i" + #ifdef WITH_MED_FILE %include "MEDLoaderCommon.i" #endif -- 2.39.2