X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDCoupling%2FMEDCouplingStructuredMesh.cxx;h=a6b9706fdb84a3dcfba4ff8bbfab5b5995dbc6a6;hb=e7835cba1eb17f50ef4e130c2cb8d0f54bc25083;hp=1e2186855f2412843fee22ca0679d26bb8e6fba9;hpb=07c8e8ff8efab9224c53b20bf63872110dea6ab6;p=tools%2Fmedcoupling.git diff --git a/src/MEDCoupling/MEDCouplingStructuredMesh.cxx b/src/MEDCoupling/MEDCouplingStructuredMesh.cxx index 1e2186855..a6b9706fd 100644 --- a/src/MEDCoupling/MEDCouplingStructuredMesh.cxx +++ b/src/MEDCoupling/MEDCouplingStructuredMesh.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2014 CEA/DEN, EDF R&D +// Copyright (C) 2007-2016 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 @@ -23,16 +23,17 @@ #include "MEDCouplingMemArray.hxx" #include "MEDCoupling1GTUMesh.hxx" #include "MEDCouplingUMesh.hxx" +#include "MEDCouplingIMesh.hxx"//tony to throw when optimization will be performed in AssignPartOfFieldOfDoubleUsing #include -using namespace ParaMEDMEM; +using namespace MEDCoupling; MEDCouplingStructuredMesh::MEDCouplingStructuredMesh() { } -MEDCouplingStructuredMesh::MEDCouplingStructuredMesh(const MEDCouplingStructuredMesh& other, bool deepCopy):MEDCouplingMesh(other) +MEDCouplingStructuredMesh::MEDCouplingStructuredMesh(const MEDCouplingStructuredMesh& other, bool deepCpy):MEDCouplingMesh(other) { } @@ -55,7 +56,7 @@ bool MEDCouplingStructuredMesh::isEqualIfNotWhy(const MEDCouplingMesh *other, do return MEDCouplingMesh::isEqualIfNotWhy(other,prec,reason); } -INTERP_KERNEL::NormalizedCellType MEDCouplingStructuredMesh::getTypeOfCell(int cellId) const +INTERP_KERNEL::NormalizedCellType MEDCouplingStructuredMesh::getTypeOfCell(std::size_t cellId) const { return GetGeoTypeGivenMeshDimension(getMeshDimension()); } @@ -84,19 +85,19 @@ std::set MEDCouplingStructuredMesh::getAllGeo return ret2; } -int MEDCouplingStructuredMesh::getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const +std::size_t MEDCouplingStructuredMesh::getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const { - int ret=getNumberOfCells(); + std::size_t ret(getNumberOfCells()); if(type==getTypeOfCell(0)) return ret; - const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getTypeOfCell(0)); + const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(getTypeOfCell(0))); std::ostringstream oss; oss << "MEDCouplingStructuredMesh::getNumberOfCellsWithType : no specified type ! Type available is " << cm.getRepr() << " !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } DataArrayInt *MEDCouplingStructuredMesh::giveCellsWithType(INTERP_KERNEL::NormalizedCellType type) const { - MEDCouplingAutoRefCountObjectPtr ret=DataArrayInt::New(); + MCAuto ret=DataArrayInt::New(); if(getTypeOfCell(0)==type) { ret->alloc(getNumberOfCells(),1); @@ -110,7 +111,7 @@ DataArrayInt *MEDCouplingStructuredMesh::giveCellsWithType(INTERP_KERNEL::Normal DataArrayInt *MEDCouplingStructuredMesh::computeNbOfNodesPerCell() const { int nbCells=getNumberOfCells(); - MEDCouplingAutoRefCountObjectPtr ret=DataArrayInt::New(); + MCAuto ret=DataArrayInt::New(); ret->alloc(nbCells,1); const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getTypeOfCell(0)); ret->fillWithValue((int)cm.getNumberOfNodes()); @@ -120,7 +121,7 @@ DataArrayInt *MEDCouplingStructuredMesh::computeNbOfNodesPerCell() const DataArrayInt *MEDCouplingStructuredMesh::computeNbOfFacesPerCell() const { int nbCells=getNumberOfCells(); - MEDCouplingAutoRefCountObjectPtr ret=DataArrayInt::New(); + MCAuto ret=DataArrayInt::New(); ret->alloc(nbCells,1); const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getTypeOfCell(0)); ret->fillWithValue((int)cm.getNumberOfSons()); @@ -139,7 +140,7 @@ DataArrayInt *MEDCouplingStructuredMesh::computeEffectiveNbOfNodesPerCell() cons return computeNbOfNodesPerCell(); } -void MEDCouplingStructuredMesh::getNodeIdsOfCell(int cellId, std::vector& conn) const +void MEDCouplingStructuredMesh::getNodeIdsOfCell(std::size_t cellId, std::vector& conn) const { int meshDim=getMeshDimension(); int tmpCell[3],tmpNode[3]; @@ -309,21 +310,21 @@ DataArrayInt *MEDCouplingStructuredMesh::checkTypeConsistencyAndContig(const std * - After \a code contains [NORM_...,nbCells,0], \a idsInPflPerType [[0,1]] and \a idsPerType is [[1,2]]
*/ -void MEDCouplingStructuredMesh::splitProfilePerType(const DataArrayInt *profile, std::vector& code, std::vector& idsInPflPerType, std::vector& idsPerType) const +void MEDCouplingStructuredMesh::splitProfilePerType(const DataArrayInt *profile, std::vector& code, std::vector& idsInPflPerType, std::vector& idsPerType, bool smartPflKiller) const { if(!profile || !profile->isAllocated()) throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::splitProfilePerType : input profile is NULL or not allocated !"); if(profile->getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::splitProfilePerType : input profile should have exactly one component !"); - int nbTuples=profile->getNumberOfTuples(); + int nbTuples(profile->getNumberOfTuples()); int nbOfCells=getNumberOfCells(); code.resize(3); idsInPflPerType.resize(1); code[0]=(int)getTypeOfCell(0); code[1]=nbOfCells; idsInPflPerType.resize(1); - if(profile->isIdentity() && nbTuples==nbOfCells) + if(smartPflKiller && profile->isIota(nbOfCells)) { code[2]=-1; - idsInPflPerType[0]=0; + idsInPflPerType[0]=profile->deepCopy(); idsPerType.clear(); return ; } @@ -331,12 +332,16 @@ void MEDCouplingStructuredMesh::splitProfilePerType(const DataArrayInt *profile, code[2]=0; profile->checkAllIdsInRange(0,nbOfCells); idsPerType.resize(1); - idsPerType[0]=profile->deepCpy(); + idsPerType[0]=profile->deepCopy(); idsInPflPerType[0]=DataArrayInt::Range(0,nbTuples,1); } /*! * Creates a new unstructured mesh (MEDCoupling1SGTUMesh) from \a this structured one. + * + * In the returned mesh, the nodes are ordered with the first axis varying first: (X0,Y0), (X1,Y0), ... (X0,Y1), (X1,Y1), ... + * and the cells are ordered with the same logic, i.e. in (i,j) notation: (0,0), (1,0), (2,0), ... (0,1), (1,1), ... + * * \return MEDCouplingUMesh * - a new instance of MEDCouplingUMesh. The caller is to * delete this array using decrRef() as it is no more needed. * \throw If \a this->getMeshDimension() is not among [1,2,3]. @@ -346,11 +351,11 @@ MEDCoupling1SGTUMesh *MEDCouplingStructuredMesh::build1SGTUnstructured() const int meshDim(getMeshDimension()),spaceDim(getSpaceDimensionOnNodeStruct()); if((meshDim<0 || meshDim>3) || (spaceDim<0 || spaceDim>3)) throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::build1SGTUnstructured : meshdim and spacedim must be in [1,2,3] !"); - MEDCouplingAutoRefCountObjectPtr coords(getCoordinatesAndOwner()); + MCAuto coords(getCoordinatesAndOwner()); int ns[3]; getNodeGridStructure(ns); - MEDCouplingAutoRefCountObjectPtr conn(Build1GTNodalConnectivity(ns,ns+spaceDim)); - MEDCouplingAutoRefCountObjectPtr ret(MEDCoupling1SGTUMesh::New(getName(),GetGeoTypeGivenMeshDimension(meshDim))); + MCAuto conn(Build1GTNodalConnectivity(ns,ns+spaceDim)); + MCAuto ret(MEDCoupling1SGTUMesh::New(getName(),GetGeoTypeGivenMeshDimension(meshDim))); ret->setNodalConnectivity(conn); ret->setCoords(coords); try { ret->copyTinyInfoFrom(this); } @@ -369,24 +374,28 @@ MEDCoupling1SGTUMesh *MEDCouplingStructuredMesh::build1SGTSubLevelMesh() const int meshDim(getMeshDimension()); if(meshDim<1 || meshDim>3) throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::build1SGTSubLevelMesh : meshdim must be in [2,3] !"); - MEDCouplingAutoRefCountObjectPtr coords(getCoordinatesAndOwner()); + MCAuto coords(getCoordinatesAndOwner()); int ns[3]; getNodeGridStructure(ns); - MEDCouplingAutoRefCountObjectPtr conn(Build1GTNodalConnectivityOfSubLevelMesh(ns,ns+meshDim)); - MEDCouplingAutoRefCountObjectPtr ret(MEDCoupling1SGTUMesh::New(getName(),GetGeoTypeGivenMeshDimension(meshDim-1))); + MCAuto conn(Build1GTNodalConnectivityOfSubLevelMesh(ns,ns+meshDim)); + MCAuto ret(MEDCoupling1SGTUMesh::New(getName(),GetGeoTypeGivenMeshDimension(meshDim-1))); ret->setNodalConnectivity(conn); ret->setCoords(coords); return ret.retn(); } /*! * Creates a new unstructured mesh (MEDCouplingUMesh) from \a this structured one. + * + * In the returned mesh, the nodes are ordered with the first axis varying first: (X0,Y0), (X1,Y0), ... (X0,Y1), (X1,Y1), ... + * and the cells are ordered with the same logic, i.e. in (i,j) notation: (0,0), (1,0), (2,0), ... (0,1), (1,1), ... + * * \return MEDCouplingUMesh * - a new instance of MEDCouplingUMesh. The caller is to * delete this array using decrRef() as it is no more needed. * \throw If \a this->getMeshDimension() is not among [1,2,3]. */ MEDCouplingUMesh *MEDCouplingStructuredMesh::buildUnstructured() const { - MEDCouplingAutoRefCountObjectPtr ret0(build1SGTUnstructured()); + MCAuto ret0(build1SGTUnstructured()); return ret0->buildUnstructured(); } @@ -402,10 +411,8 @@ MEDCouplingUMesh *MEDCouplingStructuredMesh::buildUnstructured() const */ MEDCouplingMesh *MEDCouplingStructuredMesh::buildPart(const int *start, const int *end) const { - MEDCouplingUMesh *um=buildUnstructured(); - MEDCouplingMesh *ret=um->buildPart(start,end); - um->decrRef(); - return ret; + MCAuto um(buildUnstructured()); + return um->buildPart(start,end); } MEDCouplingMesh *MEDCouplingStructuredMesh::buildPartAndReduceNodes(const int *start, const int *end, DataArrayInt*& arr) const @@ -414,24 +421,22 @@ MEDCouplingMesh *MEDCouplingStructuredMesh::buildPartAndReduceNodes(const int *s std::vector< std::pair > cellPartFormat,nodePartFormat; if(IsPartStructured(start,end,cgs,cellPartFormat)) { - MEDCouplingAutoRefCountObjectPtr ret(buildStructuredSubPart(cellPartFormat)); + MCAuto ret(buildStructuredSubPart(cellPartFormat)); nodePartFormat=cellPartFormat; for(std::vector< std::pair >::iterator it=nodePartFormat.begin();it!=nodePartFormat.end();it++) (*it).second++; - MEDCouplingAutoRefCountObjectPtr tmp1(BuildExplicitIdsFrom(getNodeGridStructure(),nodePartFormat)); - MEDCouplingAutoRefCountObjectPtr tmp2(DataArrayInt::New()); tmp2->alloc(getNumberOfNodes(),1); + MCAuto tmp1(BuildExplicitIdsFrom(getNodeGridStructure(),nodePartFormat)); + MCAuto tmp2(DataArrayInt::New()); tmp2->alloc(getNumberOfNodes(),1); tmp2->fillWithValue(-1); - MEDCouplingAutoRefCountObjectPtr tmp3(DataArrayInt::New()); tmp3->alloc(tmp1->getNumberOfTuples(),1); tmp3->iota(0); + MCAuto tmp3(DataArrayInt::New()); tmp3->alloc(tmp1->getNumberOfTuples(),1); tmp3->iota(0); tmp2->setPartOfValues3(tmp3,tmp1->begin(),tmp1->end(),0,1,1); arr=tmp2.retn(); return ret.retn(); } else { - MEDCouplingUMesh *um=buildUnstructured(); - MEDCouplingMesh *ret=um->buildPartAndReduceNodes(start,end,arr); - um->decrRef(); - return ret; + MCAuto um(buildUnstructured()); + return um->buildPartAndReduceNodes(start,end,arr); } } @@ -452,17 +457,16 @@ MEDCouplingFieldDouble *MEDCouplingStructuredMesh::buildOrthogonalField() const { if(getMeshDimension()!=2) throw INTERP_KERNEL::Exception("Expected a MEDCouplingStructuredMesh with meshDim == 2 !"); - MEDCouplingFieldDouble *ret=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME); - DataArrayDouble *array=DataArrayDouble::New(); - int nbOfCells=getNumberOfCells(); + MCAuto ret(MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME)); + MCAuto array(DataArrayDouble::New()); + int nbOfCells(getNumberOfCells()); array->alloc(nbOfCells,3); - double *vals=array->getPointer(); + double *vals(array->getPointer()); for(int i=0;isetArray(array); - array->decrRef(); ret->setMesh(this); - return ret; + return ret.retn(); } void MEDCouplingStructuredMesh::getReverseNodalConnectivity(DataArrayInt *revNodal, DataArrayInt *revNodalIndx) const @@ -631,7 +635,7 @@ DataArrayInt *MEDCouplingStructuredMesh::Build1GTNodalConnectivity(const int *no { case 0: { - MEDCouplingAutoRefCountObjectPtr conn(DataArrayInt::New()); + MCAuto conn(DataArrayInt::New()); conn->alloc(1,1); conn->setIJ(0,0,0); return conn.retn(); } @@ -673,7 +677,7 @@ DataArrayInt *MEDCouplingStructuredMesh::ComputeCornersGhost(const std::vector= 0 !"); std::size_t dim(st.size()); - MEDCouplingAutoRefCountObjectPtr ret(DataArrayInt::New()); + MCAuto ret(DataArrayInt::New()); switch(dim) { case 1: @@ -961,11 +965,11 @@ std::vector< std::vector > MEDCouplingStructuredMesh::ComputeSignaturePerAx DataArrayInt *MEDCouplingStructuredMesh::Build1GTNodalConnectivity1D(const int *nodeStBg) { - int nbOfCells(*nodeStBg-1); - MEDCouplingAutoRefCountObjectPtr conn(DataArrayInt::New()); + std::size_t nbOfCells(*nodeStBg-1); + MCAuto conn(DataArrayInt::New()); conn->alloc(2*nbOfCells,1); int *cp=conn->getPointer(); - for(int i=0;i conn(DataArrayInt::New()); + std::size_t n1(nodeStBg[0]-1),n2(nodeStBg[1]-1); + MCAuto conn(DataArrayInt::New()); conn->alloc(4*n1*n2,1); - int *cp=conn->getPointer(); - int pos=0; - for(int j=0;jgetPointer()); + std::size_t pos(0); + for(std::size_t j=0;j conn(DataArrayInt::New()); + std::size_t n1(nodeStBg[0]-1),n2(nodeStBg[1]-1),n3(nodeStBg[2]-1); + MCAuto conn(DataArrayInt::New()); conn->alloc(8*n1*n2*n3,1); - int *cp=conn->getPointer(); - int pos=0; - for(int k=0;kgetPointer()); + std::size_t pos(0); + for(std::size_t k=0;k ngs(3); int n0(nodeStBg[0]-1),n1(nodeStBg[1]-1),n2(nodeStBg[2]-1); ngs[0]=n0; ngs[1]=n1; ngs[2]=n2; int off0(nodeStBg[0]),off1(nodeStBg[0]*nodeStBg[1]); - MEDCouplingAutoRefCountObjectPtr conn(DataArrayInt::New()); + MCAuto conn(DataArrayInt::New()); conn->alloc(4*GetNumberOfCellsOfSubLevelMesh(ngs,3)); int *cp(conn->getPointer()); //X @@ -1188,7 +1189,7 @@ DataArrayInt *MEDCouplingStructuredMesh::Build1GTNodalConnectivityOfSubLevelMesh std::vector ngs(2); int n0(nodeStBg[0]-1),n1(nodeStBg[1]-1); ngs[0]=n0; ngs[1]=n1; int off0(nodeStBg[0]); - MEDCouplingAutoRefCountObjectPtr conn(DataArrayInt::New()); + MCAuto conn(DataArrayInt::New()); conn->alloc(2*GetNumberOfCellsOfSubLevelMesh(ngs,2)); int *cp(conn->getPointer()); //X @@ -1238,10 +1239,10 @@ int MEDCouplingStructuredMesh::getNodeIdFromPos(int i, int j, int k) const } -int MEDCouplingStructuredMesh::getNumberOfCells() const +std::size_t MEDCouplingStructuredMesh::getNumberOfCells() const { std::vector ngs(getNodeGridStructure()); - int ret(1); + std::size_t ret(1); bool isCatched(false); std::size_t ii(0); for(std::vector::const_iterator it=ngs.begin();it!=ngs.end();it++,ii++) @@ -1270,9 +1271,55 @@ int MEDCouplingStructuredMesh::getNumberOfNodes() const return ret; } -void MEDCouplingStructuredMesh::GetPosFromId(int nodeId, int meshDim, const int *split, int *res) +/*! + * This method returns for a cell which id is \a cellId the location (locX,locY,locZ) of this cell in \a this. + * + * \param [in] cellId + * \return - A vector of size this->getMeshDimension() + * \throw if \a cellId not in [ 0, this->getNumberOfCells() ) + */ +std::vector MEDCouplingStructuredMesh::getLocationFromCellId(int cellId) const +{ + int meshDim(getMeshDimension()); + std::vector ret(meshDim); + std::vector struc(getCellGridStructure()); + int nbCells(std::accumulate(struc.begin(),struc.end(),1,std::multiplies())); + if(cellId<0 || cellId>=nbCells) + { + std::ostringstream oss; oss << "MEDCouplingStructuredMesh::getLocationFromCellId : Input cell id (" << cellId << ") is invalid ! Should be in [0," << nbCells << ") !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + std::vector spt(GetSplitVectFromStruct(struc)); + GetPosFromId(cellId,meshDim,&spt[0],&ret[0]); + return ret; +} + +/*! + * This method returns for a node which id is \a nodeId the location (locX,locY,locZ) of this node in \a this. + * + * \param [in] nodeId + * \return - A vector of size this->getSpaceDimension() + * \throw if \a cellId not in [ 0, this->getNumberOfNodes() ) + */ +std::vector MEDCouplingStructuredMesh::getLocationFromNodeId(int nodeId) const { - int work=nodeId; + int spaceDim(getSpaceDimension()); + std::vector ret(spaceDim); + std::vector struc(getNodeGridStructure()); + int nbNodes(std::accumulate(struc.begin(),struc.end(),1,std::multiplies())); + if(nodeId<0 || nodeId>=nbNodes) + { + std::ostringstream oss; oss << "MEDCouplingStructuredMesh::getLocationFromNodeId : Input node id (" << nodeId << ") is invalid ! Should be in [0," << nbNodes << ") !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + std::vector spt(GetSplitVectFromStruct(struc)); + GetPosFromId(nodeId,spaceDim,&spt[0],&ret[0]); + return ret; +} + +void MEDCouplingStructuredMesh::GetPosFromId(int eltId, int meshDim, const int *split, int *res) +{ + int work(eltId); for(int i=meshDim-1;i>=0;i--) { int pos=work/split[i]; @@ -1469,6 +1516,8 @@ std::vector< std::pair > MEDCouplingStructuredMesh::GetCompactFrmtFromD /*! * This method returns the intersection zone of two ranges (in compact format) \a r1 and \a r2. * This method will throw exception if on one axis the intersection is empty. + * + * \sa AreRangesIntersect */ std::vector< std::pair > MEDCouplingStructuredMesh::IntersectRanges(const std::vector< std::pair >& r1, const std::vector< std::pair >& r2) { @@ -1499,6 +1548,36 @@ std::vector< std::pair > MEDCouplingStructuredMesh::IntersectRanges(con return ret; } +/*! + * This method states if \a r1 and \a r2 do overlap of not. If yes you can call IntersectRanges to know the intersection area. + * + * \sa IntersectRanges + */ +bool MEDCouplingStructuredMesh::AreRangesIntersect(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::AreRangesIntersect : the two ranges must have the same dimension !"); + for(std::size_t i=0;ir1[i].second) + { + std::ostringstream oss; oss << "MEDCouplingStructuredMesh::AreRangesIntersect : 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::AreRangesIntersect : On axis " << i << " of range r2, end is before start !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + if(r1[i].second<=r2[i].first) + return false; + if(r1[i].first>=r2[i].second) + return false; + } + return true; +} + /*! * This method is close to BuildExplicitIdsFrom except that instead of returning a DataArrayInt instance containing explicit ids it * enable elems in the vector of booleans (for performance reasons). As it is method for performance, this method is \b not @@ -1634,7 +1713,7 @@ DataArrayDouble *MEDCouplingStructuredMesh::ExtractFieldOfDoubleFrom(const std:: throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::ExtractFieldOfDoubleFrom : invalid size of input array of double regarding the structure !"); std::vector dims(GetDimensionsFromCompactFrmt(partCompactFormat)); int nbOfTuplesOfOutField(DeduceNumberOfGivenStructure(dims)),nbComp(fieldOfDbl->getNumberOfComponents()); - MEDCouplingAutoRefCountObjectPtr ret(DataArrayDouble::New()); ret->alloc(nbOfTuplesOfOutField,nbComp); + MCAuto ret(DataArrayDouble::New()); ret->alloc(nbOfTuplesOfOutField,nbComp); ret->copyStringInfoFrom(*fieldOfDbl); double *ptRet(ret->getPointer()); const double *fieldOfDblPtr(fieldOfDbl->begin()); @@ -1676,6 +1755,20 @@ DataArrayDouble *MEDCouplingStructuredMesh::ExtractFieldOfDoubleFrom(const std:: return ret.retn(); } +/*! + * This method assign a part of values in \a fieldOfDbl using entirely values of \b other. + * + * \param [in] st - the structure of \a fieldOfDbl. + * \param [in,out] fieldOfDbl - the array that will be partially filled using \a other. + * \param [in] partCompactFormat - the specification of the part. + * \param [in] other - the array that will be used to fill \a fieldOfDbl. + */ +void MEDCouplingStructuredMesh::AssignPartOfFieldOfDoubleUsing(const std::vector& st, DataArrayDouble *fieldOfDbl, const std::vector< std::pair >& partCompactFormat, const DataArrayDouble *other) +{//to be optimized + std::vector facts(st.size(),1.); + MEDCouplingIMesh::CondenseFineToCoarse(st,other,partCompactFormat,facts,fieldOfDbl); +} + /*! * This method changes the reference of a part of structured mesh \a partOfBigInAbs define in absolute reference to a new reference \a bigInAbs. * So this method only performs a translation by doing \a partOfBigRelativeToBig = \a partOfBigInAbs - \a bigInAbs @@ -1794,7 +1887,7 @@ std::vector MEDCouplingStructuredMesh::FindTranslationFrom(const std::vecto /*! * This method builds the explicit entity array from the structure in \a st and the range in \a partCompactFormat. - * If the range contains invalid values regarding sructure an exception will be thrown. + * If the range contains invalid values regarding structure an exception will be thrown. * * \return DataArrayInt * - a new object. * \sa MEDCouplingStructuredMesh::IsPartStructured, MEDCouplingStructuredMesh::DeduceNumberOfGivenRangeInCompactFrmt, SwitchOnIdsFrom, ExtractFieldOfBoolFrom, ExtractFieldOfDoubleFrom, MultiplyPartOf @@ -1816,7 +1909,7 @@ DataArrayInt *MEDCouplingStructuredMesh::BuildExplicitIdsFrom(const std::vector< dims[i]=partCompactFormat[i].second-partCompactFormat[i].first; nbOfItems*=dims[i]; } - MEDCouplingAutoRefCountObjectPtr ret(DataArrayInt::New()); + MCAuto ret(DataArrayInt::New()); ret->alloc(nbOfItems,1); int *pt(ret->getPointer()); switch(st.size()) @@ -1863,7 +1956,7 @@ DataArrayInt *MEDCouplingStructuredMesh::BuildExplicitIdsFrom(const std::vector< * \param [in] st - the structure of grid ( \b without considering ghost cells). * \param [in] part - the part in the structure ( \b without considering ghost cells) contained in grid whose structure is defined by \a st. * \param [in] factor - the factor, the tuples in \a da will be multiply by. - * \param [in,out] da - The DataArray in wich only tuples specified by \a part will be modified. + * \param [in,out] da - The DataArray in which only tuples specified by \a part will be modified. * * \sa BuildExplicitIdsFrom */ @@ -1944,7 +2037,7 @@ void MEDCouplingStructuredMesh::MultiplyPartOf(const std::vector& st, const * \param [in] part - the part in the structure ( \b without considering ghost cells) contained in grid whose structure is defined by \a st. * \param [in] ghostSize - \a ghostSize must be >= 0. * \param [in] factor - the factor, the tuples in \a da will be multiply by. - * \param [in,out] da - The DataArray in wich only tuples specified by \a part will be modified. + * \param [in,out] da - The DataArray in which only tuples specified by \a part will be modified. * * \sa MultiplyPartOf, PutInGhostFormat */