X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FParaMEDMEM%2FExplicitCoincidentDEC.cxx;h=32a59f463bf481b1ac98d4d80d1c8d532f14f503;hb=c41e6035d050073ea10040690daae247865b8b74;hp=79ca011975d8c0554ce93b22e3fe9722b17e21f2;hpb=48782c06022ca2caa36f849cb5a29ea4fe2aaa83;p=tools%2Fmedcoupling.git diff --git a/src/ParaMEDMEM/ExplicitCoincidentDEC.cxx b/src/ParaMEDMEM/ExplicitCoincidentDEC.cxx index 79ca01197..32a59f463 100644 --- a/src/ParaMEDMEM/ExplicitCoincidentDEC.cxx +++ b/src/ParaMEDMEM/ExplicitCoincidentDEC.cxx @@ -1,21 +1,22 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// Copyright (C) 2007-2016 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. +// 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. +// 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 +// 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 +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // + #include #include "CommInterface.hxx" #include "Topology.hxx" @@ -29,10 +30,71 @@ using namespace std; -namespace ParaMEDMEM +namespace MEDCoupling { - ExplicitCoincidentDEC::ExplicitCoincidentDEC():_toposource(0),_topotarget(0) + /*! + \anchor ExplicitCoincidentDEC-det + \class ExplicitCoincidentDEC + + + This class aims at \ref interpolation "remapping fields" that have identical + supports (=the same underlying mesh) but different parallel topologies + (=different sub-domains in the mesh). It can be used to couple + together multi-physics codes that operate on the same domain + with different partitioning. + + It is very similar to what the \ref StructuredCoincidentDEC-det "StructuredCoincidentDEC" + does, except that it works with an arbitrary user-defined topology. + + The remapping between the two supports is based on identity of global + ids, instead of geometrical considerations (as it is the case for + \ref InterpKernelDEC-det "InterpKernelDEC"). + Therefore, beware that this \ref para-dec "DEC" can not be used + for coincident meshes if they do *not* have the exact same numbering. + + With this \ref para-dec "DEC" no projection, and no interpolation of the field data is done, contrary + to what happens in \ref InterpKernelDEC-det "InterpKernelDEC". It is just + a matter of allocating the values from one side to the other, using directly the cell + identifiers. + + As all the other DECs, its usage requires two phases : + - a setup phase during which the topologies are exchanged so that + the target side knows from which processors it should expect + the data. + - a send/recv phase during which the field data is actually transferred. + + This example illustrates the sending of a field with + the \c ExplicitCoincidentDEC : + \code + ... + ExplicitCoincidentDEC dec(groupA, groupB); + dec.attachLocalField(field); + dec.synchronize(); + if (groupA.containsMyRank()) + dec.recvData(); + else if (groupB.containsMyRank()) + dec.sendData(); + ... + \endcode + + Creating a ParaFIELD to be attached to the %DEC is done in exactly the same way as for + the other DECs, if only the partitioning of the support mesh differs. + In the case where the + fields have also different *component* topologies, creating the ParaFIELD + requires some more effort. See the \ref para-over "parallelism" section for more details. + */ + + + /*! Constructor + */ + ExplicitCoincidentDEC::ExplicitCoincidentDEC(): + _toposource(0),_topotarget(0), + _targetgroup(0), _sourcegroup(0), + _sendcounts(0), _recvcounts(0), + _senddispls(0), _recvdispls(0), + _recvbuffer(0), _sendbuffer(0), + _distant_elems(), _explicit_mapping() { } @@ -177,8 +239,7 @@ namespace ParaMEDMEM /*! - * Synchronizing a topology so that all the - * group possesses it. + * Synchronizing a topology so that all the groups get it. * * \param toposend Topology that is transmitted. It is read on processes where it already exists, and it is created and filled on others. * \param toporecv Topology which is received. @@ -210,7 +271,7 @@ namespace ParaMEDMEM } else { - vector size (group->size()); + vector size2(group->size()); int myworldrank=group->myRank(); for (int iproc=0; iprocsize();iproc++) { @@ -232,7 +293,7 @@ namespace ParaMEDMEM int sendlocal=topotemp->globalToLocal(global); if (sendlocal!=-1) { - size[iproc]++; + size2[iproc]++; _explicit_mapping.pushBackElem(make_pair(iproc,sendlocal)); } } @@ -280,7 +341,7 @@ namespace ParaMEDMEM } int* recvcounts=new int[world_size]; int* recvdispls=new int[world_size]; - int *dummyrecv; + int *dummyrecv=0; for (int i=0; i