From 945dd39233410a91251398855d8bed0227985751 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Mon, 23 Jan 2023 17:29:31 +0100 Subject: [PATCH] WIP --- .../MEDCouplingFieldDiscretization.cxx | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) 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