X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDCoupling%2FMEDCouplingIMesh.cxx;h=d28b5c07b8a10b22a124e52242a851ff10b28c24;hb=04f1c450d57b28c7c473bdc59dc87eeef7393ca5;hp=6ba02d4a028c28aeb404120a8d67d4563977ee67;hpb=7de62920cadf9bfcd33addf31d4a8256bffaf1ec;p=tools%2Fmedcoupling.git diff --git a/src/MEDCoupling/MEDCouplingIMesh.cxx b/src/MEDCoupling/MEDCouplingIMesh.cxx old mode 100644 new mode 100755 index 6ba02d4a0..d28b5c07b --- a/src/MEDCoupling/MEDCouplingIMesh.cxx +++ b/src/MEDCoupling/MEDCouplingIMesh.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2016 CEA/DEN, EDF R&D +// Copyright (C) 2007-2020 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 @@ -53,7 +53,7 @@ MEDCouplingIMesh *MEDCouplingIMesh::New() return new MEDCouplingIMesh; } -MEDCouplingIMesh *MEDCouplingIMesh::New(const std::string& meshName, int spaceDim, const int *nodeStrctStart, const int *nodeStrctStop, +MEDCouplingIMesh *MEDCouplingIMesh::New(const std::string& meshName, int spaceDim, const mcIdType *nodeStrctStart, const mcIdType *nodeStrctStop, const double *originStart, const double *originStop, const double *dxyzStart, const double *dxyzStop) { MCAuto ret(new MEDCouplingIMesh); @@ -88,17 +88,17 @@ const DataArrayDouble *MEDCouplingIMesh::getDirectAccessOfCoordsArrIfInStructure * \return MEDCouplingIMesh * - a newly alloacted object to be managed by the caller. * \throw if \a ghostLev < 0. */ -MEDCouplingIMesh *MEDCouplingIMesh::buildWithGhost(int ghostLev) const +MEDCouplingIMesh *MEDCouplingIMesh::buildWithGhost(mcIdType ghostLev) const { if(ghostLev<0) throw INTERP_KERNEL::Exception("MEDCouplingIMesh::buildWithGhost : the ghostLev must be >= 0 !"); checkConsistencyLight(); int spaceDim(getSpaceDimension()); double origin[3],dxyz[3]; - int structure[3]; + mcIdType structure[3]; for(int i=0;i(ghostLev)*_dxyz[i]; dxyz[i]=_dxyz[i]; structure[i]=_structure[i]+2*ghostLev; } @@ -107,26 +107,26 @@ MEDCouplingIMesh *MEDCouplingIMesh::buildWithGhost(int ghostLev) const return ret.retn(); } -void MEDCouplingIMesh::setNodeStruct(const int *nodeStrctStart, const int *nodeStrctStop) +void MEDCouplingIMesh::setNodeStruct(const mcIdType *nodeStrctStart, const mcIdType *nodeStrctStop) { checkSpaceDimension(); - int sz((int)std::distance(nodeStrctStart,nodeStrctStop)); + mcIdType sz((mcIdType)std::distance(nodeStrctStart,nodeStrctStop)); if(sz!=_space_dim) throw INTERP_KERNEL::Exception("MEDCouplingIMesh::setNodeStruct : input vector of node structure has not the right size ! Or change space dimension before calling it !"); std::copy(nodeStrctStart,nodeStrctStop,_structure); declareAsNew(); } -std::vector MEDCouplingIMesh::getNodeStruct() const +std::vector MEDCouplingIMesh::getNodeStruct() const { checkSpaceDimension(); - return std::vector(_structure,_structure+_space_dim); + return std::vector(_structure,_structure+_space_dim); } void MEDCouplingIMesh::setOrigin(const double *originStart, const double *originStop) { checkSpaceDimension(); - int sz((int)std::distance(originStart,originStop)); + mcIdType sz(ToIdType(std::distance(originStart,originStop))); if(sz!=_space_dim) throw INTERP_KERNEL::Exception("MEDCouplingIMesh::setOrigin : input vector of origin vector has not the right size ! Or change space dimension before calling it !"); std::copy(originStart,originStop,_origin); @@ -142,7 +142,7 @@ std::vector MEDCouplingIMesh::getOrigin() const void MEDCouplingIMesh::setDXYZ(const double *dxyzStart, const double *dxyzStop) { checkSpaceDimension(); - int sz((int)std::distance(dxyzStart,dxyzStop)); + mcIdType sz(ToIdType(std::distance(dxyzStart,dxyzStop))); if(sz!=_space_dim) throw INTERP_KERNEL::Exception("MEDCouplingIMesh::setDXYZ : input vector of dxyz vector has not the right size ! Or change space dimension before calling it !"); std::copy(dxyzStart,dxyzStop,_dxyz); @@ -214,12 +214,12 @@ MEDCouplingCMesh *MEDCouplingIMesh::convertToCartesian() const * The origin of \a this will be not touched only spacing and node structure will be changed. * This method can be useful for AMR users. */ -void MEDCouplingIMesh::refineWithFactor(const std::vector& factors) +void MEDCouplingIMesh::refineWithFactor(const std::vector& factors) { - if((int)factors.size()!=_space_dim) + if(ToIdType(factors.size())!=_space_dim) throw INTERP_KERNEL::Exception("MEDCouplingIMesh::refineWithFactor : refinement factors must have size equal to spaceDim !"); checkConsistencyLight(); - std::vector structure(_structure,_structure+3); + std::vector structure(_structure,_structure+3); std::vector dxyz(_dxyz,_dxyz+3); for(int i=0;i<_space_dim;i++) { @@ -228,7 +228,7 @@ void MEDCouplingIMesh::refineWithFactor(const std::vector& factors) std::ostringstream oss; oss << "MEDCouplingIMesh::refineWithFactor : factor for axis #" << i << " (" << factors[i] << ")is invalid ! Must be > 0 !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - int factAbs(std::abs(factors[i])); + mcIdType factAbs(std::abs(factors[i])); double fact2(1./(double)factors[i]); structure[i]=(_structure[i]-1)*factAbs+1; dxyz[i]=fact2*_dxyz[i]; @@ -248,14 +248,14 @@ void MEDCouplingIMesh::refineWithFactor(const std::vector& factors) MEDCouplingIMesh *MEDCouplingIMesh::asSingleCell() const { checkConsistencyLight(); - int spaceDim(getSpaceDimension()),nodeSt[3]; + mcIdType spaceDim(getSpaceDimension()),nodeSt[3]; double dxyz[3]; for(int i=0;i=2) { nodeSt[i]=2; - dxyz[i]=(_structure[i]-1)*_dxyz[i]; + dxyz[i]=double(_structure[i]-1)*_dxyz[i]; } else { @@ -281,24 +281,25 @@ MEDCouplingIMesh *MEDCouplingIMesh::asSingleCell() const * * \sa CondenseFineToCoarseGhost,SpreadCoarseToFine */ -void MEDCouplingIMesh::CondenseFineToCoarse(const std::vector& coarseSt, const DataArrayDouble *fineDA, const std::vector< std::pair >& fineLocInCoarse, const std::vector& facts, DataArrayDouble *coarseDA) +void MEDCouplingIMesh::CondenseFineToCoarse(const std::vector& coarseSt, const DataArrayDouble *fineDA, const std::vector< std::pair >& fineLocInCoarse, const std::vector& facts, DataArrayDouble *coarseDA) { if(coarseSt.size()!=fineLocInCoarse.size() || coarseSt.size()!=facts.size()) throw INTERP_KERNEL::Exception("MEDCouplingIMesh::CondenseFineToCoarse : All input vectors (dimension) must have the same size !"); if(!coarseDA || !coarseDA->isAllocated() || !fineDA || !fineDA->isAllocated()) throw INTERP_KERNEL::Exception("MEDCouplingIMesh::CondenseFineToCoarse : the parameters 1 or 3 are NULL or not allocated !"); - int meshDim((int)coarseSt.size()),nbOfTuplesInCoarseExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(coarseSt)),nbOfTuplesInFineExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenRangeInCompactFrmt(fineLocInCoarse)); - int nbCompo(fineDA->getNumberOfComponents()); - if((int)coarseDA->getNumberOfComponents()!=nbCompo) + std::size_t meshDim(coarseSt.size()); + mcIdType nbOfTuplesInCoarseExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(coarseSt)),nbOfTuplesInFineExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenRangeInCompactFrmt(fineLocInCoarse)); + std::size_t nbCompo=fineDA->getNumberOfComponents(); + if(coarseDA->getNumberOfComponents()!=nbCompo) throw INTERP_KERNEL::Exception("MEDCouplingIMesh::CondenseFineToCoarse : the number of components of fine DA and coarse one mismatches !"); - if(meshDim!=(int)fineLocInCoarse.size() || meshDim!=(int)facts.size()) + if(meshDim!=fineLocInCoarse.size() || meshDim!=facts.size()) throw INTERP_KERNEL::Exception("MEDCouplingIMesh::CondenseFineToCoarse : the size of fineLocInCoarse (4th param) and facts (5th param) must be equal to the sier of coarseSt (2nd param) !"); if(coarseDA->getNumberOfTuples()!=nbOfTuplesInCoarseExp) { std::ostringstream oss; oss << "MEDCouplingIMesh::CondenseFineToCoarse : Expecting " << nbOfTuplesInCoarseExp << " tuples having " << coarseDA->getNumberOfTuples() << " !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - int nbTuplesFine(fineDA->getNumberOfTuples()); + mcIdType nbTuplesFine(fineDA->getNumberOfTuples()); if(nbOfTuplesInFineExp==0) { if(nbTuplesFine==0) @@ -308,7 +309,7 @@ void MEDCouplingIMesh::CondenseFineToCoarse(const std::vector& coarseSt, co } if(nbTuplesFine%nbOfTuplesInFineExp!=0) throw INTERP_KERNEL::Exception("MEDCouplingIMesh::CondenseFineToCoarse : Invalid nb of tuples in fine DataArray regarding its structure !"); - int fact(std::accumulate(facts.begin(),facts.end(),1,std::multiplies())); + mcIdType fact(std::accumulate(facts.begin(),facts.end(),1,std::multiplies())); if(nbTuplesFine!=fact*nbOfTuplesInFineExp) { std::ostringstream oss; oss << "MEDCouplingIMesh::CondenseFineToCoarse : Invalid number of tuples (" << nbTuplesFine << ") of fine dataarray is invalid ! Must be " << fact*nbOfTuplesInFineExp << "!"; @@ -318,16 +319,16 @@ void MEDCouplingIMesh::CondenseFineToCoarse(const std::vector& coarseSt, co double *outPtr(coarseDA->getPointer()); const double *inPtr(fineDA->begin()); // - std::vector dims(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(fineLocInCoarse)); + std::vector dims(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(fineLocInCoarse)); switch(meshDim) { case 1: { - int offset(fineLocInCoarse[0].first),fact0(facts[0]); + mcIdType offset(fineLocInCoarse[0].first),fact0(facts[0]); for(int i=0;i()); @@ -339,15 +340,15 @@ void MEDCouplingIMesh::CondenseFineToCoarse(const std::vector& coarseSt, co } case 2: { - int kk(fineLocInCoarse[0].first+coarseSt[0]*fineLocInCoarse[1].first),fact1(facts[1]),fact0(facts[0]); + mcIdType kk(fineLocInCoarse[0].first+coarseSt[0]*fineLocInCoarse[1].first),fact1(facts[1]),fact0(facts[0]); for(int j=0;j()); @@ -362,19 +363,19 @@ void MEDCouplingIMesh::CondenseFineToCoarse(const std::vector& coarseSt, co } case 3: { - int kk(fineLocInCoarse[0].first+coarseSt[0]*fineLocInCoarse[1].first+coarseSt[0]*coarseSt[1]*fineLocInCoarse[2].first),fact2(facts[2]),fact1(facts[1]),fact0(facts[0]); + mcIdType kk(fineLocInCoarse[0].first+coarseSt[0]*fineLocInCoarse[1].first+coarseSt[0]*coarseSt[1]*fineLocInCoarse[2].first),fact2(facts[2]),fact1(facts[1]),fact0(facts[0]); for(int k=0;k()); @@ -408,7 +409,7 @@ void MEDCouplingIMesh::CondenseFineToCoarse(const std::vector& coarseSt, co * * \sa CondenseFineToCoarse,SpreadCoarseToFineGhost */ -void MEDCouplingIMesh::CondenseFineToCoarseGhost(const std::vector& coarseSt, const DataArrayDouble *fineDA, const std::vector< std::pair >& fineLocInCoarse, const std::vector& facts, DataArrayDouble *coarseDA, int ghostSize) +void MEDCouplingIMesh::CondenseFineToCoarseGhost(const std::vector& coarseSt, const DataArrayDouble *fineDA, const std::vector< std::pair >& fineLocInCoarse, const std::vector& facts, DataArrayDouble *coarseDA, mcIdType ghostSize) { if(ghostSize<0) throw INTERP_KERNEL::Exception("MEDCouplingIMesh::CondenseFineToCoarseGhost : ghost level has to be >= 0 !"); @@ -416,12 +417,13 @@ void MEDCouplingIMesh::CondenseFineToCoarseGhost(const std::vector& coarseS throw INTERP_KERNEL::Exception("MEDCouplingIMesh::CondenseFineToCoarseGhost : All input vectors (dimension) must have the same size !"); if(!coarseDA || !coarseDA->isAllocated() || !fineDA || !fineDA->isAllocated()) throw INTERP_KERNEL::Exception("MEDCouplingIMesh::CondenseFineToCoarseGhost : the parameters 1 or 3 are NULL or not allocated !"); - std::vector coarseStG(coarseSt.size()); std::transform(coarseSt.begin(),coarseSt.end(),coarseStG.begin(),std::bind2nd(std::plus(),2*ghostSize)); - int meshDim((int)coarseSt.size()),nbOfTuplesInCoarseExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(coarseStG)); - int nbCompo(fineDA->getNumberOfComponents()); - if((int)coarseDA->getNumberOfComponents()!=nbCompo) + std::vector coarseStG(coarseSt.size()); std::transform(coarseSt.begin(),coarseSt.end(),coarseStG.begin(),std::bind2nd(std::plus(),2*ghostSize)); + std::size_t meshDim(coarseSt.size()); + mcIdType nbOfTuplesInCoarseExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(coarseStG)); + std::size_t nbCompo(fineDA->getNumberOfComponents()); + if(coarseDA->getNumberOfComponents()!=nbCompo) throw INTERP_KERNEL::Exception("MEDCouplingIMesh::CondenseFineToCoarseGhost : the number of components of fine DA and coarse one mismatches !"); - if(meshDim!=(int)fineLocInCoarse.size() || meshDim!=(int)facts.size()) + if(meshDim!=fineLocInCoarse.size() || meshDim!=facts.size()) throw INTERP_KERNEL::Exception("MEDCouplingIMesh::CondenseFineToCoarseGhost : the size of fineLocInCoarse (4th param) and facts (5th param) must be equal to the sier of coarseSt (2nd param) !"); if(coarseDA->getNumberOfTuples()!=nbOfTuplesInCoarseExp) { @@ -429,10 +431,10 @@ void MEDCouplingIMesh::CondenseFineToCoarseGhost(const std::vector& coarseS throw INTERP_KERNEL::Exception(oss.str().c_str()); } // - std::vector fineStG(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(fineLocInCoarse)); - std::transform(fineStG.begin(),fineStG.end(),facts.begin(),fineStG.begin(),std::multiplies()); - std::transform(fineStG.begin(),fineStG.end(),fineStG.begin(),std::bind2nd(std::plus(),2*ghostSize)); - int nbTuplesFine(fineDA->getNumberOfTuples()),nbTuplesFineExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(fineStG)); + std::vector fineStG(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(fineLocInCoarse)); + std::transform(fineStG.begin(),fineStG.end(),facts.begin(),fineStG.begin(),std::multiplies()); + std::transform(fineStG.begin(),fineStG.end(),fineStG.begin(),std::bind2nd(std::plus(),2*ghostSize)); + mcIdType nbTuplesFine(fineDA->getNumberOfTuples()),nbTuplesFineExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(fineStG)); if(fineDA->getNumberOfTuples()!=nbTuplesFineExp) { std::ostringstream oss; oss << "MEDCouplingIMesh::CondenseFineToCoarseGhost : Expecting " << nbTuplesFineExp << " tuples in fine DataArray having " << nbTuplesFine << " !"; @@ -442,17 +444,17 @@ void MEDCouplingIMesh::CondenseFineToCoarseGhost(const std::vector& coarseS double *outPtr(coarseDA->getPointer()); const double *inPtr(fineDA->begin()); // - std::vector dims(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(fineLocInCoarse)); + std::vector dims(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(fineLocInCoarse)); switch(meshDim) { case 1: { - int offset(fineLocInCoarse[0].first+ghostSize),fact0(facts[0]); + mcIdType offset(fineLocInCoarse[0].first+ghostSize),fact0(facts[0]); inPtr+=ghostSize*nbCompo; for(int i=0;i()); @@ -464,18 +466,18 @@ void MEDCouplingIMesh::CondenseFineToCoarseGhost(const std::vector& coarseS } case 2: { - int nxwg(coarseSt[0]+2*ghostSize); - int kk(fineLocInCoarse[0].first+ghostSize+nxwg*(fineLocInCoarse[1].first+ghostSize)),fact1(facts[1]),fact0(facts[0]); + mcIdType nxwg(coarseSt[0]+2*ghostSize); + mcIdType kk(fineLocInCoarse[0].first+ghostSize+nxwg*(fineLocInCoarse[1].first+ghostSize)),fact1(facts[1]),fact0(facts[0]); inPtr+=(dims[0]*fact0+2*ghostSize)*ghostSize*nbCompo; for(int j=0;j()); @@ -491,24 +493,24 @@ void MEDCouplingIMesh::CondenseFineToCoarseGhost(const std::vector& coarseS } case 3: { - int nxwg(coarseSt[0]+2*ghostSize),nxywg((coarseSt[0]+2*ghostSize)*(coarseSt[1]+2*ghostSize)); - int kk(fineLocInCoarse[0].first+ghostSize+nxwg*(fineLocInCoarse[1].first+ghostSize)+nxywg*(fineLocInCoarse[2].first+ghostSize)),fact2(facts[2]),fact1(facts[1]),fact0(facts[0]); + mcIdType nxwg(coarseSt[0]+2*ghostSize),nxywg((coarseSt[0]+2*ghostSize)*(coarseSt[1]+2*ghostSize)); + mcIdType kk(fineLocInCoarse[0].first+ghostSize+nxwg*(fineLocInCoarse[1].first+ghostSize)+nxywg*(fineLocInCoarse[2].first+ghostSize)),fact2(facts[2]),fact1(facts[1]),fact0(facts[0]); inPtr+=(dims[0]*fact0+2*ghostSize)*(dims[1]*fact1+2*ghostSize)*ghostSize*nbCompo; for(int k=0;k()); @@ -540,27 +542,28 @@ void MEDCouplingIMesh::CondenseFineToCoarseGhost(const std::vector& coarseS * \param [in] facts The refinement coefficient per axis. * \sa SpreadCoarseToFineGhost, CondenseFineToCoarse */ -void MEDCouplingIMesh::SpreadCoarseToFine(const DataArrayDouble *coarseDA, const std::vector& coarseSt, DataArrayDouble *fineDA, const std::vector< std::pair >& fineLocInCoarse, const std::vector& facts) +void MEDCouplingIMesh::SpreadCoarseToFine(const DataArrayDouble *coarseDA, const std::vector& coarseSt, DataArrayDouble *fineDA, const std::vector< std::pair >& fineLocInCoarse, const std::vector& facts) { if(coarseSt.size()!=fineLocInCoarse.size() || coarseSt.size()!=facts.size()) throw INTERP_KERNEL::Exception("MEDCouplingIMesh::SpreadCoarseToFine : All input vectors (dimension) must have the same size !"); if(!coarseDA || !coarseDA->isAllocated() || !fineDA || !fineDA->isAllocated()) throw INTERP_KERNEL::Exception("MEDCouplingIMesh::SpreadCoarseToFine : the parameters 1 or 3 are NULL or not allocated !"); - int meshDim((int)coarseSt.size()),nbOfTuplesInCoarseExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(coarseSt)),nbOfTuplesInFineExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenRangeInCompactFrmt(fineLocInCoarse)); - int nbCompo(fineDA->getNumberOfComponents()); - if((int)coarseDA->getNumberOfComponents()!=nbCompo) + std::size_t meshDim(coarseSt.size()); + mcIdType nbOfTuplesInCoarseExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(coarseSt)),nbOfTuplesInFineExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenRangeInCompactFrmt(fineLocInCoarse)); + std::size_t nbCompo=fineDA->getNumberOfComponents(); + if(coarseDA->getNumberOfComponents()!=nbCompo) throw INTERP_KERNEL::Exception("MEDCouplingIMesh::SpreadCoarseToFine : the number of components of fine DA and coarse one mismatches !"); - if(meshDim!=(int)fineLocInCoarse.size() || meshDim!=(int)facts.size()) + if(meshDim!=fineLocInCoarse.size() || meshDim!=facts.size()) throw INTERP_KERNEL::Exception("MEDCouplingIMesh::SpreadCoarseToFine : the size of fineLocInCoarse (4th param) and facts (5th param) must be equal to the sier of coarseSt (2nd param) !"); if(coarseDA->getNumberOfTuples()!=nbOfTuplesInCoarseExp) { std::ostringstream oss; oss << "MEDCouplingIMesh::SpreadCoarseToFine : Expecting " << nbOfTuplesInCoarseExp << " tuples having " << coarseDA->getNumberOfTuples() << " !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - int nbTuplesFine(fineDA->getNumberOfTuples()); + mcIdType nbTuplesFine(fineDA->getNumberOfTuples()); if(nbTuplesFine%nbOfTuplesInFineExp!=0) throw INTERP_KERNEL::Exception("MEDCouplingIMesh::SpreadCoarseToFine : Invalid nb of tuples in fine DataArray regarding its structure !"); - int fact(std::accumulate(facts.begin(),facts.end(),1,std::multiplies())); + mcIdType fact(std::accumulate(facts.begin(),facts.end(),1,std::multiplies())); if(nbTuplesFine!=fact*nbOfTuplesInFineExp) { std::ostringstream oss; oss << "MEDCouplingIMesh::SpreadCoarseToFine : Invalid number of tuples (" << nbTuplesFine << ") of fine dataarray is invalid ! Must be " << fact*nbOfTuplesInFineExp << "!"; @@ -570,31 +573,31 @@ void MEDCouplingIMesh::SpreadCoarseToFine(const DataArrayDouble *coarseDA, const double *outPtr(fineDA->getPointer()); const double *inPtr(coarseDA->begin()); // - std::vector dims(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(fineLocInCoarse)); + std::vector dims(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(fineLocInCoarse)); switch(meshDim) { case 1: { - int offset(fineLocInCoarse[0].first),fact0(facts[0]); + mcIdType offset(fineLocInCoarse[0].first),fact0(facts[0]); for(int i=0;i& coarseSt, DataArrayDouble *fineDA, const std::vector< std::pair >& fineLocInCoarse, const std::vector& facts, int ghostSize) +void MEDCouplingIMesh::SpreadCoarseToFineGhost(const DataArrayDouble *coarseDA, const std::vector& coarseSt, DataArrayDouble *fineDA, const std::vector< std::pair >& fineLocInCoarse, const std::vector& facts, mcIdType ghostSize) { if(ghostSize<0) throw INTERP_KERNEL::Exception("MEDCouplingIMesh::SpreadCoarseToFineGhost : ghost level has to be >= 0 !"); @@ -651,12 +654,13 @@ void MEDCouplingIMesh::SpreadCoarseToFineGhost(const DataArrayDouble *coarseDA, throw INTERP_KERNEL::Exception("MEDCouplingIMesh::SpreadCoarseToFineGhost : All input vectors (dimension) must have the same size !"); if(!coarseDA || !coarseDA->isAllocated() || !fineDA || !fineDA->isAllocated()) throw INTERP_KERNEL::Exception("MEDCouplingIMesh::SpreadCoarseToFineGhost : the parameters 1 or 3 are NULL or not allocated !"); - std::vector coarseStG(coarseSt.size()); std::transform(coarseSt.begin(),coarseSt.end(),coarseStG.begin(),std::bind2nd(std::plus(),2*ghostSize)); - int meshDim((int)coarseSt.size()),nbOfTuplesInCoarseExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(coarseStG)); - int nbCompo(fineDA->getNumberOfComponents()); - if((int)coarseDA->getNumberOfComponents()!=nbCompo) + std::vector coarseStG(coarseSt.size()); std::transform(coarseSt.begin(),coarseSt.end(),coarseStG.begin(),std::bind2nd(std::plus(),2*ghostSize)); + std::size_t meshDim(coarseSt.size()); + mcIdType nbOfTuplesInCoarseExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(coarseStG)); + std::size_t nbCompo=fineDA->getNumberOfComponents(); + if(coarseDA->getNumberOfComponents()!=nbCompo) throw INTERP_KERNEL::Exception("MEDCouplingIMesh::SpreadCoarseToFineGhost : the number of components of fine DA and coarse one mismatches !"); - if(meshDim!=(int)fineLocInCoarse.size() || meshDim!=(int)facts.size()) + if(meshDim!=fineLocInCoarse.size() || meshDim!=facts.size()) throw INTERP_KERNEL::Exception("MEDCouplingIMesh::SpreadCoarseToFineGhost : the size of fineLocInCoarse (4th param) and facts (5th param) must be equal to the sier of coarseSt (2nd param) !"); if(coarseDA->getNumberOfTuples()!=nbOfTuplesInCoarseExp) { @@ -664,10 +668,10 @@ void MEDCouplingIMesh::SpreadCoarseToFineGhost(const DataArrayDouble *coarseDA, throw INTERP_KERNEL::Exception(oss.str().c_str()); } // - std::vector fineStG(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(fineLocInCoarse)); - std::transform(fineStG.begin(),fineStG.end(),facts.begin(),fineStG.begin(),std::multiplies()); - std::transform(fineStG.begin(),fineStG.end(),fineStG.begin(),std::bind2nd(std::plus(),2*ghostSize)); - int nbTuplesFine(fineDA->getNumberOfTuples()),nbTuplesFineExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(fineStG)); + std::vector fineStG(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(fineLocInCoarse)); + std::transform(fineStG.begin(),fineStG.end(),facts.begin(),fineStG.begin(),std::multiplies()); + std::transform(fineStG.begin(),fineStG.end(),fineStG.begin(),std::bind2nd(std::plus(),2*ghostSize)); + mcIdType nbTuplesFine(fineDA->getNumberOfTuples()),nbTuplesFineExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(fineStG)); if(fineDA->getNumberOfTuples()!=nbTuplesFineExp) { std::ostringstream oss; oss << "MEDCouplingIMesh::SpreadCoarseToFineGhost : Expecting " << nbTuplesFineExp << " tuples in fine DataArray having " << nbTuplesFine << " !"; @@ -681,19 +685,19 @@ void MEDCouplingIMesh::SpreadCoarseToFineGhost(const DataArrayDouble *coarseDA, { case 1: { - std::vector dims(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(fineLocInCoarse)); - int offset(fineLocInCoarse[0].first+ghostSize-1),fact0(facts[0]);//offset is always >=0 thanks to the fact that ghostSize>=1 ! - for(int i=0;i dims(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(fineLocInCoarse)); + mcIdType offset(fineLocInCoarse[0].first+ghostSize-1),fact0(facts[0]);//offset is always >=0 thanks to the fact that ghostSize>=1 ! + for(mcIdType i=0;i dims(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(fineLocInCoarse)); - int fact0(facts[0]),fact1(facts[1]),fact2(facts[2]); - int nxyWgCoarse((coarseSt[0]+2*ghostSize)*(coarseSt[1]+2*ghostSize)),nxyWgFine((dims[0]*fact0+2*ghostSize)*(dims[1]*fact1+2*ghostSize)); - int offset((fineLocInCoarse[2].first+ghostSize-1)*nxyWgCoarse);//offset is always >=0 thanks to the fact that ghostSize>=1 ! - for(int i=0;i dims(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(fineLocInCoarse)); + mcIdType fact0(facts[0]),fact1(facts[1]),fact2(facts[2]); + mcIdType nxyWgCoarse((coarseSt[0]+2*ghostSize)*(coarseSt[1]+2*ghostSize)),nxyWgFine((dims[0]*fact0+2*ghostSize)*(dims[1]*fact1+2*ghostSize)); + mcIdType offset((fineLocInCoarse[2].first+ghostSize-1)*nxyWgCoarse);//offset is always >=0 thanks to the fact that ghostSize>=1 ! + for(mcIdType i=0;i& coarseSt, DataArrayDouble *fineDA, const std::vector< std::pair >& fineLocInCoarse, const std::vector& facts, int ghostSize) +void MEDCouplingIMesh::SpreadCoarseToFineGhostZone(const DataArrayDouble *coarseDA, const std::vector& coarseSt, DataArrayDouble *fineDA, const std::vector< std::pair >& fineLocInCoarse, const std::vector& facts, mcIdType ghostSize) { if(ghostSize<0) throw INTERP_KERNEL::Exception("MEDCouplingIMesh::SpreadCoarseToFineGhostZone : ghost level has to be >= 0 !"); @@ -743,12 +747,13 @@ void MEDCouplingIMesh::SpreadCoarseToFineGhostZone(const DataArrayDouble *coarse throw INTERP_KERNEL::Exception("MEDCouplingIMesh::SpreadCoarseToFineGhostZone : All input vectors (dimension) must have the same size !"); if(!coarseDA || !coarseDA->isAllocated() || !fineDA || !fineDA->isAllocated()) throw INTERP_KERNEL::Exception("MEDCouplingIMesh::SpreadCoarseToFineGhostZone : the parameters 1 or 3 are NULL or not allocated !"); - std::vector coarseStG(coarseSt.size()); std::transform(coarseSt.begin(),coarseSt.end(),coarseStG.begin(),std::bind2nd(std::plus(),2*ghostSize)); - int meshDim((int)coarseSt.size()),nbOfTuplesInCoarseExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(coarseStG)); - int nbCompo(fineDA->getNumberOfComponents()); - if((int)coarseDA->getNumberOfComponents()!=nbCompo) + std::vector coarseStG(coarseSt.size()); std::transform(coarseSt.begin(),coarseSt.end(),coarseStG.begin(),std::bind2nd(std::plus(),2*ghostSize)); + std::size_t meshDim(coarseSt.size()); + mcIdType nbOfTuplesInCoarseExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(coarseStG)); + std::size_t nbCompo=fineDA->getNumberOfComponents(); + if(coarseDA->getNumberOfComponents()!=nbCompo) throw INTERP_KERNEL::Exception("MEDCouplingIMesh::SpreadCoarseToFineGhostZone : the number of components of fine DA and coarse one mismatches !"); - if(meshDim!=(int)fineLocInCoarse.size() || meshDim!=(int)facts.size()) + if(meshDim!=fineLocInCoarse.size() || meshDim!=facts.size()) throw INTERP_KERNEL::Exception("MEDCouplingIMesh::SpreadCoarseToFineGhostZone : the size of fineLocInCoarse (4th param) and facts (5th param) must be equal to the sier of coarseSt (2nd param) !"); if(coarseDA->getNumberOfTuples()!=nbOfTuplesInCoarseExp) { @@ -756,10 +761,10 @@ void MEDCouplingIMesh::SpreadCoarseToFineGhostZone(const DataArrayDouble *coarse throw INTERP_KERNEL::Exception(oss.str().c_str()); } // - std::vector fineStG(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(fineLocInCoarse)); - std::transform(fineStG.begin(),fineStG.end(),facts.begin(),fineStG.begin(),std::multiplies()); - std::transform(fineStG.begin(),fineStG.end(),fineStG.begin(),std::bind2nd(std::plus(),2*ghostSize)); - int nbTuplesFine(fineDA->getNumberOfTuples()),nbTuplesFineExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(fineStG)); + std::vector fineStG(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(fineLocInCoarse)); + std::transform(fineStG.begin(),fineStG.end(),facts.begin(),fineStG.begin(),std::multiplies()); + std::transform(fineStG.begin(),fineStG.end(),fineStG.begin(),std::bind2nd(std::plus(),2*ghostSize)); + mcIdType nbTuplesFine(fineDA->getNumberOfTuples()),nbTuplesFineExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(fineStG)); if(fineDA->getNumberOfTuples()!=nbTuplesFineExp) { std::ostringstream oss; oss << "MEDCouplingIMesh::SpreadCoarseToFineGhostZone : Expecting " << nbTuplesFineExp << " tuples in fine DataArray having " << nbTuplesFine << " !"; @@ -769,38 +774,38 @@ void MEDCouplingIMesh::SpreadCoarseToFineGhostZone(const DataArrayDouble *coarse double *outPtr(fineDA->getPointer()); const double *inPtr(coarseDA->begin()); // - std::vector dims(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(fineLocInCoarse)); + std::vector dims(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(fineLocInCoarse)); switch(meshDim) { case 1: { - int offset(fineLocInCoarse[0].first+ghostSize-1),fact0(facts[0]);//offset is always >=0 thanks to the fact that ghostSize>=1 ! - for(int i=0;i=0 thanks to the fact that ghostSize>=1 ! + for(mcIdType i=0;i=0 thanks to the fact that ghostSize>=1 ! - for(int i=0;i=0 thanks to the fact that ghostSize>=1 ! + for(mcIdType i=0;i MEDCouplingIMesh::getNodeGridStructure() const +std::vector MEDCouplingIMesh::getNodeGridStructure() const { checkSpaceDimension(); - std::vector ret(_structure,_structure+_space_dim); + std::vector ret(_structure,_structure+_space_dim); return ret; } -MEDCouplingStructuredMesh *MEDCouplingIMesh::buildStructuredSubPart(const std::vector< std::pair >& cellPart) const +MEDCouplingStructuredMesh *MEDCouplingIMesh::buildStructuredSubPart(const std::vector< std::pair >& cellPart) const { checkConsistencyLight(); int dim(getSpaceDimension()); - if(dim!=(int)cellPart.size()) + if(dim!=ToIdType(cellPart.size())) { std::ostringstream oss; oss << "MEDCouplingIMesh::buildStructuredSubPart : the space dimension is " << dim << " and cell part size is " << cellPart.size() << " !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } double retOrigin[3]={0.,0.,0.}; - int retStruct[3]={0,0,0}; + mcIdType retStruct[3]={0,0,0}; MCAuto ret(dynamic_cast(deepCopy())); for(int i=0;i=_structure[i]) { std::ostringstream oss; oss << "MEDCouplingIMesh::buildStructuredSubPart : At dimension #" << i << " the start node id is " << startNode << " it should be in [0," << _structure[i] << ") !"; @@ -993,7 +998,7 @@ MEDCouplingStructuredMesh *MEDCouplingIMesh::buildStructuredSubPart(const std::v std::ostringstream oss; oss << "MEDCouplingIMesh::buildStructuredSubPart : Along dimension #" << i << " the number of nodes is " << _structure[i] << ", and you are requesting for " << myDelta << " nodes wide range !" << std::endl; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - retOrigin[i]=_origin[i]+startNode*_dxyz[i]; + retOrigin[i]=_origin[i]+FromIdType(startNode)*_dxyz[i]; retStruct[i]=myDelta; } ret->setNodeStruct(retStruct,retStruct+dim); @@ -1010,15 +1015,15 @@ int MEDCouplingIMesh::getSpaceDimension() const return _space_dim; } -void MEDCouplingIMesh::getCoordinatesOfNode(int nodeId, std::vector& coo) const +void MEDCouplingIMesh::getCoordinatesOfNode(mcIdType nodeId, std::vector& coo) const { - int tmp[3]; + mcIdType tmp[3]; int spaceDim(getSpaceDimension()); getSplitNodeValues(tmp); - int tmp2[3]; + mcIdType tmp2[3]; GetPosFromId(nodeId,spaceDim,tmp,tmp2); for(int j=0;j(tmp2[j])); } std::string MEDCouplingIMesh::simpleRepr() const @@ -1054,7 +1059,7 @@ void MEDCouplingIMesh::getBoundingBox(double *bbox) const for(int idim=0; idim1) coeff=_structure[idim]-1; - bbox[2*idim+1]=_origin[idim]+_dxyz[idim]*coeff; + bbox[2*idim+1]=_origin[idim]+_dxyz[idim]*FromIdType(coeff); } } @@ -1082,7 +1087,7 @@ MEDCouplingFieldDouble *MEDCouplingIMesh::getMeasureField(bool isAbs) const checkConsistencyLight(); std::string name="MeasureOfMesh_"; name+=getName(); - int nbelem(getNumberOfCells()); + std::size_t nbelem=getNumberOfCells(); MEDCouplingFieldDouble *field(MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME)); field->setName(name); DataArrayDouble* array(DataArrayDouble::New()); @@ -1104,14 +1109,14 @@ MEDCouplingFieldDouble *MEDCouplingIMesh::getMeasureFieldOnNode(bool isAbs) cons //return 0; } -int MEDCouplingIMesh::getCellContainingPoint(const double *pos, double eps) const +mcIdType MEDCouplingIMesh::getCellContainingPoint(const double *pos, double eps) const { - int dim(getSpaceDimension()),ret(0),coeff(1); - for(int i=0;i=0 && tmp& elts) const +void MEDCouplingIMesh::getCellsContainingPoint(const double *pos, double eps, std::vector& elts) const { - int ret(getCellContainingPoint(pos,eps)); + mcIdType ret(getCellContainingPoint(pos,eps)); elts.push_back(ret); } @@ -1182,17 +1187,18 @@ DataArrayDouble *MEDCouplingIMesh::getCoordinatesAndOwner() const { checkConsistencyLight(); MCAuto ret(DataArrayDouble::New()); - int spaceDim(getSpaceDimension()),nbNodes(getNumberOfNodes()); + int spaceDim(getSpaceDimension()); + mcIdType nbNodes(getNumberOfNodes()); ret->alloc(nbNodes,spaceDim); double *pt(ret->getPointer()); ret->setInfoOnComponents(buildInfoOnComponents()); - int tmp2[3],tmp[3]; + mcIdType tmp2[3],tmp[3]; getSplitNodeValues(tmp); - for(int i=0;i(tmp2[j])+_origin[j]; } return ret.retn(); } @@ -1209,18 +1215,19 @@ DataArrayDouble *MEDCouplingIMesh::computeCellCenterOfMass() const { checkConsistencyLight(); MCAuto ret(DataArrayDouble::New()); - int spaceDim(getSpaceDimension()),nbCells(getNumberOfCells()),tmp[3],tmp2[3]; + int spaceDim(getSpaceDimension()); + mcIdType nbCells(ToIdType(getNumberOfCells())),tmp[3],tmp2[3]; ret->alloc(nbCells,spaceDim); double *pt(ret->getPointer()),shiftOrigin[3]; std::transform(_dxyz,_dxyz+spaceDim,shiftOrigin,std::bind2nd(std::multiplies(),0.5)); std::transform(_origin,_origin+spaceDim,shiftOrigin,shiftOrigin,std::plus()); getSplitCellValues(tmp); ret->setInfoOnComponents(buildInfoOnComponents()); - for(int i=0;i(tmp2[j])+shiftOrigin[j]; } return ret.retn(); } @@ -1230,12 +1237,12 @@ DataArrayDouble *MEDCouplingIMesh::computeIsoBarycenterOfNodesPerCell() const return MEDCouplingIMesh::computeCellCenterOfMass(); } -void MEDCouplingIMesh::renumberCells(const int *old2NewBg, bool check) +void MEDCouplingIMesh::renumberCells(const mcIdType *old2NewBg, bool check) { throw INTERP_KERNEL::Exception("Functionality of renumbering cell not available for IMesh !"); } -void MEDCouplingIMesh::getTinySerializationInformation(std::vector& tinyInfoD, std::vector& tinyInfo, std::vector& littleStrings) const +void MEDCouplingIMesh::getTinySerializationInformation(std::vector& tinyInfoD, std::vector& tinyInfo, std::vector& littleStrings) const { int it,order; double time(getTime(it,order)); @@ -1255,29 +1262,29 @@ void MEDCouplingIMesh::getTinySerializationInformation(std::vector& tiny tinyInfoD.insert(tinyInfoD.end(),_origin,_origin+3); } -void MEDCouplingIMesh::resizeForUnserialization(const std::vector& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector& littleStrings) const +void MEDCouplingIMesh::resizeForUnserialization(const std::vector& tinyInfo, DataArrayIdType *a1, DataArrayDouble *a2, std::vector& littleStrings) const { a1->alloc(0,1); a2->alloc(0,1); } -void MEDCouplingIMesh::serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const +void MEDCouplingIMesh::serialize(DataArrayIdType *&a1, DataArrayDouble *&a2) const { - a1=DataArrayInt::New(); + a1=DataArrayIdType::New(); a1->alloc(0,1); a2=DataArrayDouble::New(); a2->alloc(0,1); } -void MEDCouplingIMesh::unserialization(const std::vector& tinyInfoD, const std::vector& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, +void MEDCouplingIMesh::unserialization(const std::vector& tinyInfoD, const std::vector& tinyInfo, const DataArrayIdType *a1, DataArrayDouble *a2, const std::vector& littleStrings) { setName(littleStrings[0]); setDescription(littleStrings[1]); setTimeUnit(littleStrings[2]); setAxisUnit(littleStrings[3]); - setTime(tinyInfoD[0],tinyInfo[0],tinyInfo[1]); - _space_dim=tinyInfo[2]; + setTime(tinyInfoD[0],FromIdType(tinyInfo[0]),FromIdType(tinyInfo[1])); + _space_dim=FromIdType(tinyInfo[2]); _structure[0]=tinyInfo[3]; _structure[1]=tinyInfo[4]; _structure[2]=tinyInfo[5]; _dxyz[0]=tinyInfoD[1]; _dxyz[1]=tinyInfoD[2]; _dxyz[2]=tinyInfoD[3]; _origin[0]=tinyInfoD[4]; _origin[1]=tinyInfoD[5]; _origin[2]=tinyInfoD[6]; @@ -1314,12 +1321,12 @@ void MEDCouplingIMesh::reprQuickOverview(std::ostream& stream) const return ; stream << "\n"; std::ostringstream stream0,stream1; - int nbNodes(1),nbCells(0); + mcIdType nbNodes(1),nbCells(0); bool isPb(false); for(int i=0;i<_space_dim;i++) { - char tmp('X'+i); - int tmpNodes(_structure[i]); + char tmp=(char)((int)('X')+i); + mcIdType tmpNodes(_structure[i]); stream1 << "- Axis " << tmp << " : " << tmpNodes << " nodes (orig=" << _origin[i] << ", inter=" << _dxyz[i] << ")."; if(i!=_space_dim-1) stream1 << std::endl; @@ -1358,7 +1365,7 @@ std::vector MEDCouplingIMesh::buildInfoOnComponents() const for(int i=0;i& coarseSt, const std::vector< std::pair >& fineLocInCoarse, const std::vector& facts, int ghostSize) +void MEDCouplingIMesh::SpreadCoarseToFineGhost2D(const double *inPtr, double *outPtr, std::size_t nbCompo, const std::vector& coarseSt, const std::vector< std::pair >& fineLocInCoarse, const std::vector& facts, mcIdType ghostSize) { double *outPtrWork(outPtr); - std::vector dims(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(fineLocInCoarse)); - int nxwg(coarseSt[0]+2*ghostSize),fact0(facts[0]),fact1(facts[1]); - int kk(fineLocInCoarse[0].first+ghostSize-1+nxwg*(fineLocInCoarse[1].first+ghostSize-1));//kk is always >=0 thanks to the fact that ghostSize>=1 ! - for(int jg=0;jg dims(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(fineLocInCoarse)); + mcIdType nxwg(coarseSt[0]+2*ghostSize),fact0(facts[0]),fact1(facts[1]); + mcIdType kk(fineLocInCoarse[0].first+ghostSize-1+nxwg*(fineLocInCoarse[1].first+ghostSize-1));//kk is always >=0 thanks to the fact that ghostSize>=1 ! + for(mcIdType jg=0;jg= ghostlev - for(int i=0;i= ghostlev + for(mcIdType i=0;i& coarseSt, const std::vector< std::pair >& fineLocInCoarse, const std::vector& facts, int ghostSize) +void MEDCouplingIMesh::SpreadCoarseToFineGhostZone2D(const double *inPtr, double *outPtr, std::size_t nbCompo, const std::vector& coarseSt, const std::vector< std::pair >& fineLocInCoarse, const std::vector& facts, mcIdType ghostSize) { double *outPtr2(outPtr); - std::vector dims(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(fineLocInCoarse)); - int nxwg(coarseSt[0]+2*ghostSize),fact0(facts[0]),fact1(facts[1]); - int kk(fineLocInCoarse[0].first+ghostSize-1+nxwg*(fineLocInCoarse[1].first+ghostSize-1));//kk is always >=0 thanks to the fact that ghostSize>=1 ! - for(int jg=0;jg dims(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(fineLocInCoarse)); + mcIdType nxwg(coarseSt[0]+2*ghostSize),fact0(facts[0]),fact1(facts[1]); + mcIdType kk(fineLocInCoarse[0].first+ghostSize-1+nxwg*(fineLocInCoarse[1].first+ghostSize-1));//kk is always >=0 thanks to the fact that ghostSize>=1 ! + for(mcIdType jg=0;jg= ghostlev + mcIdType kk0(kk+1+dims[0]);//1 not ghost. We make the hypothesis that factors is >= ghostlev outPtr2+=fact0*nbCompo*dims[0]; - for(int ig=0;ig