X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FINTERP_KERNEL%2FGaussPoints%2FInterpKernelGaussCoords.cxx;h=2f3ad3ff3eacd15101afc4077dd9566f4dbc4637;hb=9727e779d56acece98be02cdccd0f99cc5ef0fa2;hp=0fa9d7b5acde60717db21bbc867748548e7bf597;hpb=c66a21a11fed90a9536b758a162785908cfe87da;p=tools%2Fmedcoupling.git diff --git a/src/INTERP_KERNEL/GaussPoints/InterpKernelGaussCoords.cxx b/src/INTERP_KERNEL/GaussPoints/InterpKernelGaussCoords.cxx index 0fa9d7b5a..2f3ad3ff3 100644 --- a/src/INTERP_KERNEL/GaussPoints/InterpKernelGaussCoords.cxx +++ b/src/INTERP_KERNEL/GaussPoints/InterpKernelGaussCoords.cxx @@ -1,9 +1,9 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D +// Copyright (C) 2007-2019 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 @@ -28,6 +28,66 @@ 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::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 \ @@ -159,6 +219,157 @@ 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_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 GaussInfo::NormalizeCoordinatesIfNecessary(NormalizedCellType ct, int inputDim, const std::vector& inputArray) +{ + std::size_t sz(inputArray.size()),dim((std::size_t)inputDim); + if(dim==0) + throw INTERP_KERNEL::Exception("GaussInfo::NormalizeCoordinatesIfNecessary : invalid dimension ! Must be !=0 !"); + if(sz%dim!=0) + throw INTERP_KERNEL::Exception("GaussInfo::NormalizeCoordinatesIfNecessary : invalid input array ! Inconsistent with the given dimension !"); + const CellModel& cm(CellModel::GetCellModel(ct)); + std::size_t baseDim((std::size_t)cm.getDimension()); + if(baseDim==dim) + return inputArray; + std::size_t nbOfItems(sz/dim); + std::vector ret(nbOfItems*baseDim); + if(baseDim>dim) + { + for(std::size_t i=0;igetNbGauss(); @@ -2093,7 +3002,7 @@ double* GaussCoords::calculateCoords( NormalizedCellType theGeometry, } -void GaussCoords::calculateCoords( NormalizedCellType theGeometry, const double *theNodeCoords, const int theSpaceDim, const int *theIndex, double *result) throw(INTERP_KERNEL::Exception) +void GaussCoords::calculateCoords( NormalizedCellType theGeometry, const double *theNodeCoords, const int theSpaceDim, const int *theIndex, double *result) { const GaussInfo *info = getInfoGivenCellType(theGeometry); calculateCoordsAlg(info,theNodeCoords,theSpaceDim,theIndex,result);