2 // Copyright (C) 2007-2019 CEA/DEN, EDF R&D
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 #include "ParaMESH.hxx"
22 #include "ProcessorGroup.hxx"
23 #include "MPIProcessorGroup.hxx"
24 #include "Topology.hxx"
25 #include "BlockTopology.hxx"
26 #include "MEDCouplingMemArray.hxx"
31 //inclusion for the namespaces
36 ParaMESH::ParaMESH( MEDCouplingPointSet *subdomain_mesh, MEDCouplingPointSet *subdomain_face,
37 DataArrayInt *CorrespElt_local2global, DataArrayInt *CorrespFace_local2global,
38 DataArrayInt *CorrespNod_local2global, const ProcessorGroup& proc_group ):
39 _cell_mesh(subdomain_mesh),
40 _face_mesh(subdomain_face),
41 _my_domain_id(proc_group.myRank()),
42 _block_topology (new BlockTopology(proc_group, subdomain_mesh->getNumberOfCells())),
43 _explicit_topology(0),
44 _node_global(CorrespNod_local2global),
45 _face_global(CorrespFace_local2global),
46 _cell_global(CorrespElt_local2global)
49 _cell_mesh->incrRef();
51 _face_mesh->incrRef();
52 if(CorrespElt_local2global)
53 CorrespElt_local2global->incrRef();
54 if(CorrespFace_local2global)
55 CorrespFace_local2global->incrRef();
56 if(CorrespNod_local2global)
57 CorrespNod_local2global->incrRef();
60 ParaMESH::ParaMESH( MEDCouplingPointSet *mesh, const ProcessorGroup& proc_group, const std::string& name):
63 _my_domain_id(proc_group.myRank()),
64 _block_topology (new BlockTopology(proc_group, mesh->getNumberOfCells())),
69 _cell_mesh->incrRef();
70 int nb_elem=mesh->getNumberOfCells();
71 _explicit_topology=new BlockTopology(proc_group,nb_elem);
72 int nbOfCells=mesh->getNumberOfCells();
73 _cell_global = DataArrayInt::New();
74 _cell_global->alloc(nbOfCells,1);
75 int *cellglobal=_cell_global->getPointer();
76 int offset = _block_topology->localToGlobal(make_pair(_my_domain_id,0));
77 for (int i=0; i<nbOfCells; i++)
79 cellglobal[i]=offset+i;
83 void ParaMESH::setNodeGlobal(DataArrayInt *nodeGlobal)
85 if(nodeGlobal!=_node_global)
88 _node_global->decrRef();
89 _node_global=nodeGlobal;
91 _node_global->incrRef();
95 void ParaMESH::setCellGlobal(DataArrayInt *cellGlobal)
97 if(cellGlobal!=_cell_global)
100 _cell_global->decrRef();
101 _cell_global=cellGlobal;
103 _cell_global->incrRef();
107 ParaMESH::~ParaMESH()
110 _cell_mesh->decrRef();
112 _face_mesh->decrRef();
113 delete _block_topology;
115 _node_global->decrRef();
117 _cell_global->decrRef();
119 _face_global->decrRef();
120 delete _explicit_topology;