#include "MEDCoupling1GTUMesh.hxx"
#include "MEDCouplingUMesh.hxx"
#include "MEDCouplingFieldDouble.hxx"
+#include "MEDCouplingCMesh.hxx"
#include "SplitterTetra.hxx"
}
}
ret->setNodalConnectivity(conn);
+ try
+ { ret->copyTinyInfoFrom(m); }
+ catch(INTERP_KERNEL::Exception&) { }
return ret.retn();
}
}
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cI=DataArrayInt::Range(0,(nbCells+1)*(nbNodesPerCell+1),nbNodesPerCell+1);
ret->setConnectivity(c,cI,true);
+ try
+ { ret->copyTinyInfoFrom(this); }
+ catch(INTERP_KERNEL::Exception&) { }
return ret.retn();
}
return ret.retn();
}
+/*!
+ * This method starts from an unstructured mesh that hides in reality a cartesian mesh.
+ * If it is not the case, an exception will be thrown.
+ * This method returns three objects : The cartesian mesh geometrically equivalent to \a this (within a precision of \a eps) and a permutation of cells
+ * and a permutation of nodes.
+ *
+ * \param [out] cellPerm the permutation array of size \c this->getNumberOfCells()
+ * \param [out] nodePerm the permutation array of size \c this->getNumberOfNodes()
+ * \return MEDCouplingCMesh * - a newly allocated mesh that is the result of the structurization of \a this.
+ */
+MEDCouplingCMesh *MEDCoupling1SGTUMesh::structurizeMe(DataArrayInt *& cellPerm, DataArrayInt *& nodePerm, double eps) const
+{
+ checkCoherency();
+ int spaceDim(getSpaceDimension()),meshDim(getMeshDimension()),nbNodes(getNumberOfNodes());
+ if(MEDCouplingStructuredMesh::GetGeoTypeGivenMeshDimension(meshDim)!=getCellModelEnum())
+ throw INTERP_KERNEL::Exception("MEDCoupling1SGTUMesh::structurizeMe : the unique geo type in this is not compatible with the geometric type regarding mesh dimension !");
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingCMesh> cm(MEDCouplingCMesh::New());
+ for(int i=0;i<spaceDim;i++)
+ {
+ std::vector<int> tmp(1,i);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> elt(static_cast<DataArrayDouble*>(getCoords()->keepSelectedComponents(tmp)));
+ elt=elt->getDifferentValues(eps);
+ elt->sort(true);
+ cm->setCoordsAt(i,elt);
+ }
+ if(nbNodes!=cm->getNumberOfNodes())
+ throw INTERP_KERNEL::Exception("MEDCoupling1SGTUMesh::structurizeMe : considering the number of nodes after split per components in space this can't be a cartesian mesh ! Maybe your epsilon parameter is invalid ?");
+ try
+ { cm->copyTinyInfoFrom(this); }
+ catch(INTERP_KERNEL::Exception&) { }
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> um(cm->buildUnstructured()),self(buildUnstructured());
+ self->checkGeoEquivalWith(um,12,eps,cellPerm,nodePerm);
+ return cm.retn();
+}
+
/// @cond INTERNAL
bool UpdateHexa8Cell(int validAxis, int neighId, const int *validConnQuad4NeighSide, int *allFacesNodalConn, int *myNeighbours)
}
}
ret->setConnectivity(c,cI,true);
+ try
+ { ret->copyTinyInfoFrom(this); }
+ catch(INTERP_KERNEL::Exception&) { }
return ret.retn();
}
};
class MEDCoupling1DGTUMesh;
+ class MEDCouplingCMesh;
class MEDCoupling1SGTUMesh : public MEDCoupling1GTUMesh
{
MEDCOUPLING_EXPORT MEDCoupling1GTUMesh *computeDualMesh() const;
MEDCOUPLING_EXPORT DataArrayInt *sortHexa8EachOther();
MEDCOUPLING_EXPORT MEDCoupling1SGTUMesh *explodeEachHexa8To6Quad4() const;
+ MEDCOUPLING_EXPORT MEDCouplingCMesh *structurizeMe(DataArrayInt *& cellPerm, DataArrayInt *& nodePerm, double eps=1e-12) const;
public://serialization
MEDCOUPLING_EXPORT void getTinySerializationInformation(std::vector<double>& tinyInfoD, std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const;
MEDCOUPLING_EXPORT void resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings) const;
*/
void MEDCouplingPointSet::copyTinyStringsFrom(const MEDCouplingMesh *other)
{
+ MEDCouplingMesh::copyTinyStringsFrom(other);
const MEDCouplingPointSet *otherC=dynamic_cast<const MEDCouplingPointSet *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("MEDCouplingPointSet::copyTinyStringsFrom : meshes have not same type !");
- MEDCouplingMesh::copyTinyStringsFrom(other);
if(_coords && otherC->_coords)
_coords->copyStringInfoFrom(*otherC->_coords);
}
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> conn(Build1GTNodalConnectivity(ns,ns+spaceDim));
MEDCouplingAutoRefCountObjectPtr<MEDCoupling1SGTUMesh> ret(MEDCoupling1SGTUMesh::New(getName(),GetGeoTypeGivenMeshDimension(meshDim)));
ret->setNodalConnectivity(conn); ret->setCoords(coords);
+ try
+ { ret->copyTinyInfoFrom(this); }
+ catch(INTERP_KERNEL::Exception&) { }
return ret.retn();
}
#f.applyLin(2.,0.)
#self.assertTrue(f.getArray().isEqual(DataArrayDouble([243.,211.,211.,179.,211.,179.,179.,127.]),1e-12))
pass
-
+
+ def testSwig2StructurizeMe1(self):
+ arrx=DataArrayDouble(3) ; arrx.iota() ; arrx*=2.
+ arry=DataArrayDouble(4) ; arry.iota() ; arry+=3.
+ arrz=DataArrayDouble(5) ; arrz.iota() ; arrz*=0.5 ; arrz+=2.
+ c=MEDCouplingCMesh() ; c.setCoords(arrx,arry,arrz)
+ c.setName("mesh") ; c.setDescription("mesh descr") ; c.setTimeUnit("us") ; c.setTime(1.2,3,4)
+ u=c.buildUnstructured()
+ cp=DataArrayInt([3,5,6,1,0,9,8,7,12,11,16,10,17,23,22,21,19,20,18,14,13,2,4,15])
+ np=DataArrayInt([3,33,5,35,6,36,1,31,0,30,9,39,8,38,7,37,12,42,11,41,16,46,10,40,17,47,23,53,22,52,21,51,19,49,20,50,18,48,14,44,13,43,2,32,4,34,15,45,29,59,28,58,27,57,26,56,25,55,24,54])
+ u.renumberCells(cp)
+ u.renumberNodes(np,len(np))
+ u=MEDCoupling1SGTUMesh(u)
+ #
+ e,d,f=u.structurizeMe()
+ self.assertTrue(c.isEqual(e,1e-12))
+ self.assertTrue(d.isEqual(cp))
+ self.assertTrue(f.isEqual(np))
+ pass
+
def setUp(self):
pass
pass
return oss.str();
}
+ PyObject *structurizeMe(double eps=1e-12) const throw(INTERP_KERNEL::Exception)
+ {
+ DataArrayInt *cellPerm(0),*nodePerm(0);
+ MEDCouplingCMesh *retCpp(self->structurizeMe(cellPerm,nodePerm,eps));
+ PyObject *ret(PyTuple_New(3));
+ PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(retCpp),SWIGTYPE_p_ParaMEDMEM__MEDCouplingCMesh, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(cellPerm),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,2,SWIG_NewPointerObj(SWIG_as_voidptr(nodePerm),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ return ret;
+ }
+
static MEDCoupling1SGTUMesh *Merge1SGTUMeshes(PyObject *li) throw(INTERP_KERNEL::Exception)
{
std::vector<const ParaMEDMEM::MEDCoupling1SGTUMesh *> tmp;