-// Copyright (C) 2007-2014 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2015 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
return mesh;
}
-std::vector<const BigMemoryObject *> MEDCouplingCartesianAMRPatchGen::getDirectChildren() const
+std::vector<const BigMemoryObject *> MEDCouplingCartesianAMRPatchGen::getDirectChildrenWithNull() const
{
std::vector<const BigMemoryObject *> ret;
- if((const MEDCouplingCartesianAMRMeshGen *)_mesh)
- ret.push_back((const MEDCouplingCartesianAMRMeshGen *)_mesh);
+ ret.push_back((const MEDCouplingCartesianAMRMeshGen *)_mesh);
return ret;
}
throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRPatch::isInMyNeighborhood : the input patch is NULL !");
const std::vector< std::pair<int,int> >& thisp(getBLTRRange());
const std::vector< std::pair<int,int> >& otherp(other->getBLTRRange());
- return IsInMyNeighborhood(ghostLev,thisp,otherp);
+ return IsInMyNeighborhood(ghostLev==0?0:1,thisp,otherp);//make hypothesis that nb this->_mesh->getFather->getFactors() is >= ghostLev
}
/*!
return IsInMyNeighborhood(ghostLev>0?1:0,thispp,otherpp);//1 not ghostLev ! It is not a bug ( I hope :) ) ! Because as \a this is a refinement of \a other ghostLev is supposed to be <= factors
}
+std::vector< std::pair<int,int> > MEDCouplingCartesianAMRPatch::getBLTRRangeRelativeToGF() const
+{
+ std::vector< std::pair<int,int> > ret(_bl_tr);
+ const MEDCouplingCartesianAMRMeshGen *mesh(getMesh());
+ if(!mesh)
+ throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRPatch::getBLTRRangeRelativeToGF : not valid !");
+ const MEDCouplingCartesianAMRMeshGen *fath(mesh->getFather());
+ if(!fath)
+ throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRPatch::getBLTRRangeRelativeToGF : not valid 2 !");
+ std::vector<int> factors(fath->getFactors());
+ std::size_t sz(ret.size());
+ for(std::size_t ii=0;ii<sz;ii++)
+ {
+ ret[ii].first*=factors[ii];
+ ret[ii].second*=factors[ii];
+ }
+ const MEDCouplingCartesianAMRMeshGen *oldFather(fath);
+ fath=oldFather->getFather();
+ while(fath)
+ {
+ int pos(fath->getPatchIdFromChildMesh(oldFather));
+ const MEDCouplingCartesianAMRPatch *p(fath->getPatch(pos));
+ const std::vector< std::pair<int,int> >& tmp(p->getBLTRRange());
+ const std::vector<int>& factors2(fath->getFactors());
+ std::transform(factors.begin(),factors.end(),factors2.begin(),factors.begin(),std::multiplies<int>());
+ for(std::size_t ii=0;ii<sz;ii++)
+ {
+ int delta(ret[ii].second-ret[ii].first);
+ ret[ii].first+=tmp[ii].first*factors[ii];
+ ret[ii].second=ret[ii].first+delta;
+ }
+ oldFather=fath;
+ fath=oldFather->getFather();
+ }
+ return ret;
+}
+
std::vector<int> MEDCouplingCartesianAMRPatch::computeCellGridSt() const
{
const MEDCouplingCartesianAMRMeshGen *m(getMesh());
// Gradient absolute value
for(std::size_t i=1;i<derivate_second_order.size();i++)
- gradient_absolute.push_back(fabs(derivate_second_order[i]-derivate_second_order[i-1])) ;
+ gradient_absolute.push_back(abs(derivate_second_order[i]-derivate_second_order[i-1])) ;
if(derivate_second_order.empty())
continue;
for(std::size_t i=1;i<derivate_second_order.size()-1;i++)
return sizeof(MEDCouplingCartesianAMRMeshGen);
}
-std::vector<const BigMemoryObject *> MEDCouplingCartesianAMRMeshGen::getDirectChildren() const
+std::vector<const BigMemoryObject *> MEDCouplingCartesianAMRMeshGen::getDirectChildrenWithNull() const
{
std::vector<const BigMemoryObject *> ret;
- if((const MEDCouplingIMesh *)_mesh)
- ret.push_back((const MEDCouplingIMesh *)_mesh);
+ ret.push_back((const MEDCouplingIMesh *)_mesh);
for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingCartesianAMRPatch> >::const_iterator it=_patches.begin();it!=_patches.end();it++)
- {
- if((const MEDCouplingCartesianAMRPatch*)*it)
- ret.push_back((const MEDCouplingCartesianAMRPatch*)*it);
- }
+ ret.push_back((const MEDCouplingCartesianAMRPatch*)*it);
return ret;
}
return new MEDCouplingCartesianAMRMesh(meshName,spaceDim,nodeStrctStart,nodeStrctStop,originStart,originStop,dxyzStart,dxyzStop);
}
+MEDCouplingCartesianAMRMesh *MEDCouplingCartesianAMRMesh::New(MEDCouplingIMesh *mesh)
+{
+ return new MEDCouplingCartesianAMRMesh(mesh);
+}
+
const MEDCouplingCartesianAMRMeshGen *MEDCouplingCartesianAMRMesh::getFather() const
{
//I'm god father ! No father !
{
}
-std::vector<const BigMemoryObject *> MEDCouplingCartesianAMRMesh::getDirectChildren() const
+MEDCouplingCartesianAMRMesh::MEDCouplingCartesianAMRMesh(MEDCouplingIMesh *mesh):MEDCouplingCartesianAMRMeshGen(mesh)
+{
+}
+
+std::vector<const BigMemoryObject *> MEDCouplingCartesianAMRMesh::getDirectChildrenWithNull() const
{
- std::vector<const BigMemoryObject *> ret(MEDCouplingCartesianAMRMeshGen::getDirectChildren());
+ std::vector<const BigMemoryObject *> ret(MEDCouplingCartesianAMRMeshGen::getDirectChildrenWithNull());
return ret;
}