std::string name="MeasureOnNodeOfMesh_";
name+=getName();
int nbNodes=getNumberOfNodes();
+ MCAuto<DataArrayDouble> nnpc;
+ {
+ MCAuto<DataArrayInt> tmp(computeNbOfNodesPerCell());
+ nnpc=tmp->convertToDblArr();
+ }
+ std::for_each(nnpc->rwBegin(),nnpc->rwEnd(),[](double& v) { v=1./v; });
+ const double *nnpcPtr(nnpc->begin());
MCAuto<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(ON_NODES);
- double cst=1./((double)getMeshDimension()+1.);
MCAuto<DataArrayDouble> array=DataArrayDouble::New();
array->alloc(nbNodes,1);
double *valsToFill=array->getPointer();
const int *daIPtr=daInd->getConstPointer();
for(int i=0;i<nbNodes;i++)
for(const int *cell=daPtr+daIPtr[i];cell!=daPtr+daIPtr[i+1];cell++)
- valsToFill[i]+=cst*values[*cell];
+ valsToFill[i]+=nnpcPtr[*cell]*values[*cell];
ret->setMesh(this);
ret->setArray(array);
return ret.retn();
CPPUNIT_ASSERT_DOUBLES_EQUAL(3.6,values4[0],1.e-12);
CPPUNIT_ASSERT_DOUBLES_EQUAL(7.2,values4[1],1.e-12);
f1->integral(true,values4);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,values4[0],1.e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,values4[1],1.e-12);
+ //0.4 == 0.25/4*-0.6+(0.25/4+0.125/3)*-0.1+0.4*(0.125/3.+0.125/3)+(-0.1)*(0.25/4+0.25/4)+0.4*(0.25/4+0.125/3+0.125/3+0.25/4+0.25/4)+0.9*(0.25/4+0.125/3)+0.4*0.25/4+0.9*(0.25/4+0.25/4)+1.4*0.25/4
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.4,values4[0],1.e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.8,values4[1],1.e-12);
f1->decrRef();
//
CPPUNIT_ASSERT_THROW(f1=m->fillFromAnalytic(ON_NODES,1,func3),INTERP_KERNEL::Exception);
CPPUNIT_ASSERT_DOUBLES_EQUAL(3.6,values4[0],1.e-12);
CPPUNIT_ASSERT_DOUBLES_EQUAL(7.2,values4[1],1.e-12);
f1->integral(true,values4);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,values4[0],1.e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,values4[1],1.e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.4,values4[0],1.e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.8,values4[1],1.e-12);
f1->decrRef();
//
CPPUNIT_ASSERT_THROW(f1=m->fillFromAnalytic(ON_NODES,1,"1./(x-0.2)"),INTERP_KERNEL::Exception);
CPPUNIT_ASSERT_DOUBLES_EQUAL(3.6,values4[0],1.e-12);
CPPUNIT_ASSERT_DOUBLES_EQUAL(7.2,values4[1],1.e-12);
f1->integral(true,values4);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,values4[0],1.e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,values4[1],1.e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.4,values4[0],1.e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.8,values4[1],1.e-12);
f1->decrRef();
//
f1=MEDCouplingFieldDouble::New(ON_NODES,NO_TIME);
self.assertTrue(abs(3.6-values4[0])<1.e-12);
self.assertTrue(abs(7.2-values4[1])<1.e-12);
values4=f1.integral(True);
+ #0.4 == 0.25/4*-0.6+(0.25/4+0.125/3)*-0.1+0.4*(0.125/3.+0.125/3)+(-0.1)*(0.25/4+0.25/4)+0.4*(0.25/4+0.125/3+0.125/3+0.25/4+0.25/4)+0.9*(0.25/4+0.125/3)+0.4*0.25/4+0.9*(0.25/4+0.25/4)+1.4*0.25/4
self.assertEqual(2,len(values4))
- self.assertTrue(abs(0.5-values4[0])<1.e-12);
- self.assertTrue(abs(1.-values4[1])<1.e-12);
+ self.assertTrue(abs(0.4-values4[0])<1.e-12);
+ self.assertTrue(abs(0.8-values4[1])<1.e-12);
#
self.assertRaises(InterpKernelException,m.fillFromAnalytic,ON_NODES,1,"1./(x-0.2)");
pass
self.assertTrue(abs(3.6-values4[0])<1.e-12);
self.assertTrue(abs(7.2-values4[1])<1.e-12);
values4=f1.integral(True);
- self.assertTrue(abs(0.5-values4[0])<1.e-12);
- self.assertTrue(abs(1.-values4[1])<1.e-12);
+ self.assertTrue(abs(0.4-values4[0])<1.e-12);
+ self.assertTrue(abs(0.8-values4[1])<1.e-12);
pass
def testApplyFunc(self):
self.assertTrue(abs(3.6-values4[0])<1.e-12);
self.assertTrue(abs(7.2-values4[1])<1.e-12);
values4=f1.integral(True);
- self.assertTrue(abs(0.5-values4[0])<1.e-12);
- self.assertTrue(abs(1.-values4[1])<1.e-12);
+ self.assertTrue(abs(0.4-values4[0])<1.e-12);
+ self.assertTrue(abs(0.8-values4[1])<1.e-12);
#
f1=MEDCouplingFieldDouble.New(ON_NODES,NO_TIME);
f1.setMesh(m);