Salome HOME
Merge branch 'master' of https://codev-tuleap.cea.fr/plugins/git/salome/medcoupling
[tools/medcoupling.git] / src / MEDLoader / MEDFileFieldGlobs.cxx
1 // Copyright (C) 2007-2019  CEA/DEN, EDF R&D
2 //
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, or (at your option) any later version.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // Author : Anthony Geay (EDF R&D)
20
21 #include "MEDFileFieldGlobs.hxx"
22 #include "MEDFileField.txx"
23 #include "MEDFileMesh.hxx"
24 #include "MEDLoaderBase.hxx"
25 #include "MEDLoaderTraits.hxx"
26 #include "MEDFileSafeCaller.txx"
27 #include "MEDFileFieldOverView.hxx"
28 #include "MEDFileBlowStrEltUp.hxx"
29 #include "MEDFileFieldVisitor.hxx"
30
31 #include "MEDCouplingFieldDiscretization.hxx"
32 #include "MCType.hxx"
33
34 #include "InterpKernelAutoPtr.hxx"
35 #include "CellModel.hxx"
36
37 #include <algorithm>
38 #include <iterator>
39
40 using namespace MEDCoupling;
41
42 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
43 {
44   if(id>=(int)_pfls.size())
45     _pfls.resize(id+1);
46   _pfls[id]=DataArrayInt::New();
47   int lgth(MEDprofileSizeByName(fid,pflName.c_str()));
48   _pfls[id]->setName(pflName);
49   _pfls[id]->alloc(lgth,1);
50   MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName.c_str(),_pfls[id]->getPointer()));
51   _pfls[id]->applyLin(1,-1,0);//Converting into C format
52 }
53
54 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
55 {
56   INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
57   int sz;
58   MEDFILESAFECALLERRD0(MEDprofileInfo,(fid,i+1,pflName,&sz));
59   std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
60   if(i>=(int)_pfls.size())
61     _pfls.resize(i+1);
62   _pfls[i]=DataArrayInt::New();
63   _pfls[i]->alloc(sz,1);
64   _pfls[i]->setName(pflCpp.c_str());
65   MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName,_pfls[i]->getPointer()));
66   _pfls[i]->applyLin(1,-1,0);//Converting into C format
67 }
68
69 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
70 {
71   int nbOfPfls=_pfls.size();
72   for(int i=0;i<nbOfPfls;i++)
73     {
74       MCAuto<DataArrayInt> cpy=_pfls[i]->deepCopy();
75       cpy->applyLin(1,1,0);
76       INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
77       MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
78       MEDFILESAFECALLERWR0(MEDprofileWr,(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer()));
79     }
80   //
81   int nbOfLocs=_locs.size();
82   for(int i=0;i<nbOfLocs;i++)
83     _locs[i]->writeLL(fid);
84 }
85
86 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps)
87 {
88   std::vector<std::string> pfls=getPfls();
89   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
90     {
91       std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
92       if(it2==pfls.end())
93         {
94           _pfls.push_back(*it);
95         }
96       else
97         {
98           int id=std::distance(pfls.begin(),it2);
99           if(!(*it)->isEqual(*_pfls[id]))
100             {
101               std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
102               throw INTERP_KERNEL::Exception(oss.str());
103             }
104         }
105     }
106   std::vector<std::string> locs=getLocs();
107   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=other._locs.begin();it!=other._locs.end();it++)
108     {
109       std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
110       if(it2==locs.end())
111         {
112           _locs.push_back(*it);
113         }
114       else
115         {
116           int id=std::distance(locs.begin(),it2);
117           if(!(*it)->isEqual(*_locs[id],eps))
118             {
119               std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
120               throw INTERP_KERNEL::Exception(oss.str());
121             }
122         }
123     }
124 }
125
126 void MEDFileFieldGlobs::checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const
127 {
128   for(std::vector<std::string>::const_iterator it=pflsUsed.begin();it!=pflsUsed.end();it++)
129     getProfile((*it).c_str());
130 }
131
132 void MEDFileFieldGlobs::checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const
133 {
134   for(std::vector<std::string>::const_iterator it=locsUsed.begin();it!=locsUsed.end();it++)
135     getLocalization((*it).c_str());
136 }
137
138 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real)
139 {
140   std::vector<std::string> profiles=real.getPflsReallyUsed();
141   int sz=profiles.size();
142   _pfls.resize(sz);
143   for(int i=0;i<sz;i++)
144     loadProfileInFile(fid,i,profiles[i].c_str());
145   //
146   std::vector<std::string> locs=real.getLocsReallyUsed();
147   sz=locs.size();
148   _locs.resize(sz);
149   for(int i=0;i<sz;i++)
150     _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
151 }
152
153 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid, const MEDFileEntities *entities)
154 {
155   int nProfil=MEDnProfile(fid);
156   for(int i=0;i<nProfil;i++)
157     loadProfileInFile(fid,i);
158   int sz=MEDnLocalization(fid);
159   _locs.resize(sz);
160   for(int i=0;i<sz;i++)
161     {
162       _locs[i]=MEDFileFieldLoc::New(fid,i,entities);
163     }
164 }
165
166 MEDFileFieldGlobs *MEDFileFieldGlobs::New(med_idt fid)
167 {
168   return new MEDFileFieldGlobs(fid);
169 }
170
171 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
172 {
173   return new MEDFileFieldGlobs;
174 }
175
176 std::size_t MEDFileFieldGlobs::getHeapMemorySizeWithoutChildren() const
177 {
178   return _file_name.capacity()+_pfls.capacity()*sizeof(MCAuto<DataArrayInt>)+_locs.capacity()*sizeof(MCAuto<MEDFileFieldLoc>);
179 }
180
181 std::vector<const BigMemoryObject *> MEDFileFieldGlobs::getDirectChildrenWithNull() const
182 {
183   std::vector<const BigMemoryObject *> ret;
184   for(std::vector< MCAuto< DataArrayInt > >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
185     ret.push_back((const DataArrayInt *)*it);
186   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
187     ret.push_back((const MEDFileFieldLoc *)*it);
188   return ret;
189 }
190
191 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCopy() const
192 {
193   MCAuto<MEDFileFieldGlobs> ret=new MEDFileFieldGlobs(*this);
194   std::size_t i=0;
195   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
196     {
197       if((const DataArrayInt *)*it)
198         ret->_pfls[i]=(*it)->deepCopy();
199     }
200   i=0;
201   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
202     {
203       if((const MEDFileFieldLoc*)*it)
204         ret->_locs[i]=(*it)->deepCopy();
205     }
206   return ret.retn();
207 }
208
209 /*!
210  * \throw if a profile in \a pfls in not in \a this.
211  * \throw if a localization in \a locs in not in \a this.
212  * \sa MEDFileFieldGlobs::deepCpyPart
213  */
214 MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
215 {
216   MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
217   for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
218     {
219       DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
220       if(!pfl)
221         throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! pfl null !");
222       pfl->incrRef();
223       MCAuto<DataArrayInt> pfl2(pfl);
224       ret->_pfls.push_back(pfl2);
225     }
226   for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
227     {
228       MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
229       if(!loc)
230         throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! loc null !");
231       loc->incrRef();
232       MCAuto<MEDFileFieldLoc> loc2(loc);
233       ret->_locs.push_back(loc2);
234     }
235   ret->setFileName(getFileName());
236   return ret.retn();
237 }
238
239 /*!
240  * \throw if a profile in \a pfls in not in \a this.
241  * \throw if a localization in \a locs in not in \a this.
242  * \sa MEDFileFieldGlobs::shallowCpyPart
243  */
244 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
245 {
246   MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
247   for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
248     {
249       DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
250       if(!pfl)
251         throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! pfl null !");
252       ret->_pfls.push_back(pfl->deepCopy());
253     }
254   for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
255     {
256       MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
257       if(!loc)
258         throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! loc null !");
259       ret->_locs.push_back(loc->deepCopy());
260     }
261   ret->setFileName(getFileName());
262   return ret.retn();
263 }
264
265 MEDFileFieldGlobs::MEDFileFieldGlobs(med_idt fid):_file_name(MEDFileWritable::FileNameFromFID(fid))
266 {
267 }
268
269 MEDFileFieldGlobs::MEDFileFieldGlobs()
270 {
271 }
272
273 MEDFileFieldGlobs::~MEDFileFieldGlobs()
274 {
275 }
276
277 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
278 {
279   oss << "Profiles :\n";
280   std::size_t n=_pfls.size();
281   for(std::size_t i=0;i<n;i++)
282     {
283       oss << "  - #" << i << " ";
284       const DataArrayInt *pfl=_pfls[i];
285       if(pfl)
286         oss << "\"" << pfl->getName() << "\"\n";
287       else
288         oss << "EMPTY !\n";
289     }
290   n=_locs.size();
291   oss << "Localizations :\n";
292   for(std::size_t i=0;i<n;i++)
293     {
294       oss << "  - #" << i << " ";
295       const MEDFileFieldLoc *loc=_locs[i];
296       if(loc)
297         loc->simpleRepr(oss);
298       else
299         oss<< "EMPTY !\n";
300     }
301 }
302
303 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
304 {
305   for(std::vector< MCAuto<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
306     {
307       DataArrayInt *elt(*it);
308       if(elt)
309         {
310           std::string name(elt->getName());
311           for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
312             {
313               if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
314                 {
315                   elt->setName((*it2).second.c_str());
316                   return;
317                 }
318             }
319         }
320     }
321 }
322
323 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
324 {
325   for(std::vector< MCAuto<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
326     {
327       MEDFileFieldLoc *elt(*it);
328       if(elt)
329         {
330           std::string name(elt->getName());
331           for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
332             {
333               if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
334                 {
335                   elt->setName((*it2).second.c_str());
336                   return;
337                 }
338             }
339         }
340     }
341 }
342
343 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const
344 {
345   if(locId<0 || locId>=(int)_locs.size())
346     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
347   return _locs[locId]->getNbOfGaussPtPerCell();
348 }
349
350 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName) const
351 {
352   return getLocalizationFromId(getLocalizationId(locName));
353 }
354
355 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const
356 {
357   if(locId<0 || locId>=(int)_locs.size())
358     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
359   return *_locs[locId];
360 }
361
362 /// @cond INTERNAL
363 namespace MEDCouplingImpl
364 {
365   class LocFinder
366   {
367   public:
368     LocFinder(const std::string& loc):_loc(loc) { }
369     bool operator() (const MCAuto<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
370   private:
371     const std::string &_loc;
372   };
373
374   class PflFinder
375   {
376   public:
377     PflFinder(const std::string& pfl):_pfl(pfl) { }
378     bool operator() (const MCAuto<DataArrayInt>& loc) { return loc->getName()==_pfl; }
379   private:
380     const std::string _pfl;
381   };
382 }
383 /// @endcond
384
385 int MEDFileFieldGlobs::getLocalizationId(const std::string& loc) const
386 {
387   std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),MEDCouplingImpl::LocFinder(loc));
388   if(it==_locs.end())
389     {
390       std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
391       for(it=_locs.begin();it!=_locs.end();it++)
392         oss << "\"" << (*it)->getName() << "\", ";
393       throw INTERP_KERNEL::Exception(oss.str());
394     }
395   return std::distance(_locs.begin(),it);
396 }
397
398 int MEDFileFieldGlobs::getProfileId(const std::string& pfl) const
399 {
400   std::vector< MCAuto<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pfl));
401   if(it==_pfls.end())
402     {
403       std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfileId : no such profile name : \"" << pfl << "\" Possible localizations are : ";
404       for(it=_pfls.begin();it!=_pfls.end();it++)
405         oss << "\"" << (*it)->getName() << "\", ";
406       throw INTERP_KERNEL::Exception(oss.str());
407     }
408   return std::distance(_pfls.begin(),it);
409 }
410
411 /*!
412  * The returned value is never null.
413  */
414 const DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName) const
415 {
416   return getProfileFromId(getProfileId(pflName));
417 }
418
419 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const
420 {
421   if(pflId<0 || pflId>=(int)_pfls.size())
422     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
423   return _pfls[pflId];
424 }
425
426 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId)
427 {
428   if(locId<0 || locId>=(int)_locs.size())
429     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
430   return *_locs[locId];
431 }
432
433 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName)
434 {
435   return getLocalizationFromId(getLocalizationId(locName));
436 }
437
438 /*!
439  * The returned value is never null. Borrowed reference returned.
440  */
441 DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName)
442 {
443   std::string pflNameCpp(pflName);
444   std::vector< MCAuto<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
445   if(it==_pfls.end())
446     {
447       std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
448       for(it=_pfls.begin();it!=_pfls.end();it++)
449         oss << "\"" << (*it)->getName() << "\", ";
450       throw INTERP_KERNEL::Exception(oss.str());
451     }
452   return *it;
453 }
454
455 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId)
456 {
457   if(pflId<0 || pflId>=(int)_pfls.size())
458     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
459   return _pfls[pflId];
460 }
461
462 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds)
463 {
464   std::vector< MCAuto<DataArrayInt> > newPfls;
465   int i=0;
466   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
467     {
468       if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
469         newPfls.push_back(*it);
470     }
471   _pfls=newPfls;
472 }
473
474 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds)
475 {
476   std::vector< MCAuto<MEDFileFieldLoc> > newLocs;
477   int i=0;
478   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
479     {
480       if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
481         newLocs.push_back(*it);
482     }
483   _locs=newLocs;
484 }
485
486 void MEDFileFieldGlobs::killStructureElementsInGlobs()
487 {
488   std::vector< MCAuto<MEDFileFieldLoc> > newLocs;
489   for(std::vector< MCAuto<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
490     {
491       if((*it).isNull())
492         continue;
493       if(!(*it)->isOnStructureElement())
494         newLocs.push_back(*it);
495     }
496   _locs=newLocs;
497 }
498
499 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
500 {
501   int sz=_pfls.size();
502   std::vector<std::string> ret(sz);
503   for(int i=0;i<sz;i++)
504     ret[i]=_pfls[i]->getName();
505   return ret;
506 }
507
508 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
509 {
510   int sz=_locs.size();
511   std::vector<std::string> ret(sz);
512   for(int i=0;i<sz;i++)
513     ret[i]=_locs[i]->getName();
514   return ret;
515 }
516
517 bool MEDFileFieldGlobs::existsPfl(const std::string& pflName) const
518 {
519   std::vector<std::string> v=getPfls();
520   std::string s(pflName);
521   return std::find(v.begin(),v.end(),s)!=v.end();
522 }
523
524 bool MEDFileFieldGlobs::existsLoc(const std::string& locName) const
525 {
526   std::vector<std::string> v=getLocs();
527   std::string s(locName);
528   return std::find(v.begin(),v.end(),s)!=v.end();
529 }
530
531 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
532 {
533   std::map<int,std::vector<int> > m;
534   int i=0;
535   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
536     {
537       const DataArrayInt *tmp=(*it);
538       if(tmp)
539         {
540           m[tmp->getHashCode()].push_back(i);
541         }
542     }
543   std::vector< std::vector<int> > ret;
544   for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
545     {
546       if((*it2).second.size()>1)
547         {
548           std::vector<int> ret0;
549           bool equalityOrNot=false;
550           for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
551             {
552               std::vector<int>::const_iterator it4=it3; it4++;
553               for(;it4!=(*it2).second.end();it4++)
554                 {
555                   if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
556                     {
557                       if(!equalityOrNot)
558                         ret0.push_back(*it3);
559                       ret0.push_back(*it4);
560                       equalityOrNot=true;
561                     }
562                 }
563             }
564           if(!ret0.empty())
565             ret.push_back(ret0);
566         }
567     }
568   return ret;
569 }
570
571 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
572 {
573   throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
574 }
575
576 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl)
577 {
578   std::string name(pfl->getName());
579   if(name.empty())
580     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
581   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
582     if(name==(*it)->getName())
583       {
584         if(!pfl->isEqual(*(*it)))
585           {
586             std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
587             throw INTERP_KERNEL::Exception(oss.str());
588           }
589       }
590   pfl->incrRef();
591   _pfls.push_back(pfl);
592 }
593
594 void MEDFileFieldGlobs::appendLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w)
595 {
596   std::string name(locName);
597   if(name.empty())
598     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
599   MCAuto<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
600   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
601     if((*it)->isName(locName))
602       {
603         if(!(*it)->isEqual(*obj,1e-12))
604           {
605             std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
606             throw INTERP_KERNEL::Exception(oss.str());
607           }
608       }
609   _locs.push_back(obj);
610 }
611
612 std::string MEDFileFieldGlobs::createNewNameOfPfl() const
613 {
614   std::vector<std::string> names=getPfls();
615   return CreateNewNameNotIn("NewPfl_",names);
616 }
617
618 std::string MEDFileFieldGlobs::createNewNameOfLoc() const
619 {
620   std::vector<std::string> names=getLocs();
621   return CreateNewNameNotIn("NewLoc_",names);
622 }
623
624 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const std::string& prefix, const std::vector<std::string>& namesToAvoid)
625 {
626   for(std::size_t sz=0;sz<100000;sz++)
627     {
628       std::ostringstream tryName;
629       tryName << prefix << sz;
630       if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
631         return tryName.str();
632     }
633   throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
634 }
635
636 /*!
637  * Creates a MEDFileFieldGlobsReal on a given file name. Nothing is read here.
638  *  \param [in] fname - the file name.
639  */
640 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(med_idt fid):_globals(MEDFileFieldGlobs::New(fid))
641 {
642 }
643
644 /*!
645  * Creates an empty MEDFileFieldGlobsReal.
646  */
647 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
648 {
649 }
650
651 std::size_t MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren() const
652 {
653   return 0;
654 }
655
656 std::vector<const BigMemoryObject *> MEDFileFieldGlobsReal::getDirectChildrenWithNull() const
657 {
658   std::vector<const BigMemoryObject *> ret;
659   ret.push_back((const MEDFileFieldGlobs *)_globals);
660   return ret;
661 }
662
663 /*!
664  * Returns a string describing profiles and Gauss points held in \a this.
665  *  \return std::string - the description string.
666  */
667 void MEDFileFieldGlobsReal::simpleReprGlobs(std::ostream& oss) const
668 {
669   const MEDFileFieldGlobs *glob=_globals;
670   std::ostringstream oss2; oss2 << glob;
671   std::string stars(oss2.str().length(),'*');
672   oss << "Globals information on fields (at " << oss2.str() << "):" << "\n************************************" << stars  << "\n\n";
673   if(glob)
674     glob->simpleRepr(oss);
675   else
676     oss << "NO GLOBAL INFORMATION !\n";
677 }
678
679 void MEDFileFieldGlobsReal::resetContent()
680 {
681   _globals=MEDFileFieldGlobs::New();
682 }
683
684 void MEDFileFieldGlobsReal::killStructureElementsInGlobs()
685 {
686   contentNotNull()->killStructureElementsInGlobs();
687 }
688
689 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
690 {
691 }
692
693 /*!
694  * Copies references to profiles and Gauss points from another MEDFileFieldGlobsReal.
695  *  \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
696  */
697 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
698 {
699   _globals=other._globals;
700 }
701
702 /*!
703  * Copies references to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
704  *  \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
705  */
706 void MEDFileFieldGlobsReal::shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
707 {
708   const MEDFileFieldGlobs *otherg(other._globals);
709   if(!otherg)
710     return ;
711   _globals=otherg->shallowCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
712 }
713
714 /*!
715  * Copies deeply to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
716  *  \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
717  */
718 void MEDFileFieldGlobsReal::deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
719 {
720   const MEDFileFieldGlobs *otherg(other._globals);
721   if(!otherg)
722     return ;
723   _globals=otherg->deepCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
724 }
725
726 void MEDFileFieldGlobsReal::deepCpyGlobs(const MEDFileFieldGlobsReal& other)
727 {
728   _globals=other._globals;
729   if((const MEDFileFieldGlobs *)_globals)
730     _globals=other._globals->deepCopy();
731 }
732
733 /*!
734  * Adds profiles and Gauss points held by another MEDFileFieldGlobsReal to \a this one.
735  *  \param [in] other - the MEDFileFieldGlobsReal to copy data from.
736  *  \param [in] eps - a precision used to compare Gauss points with same name held by
737  *         \a this and \a other MEDFileFieldGlobsReal.
738  *  \throw If \a this and \a other hold profiles with equal names but different ids.
739  *  \throw If  \a this and \a other hold different Gauss points with equal names.
740  */
741 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps)
742 {
743   const MEDFileFieldGlobs *thisGlobals(_globals),*otherGlobals(other._globals);
744   if(thisGlobals==otherGlobals)
745     return ;
746   if(!thisGlobals)
747     {
748       _globals=other._globals;
749       return ;
750     }
751   _globals->appendGlobs(*other._globals,eps);
752 }
753
754 void MEDFileFieldGlobsReal::checkGlobsCoherency() const
755 {
756   checkGlobsPflsPartCoherency();
757   checkGlobsLocsPartCoherency();
758 }
759
760 void MEDFileFieldGlobsReal::checkGlobsPflsPartCoherency() const
761 {
762   contentNotNull()->checkGlobsPflsPartCoherency(getPflsReallyUsed());
763 }
764
765 void MEDFileFieldGlobsReal::checkGlobsLocsPartCoherency() const
766 {
767   contentNotNull()->checkGlobsLocsPartCoherency(getLocsReallyUsed());
768 }
769
770 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
771 {
772   contentNotNull()->loadProfileInFile(fid,id,pflName);
773 }
774
775 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
776 {
777   contentNotNull()->loadProfileInFile(fid,id);
778 }
779
780 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid)
781 {
782   contentNotNull()->loadGlobals(fid,*this);
783 }
784
785 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid, const MEDFileEntities *entities)
786 {
787   contentNotNull()->loadAllGlobals(fid,entities);
788 }
789
790 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
791 {
792   contentNotNull()->writeGlobals(fid,opt);
793 }
794
795 /*!
796  * Returns names of all profiles. To get only used profiles call getPflsReallyUsed()
797  * or getPflsReallyUsedMulti().
798  *  \return std::vector<std::string> - a sequence of names of all profiles.
799  */
800 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
801 {
802   return contentNotNull()->getPfls();
803 }
804
805 /*!
806  * Returns names of all localizations. To get only used localizations call getLocsReallyUsed()
807  * or getLocsReallyUsedMulti().
808  *  \return std::vector<std::string> - a sequence of names of all localizations.
809  */
810 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
811 {
812   return contentNotNull()->getLocs();
813 }
814
815 /*!
816  * Checks if the profile with a given name exists.
817  *  \param [in] pflName - the profile name of interest.
818  *  \return bool - \c true if the profile named \a pflName exists.
819  */
820 bool MEDFileFieldGlobsReal::existsPfl(const std::string& pflName) const
821 {
822   return contentNotNull()->existsPfl(pflName);
823 }
824
825 /*!
826  * Checks if the localization with a given name exists.
827  *  \param [in] locName - the localization name of interest.
828  *  \return bool - \c true if the localization named \a locName exists.
829  */
830 bool MEDFileFieldGlobsReal::existsLoc(const std::string& locName) const
831 {
832   return contentNotNull()->existsLoc(locName);
833 }
834
835 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const
836 {
837   return contentNotNull()->createNewNameOfPfl();
838 }
839
840 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const
841 {
842   return contentNotNull()->createNewNameOfLoc();
843 }
844
845 /*!
846  * Sets the name of a MED file.
847  *  \param [inout] fileName - the file name.
848  */
849 void MEDFileFieldGlobsReal::setFileName(const std::string& fileName)
850 {
851   contentNotNull()->setFileName(fileName);
852 }
853
854 /*!
855  * Finds equal profiles. Two profiles are considered equal if they contain the same ids
856  * in the same order.
857  *  \return std::vector< std::vector<int> > - a sequence of groups of equal profiles.
858  *          Each item of this sequence is a vector containing ids of equal profiles.
859  */
860 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
861 {
862   return contentNotNull()->whichAreEqualProfiles();
863 }
864
865 /*!
866  * Finds equal localizations.
867  *  \param [in] eps - a precision used to compare real values of the localizations.
868  *  \return std::vector< std::vector<int> > - a sequence of groups of equal localizations.
869  *          Each item of this sequence is a vector containing ids of equal localizations.
870  */
871 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
872 {
873   return contentNotNull()->whichAreEqualLocs(eps);
874 }
875
876 /*!
877  * Renames the profiles. References to profiles (a reference is a profile name) are not changed.
878  * \param [in] mapOfModif - a sequence describing required renaming. Each element of
879  *        this sequence is a pair whose 
880  *        - the first item is a vector of profile names to replace by the second item,
881  *        - the second item is a profile name to replace every profile name of the first item.
882  */
883 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
884 {
885   contentNotNull()->changePflsNamesInStruct(mapOfModif);
886 }
887
888 /*!
889  * Renames the localizations. References to localizations (a reference is a localization name) are not changed.
890  * \param [in] mapOfModif - a sequence describing required renaming. Each element of
891  *        this sequence is a pair whose 
892  *        - the first item is a vector of localization names to replace by the second item,
893  *        - the second item is a localization name to replace every localization name of the first item.
894  */
895 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
896 {
897   contentNotNull()->changeLocsNamesInStruct(mapOfModif);
898 }
899
900 /*!
901  * Replaces references to some profiles (a reference is a profile name) by references
902  * to other profiles and, contrary to changePflsRefsNamesGen(), renames the profiles
903  * them-selves accordingly. <br>
904  * This method is a generalization of changePflName().
905  * \param [in] mapOfModif - a sequence describing required replacements. Each element of
906  *        this sequence is a pair whose 
907  *        - the first item is a vector of profile names to replace by the second item,
908  *        - the second item is a profile name to replace every profile of the first item.
909  * \sa changePflsRefsNamesGen()
910  * \sa changePflName()
911  */
912 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
913 {
914   changePflsRefsNamesGen(mapOfModif);
915   changePflsNamesInStruct(mapOfModif);
916 }
917
918 /*!
919  * Replaces references to some localizations (a reference is a localization name) by references
920  * to other localizations and, contrary to changeLocsRefsNamesGen(), renames the localizations
921  * them-selves accordingly. <br>
922  * This method is a generalization of changeLocName().
923  * \param [in] mapOfModif - a sequence describing required replacements. Each element of
924  *        this sequence is a pair whose 
925  *        - the first item is a vector of localization names to replace by the second item,
926  *        - the second item is a localization name to replace every localization of the first item.
927  * \sa changeLocsRefsNamesGen()
928  * \sa changeLocName()
929  */
930 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
931 {
932   changeLocsRefsNamesGen(mapOfModif);
933   changeLocsNamesInStruct(mapOfModif);
934 }
935
936 /*!
937  * Renames the profile having a given name and updates references to this profile.
938  *  \param [in] oldName - the name of the profile to rename.
939  *  \param [in] newName - a new name of the profile.
940  * \sa changePflsNames().
941  */
942 void MEDFileFieldGlobsReal::changePflName(const std::string& oldName, const std::string& newName)
943 {
944   std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
945   std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
946   mapOfModif[0]=p;
947   changePflsNames(mapOfModif);
948 }
949
950 /*!
951  * Renames the localization having a given name and updates references to this localization.
952  *  \param [in] oldName - the name of the localization to rename.
953  *  \param [in] newName - a new name of the localization.
954  * \sa changeLocsNames().
955  */
956 void MEDFileFieldGlobsReal::changeLocName(const std::string& oldName, const std::string& newName)
957 {
958   std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
959   std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
960   mapOfModif[0]=p;
961   changeLocsNames(mapOfModif);
962 }
963
964 /*!
965  * Removes duplicated profiles. Returns a map used to update references to removed 
966  * profiles via changePflsRefsNamesGen().
967  * Equal profiles are found using whichAreEqualProfiles().
968  *  \return std::vector< std::pair<std::vector<std::string>, std::string > > - 
969  *          a sequence describing the performed replacements of profiles. Each element of
970  *          this sequence is a pair whose
971  *          - the first item is a vector of profile names replaced by the second item,
972  *          - the second item is a profile name replacing every profile of the first item.
973  */
974 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames()
975 {
976   std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
977   std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
978   int i=0;
979   for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
980     {
981       std::vector< std::string > tmp((*it).size());
982       int j=0;
983       for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
984         tmp[j]=std::string(getProfileFromId(*it2)->getName());
985       std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
986       ret[i]=p;
987       std::vector<int> tmp2((*it).begin()+1,(*it).end());
988       killProfileIds(tmp2);
989     }
990   changePflsRefsNamesGen(ret);
991   return ret;
992 }
993
994 /*!
995  * Removes duplicated localizations. Returns a map used to update references to removed 
996  * localizations via changeLocsRefsNamesGen().
997  * Equal localizations are found using whichAreEqualLocs().
998  *  \param [in] eps - a precision used to compare real values of the localizations.
999  *  \return std::vector< std::pair<std::vector<std::string>, std::string > > - 
1000  *          a sequence describing the performed replacements of localizations. Each element of
1001  *          this sequence is a pair whose
1002  *          - the first item is a vector of localization names replaced by the second item,
1003  *          - the second item is a localization name replacing every localization of the first item.
1004  */
1005 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps)
1006 {
1007   std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
1008   std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
1009   int i=0;
1010   for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
1011     {
1012       std::vector< std::string > tmp((*it).size());
1013       int j=0;
1014       for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
1015         tmp[j]=std::string(getLocalizationFromId(*it2).getName());
1016       std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
1017       ret[i]=p;
1018       std::vector<int> tmp2((*it).begin()+1,(*it).end());
1019       killLocalizationIds(tmp2);
1020     }
1021   changeLocsRefsNamesGen(ret);
1022   return ret;
1023 }
1024
1025 /*!
1026  * Returns number of Gauss points per cell in a given localization.
1027  *  \param [in] locId - an id of the localization of interest.
1028  *  \return int - the number of the Gauss points per cell.
1029  */
1030 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const
1031 {
1032   return contentNotNull()->getNbOfGaussPtPerCell(locId);
1033 }
1034
1035 /*!
1036  * Returns an id of a localization by its name.
1037  *  \param [in] loc - the localization name of interest.
1038  *  \return int - the id of the localization.
1039  *  \throw If there is no a localization named \a loc.
1040  */
1041 int MEDFileFieldGlobsReal::getLocalizationId(const std::string& loc) const
1042 {
1043   return contentNotNull()->getLocalizationId(loc);
1044 }
1045
1046 /*!
1047  * Returns an id of a profile by its name.
1048  *  \param [in] loc - the profile name of interest.
1049  *  \return int - the id of the profile.
1050  *  \throw If there is no a profile named \a loc.
1051  */
1052 int MEDFileFieldGlobsReal::getProfileId(const std::string& pfl) const
1053 {
1054   return contentNotNull()->getProfileId(pfl);
1055 }
1056
1057 /*!
1058  * Returns the name of the MED file.
1059  *  \return const std::string&  - the MED file name.
1060  */
1061 std::string MEDFileFieldGlobsReal::getFileName() const
1062 {
1063   return contentNotNull()->getFileName();
1064 }
1065
1066 /*!
1067  * Returns a localization object by its name.
1068  *  \param [in] locName - the name of the localization of interest.
1069  *  \return const MEDFileFieldLoc& - the localization object having the name \a locName.
1070  *  \throw If there is no a localization named \a locName.
1071  */
1072 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName) const
1073 {
1074   return contentNotNull()->getLocalization(locName);
1075 }
1076
1077 /*!
1078  * Returns a localization object by its id.
1079  *  \param [in] locId - the id of the localization of interest.
1080  *  \return const MEDFileFieldLoc& - the localization object having the id \a locId.
1081  *  \throw If there is no a localization with id \a locId.
1082  */
1083 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const
1084 {
1085   return contentNotNull()->getLocalizationFromId(locId);
1086 }
1087
1088 /*!
1089  * Returns a profile array by its name.
1090  *  \param [in] pflName - the name of the profile of interest.
1091  *  \return const DataArrayInt * - the profile array having the name \a pflName.
1092  *  \throw If there is no a profile named \a pflName.
1093  */
1094 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName) const
1095 {
1096   return contentNotNull()->getProfile(pflName);
1097 }
1098
1099 /*!
1100  * Returns a profile array by its id.
1101  *  \param [in] pflId - the id of the profile of interest.
1102  *  \return const DataArrayInt * - the profile array having the id \a pflId.
1103  *  \throw If there is no a profile with id \a pflId.
1104  */
1105 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const
1106 {
1107   return contentNotNull()->getProfileFromId(pflId);
1108 }
1109
1110 /*!
1111  * Returns a localization object, apt for modification, by its id.
1112  *  \param [in] locId - the id of the localization of interest.
1113  *  \return MEDFileFieldLoc& - a non-const reference to the localization object
1114  *          having the id \a locId.
1115  *  \throw If there is no a localization with id \a locId.
1116  */
1117 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId)
1118 {
1119   return contentNotNull()->getLocalizationFromId(locId);
1120 }
1121
1122 /*!
1123  * Returns a localization object, apt for modification, by its name.
1124  *  \param [in] locName - the name of the localization of interest.
1125  *  \return MEDFileFieldLoc& - a non-const reference to the localization object
1126  *          having the name \a locName.
1127  *  \throw If there is no a localization named \a locName.
1128  */
1129 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName)
1130 {
1131   return contentNotNull()->getLocalization(locName);
1132 }
1133
1134 /*!
1135  * Returns a profile array, apt for modification, by its name.
1136  *  \param [in] pflName - the name of the profile of interest.
1137  *  \return DataArrayInt * - Borrowed reference - a non-const pointer to the profile array having the name \a pflName.
1138  *  \throw If there is no a profile named \a pflName.
1139  */
1140 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName)
1141 {
1142   return contentNotNull()->getProfile(pflName);
1143 }
1144
1145 /*!
1146  * Returns a profile array, apt for modification, by its id.
1147  *  \param [in] pflId - the id of the profile of interest.
1148  *  \return DataArrayInt * - Borrowed reference - a non-const pointer to the profile array having the id \a pflId.
1149  *  \throw If there is no a profile with id \a pflId.
1150  */
1151 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId)
1152 {
1153   return contentNotNull()->getProfileFromId(pflId);
1154 }
1155
1156 /*!
1157  * Removes profiles given by their ids. No data is updated to track this removal.
1158  *  \param [in] pflIds - a sequence of ids of the profiles to remove.
1159  */
1160 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds)
1161 {
1162   contentNotNull()->killProfileIds(pflIds);
1163 }
1164
1165 /*!
1166  * Removes localizations given by their ids. No data is updated to track this removal.
1167  *  \param [in] locIds - a sequence of ids of the localizations to remove.
1168  */
1169 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds)
1170 {
1171   contentNotNull()->killLocalizationIds(locIds);
1172 }
1173
1174 /*!
1175  * Stores a profile array.
1176  *  \param [in] pfl - the profile array to store.
1177  *  \throw If the name of \a pfl is empty.
1178  *  \throw If a profile with the same name as that of \a pfl already exists but contains
1179  *         different ids.
1180  */
1181 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl)
1182 {
1183   contentNotNull()->appendProfile(pfl);
1184 }
1185
1186 /*!
1187  * Adds a new localization of Gauss points.
1188  *  \param [in] locName - the name of the new localization.
1189  *  \param [in] geoType - a geometrical type of the reference cell.
1190  *  \param [in] refCoo - coordinates of points of the reference cell. Size of this vector
1191  *         must be \c nbOfNodesPerCell * \c dimOfType.
1192  *  \param [in] gsCoo - coordinates of Gauss points on the reference cell. Size of this vector
1193  *         must be  _wg_.size() * \c dimOfType.
1194  *  \param [in] w - the weights of Gauss points.
1195  *  \throw If \a locName is empty.
1196  *  \throw If a localization with the name \a locName already exists but is
1197  *         different form the new one.
1198  */
1199 void MEDFileFieldGlobsReal::appendLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w)
1200 {
1201   contentNotNull()->appendLoc(locName,geoType,refCoo,gsCoo,w);
1202 }
1203
1204 MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull()
1205 {
1206   MEDFileFieldGlobs *g(_globals);
1207   if(!g)
1208     throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in not const !");
1209   return g;
1210 }
1211
1212 const MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() const
1213 {
1214   const MEDFileFieldGlobs *g(_globals);
1215   if(!g)
1216     throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in const !");
1217   return g;
1218 }
1219
1220 //= MEDFileFieldNameScope
1221
1222 MEDFileFieldNameScope::MEDFileFieldNameScope()
1223 {
1224 }
1225
1226 MEDFileFieldNameScope::MEDFileFieldNameScope(const std::string& fieldName, const std::string& meshName):_name(fieldName),_mesh_name(meshName)
1227 {
1228 }
1229
1230 /*!
1231  * Returns the name of \a this field.
1232  *  \return std::string - a string containing the field name.
1233  */
1234 std::string MEDFileFieldNameScope::getName() const
1235 {
1236   return _name;
1237 }
1238
1239 /*!
1240  * Sets name of \a this field
1241  *  \param [in] name - the new field name.
1242  */
1243 void MEDFileFieldNameScope::setName(const std::string& fieldName)
1244 {
1245   _name=fieldName;
1246 }
1247
1248 std::string MEDFileFieldNameScope::getDtUnit() const
1249 {
1250   return _dt_unit;
1251 }
1252
1253 void MEDFileFieldNameScope::setDtUnit(const std::string& dtUnit)
1254 {
1255   _dt_unit=dtUnit;
1256 }
1257
1258 void MEDFileFieldNameScope::copyNameScope(const MEDFileFieldNameScope& other)
1259 {
1260   _name=other._name;
1261   _mesh_name=other._mesh_name;
1262   _dt_unit=other._dt_unit;
1263 }
1264
1265 /*!
1266  * Returns the mesh name.
1267  *  \return std::string - a string holding the mesh name.
1268  *  \throw If \c _field_per_mesh.empty()
1269  */
1270 std::string MEDFileFieldNameScope::getMeshName() const
1271 {
1272   return _mesh_name;
1273 }
1274
1275 void MEDFileFieldNameScope::setMeshName(const std::string& meshName)
1276 {
1277   _mesh_name=meshName;
1278 }
1279