Back to index

salome-med  6.5.0
ExplicitTopology.hxx
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 #ifndef __EXPLICITTOPOLOGY_HXX__
00021 #define __EXPLICITTOPOLOGY_HXX__
00022 
00023 #include "ProcessorGroup.hxx"
00024 #include "InterpKernelHashMap.hxx"
00025 
00026 #include <vector>
00027 #include <utility>
00028 #include <iostream>
00029 
00030 namespace ParaMEDMEM
00031 {
00032   class ParaMESH;
00033   class Topology;
00034   class ComponentTopology;
00035 
00036   class ExplicitTopology : public Topology
00037   {
00038   public:
00039     ExplicitTopology() { }
00040     ExplicitTopology( const ExplicitTopology& topo, int nbcomponents);
00041     ExplicitTopology(const ParaMESH &mesh);
00042     virtual ~ExplicitTopology();
00043     
00044     inline int getNbElements()const;
00045     inline int getNbLocalElements() const;
00046     const ProcessorGroup* getProcGroup()const { return _proc_group; }
00047     int localToGlobal (const std::pair<int,int> local) const { return localToGlobal(local.second); }
00048     inline int localToGlobal(int) const;
00049     inline int globalToLocal(int) const;
00050     void serialize(int* & serializer, int& size) const ;
00051     void unserialize(const int* serializer, const CommInterface& comm_interface);
00052     int getNbComponents() const { return _nb_components; }
00053   private:
00054     //Processor group
00055     const ProcessorGroup* _proc_group;
00056     //nb of elements
00057     int _nb_elems;
00058     //nb of components
00059     int _nb_components;
00060     //mapping local to global
00061     int* _loc2glob;
00062     //mapping global to local
00063     INTERP_KERNEL::HashMap<int,int> _glob2loc;
00064   };
00065 
00067   inline int ExplicitTopology::globalToLocal(const int global) const
00068   {
00069     return (_glob2loc.find(global))->second;;
00070   }
00071 
00073   int ExplicitTopology::localToGlobal(int local) const
00074   {
00075     return _loc2glob[local];
00076   }
00077   
00079   inline int ExplicitTopology::getNbElements() const
00080   {
00081     return _nb_elems;
00082   }
00083 
00084   //Retrieves the local number of elements 
00085   inline int ExplicitTopology::getNbLocalElements()const 
00086   {
00087     return _glob2loc.size();
00088   }
00089 }
00090 
00091 
00092 #endif