Back to index

salome-med  6.5.0
ParaMESH.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 #include "ParaMESH.hxx"
00021 #include "ProcessorGroup.hxx"
00022 #include "MPIProcessorGroup.hxx"
00023 #include "Topology.hxx"
00024 #include "BlockTopology.hxx"
00025 #include "MEDCouplingMemArray.hxx"
00026 
00027 #include <fstream>
00028 #include <vector>
00029 
00030 //inclusion for the namespaces
00031 using namespace std;
00032 
00033 namespace ParaMEDMEM
00034 {
00035   ParaMESH::ParaMESH( MEDCouplingPointSet *subdomain_mesh, MEDCouplingPointSet *subdomain_face,
00036             DataArrayInt *CorrespElt_local2global, DataArrayInt *CorrespFace_local2global,
00037             DataArrayInt *CorrespNod_local2global, const ProcessorGroup& proc_group ):
00038     _cell_mesh(subdomain_mesh),
00039     _face_mesh(subdomain_face),
00040     _my_domain_id(proc_group.myRank()),
00041     _block_topology (new BlockTopology(proc_group, subdomain_mesh->getNumberOfCells())),
00042     _explicit_topology(0),
00043     _node_global(CorrespNod_local2global),
00044     _face_global(CorrespFace_local2global),
00045     _cell_global(CorrespElt_local2global)
00046   {
00047     if(_cell_mesh)
00048       _cell_mesh->incrRef();
00049     if(_face_mesh)
00050       _face_mesh->incrRef();
00051     if(CorrespElt_local2global)
00052       CorrespElt_local2global->incrRef();
00053     if(CorrespFace_local2global)
00054       CorrespFace_local2global->incrRef();
00055     if(CorrespNod_local2global)
00056       CorrespNod_local2global->incrRef();
00057   }
00058 
00059   ParaMESH::ParaMESH( MEDCouplingPointSet *mesh, const ProcessorGroup& proc_group, const std::string& name):
00060     _cell_mesh(mesh),
00061     _face_mesh(0),
00062     _my_domain_id(proc_group.myRank()),
00063     _block_topology (new BlockTopology(proc_group, mesh->getNumberOfCells())),
00064     _node_global(0),
00065     _face_global(0)
00066   {
00067     if(_cell_mesh)
00068       _cell_mesh->incrRef();
00069     int nb_elem=mesh->getNumberOfCells();
00070     _explicit_topology=new BlockTopology(proc_group,nb_elem);
00071     int nbOfCells=mesh->getNumberOfCells();
00072     _cell_global = DataArrayInt::New();
00073     _cell_global->alloc(nbOfCells,1);
00074     int *cellglobal=_cell_global->getPointer();
00075     int offset = _block_topology->localToGlobal(make_pair(_my_domain_id,0));
00076     for (int i=0; i<nbOfCells; i++)
00077       {
00078         cellglobal[i]=offset+i;
00079       }
00080   }
00081 
00082   void ParaMESH::setNodeGlobal(DataArrayInt *nodeGlobal)
00083   {
00084     if(nodeGlobal!=_node_global)
00085       {
00086         if(_node_global)
00087           _node_global->decrRef();
00088         _node_global=nodeGlobal;
00089         if(_node_global)
00090           _node_global->incrRef();
00091       }
00092   }
00093 
00094   void ParaMESH::setCellGlobal(DataArrayInt *cellGlobal)
00095   {
00096     if(cellGlobal!=_cell_global)
00097       {
00098         if(_cell_global)
00099           _cell_global->decrRef();
00100         _cell_global=cellGlobal;
00101         if(_cell_global)
00102           _cell_global->incrRef();
00103       }
00104   }
00105 
00106   ParaMESH::~ParaMESH()
00107   {
00108     if(_cell_mesh)
00109       _cell_mesh->decrRef();
00110     if(_face_mesh)
00111       _face_mesh->decrRef();
00112     delete _block_topology;
00113     if(_node_global)
00114       _node_global->decrRef();
00115     if(_cell_global)
00116       _cell_global->decrRef();
00117     if(_face_global)
00118       _face_global->decrRef();
00119     delete _explicit_topology;
00120   }
00121 
00122 }