From: geay Date: Tue, 27 May 2014 07:37:26 +0000 (+0200) Subject: stash 2 X-Git-Tag: V7_5_0a1~2^2~32^2~32 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=be44457a3e305839237d4fede94f5a4a09fad5b1;p=tools%2Fmedcoupling.git stash 2 --- diff --git a/src/MEDCoupling/MEDCouplingCartesianAMRMesh.cxx b/src/MEDCoupling/MEDCouplingCartesianAMRMesh.cxx index b923249b6..3d872445d 100644 --- a/src/MEDCoupling/MEDCouplingCartesianAMRMesh.cxx +++ b/src/MEDCoupling/MEDCouplingCartesianAMRMesh.cxx @@ -675,17 +675,24 @@ void MEDCouplingCartesianAMRMesh::fillCellFieldOnPatchGhost(int patchId, const D */ void MEDCouplingCartesianAMRMesh::fillCellFieldOnPatchGhostAdv(int patchId, const DataArrayDouble *cellFieldOnThis, int ghostLev, const std::vector& arrsOnPatches) const { - int nbp(getNumberOfPatches()); + int nbp(getNumberOfPatches()),dim(getSpaceDimension()); if(nbp!=(int)arrsOnPatches.size()) { std::ostringstream oss; oss << "MEDCouplingCartesianAMRMesh::fillCellFieldOnPatchGhostAdv : there are " << nbp << " patches in this and " << arrsOnPatches.size() << " arrays in the last parameter !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } + DataArrayDouble *theFieldToFill(const_cast(arrsOnPatches[patchId])); // first, do as usual - fillCellFieldOnPatchGhost(patchId,cellFieldOnThis,const_cast(arrsOnPatches[patchId]),ghostLev); - // + fillCellFieldOnPatchGhost(patchId,cellFieldOnThis,theFieldToFill,ghostLev); + // all reference patch stuff const MEDCouplingCartesianAMRPatch *refP(getPatch(patchId)); const std::vector< std::pair >& refBLTR(refP->getBLTRRange()); + std::vector dimsCoarse(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(refBLTR)); + std::transform(dimsCoarse.begin(),dimsCoarse.end(),_factors.begin(),dimsCoarse.begin(),std::multiplies()); + std::transform(dimsCoarse.begin(),dimsCoarse.end(),dimsCoarse.begin(),std::bind2nd(std::plus(),2*ghostLev)); + std::vector< std::pair > rangeCoarse(MEDCouplingStructuredMesh::GetCompactFrmtFromDimensions(dimsCoarse)); + std::vector fakeFactors(dim,1); + // for(int i=0;i dims(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(fineLocInCoarse)); + std::vector dimsFine(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(otherBLTR)); + MEDCouplingAutoRefCountObjectPtr ghostVals;//(MEDCouplingStructuredMesh::ExtractFieldOfDoubleFrom(dimsFine,arrsOnPatches[i],)); + std::vector< std::pair > interstRange(MEDCouplingStructuredMesh::IntersectRanges(tmp0,rangeCoarse)); + MEDCouplingIMesh::CondenseFineToCoarse(dimsCoarse,ghostVals,interstRange,fakeFactors,theFieldToFill); } } } diff --git a/src/MEDCoupling/MEDCouplingStructuredMesh.cxx b/src/MEDCoupling/MEDCouplingStructuredMesh.cxx index 8d5126f9b..9b213d795 100644 --- a/src/MEDCoupling/MEDCouplingStructuredMesh.cxx +++ b/src/MEDCoupling/MEDCouplingStructuredMesh.cxx @@ -1270,11 +1270,81 @@ bool MEDCouplingStructuredMesh::IsPartStructured(const int *startIds, const int } } +/*! + * This method takes in input a compact format [[Xmax,Xmin),[Ymin,Ymax)] and returns the corresponding dimensions for each axis that is to say + * [Xmax-Xmin,Ymax-Ymin]. + * + * \throw if an axis range is so that max MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(const std::vector< std::pair >& partCompactFormat) { std::vector ret(partCompactFormat.size()); for(std::size_t i=0;ipartCompactFormat[i].second) + { + std::ostringstream oss; oss << "MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt : For axis #" << i << " end is before start !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + ret[i]=partCompactFormat[i].second-partCompactFormat[i].first; + } + return ret; +} + +/*! + * This method takes in input a vector giving the number of entity per axis and returns for each axis a range starting from [0,0...] + * + * \throw if there is an axis in \a dims that is < 0. + * \sa GetDimensionsFromCompactFrmt, ChangeReferenceFromGlobalOfCompactFrmt, ChangeReferenceToGlobalOfCompactFrmt + */ +std::vector< std::pair > MEDCouplingStructuredMesh::GetCompactFrmtFromDimensions(const std::vector& dims) +{ + std::size_t sz(dims.size()); + std::vector< std::pair > ret(sz); + for(std::size_t i=0;i > MEDCouplingStructuredMesh::IntersectRanges(const std::vector< std::pair >& r1, const std::vector< std::pair >& r2) +{ + std::size_t sz(r1.size()); + if(sz!=r2.size()) + throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::IntersectRanges : the two ranges must have the same dimension !"); + std::vector< std::pair > ret(sz); + for(std::size_t i=0;ir1[i].second) + { + std::ostringstream oss; oss << "MEDCouplingStructuredMesh::IntersectRanges : On axis " << i << " of range r1, end is before start !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + if(r2[i].first>r2[i].second) + { + std::ostringstream oss; oss << "MEDCouplingStructuredMesh::IntersectRanges : On axis " << i << " of range r2, end is before start !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + ret[i].first=std::max(r1[i].first,r2[i].first); + ret[i].second=std::min(r1[i].second,r2[i].second); + if(ret[i].first>ret[i].second) + { + std::ostringstream oss; oss << "MEDCouplingStructuredMesh::IntersectRanges : On axis " << i << " the intersection of r1 and r2 is empty !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + } return ret; } diff --git a/src/MEDCoupling/MEDCouplingStructuredMesh.hxx b/src/MEDCoupling/MEDCouplingStructuredMesh.hxx index dc5b78590..b669deafd 100644 --- a/src/MEDCoupling/MEDCouplingStructuredMesh.hxx +++ b/src/MEDCoupling/MEDCouplingStructuredMesh.hxx @@ -73,6 +73,8 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT static std::vector GetSplitVectFromStruct(const std::vector& strct); MEDCOUPLING_EXPORT static bool IsPartStructured(const int *startIds, const int *stopIds, const std::vector& st, std::vector< std::pair >& partCompactFormat); MEDCOUPLING_EXPORT static std::vector GetDimensionsFromCompactFrmt(const std::vector< std::pair >& partCompactFormat); + MEDCOUPLING_EXPORT static std::vector< std::pair > GetCompactFrmtFromDimensions(const std::vector& dims); + MEDCOUPLING_EXPORT static std::vector< std::pair > IntersectRanges(const std::vector< std::pair >& r1, const std::vector< std::pair >& r2); MEDCOUPLING_EXPORT static void SwitchOnIdsFrom(const std::vector& st, const std::vector< std::pair >& partCompactFormat, std::vector& vectToSwitchOn); MEDCOUPLING_EXPORT static void ExtractFieldOfBoolFrom(const std::vector& st, const std::vector& fieldOfBool, const std::vector< std::pair >& partCompactFormat, std::vector& fieldOut); MEDCOUPLING_EXPORT static DataArrayDouble *ExtractFieldOfDoubleFrom(const std::vector& st, const DataArrayDouble *fieldOfDbl, const std::vector< std::pair >& partCompactFormat); diff --git a/src/MEDCoupling_Swig/MEDCouplingCommon.i b/src/MEDCoupling_Swig/MEDCouplingCommon.i index 548c998e5..ea847d73e 100644 --- a/src/MEDCoupling_Swig/MEDCouplingCommon.i +++ b/src/MEDCoupling_Swig/MEDCouplingCommon.i @@ -2907,6 +2907,37 @@ namespace ParaMEDMEM return MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(inp); } + static PyObject *GetCompactFrmtFromDimensions(const std::vector& dims) throw(INTERP_KERNEL::Exception) + { + std::vector< std::pair > ret(MEDCouplingStructuredMesh::GetCompactFrmtFromDimensions(dims)); + PyObject *retPy=PyList_New(ret.size()); + for(std::size_t i=0;i > r1Cpp,r2Cpp; + convertPyToVectorPairInt(r1,r1Cpp); + convertPyToVectorPairInt(r2,r2Cpp); + std::vector< std::pair > ret(MEDCouplingStructuredMesh::IntersectRanges(r1Cpp,r2Cpp)); + PyObject *retPy=PyList_New(ret.size()); + for(std::size_t i=0;i