From: Anthony Geay Date: Mon, 23 Jan 2023 16:29:31 +0000 (+0100) Subject: WIP X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=945dd39233410a91251398855d8bed0227985751;p=tools%2Fmedcoupling.git WIP --- diff --git a/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx b/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx index d7cf86b66..384785366 100755 --- a/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx +++ b/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx @@ -1711,8 +1711,11 @@ MEDCouplingFieldDouble *MEDCouplingFieldDiscretizationGauss::getMeasureField(con { if(!mesh) throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGauss::getMeasureField : mesh instance specified is NULL !"); - MCAuto vol=mesh->getMeasureField(isAbs); - const double *volPtr=vol->getArray()->begin(); + MCAuto umesh(mesh->buildUnstructured()); + const double *coordsOfMesh( umesh->getCoords()->begin() ); + + //MCAuto vol=mesh->getMeasureField(isAbs); + //const double *volPtr=vol->getArray()->begin(); MCAuto ret=MEDCouplingFieldDouble::New(ON_GAUSS_PT); ret->setMesh(mesh); ret->setDiscretization(const_cast(this)); @@ -1721,7 +1724,7 @@ MEDCouplingFieldDouble *MEDCouplingFieldDiscretizationGauss::getMeasureField(con _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 offset=getOffsetArr(mesh); MCAuto arr=DataArrayDouble::New(); arr->alloc(getNumberOfTuples(mesh),1); @@ -1744,8 +1747,15 @@ MEDCouplingFieldDouble *MEDCouplingFieldDiscretizationGauss::getMeasureField(con 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(),std::placeholders::_1,1./sum)); for(const mcIdType *cellId=curIds->begin();cellId!=curIds->end();cellId++) + { + std::vector conn; + umesh->getNodeIdsOfCell(*cellId,conn); + std::vector 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