Back to index

salome-med  6.5.0
MEDCouplingFieldDouble.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 #include "MEDCouplingFieldDouble.hxx"
00021 #include "MEDCouplingFieldTemplate.hxx"
00022 #include "MEDCouplingUMesh.hxx"
00023 #include "MEDCouplingTimeDiscretization.hxx"
00024 #include "MEDCouplingFieldDiscretization.hxx"
00025 #include "MEDCouplingAutoRefCountObjectPtr.hxx"
00026 #include "MEDCouplingNatureOfField.hxx"
00027 
00028 #include <sstream>
00029 #include <limits>
00030 #include <algorithm>
00031 #include <functional>
00032 
00033 using namespace ParaMEDMEM;
00034 
00035 MEDCouplingFieldDouble *MEDCouplingFieldDouble::New(TypeOfField type, TypeOfTimeDiscretization td)
00036 {
00037   return new MEDCouplingFieldDouble(type,td);
00038 }
00039 
00040 MEDCouplingFieldDouble *MEDCouplingFieldDouble::New(const MEDCouplingFieldTemplate *ft, TypeOfTimeDiscretization td)
00041 {
00042   return new MEDCouplingFieldDouble(ft,td);
00043 }
00044 
00045 void MEDCouplingFieldDouble::setTimeUnit(const char *unit)
00046 {
00047   _time_discr->setTimeUnit(unit);
00048 }
00049 
00050 const char *MEDCouplingFieldDouble::getTimeUnit() const
00051 {
00052   return _time_discr->getTimeUnit();
00053 }
00054 
00070 MEDCouplingFieldDouble *MEDCouplingFieldDouble::clone(bool recDeepCpy) const
00071 {
00072   return new MEDCouplingFieldDouble(*this,recDeepCpy);
00073 }
00074 
00083 MEDCouplingFieldDouble *MEDCouplingFieldDouble::cloneWithMesh(bool recDeepCpy) const
00084 {
00085   MEDCouplingFieldDouble *ret=clone(recDeepCpy);
00086   if(_mesh)
00087     {
00088       MEDCouplingMesh *mCpy=_mesh->deepCpy();
00089       ret->setMesh(mCpy);
00090       mCpy->decrRef();
00091     }
00092   return ret;
00093 }
00094 
00101 MEDCouplingFieldDouble *MEDCouplingFieldDouble::deepCpy() const
00102 {
00103   return cloneWithMesh(true);
00104 }
00105 
00106 MEDCouplingFieldDouble *MEDCouplingFieldDouble::buildNewTimeReprFromThis(TypeOfTimeDiscretization td, bool deepCopy) const
00107 {
00108   MEDCouplingTimeDiscretization *tdo=_time_discr->buildNewTimeReprFromThis(td,deepCopy);
00109   MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(getNature(),tdo,_type->clone());
00110   ret->setMesh(getMesh());
00111   ret->setName(getName());
00112   ret->setDescription(getDescription());
00113   return ret;
00114 }
00115 
00119 void MEDCouplingFieldDouble::copyTinyStringsFrom(const MEDCouplingFieldDouble *other) throw(INTERP_KERNEL::Exception)
00120 {
00121   if(other)
00122     {
00123       setName(other->_name.c_str());
00124       setDescription(other->_desc.c_str());
00125       _time_discr->copyTinyStringsFrom(*other->_time_discr);
00126     }
00127 }
00128 
00133 void MEDCouplingFieldDouble::copyTinyAttrFrom(const MEDCouplingFieldDouble *other) throw(INTERP_KERNEL::Exception)
00134 {
00135   if(other)
00136     {
00137       _time_discr->copyTinyAttrFrom(*other->_time_discr);
00138     }
00139 }
00140 
00141 std::string MEDCouplingFieldDouble::simpleRepr() const
00142 {
00143   std::ostringstream ret;
00144   ret << "FieldDouble with name : \"" << getName() << "\"\n";
00145   ret << "Description of field is : \"" << getDescription() << "\"\n";
00146   ret << "FieldDouble space discretization is : " << _type->getStringRepr() << "\n";
00147   ret << "FieldDouble time discretization is : " << _time_discr->getStringRepr() << "\n";
00148   ret << "FieldDouble nature of field is : " << MEDCouplingNatureOfField::getRepr(_nature) << "\n";
00149   if(getArray())
00150     {
00151       int nbOfCompo=getArray()->getNumberOfComponents();
00152       ret << "FieldDouble default array has " << nbOfCompo << " components and " << getArray()->getNumberOfTuples() << " tuples.\n";
00153       ret << "FieldDouble default array has following info on components : ";
00154       for(int i=0;i<nbOfCompo;i++)
00155         ret << "\"" << getArray()->getInfoOnComponent(i) << "\" ";
00156       ret << "\n";
00157     }
00158   if(_mesh)
00159     ret << "Mesh support information :\n__________________________\n" << _mesh->simpleRepr();
00160   else
00161     ret << "Mesh support information : No mesh set !\n";
00162   return ret.str();
00163 }
00164 
00165 std::string MEDCouplingFieldDouble::advancedRepr() const
00166 {
00167   std::ostringstream ret;
00168   ret << "FieldDouble with name : \"" << getName() << "\"\n";
00169   ret << "Description of field is : \"" << getDescription() << "\"\n";
00170   ret << "FieldDouble space discretization is : " << _type->getStringRepr() << "\n";
00171   ret << "FieldDouble time discretization is : " << _time_discr->getStringRepr() << "\n";
00172   if(getArray())
00173     ret << "FieldDouble default array has " << getArray()->getNumberOfComponents() << " components and " << getArray()->getNumberOfTuples() << " tuples.\n";
00174   if(_mesh)
00175     ret << "Mesh support information :\n__________________________\n" << _mesh->simpleRepr();
00176   else
00177     ret << "Mesh support information : No mesh set !\n";
00178   std::vector<DataArrayDouble *> arrays;
00179   _time_discr->getArrays(arrays);
00180   int arrayId=0;
00181   for(std::vector<DataArrayDouble *>::const_iterator iter=arrays.begin();iter!=arrays.end();iter++,arrayId++)
00182     {
00183       ret << "Array #" << arrayId << " :\n__________\n";
00184       if(*iter)
00185         (*iter)->reprWithoutNameStream(ret);
00186       else
00187         ret << "Array empty !";
00188       ret << "\n";
00189     }
00190   return ret.str();
00191 }
00192 
00193 bool MEDCouplingFieldDouble::isEqual(const MEDCouplingField *other, double meshPrec, double valsPrec) const
00194 {
00195   const MEDCouplingFieldDouble *otherC=dynamic_cast<const MEDCouplingFieldDouble *>(other);
00196   if(!otherC)
00197     return false;
00198   if(!MEDCouplingField::isEqual(other,meshPrec,valsPrec))
00199     return false;
00200   if(!_time_discr->isEqual(otherC->_time_discr,valsPrec))
00201     return false;
00202   return true;
00203 }
00204 
00205 bool MEDCouplingFieldDouble::isEqualWithoutConsideringStr(const MEDCouplingField *other, double meshPrec, double valsPrec) const
00206 {
00207   const MEDCouplingFieldDouble *otherC=dynamic_cast<const MEDCouplingFieldDouble *>(other);
00208   if(!otherC)
00209     return false;
00210   if(!MEDCouplingField::isEqualWithoutConsideringStr(other,meshPrec,valsPrec))
00211     return false;
00212   if(!_time_discr->isEqualWithoutConsideringStr(otherC->_time_discr,valsPrec))
00213     return false;
00214   return true;
00215 }
00216 
00222 bool MEDCouplingFieldDouble::areCompatibleForMerge(const MEDCouplingField *other) const
00223 {
00224   if(!MEDCouplingField::areCompatibleForMerge(other))
00225     return false;
00226   const MEDCouplingFieldDouble *otherC=dynamic_cast<const MEDCouplingFieldDouble *>(other);
00227   if(!otherC)
00228     return false;
00229   if(!_time_discr->areCompatible(otherC->_time_discr))
00230     return false;
00231   return true;
00232 }
00233 
00238 bool MEDCouplingFieldDouble::areStrictlyCompatible(const MEDCouplingField *other) const
00239 {
00240   if(!MEDCouplingField::areStrictlyCompatible(other))
00241     return false;
00242   const MEDCouplingFieldDouble *otherC=dynamic_cast<const MEDCouplingFieldDouble *>(other);
00243   if(!otherC)
00244     return false;
00245   if(!_time_discr->areStrictlyCompatible(otherC->_time_discr))
00246     return false;
00247   return true;
00248 }
00249 
00254 bool MEDCouplingFieldDouble::areCompatibleForMul(const MEDCouplingField *other) const
00255 {
00256   if(!MEDCouplingField::areStrictlyCompatible(other))
00257     return false;
00258   const MEDCouplingFieldDouble *otherC=dynamic_cast<const MEDCouplingFieldDouble *>(other);
00259   if(!otherC)
00260     return false;
00261   if(!_time_discr->areStrictlyCompatibleForMul(otherC->_time_discr))
00262     return false;
00263   return true;
00264 }
00265 
00270 bool MEDCouplingFieldDouble::areCompatibleForDiv(const MEDCouplingField *other) const
00271 {
00272   if(!MEDCouplingField::areStrictlyCompatible(other))
00273     return false;
00274   const MEDCouplingFieldDouble *otherC=dynamic_cast<const MEDCouplingFieldDouble *>(other);
00275   if(!otherC)
00276     return false;
00277   if(!_time_discr->areStrictlyCompatibleForDiv(otherC->_time_discr))
00278     return false;
00279   return true;
00280 }
00281 
00286 bool MEDCouplingFieldDouble::areCompatibleForMeld(const MEDCouplingFieldDouble *other) const
00287 {
00288   if(!MEDCouplingField::areStrictlyCompatible(other))
00289     return false;
00290   if(!_time_discr->areCompatibleForMeld(other->_time_discr))
00291     return false;
00292   return true;
00293 }
00294 
00299 void MEDCouplingFieldDouble::renumberCells(const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception)
00300 {
00301   renumberCellsWithoutMesh(old2NewBg,check);
00302   MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=_mesh->deepCpy();
00303   m->renumberCells(old2NewBg,check);
00304   setMesh(m);
00305   updateTime();
00306 }
00307 
00314 void MEDCouplingFieldDouble::renumberCellsWithoutMesh(const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception)
00315 {
00316    if(!_mesh)
00317     throw INTERP_KERNEL::Exception("Expecting a defined mesh to be able to operate a renumbering !");
00318   //
00319   _type->renumberCells(old2NewBg,check);
00320   std::vector<DataArrayDouble *> arrays;
00321   _time_discr->getArrays(arrays);
00322   _type->renumberArraysForCell(_mesh,arrays,old2NewBg,check);
00323   //
00324   updateTime();
00325 }
00326 
00331 void MEDCouplingFieldDouble::renumberNodes(const int *old2NewBg) throw(INTERP_KERNEL::Exception)
00332 {
00333   const MEDCouplingPointSet *meshC=dynamic_cast<const MEDCouplingPointSet *>(_mesh);
00334   if(!meshC)
00335     throw INTERP_KERNEL::Exception("Invalid mesh to apply renumberNodes on it !");
00336   int nbOfNodes=meshC->getNumberOfNodes();
00337   MEDCouplingAutoRefCountObjectPtr<MEDCouplingPointSet> meshC2((MEDCouplingPointSet *)meshC->deepCpy());
00338   renumberNodesWithoutMesh(old2NewBg);
00339   meshC2->renumberNodes(old2NewBg,*std::max_element(old2NewBg,old2NewBg+nbOfNodes)+1);
00340   setMesh(meshC2);
00341 }
00342 
00348 void MEDCouplingFieldDouble::renumberNodesWithoutMesh(const int *old2NewBg, double eps) throw(INTERP_KERNEL::Exception)
00349 {
00350   std::vector<DataArrayDouble *> arrays;
00351   _time_discr->getArrays(arrays);
00352   for(std::vector<DataArrayDouble *>::const_iterator iter=arrays.begin();iter!=arrays.end();iter++)
00353     if(*iter)
00354       _type->renumberValuesOnNodes(eps,old2NewBg,*iter);
00355 }
00356 
00363 DataArrayInt *MEDCouplingFieldDouble::getIdsInRange(double vmin, double vmax) const throw(INTERP_KERNEL::Exception)
00364 {
00365   if(getArray()==0)
00366     throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::getIdsInRange : no default array set !");
00367   return getArray()->getIdsInRange(vmin,vmax);
00368 }
00369 
00386 MEDCouplingFieldDouble *MEDCouplingFieldDouble::buildSubPart(const DataArrayInt *part) const throw(INTERP_KERNEL::Exception)
00387 {
00388   if(part==0)
00389     throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::buildSubPart : not empty array must be passed to this method !");
00390   const int *start=part->getConstPointer();
00391   const int *end=start+part->getNbOfElems();
00392   return buildSubPart(start,end);
00393 }
00394 
00415 MEDCouplingFieldDouble *MEDCouplingFieldDouble::buildSubPart(const int *partBg, const int *partEnd) const throw(INTERP_KERNEL::Exception)
00416 {
00417   DataArrayInt *arrSelect;
00418   MEDCouplingMesh *m=_type->buildSubMeshData(_mesh,partBg,partEnd,arrSelect);
00419   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arrSelect2(arrSelect);
00420   MEDCouplingFieldDouble *ret=clone(false);//quick shallow copy.
00421   ret->setMesh(m);
00422   m->decrRef();
00423   std::vector<DataArrayDouble *> arrays;
00424   _time_discr->getArrays(arrays);
00425   std::vector<DataArrayDouble *> arrs;
00426   const int *arrSelBg=arrSelect->getConstPointer();
00427   const int *arrSelEnd=arrSelBg+arrSelect->getNbOfElems();
00428   for(std::vector<DataArrayDouble *>::const_iterator iter=arrays.begin();iter!=arrays.end();iter++)
00429     {
00430       DataArrayDouble *arr=0;
00431       if(*iter)
00432         arr=(*iter)->selectByTupleId(arrSelBg,arrSelEnd);
00433       arrs.push_back(arr);
00434     }
00435   ret->_time_discr->setArrays(arrs,0);
00436   for(std::vector<DataArrayDouble *>::const_iterator iter=arrs.begin();iter!=arrs.end();iter++)
00437     if(*iter)
00438       (*iter)->decrRef();
00439   return ret;
00440 }
00441 
00442 TypeOfTimeDiscretization MEDCouplingFieldDouble::getTimeDiscretization() const
00443 {
00444   return _time_discr->getEnum();
00445 }
00446 
00447 MEDCouplingFieldDouble::MEDCouplingFieldDouble(TypeOfField type, TypeOfTimeDiscretization td):MEDCouplingField(type),
00448                                                                                               _time_discr(MEDCouplingTimeDiscretization::New(td))
00449 {
00450 }
00451 
00452 MEDCouplingFieldDouble::MEDCouplingFieldDouble(const MEDCouplingFieldTemplate *ft, TypeOfTimeDiscretization td):MEDCouplingField(*ft),
00453                                                                                                                 _time_discr(MEDCouplingTimeDiscretization::New(td))
00454 {
00455 }
00456 
00457 MEDCouplingFieldDouble::MEDCouplingFieldDouble(const MEDCouplingFieldDouble& other, bool deepCopy):MEDCouplingField(other),
00458                                                                                                    _time_discr(other._time_discr->performCpy(deepCopy))
00459 {
00460 }
00461 
00462 MEDCouplingFieldDouble::MEDCouplingFieldDouble(NatureOfField n, MEDCouplingTimeDiscretization *td, MEDCouplingFieldDiscretization *type):MEDCouplingField(type,n),_time_discr(td)
00463 {
00464 }
00465 
00466 MEDCouplingFieldDouble::~MEDCouplingFieldDouble()
00467 {
00468   delete _time_discr;
00469 }
00470 
00471 void MEDCouplingFieldDouble::checkCoherency() const throw(INTERP_KERNEL::Exception)
00472 {
00473   if(!_mesh)
00474     throw INTERP_KERNEL::Exception("Field invalid because no mesh specified !");
00475   _time_discr->checkCoherency();
00476   _type->checkCoherencyBetween(_mesh,getArray());
00477 }
00478 
00482 double MEDCouplingFieldDouble::accumulate(int compId) const
00483 {
00484   if(getArray()==0)
00485     throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::accumulate : no default array defined !");
00486   return getArray()->accumulate(compId);
00487 }
00488 
00493 void MEDCouplingFieldDouble::accumulate(double *res) const
00494 {
00495   if(getArray()==0)
00496     throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::accumulate : no default array defined !");
00497   getArray()->accumulate(res);
00498 }
00499 
00505 double MEDCouplingFieldDouble::getMaxValue() const throw(INTERP_KERNEL::Exception)
00506 {
00507   std::vector<DataArrayDouble *> arrays;
00508   _time_discr->getArrays(arrays);
00509   double ret=-std::numeric_limits<double>::max();
00510   bool isExistingArr=false;
00511   for(std::vector<DataArrayDouble *>::const_iterator iter=arrays.begin();iter!=arrays.end();iter++)
00512     {
00513       if(*iter)
00514         {
00515           isExistingArr=true;
00516           int loc;
00517           ret=std::max(ret,(*iter)->getMaxValue(loc));
00518         }
00519     }
00520   if(!isExistingArr)
00521     throw INTERP_KERNEL::Exception("getMaxValue : No arrays defined !");
00522   return ret;
00523 }
00524 
00532 double MEDCouplingFieldDouble::getMaxValue2(DataArrayInt*& tupleIds) const throw(INTERP_KERNEL::Exception)
00533 {
00534   std::vector<DataArrayDouble *> arrays;
00535   _time_discr->getArrays(arrays);
00536   double ret=-std::numeric_limits<double>::max();
00537   bool isExistingArr=false;
00538   tupleIds=0;
00539   for(std::vector<DataArrayDouble *>::const_iterator iter=arrays.begin();iter!=arrays.end();iter++)
00540     {
00541       if(*iter)
00542         {
00543           isExistingArr=true;
00544           DataArrayInt *tmp;
00545           ret=std::max(ret,(*iter)->getMaxValue2(tmp));
00546           if(!tupleIds)
00547             tupleIds=tmp;
00548           else
00549             tmp->decrRef();
00550         }
00551     }
00552   if(!isExistingArr)
00553     throw INTERP_KERNEL::Exception("getMaxValue2 : No arrays defined !");
00554   return ret;
00555 }
00556 
00562 double MEDCouplingFieldDouble::getMinValue() const throw(INTERP_KERNEL::Exception)
00563 {
00564   std::vector<DataArrayDouble *> arrays;
00565   _time_discr->getArrays(arrays);
00566   double ret=std::numeric_limits<double>::max();
00567   bool isExistingArr=false;
00568   for(std::vector<DataArrayDouble *>::const_iterator iter=arrays.begin();iter!=arrays.end();iter++)
00569     {
00570       if(*iter)
00571         {
00572           isExistingArr=true;
00573           int loc;
00574           ret=std::min(ret,(*iter)->getMinValue(loc));
00575         }
00576     }
00577   if(!isExistingArr)
00578     throw INTERP_KERNEL::Exception("getMinValue : No arrays defined !");
00579   return ret;
00580 }
00581 
00589 double MEDCouplingFieldDouble::getMinValue2(DataArrayInt*& tupleIds) const throw(INTERP_KERNEL::Exception)
00590 {
00591   std::vector<DataArrayDouble *> arrays;
00592   _time_discr->getArrays(arrays);
00593   double ret=-std::numeric_limits<double>::max();
00594   bool isExistingArr=false;
00595   tupleIds=0;
00596   for(std::vector<DataArrayDouble *>::const_iterator iter=arrays.begin();iter!=arrays.end();iter++)
00597     {
00598       if(*iter)
00599         {
00600           isExistingArr=true;
00601           DataArrayInt *tmp;
00602           ret=std::max(ret,(*iter)->getMinValue2(tmp));
00603           if(!tupleIds)
00604             tupleIds=tmp;
00605           else
00606             tmp->decrRef();
00607         }
00608     }
00609   if(!isExistingArr)
00610     throw INTERP_KERNEL::Exception("getMinValue2 : No arrays defined !");
00611   return ret;
00612 }
00613 
00619 double MEDCouplingFieldDouble::getAverageValue() const throw(INTERP_KERNEL::Exception)
00620 {
00621   if(getArray()==0)
00622     throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::getAverageValue : no default array defined !");
00623   return getArray()->getAverageValue();
00624 }
00625 
00633 double MEDCouplingFieldDouble::norm2() const throw(INTERP_KERNEL::Exception)
00634 {
00635   if(getArray()==0)
00636     throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::norm2 : no default array defined !");
00637   return getArray()->norm2();
00638 }
00639 
00647 double MEDCouplingFieldDouble::normMax() const throw(INTERP_KERNEL::Exception)
00648 {
00649   if(getArray()==0)
00650     throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::normMax : no default array defined !");
00651   return getArray()->normMax();
00652 }
00653 
00660 double MEDCouplingFieldDouble::getWeightedAverageValue() const throw(INTERP_KERNEL::Exception)
00661 {
00662   if(getArray()==0)
00663     throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::getWeightedAverageValue : no default array defined !");
00664   MEDCouplingFieldDouble *w=buildMeasureField(true);
00665   double deno=w->getArray()->accumulate(0);
00666   w->getArray()->multiplyEqual(getArray());
00667   double res=w->getArray()->accumulate(0);
00668   w->decrRef();
00669   return res/deno;
00670 }
00671 
00679 double MEDCouplingFieldDouble::normL1(int compId) const throw(INTERP_KERNEL::Exception)
00680 {
00681   if(!_mesh)
00682     throw INTERP_KERNEL::Exception("No mesh underlying this field to perform normL1");
00683   int nbComps=getArray()->getNumberOfComponents();
00684   if(compId>=nbComps)
00685     throw INTERP_KERNEL::Exception("Invalid compId specified : No such nb of components !");
00686   double *res=new double[nbComps];
00687   try
00688     {
00689       _type->normL1(_mesh,getArray(),res);
00690     }
00691   catch(INTERP_KERNEL::Exception& e)
00692     {
00693       delete [] res;
00694       throw e;
00695     }
00696   double ret=res[compId];
00697   delete [] res;
00698   return ret;
00699 }
00700 
00708 void MEDCouplingFieldDouble::normL1(double *res) const throw(INTERP_KERNEL::Exception)
00709 {
00710   if(!_mesh)
00711     throw INTERP_KERNEL::Exception("No mesh underlying this field to perform normL1");
00712   _type->normL1(_mesh,getArray(),res);
00713 }
00714 
00722 double MEDCouplingFieldDouble::normL2(int compId) const throw(INTERP_KERNEL::Exception)
00723 {
00724   if(!_mesh)
00725     throw INTERP_KERNEL::Exception("No mesh underlying this field to perform normL2");
00726   int nbComps=getArray()->getNumberOfComponents();
00727   if(compId>=nbComps)
00728     throw INTERP_KERNEL::Exception("Invalid compId specified : No such nb of components !");
00729   double *res=new double[nbComps];
00730   try
00731     {
00732       _type->normL2(_mesh,getArray(),res);
00733     }
00734   catch(INTERP_KERNEL::Exception& e)
00735     {
00736       delete [] res;
00737       throw e;
00738     }
00739   double ret=res[compId];
00740   delete [] res;
00741   return ret;
00742 }
00743 
00751 void MEDCouplingFieldDouble::normL2(double *res) const throw(INTERP_KERNEL::Exception)
00752 {
00753   if(!_mesh)
00754     throw INTERP_KERNEL::Exception("No mesh underlying this field to perform normL2");
00755   _type->normL2(_mesh,getArray(),res);
00756 }
00757 
00763 double MEDCouplingFieldDouble::integral(int compId, bool isWAbs) const throw(INTERP_KERNEL::Exception)
00764 {
00765   if(!_mesh)
00766     throw INTERP_KERNEL::Exception("No mesh underlying this field to perform integral");
00767   int nbComps=getArray()->getNumberOfComponents();
00768   if(compId>=nbComps)
00769     throw INTERP_KERNEL::Exception("Invalid compId specified : No such nb of components !");
00770   double *res=new double[nbComps];
00771   try
00772     {
00773       _type->integral(_mesh,getArray(),isWAbs,res);
00774     }
00775   catch(INTERP_KERNEL::Exception& e)
00776     {
00777       delete [] res;
00778       throw e;
00779     }
00780   double ret=res[compId];
00781   delete [] res;
00782   return ret;
00783 }
00784 
00790 void MEDCouplingFieldDouble::integral(bool isWAbs, double *res) const throw(INTERP_KERNEL::Exception)
00791 {
00792   if(!_mesh)
00793     throw INTERP_KERNEL::Exception("No mesh underlying this field to perform integral2");
00794   _type->integral(_mesh,getArray(),isWAbs,res);
00795 }
00796 
00802 void MEDCouplingFieldDouble::getValueOnPos(int i, int j, int k, double *res) const throw(INTERP_KERNEL::Exception)
00803 {
00804   const DataArrayDouble *arr=_time_discr->getArray();
00805   if(!_mesh)
00806     throw INTERP_KERNEL::Exception("No mesh underlying this field to perform getValueOnPos");
00807   _type->getValueOnPos(arr,_mesh,i,j,k,res);
00808 }
00809 
00814 void MEDCouplingFieldDouble::getValueOn(const double *spaceLoc, double *res) const throw(INTERP_KERNEL::Exception)
00815 {
00816   const DataArrayDouble *arr=_time_discr->getArray();
00817   if(!_mesh)
00818     throw INTERP_KERNEL::Exception("No mesh underlying this field to perform getValueOn");
00819   _type->getValueOn(arr,_mesh,spaceLoc,res);
00820 }
00821 
00825 DataArrayDouble *MEDCouplingFieldDouble::getValueOnMulti(const double *spaceLoc, int nbOfPoints) const throw(INTERP_KERNEL::Exception)
00826 {
00827   const DataArrayDouble *arr=_time_discr->getArray();
00828   if(!_mesh)
00829     throw INTERP_KERNEL::Exception("No mesh underlying this field to perform getValueOnMulti");
00830   return _type->getValueOnMulti(arr,_mesh,spaceLoc,nbOfPoints);
00831 }
00832 
00838 void MEDCouplingFieldDouble::getValueOn(const double *spaceLoc, double time, double *res) const throw(INTERP_KERNEL::Exception)
00839 {
00840   std::vector< const DataArrayDouble *> arrs=_time_discr->getArraysForTime(time);
00841   if(!_mesh)
00842     throw INTERP_KERNEL::Exception("No mesh underlying this field to perform getValueOn");
00843   std::vector<double> res2;
00844   for(std::vector< const DataArrayDouble *>::const_iterator iter=arrs.begin();iter!=arrs.end();iter++)
00845     {
00846       int sz=(int)res2.size();
00847       res2.resize(sz+(*iter)->getNumberOfComponents());
00848       _type->getValueOn(*iter,_mesh,spaceLoc,&res2[sz]);
00849     }
00850   _time_discr->getValueForTime(time,res2,res);
00851 }
00852 
00856 void MEDCouplingFieldDouble::applyLin(double a, double b, int compoId)
00857 {
00858   _time_discr->applyLin(a,b,compoId);
00859 }
00860 
00866 MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator=(double value) throw(INTERP_KERNEL::Exception)
00867 {
00868   if(!_mesh)
00869     throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::operator= : no mesh defined !");
00870   int nbOfTuple=_type->getNumberOfTuples(_mesh);
00871   _time_discr->setUniformValue(nbOfTuple,1,value);
00872   return *this;
00873 }
00874 
00881 void MEDCouplingFieldDouble::fillFromAnalytic(int nbOfComp, FunctionToEvaluate func) throw(INTERP_KERNEL::Exception)
00882 {
00883   if(!_mesh)
00884     throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::fillFromAnalytic : no mesh defined !");
00885   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> loc=_type->getLocalizationOfDiscValues(_mesh);
00886   _time_discr->fillFromAnalytic(loc,nbOfComp,func);
00887 }
00888 
00895 void MEDCouplingFieldDouble::fillFromAnalytic(int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception)
00896 {
00897   if(!_mesh)
00898     throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::fillFromAnalytic : no mesh defined !");
00899   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> loc=_type->getLocalizationOfDiscValues(_mesh);
00900   _time_discr->fillFromAnalytic(loc,nbOfComp,func);
00901 }
00902 
00909 void MEDCouplingFieldDouble::fillFromAnalytic2(int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception)
00910 {
00911   if(!_mesh)
00912     throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::fillFromAnalytic2 : no mesh defined !");
00913   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> loc=_type->getLocalizationOfDiscValues(_mesh);
00914   _time_discr->fillFromAnalytic2(loc,nbOfComp,func);
00915 }
00916 
00923 void MEDCouplingFieldDouble::fillFromAnalytic3(int nbOfComp, const std::vector<std::string>& varsOrder, const char *func) throw(INTERP_KERNEL::Exception)
00924 {
00925   if(!_mesh)
00926     throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::fillFromAnalytic2 : no mesh defined !");
00927   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> loc=_type->getLocalizationOfDiscValues(_mesh);
00928   _time_discr->fillFromAnalytic3(loc,nbOfComp,varsOrder,func);
00929 }
00930 
00935 void MEDCouplingFieldDouble::applyFunc(int nbOfComp, FunctionToEvaluate func)
00936 {
00937   _time_discr->applyFunc(nbOfComp,func);
00938 }
00939 
00944 void MEDCouplingFieldDouble::applyFunc(int nbOfComp, double val)
00945 {
00946   if(!_mesh)
00947     throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::applyFunc : no mesh defined !");
00948   int nbOfTuple=_type->getNumberOfTuples(_mesh);
00949   _time_discr->setUniformValue(nbOfTuple,nbOfComp,val);
00950 }
00951 
00957 void MEDCouplingFieldDouble::applyFunc(int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception)
00958 {
00959   _time_discr->applyFunc(nbOfComp,func);
00960 }
00961 
00966 void MEDCouplingFieldDouble::applyFunc2(int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception)
00967 {
00968   _time_discr->applyFunc2(nbOfComp,func);
00969 }
00970 
00975 void MEDCouplingFieldDouble::applyFunc3(int nbOfComp, const std::vector<std::string>& varsOrder, const char *func) throw(INTERP_KERNEL::Exception)
00976 {
00977   _time_discr->applyFunc3(nbOfComp,varsOrder,func);
00978 }
00979 
00985 void MEDCouplingFieldDouble::applyFunc(const char *func) throw(INTERP_KERNEL::Exception)
00986 {
00987   _time_discr->applyFunc(func);
00988 }
00989 
00995 void MEDCouplingFieldDouble::applyFuncFast32(const char *func) throw(INTERP_KERNEL::Exception)
00996 {
00997   _time_discr->applyFuncFast32(func);
00998 }
00999 
01005 void MEDCouplingFieldDouble::applyFuncFast64(const char *func) throw(INTERP_KERNEL::Exception)
01006 {
01007   _time_discr->applyFuncFast64(func);
01008 }
01009 
01015 int MEDCouplingFieldDouble::getNumberOfComponents() const throw(INTERP_KERNEL::Exception)
01016 {
01017   if(getArray()==0)
01018     throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::getNumberOfComponents : No array specified !");
01019   return getArray()->getNumberOfComponents();
01020 }
01021 
01029 int MEDCouplingFieldDouble::getNumberOfTuples() const throw(INTERP_KERNEL::Exception)
01030 {
01031   if(!_mesh)
01032     throw INTERP_KERNEL::Exception("Impossible to retrieve number of tuples because no mesh specified !");
01033   return _type->getNumberOfTuples(_mesh);
01034 }
01035 
01041 int MEDCouplingFieldDouble::getNumberOfValues() const throw(INTERP_KERNEL::Exception)
01042 {
01043   if(getArray()==0)
01044     throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::getNumberOfValues : No array specified !");
01045   return getArray()->getNbOfElems();
01046 }
01047 
01048 void MEDCouplingFieldDouble::updateTime() const
01049 {
01050   MEDCouplingField::updateTime();
01051   updateTimeWith(*_time_discr);
01052 }
01053 
01054 void MEDCouplingFieldDouble::setNature(NatureOfField nat) throw(INTERP_KERNEL::Exception)
01055 {
01056   MEDCouplingField::setNature(nat);
01057   _type->checkCompatibilityWithNature(nat);
01058 }
01059 
01060 double MEDCouplingFieldDouble::getIJK(int cellId, int nodeIdInCell, int compoId) const
01061 {
01062   return _type->getIJK(_mesh,getArray(),cellId,nodeIdInCell,compoId);
01063 }
01064 
01065 void MEDCouplingFieldDouble::setArray(DataArrayDouble *array)
01066 {
01067   _time_discr->setArray(array,this);
01068 }
01069 
01070 void MEDCouplingFieldDouble::setEndArray(DataArrayDouble *array)
01071 {
01072   _time_discr->setEndArray(array,this);
01073 }
01074 
01075 void MEDCouplingFieldDouble::setArrays(const std::vector<DataArrayDouble *>& arrs) throw(INTERP_KERNEL::Exception)
01076 {
01077   _time_discr->setArrays(arrs,this);
01078 }
01079 
01080 void MEDCouplingFieldDouble::getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const
01081 {
01082   tinyInfo.clear();
01083   _time_discr->getTinySerializationStrInformation(tinyInfo);
01084   tinyInfo.push_back(_name);
01085   tinyInfo.push_back(_desc);
01086   tinyInfo.push_back(getTimeUnit());
01087 }
01088 
01094 void MEDCouplingFieldDouble::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const
01095 {
01096   tinyInfo.clear();
01097   tinyInfo.push_back((int)_type->getEnum());
01098   tinyInfo.push_back((int)_time_discr->getEnum());
01099   tinyInfo.push_back((int)_nature);
01100   _time_discr->getTinySerializationIntInformation(tinyInfo);
01101   std::vector<int> tinyInfo2;
01102   _type->getTinySerializationIntInformation(tinyInfo2);
01103   tinyInfo.insert(tinyInfo.end(),tinyInfo2.begin(),tinyInfo2.end());
01104   tinyInfo.push_back((int)tinyInfo2.size());
01105 }
01106 
01111 void MEDCouplingFieldDouble::getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const
01112 {
01113   tinyInfo.clear();
01114   _time_discr->getTinySerializationDbleInformation(tinyInfo);
01115   std::vector<double> tinyInfo2;
01116   _type->getTinySerializationDbleInformation(tinyInfo2);
01117   tinyInfo.insert(tinyInfo.end(),tinyInfo2.begin(),tinyInfo2.end());
01118   tinyInfo.push_back((int)tinyInfo2.size());//very bad, lack of time to improve it
01119 }
01120 
01128 void MEDCouplingFieldDouble::resizeForUnserialization(const std::vector<int>& tinyInfoI, DataArrayInt *&dataInt, std::vector<DataArrayDouble *>& arrays)
01129 {
01130   dataInt=0;
01131   std::vector<int> tinyInfoITmp(tinyInfoI);
01132   int sz=tinyInfoITmp.back();
01133   tinyInfoITmp.pop_back();
01134   std::vector<int> tinyInfoITmp2(tinyInfoITmp.begin(),tinyInfoITmp.end()-sz);
01135   std::vector<int> tinyInfoI2(tinyInfoITmp2.begin()+3,tinyInfoITmp2.end());
01136   _time_discr->resizeForUnserialization(tinyInfoI2,arrays);
01137   std::vector<int> tinyInfoITmp3(tinyInfoITmp.end()-sz,tinyInfoITmp.end());
01138   _type->resizeForUnserialization(tinyInfoITmp3,dataInt);
01139 }
01140 
01141 void MEDCouplingFieldDouble::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS)
01142 {
01143   std::vector<int> tinyInfoI2(tinyInfoI.begin()+3,tinyInfoI.end());
01144   //
01145   std::vector<double> tmp(tinyInfoD);
01146   int sz=(int)tinyInfoD.back();//very bad, lack of time to improve it
01147   tmp.pop_back();
01148   std::vector<double> tmp1(tmp.begin(),tmp.end()-sz);
01149   std::vector<double> tmp2(tmp.end()-sz,tmp.end());
01150   //
01151   _time_discr->finishUnserialization(tinyInfoI2,tmp1,tinyInfoS);
01152   _nature=(NatureOfField)tinyInfoI[2];
01153   _type->finishUnserialization(tmp2);
01154   int nbOfElemS=(int)tinyInfoS.size();
01155   _name=tinyInfoS[nbOfElemS-3];
01156   _desc=tinyInfoS[nbOfElemS-2];
01157   setTimeUnit(tinyInfoS[nbOfElemS-1].c_str());
01158 }
01159 
01164 void MEDCouplingFieldDouble::serialize(DataArrayInt *&dataInt, std::vector<DataArrayDouble *>& arrays) const
01165 {
01166   _time_discr->getArrays(arrays);
01167   _type->getSerializationIntArray(dataInt);
01168 }
01169 
01175 void MEDCouplingFieldDouble::changeUnderlyingMesh(const MEDCouplingMesh *other, int levOfCheck, double prec) throw(INTERP_KERNEL::Exception)
01176 {
01177   if(_mesh==0 || other==0)
01178     throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::changeUnderlyingMesh : is expected to operate on not null meshes !");
01179   DataArrayInt *cellCor,*nodeCor;
01180   other->checkGeoEquivalWith(_mesh,levOfCheck,prec,cellCor,nodeCor);
01181   if(cellCor)
01182     {
01183       renumberCellsWithoutMesh(cellCor->getConstPointer(),false);
01184       cellCor->decrRef();
01185     }
01186   if(nodeCor)
01187     {
01188       renumberNodesWithoutMesh(nodeCor->getConstPointer());
01189       nodeCor->decrRef();
01190     }
01191   setMesh(const_cast<MEDCouplingMesh *>(other));
01192 }
01193 
01200 void MEDCouplingFieldDouble::substractInPlaceDM(const MEDCouplingFieldDouble *f, int levOfCheck, double prec) throw(INTERP_KERNEL::Exception)
01201 {
01202   checkCoherency();
01203   f->checkCoherency();
01204   if(!areCompatibleForMerge(f))
01205     throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::diffWith : Fields are not compatible ; unable to apply mergeFields on them !");
01206   changeUnderlyingMesh(f->getMesh(),levOfCheck,prec);
01207   operator-=(*f);
01208 }
01209 
01215 bool MEDCouplingFieldDouble::mergeNodes(double eps, double epsOnVals) throw(INTERP_KERNEL::Exception)
01216 {
01217   const MEDCouplingPointSet *meshC=dynamic_cast<const MEDCouplingPointSet *>(_mesh);
01218   if(!meshC)
01219     throw INTERP_KERNEL::Exception("Invalid support mesh to apply mergeNodes on it : must be a MEDCouplingPointSet one !");
01220   MEDCouplingAutoRefCountObjectPtr<MEDCouplingPointSet> meshC2((MEDCouplingPointSet *)meshC->deepCpy());
01221   bool ret;
01222   int ret2;
01223   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=meshC2->mergeNodes(eps,ret,ret2);
01224   if(!ret)//no nodes have been merged.
01225     return ret;
01226   std::vector<DataArrayDouble *> arrays;
01227   _time_discr->getArrays(arrays);
01228   for(std::vector<DataArrayDouble *>::const_iterator iter=arrays.begin();iter!=arrays.end();iter++)
01229     if(*iter)
01230       _type->renumberValuesOnNodes(epsOnVals,arr->getConstPointer(),*iter);
01231   setMesh(meshC2);
01232   return true;
01233 }
01234 
01240 bool MEDCouplingFieldDouble::mergeNodes2(double eps, double epsOnVals) throw(INTERP_KERNEL::Exception)
01241 {
01242   const MEDCouplingPointSet *meshC=dynamic_cast<const MEDCouplingPointSet *>(_mesh);
01243   if(!meshC)
01244     throw INTERP_KERNEL::Exception("Invalid support mesh to apply mergeNodes on it : must be a MEDCouplingPointSet one !");
01245   MEDCouplingAutoRefCountObjectPtr<MEDCouplingPointSet> meshC2((MEDCouplingPointSet *)meshC->deepCpy());
01246   bool ret;
01247   int ret2;
01248   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=meshC2->mergeNodes2(eps,ret,ret2);
01249   if(!ret)//no nodes have been merged.
01250     return ret;
01251   std::vector<DataArrayDouble *> arrays;
01252   _time_discr->getArrays(arrays);
01253   for(std::vector<DataArrayDouble *>::const_iterator iter=arrays.begin();iter!=arrays.end();iter++)
01254     if(*iter)
01255       _type->renumberValuesOnNodes(epsOnVals,arr->getConstPointer(),*iter);
01256   setMesh(meshC2);
01257   return true;
01258 }
01259 
01265 bool MEDCouplingFieldDouble::zipCoords(double epsOnVals) throw(INTERP_KERNEL::Exception)
01266 {
01267   const MEDCouplingPointSet *meshC=dynamic_cast<const MEDCouplingPointSet *>(_mesh);
01268   if(!meshC)
01269     throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::zipCoords : Invalid support mesh to apply zipCoords on it : must be a MEDCouplingPointSet one !");
01270   MEDCouplingAutoRefCountObjectPtr<MEDCouplingPointSet> meshC2((MEDCouplingPointSet *)meshC->deepCpy());
01271   int oldNbOfNodes=meshC2->getNumberOfNodes();
01272   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=meshC2->zipCoordsTraducer();
01273   if(meshC2->getNumberOfNodes()!=oldNbOfNodes)
01274     {
01275       std::vector<DataArrayDouble *> arrays;
01276       _time_discr->getArrays(arrays);
01277       for(std::vector<DataArrayDouble *>::const_iterator iter=arrays.begin();iter!=arrays.end();iter++)
01278         if(*iter)
01279           _type->renumberValuesOnNodes(epsOnVals,arr->getConstPointer(),*iter);
01280       setMesh(meshC2);
01281       return true;
01282     }
01283   return false;
01284 }
01285 
01291 bool MEDCouplingFieldDouble::zipConnectivity(int compType, double epsOnVals) throw(INTERP_KERNEL::Exception)
01292 {
01293   const MEDCouplingUMesh *meshC=dynamic_cast<const MEDCouplingUMesh *>(_mesh);
01294   if(!meshC)
01295     throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::zipCoords : Invalid support mesh to apply zipCoords on it : must be a MEDCouplingPointSet one !");
01296   MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> meshC2((MEDCouplingUMesh *)meshC->deepCpy());
01297   int oldNbOfCells=meshC2->getNumberOfCells();
01298   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=meshC2->zipConnectivityTraducer(compType);
01299   if(meshC2->getNumberOfCells()!=oldNbOfCells)
01300     {
01301       std::vector<DataArrayDouble *> arrays;
01302       _time_discr->getArrays(arrays);
01303       for(std::vector<DataArrayDouble *>::const_iterator iter=arrays.begin();iter!=arrays.end();iter++)
01304         if(*iter)
01305           _type->renumberValuesOnCells(epsOnVals,meshC,arr->getConstPointer(),*iter);
01306       setMesh(meshC2);
01307       return true;
01308     }
01309   return false;
01310 }
01311 
01316 bool MEDCouplingFieldDouble::simplexize(int policy) throw(INTERP_KERNEL::Exception)
01317 {
01318   int oldNbOfCells=_mesh->getNumberOfCells();
01319   MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> meshC2(_mesh->deepCpy());
01320   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=meshC2->simplexize(policy);
01321   int newNbOfCells=meshC2->getNumberOfCells();
01322   if(oldNbOfCells==newNbOfCells)
01323     return false;
01324   std::vector<DataArrayDouble *> arrays;
01325   _time_discr->getArrays(arrays);
01326   for(std::vector<DataArrayDouble *>::const_iterator iter=arrays.begin();iter!=arrays.end();iter++)
01327     if(*iter)
01328       _type->renumberValuesOnCellsR(_mesh,arr->getConstPointer(),arr->getNbOfElems(),*iter);
01329   setMesh(meshC2);
01330   return true;
01331 }
01332 
01333 MEDCouplingFieldDouble *MEDCouplingFieldDouble::doublyContractedProduct() const throw(INTERP_KERNEL::Exception)
01334 {
01335   MEDCouplingTimeDiscretization *td=_time_discr->doublyContractedProduct();
01336   td->copyTinyAttrFrom(*_time_discr);
01337   MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone());
01338   ret->setName("DoublyContractedProduct");
01339   ret->setMesh(getMesh());
01340   return ret;
01341 }
01342 
01343 MEDCouplingFieldDouble *MEDCouplingFieldDouble::determinant() const throw(INTERP_KERNEL::Exception)
01344 {
01345   MEDCouplingTimeDiscretization *td=_time_discr->determinant();
01346   td->copyTinyAttrFrom(*_time_discr);
01347   MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone());
01348   ret->setName("Determinant");
01349   ret->setMesh(getMesh());
01350   return ret;
01351 }
01352 
01353 MEDCouplingFieldDouble *MEDCouplingFieldDouble::eigenValues() const throw(INTERP_KERNEL::Exception)
01354 {
01355   MEDCouplingTimeDiscretization *td=_time_discr->eigenValues();
01356   td->copyTinyAttrFrom(*_time_discr);
01357   MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone());
01358   ret->setName("EigenValues");
01359   ret->setMesh(getMesh());
01360   return ret;
01361 }
01362 
01363 MEDCouplingFieldDouble *MEDCouplingFieldDouble::eigenVectors() const throw(INTERP_KERNEL::Exception)
01364 {
01365   MEDCouplingTimeDiscretization *td=_time_discr->eigenVectors();
01366   td->copyTinyAttrFrom(*_time_discr);
01367   MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone());
01368   ret->setName("EigenVectors");
01369   ret->setMesh(getMesh());
01370   return ret;
01371 }
01372 
01373 MEDCouplingFieldDouble *MEDCouplingFieldDouble::inverse() const throw(INTERP_KERNEL::Exception)
01374 {
01375   MEDCouplingTimeDiscretization *td=_time_discr->inverse();
01376   td->copyTinyAttrFrom(*_time_discr);
01377   MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone());
01378   ret->setName("Inversion");
01379   ret->setMesh(getMesh());
01380   return ret;
01381 }
01382 
01383 MEDCouplingFieldDouble *MEDCouplingFieldDouble::trace() const throw(INTERP_KERNEL::Exception)
01384 {
01385   MEDCouplingTimeDiscretization *td=_time_discr->trace();
01386   td->copyTinyAttrFrom(*_time_discr);
01387   MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone());
01388   ret->setName("Trace");
01389   ret->setMesh(getMesh());
01390   return ret;
01391 }
01392 
01393 MEDCouplingFieldDouble *MEDCouplingFieldDouble::deviator() const throw(INTERP_KERNEL::Exception)
01394 {
01395   MEDCouplingTimeDiscretization *td=_time_discr->deviator();
01396   td->copyTinyAttrFrom(*_time_discr);
01397   MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone());
01398   ret->setName("Trace");
01399   ret->setMesh(getMesh());
01400   return ret;
01401 }
01402 
01403 MEDCouplingFieldDouble *MEDCouplingFieldDouble::magnitude() const throw(INTERP_KERNEL::Exception)
01404 {
01405   MEDCouplingTimeDiscretization *td=_time_discr->magnitude();
01406   td->copyTinyAttrFrom(*_time_discr);
01407   MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone());
01408   ret->setName("Magnitude");
01409   ret->setMesh(getMesh());
01410   return ret;
01411 }
01412 
01413 MEDCouplingFieldDouble *MEDCouplingFieldDouble::maxPerTuple() const throw(INTERP_KERNEL::Exception)
01414 {
01415   MEDCouplingTimeDiscretization *td=_time_discr->maxPerTuple();
01416   td->copyTinyAttrFrom(*_time_discr);
01417   MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone());
01418   std::ostringstream oss;
01419   oss << "Max_" << getName();
01420   ret->setName(oss.str().c_str());
01421   ret->setMesh(getMesh());
01422   return ret;
01423 }
01424 
01425 void MEDCouplingFieldDouble::changeNbOfComponents(int newNbOfComp, double dftValue) throw(INTERP_KERNEL::Exception)
01426 {
01427   _time_discr->changeNbOfComponents(newNbOfComp,dftValue);
01428 }
01429 
01430 MEDCouplingFieldDouble *MEDCouplingFieldDouble::keepSelectedComponents(const std::vector<int>& compoIds) const throw(INTERP_KERNEL::Exception)
01431 {
01432   MEDCouplingTimeDiscretization *td=_time_discr->keepSelectedComponents(compoIds);
01433   td->copyTinyAttrFrom(*_time_discr);
01434   MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone());
01435   ret->setName(getName());
01436   ret->setMesh(getMesh());
01437   return ret;
01438 }
01439 
01440 void MEDCouplingFieldDouble::setSelectedComponents(const MEDCouplingFieldDouble *f, const std::vector<int>& compoIds) throw(INTERP_KERNEL::Exception)
01441 {
01442   _time_discr->setSelectedComponents(f->_time_discr,compoIds);
01443 }
01444 
01445 void MEDCouplingFieldDouble::sortPerTuple(bool asc) throw(INTERP_KERNEL::Exception)
01446 {
01447   _time_discr->sortPerTuple(asc);
01448 }
01449 
01450 MEDCouplingFieldDouble *MEDCouplingFieldDouble::MergeFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception)
01451 {
01452   if(!f1->areCompatibleForMerge(f2))
01453     throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply MergeFields on them !");
01454   const MEDCouplingMesh *m1=f1->getMesh();
01455   const MEDCouplingMesh *m2=f2->getMesh();
01456   MEDCouplingMesh *m=m1->mergeMyselfWith(m2);
01457   MEDCouplingTimeDiscretization *td=f1->_time_discr->aggregate(f2->_time_discr);
01458   td->copyTinyAttrFrom(*f1->_time_discr);
01459   MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone());
01460   ret->setMesh(m);
01461   m->decrRef();
01462   ret->setName(f1->getName());
01463   ret->setDescription(f1->getDescription());
01464   return ret;
01465 }
01466 
01473 MEDCouplingFieldDouble *MEDCouplingFieldDouble::MergeFields(const std::vector<const MEDCouplingFieldDouble *>& a) throw(INTERP_KERNEL::Exception)
01474 {
01475   if(a.size()<1)
01476     throw INTERP_KERNEL::Exception("FieldDouble::MergeFields : size of array must be >= 1 !");
01477   std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> > ms(a.size());
01478   std::vector< const MEDCouplingUMesh *> ms2(a.size());
01479   std::vector< const MEDCouplingTimeDiscretization *> tds(a.size());
01480   std::vector<const MEDCouplingFieldDouble *>::const_iterator it=a.begin();
01481   const MEDCouplingFieldDouble *ref=(*it++);
01482   for(;it!=a.end();it++)
01483     if(!ref->areCompatibleForMerge(*it))
01484       throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply MergeFields on them !");
01485   for(int i=0;i<(int)a.size();i++)
01486     {
01487       if(!a[i]->getMesh())
01488         throw INTERP_KERNEL::Exception("MergeFields : A field as no underlying mesh !");
01489       ms[i]=a[i]->getMesh()->buildUnstructured();
01490       ms2[i]=ms[i];
01491       tds[i]=a[i]->_time_discr;
01492     }
01493   MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> m=MEDCouplingUMesh::MergeUMeshes(ms2);
01494   m->setName(ms2[0]->getName()); m->setDescription(ms2[0]->getDescription());
01495   MEDCouplingTimeDiscretization *td=tds[0]->aggregate(tds);
01496   td->copyTinyAttrFrom(*(a[0]->_time_discr));
01497   MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(a[0]->getNature(),td,a[0]->_type->clone());
01498   ret->setMesh(m);
01499   ret->setName(a[0]->getName());
01500   ret->setDescription(a[0]->getDescription());
01501   return ret;
01502 }
01503 
01504 MEDCouplingFieldDouble *MEDCouplingFieldDouble::MeldFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception)
01505 {
01506   if(!f1->areCompatibleForMeld(f2))
01507     throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply MeldFields on them !");
01508   MEDCouplingTimeDiscretization *td=f1->_time_discr->meld(f2->_time_discr);
01509   td->copyTinyAttrFrom(*f1->_time_discr);
01510   MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone());
01511   ret->setMesh(f1->getMesh());
01512   return ret;
01513 }
01514 
01515 MEDCouplingFieldDouble *MEDCouplingFieldDouble::DotFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception)
01516 {
01517   if(!f1->areStrictlyCompatible(f2))
01518     throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply DotFields on them !");
01519   MEDCouplingTimeDiscretization *td=f1->_time_discr->dot(f2->_time_discr);
01520   td->copyTinyAttrFrom(*f1->_time_discr);
01521   MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone());
01522   ret->setMesh(f1->getMesh());
01523   return ret;
01524 }
01525 
01526 MEDCouplingFieldDouble *MEDCouplingFieldDouble::CrossProductFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception)
01527 {
01528   if(!f1->areStrictlyCompatible(f2))
01529     throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply CrossProductFields on them !");
01530   MEDCouplingTimeDiscretization *td=f1->_time_discr->crossProduct(f2->_time_discr);
01531   td->copyTinyAttrFrom(*f1->_time_discr);
01532   MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone());
01533   ret->setMesh(f1->getMesh());
01534   return ret;
01535 }
01536 
01537 MEDCouplingFieldDouble *MEDCouplingFieldDouble::MaxFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception)
01538 {
01539   if(!f1->areStrictlyCompatible(f2))
01540     throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply MaxFields on them !");
01541   MEDCouplingTimeDiscretization *td=f1->_time_discr->max(f2->_time_discr);
01542   td->copyTinyAttrFrom(*f1->_time_discr);
01543   MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone());
01544   ret->setMesh(f1->getMesh());
01545   return ret;
01546 }
01547 
01548 MEDCouplingFieldDouble *MEDCouplingFieldDouble::MinFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception)
01549 {
01550   if(!f1->areStrictlyCompatible(f2))
01551     throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply MinFields on them !");
01552   MEDCouplingTimeDiscretization *td=f1->_time_discr->min(f2->_time_discr);
01553   td->copyTinyAttrFrom(*f1->_time_discr);
01554   MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone());
01555   ret->setMesh(f1->getMesh());
01556   return ret;
01557 }
01558 
01559 MEDCouplingFieldDouble *MEDCouplingFieldDouble::AddFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception)
01560 {
01561   if(!f1->areStrictlyCompatible(f2))
01562     throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply AddFields on them !");
01563   MEDCouplingTimeDiscretization *td=f1->_time_discr->add(f2->_time_discr);
01564   td->copyTinyAttrFrom(*f1->_time_discr);
01565   MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone());
01566   ret->setMesh(f1->getMesh());
01567   return ret;
01568 }
01569 
01570 const MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator+=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception)
01571 {
01572   if(!areStrictlyCompatible(&other))
01573     throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply += on them !");
01574   _time_discr->addEqual(other._time_discr);
01575   return *this;
01576 }
01577 
01578 MEDCouplingFieldDouble *MEDCouplingFieldDouble::SubstractFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception)
01579 {
01580   if(!f1->areStrictlyCompatible(f2))
01581     throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply SubstractFields on them !");
01582   MEDCouplingTimeDiscretization *td=f1->_time_discr->substract(f2->_time_discr);
01583   td->copyTinyAttrFrom(*f1->_time_discr);
01584   MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone());
01585   ret->setMesh(f1->getMesh());
01586   return ret;
01587 }
01588 
01589 const MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator-=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception)
01590 {
01591   if(!areStrictlyCompatible(&other))
01592     throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply -= on them !");
01593   _time_discr->substractEqual(other._time_discr);
01594   return *this;
01595 }
01596 
01597 MEDCouplingFieldDouble *MEDCouplingFieldDouble::MultiplyFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception)
01598 {
01599   if(!f1->areCompatibleForMul(f2))
01600     throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply MultiplyFields on them !");
01601   MEDCouplingTimeDiscretization *td=f1->_time_discr->multiply(f2->_time_discr);
01602   td->copyTinyAttrFrom(*f1->_time_discr);
01603   MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone());
01604   ret->setMesh(f1->getMesh());
01605   return ret;
01606 }
01607 
01608 const MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator*=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception)
01609 {
01610   if(!areCompatibleForMul(&other))
01611     throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply *= on them !");
01612   _time_discr->multiplyEqual(other._time_discr);
01613   return *this;
01614 }
01615 
01616 MEDCouplingFieldDouble *MEDCouplingFieldDouble::DivideFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception)
01617 {
01618   if(!f1->areCompatibleForDiv(f2))
01619     throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply DivideFields on them !");
01620   MEDCouplingTimeDiscretization *td=f1->_time_discr->divide(f2->_time_discr);
01621   td->copyTinyAttrFrom(*f1->_time_discr);
01622   MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone());
01623   ret->setMesh(f1->getMesh());
01624   return ret;
01625 }
01626 
01627 const MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator/=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception)
01628 {
01629   if(!areCompatibleForDiv(&other))
01630     throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply /= on them !");
01631   _time_discr->divideEqual(other._time_discr);
01632   return *this;
01633 }
01634 
01641 void MEDCouplingFieldDouble::WriteVTK(const char *fileName, const std::vector<const MEDCouplingFieldDouble *>& fs) throw(INTERP_KERNEL::Exception)
01642 {
01643   if(fs.empty())
01644     return;
01645   std::size_t nfs=fs.size();
01646   const MEDCouplingMesh *m=fs[0]->getMesh();
01647   for(std::size_t i=1;i<nfs;i++)
01648     if(fs[i]->getMesh()!=m)
01649       throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::WriteVTK : Fields are not lying on a same mesh ! Expected by VTK ! MEDCouplingFieldDouble::setMesh or MEDCouplingFieldDouble::changeUnderlyingMesh can help to that.");
01650   if(!m)
01651     throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::WriteVTK : Fields are lying on a same mesh but it is empty !");
01652   std::ostringstream coss,noss;
01653   for(std::size_t i=0;i<nfs;i++)
01654     {
01655       const MEDCouplingFieldDouble *cur=fs[i];
01656       std::string name(cur->getName());
01657       if(name.empty())
01658         {
01659           std::ostringstream oss; oss << "MEDCouplingFieldDouble::WriteVTK : Field in pos #" << i << " has no name !";
01660           throw INTERP_KERNEL::Exception(oss.str().c_str());
01661         }
01662       TypeOfField typ=cur->getTypeOfField();
01663       if(typ==ON_CELLS)
01664         cur->getArray()->writeVTK(coss,8,cur->getName());
01665       else if(typ==ON_NODES)
01666         cur->getArray()->writeVTK(noss,8,cur->getName());
01667     }
01668   m->writeVTKAdvanced(fileName,coss.str(),noss.str());
01669 }