X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FINTERP_KERNEL%2FGaussPoints%2FInterpKernelGaussCoords.cxx;h=ca889b288973411395f924f098b66582aa2620d2;hb=b307fa3ee9c6d9e08082e2ccc832b28a17fd6d2c;hp=42ef1a89d3dcf1ac6282e1eeace1936673141037;hpb=659f8c67d0348350e12fde38fe8c4de1ff95dffe;p=tools%2Fmedcoupling.git diff --git a/src/INTERP_KERNEL/GaussPoints/InterpKernelGaussCoords.cxx b/src/INTERP_KERNEL/GaussPoints/InterpKernelGaussCoords.cxx index 42ef1a89d..ca889b288 100644 --- a/src/INTERP_KERNEL/GaussPoints/InterpKernelGaussCoords.cxx +++ b/src/INTERP_KERNEL/GaussPoints/InterpKernelGaussCoords.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2014 CEA/DEN, EDF R&D +// Copyright (C) 2007-2021 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 @@ -28,6 +28,70 @@ using namespace INTERP_KERNEL; +const double GaussInfo::SEG2A_REF[2]={-1.0, 1.0}; + +const double GaussInfo::SEG2B_REF[2]={0., 1.0}; + +const double GaussInfo::SEG3_REF[3]={-1.0, 1.0, 0.0}; + +const double GaussInfo::TRIA3A_REF[6]={-1.0, 1.0, -1.0, -1.0, 1.0, -1.0}; + +const double GaussInfo::TRIA3B_REF[6]={0.0, 0.0, 1.0, 0.0, 0.0, 1.0}; + +const double GaussInfo::TRIA6A_REF[12]={-1.0, 1.0, -1.0, -1.0, 1.0, -1.0, -1.0, 1.0, 0.0, -1.0, 0.0, 0.0}; + +const double GaussInfo::TRIA6B_REF[12]={0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.5, 0.0, 0.5, 0.5, 0.0, 0.5}; + +const double GaussInfo::TRIA7A_REF[14]={0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.5, 0.0, 0.5, 0.5, 0.0, 0.5, 0.3333333333333333, 0.3333333333333333}; + +const double GaussInfo::QUAD4A_REF[8]={-1.0, 1.0, -1.0, -1.0, 1.0, -1.0, 1.0, 1.0}; + +const double GaussInfo::QUAD4B_REF[8]={-1.0, -1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0}; + +const double GaussInfo::QUAD8A_REF[16]={-1.0, 1.0, -1.0, -1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 0.0, 0.0, -1.0, 1.0, 0.0, 0.0, 1.0}; + +const double GaussInfo::QUAD8B_REF[16]={-1.0, -1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 0.0, -1.0, 1.0, 0.0, 0.0, 1.0, -1.0, 0.0}; + +const double GaussInfo::QUAD9A_REF[18]={-1.0, -1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 0.0, -1.0, 1.0, 0.0, 0.0, 1.0, -1.0, 0.0, 0.0, 0.0}; + +const double GaussInfo::TETRA4A_REF[12]={0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0}; + +const double GaussInfo::TETRA4B_REF[12]={0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0}; + +const double GaussInfo::TETRA10A_REF[30]={0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.0, 0.0, 0.5, 0.0, 0.5, 0.0, 0.5, 0.5, 0.0, 0.5, 0.0, 0.5, 0.5, 0.0, 0.0}; + +const double GaussInfo::TETRA10B_REF[30]={0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.5, 0.0, 0.5, 0.5, 0.5, 0.5, 0.0, 0.5, 0.0, 0.0, 0.5, 0.0, 0.5}; + +const double GaussInfo::PYRA5A_REF[15]={1.0, 0.0, 0.0, 0.0, 1.0, 0.0, -1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, 1.0}; + +const double GaussInfo::PYRA5B_REF[15]={1.0, 0.0, 0.0, 0.0, -1.0, 0.0, -1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0}; + +const double GaussInfo::PYRA13A_REF[39]={1.0, 0.0, 0.0, 0.0, 1.0, 0.0, -1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, 1.0, 0.5, 0.5, 0.0, -0.5, 0.5, 0.0, -0.5, -0.5, 0.0, 0.5, -0.5, 0.0, 0.5, 0.0, 0.5, 0.0, 0.5, 0.5, -0.5, 0.0, 0.5, 0.0, -0.5, 0.5}; + +const double GaussInfo::PYRA13B_REF[39]={1.0, 0.0, 0.0, 0.0, -1.0, 0.0, -1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.5, -0.5, 0.0, -0.5, -0.5, 0.0, -0.5, 0.5, 0.0, 0.5, 0.5, 0.0, 0.5, 0.0, 0.5, 0.0, -0.5, 0.5, -0.5, 0.0, 0.5, 0.0, 0.5, 0.5}; + +const double GaussInfo::PENTA6A_REF[18]={-1.0, 1.0, 0.0, -1.0, -0.0, 1.0, -1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0}; + +const double GaussInfo::PENTA6B_REF[18]={-1.0, 1.0, 0.0, -1.0, 0.0, 0.0, -1.0, -0.0, 1.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0}; + +const double GaussInfo::PENTA15A_REF[45]={-1.0, 1.0, 0.0, -1.0, -0.0, 1.0, -1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0, -1.0, 0.5, 0.5, -1.0, 0.0, 0.5, -1.0, 0.5, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.5, 0.5, 1.0, 0.0, 0.5, 1.0, 0.5, 0.0}; + +const double GaussInfo::PENTA15B_REF[45]={-1.0, 1.0, 0.0, -1.0, 0.0, 0.0, -1.0, -0.0, 1.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, -1.0, 0.5, 0.0, -1.0, 0.0, 0.5, -1.0, 0.5, 0.5, 1.0, 0.5, 0.0, 1.0, 0.0, 0.5, 1.0, 0.5, 0.5, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0}; + +const double GaussInfo::PENTA18A_REF[54]={-1.0, 1.0, 0.0, -1.0, -0.0, 1.0, -1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0, -1.0, 0.5, 0.5, -1.0, 0.0, 0.5, -1.0, 0.5, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.5, 0.5, 1.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0, 0.5, 0.5, 0.0, 0.0, 0.5, 0.0, 0.5, 0.0}; + +const double GaussInfo::PENTA18B_REF[54]={-1.0, 1.0, 0.0, -1.0, 0.0, 0.0, -1.0, -0.0, 1.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, -1.0, 0.5, 0.0, -1.0, 0.0, 0.5, -1.0, 0.5, 0.5, 1.0, 0.5, 0.0, 1.0, 0.0, 0.5, 1.0, 0.5, 0.5, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.5, 0.0, 0.5, 0.5}; + +const double GaussInfo::HEXA8A_REF[24]={-1.0, -1.0, -1.0, 1.0, -1.0, -1.0, 1.0, 1.0, -1.0, -1.0, 1.0, -1.0, -1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 1.0, 1.0, 1.0, -1.0, 1.0, 1.0}; + +const double GaussInfo::HEXA8B_REF[24]={-1.0, -1.0, -1.0, -1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0, -1.0, -1.0, -1.0, -1.0, 1.0, -1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1.0, 1.0}; + +const double GaussInfo::HEXA20A_REF[60]={-1.0, -1.0, -1.0, 1.0, -1.0, -1.0, 1.0, 1.0, -1.0, -1.0, 1.0, -1.0, -1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 1.0, 1.0, 1.0, -1.0, 1.0, 1.0, 0.0, -1.0, -1.0, 1.0, 0.0, -1.0, 0.0, 1.0, -1.0, -1.0, 0.0, -1.0, -1.0, -1.0, 0.0, 1.0, -1.0, 0.0, 1.0, 1.0, 0.0, -1.0, 1.0, 0.0, 0.0, -1.0, 1.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, -1.0, 0.0, 1.0}; + +const double GaussInfo::HEXA20B_REF[60]={-1.0, -1.0, -1.0, -1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0, -1.0, -1.0, -1.0, -1.0, 1.0, -1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1.0, 1.0, -1.0, 0.0, -1.0, 0.0, 1.0, -1.0, 1.0, 0.0, -1.0, 0.0, -1.0, -1.0, -1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0, 0.0, -1.0, 1.0, -1.0, -1.0, 0.0, -1.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0, -1.0, 0.0}; + +const double GaussInfo::HEXA27A_REF[81]={-1.0, -1.0, -1.0, -1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0, -1.0, -1.0, -1.0, -1.0, 1.0, -1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1.0, 1.0, -1.0, 0.0, -1.0, 0.0, 1.0, -1.0, 1.0, 0.0, -1.0, 0.0, -1.0, -1.0, -1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0, 0.0, -1.0, 1.0, -1.0, -1.0, 0.0, -1.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0, -1.0, 0.0, 0.0, 0.0, -1.0, -1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0}; + //Define common part of the code in the MACRO //--------------------------------------------------------------- #define LOCAL_COORD_MACRO_BEGIN \ @@ -112,7 +176,7 @@ int GaussInfo::getGaussCoordDim() const { if( _my_nb_gauss ) { - return _my_gauss_coord.size()/_my_nb_gauss; + return (int)_my_gauss_coord.size()/_my_nb_gauss; } else { @@ -127,7 +191,7 @@ int GaussInfo::getReferenceCoordDim() const { if( _my_nb_ref ) { - return _my_reference_coord.size()/_my_nb_ref; + return (int)(_my_reference_coord.size()/_my_nb_ref); } else { @@ -159,6 +223,172 @@ int GaussInfo::getNbRef() const return _my_nb_ref; } +GaussInfo GaussInfo::convertToLinear() const +{ + switch(_my_geometry) + { + case NORM_SEG3: + { + std::vector a(SEG3_REF,SEG3_REF+3); + if(IsSatisfy(a,_my_reference_coord)) + { + std::vector c(SEG2A_REF,SEG2A_REF+2); + return GaussInfo(NORM_SEG2,_my_gauss_coord,getNbGauss(),c,2); + } + throw INTERP_KERNEL::Exception("GaussInfo::convertToLinear : not recognized pattern for SEG3 !"); + } + case NORM_TRI6: + { + std::vector a(TRIA6A_REF,TRIA6A_REF+12),b(TRIA6B_REF,TRIA6B_REF+12); + if(IsSatisfy(a,_my_reference_coord)) + { + std::vector c(TRIA3A_REF,TRIA3A_REF+6); + return GaussInfo(NORM_TRI3,_my_gauss_coord,getNbGauss(),c,3); + } + if(IsSatisfy(b,_my_reference_coord)) + { + std::vector c(TRIA3B_REF,TRIA3B_REF+6); + return GaussInfo(NORM_TRI3,_my_gauss_coord,getNbGauss(),c,3); + } + throw INTERP_KERNEL::Exception("GaussInfo::convertToLinear : not recognized pattern for TRI6 !"); + } + case NORM_TRI7: + { + std::vector a(TRIA7A_REF,TRIA7A_REF+14); + if(IsSatisfy(a,_my_reference_coord)) + { + std::vector c(TRIA3B_REF,TRIA3B_REF+6); + return GaussInfo(NORM_TRI3,_my_gauss_coord,getNbGauss(),c,3); + } + throw INTERP_KERNEL::Exception("GaussInfo::convertToLinear : not recognized pattern for TRI7 !"); + } + case NORM_QUAD8: + { + std::vector a(QUAD8A_REF,QUAD8A_REF+16),b(QUAD8B_REF,QUAD8B_REF+16); + if(IsSatisfy(a,_my_reference_coord)) + { + std::vector c(QUAD4A_REF,QUAD4A_REF+8); + return GaussInfo(NORM_QUAD4,_my_gauss_coord,getNbGauss(),c,4); + } + if(IsSatisfy(b,_my_reference_coord)) + { + std::vector c(QUAD4B_REF,QUAD4B_REF+8); + return GaussInfo(NORM_QUAD4,_my_gauss_coord,getNbGauss(),c,4); + } + throw INTERP_KERNEL::Exception("GaussInfo::convertToLinear : not recognized pattern for QUAD8 !"); + } + case NORM_QUAD9: + { + std::vector a(QUAD9A_REF,QUAD9A_REF+18); + if(IsSatisfy(a,_my_reference_coord)) + { + std::vector c(QUAD4B_REF,QUAD4B_REF+8); + return GaussInfo(NORM_QUAD4,_my_gauss_coord,getNbGauss(),c,4); + } + throw INTERP_KERNEL::Exception("GaussInfo::convertToLinear : not recognized pattern for QUAD9 !"); + } + case NORM_TETRA10: + { + std::vector a(TETRA10A_REF,TETRA10A_REF+30),b(TETRA10B_REF,TETRA10B_REF+30); + if(IsSatisfy(a,_my_reference_coord)) + { + std::vector c(TETRA4A_REF,TETRA4A_REF+12); + return GaussInfo(NORM_TETRA4,_my_gauss_coord,getNbGauss(),c,4); + } + if(IsSatisfy(b,_my_reference_coord)) + { + std::vector c(TETRA4B_REF,TETRA4B_REF+12); + return GaussInfo(NORM_TETRA4,_my_gauss_coord,getNbGauss(),c,4); + } + throw INTERP_KERNEL::Exception("GaussInfo::convertToLinear : not recognized pattern for TETRA10 !"); + } + case NORM_PYRA13: + { + std::vector a(PYRA13A_REF,PYRA13A_REF+39),b(PYRA13B_REF,PYRA13B_REF+39); + if(IsSatisfy(a,_my_reference_coord)) + { + std::vector c(PYRA5A_REF,PYRA5A_REF+15); + return GaussInfo(NORM_PYRA5,_my_gauss_coord,getNbGauss(),c,5); + } + if(IsSatisfy(b,_my_reference_coord)) + { + std::vector c(PYRA5B_REF,PYRA5B_REF+15); + return GaussInfo(NORM_PYRA5,_my_gauss_coord,getNbGauss(),c,5); + } + throw INTERP_KERNEL::Exception("GaussInfo::convertToLinear : not recognized pattern for PYRA13 !"); + } + case NORM_PENTA15: + { + std::vector a(PENTA15A_REF,PENTA15A_REF+45),b(PENTA15B_REF,PENTA15B_REF+45); + if(IsSatisfy(a,_my_reference_coord)) + { + std::vector c(PENTA6A_REF,PENTA6A_REF+18); + return GaussInfo(NORM_PENTA6,_my_gauss_coord,getNbGauss(),c,6); + } + if(IsSatisfy(b,_my_reference_coord)) + { + std::vector c(PENTA6B_REF,PENTA6B_REF+18); + return GaussInfo(NORM_PENTA6,_my_gauss_coord,getNbGauss(),c,6); + } + throw INTERP_KERNEL::Exception("GaussInfo::convertToLinear : not recognized pattern for PENTA15 !"); + } + case NORM_PENTA18: + { + std::vector a(PENTA18A_REF,PENTA18A_REF+54),b(PENTA18B_REF,PENTA18B_REF+54); + if(IsSatisfy(a,_my_reference_coord)) + { + std::vector c(PENTA6A_REF,PENTA6A_REF+18); + return GaussInfo(NORM_PENTA6,_my_gauss_coord,getNbGauss(),c,6); + } + if(IsSatisfy(b,_my_reference_coord)) + { + std::vector c(PENTA6B_REF,PENTA6B_REF+18); + return GaussInfo(NORM_PENTA6,_my_gauss_coord,getNbGauss(),c,6); + } + throw INTERP_KERNEL::Exception("GaussInfo::convertToLinear : not recognized pattern for PENTA18 !"); + } + case NORM_HEXA20: + { + std::vector a(HEXA20A_REF,HEXA20A_REF+60),b(HEXA20B_REF,HEXA20B_REF+60); + if(IsSatisfy(a,_my_reference_coord)) + { + std::vector c(HEXA8A_REF,HEXA8A_REF+24); + return GaussInfo(NORM_HEXA8,_my_gauss_coord,getNbGauss(),c,8); + } + if(IsSatisfy(b,_my_reference_coord)) + { + std::vector c(HEXA8B_REF,HEXA8B_REF+24); + return GaussInfo(NORM_HEXA8,_my_gauss_coord,getNbGauss(),c,8); + } + throw INTERP_KERNEL::Exception("GaussInfo::convertToLinear : not recognized pattern for HEXA20 !"); + } + case NORM_HEXA27: + { + std::vector a(HEXA27A_REF,HEXA27A_REF+81); + if(IsSatisfy(a,_my_reference_coord)) + { + std::vector c(HEXA8B_REF,HEXA8B_REF+24); + return GaussInfo(NORM_HEXA8,_my_gauss_coord,getNbGauss(),c,8); + } + throw INTERP_KERNEL::Exception("GaussInfo::convertToLinear : not recognized pattern for HEXA27 !"); + } + default: + throw INTERP_KERNEL::Exception("GaussInfo::convertToLinear : not implemented yet for other types than TETRA10, HEXA20, HEXA27, TRI3, QUAD8, QUAD8, PYRA13, PENTA15 !"); + } +} + + +bool GaussInfo::IsSatisfy(const std::vector& ref1, const std::vector& ref2) +{ + std::size_t sz(ref1.size()); + if(sz!=ref2.size()) + return false; + for(std::size_t i=0;i(theNbGauss), aReferenceCoord, FromIdType(theNbRef)); info->initLocalInfo(); //If info with cell type doesn't exist add it @@ -2527,7 +3256,7 @@ void GaussCoords::addGaussInfo( NormalizedCellType theGeometry, } else { - int index = std::distance(_my_gauss_info.begin(),it); + std::size_t index = std::distance(_my_gauss_info.begin(),it); delete (*it); _my_gauss_info[index] = info; } @@ -2540,7 +3269,7 @@ void GaussCoords::addGaussInfo( NormalizedCellType theGeometry, double* GaussCoords::calculateCoords( NormalizedCellType theGeometry, const double *theNodeCoords, const int theSpaceDim, - const int *theIndex) + const mcIdType *theIndex) { const GaussInfo *info = getInfoGivenCellType(theGeometry); int nbCoords = theSpaceDim * info->getNbGauss(); @@ -2550,13 +3279,13 @@ double* GaussCoords::calculateCoords( NormalizedCellType theGeometry, } -void GaussCoords::calculateCoords( NormalizedCellType theGeometry, const double *theNodeCoords, const int theSpaceDim, const int *theIndex, double *result) +void GaussCoords::calculateCoords( NormalizedCellType theGeometry, const double *theNodeCoords, const int theSpaceDim, const mcIdType *theIndex, double *result) { const GaussInfo *info = getInfoGivenCellType(theGeometry); calculateCoordsAlg(info,theNodeCoords,theSpaceDim,theIndex,result); } -void GaussCoords::calculateCoordsAlg(const GaussInfo *info, const double* theNodeCoords, const int theSpaceDim, const int *theIndex, double *result) +void GaussCoords::calculateCoordsAlg(const GaussInfo *info, const double* theNodeCoords, const int theSpaceDim, const mcIdType *theIndex, double *result) { int aConn = info->getNbRef();