Back to index

salome-med  6.5.0
MEDPARTITIONER_ConnectZone.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 "MEDPARTITIONER_ConnectZone.hxx"
00021 
00022 #include <map>
00023 
00024 MEDPARTITIONER::ConnectZone::ConnectZone():
00025   _name("")
00026   ,_description("")
00027   ,_local_domain_number(0)
00028   ,_distant_domain_number(0)
00029   ,_node_corresp(0)
00030   ,_face_corresp(0)
00031 {
00032 }
00033 
00034 MEDPARTITIONER::ConnectZone::~ConnectZone()
00035 {
00036   delete _node_corresp;
00037   delete _face_corresp;
00038   for(std::map < std::pair <int, int>,SkyLineArray * >::iterator iter=_entity_corresp.begin(); iter!=_entity_corresp.end();iter++)
00039     {
00040       delete iter->second;
00041     }
00042 }
00043 
00044 MEDPARTITIONER::ConnectZone::ConnectZone(const ConnectZone & myConnectZone):
00045   _name(myConnectZone._name)
00046   ,_description(myConnectZone._description)
00047   ,_local_domain_number(myConnectZone._local_domain_number)
00048   ,_distant_domain_number(myConnectZone._distant_domain_number)
00049   ,_node_corresp(myConnectZone._node_corresp)
00050   ,_face_corresp(myConnectZone._face_corresp)
00051   ,_entity_corresp(myConnectZone._entity_corresp)
00052 {
00053 }
00054 
00055 std::string MEDPARTITIONER::ConnectZone::getName() const 
00056 {
00057   return _name;
00058 }
00059 
00060 std::string MEDPARTITIONER::ConnectZone::getDescription() const     
00061 {
00062   return _description;
00063 }
00064 
00065 int MEDPARTITIONER::ConnectZone::getDistantDomainNumber() const 
00066 {
00067   return _distant_domain_number;
00068 }
00069 
00070 int MEDPARTITIONER::ConnectZone::getLocalDomainNumber() const 
00071 {
00072   return _local_domain_number;
00073 }
00074 
00075 ParaMEDMEM::MEDCouplingUMesh *MEDPARTITIONER::ConnectZone::getLocalMesh() const 
00076 {
00077   return _local_mesh;
00078 }
00079 
00080 ParaMEDMEM::MEDCouplingUMesh *MEDPARTITIONER::ConnectZone::getDistantMesh() const 
00081 {
00082   return _distant_mesh;
00083 }
00084 
00085 bool MEDPARTITIONER::ConnectZone::isEntityCorrespPresent(int localEntity, int distantEntity) const
00086 {
00087   typedef std::map<std::pair<int,int>, SkyLineArray*>::const_iterator map_iter;
00088   for(map_iter iter=_entity_corresp.begin(); iter != _entity_corresp.end(); iter++)
00089     {
00090       if ((iter->first).first==localEntity && (iter->first).second==distantEntity)
00091         return true;
00092     }
00093   return false;
00094 }
00095 
00096 const int *MEDPARTITIONER::ConnectZone::getNodeCorrespIndex() const
00097 {
00098   return _node_corresp->getIndex();
00099 }
00100 
00101 const int *MEDPARTITIONER::ConnectZone::getNodeCorrespValue() const
00102 {
00103   return _node_corresp->getValue();
00104 }
00105 
00106 int MEDPARTITIONER::ConnectZone::getNodeNumber() const
00107 {
00108   return _node_corresp->getNumberOf();
00109 }
00110 
00111 const int *MEDPARTITIONER::ConnectZone::getFaceCorrespIndex() const
00112 {
00113   return _face_corresp->getIndex();
00114 }
00115 
00116 const int *MEDPARTITIONER::ConnectZone::getFaceCorrespValue() const
00117 {
00118   return _face_corresp->getValue();
00119 }
00120 
00121 int MEDPARTITIONER::ConnectZone::getFaceNumber() const
00122 {
00123   return _face_corresp->getNumberOf();
00124 }
00125 
00126 const int *MEDPARTITIONER::ConnectZone::getEntityCorrespIndex(int localEntity,
00127                                                int distantEntity) const
00128 {
00129   typedef std::map<std::pair<int,int>, SkyLineArray*>::const_iterator map_iter;
00130 
00131   for(map_iter iter=_entity_corresp.begin();iter!=_entity_corresp.end();iter++)
00132     {
00133       if ((iter->first).first==localEntity && (iter->first).second==distantEntity)
00134         return iter->second->getIndex();
00135     }
00136   return 0;
00137 }
00138 
00139 const int *MEDPARTITIONER::ConnectZone::getEntityCorrespValue(int localEntity,
00140                                                int distantEntity) const
00141 {
00142   typedef std::map<std::pair<int,int>, SkyLineArray*>::const_iterator map_iter;
00143 
00144   for (map_iter iter=_entity_corresp.begin();iter!=_entity_corresp.end();iter++)
00145     {
00146       if ((iter->first).first==localEntity && (iter->first).second==distantEntity)
00147         return iter->second->getValue();
00148     }
00149   return 0;
00150 }
00151 
00152 int MEDPARTITIONER::ConnectZone::getEntityCorrespNumber(int localEntity,
00153                                         int distantEntity) const
00154 {
00155   typedef std::map<std::pair<int,int>, SkyLineArray*>::const_iterator map_iter;
00156 
00157   for(map_iter iter=_entity_corresp.begin();iter!=_entity_corresp.end();iter++)
00158     {
00159       if((iter->first).first==localEntity && (iter->first).second==distantEntity)
00160         return iter->second->getNumberOf();
00161     }
00162   return 0;
00163 }
00164 
00165 int MEDPARTITIONER::ConnectZone::getEntityCorrespLength(int localEntity,
00166                                         int distantEntity) const
00167 {
00168   typedef std::map<std::pair<int,int>, SkyLineArray*>::const_iterator map_iter;
00169   
00170   for (map_iter iter=_entity_corresp.begin(); iter != _entity_corresp.end(); iter++)
00171     {
00172       if ((iter->first).first==localEntity && (iter->first).second==distantEntity)
00173         return iter->second->getLength();
00174     }
00175   return 0;
00176 }
00177 
00178 void MEDPARTITIONER::ConnectZone::setName(const std::string& name) 
00179 {
00180   _name=name;
00181 }
00182 
00183 void MEDPARTITIONER::ConnectZone::setDescription(const std::string& description)
00184 {
00185   _description=description;
00186 }
00187 
00188 void MEDPARTITIONER::ConnectZone::setDistantDomainNumber(int distantDomainNumber)
00189 {
00190   _distant_domain_number=distantDomainNumber;
00191 }
00192 
00193 void MEDPARTITIONER::ConnectZone::setLocalDomainNumber(int localDomainNumber)
00194 {
00195   _local_domain_number=localDomainNumber;
00196 }
00197 
00198 void MEDPARTITIONER::ConnectZone::setLocalMesh(ParaMEDMEM::MEDCouplingUMesh * localMesh)
00199 {
00200   _local_mesh=localMesh;
00201 }
00202 
00203 void MEDPARTITIONER::ConnectZone::setDistantMesh(ParaMEDMEM::MEDCouplingUMesh * distantMesh)
00204 {
00205   _distant_mesh=distantMesh;
00206 }
00207 
00212 void MEDPARTITIONER::ConnectZone::setNodeCorresp(int * nodeCorresp, int nbnode)
00213 {
00214   std::vector<int> index(nbnode+1),value(2*nbnode);
00215   for (int i=0; i<nbnode; i++)
00216     {
00217       index[i]=2*i;
00218       value[2*i]=nodeCorresp[2*i];
00219       value[2*i+1]=nodeCorresp[2*i+1];
00220     }
00221   index[nbnode]=2*nbnode;
00222   _node_corresp = new SkyLineArray(index,value);
00223 }
00224 
00225 void MEDPARTITIONER::ConnectZone::setNodeCorresp(SkyLineArray* array)
00226 {
00227   _node_corresp = array;
00228 }
00229 
00234 void MEDPARTITIONER::ConnectZone::setFaceCorresp(int * faceCorresp, int nbface)
00235 {
00236   std::vector<int> index(nbface+1),value(2*nbface);
00237   for (int i=0; i<nbface; i++)
00238     {
00239       index[i]=2*i;
00240       value[2*i]=faceCorresp[2*i];
00241       value[2*i+1]=faceCorresp[2*i+1];
00242     }
00243   index[nbface]=2*nbface;
00244   _face_corresp = new MEDPARTITIONER::SkyLineArray(index,value);
00245 }
00246 
00247 void MEDPARTITIONER::ConnectZone::setFaceCorresp(SkyLineArray* array)
00248 {
00249   _face_corresp = array;
00250 }
00251 
00258 void MEDPARTITIONER::ConnectZone::setEntityCorresp(int localEntity, int distantEntity,
00259                                                    int *entityCorresp, int nbentity)
00260 { 
00261   std::vector<int> index(nbentity+1),value(2*nbentity);
00262   for (int i=0; i<nbentity; i++)
00263     {
00264       index[i]=2*i;
00265       value[2*i]=entityCorresp[2*i];
00266       value[2*i+1]=entityCorresp[2*i+1];
00267     }
00268   index[nbentity]=2*nbentity;
00269   _entity_corresp[std::make_pair(localEntity,distantEntity)] = new SkyLineArray(index,value);
00270 }
00271 
00272 void MEDPARTITIONER::ConnectZone::setEntityCorresp(int localEntity, int distantEntity,
00273                                                    SkyLineArray *array)
00274 {
00275   _entity_corresp[std::make_pair(localEntity,distantEntity)]=array;
00276 }
00277 
00278 
00279 
00280 
00281 
00282 
00283