1 // Copyright (C) 2007-2014 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "ParaMESH.hxx"
21 #include "ProcessorGroup.hxx"
22 #include "MPIProcessorGroup.hxx"
23 #include "Topology.hxx"
24 #include "BlockTopology.hxx"
25 #include "MEDCouplingMemArray.hxx"
30 //inclusion for the namespaces
35 ParaMESH::ParaMESH( MEDCouplingPointSet *subdomain_mesh, MEDCouplingPointSet *subdomain_face,
36 DataArrayInt *CorrespElt_local2global, DataArrayInt *CorrespFace_local2global,
37 DataArrayInt *CorrespNod_local2global, const ProcessorGroup& proc_group ):
38 _cell_mesh(subdomain_mesh),
39 _face_mesh(subdomain_face),
40 _my_domain_id(proc_group.myRank()),
41 _block_topology (new BlockTopology(proc_group, subdomain_mesh->getNumberOfCells())),
42 _explicit_topology(0),
43 _node_global(CorrespNod_local2global),
44 _face_global(CorrespFace_local2global),
45 _cell_global(CorrespElt_local2global)
48 _cell_mesh->incrRef();
50 _face_mesh->incrRef();
51 if(CorrespElt_local2global)
52 CorrespElt_local2global->incrRef();
53 if(CorrespFace_local2global)
54 CorrespFace_local2global->incrRef();
55 if(CorrespNod_local2global)
56 CorrespNod_local2global->incrRef();
59 ParaMESH::ParaMESH( MEDCouplingPointSet *mesh, const ProcessorGroup& proc_group, const std::string& name):
62 _my_domain_id(proc_group.myRank()),
63 _block_topology (new BlockTopology(proc_group, mesh->getNumberOfCells())),
68 _cell_mesh->incrRef();
69 int nb_elem=mesh->getNumberOfCells();
70 _explicit_topology=new BlockTopology(proc_group,nb_elem);
71 int nbOfCells=mesh->getNumberOfCells();
72 _cell_global = DataArrayInt::New();
73 _cell_global->alloc(nbOfCells,1);
74 int *cellglobal=_cell_global->getPointer();
75 int offset = _block_topology->localToGlobal(make_pair(_my_domain_id,0));
76 for (int i=0; i<nbOfCells; i++)
78 cellglobal[i]=offset+i;
82 void ParaMESH::setNodeGlobal(DataArrayInt *nodeGlobal)
84 if(nodeGlobal!=_node_global)
87 _node_global->decrRef();
88 _node_global=nodeGlobal;
90 _node_global->incrRef();
94 void ParaMESH::setCellGlobal(DataArrayInt *cellGlobal)
96 if(cellGlobal!=_cell_global)
99 _cell_global->decrRef();
100 _cell_global=cellGlobal;
102 _cell_global->incrRef();
106 ParaMESH::~ParaMESH()
109 _cell_mesh->decrRef();
111 _face_mesh->decrRef();
112 delete _block_topology;
114 _node_global->decrRef();
116 _cell_global->decrRef();
118 _face_global->decrRef();
119 delete _explicit_topology;