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