-// Copyright (C) 2007-2013 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2016 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
#include "CellModel.hxx"
#include "InterpKernelException.hxx"
+#include "DiameterCalculator.hxx"
#include <algorithm>
#include <sstream>
{
_nb_of_pts=0; _nb_of_sons=0; _dim=1; _dyn=true; _extruded_type=NORM_POLYGON; _is_simplex=false;
}
+ break;
case NORM_ERROR:
{
_nb_of_pts=std::numeric_limits<unsigned>::max(); _nb_of_sons=std::numeric_limits<unsigned>::max(); _dim=std::numeric_limits<unsigned>::max();
return (lgth-std::count(conn,conn+lgth,-1))/2;
}
+ /*!
+ * \sa fillMicroEdgeNodalConnectivity
+ */
+ unsigned CellModel::getNumberOfMicroEdges() const
+ {
+ unsigned mul(isQuadratic()?2:1);
+ if(!isDynamic())
+ {
+ switch(getDimension())
+ {
+ case 2:
+ return mul*getNumberOfSons();
+ case 3:
+ return mul*_nb_of_little_sons;
+ default:
+ throw INTERP_KERNEL::Exception("CellModel::getNumberOfMacroEdges : only 2D and 3D cells support this !");
+ }
+ }
+ else
+ throw INTERP_KERNEL::Exception("CellModel::getNumberOfMacroEdges : not supported by dynamic type !");
+ }
+
NormalizedCellType CellModel::getCorrespondingPolyType() const
{
switch(getDimension())
throw INTERP_KERNEL::Exception("CellModel::fillSonEdgesNodalConnectivity3D : not implemented yet for NORM_POLYHED !");
}
+ /*!
+ * \sa getNumberOfMicroEdges
+ */
+ unsigned CellModel::fillMicroEdgeNodalConnectivity(int sonId, const int *nodalConn, int *sonNodalConn, NormalizedCellType& typeOfSon) const
+ {
+ if(isQuadratic())
+ {
+ int edgeId(sonId/2),subEdgeId(sonId%2);
+ typeOfSon=NORM_SEG2;
+ const unsigned *sonConn(0);
+ switch(getDimension())
+ {
+ case 2:
+ {
+ sonConn=_sons_con[edgeId];
+ break;
+ }
+ case 3:
+ {
+ sonConn=_little_sons_con[edgeId];
+ break;
+ }
+ default:
+ throw INTERP_KERNEL::Exception("CellModel::fillMicroEdgeNodalConnectivity : only 2D and 3D cells support this !");
+ }
+ const unsigned tmp[3]={sonConn[0],sonConn[2],sonConn[1]};
+ sonNodalConn[0]=nodalConn[tmp[subEdgeId]];
+ sonNodalConn[1]=nodalConn[tmp[subEdgeId+1]];
+ return 2;
+ }
+ else
+ {
+ switch(getDimension())
+ {
+ case 2:
+ return fillSonCellNodalConnectivity2(sonId,nodalConn,0,sonNodalConn,typeOfSon);
+ case 3:
+ return fillSonEdgesNodalConnectivity3D(sonId,nodalConn,0,sonNodalConn,typeOfSon);
+ default:
+ throw INTERP_KERNEL::Exception("CellModel::fillMicroEdgeNodalConnectivity : only 2D and 3D cells support this #2 !");
+ }
+ }
+ }
+
+ void CellModel::changeOrientationOf2D(int *nodalConn, unsigned int sz) const
+ {
+ if(sz<1)
+ return ;
+ if(!isQuadratic())
+ {
+ std::vector<int> tmp(sz-1);
+ std::copy(nodalConn+1,nodalConn+sz,tmp.rbegin());
+ std::copy(tmp.begin(),tmp.end(),nodalConn+1);
+ }
+ else
+ {
+ unsigned int sz2(sz/2);
+ std::vector<int> tmp0(sz2-1),tmp1(sz2);
+ std::copy(nodalConn+1,nodalConn+sz2,tmp0.rbegin());
+ std::copy(nodalConn+sz2,nodalConn+sz,tmp1.rbegin());
+ std::copy(tmp0.begin(),tmp0.end(),nodalConn+1);
+ std::copy(tmp1.begin(),tmp1.end(),nodalConn+sz2);
+ }
+ }
+
+ void CellModel::changeOrientationOf1D(int *nodalConn, unsigned int sz) const
+ {
+ if(!isDynamic())
+ {
+ if(sz==2 || sz==3)
+ {
+ std::swap(nodalConn[0],nodalConn[1]);
+ return ;
+ }
+ else if(sz==4)
+ {
+ std::swap(nodalConn[0],nodalConn[1]);
+ std::swap(nodalConn[2],nodalConn[3]);
+ }
+ else
+ throw Exception("CellModel::changeOrientationOf1D : unrecognized 1D cell type !");
+ }
+ else
+ {
+ std::vector<int> tmp(sz-1);
+ std::copy(nodalConn+1,nodalConn+sz,tmp.rbegin());
+ std::copy(tmp.begin(),tmp.end(),nodalConn+1);
+ }
+ }
+
//================================================================================
/*!
* \brief Return number of nodes in sonId-th son of a Dynamic() cell
}
}
}
-
+
+ DiameterCalculator *CellModel::buildInstanceOfDiameterCalulator(int spaceDim) const
+ {
+ switch(_type)
+ {
+ case NORM_TRI3:
+ {
+ switch(spaceDim)
+ {
+ case 2:
+ return new DiameterCalulatorTRI3S2;
+ case 3:
+ return new DiameterCalulatorTRI3S3;
+ default:
+ throw Exception("CellModel::buildInstanceOfDiameterCalulator : For TRI3 only space dimension 2 and 3 implemented !");
+ }
+ break;
+ }
+ case NORM_QUAD4:
+ {
+ switch(spaceDim)
+ {
+ case 2:
+ return new DiameterCalulatorQUAD4S2;
+ case 3:
+ return new DiameterCalulatorQUAD4S3;
+ default:
+ throw Exception("CellModel::buildInstanceOfDiameterCalulator : For QUAD4 only space dimension 2 and 3 implemented !");
+ }
+ break;
+ }
+ case NORM_TRI6:
+ {
+ switch(spaceDim)
+ {
+ case 2:
+ return new DiameterCalulatorTRI6S2;
+ case 3:
+ return new DiameterCalulatorTRI6S3;
+ default:
+ throw Exception("CellModel::buildInstanceOfDiameterCalulator : For TRI6 only space dimension 2 and 3 implemented !");
+ }
+ break;
+ }
+ case NORM_TRI7:
+ {
+ switch(spaceDim)
+ {
+ case 2:
+ return new DiameterCalulatorTRI7S2;
+ case 3:
+ return new DiameterCalulatorTRI7S3;
+ default:
+ throw Exception("CellModel::buildInstanceOfDiameterCalulator : For TRI7 only space dimension 2 and 3 implemented !");
+ }
+ break;
+ }
+ case NORM_QUAD8:
+ {
+ switch(spaceDim)
+ {
+ case 2:
+ return new DiameterCalulatorQUAD8S2;
+ case 3:
+ return new DiameterCalulatorQUAD8S3;
+ default:
+ throw Exception("CellModel::buildInstanceOfDiameterCalulator : For QUAD8 only space dimension 2 and 3 implemented !");
+ }
+ break;
+ }
+ case NORM_QUAD9:
+ {
+ switch(spaceDim)
+ {
+ case 2:
+ return new DiameterCalulatorQUAD9S2;
+ case 3:
+ return new DiameterCalulatorQUAD9S3;
+ default:
+ throw Exception("CellModel::buildInstanceOfDiameterCalulator : For QUAD9 only space dimension 2 and 3 implemented !");
+ }
+ break;
+ }
+ case NORM_TETRA4:
+ {
+ if(spaceDim==3)
+ return new DiameterCalulatorTETRA4;
+ else
+ throw Exception("CellModel::buildInstanceOfDiameterCalulator : For TETRA4 space dimension 3 expected !");
+ }
+ case NORM_TETRA10:
+ {
+ if(spaceDim==3)
+ return new DiameterCalulatorTETRA10;
+ else
+ throw Exception("CellModel::buildInstanceOfDiameterCalulator : For TETRA10 space dimension 3 expected !");
+ }
+ case NORM_HEXA8:
+ {
+ if(spaceDim==3)
+ return new DiameterCalulatorHEXA8;
+ else
+ throw Exception("CellModel::buildInstanceOfDiameterCalulator : For HEXA8 space dimension 3 expected !");
+ }
+ case NORM_HEXA20:
+ {
+ if(spaceDim==3)
+ return new DiameterCalulatorHEXA20;
+ else
+ throw Exception("CellModel::buildInstanceOfDiameterCalulator : For HEXA20 space dimension 3 expected !");
+ }
+ case NORM_HEXA27:
+ {
+ if(spaceDim==3)
+ return new DiameterCalulatorHEXA27;
+ else
+ throw Exception("CellModel::buildInstanceOfDiameterCalulator : For HEXA27 space dimension 3 expected !");
+ }
+ case NORM_PENTA6:
+ {
+ if(spaceDim==3)
+ return new DiameterCalulatorPENTA6;
+ else
+ throw Exception("CellModel::buildInstanceOfDiameterCalulator : For PENTA6 space dimension 3 expected !");
+ }
+ case NORM_PENTA15:
+ {
+ if(spaceDim==3)
+ return new DiameterCalulatorPENTA15;
+ else
+ throw Exception("CellModel::buildInstanceOfDiameterCalulator : For PENTA15 space dimension 3 expected !");
+ }
+ case NORM_PYRA5:
+ {
+ if(spaceDim==3)
+ return new DiameterCalulatorPYRA5;
+ else
+ throw Exception("CellModel::buildInstanceOfDiameterCalulator : For PYRA5 space dimension 3 expected !");
+ }
+ case NORM_PYRA13:
+ {
+ if(spaceDim==3)
+ return new DiameterCalulatorPYRA13;
+ else
+ throw Exception("CellModel::buildInstanceOfDiameterCalulator : For PYRA13 space dimension 3 expected !");
+ }
+ default:
+ throw Exception("CellModel::buildInstanceOfDiameterCalulator : implemented only for TRI3, QUAD4, TETRA4, HEXA8, PENTA6, PYRA5 !");
+ }
+ }
}