1 // Copyright (C) 2007-2013 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.
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 "MEDPARTITIONER_ConnectZone.hxx"
24 MEDPARTITIONER::ConnectZone::ConnectZone():
27 ,_local_domain_number(0)
28 ,_distant_domain_number(0)
34 MEDPARTITIONER::ConnectZone::~ConnectZone()
38 for(std::map < std::pair <int, int>,SkyLineArray * >::iterator iter=_entity_corresp.begin(); iter!=_entity_corresp.end();iter++)
44 MEDPARTITIONER::ConnectZone::ConnectZone(const ConnectZone & myConnectZone):
45 _name(myConnectZone._name)
46 ,_description(myConnectZone._description)
47 ,_local_domain_number(myConnectZone._local_domain_number)
48 ,_distant_domain_number(myConnectZone._distant_domain_number)
49 ,_node_corresp(myConnectZone._node_corresp)
50 ,_face_corresp(myConnectZone._face_corresp)
51 ,_entity_corresp(myConnectZone._entity_corresp)
55 std::string MEDPARTITIONER::ConnectZone::getName() const
60 std::string MEDPARTITIONER::ConnectZone::getDescription() const
65 int MEDPARTITIONER::ConnectZone::getDistantDomainNumber() const
67 return _distant_domain_number;
70 int MEDPARTITIONER::ConnectZone::getLocalDomainNumber() const
72 return _local_domain_number;
75 ParaMEDMEM::MEDCouplingUMesh *MEDPARTITIONER::ConnectZone::getLocalMesh() const
80 ParaMEDMEM::MEDCouplingUMesh *MEDPARTITIONER::ConnectZone::getDistantMesh() const
85 bool MEDPARTITIONER::ConnectZone::isEntityCorrespPresent(int localEntity, int distantEntity) const
87 typedef std::map<std::pair<int,int>, SkyLineArray*>::const_iterator map_iter;
88 for(map_iter iter=_entity_corresp.begin(); iter != _entity_corresp.end(); iter++)
90 if ((iter->first).first==localEntity && (iter->first).second==distantEntity)
96 const int *MEDPARTITIONER::ConnectZone::getNodeCorrespIndex() const
98 return _node_corresp->getIndex();
101 const int *MEDPARTITIONER::ConnectZone::getNodeCorrespValue() const
103 return _node_corresp->getValue();
106 int MEDPARTITIONER::ConnectZone::getNodeNumber() const
108 return _node_corresp->getNumberOf();
111 const int *MEDPARTITIONER::ConnectZone::getFaceCorrespIndex() const
113 return _face_corresp->getIndex();
116 const int *MEDPARTITIONER::ConnectZone::getFaceCorrespValue() const
118 return _face_corresp->getValue();
121 int MEDPARTITIONER::ConnectZone::getFaceNumber() const
123 return _face_corresp->getNumberOf();
126 const int *MEDPARTITIONER::ConnectZone::getEntityCorrespIndex(int localEntity,
127 int distantEntity) const
129 typedef std::map<std::pair<int,int>, SkyLineArray*>::const_iterator map_iter;
131 for(map_iter iter=_entity_corresp.begin();iter!=_entity_corresp.end();iter++)
133 if ((iter->first).first==localEntity && (iter->first).second==distantEntity)
134 return iter->second->getIndex();
139 const int *MEDPARTITIONER::ConnectZone::getEntityCorrespValue(int localEntity,
140 int distantEntity) const
142 typedef std::map<std::pair<int,int>, SkyLineArray*>::const_iterator map_iter;
144 for (map_iter iter=_entity_corresp.begin();iter!=_entity_corresp.end();iter++)
146 if ((iter->first).first==localEntity && (iter->first).second==distantEntity)
147 return iter->second->getValue();
152 int MEDPARTITIONER::ConnectZone::getEntityCorrespNumber(int localEntity,
153 int distantEntity) const
155 typedef std::map<std::pair<int,int>, SkyLineArray*>::const_iterator map_iter;
157 for(map_iter iter=_entity_corresp.begin();iter!=_entity_corresp.end();iter++)
159 if((iter->first).first==localEntity && (iter->first).second==distantEntity)
160 return iter->second->getNumberOf();
165 int MEDPARTITIONER::ConnectZone::getEntityCorrespLength(int localEntity,
166 int distantEntity) const
168 typedef std::map<std::pair<int,int>, SkyLineArray*>::const_iterator map_iter;
170 for (map_iter iter=_entity_corresp.begin(); iter != _entity_corresp.end(); iter++)
172 if ((iter->first).first==localEntity && (iter->first).second==distantEntity)
173 return iter->second->getLength();
178 void MEDPARTITIONER::ConnectZone::setName(const std::string& name)
183 void MEDPARTITIONER::ConnectZone::setDescription(const std::string& description)
185 _description=description;
188 void MEDPARTITIONER::ConnectZone::setDistantDomainNumber(int distantDomainNumber)
190 _distant_domain_number=distantDomainNumber;
193 void MEDPARTITIONER::ConnectZone::setLocalDomainNumber(int localDomainNumber)
195 _local_domain_number=localDomainNumber;
198 void MEDPARTITIONER::ConnectZone::setLocalMesh(ParaMEDMEM::MEDCouplingUMesh * localMesh)
200 _local_mesh=localMesh;
203 void MEDPARTITIONER::ConnectZone::setDistantMesh(ParaMEDMEM::MEDCouplingUMesh * distantMesh)
205 _distant_mesh=distantMesh;
208 /*! transforms an int array containing
209 * the node-node connections
212 void MEDPARTITIONER::ConnectZone::setNodeCorresp(int * nodeCorresp, int nbnode)
214 std::vector<int> index(nbnode+1),value(2*nbnode);
215 for (int i=0; i<nbnode; i++)
218 value[2*i]=nodeCorresp[2*i];
219 value[2*i+1]=nodeCorresp[2*i+1];
221 index[nbnode]=2*nbnode;
222 _node_corresp = new SkyLineArray(index,value);
225 void MEDPARTITIONER::ConnectZone::setNodeCorresp(SkyLineArray* array)
227 _node_corresp = array;
230 /*! transforms an int array containing
231 * the face-face connections
234 void MEDPARTITIONER::ConnectZone::setFaceCorresp(int * faceCorresp, int nbface)
236 std::vector<int> index(nbface+1),value(2*nbface);
237 for (int i=0; i<nbface; i++)
240 value[2*i]=faceCorresp[2*i];
241 value[2*i+1]=faceCorresp[2*i+1];
243 index[nbface]=2*nbface;
244 _face_corresp = new MEDPARTITIONER::SkyLineArray(index,value);
247 void MEDPARTITIONER::ConnectZone::setFaceCorresp(SkyLineArray* array)
249 _face_corresp = array;
252 /*! transforms an int array containing
253 * the entity-entity connections
256 * the resulting SkyLineArray is put in the map
258 void MEDPARTITIONER::ConnectZone::setEntityCorresp(int localEntity, int distantEntity,
259 int *entityCorresp, int nbentity)
261 std::vector<int> index(nbentity+1),value(2*nbentity);
262 for (int i=0; i<nbentity; i++)
265 value[2*i]=entityCorresp[2*i];
266 value[2*i+1]=entityCorresp[2*i+1];
268 index[nbentity]=2*nbentity;
269 _entity_corresp[std::make_pair(localEntity,distantEntity)] = new SkyLineArray(index,value);
272 void MEDPARTITIONER::ConnectZone::setEntityCorresp(int localEntity, int distantEntity,
275 _entity_corresp[std::make_pair(localEntity,distantEntity)]=array;