From 634bc0a0a35a1e5c7500a3791b64f104ebd57ef2 Mon Sep 17 00:00:00 2001 From: ageay Date: Thu, 20 Aug 2009 12:10:09 +0000 Subject: [PATCH] Some new functionalities able to deal with dynamic types as classic one. --- src/INTERP_KERNEL/CellModel.cxx | 82 ++++++++++++++++++++++++++++++++- src/INTERP_KERNEL/CellModel.hxx | 7 ++- 2 files changed, 86 insertions(+), 3 deletions(-) diff --git a/src/INTERP_KERNEL/CellModel.cxx b/src/INTERP_KERNEL/CellModel.cxx index c31b7e0e7..6b2811676 100644 --- a/src/INTERP_KERNEL/CellModel.cxx +++ b/src/INTERP_KERNEL/CellModel.cxx @@ -20,6 +20,7 @@ #include "InterpKernelException.hxx" +#include #include #include @@ -42,6 +43,25 @@ namespace INTERP_KERNEL return (*iter).second; } + /*! + * This method is compatible with all types including dynamic one. + */ + bool CellModel::isCompatibleWith(NormalizedCellType type) const + { + if(_type==type) + return true; + const CellModel& other=getCellModel(type); + if(_dim!=other.getDimension()) + return false; + bool b1=isQuadratic(); + bool b2=other.isQuadratic(); + if((b1 && !b2) || (!b1 && b2)) + return false; + b1=isDynamic(); + b2=other.isDynamic(); + return b1 || b2; + } + void CellModel::buildUniqueInstance() { _map_of_unique_instance.insert(make_pair(NORM_POINT0,CellModel(NORM_POINT0))); @@ -63,7 +83,7 @@ namespace INTERP_KERNEL _map_of_unique_instance.insert(make_pair(NORM_POLYHED,CellModel(NORM_POLYHED))); } - CellModel::CellModel(NormalizedCellType type) + CellModel::CellModel(NormalizedCellType type):_type(type) { _quadratic=false; _dyn=false; @@ -228,11 +248,69 @@ namespace INTERP_KERNEL } } - void CellModel::fillSonCellNodalConnectivity(int sonId, const int *nodalConn, int *sonNodalConn) const + /*! + * Equivalent to getNumberOfSons except that this method deals with dynamic type. + */ + unsigned CellModel::getNumberOfSons2(const int *conn, int lgth) const + { + if(!isDynamic()) + return getNumberOfSons(); + if(_dim==2)//polygon + return lgth; + else + return std::count(conn,conn+lgth,-1)+1; + } + + /*! + * Equivalent to getSonType except that this method deals with dynamic type. + */ + NormalizedCellType CellModel::getSonType2(unsigned sonId) const + { + if(!isDynamic()) + return getSonType(sonId); + if(_dim==2)//polygon + return NORM_SEG2; + //polyedron + return NORM_POLYGON; + } + + /*! + * \b WARNING this method do not manage correctly types that return true at the call of isDynamic. Use fillSonCellNodalConnectivity2 instead. + */ + unsigned CellModel::fillSonCellNodalConnectivity(int sonId, const int *nodalConn, int *sonNodalConn) const { unsigned nbOfTurnLoop=_nb_of_sons_con[sonId]; const unsigned *sonConn=_sons_con[sonId]; for(unsigned i=0;i