MEDCouplingCartesianAMRMesh *MEDCouplingCartesianAMRMesh::New(const std::string& meshName, int spaceDim, const int *nodeStrctStart, const int *nodeStrctStop,
- const double *originStart, const double *originStop, const double *dxyzStart, const double *dxyzStop)
+ const double *originStart, const double *originStop, const double *dxyzStart, const double *dxyzStop)
{
return new MEDCouplingCartesianAMRMesh(meshName,spaceDim,nodeStrctStart,nodeStrctStop,originStart,originStop,dxyzStart,dxyzStop);
}
}
MEDCouplingCartesianAMRMesh::MEDCouplingCartesianAMRMesh(const std::string& meshName, int spaceDim, const int *nodeStrctStart, const int *nodeStrctStop,
- const double *originStart, const double *originStop, const double *dxyzStart, const double *dxyzStop):_father(0)
+ const double *originStart, const double *originStop, const double *dxyzStart, const double *dxyzStop):_father(0)
{
_mesh=MEDCouplingIMesh::New(meshName,spaceDim,nodeStrctStart,nodeStrctStop,originStart,originStop,dxyzStart,dxyzStop);
}
{
public:
MEDCOUPLING_EXPORT static MEDCouplingCartesianAMRMesh *New(const std::string& meshName, int spaceDim, const int *nodeStrctStart, const int *nodeStrctStop,
- const double *originStart, const double *originStop, const double *dxyzStart, const double *dxyzStop);
+ const double *originStart, const double *originStop, const double *dxyzStart, const double *dxyzStop);
MEDCOUPLING_EXPORT int getSpaceDimension() const;
MEDCOUPLING_EXPORT int getMaxNumberOfLevelsRelativeToThis() const;
MEDCOUPLING_EXPORT int getNumberOfCellsAtCurrentLevel() const;
MEDCOUPLING_EXPORT MEDCouplingUMesh *buildUnstructured() const;
private:
MEDCouplingCartesianAMRMesh(const std::string& meshName, int spaceDim, const int *nodeStrctStart, const int *nodeStrctStop,
- const double *originStart, const double *originStop, const double *dxyzStart, const double *dxyzStop);
+ const double *originStart, const double *originStop, const double *dxyzStart, const double *dxyzStop);
MEDCouplingCartesianAMRMesh(MEDCouplingCartesianAMRMesh *father, MEDCouplingIMesh *mesh);
void checkPatchId(int patchId) const;
protected:
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
int nbTuplesFine(fineDA->getNumberOfTuples());
- if(nbTuplesFine%nbOfTuplesInCoarseExp!=0)
+ if(nbTuplesFine%nbOfTuplesInFineExp!=0)
throw INTERP_KERNEL::Exception("MEDCouplingIMesh::CondenseFineToCoarse : Invalid nb of tuples in fine DataArray regarding its structure !");
int factN(nbTuplesFine/nbOfTuplesInFineExp);
int fact(FindIntRoot(factN,meshDim));
// to improve use jump-iterator. Factorizes with SwitchOnIdsFrom BuildExplicitIdsFrom
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids(BuildExplicitIdsFrom(coarseSt,fineLocInCoarse));
- const int *idsPtr(ids->begin());
double *outPtr(coarseDA->getPointer());
const double *inPtr(fineDA->begin());
- coarseDA->setPartOfValuesSimple3(0.,ids->begin(),ids->end(),0,nbCompo,1);
//
switch(meshDim)
{
case 2:
{
- int kk(0);
std::vector<int> dims(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(fineLocInCoarse));
- for(int it=0;it<dims[1];it++)
+ int kk(fineLocInCoarse[0].first+coarseSt[0]*fineLocInCoarse[1].first);
+ for(int j=0;j<dims[1];j++)
{
- for(int i=0;i<fact;i++)
+ for(int jfact=0;jfact<fact;jfact++)
{
- for(int j=0;j<dims[0];j++,inPtr+=fact)
+ for(int i=0;i<dims[0];i++)
{
- double *loc(outPtr+idsPtr[kk+j]*nbCompo);
- std::transform(inPtr,inPtr+fact,loc,loc,std::plus<double>());
+ double *loc(outPtr+(kk+i)*nbCompo);
+ for(int ifact=0;ifact<fact;ifact++,inPtr+=nbCompo)
+ {
+ if(jfact!=0 || ifact!=0)
+ std::transform(inPtr,inPtr+nbCompo,loc,loc,std::plus<double>());
+ else
+ std::copy(inPtr,inPtr+nbCompo,loc);
+ }
}
}
- kk+=it;
+ kk+=coarseSt[0];
}
break;
}
self.assertTrue(m2.getData().isEqual(DataArrayDouble([29,37,37,62]),1e-12))
pass
+ def testAMR2(self):
+ """ Test condensation of fine IMesh instance into a coarse one, with a factor. See testRemapperAMR1 in MEDCouplingRemapperTest.py file to see how the expected value is obtained."""
+ coarse=DataArrayDouble(35) ; coarse.iota(0) #X=5,Y=7
+ fine=DataArrayDouble(3*2*4*4) ; fine.iota(0) #X=3,Y=2 refined by 4
+ MEDCouplingIMesh.CondenseFineToCoarse(coarse,[5,7],fine,[(1,4),(2,4)])
+ self.assertTrue(coarse.isEqual(DataArrayDouble([0,1,2,3,4,5,6,7,8,9,10,312,376,440,14,15,1080,1144,1208,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34]),1e-12))
+ pass
+
def setUp(self):
pass
pass