+void MEDCouplingFieldDiscretizationGaussNE::integral(const MEDCouplingMesh *mesh, const DataArrayDouble *arr, bool isWAbs, double *res) const throw(INTERP_KERNEL::Exception)
+{
+ if(!mesh || !arr)
+ throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGaussNE::integral : input mesh or array is null !");
+ int nbOfCompo=arr->getNumberOfComponents();
+ std::fill(res,res+nbOfCompo,0.);
+ //
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> vol=getMeasureField(mesh,isWAbs);
+ std::set<INTERP_KERNEL::NormalizedCellType> types=mesh->getAllGeoTypes();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> nbOfNodesPerCell=mesh->computeNbOfNodesPerCell();
+ nbOfNodesPerCell->computeOffsets2();
+ const double *arrPtr=arr->begin(),*volPtr=vol->getArray()->begin();
+ for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=types.begin();it!=types.end();it++)
+ {
+ std::size_t wArrSz=-1;
+ const double *wArr=GetWeightArrayFromGeometricType(*it,wArrSz);
+ INTERP_KERNEL::AutoPtr<double> wArr2=new double[wArrSz];
+ double sum=std::accumulate(wArr,wArr+wArrSz,0.);
+ std::transform(wArr,wArr+wArrSz,(double *)wArr2,std::bind2nd(std::multiplies<double>(),1./sum));
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=mesh->giveCellsWithType(*it);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids2=ids->buildExplicitArrByRanges(nbOfNodesPerCell);
+ const int *ptIds2=ids2->begin(),*ptIds=ids->begin();
+ int nbOfCellsWithCurGeoType=ids->getNumberOfTuples();
+ for(int i=0;i<nbOfCellsWithCurGeoType;i++,ptIds++,ptIds2+=wArrSz)
+ {
+ for(int k=0;k<nbOfCompo;k++)
+ {
+ double tmp=0.;
+ for(std::size_t j=0;j<wArrSz;j++)
+ tmp+=arrPtr[nbOfCompo*ptIds2[j]+k]*wArr2[j];
+ res[k]+=tmp*volPtr[*ptIds];
+ }
+ }
+ }
+}
+
+const double *MEDCouplingFieldDiscretizationGaussNE::GetWeightArrayFromGeometricType(INTERP_KERNEL::NormalizedCellType geoType, std::size_t& lgth) throw(INTERP_KERNEL::Exception)
+{
+ switch(geoType)
+ {
+ case INTERP_KERNEL::NORM_SEG2:
+ lgth=(int)sizeof(FGP_SEG2)/sizeof(double);
+ return FGP_SEG2;
+ case INTERP_KERNEL::NORM_SEG3:
+ lgth=(int)sizeof(FGP_SEG3)/sizeof(double);
+ return FGP_SEG3;
+ case INTERP_KERNEL::NORM_SEG4:
+ lgth=(int)sizeof(FGP_SEG4)/sizeof(double);
+ return FGP_SEG4;
+ case INTERP_KERNEL::NORM_TRI3:
+ lgth=(int)sizeof(FGP_TRI3)/sizeof(double);
+ return FGP_TRI3;
+ case INTERP_KERNEL::NORM_TRI6:
+ lgth=(int)sizeof(FGP_TRI6)/sizeof(double);
+ return FGP_TRI6;
+ case INTERP_KERNEL::NORM_TRI7:
+ lgth=(int)sizeof(FGP_TRI7)/sizeof(double);
+ return FGP_TRI7;
+ case INTERP_KERNEL::NORM_QUAD4:
+ lgth=(int)sizeof(FGP_QUAD4)/sizeof(double);
+ return FGP_QUAD4;
+ case INTERP_KERNEL::NORM_QUAD9:
+ lgth=(int)sizeof(FGP_QUAD9)/sizeof(double);
+ return FGP_QUAD9;
+ case INTERP_KERNEL::NORM_TETRA4:
+ lgth=(int)sizeof(FGP_TETRA4)/sizeof(double);
+ return FGP_TETRA4;
+ case INTERP_KERNEL::NORM_PENTA6:
+ lgth=(int)sizeof(FGP_PENTA6)/sizeof(double);
+ return FGP_PENTA6;
+ case INTERP_KERNEL::NORM_HEXA8:
+ lgth=(int)sizeof(FGP_HEXA8)/sizeof(double);
+ return FGP_HEXA8;
+ case INTERP_KERNEL::NORM_HEXA27:
+ lgth=(int)sizeof(FGP_HEXA27)/sizeof(double);
+ return FGP_HEXA27;
+ case INTERP_KERNEL::NORM_PYRA5:
+ lgth=(int)sizeof(FGP_PYRA5)/sizeof(double);
+ return FGP_PYRA5;
+ default:
+ throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGaussNE::GetWeightArrayFromGeometricType : only SEG[2,3,4], TRI[3,6,7], QUAD[4,9], TETRA4, PENTA6, HEXA[8,27], PYRA5 supported !");
+ }
+}
+