-// Copyright (C) 2007-2013 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2014 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
// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
INTERP_KERNEL::NormalizedCellType MEDCouplingStructuredMesh::GetGeoTypeGivenMeshDimension(int meshDim)
{
switch(meshDim)
- {
+ {
case 3:
return INTERP_KERNEL::NORM_HEXA8;
case 2:
return INTERP_KERNEL::NORM_QUAD4;
case 1:
return INTERP_KERNEL::NORM_SEG2;
+ case 0:
+ return INTERP_KERNEL::NORM_POINT1;
default:
throw INTERP_KERNEL::Exception("Unexpected dimension for MEDCouplingStructuredMesh::GetGeoTypeGivenMeshDimension !");
- }
+ }
}
std::set<INTERP_KERNEL::NormalizedCellType> MEDCouplingStructuredMesh::getAllGeoTypes() const
int tmp2[3];
GetPosFromId(cellId,meshDim,tmpCell,tmp2);
switch(meshDim)
- {
+ {
case 1:
conn.push_back(tmp2[0]); conn.push_back(tmp2[0]+1);
break;
break;
default:
throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::getNodeIdsOfCell : big problem spacedim must be in 1,2 or 3 !");
- };
+ };
+}
+
+/*!
+ * This method returns the mesh dimension of \a this. It can be different from space dimension in case of a not null dimension contains only one node.
+ */
+int MEDCouplingStructuredMesh::getMeshDimension() const
+{
+ std::vector<int> ngs(getNodeGridStructure());
+ int ret(0),pos(0);
+ for(std::vector<int>::const_iterator it=ngs.begin();it!=ngs.end();it++,pos++)
+ {
+ if(*it<=0)
+ {
+ std::ostringstream oss; oss << "MEDCouplingStructuredMesh::getMeshDimension : At pos #" << pos << " number of nodes is " << *it << " ! Must be > 0 !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ if(*it>1)
+ ret++;
+ }
+ return ret;
+}
+
+/*!
+ * This method returns the space dimension by only considering the node grid structure.
+ * For cartesian mesh the returned value is equal to those returned by getSpaceDimension.
+ * But for curvelinear is could be different !
+ */
+int MEDCouplingStructuredMesh::getSpaceDimensionOnNodeStruct() const
+{
+ std::vector<int> nodeStr(getNodeGridStructure());
+ int spd1(0),pos(0);
+ for(std::vector<int>::const_iterator it=nodeStr.begin();it!=nodeStr.end();it++,pos++)
+ {
+ int elt(*it);
+ if(elt<=0)
+ {
+ std::ostringstream oss; oss << "MEDCouplingStructuredMesh::getSpaceDimensionOnNodeStruct : At pos #" << pos << " value of node grid structure is " << *it << " ! must be >=1 !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ spd1++;
+ }
+ return spd1;
+}
+
+void MEDCouplingStructuredMesh::getSplitCellValues(int *res) const
+{
+ std::vector<int> strct(getCellGridStructure());
+ std::vector<int> ret(MEDCouplingStructuredMesh::GetSplitVectFromStruct(strct));
+ std::copy(ret.begin(),ret.end(),res);
+}
+
+void MEDCouplingStructuredMesh::getSplitNodeValues(int *res) const
+{
+ std::vector<int> strct(getNodeGridStructure());
+ std::vector<int> ret(MEDCouplingStructuredMesh::GetSplitVectFromStruct(strct));
+ std::copy(ret.begin(),ret.end(),res);
+}
+
+/*!
+ * This method returns the number of cells of unstructured sub level mesh, without building it.
+ */
+int MEDCouplingStructuredMesh::getNumberOfCellsOfSubLevelMesh() const
+{
+ std::vector<int> cgs(getCellGridStructure());
+ return GetNumberOfCellsOfSubLevelMesh(cgs,getMeshDimension());
}
/*!
*/
MEDCoupling1SGTUMesh *MEDCouplingStructuredMesh::build1SGTUnstructured() const
{
- int meshDim=getMeshDimension();
- if(meshDim<0 || meshDim>3)
- throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::build1SGTUnstructured : meshdim must be in [1,2,3] !");
+ 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<DataArrayDouble> coords(getCoordinatesAndOwner());
+ int ns[3];
+ getNodeGridStructure(ns);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> conn(Build1GTNodalConnectivity(ns,ns+spaceDim));
+ MEDCouplingAutoRefCountObjectPtr<MEDCoupling1SGTUMesh> ret(MEDCoupling1SGTUMesh::New(getName(),GetGeoTypeGivenMeshDimension(meshDim)));
+ ret->setNodalConnectivity(conn); ret->setCoords(coords);
+ return ret.retn();
+}
+
+/*!
+ * This method returns the unstructured mesh (having single geometric type) of the sub level mesh of \a this.
+ * This method is equivalent to computing MEDCouplingUMesh::buildDescendingConnectivity on the unstructurized \a this mesh.
+ *
+ * The caller is to delete the returned mesh using decrRef() as it is no more needed.
+ */
+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<DataArrayDouble> coords(getCoordinatesAndOwner());
int ns[3];
getNodeGridStructure(ns);
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> conn(Build1GTNodalConnectivity(ns,ns+meshDim));
- MEDCouplingAutoRefCountObjectPtr<MEDCoupling1SGTUMesh> ret(MEDCoupling1SGTUMesh::New(getName().c_str(),GetGeoTypeGivenMeshDimension(meshDim)));
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> conn(Build1GTNodalConnectivityOfSubLevelMesh(ns,ns+meshDim));
+ MEDCouplingAutoRefCountObjectPtr<MEDCoupling1SGTUMesh> ret(MEDCoupling1SGTUMesh::New(getName(),GetGeoTypeGivenMeshDimension(meshDim-1)));
ret->setNodalConnectivity(conn); ret->setCoords(coords);
return ret.retn();
}
void MEDCouplingStructuredMesh::getReverseNodalConnectivity(DataArrayInt *revNodal, DataArrayInt *revNodalIndx) const
{
std::vector<int> ngs(getNodeGridStructure());
- int dim(getMeshDimension());
+ int dim(getSpaceDimension());
switch(dim)
{
case 1:
if(nbNodes==0)
{ revNodal->alloc(0,1); revNodalIndx->setIJ(0,0,0); return ; }
if(nbNodes==1)
- { revNodal->alloc(0,1); revNodalIndx->setIJ(0,0,0); revNodalIndx->setIJ(1,0,0); return ; }
+ { revNodal->alloc(1,1); revNodal->setIJ(0,0,0); revNodalIndx->setIJ(0,0,0); revNodalIndx->setIJ(1,0,1); return ; }
revNodal->alloc(2*(nbNodes-1),1);
int *rn(revNodal->getPointer()),*rni(revNodalIndx->getPointer());
*rni++=0; *rni=1; *rn++=0;
*/
DataArrayInt *MEDCouplingStructuredMesh::Build1GTNodalConnectivity(const int *nodeStBg, const int *nodeStEnd)
{
- std::size_t dim=std::distance(nodeStBg,nodeStEnd);
+ int zippedNodeSt[3];
+ int dim(ZipNodeStructure(nodeStBg,nodeStEnd,zippedNodeSt));
switch(dim)
- {
+ {
+ case 0:
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> conn(DataArrayInt::New());
+ conn->alloc(1,1); conn->setIJ(0,0,0);
+ return conn.retn();
+ }
case 1:
- return Build1GTNodalConnectivity1D(nodeStBg);
+ return Build1GTNodalConnectivity1D(zippedNodeSt);
case 2:
- return Build1GTNodalConnectivity2D(nodeStBg);
+ return Build1GTNodalConnectivity2D(zippedNodeSt);
+ case 3:
+ return Build1GTNodalConnectivity3D(zippedNodeSt);
+ default:
+ throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::Build1GTNodalConnectivity : only dimension in [0,1,2,3] supported !");
+ }
+}
+
+DataArrayInt *MEDCouplingStructuredMesh::Build1GTNodalConnectivityOfSubLevelMesh(const int *nodeStBg, const int *nodeStEnd)
+{
+ std::size_t dim(std::distance(nodeStBg,nodeStEnd));
+ switch(dim)
+ {
case 3:
- return Build1GTNodalConnectivity3D(nodeStBg);
+ return Build1GTNodalConnectivityOfSubLevelMesh3D(nodeStBg);
+ case 2:
+ return Build1GTNodalConnectivityOfSubLevelMesh2D(nodeStBg);
default:
- throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::Build1GTNodalConnectivity : only dimension in [1,2,3] supported !");
+ throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::Build1GTNodalConnectivityOfSubLevelMesh: only dimension in [2,3] supported !");
+ }
+}
+
+/*!
+ * This method retrieves the number of entities (it can be cells or nodes) given a range in compact standard format
+ * used in methods like BuildExplicitIdsFrom,IsPartStructured.
+ *
+ * \sa BuildExplicitIdsFrom,IsPartStructured
+ */
+int MEDCouplingStructuredMesh::DeduceNumberOfGivenRangeInCompactFrmt(const std::vector< std::pair<int,int> >& partCompactFormat)
+{
+ int ret(1);
+ bool isFetched(false);
+ std::size_t ii(0);
+ for(std::vector< std::pair<int,int> >::const_iterator it=partCompactFormat.begin();it!=partCompactFormat.end();it++,ii++)
+ {
+ int a((*it).first),b((*it).second);
+ if(a<0 || b<0 || b-a<0)
+ {
+ std::ostringstream oss; oss << "MEDCouplingStructuredMesh::DeduceNumberOfGivenRangeInCompactFrmt : invalid input at dimension " << ii << " !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ if(b-a>0)
+ {
+ isFetched=true;
+ ret*=(b-a);
+ }
+ }
+ return isFetched?ret:0;
+}
+
+int MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(const std::vector<int>& st)
+{
+ int ret(1);
+ bool isFetched(false);
+ for(std::size_t i=0;i<st.size();i++)
+ {
+ if(st[i]<0)
+ throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure : presence of a negative value in structure !");
+ ret*=st[i];
+ isFetched=true;
}
+ return isFetched?ret:0;
}
DataArrayInt *MEDCouplingStructuredMesh::Build1GTNodalConnectivity1D(const int *nodeStBg)
cp[4*pos+1]=i+j*(n1+1);
cp[4*pos+2]=i+(j+1)*(n1+1);
cp[4*pos+3]=i+1+(j+1)*(n1+1);
- }
+ }
return conn.retn();
}
return conn.retn();
}
+DataArrayInt *MEDCouplingStructuredMesh::Build1GTNodalConnectivityOfSubLevelMesh3D(const int *nodeStBg)
+{
+ std::vector<int> 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<DataArrayInt> conn(DataArrayInt::New());
+ conn->alloc(4*GetNumberOfCellsOfSubLevelMesh(ngs,3));
+ int *cp(conn->getPointer());
+ //X
+ for(int i=0;i<nodeStBg[0];i++)
+ for(int j=0;j<n1;j++)
+ for(int k=0;k<n2;k++,cp+=4)
+ { cp[0]=k*off1+j*off0+i; cp[1]=(k+1)*off1+j*off0+i; cp[2]=(k+1)*off1+(j+1)*off0+i; cp[3]=k*off1+(j+1)*off0+i; }
+ //Y
+ for(int j=0;j<nodeStBg[1];j++)
+ for(int i=0;i<n0;i++)
+ for(int k=0;k<n2;k++,cp+=4)
+ { cp[0]=k*off1+j*off0+i; cp[1]=(k+1)*off1+j*off0+i; cp[2]=(k+1)*off1+j*off0+(i+1); cp[3]=k*off1+j*off0+(i+1); }
+ //Z
+ for(int k=0;k<nodeStBg[2];k++)
+ for(int i=0;i<n0;i++)
+ for(int j=0;j<n1;j++,cp+=4)
+ { cp[0]=k*off1+j*off0+i; cp[1]=k*off1+j*off0+(i+1); cp[2]=k*off1+(j+1)*off0+(i+1); cp[3]=k*off1+(j+1)*off0+i; }
+ return conn.retn();
+}
+
+/*!
+ * This method computes given the nodal structure defined by [ \a nodeStBg , \a nodeStEnd ) the zipped form.
+ * std::distance( \a nodeStBg, \a nodeStEnd ) is equal to the space dimension. The returned value is equal to
+ * the meshDimension (or the zipped spaceDimension).
+ *
+ * \param [out] zipNodeSt - The zipped node strucutre
+ * \return int - the
+ */
+int MEDCouplingStructuredMesh::ZipNodeStructure(const int *nodeStBg, const int *nodeStEnd, int zipNodeSt[3])
+{
+ int spaceDim((int)std::distance(nodeStBg,nodeStEnd));
+ if(spaceDim>3 || spaceDim<1)
+ throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::ZipNodeStructure : spaceDim must in [1,2,3] !");
+ zipNodeSt[0]=0; zipNodeSt[1]=0; zipNodeSt[2]=0;
+ int zippedI(0);
+ for(int i=0;i<spaceDim;i++)
+ {
+ int elt(nodeStBg[i]);
+ if(elt<1)
+ {
+ std::ostringstream oss; oss << "MEDCouplingStructuredMesh::ZipNodeStructure : the input nodal structure at pos#" << i << "(" << nodeStBg[i] << ") is invalid !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ if(elt>=2)
+ zipNodeSt[zippedI++]=elt;
+ }
+ return zippedI;
+}
+
+DataArrayInt *MEDCouplingStructuredMesh::Build1GTNodalConnectivityOfSubLevelMesh2D(const int *nodeStBg)
+{
+ std::vector<int> ngs(2);
+ int n0(nodeStBg[0]-1),n1(nodeStBg[1]-1); ngs[0]=n0; ngs[1]=n1;
+ int off0(nodeStBg[0]);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> conn(DataArrayInt::New());
+ conn->alloc(2*GetNumberOfCellsOfSubLevelMesh(ngs,2));
+ int *cp(conn->getPointer());
+ //X
+ for(int i=0;i<nodeStBg[0];i++)
+ for(int j=0;j<n1;j++,cp+=2)
+ { cp[0]=j*off0+i; cp[1]=(j+1)*off0+i; }
+ //Y
+ for(int j=0;j<nodeStBg[1];j++)
+ for(int i=0;i<n0;i++,cp+=2)
+ { cp[0]=j*off0+i; cp[1]=j*off0+(i+1); }
+ return conn.retn();
+}
+
/*!
* Returns a cell id by its (i,j,k) index. The cell is located between the i-th and
* ( i + 1 )-th nodes along X axis etc.
{
int tmp[3]={i,j,k};
int tmp2[3];
- int meshDim=getMeshDimension();
+ int meshDim(getMeshDimension());
getSplitCellValues(tmp2);
std::transform(tmp,tmp+meshDim,tmp2,tmp,std::multiplies<int>());
return std::accumulate(tmp,tmp+meshDim,0);
{
int tmp[3]={i,j,k};
int tmp2[3];
- int meshDim=getMeshDimension();
+ int spaceDim(getSpaceDimension());
getSplitNodeValues(tmp2);
- std::transform(tmp,tmp+meshDim,tmp2,tmp,std::multiplies<int>());
- return std::accumulate(tmp,tmp+meshDim,0);
+ std::transform(tmp,tmp+spaceDim,tmp2,tmp,std::multiplies<int>());
+ return std::accumulate(tmp,tmp+spaceDim,0);
+}
+
+
+int MEDCouplingStructuredMesh::getNumberOfCells() const
+{
+ std::vector<int> ngs(getNodeGridStructure());
+ int ret(1);
+ bool isCatched(false);
+ std::size_t ii(0);
+ for(std::vector<int>::const_iterator it=ngs.begin();it!=ngs.end();it++,ii++)
+ {
+ int elt(*it);
+ if(elt<=0)
+ {
+ std::ostringstream oss; oss << "MEDCouplingStructuredMesh::getNumberOfCells : at pos #" << ii << " the number of nodes in nodeStructure is " << *it << " ! Must be > 0 !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ if(elt>1)
+ {
+ ret*=elt-1;
+ isCatched=true;
+ }
+ }
+ return isCatched?ret:0;
+}
+
+int MEDCouplingStructuredMesh::getNumberOfNodes() const
+{
+ std::vector<int> ngs(getNodeGridStructure());
+ int ret(1);
+ for(std::vector<int>::const_iterator it=ngs.begin();it!=ngs.end();it++)
+ ret*=*it;
+ return ret;
}
void MEDCouplingStructuredMesh::GetPosFromId(int nodeId, int meshDim, const int *split, int *res)
return ret;
}
+/*!
+ * Given a struct \a strct it returns a split vector [1,strct[0],strct[0]*strct[1]...]
+ * This decomposition allows to quickly find i,j,k given a global id.
+ */
+std::vector<int> MEDCouplingStructuredMesh::GetSplitVectFromStruct(const std::vector<int>& strct)
+{
+ int spaceDim((int)strct.size());
+ std::vector<int> res(spaceDim);
+ for(int l=0;l<spaceDim;l++)
+ {
+ int val=1;
+ for(int p=0;p<spaceDim-l-1;p++)
+ val*=strct[p];
+ res[spaceDim-l-1]=val;
+ }
+ return res;
+}
+
/*!
* This method states if given part ids [ \a startIds, \a stopIds) and a structure \a st returns if it can be considered as a structured dataset.
* If true is returned \a partCompactFormat will contain the information to build the corresponding part.
*
- * \sa MEDCouplingStructuredMesh::BuildExplicitIdsFrom
+ * \sa MEDCouplingStructuredMesh::BuildExplicitIdsFrom, MEDCouplingStructuredMesh::DeduceNumberOfGivenRangeInCompactFrmt
*/
bool MEDCouplingStructuredMesh::IsPartStructured(const int *startIds, const int *stopIds, const std::vector<int>& st, std::vector< std::pair<int,int> >& partCompactFormat)
{
return false;
const int *w(startIds);
switch(dim)
- {
+ {
case 3:
{
for(int i=0;i<tmp4[2];i++)
}
default:
throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::IsPartStructured : internal error !");
- }
+ }
+}
+
+std::vector<int> MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(const std::vector< std::pair<int,int> >& partCompactFormat)
+{
+ std::vector<int> ret(partCompactFormat.size());
+ for(std::size_t i=0;i<partCompactFormat.size();i++)
+ ret[i]=partCompactFormat[i].second-partCompactFormat[i].first;
+ return ret;
+}
+
+/*!
+ * 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
+ * available in python.
+ *
+ * \param [in] st The entity structure.
+ * \param [in] partCompactFormat The compact subpart to be enabled.
+ * \param [in,out] vectToSwitchOn Vector which fetched items are enabled.
+ *
+ * \sa MEDCouplingStructuredMesh::BuildExplicitIdsFrom
+ */
+void MEDCouplingStructuredMesh::SwitchOnIdsFrom(const std::vector<int>& st, const std::vector< std::pair<int,int> >& partCompactFormat, std::vector<bool>& vectToSwitchOn)
+{
+ if(st.size()!=partCompactFormat.size())
+ throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::SwitchOnIdsFrom : input arrays must have the same size !");
+ if((int)vectToSwitchOn.size()!=DeduceNumberOfGivenStructure(st))
+ throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::SwitchOnIdsFrom : invalid size of input vector of boolean regarding the structure !");
+ std::vector<int> dims(GetDimensionsFromCompactFrmt(partCompactFormat));
+ switch(st.size())
+ {
+ case 3:
+ {
+ for(int i=0;i<dims[2];i++)
+ {
+ int a=(partCompactFormat[2].first+i)*st[0]*st[1];
+ for(int j=0;j<dims[1];j++)
+ {
+ int b=(partCompactFormat[1].first+j)*st[0];
+ for(int k=0;k<dims[0];k++)
+ vectToSwitchOn[partCompactFormat[0].first+k+b+a]=true;
+ }
+ }
+ break;
+ }
+ case 2:
+ {
+ for(int j=0;j<dims[1];j++)
+ {
+ int b=(partCompactFormat[1].first+j)*st[0];
+ for(int k=0;k<dims[0];k++)
+ vectToSwitchOn[partCompactFormat[0].first+k+b]=true;
+ }
+ break;
+ }
+ case 1:
+ {
+ for(int k=0;k<dims[0];k++)
+ vectToSwitchOn[partCompactFormat[0].first+k]=true;
+ break;
+ }
+ default:
+ throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::BuildExplicitIdsFrom : Dimension supported are 1,2 or 3 !");
+ }
}
/*!
* 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 sructure an exception will be thrown.
*
* \return DataArrayInt * - a new object.
- * \sa MEDCouplingStructuredMesh::IsPartStructured
+ * \sa MEDCouplingStructuredMesh::IsPartStructured, MEDCouplingStructuredMesh::DeduceNumberOfGivenRangeInCompactFrmt, SwitchOnIdsFrom
*/
DataArrayInt *MEDCouplingStructuredMesh::BuildExplicitIdsFrom(const std::vector<int>& st, const std::vector< std::pair<int,int> >& partCompactFormat)
{
ret->alloc(nbOfItems,1);
int *pt(ret->getPointer());
switch(st.size())
- {
+ {
case 3:
{
for(int i=0;i<dims[2];i++)
}
default:
throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::BuildExplicitIdsFrom : Dimension supported are 1,2 or 3 !");
- }
+ }
return ret.retn();
}
+
+int MEDCouplingStructuredMesh::GetNumberOfCellsOfSubLevelMesh(const std::vector<int>& cgs, int mdim)
+{
+ int ret(0);
+ for(int i=0;i<mdim;i++)
+ {
+ int locRet(1);
+ for(int j=0;j<mdim;j++)
+ if(j!=i)
+ locRet*=cgs[j];
+ else
+ locRet*=cgs[j]+1;
+ ret+=locRet;
+ }
+ return ret;
+}