2 // Copyright (C) 2007-2023 CEA, EDF
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 DataArrayIdType *CorrespElt_local2global, DataArrayIdType *CorrespFace_local2global,
38 DataArrayIdType *CorrespNod_local2global, const ProcessorGroup& proc_group ):
39 _my_domain_id(proc_group.myRank()),
40 _block_topology(new BlockTopology(proc_group, subdomain_mesh->getNumberOfCells())),
41 _explicit_topology(nullptr)
43 _cell_mesh.takeRef(subdomain_mesh);
44 _face_mesh.takeRef(subdomain_face);
45 _node_global.takeRef(CorrespNod_local2global);
46 _face_global.takeRef(CorrespFace_local2global);
47 _cell_global.takeRef(CorrespElt_local2global);
50 ParaMESH::ParaMESH( MEDCouplingPointSet *mesh, const ProcessorGroup& proc_group, const std::string& name):
51 _my_domain_id(proc_group.myRank()),
52 _block_topology(new BlockTopology(proc_group, mesh->getNumberOfCells()))
54 _cell_mesh.takeRef(mesh);
55 mcIdType nb_elem=mesh->getNumberOfCells();
56 _explicit_topology=new BlockTopology(proc_group,nb_elem);
57 mcIdType nbOfCells=mesh->getNumberOfCells();
58 _cell_global = DataArrayIdType::New();
59 _cell_global->alloc(nbOfCells,1);
60 mcIdType *cellglobal=_cell_global->getPointer();
61 mcIdType offset = _block_topology->localToGlobal(make_pair(_my_domain_id,0));
62 for (mcIdType i=0; i<nbOfCells; i++)
64 cellglobal[i]=offset+i;
68 void ParaMESH::setNodeGlobal(DataArrayIdType *nodeGlobal)
70 _node_global.takeRef(nodeGlobal);
73 void ParaMESH::setCellGlobal(DataArrayIdType *cellGlobal)
75 _cell_global.takeRef(cellGlobal);
83 /** Destructor involves MPI operations: make sure this is accessible from a proper
84 * method for Python wrapping.
86 void ParaMESH::release()
88 delete _block_topology;
89 delete _explicit_topology;
90 _block_topology = nullptr;
91 _explicit_topology = nullptr;