{
if(!mesh)
throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGauss::getMeasureField : mesh instance specified is NULL !");
- MCAuto<MEDCouplingFieldDouble> vol=mesh->getMeasureField(isAbs);
- const double *volPtr=vol->getArray()->begin();
+ MCAuto<MEDCouplingUMesh> umesh(mesh->buildUnstructured());
+ const double *coordsOfMesh( umesh->getCoords()->begin() );
+
+ //MCAuto<MEDCouplingFieldDouble> vol=mesh->getMeasureField(isAbs);
+ //const double *volPtr=vol->getArray()->begin();
MCAuto<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(ON_GAUSS_PT);
ret->setMesh(mesh);
ret->setDiscretization(const_cast<MEDCouplingFieldDiscretizationGauss *>(this));
_discr_per_cell->checkAllocated();
if(_discr_per_cell->getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGauss::getMeasureField : no discr per cell array defined but with nb of components different from 1 !");
- if(_discr_per_cell->getNumberOfTuples()!=vol->getNumberOfTuples())
+ if(_discr_per_cell->getNumberOfTuples()!=mesh->getNumberOfCells())
throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGauss::getMeasureField : no discr per cell array defined but mismatch between nb of cells of mesh and size of spatial disr array !");
MCAuto<DataArrayIdType> offset=getOffsetArr(mesh);
MCAuto<DataArrayDouble> arr=DataArrayDouble::New(); arr->alloc(getNumberOfTuples(mesh),1);
double sum=std::accumulate(loc.getWeights().begin(),loc.getWeights().end(),0.);
std::transform(loc.getWeights().begin(),loc.getWeights().end(),(double *)weights,std::bind(std::multiplies<double>(),std::placeholders::_1,1./sum));
for(const mcIdType *cellId=curIds->begin();cellId!=curIds->end();cellId++)
+ {
+ std::vector<mcIdType> conn;
+ umesh->getNodeIdsOfCell(*cellId,conn);
+ std::vector<double> ptsInCell; ptsInCell.reserve(conn.size()*loc.getDimension());
+ std::for_each( conn.cbegin(), conn.cend(), [coordsOfMesh,&ptsInCell](mcIdType c) { ptsInCell.insert(ptsInCell.end(),coordsOfMesh+c*2,coordsOfMesh+(c+1)*2); } );
+
for(mcIdType j=0;j<nbOfGaussPt;j++)
- arrPtr[offsetPtr[*cellId]+j]=weights[j]*volPtr[*cellId];
+ arrPtr[offsetPtr[*cellId]+j]=weights[j];//*volPtr[*cellId]
+ }
}
else
{