From 3ac70323b0baba8926ca7f2f315795ed61d321ba Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Mon, 2 Mar 2020 17:57:09 +0100 Subject: [PATCH] WIP --- src/MEDCoupling/MCAuto.hxx | 1 + src/MEDCoupling/MEDCouplingMemArray.cxx | 7 ++++ src/MEDCoupling/MEDCouplingMemArray.hxx | 3 ++ src/ParaMEDMEM/CMakeLists.txt | 3 +- src/ParaMEDMEM/ParaUMesh.cxx | 52 +++++++++++++++++++++++++ src/ParaMEDMEM/ParaUMesh.hxx | 48 +++++++++++++++++++++++ 6 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 src/ParaMEDMEM/ParaUMesh.cxx create mode 100644 src/ParaMEDMEM/ParaUMesh.hxx diff --git a/src/MEDCoupling/MCAuto.hxx b/src/MEDCoupling/MCAuto.hxx index 1a0c4038f..d1a8a2892 100644 --- a/src/MEDCoupling/MCAuto.hxx +++ b/src/MEDCoupling/MCAuto.hxx @@ -34,6 +34,7 @@ namespace MEDCoupling MCAuto(const MCAuto& other):_ptr(0) { referPtr(other._ptr); } MCAuto(T *ptr=0):_ptr(ptr) { } ~MCAuto() { destroyPtr(); } + void checkNotNull() const { if(!_ptr) throw INTERP_KERNEL::Exception("Pointer is nullptr !"); } bool isNull() const { return _ptr==0; } bool isNotNull() const { return !isNull(); } void nullify() { destroyPtr(); _ptr=0; } diff --git a/src/MEDCoupling/MEDCouplingMemArray.cxx b/src/MEDCoupling/MEDCouplingMemArray.cxx index 309f3a376..baa8dbd29 100755 --- a/src/MEDCoupling/MEDCouplingMemArray.cxx +++ b/src/MEDCoupling/MEDCouplingMemArray.cxx @@ -60,6 +60,13 @@ template class MEDCOUPLING_EXPORT MEDCoupling::DataArrayTuple; template class MEDCOUPLING_EXPORT MEDCoupling::DataArrayTuple; template class MEDCOUPLING_EXPORT MEDCoupling::DataArrayTuple; +void MEDCoupling::DACheckNbOfTuplesAndComp(const DataArray *da, mcIdType nbOfTuples, std::size_t nbOfCompo, const std::string& msg) +{ + if(!da) + throw INTERP_KERNEL::Exception("DACheckNbOfTuplesAndComp : null input object !"); + da->checkNbOfTuplesAndComp(nbOfTuples,nbOfCompo,msg); +} + template void DataArrayDouble::findCommonTuplesAlg(const double *bbox, mcIdType nbNodes, mcIdType limitNodeId, double prec, DataArrayIdType *c, DataArrayIdType *cI) const { diff --git a/src/MEDCoupling/MEDCouplingMemArray.hxx b/src/MEDCoupling/MEDCouplingMemArray.hxx index e5f4a3873..030f2c013 100755 --- a/src/MEDCoupling/MEDCouplingMemArray.hxx +++ b/src/MEDCoupling/MEDCouplingMemArray.hxx @@ -134,8 +134,11 @@ namespace MEDCoupling static mcIdType GetPosOfItemGivenBESRelativeNoThrow(T value, T begin, T end, T step); }; + class DataArray; class DataArrayByte; + MEDCOUPLING_EXPORT void DACheckNbOfTuplesAndComp(const DataArray *da, mcIdType nbOfTuples, std::size_t nbOfCompo, const std::string& msg); + class MEDCOUPLING_EXPORT DataArray : public RefCountObject, public TimeLabel { public: diff --git a/src/ParaMEDMEM/CMakeLists.txt b/src/ParaMEDMEM/CMakeLists.txt index 7324dd19d..5a7c28443 100644 --- a/src/ParaMEDMEM/CMakeLists.txt +++ b/src/ParaMEDMEM/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2019 CEA/DEN, EDF R&D +# Copyright (C) 2012-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 @@ -40,6 +40,7 @@ SET(paramedmem_SOURCES ProcessorGroup.cxx MPIProcessorGroup.cxx ParaMESH.cxx + ParaUMesh.cxx ComponentTopology.cxx MPIAccess.cxx InterpolationMatrix.cxx diff --git a/src/ParaMEDMEM/ParaUMesh.cxx b/src/ParaMEDMEM/ParaUMesh.cxx new file mode 100644 index 000000000..f29a61399 --- /dev/null +++ b/src/ParaMEDMEM/ParaUMesh.cxx @@ -0,0 +1,52 @@ +// +// Copyright (C) 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 +// +// Author : Anthony Geay (EDF R&D) + +#include "ParaUMesh.hxx" +#include "ProcessorGroup.hxx" +#include "MPIProcessorGroup.hxx" +#include "Topology.hxx" +#include "BlockTopology.hxx" +#include "MEDCouplingMemArray.hxx" + +#include +#include + +using namespace std; +using namespace MEDCoupling; + +ParaUMesh::ParaUMesh(MEDCouplingUMesh *mesh, DataArrayIdType *globalCellIds, DataArrayIdType *globalNodeIds) +{ + _mesh.takeRef(mesh); + _cell_global.takeRef(globalCellIds); + _node_global.takeRef(globalNodeIds); + _mesh.checkNotNull(); + _cell_global.checkNotNull(); + _node_global.checkNotNull(); + _mesh->checkConsistencyLight(); +} + +MCAuto ParaUMesh::getCellIdsLyingOnNodes(DataArrayIdType *globalNodeIds, bool fullyIn) const +{ + DACheckNbOfTuplesAndComp(globalNodeIds,_mesh->getNumberOfNodes(),1,"ParaUMesh::getCellIdsLyingOnNodes"); + if(fullyIn) + throw INTERP_KERNEL::Exception("ParaUMesh::getCellIdsLyingOnNodes : not implemented yet for fullyIn == True !"); + MCAuto local; +} diff --git a/src/ParaMEDMEM/ParaUMesh.hxx b/src/ParaMEDMEM/ParaUMesh.hxx new file mode 100644 index 000000000..d9b0993ed --- /dev/null +++ b/src/ParaMEDMEM/ParaUMesh.hxx @@ -0,0 +1,48 @@ +// Copyright (C) 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 +// +// Author : Anthony Geay (EDF R&D) + +#pragma once + +#include "MEDCouplingUMesh.hxx" +#include "ProcessorGroup.hxx" +#include "MEDCouplingMemArray.hxx" + +#include +#include + +namespace MEDCoupling +{ + /*! + * Parallel representation of an unstructured mesh. + * + * This class is very specific to the requirement of parallel code computations. + */ + class ParaUMesh + { + public: + ParaUMesh(MEDCouplingUMesh *mesh, DataArrayIdType *globalCellIds, DataArrayIdType *globalNodeIds); + MCAuto getCellIdsLyingOnNodes(DataArrayIdType *globalNodeIds, bool fullyIn) const; + virtual ~ParaUMesh() { } + private: + MCAuto _mesh; + MCAuto _cell_global; + MCAuto _node_global; + }; +} -- 2.39.2