Back to index

salome-med  6.5.0
MEDCouplingFieldDiscretization.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 "MEDCouplingFieldDiscretization.hxx"
00021 #include "MEDCouplingCMesh.hxx"
00022 #include "MEDCouplingUMesh.hxx"
00023 #include "MEDCouplingFieldDouble.hxx"
00024 #include "MEDCouplingAutoRefCountObjectPtr.hxx"
00025 
00026 #include "CellModel.hxx"
00027 #include "InterpolationUtils.hxx"
00028 #include "InterpKernelAutoPtr.hxx"
00029 #include "InterpKernelGaussCoords.hxx"
00030 
00031 #include <set>
00032 #include <list>
00033 #include <limits>
00034 #include <sstream>
00035 #include <algorithm>
00036 #include <functional>
00037 
00038 using namespace ParaMEDMEM;
00039 
00040 const double MEDCouplingFieldDiscretization::DFLT_PRECISION=1.e-12;
00041 
00042 const char MEDCouplingFieldDiscretizationP0::REPR[]="P0";
00043 
00044 const TypeOfField MEDCouplingFieldDiscretizationP0::TYPE=ON_CELLS;
00045 
00046 const char MEDCouplingFieldDiscretizationP1::REPR[]="P1";
00047 
00048 const TypeOfField MEDCouplingFieldDiscretizationP1::TYPE=ON_NODES;
00049 
00050 const int MEDCouplingFieldDiscretizationPerCell::DFT_INVALID_LOCID_VALUE=-1;
00051 
00052 const char MEDCouplingFieldDiscretizationGauss::REPR[]="GAUSS";
00053 
00054 const TypeOfField MEDCouplingFieldDiscretizationGauss::TYPE=ON_GAUSS_PT;
00055 
00056 const char MEDCouplingFieldDiscretizationGaussNE::REPR[]="GSSNE";
00057 
00058 const TypeOfField MEDCouplingFieldDiscretizationGaussNE::TYPE=ON_GAUSS_NE;
00059 
00060 MEDCouplingFieldDiscretization::MEDCouplingFieldDiscretization():_precision(DFLT_PRECISION)
00061 {
00062 }
00063 
00064 MEDCouplingFieldDiscretization *MEDCouplingFieldDiscretization::New(TypeOfField type)
00065 {
00066   switch(type)
00067     {
00068     case MEDCouplingFieldDiscretizationP0::TYPE:
00069       return new MEDCouplingFieldDiscretizationP0;
00070     case MEDCouplingFieldDiscretizationP1::TYPE:
00071       return new MEDCouplingFieldDiscretizationP1;
00072     case MEDCouplingFieldDiscretizationGauss::TYPE:
00073       return new MEDCouplingFieldDiscretizationGauss;
00074     case MEDCouplingFieldDiscretizationGaussNE::TYPE:
00075       return new MEDCouplingFieldDiscretizationGaussNE;
00076     default:
00077       throw INTERP_KERNEL::Exception("Choosen discretization is not implemented yet.");
00078     }
00079 }
00080 
00081 TypeOfField MEDCouplingFieldDiscretization::getTypeOfFieldFromStringRepr(const char *repr) throw(INTERP_KERNEL::Exception)
00082 {
00083   std::string reprCpp(repr);
00084   if(reprCpp==MEDCouplingFieldDiscretizationP0::REPR)
00085     return MEDCouplingFieldDiscretizationP0::TYPE;
00086   if(reprCpp==MEDCouplingFieldDiscretizationP1::REPR)
00087     return MEDCouplingFieldDiscretizationP1::TYPE;
00088   if(reprCpp==MEDCouplingFieldDiscretizationGauss::REPR)
00089     return MEDCouplingFieldDiscretizationGauss::TYPE;
00090   if(reprCpp==MEDCouplingFieldDiscretizationGaussNE::REPR)
00091     return MEDCouplingFieldDiscretizationGaussNE::TYPE;
00092   throw INTERP_KERNEL::Exception("Representation does not match with any field discretization !");
00093 }
00094 
00095 bool MEDCouplingFieldDiscretization::isEqualWithoutConsideringStr(const MEDCouplingFieldDiscretization *other, double eps) const
00096 {
00097   return isEqual(other,eps);
00098 }
00099 
00103 void MEDCouplingFieldDiscretization::updateTime() const
00104 {
00105 }
00106 
00112 void MEDCouplingFieldDiscretization::normL1(const MEDCouplingMesh *mesh, const DataArrayDouble *arr, double *res) const throw(INTERP_KERNEL::Exception)
00113 {
00114   MEDCouplingFieldDouble *vol=getMeasureField(mesh,true);
00115   int nbOfCompo=arr->getNumberOfComponents();
00116   int nbOfElems=getNumberOfTuples(mesh);
00117   std::fill(res,res+nbOfCompo,0.);
00118   const double *arrPtr=arr->getConstPointer();
00119   const double *volPtr=vol->getArray()->getConstPointer();
00120   double deno=0.;
00121   for(int i=0;i<nbOfElems;i++)
00122     {
00123       double v=fabs(volPtr[i]);
00124       for(int j=0;j<nbOfCompo;j++)
00125         res[j]+=fabs(arrPtr[i*nbOfCompo+j])*v;
00126       deno+=v;
00127     }
00128   std::transform(res,res+nbOfCompo,res,std::bind2nd(std::multiplies<double>(),1./deno));
00129   vol->decrRef();
00130 }
00131 
00137 void MEDCouplingFieldDiscretization::normL2(const MEDCouplingMesh *mesh, const DataArrayDouble *arr, double *res) const throw(INTERP_KERNEL::Exception)
00138 {
00139   MEDCouplingFieldDouble *vol=getMeasureField(mesh,true);
00140   int nbOfCompo=arr->getNumberOfComponents();
00141   int nbOfElems=getNumberOfTuples(mesh);
00142   std::fill(res,res+nbOfCompo,0.);
00143   const double *arrPtr=arr->getConstPointer();
00144   const double *volPtr=vol->getArray()->getConstPointer();
00145   double deno=0.;
00146   for(int i=0;i<nbOfElems;i++)
00147     {
00148       double v=fabs(volPtr[i]);
00149       for(int j=0;j<nbOfCompo;j++)
00150         res[j]+=arrPtr[i*nbOfCompo+j]*arrPtr[i*nbOfCompo+j]*v;
00151       deno+=v;
00152     }
00153   std::transform(res,res+nbOfCompo,res,std::bind2nd(std::multiplies<double>(),1./deno));
00154   std::transform(res,res+nbOfCompo,res,std::ptr_fun<double,double>(std::sqrt));
00155   vol->decrRef();
00156 }
00157 
00163 void MEDCouplingFieldDiscretization::integral(const MEDCouplingMesh *mesh, const DataArrayDouble *arr, bool isWAbs, double *res) const throw(INTERP_KERNEL::Exception)
00164 {
00165   MEDCouplingFieldDouble *vol=getMeasureField(mesh,isWAbs);
00166   int nbOfCompo=arr->getNumberOfComponents();
00167   int nbOfElems=getNumberOfTuples(mesh);
00168   std::fill(res,res+nbOfCompo,0.);
00169   const double *arrPtr=arr->getConstPointer();
00170   const double *volPtr=vol->getArray()->getConstPointer();
00171   double *tmp=new double[nbOfCompo];
00172   for (int i=0;i<nbOfElems;i++)
00173     {
00174       std::transform(arrPtr+i*nbOfCompo,arrPtr+(i+1)*nbOfCompo,tmp,std::bind2nd(std::multiplies<double>(),volPtr[i]));
00175       std::transform(tmp,tmp+nbOfCompo,res,res,std::plus<double>());
00176     }
00177   delete [] tmp;
00178   vol->decrRef();
00179 }
00180 
00181 void MEDCouplingFieldDiscretization::getSerializationIntArray(DataArrayInt *& arr) const
00182 {
00183   arr=0;
00184 }
00185 
00189 void MEDCouplingFieldDiscretization::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const
00190 {
00191 }
00192 
00196 void MEDCouplingFieldDiscretization::getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const
00197 {
00198 }
00199 
00200 void MEDCouplingFieldDiscretization::resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *& arr)
00201 {
00202   arr=0;
00203 }
00204 
00208 void MEDCouplingFieldDiscretization::finishUnserialization(const std::vector<double>& tinyInfo)
00209 {
00210 }
00211 
00216 void MEDCouplingFieldDiscretization::renumberCells(const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception)
00217 {
00218 }
00219 
00220 double MEDCouplingFieldDiscretization::getIJK(const MEDCouplingMesh *mesh, const DataArrayDouble *da,
00221                                               int cellId, int nodeIdInCell, int compoId) const throw(INTERP_KERNEL::Exception)
00222 {
00223   throw INTERP_KERNEL::Exception("getIJK Invalid ! only for GaussPoint and GaussNE discretizations !");
00224 }
00225 
00226 void MEDCouplingFieldDiscretization::setGaussLocalizationOnType(const MEDCouplingMesh *m, INTERP_KERNEL::NormalizedCellType type, const std::vector<double>& refCoo,
00227                                                                 const std::vector<double>& gsCoo, const std::vector<double>& wg) throw(INTERP_KERNEL::Exception)
00228 {
00229   throw INTERP_KERNEL::Exception("Invalid method for the corresponding field discretization : available only for GaussPoint discretization !");
00230 }
00231 
00232 void MEDCouplingFieldDiscretization::setGaussLocalizationOnCells(const MEDCouplingMesh *m, const int *begin, const int *end, const std::vector<double>& refCoo,
00233                                                                  const std::vector<double>& gsCoo, const std::vector<double>& wg) throw(INTERP_KERNEL::Exception)
00234 {
00235   throw INTERP_KERNEL::Exception("Invalid method for the corresponding field discretization : available only for GaussPoint discretization !");
00236 }
00237 
00238 void MEDCouplingFieldDiscretization::clearGaussLocalizations() throw(INTERP_KERNEL::Exception)
00239 {
00240   throw INTERP_KERNEL::Exception("Invalid method for the corresponding field discretization : available only for GaussPoint discretization !");
00241 }
00242 
00243 MEDCouplingGaussLocalization& MEDCouplingFieldDiscretization::getGaussLocalization(int locId) throw(INTERP_KERNEL::Exception)
00244 {
00245   throw INTERP_KERNEL::Exception("Invalid method for the corresponding field discretization : available only for GaussPoint discretization !");
00246 }
00247 
00248 const MEDCouplingGaussLocalization& MEDCouplingFieldDiscretization::getGaussLocalization(int locId) const throw(INTERP_KERNEL::Exception)
00249 {
00250   throw INTERP_KERNEL::Exception("Invalid method for the corresponding field discretization : available only for GaussPoint discretization !");
00251 }
00252 
00253 int MEDCouplingFieldDiscretization::getNbOfGaussLocalization() const throw(INTERP_KERNEL::Exception)
00254 {
00255   throw INTERP_KERNEL::Exception("Invalid method for the corresponding field discretization : available only for GaussPoint discretization !");
00256 }
00257 
00258 int MEDCouplingFieldDiscretization::getGaussLocalizationIdOfOneCell(int cellId) const throw(INTERP_KERNEL::Exception)
00259 {
00260   throw INTERP_KERNEL::Exception("Invalid method for the corresponding field discretization : available only for GaussPoint discretization !");
00261 }
00262 
00263 int MEDCouplingFieldDiscretization::getGaussLocalizationIdOfOneType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception)
00264 {
00265   throw INTERP_KERNEL::Exception("Invalid method for the corresponding field discretization : available only for GaussPoint discretization !");
00266 }
00267 
00268 void MEDCouplingFieldDiscretization::getCellIdsHavingGaussLocalization(int locId, std::vector<int>& cellIds) const throw(INTERP_KERNEL::Exception)
00269 {
00270   throw INTERP_KERNEL::Exception("Invalid method for the corresponding field discretization : available only for GaussPoint discretization !");
00271 }
00272 
00273 void MEDCouplingFieldDiscretization::renumberEntitiesFromO2NArr(double eps, const int *old2NewPtr, DataArrayDouble *arr, const char *msg)
00274 {
00275   int oldNbOfElems=arr->getNumberOfTuples();
00276   int nbOfComp=arr->getNumberOfComponents();
00277   int newNbOfTuples=(*std::max_element(old2NewPtr,old2NewPtr+oldNbOfElems))+1;
00278   DataArrayDouble *arrCpy=arr->deepCpy();
00279   const double *ptSrc=arrCpy->getConstPointer();
00280   arr->reAlloc(newNbOfTuples);
00281   double *ptToFill=arr->getPointer();
00282   std::fill(ptToFill,ptToFill+nbOfComp*newNbOfTuples,std::numeric_limits<double>::max());
00283   INTERP_KERNEL::AutoPtr<double> tmp=new double[nbOfComp];
00284   for(int i=0;i<oldNbOfElems;i++)
00285     {
00286       int newNb=old2NewPtr[i];
00287       if(newNb>=0)//if newNb<0 the node is considered as out.
00288         {
00289           if(std::find_if(ptToFill+newNb*nbOfComp,ptToFill+(newNb+1)*nbOfComp,std::bind2nd(std::not_equal_to<double>(),std::numeric_limits<double>::max()))
00290              ==ptToFill+(newNb+1)*nbOfComp)
00291             std::copy(ptSrc+i*nbOfComp,ptSrc+(i+1)*nbOfComp,ptToFill+newNb*nbOfComp);
00292           else
00293             {
00294               std::transform(ptSrc+i*nbOfComp,ptSrc+(i+1)*nbOfComp,ptToFill+newNb*nbOfComp,(double *)tmp,std::minus<double>());
00295               std::transform((double *)tmp,((double *)tmp)+nbOfComp,(double *)tmp,std::ptr_fun<double,double>(fabs));
00296               //if(!std::equal(ptSrc+i*nbOfComp,ptSrc+(i+1)*nbOfComp,ptToFill+newNb*nbOfComp))
00297               if(*std::max_element((double *)tmp,((double *)tmp)+nbOfComp)>eps)
00298                 {
00299                   arrCpy->decrRef();
00300                   std::ostringstream oss;
00301                   oss << msg << " " << i << " and " << std::find(old2NewPtr,old2NewPtr+i,newNb)-old2NewPtr
00302                       << " have been merged and " << msg << " field on them are different !";
00303                   throw INTERP_KERNEL::Exception(oss.str().c_str());
00304                 }
00305             }
00306         }
00307     }
00308   arrCpy->decrRef();
00309 }
00310 
00311 void MEDCouplingFieldDiscretization::renumberEntitiesFromN2OArr(const int *new2OldPtr, int new2OldSz, DataArrayDouble *arr, const char *msg)
00312 {
00313   int nbOfComp=arr->getNumberOfComponents();
00314   DataArrayDouble *arrCpy=arr->deepCpy();
00315   const double *ptSrc=arrCpy->getConstPointer();
00316   arr->reAlloc(new2OldSz);
00317   double *ptToFill=arr->getPointer();
00318   for(int i=0;i<new2OldSz;i++)
00319     {
00320       int oldNb=new2OldPtr[i];
00321       std::copy(ptSrc+oldNb*nbOfComp,ptSrc+(oldNb+1)*nbOfComp,ptToFill+i*nbOfComp);
00322     }
00323   arrCpy->decrRef();
00324 }
00325 
00326 MEDCouplingFieldDiscretization::~MEDCouplingFieldDiscretization()
00327 {
00328 }
00329 
00330 TypeOfField MEDCouplingFieldDiscretizationP0::getEnum() const
00331 {
00332   return TYPE;
00333 }
00334 
00335 MEDCouplingFieldDiscretization *MEDCouplingFieldDiscretizationP0::clone() const
00336 {
00337   return new MEDCouplingFieldDiscretizationP0;
00338 }
00339 
00340 std::string MEDCouplingFieldDiscretizationP0::getStringRepr() const
00341 {
00342   return std::string(REPR);
00343 }
00344 
00345 const char *MEDCouplingFieldDiscretizationP0::getRepr() const
00346 {
00347   return REPR;
00348 }
00349 
00350 bool MEDCouplingFieldDiscretizationP0::isEqual(const MEDCouplingFieldDiscretization *other, double eps) const
00351 {
00352   const MEDCouplingFieldDiscretizationP0 *otherC=dynamic_cast<const MEDCouplingFieldDiscretizationP0 *>(other);
00353   return otherC!=0;
00354 }
00355 
00356 int MEDCouplingFieldDiscretizationP0::getNumberOfTuples(const MEDCouplingMesh *mesh) const
00357 {
00358   return mesh->getNumberOfCells();
00359 }
00360 
00361 int MEDCouplingFieldDiscretizationP0::getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const
00362 {
00363   return mesh->getNumberOfCells();
00364 }
00365 
00366 DataArrayInt *MEDCouplingFieldDiscretizationP0::getOffsetArr(const MEDCouplingMesh *mesh) const
00367 {
00368   int nbOfTuples=mesh->getNumberOfCells();
00369   DataArrayInt *ret=DataArrayInt::New();
00370   ret->alloc(nbOfTuples+1,1);
00371   ret->iota(0);
00372   return ret;
00373 }
00374 
00375 void MEDCouplingFieldDiscretizationP0::renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector<DataArrayDouble *>& arrays,
00376                                                              const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception)
00377 {
00378   const int *array=old2NewBg;
00379   if(check)
00380     array=DataArrayInt::CheckAndPreparePermutation(old2NewBg,old2NewBg+mesh->getNumberOfCells());
00381   for(std::vector<DataArrayDouble *>::const_iterator it=arrays.begin();it!=arrays.end();it++)
00382     {
00383       if(*it)
00384         (*it)->renumberInPlace(array);
00385     }
00386   if(check)
00387     delete [] array;
00388 }
00389 
00390 DataArrayDouble *MEDCouplingFieldDiscretizationP0::getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const
00391 {
00392   return mesh->getBarycenterAndOwner();
00393 }
00394 
00395 void MEDCouplingFieldDiscretizationP0::computeMeshRestrictionFromTupleIds(const MEDCouplingMesh *mesh, const int *partBg, const int *partEnd,
00396                                                                           DataArrayInt *&cellRest)
00397 {
00398   cellRest=DataArrayInt::New();
00399   cellRest->alloc((int)std::distance(partBg,partEnd),1);
00400   std::copy(partBg,partEnd,cellRest->getPointer());
00401 }
00402 
00403 void MEDCouplingFieldDiscretizationP0::checkCompatibilityWithNature(NatureOfField nat) const throw(INTERP_KERNEL::Exception)
00404 {
00405 }
00406 
00407 void MEDCouplingFieldDiscretizationP0::checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception)
00408 {
00409   if(mesh->getNumberOfCells()!=da->getNumberOfTuples())
00410     {
00411       std::ostringstream message;
00412       message << "Field on cells invalid because there are " << mesh->getNumberOfCells();
00413       message << " cells in mesh and " << da->getNumberOfTuples() << " tuples in field !";
00414       throw INTERP_KERNEL::Exception(message.str().c_str());
00415     }
00416 }
00417 
00418 MEDCouplingFieldDouble *MEDCouplingFieldDiscretizationP0::getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const
00419 {
00420   return mesh->getMeasureField(isAbs);
00421 }
00422 
00423 void MEDCouplingFieldDiscretizationP0::getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const
00424 {
00425   int id=mesh->getCellContainingPoint(loc,_precision);
00426   if(id==-1)
00427     throw INTERP_KERNEL::Exception("Specified point is detected outside of mesh : unable to apply P0::getValueOn !");
00428   arr->getTuple(id,res);
00429 }
00430 
00431 void MEDCouplingFieldDiscretizationP0::getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const
00432 {
00433   const MEDCouplingCMesh *meshC=dynamic_cast<const MEDCouplingCMesh *>(mesh);
00434   if(!meshC)
00435     throw INTERP_KERNEL::Exception("P0::getValueOnPos is only accessible for structured meshes !");
00436   int id=meshC->getCellIdFromPos(i,j,k);
00437   arr->getTuple(id,res);
00438 }
00439 
00440 DataArrayDouble *MEDCouplingFieldDiscretizationP0::getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const
00441 {
00442   std::vector<int> elts,eltsIndex;
00443   mesh->getCellsContainingPoints(loc,nbOfPoints,_precision,elts,eltsIndex);
00444   int spaceDim=mesh->getSpaceDimension();
00445   int nbOfComponents=arr->getNumberOfComponents();
00446   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=DataArrayDouble::New();
00447   ret->alloc(nbOfPoints,nbOfComponents);
00448   double *ptToFill=ret->getPointer();
00449   for(int i=0;i<nbOfPoints;i++,ptToFill+=nbOfComponents)
00450     if(eltsIndex[i+1]-eltsIndex[i]>=1)
00451       arr->getTuple(elts[eltsIndex[i]],ptToFill);
00452     else
00453       {
00454         std::ostringstream oss; oss << "Point #" << i << " with coordinates : (";
00455         std::copy(loc+i*spaceDim,loc+(i+1)*spaceDim,std::ostream_iterator<double>(oss,", "));
00456         oss << ") detected outside mesh : unable to apply P0::getValueOnMulti ! ";
00457         throw INTERP_KERNEL::Exception(oss.str().c_str());
00458       }
00459   ret->incrRef();
00460   return ret;
00461 }
00462 
00466 void MEDCouplingFieldDiscretizationP0::renumberValuesOnNodes(double , const int *, DataArrayDouble *) const
00467 {
00468 }
00469 
00470 void MEDCouplingFieldDiscretizationP0::renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const
00471 {
00472   renumberEntitiesFromO2NArr(epsOnVals,old2New,arr,"Cell");
00473 }
00474 
00475 void MEDCouplingFieldDiscretizationP0::renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const int *new2old, int newSz, DataArrayDouble *arr) const
00476 {
00477   renumberEntitiesFromN2OArr(new2old,newSz,arr,"Cell");
00478 }
00479 
00485 MEDCouplingMesh *MEDCouplingFieldDiscretizationP0::buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const
00486 {
00487   MEDCouplingMesh *ret=mesh->buildPart(start,end);
00488   di=DataArrayInt::New();
00489   di->alloc((int)std::distance(start,end),1);
00490   int *pt=di->getPointer();
00491   std::copy(start,end,pt);
00492   return ret;
00493 }
00494 
00495 TypeOfField MEDCouplingFieldDiscretizationP1::getEnum() const
00496 {
00497   return TYPE;
00498 }
00499 
00500 MEDCouplingFieldDiscretization *MEDCouplingFieldDiscretizationP1::clone() const
00501 {
00502   return new MEDCouplingFieldDiscretizationP1;
00503 }
00504 
00505 std::string MEDCouplingFieldDiscretizationP1::getStringRepr() const
00506 {
00507   return std::string(REPR);
00508 }
00509 
00510 const char *MEDCouplingFieldDiscretizationP1::getRepr() const
00511 {
00512   return REPR;
00513 }
00514 
00515 bool MEDCouplingFieldDiscretizationP1::isEqual(const MEDCouplingFieldDiscretization *other, double eps) const
00516 {
00517   const MEDCouplingFieldDiscretizationP1 *otherC=dynamic_cast<const MEDCouplingFieldDiscretizationP1 *>(other);
00518   return otherC!=0;
00519 }
00520 
00524 void MEDCouplingFieldDiscretizationP1::renumberArraysForCell(const MEDCouplingMesh *, const std::vector<DataArrayDouble *>& arrays,
00525                                                              const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception)
00526 {
00527 }
00528 
00529 int MEDCouplingFieldDiscretizationP1::getNumberOfTuples(const MEDCouplingMesh *mesh) const
00530 {
00531   return mesh->getNumberOfNodes();
00532 }
00533 
00534 int MEDCouplingFieldDiscretizationP1::getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const
00535 {
00536   return mesh->getNumberOfNodes();
00537 }
00538 
00539 DataArrayInt *MEDCouplingFieldDiscretizationP1::getOffsetArr(const MEDCouplingMesh *mesh) const
00540 {
00541   int nbOfTuples=mesh->getNumberOfNodes();
00542   DataArrayInt *ret=DataArrayInt::New();
00543   ret->alloc(nbOfTuples+1,1);
00544   ret->iota(0);
00545   return ret;
00546 }
00547 
00548 DataArrayDouble *MEDCouplingFieldDiscretizationP1::getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const
00549 {
00550   return mesh->getCoordinatesAndOwner();
00551 }
00552 
00553 void MEDCouplingFieldDiscretizationP1::computeMeshRestrictionFromTupleIds(const MEDCouplingMesh *mesh, const int *partBg, const int *partEnd,
00554                                                                           DataArrayInt *&cellRest)
00555 {
00556   cellRest=mesh->getCellIdsFullyIncludedInNodeIds(partBg,partEnd);
00557 }
00558 
00559 void MEDCouplingFieldDiscretizationP1::checkCompatibilityWithNature(NatureOfField nat) const throw(INTERP_KERNEL::Exception)
00560 {
00561   if(nat!=ConservativeVolumic)
00562     throw INTERP_KERNEL::Exception("Invalid nature for P1 field !");
00563 }
00564 
00565 void MEDCouplingFieldDiscretizationP1::checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception)
00566 {
00567   if(mesh->getNumberOfNodes()!=da->getNumberOfTuples())
00568     {
00569       std::ostringstream message;
00570       message << "Field on nodes invalid because there are " << mesh->getNumberOfNodes();
00571       message << " nodes in mesh and " << da->getNumberOfTuples() << " tuples in field !";
00572       throw INTERP_KERNEL::Exception(message.str().c_str());
00573     }
00574 }
00575 
00576 MEDCouplingFieldDouble *MEDCouplingFieldDiscretizationP1::getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const
00577 {
00578   return mesh->getMeasureFieldOnNode(isAbs);
00579 }
00580 
00581 void MEDCouplingFieldDiscretizationP1::getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const
00582 {
00583   int id=mesh->getCellContainingPoint(loc,_precision);
00584   if(id==-1)
00585     throw INTERP_KERNEL::Exception("Specified point is detected outside of mesh : unable to apply P1::getValueOn !");
00586   INTERP_KERNEL::NormalizedCellType type=mesh->getTypeOfCell(id);
00587   if(type!=INTERP_KERNEL::NORM_SEG2 && type!=INTERP_KERNEL::NORM_TRI3 && type!=INTERP_KERNEL::NORM_TETRA4)
00588     throw INTERP_KERNEL::Exception("P1 getValueOn is not specified for not simplex cells !");
00589   getValueInCell(mesh,id,arr,loc,res);
00590 }
00591 
00596 void MEDCouplingFieldDiscretizationP1::getValueInCell(const MEDCouplingMesh *mesh, int cellId, const DataArrayDouble *arr, const double *loc, double *res) const
00597 {
00598   std::vector<int> conn;
00599   std::vector<double> coo;
00600   mesh->getNodeIdsOfCell(cellId,conn);
00601   for(std::vector<int>::const_iterator iter=conn.begin();iter!=conn.end();iter++)
00602     mesh->getCoordinatesOfNode(*iter,coo);
00603   int spaceDim=mesh->getSpaceDimension();
00604   std::size_t nbOfNodes=conn.size();
00605   std::vector<const double *> vec(nbOfNodes);
00606   for(std::size_t i=0;i<nbOfNodes;i++)
00607     vec[i]=&coo[i*spaceDim];
00608   INTERP_KERNEL::AutoPtr<double> tmp=new double[nbOfNodes];
00609   INTERP_KERNEL::barycentric_coords(vec,loc,tmp);
00610   int sz=arr->getNumberOfComponents();
00611   INTERP_KERNEL::AutoPtr<double> tmp2=new double[sz];
00612   std::fill(res,res+sz,0.);
00613   for(std::size_t i=0;i<nbOfNodes;i++)
00614     {
00615       arr->getTuple(conn[i],(double *)tmp2);
00616       std::transform((double *)tmp2,((double *)tmp2)+sz,(double *)tmp2,std::bind2nd(std::multiplies<double>(),tmp[i]));
00617       std::transform(res,res+sz,(double *)tmp2,res,std::plus<double>());
00618     }
00619 }
00620 
00621 void MEDCouplingFieldDiscretizationP1::getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const
00622 {
00623   const MEDCouplingCMesh *meshC=dynamic_cast<const MEDCouplingCMesh *>(mesh);
00624   if(!meshC)
00625     throw INTERP_KERNEL::Exception("P1::getValueOnPos is only accessible for structured meshes !");
00626   int id=meshC->getNodeIdFromPos(i,j,k);
00627   arr->getTuple(id,res);
00628 }
00629 
00630 DataArrayDouble *MEDCouplingFieldDiscretizationP1::getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const
00631 {
00632   std::vector<int> elts,eltsIndex;
00633   mesh->getCellsContainingPoints(loc,nbOfPoints,_precision,elts,eltsIndex);
00634   int spaceDim=mesh->getSpaceDimension();
00635   int nbOfComponents=arr->getNumberOfComponents();
00636   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=DataArrayDouble::New();
00637   ret->alloc(nbOfPoints,nbOfComponents);
00638   double *ptToFill=ret->getPointer();
00639   for(int i=0;i<nbOfPoints;i++)
00640     if(eltsIndex[i+1]-eltsIndex[i]>=1)
00641       getValueInCell(mesh,elts[eltsIndex[i]],arr,loc+i*spaceDim,ptToFill+i*nbOfComponents);
00642     else
00643       {
00644         std::ostringstream oss; oss << "Point #" << i << " with coordinates : (";
00645         std::copy(loc+i*spaceDim,loc+(i+1)*spaceDim,std::ostream_iterator<double>(oss,", "));
00646         oss << ") detected outside mesh : unable to apply P1::getValueOnMulti ! ";
00647         throw INTERP_KERNEL::Exception(oss.str().c_str());
00648       }
00649   ret->incrRef();
00650   return ret;
00651 }
00652 
00653 void MEDCouplingFieldDiscretizationP1::renumberValuesOnNodes(double epsOnVals, const int *old2NewPtr, DataArrayDouble *arr) const
00654 {
00655   renumberEntitiesFromO2NArr(epsOnVals,old2NewPtr,arr,"Node");
00656 }
00657 
00661 void MEDCouplingFieldDiscretizationP1::renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const
00662 {
00663 }
00664 
00668 void MEDCouplingFieldDiscretizationP1::renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const int *new2old, int newSz, DataArrayDouble *arr) const
00669 {
00670 }
00671 
00677 MEDCouplingMesh *MEDCouplingFieldDiscretizationP1::buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const
00678 {
00679   MEDCouplingMesh *ret=mesh->buildPartAndReduceNodes(start,end,di);
00680   DataArrayInt *di2=di->invertArrayO2N2N2O(ret->getNumberOfNodes());
00681   di->decrRef();
00682   di=di2;
00683   return ret;
00684 }
00685 
00686 MEDCouplingFieldDiscretizationPerCell::MEDCouplingFieldDiscretizationPerCell():_discr_per_cell(0)
00687 {
00688 }
00689 
00690 MEDCouplingFieldDiscretizationPerCell::~MEDCouplingFieldDiscretizationPerCell()
00691 {
00692   if(_discr_per_cell)
00693     _discr_per_cell->decrRef();
00694 }
00695 
00696 MEDCouplingFieldDiscretizationPerCell::MEDCouplingFieldDiscretizationPerCell(const MEDCouplingFieldDiscretizationPerCell& other):_discr_per_cell(0)
00697 {
00698   DataArrayInt *arr=other._discr_per_cell;
00699   if(arr)
00700     _discr_per_cell=arr->deepCpy();
00701 }
00702 
00703 void MEDCouplingFieldDiscretizationPerCell::updateTime() const
00704 {
00705   if(_discr_per_cell)
00706     updateTimeWith(*_discr_per_cell);
00707 }
00708 
00709 void MEDCouplingFieldDiscretizationPerCell::checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception)
00710 {
00711   if(!_discr_per_cell)
00712     throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationPerCell has no discretization per cell !");
00713   int nbOfTuples=_discr_per_cell->getNumberOfTuples();
00714   if(nbOfTuples!=mesh->getNumberOfCells())
00715     throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationPerCell has a discretization per cell but it's not matching the underlying mesh !");
00716 }
00717 
00718 bool MEDCouplingFieldDiscretizationPerCell::isEqual(const MEDCouplingFieldDiscretization *other, double eps) const
00719 {
00720   const MEDCouplingFieldDiscretizationPerCell *otherC=dynamic_cast<const MEDCouplingFieldDiscretizationPerCell *>(other);
00721   if(!otherC)
00722     return false;
00723   if(_discr_per_cell==0)
00724     return otherC->_discr_per_cell==0;
00725   if(otherC->_discr_per_cell==0)
00726     return false;
00727   return _discr_per_cell->isEqual(*otherC->_discr_per_cell);
00728 }
00729 
00730 bool MEDCouplingFieldDiscretizationPerCell::isEqualWithoutConsideringStr(const MEDCouplingFieldDiscretization *other, double eps) const
00731 {
00732   const MEDCouplingFieldDiscretizationPerCell *otherC=dynamic_cast<const MEDCouplingFieldDiscretizationPerCell *>(other);
00733   if(!otherC)
00734     return false;
00735   if(_discr_per_cell==0)
00736     return otherC->_discr_per_cell==0;
00737   if(otherC->_discr_per_cell==0)
00738     return false;
00739   return _discr_per_cell->isEqualWithoutConsideringStr(*otherC->_discr_per_cell);
00740 }
00741 
00746 void MEDCouplingFieldDiscretizationPerCell::renumberCells(const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception)
00747 {
00748   int nbCells=_discr_per_cell->getNumberOfTuples();
00749   const int *array=old2NewBg;
00750   if(check)
00751     array=DataArrayInt::CheckAndPreparePermutation(old2NewBg,old2NewBg+nbCells);
00752   //
00753   DataArrayInt *dpc=_discr_per_cell->renumber(array);
00754   _discr_per_cell->decrRef();
00755   _discr_per_cell=dpc;
00756   //
00757   if(check)
00758     delete [] const_cast<int *>(array);
00759 }
00760 
00761 void MEDCouplingFieldDiscretizationPerCell::buildDiscrPerCellIfNecessary(const MEDCouplingMesh *m)
00762 {
00763   if(!_discr_per_cell)
00764     {
00765       _discr_per_cell=DataArrayInt::New();
00766       int nbTuples=m->getNumberOfCells();
00767       _discr_per_cell->alloc(nbTuples,1);
00768       int *ptr=_discr_per_cell->getPointer();
00769       std::fill(ptr,ptr+nbTuples,DFT_INVALID_LOCID_VALUE);
00770     }
00771 }
00772 
00773 void MEDCouplingFieldDiscretizationPerCell::checkNoOrphanCells() const throw(INTERP_KERNEL::Exception)
00774 {
00775   if(!_discr_per_cell)
00776     throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationPerCell::checkNoOrphanCells : no discretization defined !");
00777   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> test=_discr_per_cell->getIdsEqual(DFT_INVALID_LOCID_VALUE);
00778   if(test->getNumberOfTuples()!=0)
00779     throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationPerCell::checkNoOrphanCells : presence of orphan cells !");
00780 }
00781 
00782 const DataArrayInt *MEDCouplingFieldDiscretizationPerCell::getArrayOfDiscIds() const
00783 {
00784   return _discr_per_cell;
00785 }
00786 
00787 MEDCouplingFieldDiscretizationGauss::MEDCouplingFieldDiscretizationGauss()
00788 {
00789 }
00790 
00791 MEDCouplingFieldDiscretizationGauss::MEDCouplingFieldDiscretizationGauss(const MEDCouplingFieldDiscretizationGauss& other):MEDCouplingFieldDiscretizationPerCell(other),_loc(other._loc)
00792 {
00793 }
00794 
00795 TypeOfField MEDCouplingFieldDiscretizationGauss::getEnum() const
00796 {
00797   return TYPE;
00798 }
00799 
00800 bool MEDCouplingFieldDiscretizationGauss::isEqual(const MEDCouplingFieldDiscretization *other, double eps) const
00801 {
00802   const MEDCouplingFieldDiscretizationGauss *otherC=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(other);
00803   if(!otherC)
00804     return false;
00805   if(!MEDCouplingFieldDiscretizationPerCell::isEqual(other,eps))
00806     return false;
00807   if(_loc.size()!=otherC->_loc.size())
00808     return false;
00809   std::size_t sz=_loc.size();
00810   for(std::size_t i=0;i<sz;i++)
00811     if(!_loc[i].isEqual(otherC->_loc[i],eps))
00812       return false;
00813   return true;
00814 }
00815 
00816 bool MEDCouplingFieldDiscretizationGauss::isEqualWithoutConsideringStr(const MEDCouplingFieldDiscretization *other, double eps) const
00817 {
00818   const MEDCouplingFieldDiscretizationGauss *otherC=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(other);
00819   if(!otherC)
00820     return false;
00821   if(!MEDCouplingFieldDiscretizationPerCell::isEqualWithoutConsideringStr(other,eps))
00822     return false;
00823   if(_loc.size()!=otherC->_loc.size())
00824     return false;
00825   std::size_t sz=_loc.size();
00826   for(std::size_t i=0;i<sz;i++)
00827     if(!_loc[i].isEqual(otherC->_loc[i],eps))
00828       return false;
00829   return true;
00830 }
00831 
00832 MEDCouplingFieldDiscretization *MEDCouplingFieldDiscretizationGauss::clone() const
00833 {
00834   return new MEDCouplingFieldDiscretizationGauss(*this);
00835 }
00836 
00837 std::string MEDCouplingFieldDiscretizationGauss::getStringRepr() const
00838 {
00839   std::ostringstream oss; oss << REPR << "." << std::endl;
00840   if(_discr_per_cell)
00841     {
00842       if(_discr_per_cell->isAllocated())
00843         {
00844           oss << "Discretization per cell : ";
00845           std::copy(_discr_per_cell->begin(),_discr_per_cell->end(),std::ostream_iterator<int>(oss,", "));
00846           oss << std::endl;
00847         }
00848     }
00849   oss << "Presence of " << _loc.size() << " localizations." << std::endl;
00850   int i=0;
00851   for(std::vector<MEDCouplingGaussLocalization>::const_iterator it=_loc.begin();it!=_loc.end();it++,i++)
00852     {
00853       oss << "+++++ Localization #" << i << " +++++" << std::endl;
00854       oss << (*it).getStringRepr();
00855       oss << "++++++++++" << std::endl;
00856     }
00857   return oss.str();
00858 }
00859 
00860 const char *MEDCouplingFieldDiscretizationGauss::getRepr() const
00861 {
00862   return REPR;
00863 }
00864 
00865 int MEDCouplingFieldDiscretizationGauss::getNumberOfTuples(const MEDCouplingMesh *) const
00866 {
00867   int ret=0;
00868   const int *dcPtr=_discr_per_cell->getConstPointer();
00869   int nbOfTuples=_discr_per_cell->getNumberOfTuples();
00870   for(const int *w=dcPtr;w!=dcPtr+nbOfTuples;w++)
00871     ret+=_loc[*w].getNumberOfGaussPt();
00872   return ret;
00873 }
00874 
00875 int MEDCouplingFieldDiscretizationGauss::getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const
00876 {
00877   return mesh->getNumberOfCells();
00878 }
00879 
00880 DataArrayInt *MEDCouplingFieldDiscretizationGauss::getOffsetArr(const MEDCouplingMesh *mesh) const
00881 {
00882   int nbOfTuples=mesh->getNumberOfCells();
00883   DataArrayInt *ret=DataArrayInt::New();
00884   ret->alloc(nbOfTuples+1,1);
00885   int *retPtr=ret->getPointer();
00886   const int *start=_discr_per_cell->getConstPointer();
00887   retPtr[0]=0;
00888   for(int i=0;i<nbOfTuples;i++,start++)
00889     retPtr[i+1]=retPtr[i]+_loc[*start].getNumberOfGaussPt();
00890   return ret;
00891 }
00892 
00893 void MEDCouplingFieldDiscretizationGauss::renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector<DataArrayDouble *>& arrays,
00894                                                                 const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception)
00895 {
00896   const int *array=old2NewBg;
00897   if(check)
00898     array=DataArrayInt::CheckAndPreparePermutation(old2NewBg,old2NewBg+mesh->getNumberOfCells());
00899   int nbOfCells=_discr_per_cell->getNumberOfTuples();
00900   int nbOfTuples=getNumberOfTuples(0);
00901   const int *dcPtr=_discr_per_cell->getConstPointer();
00902   int *array2=new int[nbOfTuples];//stores the final conversion array old2New to give to arrays in renumberInPlace.
00903   int *array3=new int[nbOfCells];//store for each cell in present dcp array (already renumbered) the offset needed by each cell in new numbering.
00904   array3[0]=0;
00905   for(int i=1;i<nbOfCells;i++)
00906     array3[i]=array3[i-1]+_loc[dcPtr[i-1]].getNumberOfGaussPt();
00907   int j=0;
00908   for(int i=0;i<nbOfCells;i++)
00909     {
00910       int nbOfGaussPt=_loc[dcPtr[array[i]]].getNumberOfGaussPt();
00911       for(int k=0;k<nbOfGaussPt;k++,j++)
00912         array2[j]=array3[array[i]]+k;
00913     }
00914   delete [] array3;
00915   for(std::vector<DataArrayDouble *>::const_iterator it=arrays.begin();it!=arrays.end();it++)
00916     if(*it)
00917       (*it)->renumberInPlace(array2);
00918   delete [] array2;
00919   if(check)
00920     delete [] const_cast<int*>(array);
00921 }
00922 
00923 DataArrayDouble *MEDCouplingFieldDiscretizationGauss::getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const
00924 {
00925   checkNoOrphanCells();
00926   MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> umesh=mesh->buildUnstructured();//in general do nothing
00927   int nbOfTuples=getNumberOfTuples(mesh);
00928   DataArrayDouble *ret=DataArrayDouble::New();
00929   int spaceDim=mesh->getSpaceDimension();
00930   ret->alloc(nbOfTuples,spaceDim);
00931   std::vector< std::vector<int> > locIds;
00932   std::vector<DataArrayInt *> parts=splitIntoSingleGaussDicrPerCellType(locIds);
00933   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > parts2(parts.size());
00934   std::copy(parts.begin(),parts.end(),parts2.begin());
00935   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> offsets=buildNbOfGaussPointPerCellField();
00936   offsets->computeOffsets();
00937   const int *ptrOffsets=offsets->getConstPointer();
00938   const double *coords=umesh->getCoords()->getConstPointer();
00939   const int *connI=umesh->getNodalConnectivityIndex()->getConstPointer();
00940   const int *conn=umesh->getNodalConnectivity()->getConstPointer();
00941   double *valsToFill=ret->getPointer();
00942   for(std::size_t i=0;i<parts2.size();i++)
00943     {
00944       INTERP_KERNEL::GaussCoords calculator;
00945       for(std::vector<int>::const_iterator it=locIds[i].begin();it!=locIds[i].end();it++)
00946         {
00947           const MEDCouplingGaussLocalization& cli=_loc[*it];//curLocInfo
00948           INTERP_KERNEL::NormalizedCellType typ=cli.getType();
00949           const std::vector<double>& wg=cli.getWeights();
00950           calculator.addGaussInfo(typ,INTERP_KERNEL::CellModel::GetCellModel(typ).getDimension(),
00951                                   &cli.getGaussCoords()[0],(int)wg.size(),&cli.getRefCoords()[0],
00952                                   INTERP_KERNEL::CellModel::GetCellModel(typ).getNumberOfNodes());
00953         }
00954       int nbt=parts2[i]->getNumberOfTuples();
00955       for(const int *w=parts2[i]->getConstPointer();w!=parts2[i]->getConstPointer()+nbt;w++)
00956         {
00957           const MEDCouplingGaussLocalization& cli=_loc[*w];
00958           calculator.calculateCoords(cli.getType(),coords,spaceDim,conn+connI[*w]+1,valsToFill+spaceDim*(ptrOffsets[*w]));
00959         }
00960     }
00961   ret->copyStringInfoFrom(*umesh->getCoords());
00962   return ret;
00963 }
00964 
00965 void MEDCouplingFieldDiscretizationGauss::computeMeshRestrictionFromTupleIds(const MEDCouplingMesh *mesh, const int *partBg, const int *partEnd,
00966                                                                              DataArrayInt *&cellRest)
00967 {
00968   throw INTERP_KERNEL::Exception("Not implemented yet !");
00969 }
00970 
00974 void MEDCouplingFieldDiscretizationGauss::checkCompatibilityWithNature(NatureOfField nat) const throw(INTERP_KERNEL::Exception)
00975 {
00976 }
00977 
00978 void MEDCouplingFieldDiscretizationGauss::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const
00979 {
00980   int val=-1;
00981   if(_discr_per_cell)
00982     val=_discr_per_cell->getNumberOfTuples();
00983   tinyInfo.push_back(val);
00984   tinyInfo.push_back((int)_loc.size());
00985   if(_loc.empty())
00986     tinyInfo.push_back(-1);
00987   else
00988     tinyInfo.push_back(_loc[0].getDimension());
00989   for(std::vector<MEDCouplingGaussLocalization>::const_iterator iter=_loc.begin();iter!=_loc.end();iter++)
00990     (*iter).pushTinySerializationIntInfo(tinyInfo);
00991 }
00992 
00993 void MEDCouplingFieldDiscretizationGauss::getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const
00994 {
00995   for(std::vector<MEDCouplingGaussLocalization>::const_iterator iter=_loc.begin();iter!=_loc.end();iter++)
00996     (*iter).pushTinySerializationDblInfo(tinyInfo);
00997 }
00998 
00999 void MEDCouplingFieldDiscretizationGauss::getSerializationIntArray(DataArrayInt *& arr) const
01000 {
01001   arr=0;
01002   if(_discr_per_cell)
01003     arr=_discr_per_cell;
01004 }
01005 
01006 void MEDCouplingFieldDiscretizationGauss::resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *& arr)
01007 {
01008   int val=tinyInfo[0];
01009   if(val>=0)
01010     {
01011       _discr_per_cell=DataArrayInt::New();
01012       _discr_per_cell->alloc(val,1);
01013     }
01014   else
01015     _discr_per_cell=0;
01016   arr=_discr_per_cell;
01017   int nbOfLoc=tinyInfo[1];
01018   _loc.clear();
01019   int dim=tinyInfo[2];
01020   int delta=-1;
01021   if(nbOfLoc>0)
01022     delta=((int)tinyInfo.size()-3)/nbOfLoc;
01023   for(int i=0;i<nbOfLoc;i++)
01024     {
01025       std::vector<int> tmp(tinyInfo.begin()+3+i*delta,tinyInfo.begin()+3+(i+1)*delta);
01026       MEDCouplingGaussLocalization elt=MEDCouplingGaussLocalization::BuildNewInstanceFromTinyInfo(dim,tmp);
01027       _loc.push_back(elt);
01028     }
01029 }
01030 
01031 void MEDCouplingFieldDiscretizationGauss::finishUnserialization(const std::vector<double>& tinyInfo)
01032 {
01033   double *tmp=new double[tinyInfo.size()];
01034   std::copy(tinyInfo.begin(),tinyInfo.end(),tmp);
01035   const double *work=tmp;
01036   for(std::vector<MEDCouplingGaussLocalization>::iterator iter=_loc.begin();iter!=_loc.end();iter++)
01037     work=(*iter).fillWithValues(work);
01038   delete [] tmp;
01039 }
01040 
01041 double MEDCouplingFieldDiscretizationGauss::getIJK(const MEDCouplingMesh *mesh, const DataArrayDouble *da,
01042                                                    int cellId, int nodeIdInCell, int compoId) const throw(INTERP_KERNEL::Exception)
01043 {
01044   int offset=getOffsetOfCell(cellId);
01045   return da->getIJ(offset+nodeIdInCell,compoId);
01046 }
01047 
01048 void MEDCouplingFieldDiscretizationGauss::checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception)
01049 {
01050   MEDCouplingFieldDiscretizationPerCell::checkCoherencyBetween(mesh,da);
01051   for(std::vector<MEDCouplingGaussLocalization>::const_iterator iter=_loc.begin();iter!=_loc.end();iter++)
01052     (*iter).checkCoherency();
01053   int nbOfDesc=(int)_loc.size();
01054   int nbOfCells=mesh->getNumberOfCells();
01055   const int *dc=_discr_per_cell->getConstPointer();
01056   for(int i=0;i<nbOfCells;i++)
01057     {
01058       if(dc[i]>=nbOfDesc)
01059         {
01060           std::ostringstream oss; oss << "Cell # " << i << " of mesh \"" << mesh->getName() << "\" has an undefined gauss location ! Should never happend !";
01061           throw INTERP_KERNEL::Exception(oss.str().c_str());
01062         }
01063       if(dc[i]<0)
01064         {
01065           std::ostringstream oss; oss << "Cell # " << i << " of mesh \"" << mesh->getName() << "\" has no gauss location !";
01066           throw INTERP_KERNEL::Exception(oss.str().c_str());
01067         }
01068       if(mesh->getTypeOfCell(i)!=_loc[dc[i]].getType())
01069         {
01070           std::ostringstream oss; oss << "Types of mesh and gauss location mismatch for cell # " << i;
01071           throw INTERP_KERNEL::Exception(oss.str().c_str());
01072         }
01073     }
01074   int nbOfTuples=getNumberOfTuples(mesh);
01075   if(nbOfTuples!=da->getNumberOfTuples())
01076     {
01077       std::ostringstream oss; oss << "Invalid number of tuples in the array : expecting " << nbOfTuples << " !";
01078       throw INTERP_KERNEL::Exception(oss.str().c_str());
01079     }
01080 }
01081 
01082 MEDCouplingFieldDouble *MEDCouplingFieldDiscretizationGauss::getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const
01083 {
01084   throw INTERP_KERNEL::Exception("Not implemented yet !");
01085 }
01086 
01087 void MEDCouplingFieldDiscretizationGauss::getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const
01088 {
01089   throw INTERP_KERNEL::Exception("Not implemented yet !");
01090 }
01091 
01092 void MEDCouplingFieldDiscretizationGauss::getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const
01093 {
01094   throw INTERP_KERNEL::Exception("getValueOnPos(i,j,k) : Not applyable for Gauss points !");
01095 }
01096 
01097 DataArrayDouble *MEDCouplingFieldDiscretizationGauss::getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const
01098 {
01099   throw INTERP_KERNEL::Exception("getValueOnMulti : Not implemented yet for gauss points !");
01100 }
01101 
01102 MEDCouplingMesh *MEDCouplingFieldDiscretizationGauss::buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const
01103 {
01104   throw INTERP_KERNEL::Exception("Not implemented yet !");
01105 }
01106 
01110 void MEDCouplingFieldDiscretizationGauss::renumberValuesOnNodes(double , const int *, DataArrayDouble *) const
01111 {
01112 }
01113 
01114 void MEDCouplingFieldDiscretizationGauss::renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const
01115 {
01116   throw INTERP_KERNEL::Exception("Not implemented yet !");
01117 }
01118 
01119 void MEDCouplingFieldDiscretizationGauss::renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const int *new2old, int newSz, DataArrayDouble *arr) const
01120 {
01121   throw INTERP_KERNEL::Exception("Number of cells has changed and becomes higher with some cells that have been split ! Unable to conserve the Gauss field !");
01122 }
01123 
01124 void MEDCouplingFieldDiscretizationGauss::setGaussLocalizationOnType(const MEDCouplingMesh *m, INTERP_KERNEL::NormalizedCellType type, const std::vector<double>& refCoo,
01125                                                                      const std::vector<double>& gsCoo, const std::vector<double>& wg) throw(INTERP_KERNEL::Exception)
01126 {
01127   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(type);
01128   if((int)cm.getDimension()!=m->getMeshDimension())
01129     {
01130       std::ostringstream oss; oss << "MEDCouplingFieldDiscretizationGauss::setGaussLocalizationOnType : mismatch of dimensions ! MeshDim==" << m->getMeshDimension();
01131       oss << " whereas Type '" << cm.getRepr() << "' has dimension " << cm.getDimension() << " !";
01132       throw INTERP_KERNEL::Exception(oss.str().c_str());
01133     }
01134   buildDiscrPerCellIfNecessary(m);
01135   int id=(int)_loc.size();
01136   MEDCouplingGaussLocalization elt(type,refCoo,gsCoo,wg);
01137   _loc.push_back(elt);
01138   int *ptr=_discr_per_cell->getPointer();
01139   int nbCells=m->getNumberOfCells();
01140   for(int i=0;i<nbCells;i++)
01141     if(m->getTypeOfCell(i)==type)
01142       ptr[i]=id;
01143   zipGaussLocalizations();
01144 }
01145 
01146 void MEDCouplingFieldDiscretizationGauss::setGaussLocalizationOnCells(const MEDCouplingMesh *m, const int *begin, const int *end, const std::vector<double>& refCoo,
01147                                                                       const std::vector<double>& gsCoo, const std::vector<double>& wg) throw(INTERP_KERNEL::Exception)
01148 {
01149   buildDiscrPerCellIfNecessary(m);
01150   if(std::distance(begin,end)<1)
01151     throw INTERP_KERNEL::Exception("Size of [begin,end) must be equal or greater than 1 !");
01152   INTERP_KERNEL::NormalizedCellType type=m->getTypeOfCell(*begin);
01153   MEDCouplingGaussLocalization elt(type,refCoo,gsCoo,wg);
01154   int id=(int)_loc.size();
01155   int *ptr=_discr_per_cell->getPointer();
01156   for(const int *w=begin+1;w!=end;w++)
01157     {
01158       if(m->getTypeOfCell(*w)!=type)
01159         {
01160           std::ostringstream oss; oss << "The cell with id " << *w << " has been detected to be incompatible in the [begin,end) array specified !";
01161           throw INTERP_KERNEL::Exception(oss.str().c_str());
01162         }
01163     }
01164   //
01165   for(const int *w2=begin;w2!=end;w2++)
01166     ptr[*w2]=id;
01167   //
01168   _loc.push_back(elt);
01169   zipGaussLocalizations();
01170 }
01171 
01172 void MEDCouplingFieldDiscretizationGauss::clearGaussLocalizations() throw(INTERP_KERNEL::Exception)
01173 {
01174   if(_discr_per_cell)
01175     {
01176       _discr_per_cell->decrRef();
01177       _discr_per_cell=0;
01178     }
01179   _loc.clear();
01180 }
01181 
01182 MEDCouplingGaussLocalization& MEDCouplingFieldDiscretizationGauss::getGaussLocalization(int locId) throw(INTERP_KERNEL::Exception)
01183 {
01184   checkLocalizationId(locId);
01185   return _loc[locId];
01186 }
01187 
01188 int MEDCouplingFieldDiscretizationGauss::getNbOfGaussLocalization() const throw(INTERP_KERNEL::Exception)
01189 {
01190   return (int)_loc.size();
01191 }
01192 
01193 int MEDCouplingFieldDiscretizationGauss::getGaussLocalizationIdOfOneCell(int cellId) const throw(INTERP_KERNEL::Exception)
01194 {
01195   if(!_discr_per_cell)
01196     throw INTERP_KERNEL::Exception("No Gauss localization still set !");
01197   int locId=_discr_per_cell->getConstPointer()[cellId];
01198   if(locId<0)
01199     throw INTERP_KERNEL::Exception("No Gauss localization set for the specified cell !");
01200   return locId;
01201 }
01202 
01203 int MEDCouplingFieldDiscretizationGauss::getGaussLocalizationIdOfOneType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception)
01204 {
01205   if(!_discr_per_cell)
01206     throw INTERP_KERNEL::Exception("No Gauss localization still set !");
01207   std::set<int> ret;
01208   int id=0;
01209   for(std::vector<MEDCouplingGaussLocalization>::const_iterator iter=_loc.begin();iter!=_loc.end();iter++,id++)
01210     if((*iter).getType()==type)
01211       ret.insert(id);
01212   if(ret.empty())
01213     throw INTERP_KERNEL::Exception("No gauss discretization found for the specified type !");
01214   if(ret.size()>1)
01215     throw INTERP_KERNEL::Exception("Several gauss discretizations have been found for the specified type !");
01216   return *ret.begin();
01217 }
01218 
01219 void MEDCouplingFieldDiscretizationGauss::getCellIdsHavingGaussLocalization(int locId, std::vector<int>& cellIds) const throw(INTERP_KERNEL::Exception)
01220 {
01221   if(locId<0 || locId>=(int)_loc.size())
01222     throw INTERP_KERNEL::Exception("Invalid locId given : must be in range [0:getNbOfGaussLocalization()) !");
01223   int nbOfTuples=_discr_per_cell->getNumberOfTuples();
01224   const int *ptr=_discr_per_cell->getConstPointer();
01225   for(int i=0;i<nbOfTuples;i++)
01226     if(ptr[i]==locId)
01227       cellIds.push_back(i);
01228 }
01229 
01230 const MEDCouplingGaussLocalization& MEDCouplingFieldDiscretizationGauss::getGaussLocalization(int locId) const throw(INTERP_KERNEL::Exception)
01231 {
01232   checkLocalizationId(locId);
01233   return _loc[locId];
01234 }
01235 
01236 void MEDCouplingFieldDiscretizationGauss::checkLocalizationId(int locId) const throw(INTERP_KERNEL::Exception)
01237 {
01238   if(locId<0 || locId>=(int)_loc.size())
01239     throw INTERP_KERNEL::Exception("Invalid locId given : must be in range [0:getNbOfGaussLocalization()) !");
01240 }
01241 
01242 int MEDCouplingFieldDiscretizationGauss::getOffsetOfCell(int cellId) const throw(INTERP_KERNEL::Exception)
01243 {
01244   int ret=0;
01245   const int *start=_discr_per_cell->getConstPointer();
01246   for(const int *w=start;w!=start+cellId;w++)
01247     ret+=_loc[*w].getNumberOfGaussPt();
01248   return ret;
01249 }
01250 
01257 DataArrayInt *MEDCouplingFieldDiscretizationGauss::buildNbOfGaussPointPerCellField() const throw(INTERP_KERNEL::Exception)
01258 {
01259   if(!_discr_per_cell)
01260     throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGauss::buildNbOfGaussPointPerCellField : no discretization array set !");
01261   int nbOfTuples=_discr_per_cell->getNumberOfTuples();
01262   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=DataArrayInt::New();
01263   const int *w=_discr_per_cell->getConstPointer();
01264   ret->alloc(nbOfTuples,1);
01265   int *valsToFill=ret->getPointer();
01266   for(int i=0;i<nbOfTuples;i++,w++)
01267     if(*w!=DFT_INVALID_LOCID_VALUE)
01268       valsToFill[i]=_loc[*w].getNumberOfGaussPt();
01269     else
01270       throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGauss::buildNbOfGaussPointPerCellField : orphan cell detected !");
01271   ret->incrRef();
01272   return ret;
01273 }
01274 
01280 void MEDCouplingFieldDiscretizationGauss::zipGaussLocalizations()
01281 {
01282   const int *start=_discr_per_cell->getConstPointer();
01283   int nbOfTuples=_discr_per_cell->getNumberOfTuples();
01284   int *tmp=new int[_loc.size()];
01285   std::fill(tmp,tmp+_loc.size(),-2);
01286   for(const int *w=start;w!=start+nbOfTuples;w++)
01287     if(*w>=0)
01288       tmp[*w]=1;
01289   int fid=0;
01290   for(int i=0;i<(int)_loc.size();i++)
01291     if(tmp[i]!=-2)
01292       tmp[i]=fid++;
01293   if(fid==(int)_loc.size())
01294     {//no zip needed
01295       delete [] tmp;
01296       return;
01297     }
01298   // zip needed
01299   int *start2=_discr_per_cell->getPointer();
01300   for(int *w2=start2;w2!=start2+nbOfTuples;w2++)
01301     *w2=tmp[*w2];
01302   std::vector<MEDCouplingGaussLocalization> tmpLoc;
01303   for(int i=0;i<(int)_loc.size();i++)
01304     if(tmp[i]!=-2)
01305       tmpLoc.push_back(_loc[tmp[i]]);
01306   delete [] tmp;
01307   _loc=tmpLoc;
01308 }
01309 
01320 std::vector<DataArrayInt *> MEDCouplingFieldDiscretizationGauss::splitIntoSingleGaussDicrPerCellType(std::vector< std::vector<int> >& locIds) const throw(INTERP_KERNEL::Exception)
01321 {
01322   if(!_discr_per_cell)
01323     throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGauss::splitIntoSingleGaussDicrPerCellType : no descretization set !");
01324   locIds.clear();
01325   std::vector<DataArrayInt *> ret;
01326   const int *discrPerCell=_discr_per_cell->getConstPointer();
01327   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret2=_discr_per_cell->getIdsNotEqual(-1);
01328   int nbOfTuplesSet=ret2->getNumberOfTuples();
01329   std::list<int> idsRemaining(ret2->getConstPointer(),ret2->getConstPointer()+nbOfTuplesSet);
01330   std::list<int>::iterator it=idsRemaining.begin();
01331   while(it!=idsRemaining.end())
01332     {
01333       std::vector<int> ids;
01334       std::set<int> curLocIds;
01335       std::set<INTERP_KERNEL::NormalizedCellType> curCellTypes;
01336       while(it!=idsRemaining.end())
01337         {
01338           int curDiscrId=discrPerCell[*it];
01339           INTERP_KERNEL::NormalizedCellType typ=_loc[curDiscrId].getType();
01340           if(curCellTypes.find(typ)!=curCellTypes.end())
01341             {
01342               if(curLocIds.find(curDiscrId)!=curLocIds.end())
01343                 {
01344                   curLocIds.insert(curDiscrId);
01345                   curCellTypes.insert(typ);
01346                   ids.push_back(*it);
01347                   it=idsRemaining.erase(it);
01348                 }
01349               else
01350                 it++;
01351             }
01352           else
01353             {
01354               curLocIds.insert(curDiscrId);
01355               curCellTypes.insert(typ);
01356               ids.push_back(*it);
01357               it=idsRemaining.erase(it);
01358             }
01359         }
01360       it=idsRemaining.begin();
01361       ret.resize(ret.size()+1);
01362       DataArrayInt *part=DataArrayInt::New();
01363       part->alloc((int)ids.size(),1);
01364       std::copy(ids.begin(),ids.end(),part->getPointer());
01365       ret.back()=part;
01366       locIds.resize(locIds.size()+1);
01367       locIds.back().insert(locIds.back().end(),curLocIds.begin(),curLocIds.end());
01368     }
01369   return ret;
01370 }
01371 
01372 MEDCouplingFieldDiscretizationGaussNE::MEDCouplingFieldDiscretizationGaussNE()
01373 {
01374 }
01375 
01376 TypeOfField MEDCouplingFieldDiscretizationGaussNE::getEnum() const
01377 {
01378   return TYPE;
01379 }
01380 
01381 MEDCouplingFieldDiscretization *MEDCouplingFieldDiscretizationGaussNE::clone() const
01382 {
01383   return new MEDCouplingFieldDiscretizationGaussNE(*this);
01384 }
01385 
01386 std::string MEDCouplingFieldDiscretizationGaussNE::getStringRepr() const
01387 {
01388   return std::string(REPR);
01389 }
01390 
01391 const char *MEDCouplingFieldDiscretizationGaussNE::getRepr() const
01392 {
01393   return REPR;
01394 }
01395 
01396 bool MEDCouplingFieldDiscretizationGaussNE::isEqual(const MEDCouplingFieldDiscretization *other, double eps) const
01397 {
01398   const MEDCouplingFieldDiscretizationGaussNE *otherC=dynamic_cast<const MEDCouplingFieldDiscretizationGaussNE *>(other);
01399   return otherC!=0;
01400 }
01401 
01402 int MEDCouplingFieldDiscretizationGaussNE::getNumberOfTuples(const MEDCouplingMesh *mesh) const
01403 {
01404   int ret=0;
01405   int nbOfCells=mesh->getNumberOfCells();
01406   for(int i=0;i<nbOfCells;i++)
01407     {
01408       INTERP_KERNEL::NormalizedCellType type=mesh->getTypeOfCell(i);
01409       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(type);
01410       if(cm.isDynamic())
01411         throw INTERP_KERNEL::Exception("Not implemented yet Gauss node on elements for polygons and polyedrons !");
01412       ret+=cm.getNumberOfNodes();
01413     }
01414   return ret;
01415 }
01416 
01417 int MEDCouplingFieldDiscretizationGaussNE::getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const
01418 {
01419   return mesh->getNumberOfCells();
01420 }
01421 
01422 DataArrayInt *MEDCouplingFieldDiscretizationGaussNE::getOffsetArr(const MEDCouplingMesh *mesh) const
01423 {
01424   int nbOfTuples=mesh->getNumberOfCells();
01425   DataArrayInt *ret=DataArrayInt::New();
01426   ret->alloc(nbOfTuples+1,1);
01427   int *retPtr=ret->getPointer();
01428   retPtr[0]=0;
01429   for(int i=0;i<nbOfTuples;i++)
01430     {
01431       INTERP_KERNEL::NormalizedCellType type=mesh->getTypeOfCell(i);
01432       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(type);
01433       if(cm.isDynamic())
01434         throw INTERP_KERNEL::Exception("Not implemented yet Gauss node on elements for polygons and polyedrons !");
01435       retPtr[i+1]=retPtr[i]+cm.getNumberOfNodes();
01436     }
01437   return ret;
01438 }
01439 
01440 void MEDCouplingFieldDiscretizationGaussNE::renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector<DataArrayDouble *>& arrays,
01441                                                                   const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception)
01442 {
01443   const int *array=old2NewBg;
01444   if(check)
01445     array=DataArrayInt::CheckAndPreparePermutation(old2NewBg,old2NewBg+mesh->getNumberOfCells());
01446   int nbOfCells=mesh->getNumberOfCells();
01447   int nbOfTuples=getNumberOfTuples(mesh);
01448   int *array2=new int[nbOfTuples];//stores the final conversion array old2New to give to arrays in renumberInPlace.
01449   int *array3=new int[nbOfCells];//store for each cell in after renumbering the offset needed by each cell in new numbering.
01450   array3[0]=0;
01451   for(int i=1;i<nbOfCells;i++)
01452     {
01453       INTERP_KERNEL::NormalizedCellType type=mesh->getTypeOfCell((int)std::distance(array,std::find(array,array+nbOfCells,i-1)));
01454       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(type);
01455       array3[i]=array3[i-1]+cm.getNumberOfNodes();
01456     }
01457   int j=0;
01458   for(int i=0;i<nbOfCells;i++)
01459     {
01460       INTERP_KERNEL::NormalizedCellType type=mesh->getTypeOfCell(i);
01461       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(type);
01462       for(int k=0;k<(int)cm.getNumberOfNodes();k++,j++)
01463         array2[j]=array3[array[i]]+k;
01464     }
01465   delete [] array3;
01466   for(std::vector<DataArrayDouble *>::const_iterator it=arrays.begin();it!=arrays.end();it++)
01467     if(*it)
01468       (*it)->renumberInPlace(array2);
01469   delete [] array2;
01470   if(check)
01471     delete [] const_cast<int *>(array);
01472 }
01473 
01474 DataArrayDouble *MEDCouplingFieldDiscretizationGaussNE::getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const
01475 {
01476   throw INTERP_KERNEL::Exception("Not implemented yet !");
01477 }
01478 
01479 void MEDCouplingFieldDiscretizationGaussNE::computeMeshRestrictionFromTupleIds(const MEDCouplingMesh *mesh, const int *partBg, const int *partEnd,
01480                                                                                DataArrayInt *&cellRest)
01481 {
01482   throw INTERP_KERNEL::Exception("Not implemented yet !");
01483 }
01484 
01485 void MEDCouplingFieldDiscretizationGaussNE::checkCompatibilityWithNature(NatureOfField nat) const throw(INTERP_KERNEL::Exception)
01486 {
01487 }
01488 
01489 double MEDCouplingFieldDiscretizationGaussNE::getIJK(const MEDCouplingMesh *mesh, const DataArrayDouble *da,
01490                                                      int cellId, int nodeIdInCell, int compoId) const throw(INTERP_KERNEL::Exception)
01491 {
01492   int offset=0;
01493   for(int i=0;i<cellId;i++)
01494     {
01495       INTERP_KERNEL::NormalizedCellType type=mesh->getTypeOfCell(i);
01496       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(type);
01497       offset+=cm.getNumberOfNodes();
01498     }
01499   return da->getIJ(offset+nodeIdInCell,compoId);
01500 }
01501 
01502 void MEDCouplingFieldDiscretizationGaussNE::checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception)
01503 {
01504   int nbOfTuples=getNumberOfTuples(mesh);
01505   if(nbOfTuples!=da->getNumberOfTuples())
01506     {
01507       std::ostringstream oss; oss << "Invalid number of tuples in the array : expecting " << nbOfTuples << " !";
01508       throw INTERP_KERNEL::Exception(oss.str().c_str());
01509     }
01510 }
01511 
01512 MEDCouplingFieldDouble *MEDCouplingFieldDiscretizationGaussNE::getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const
01513 {
01514   throw INTERP_KERNEL::Exception("Not implemented yet !");
01515 }
01516 
01517 void MEDCouplingFieldDiscretizationGaussNE::getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const
01518 {
01519   throw INTERP_KERNEL::Exception("Not implemented yet !");
01520 }
01521 
01522 void MEDCouplingFieldDiscretizationGaussNE::getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const
01523 {
01524   throw INTERP_KERNEL::Exception("getValueOnPos(i,j,k) : Not applyable for Gauss points !");
01525 }
01526 
01527 DataArrayDouble *MEDCouplingFieldDiscretizationGaussNE::getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const
01528 {
01529   throw INTERP_KERNEL::Exception("getValueOnMulti : Not implemented for Gauss NE !");
01530 }
01531 
01532 MEDCouplingMesh *MEDCouplingFieldDiscretizationGaussNE::buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const
01533 {
01534   throw INTERP_KERNEL::Exception("Not implemented yet !");
01535 }
01536 
01540 void MEDCouplingFieldDiscretizationGaussNE::renumberValuesOnNodes(double , const int *, DataArrayDouble *) const
01541 {
01542 }
01543 
01544 void MEDCouplingFieldDiscretizationGaussNE::renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const
01545 {
01546   throw INTERP_KERNEL::Exception("Not implemented yet !");
01547 }
01548 
01549 void MEDCouplingFieldDiscretizationGaussNE::renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const int *new2old, int newSz, DataArrayDouble *arr) const
01550 {
01551   throw INTERP_KERNEL::Exception("Not implemented yet !");
01552 }
01553 
01554 MEDCouplingFieldDiscretizationGaussNE::MEDCouplingFieldDiscretizationGaussNE(const MEDCouplingFieldDiscretizationGaussNE& other):MEDCouplingFieldDiscretization(other)
01555 {
01556 }
01557