using namespace ParaMEDMEM;
const unsigned char MEDMeshMultiLev::PARAMEDMEM_2_VTKTYPE[MEDMeshMultiLev::PARAMEDMEM_2_VTKTYPE_LGTH]=
- {1,3,21,5,9,7,22,34,23,28,255,255,255,255,10,14,13,255,12,255,24,255,16,27,255,26,255,29,255,255,25,42,36,4};
+{1,3,21,5,9,7,22,34,23,28,255,255,255,255,10,14,13,255,12,255,24,255,16,27,255,26,255,29,255,255,25,42,36,4};
const unsigned char MEDMeshMultiLev::HEXA27_PERM_ARRAY[27]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,24,22,21,23,20,25,26};
_node_reduction=const_cast<DataArrayInt*>(nr);
}
+void MEDMeshMultiLev::setCellReduction(const DataArrayInt *cr)
+{
+ if(_pfls.size()!=1)
+ throw INTERP_KERNEL::Exception("MEDMeshMultiLev::setCellReduction : can be used only for single geo type mesh !");
+ _pfls[0]=const_cast<DataArrayInt*>(cr);
+ if(cr)
+ cr->incrRef();
+}
+
bool MEDMeshMultiLev::isFastlyTheSameStruct(const MEDFileField1TSStructItem& fst, const MEDFileFieldGlobsReal *globs) const
{
if(fst.getType()==ON_NODES)
std::size_t sz(_nb_entities.size());
for(std::size_t i=0;i<sz;i++)
if(_geo_types[i]==t)
- return _nb_entities[i];
+ return _nb_entities[i];
throw INTERP_KERNEL::Exception("MEDMeshMultiLev::getNumberOfCells : not existing geometric type in this !");
}
if(pflName.empty() && !nr)
return vals->deepCpy();
if(pflName.empty() && nr)
- throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for nodes 2 !");
+ throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for nodes 2 !");
if(!pflName.empty() && nr)
{
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> p1(globs->getProfile(pflName.c_str())->deepCpy());
void MEDUMeshMultiLev::selectPartOfNodes(const DataArrayInt *pflNodes)
{
- if(!pflNodes || !pflNodes->isAllocated())
- return ;
- std::size_t sz(_parts.size());
- std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > a(sz);
- std::vector< const DataArrayInt *> aa(sz);
- for(std::size_t i=0;i<sz;i++)
- {
- const DataArrayInt *pfl(_pfls[i]);
- MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> m(_parts[i]);
- if(pfl)
- m=dynamic_cast<MEDCoupling1GTUMesh *>(_parts[i]->buildPartOfMySelfKeepCoords(pfl->begin(),pfl->end()));
- DataArrayInt *cellIds=0;
- m->fillCellIdsToKeepFromNodeIds(pflNodes->begin(),pflNodes->end(),true,cellIds);
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cellIdsSafe(cellIds);
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingPointSet> m2(m->buildPartOfMySelfKeepCoords(cellIds->begin(),cellIds->end()));
- int tmp=-1;
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> o2n(m2->getNodeIdsInUse(tmp));
- a[i]=o2n->invertArrayO2N2N2O(tmp); aa[i]=a[i];
- if(pfl)
- _pfls[i]=pfl->selectByTupleIdSafe(cellIds->begin(),cellIds->end());
- else
- _pfls[i]=cellIdsSafe;
- }
- if(!aa.empty())
- _node_reduction=DataArrayInt::Aggregate(aa);//general case
- else
- _node_reduction=pflNodes->deepCpy();//case where no cells in read mesh.
- _node_reduction->sort(true);
- _node_reduction=_node_reduction->buildUnique();
- if(_node_reduction->getNumberOfTuples()==pflNodes->getNumberOfTuples())
- return ;//This is the classical case where the input node profile corresponds perfectly to a subset of cells in _parts
- if(_node_reduction->getNumberOfTuples()>pflNodes->getNumberOfTuples())
- throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::selectPartOfNodes : internal error in MEDCoupling during cell select from a list of nodes !");
- // Here the cells available in _parts is not enough to cover all the nodes in pflNodes. So adding vertices cells in _parts...
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pflNodes2(pflNodes->deepCpy());
- pflNodes2->sort(true);
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> diff(pflNodes2->buildSubstractionOptimized(_node_reduction));
- appendVertices(diff,pflNodes2);
+ if(!pflNodes || !pflNodes->isAllocated())
+ return ;
+ std::size_t sz(_parts.size());
+ std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > a(sz);
+ std::vector< const DataArrayInt *> aa(sz);
+ for(std::size_t i=0;i<sz;i++)
+ {
+ const DataArrayInt *pfl(_pfls[i]);
+ MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> m(_parts[i]);
+ if(pfl)
+ m=dynamic_cast<MEDCoupling1GTUMesh *>(_parts[i]->buildPartOfMySelfKeepCoords(pfl->begin(),pfl->end()));
+ DataArrayInt *cellIds=0;
+ m->fillCellIdsToKeepFromNodeIds(pflNodes->begin(),pflNodes->end(),true,cellIds);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cellIdsSafe(cellIds);
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingPointSet> m2(m->buildPartOfMySelfKeepCoords(cellIds->begin(),cellIds->end()));
+ int tmp=-1;
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> o2n(m2->getNodeIdsInUse(tmp));
+ a[i]=o2n->invertArrayO2N2N2O(tmp); aa[i]=a[i];
+ if(pfl)
+ _pfls[i]=pfl->selectByTupleIdSafe(cellIds->begin(),cellIds->end());
+ else
+ _pfls[i]=cellIdsSafe;
+ }
+ if(!aa.empty())
+ _node_reduction=DataArrayInt::Aggregate(aa);//general case
+ else
+ _node_reduction=pflNodes->deepCpy();//case where no cells in read mesh.
+ _node_reduction->sort(true);
+ _node_reduction=_node_reduction->buildUnique();
+ if(_node_reduction->getNumberOfTuples()==pflNodes->getNumberOfTuples())
+ return ;//This is the classical case where the input node profile corresponds perfectly to a subset of cells in _parts
+ if(_node_reduction->getNumberOfTuples()>pflNodes->getNumberOfTuples())
+ throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::selectPartOfNodes : internal error in MEDCoupling during cell select from a list of nodes !");
+ // Here the cells available in _parts is not enough to cover all the nodes in pflNodes. So adding vertices cells in _parts...
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pflNodes2(pflNodes->deepCpy());
+ pflNodes2->sort(true);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> diff(pflNodes2->buildSubstractionOptimized(_node_reduction));
+ appendVertices(diff,pflNodes2);
}
MEDMeshMultiLev *MEDUMeshMultiLev::prepare() const
}
/*!
+ * To be called only once ! Because due to some optimizations (sometimes aggressive) the internal state can be changed...
* If returned value is false output pointer \a coords is not the internal pointer. If returned value is true output pointer \a coords is directly the internal pointer.
* If true is returned, the \a coords output parameter should be used with care (non const method call) to avoid to change the internal state of MEDFileUMesh instance.
*/
{
*dPtr++=connIPtr[1]-connIPtr[0];
dPtr=std::copy(connPtr+connIPtr[0],connPtr+connIPtr[1],dPtr);
- *cPtr++=k; k+=connIPtr[1]-connIPtr[0];
+ *cPtr++=k; k+=connIPtr[1]-connIPtr[0]+1;
}
}
else
{ faceLocations=0; faces=0; }
else
{ faceLocations=e.retn(); faces=f.retn(); }
- return tmp==((DataArrayDouble *)a);
+ return _mesh->isObjectInTheProgeny(coords);
}
void MEDUMeshMultiLev::reorderNodesIfNecessary(MEDCouplingAutoRefCountObjectPtr<DataArrayDouble>& coords, DataArrayInt *nodalConnVTK, DataArrayInt *polyhedNodalConnVTK) const
//=
-MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev(const MEDFileStructuredMesh *m):MEDMeshMultiLev(m),_is_internal(true)
+MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev(const MEDFileStructuredMesh *m, const std::vector<int>& lev):MEDMeshMultiLev(m),_is_internal(true)
+{
+ initStdFieldOfIntegers(m);
+}
+
+MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev(const MEDFileStructuredMesh *m, int nbOfNodes, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities):MEDMeshMultiLev(m,nbOfNodes,gts,pfls,nbEntities),_is_internal(true)
{
+ initStdFieldOfIntegers(m);
}
-MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev(const MEDFileStructuredMesh *m, const std::vector<int>& lev):MEDMeshMultiLev(m),_is_internal(true)
+MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev(const MEDStructuredMeshMultiLev& other):MEDMeshMultiLev(other),_is_internal(true),_face_fam_ids(other._face_fam_ids),_face_fam_ids_nocpy(other._face_fam_ids_nocpy),_face_num_ids(other._face_num_ids),_face_num_ids_nocpy(other._face_num_ids_nocpy)
+{
+}
+
+void MEDStructuredMeshMultiLev::initStdFieldOfIntegers(const MEDFileStructuredMesh *m)
{
// ids fields management
_cell_fam_ids_nocpy=true; _cell_num_ids_nocpy=true;
tmp->incrRef();
_node_num_ids=const_cast<DataArrayInt *>(tmp);
}
-}
-
-MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev(const MEDFileStructuredMesh *m, int nbOfNodes, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities):MEDMeshMultiLev(m,nbOfNodes,gts,pfls,nbEntities),_is_internal(true)
-{
- // ids fields management
- _cell_fam_ids_nocpy=true; _cell_num_ids_nocpy=true;
- const DataArrayInt *tmp(0);
- tmp=m->getFamilyFieldAtLevel(0);
- if(tmp)
- {
- tmp->incrRef();
- _cell_fam_ids=const_cast<DataArrayInt *>(tmp);
- }
- tmp=m->getNumberFieldAtLevel(0);
- if(tmp)
- {
- tmp->incrRef();
- _cell_num_ids=const_cast<DataArrayInt *>(tmp);
- }
- //
- _node_fam_ids_nocpy=true; _node_num_ids_nocpy=true;
- tmp=0;
- tmp=m->getFamilyFieldAtLevel(1);
+ // faces (if any)
+ _face_fam_ids_nocpy=true; _face_num_ids_nocpy=true;
+ tmp=m->getFamilyFieldAtLevel(-1);
if(tmp)
{
tmp->incrRef();
- _node_fam_ids=const_cast<DataArrayInt *>(tmp);
+ _face_fam_ids=const_cast<DataArrayInt *>(tmp);
}
- tmp=m->getNumberFieldAtLevel(1);
+ tmp=m->getNumberFieldAtLevel(-1);
if(tmp)
{
tmp->incrRef();
- _node_num_ids=const_cast<DataArrayInt *>(tmp);
+ _face_num_ids=const_cast<DataArrayInt *>(tmp);
}
}
-MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev(const MEDStructuredMeshMultiLev& other):MEDMeshMultiLev(other),_is_internal(true)
+void MEDStructuredMeshMultiLev::moveFaceToCell() const
{
+ const_cast<MEDStructuredMeshMultiLev *>(this)->_cell_fam_ids_nocpy=_face_fam_ids_nocpy;
+ const_cast<MEDStructuredMeshMultiLev *>(this)->_cell_num_ids_nocpy=_face_num_ids_nocpy;
+ const_cast<MEDStructuredMeshMultiLev *>(this)->_cell_fam_ids=_face_fam_ids; const_cast<MEDStructuredMeshMultiLev *>(this)->_face_fam_ids=0;
+ const_cast<MEDStructuredMeshMultiLev *>(this)->_cell_num_ids=_face_num_ids; const_cast<MEDStructuredMeshMultiLev *>(this)->_face_num_ids=0;
}
bool MEDStructuredMeshMultiLev::prepareForImplicitUnstructuredMeshCase(MEDMeshMultiLev *&ret) const
throw INTERP_KERNEL::Exception("MEDStructuredMeshMultiLev::prepareForImplicitUnstructuredMeshCase only one geo types supported at most supported for the moment !");
INTERP_KERNEL::NormalizedCellType gt(MEDCouplingStructuredMesh::GetGeoTypeGivenMeshDimension(_mesh->getMeshDimension()));
if(_geo_types[0]==gt)
- return false;
+ return false;
MEDCoupling1GTUMesh *facesIfPresent((static_cast<const MEDFileStructuredMesh *>(_mesh))->getImplicitFaceMesh());
if(!facesIfPresent)
return false;
if(!_pfls.empty())
pfl=_pfls[0];
MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> facesIfPresent2(facesIfPresent); facesIfPresent->incrRef();
+ moveFaceToCell();
MEDCouplingAutoRefCountObjectPtr<MEDUMeshMultiLev> ret2(new MEDUMeshMultiLev(*this,facesIfPresent2));
if(pfl)
- throw INTERP_KERNEL::Exception("MEDStructuredMeshMultiLev::prepareForImplicitUnstructuredMeshCase : case is not treated yet for profile on implicit unstructured mesh.");
+ ret2->setCellReduction(pfl);
if(nr)
throw INTERP_KERNEL::Exception("MEDStructuredMeshMultiLev::prepareForImplicitUnstructuredMeshCase : case is not treated yet for node reduction on implicit unstructured mesh.");
ret=ret2.retn();
ret2->setNumberIdsOnCells(tmp,false);
}
return ret2.retn();
-
+
}
else
{
return true;
}
-bool MEDFileField1TSStructItem2::operator==(const MEDFileField1TSStructItem2& other) const throw(INTERP_KERNEL::Exception)
+bool MEDFileField1TSStructItem2::operator==(const MEDFileField1TSStructItem2& other) const
{
//_nb_of_entity is not taken into account here. It is not a bug, because no mesh consideration needed here to perform fast compare.
//idem for _loc. It is not an effective attribute for support comparison.
void MEDFileField1TSStructItem::checkWithMeshStruct(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs)
{
switch(_type)
- {
+ {
case ON_NODES:
{
int nbOfEnt=mst->getNumberOfNodes();
}
default:
throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::checkWithMeshStruct : not managed field type !");
- }
+ }
}
-bool MEDFileField1TSStructItem::operator==(const MEDFileField1TSStructItem& other) const throw(INTERP_KERNEL::Exception)
+bool MEDFileField1TSStructItem::operator==(const MEDFileField1TSStructItem& other) const
{
if(_type!=other._type)
return false;
return false;
}
-const MEDFileField1TSStructItem2& MEDFileField1TSStructItem::operator[](std::size_t i) const throw(INTERP_KERNEL::Exception)
+const MEDFileField1TSStructItem2& MEDFileField1TSStructItem::operator[](std::size_t i) const
{
if(i>=_items.size())
throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::operator[] : input is not in valid range !");