// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // // 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, 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 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "MED_GaussUtils.hxx" #include "MED_Utilities.hxx" #ifdef _DEBUG_ static int MYDEBUG = 0; static int MYVALUEDEBUG = 0; #else // static int MYDEBUG = 0; // static int MYVALUEDEBUG = 0; #endif //#define _DEBUG_REF_COORDS_ namespace MED { //--------------------------------------------------------------- TGaussCoord ::TGaussCoord(): TModeSwitchInfo(eFULL_INTERLACE), myNbElem(0), myNbGauss(0), myDim(0), myGaussStep(0) { } void TGaussCoord ::Init(TInt theNbElem, TInt theNbGauss, TInt theDim, EModeSwitch theMode) { myModeSwitch = theMode; myNbElem = theNbElem; myNbGauss = theNbGauss; myDim = theDim; myGaussStep = myNbGauss*myDim; myGaussCoord.resize(theNbElem*myGaussStep); } TInt TGaussCoord ::GetNbElem() const { return myNbElem; } TInt TGaussCoord ::GetNbGauss() const { return myNbGauss; } TInt TGaussCoord ::GetDim() const { return myDim; } unsigned char* TGaussCoord ::GetValuePtr() { return (unsigned char*)&(myGaussCoord[0]); } TCCoordSliceArr TGaussCoord ::GetCoordSliceArr(TInt theElemId) const { TCCoordSliceArr aCoordSliceArr(myNbGauss); if(GetModeSwitch() == eFULL_INTERLACE){ TInt anId = theElemId*myGaussStep; for(TInt anGaussId = 0; anGaussId < myNbGauss; anGaussId++){ aCoordSliceArr[anGaussId] = TCCoordSlice(myGaussCoord,std::slice(anId,myDim,1)); anId += myDim; } } else{ for(TInt anGaussId = 0; anGaussId < myNbGauss; anGaussId++){ aCoordSliceArr[anGaussId] = TCCoordSlice(myGaussCoord,std::slice(theElemId,myDim,myGaussStep)); } } return aCoordSliceArr; } TCoordSliceArr TGaussCoord ::GetCoordSliceArr(TInt theElemId) { TCoordSliceArr aCoordSliceArr(myNbGauss); if(GetModeSwitch() == eFULL_INTERLACE){ TInt anId = theElemId*myGaussStep; for(TInt anGaussId = 0; anGaussId < myNbGauss; anGaussId++){ aCoordSliceArr[anGaussId] = TCoordSlice(myGaussCoord,std::slice(anId,myDim,1)); anId += myDim; } } else{ for(TInt anGaussId = 0; anGaussId < myNbGauss; anGaussId++){ aCoordSliceArr[anGaussId] = TCoordSlice(myGaussCoord,std::slice(theElemId,myDim,myGaussStep)); } } return aCoordSliceArr; } //--------------------------------------------------------------- inline bool IsEqual(TFloat theLeft, TFloat theRight) { static TFloat EPS = 1.0E-3; if(fabs(theLeft) + fabs(theRight) > EPS) return fabs(theLeft-theRight)/(fabs(theLeft)+fabs(theRight)) < EPS; return true; } //--------------------------------------------------------------- class TShapeFun::TFun { TFloatVector myFun; TInt myNbRef; public: void Init(TInt theNbGauss, TInt theNbRef) { myFun.resize(theNbGauss*theNbRef); myNbRef = theNbRef; } TCFloatVecSlice GetFunSlice(TInt theGaussId) const { return TCFloatVecSlice(myFun,std::slice(theGaussId*myNbRef,myNbRef,1)); } TFloatVecSlice GetFunSlice(TInt theGaussId) { return TFloatVecSlice(myFun,std::slice(theGaussId*myNbRef,myNbRef,1)); } }; //--------------------------------------------------------------- TShapeFun::TShapeFun(TInt theDim, TInt theNbRef): myRefCoord(theNbRef*theDim), myDim(theDim), myNbRef(theNbRef) {} TCCoordSlice TShapeFun::GetCoord(TInt theRefId) const { return TCCoordSlice(myRefCoord,std::slice(theRefId*myDim,myDim,1)); } TCoordSlice TShapeFun::GetCoord(TInt theRefId) { return TCoordSlice(myRefCoord,std::slice(theRefId*myDim,myDim,1)); } void TShapeFun::GetFun(const TCCoordSliceArr& theRef, const TCCoordSliceArr& theGauss, TFun& theFun) const { TInt aNbRef = theRef.size(); TInt aNbGauss = theGauss.size(); theFun.Init(aNbGauss,aNbRef); } bool TShapeFun::IsSatisfy(const TCCoordSliceArr& theRefCoord) const { TInt aNbRef = theRefCoord.size(); TInt aNbRef2 = GetNbRef(); INITMSG(MYDEBUG,"TShapeFun::IsSatisfy "<< "- aNbRef("<GetDim(); TInt aNbGauss = theGauss.size(); bool anIsSubMesh = !theElemNum.empty(); TInt aNbElem; if(anIsSubMesh) aNbElem = theElemNum.size(); else aNbElem = theCellInfo.GetNbElem(); theGaussCoord.Init(aNbElem,aNbGauss,aDim,theMode); TFun aFun; InitFun(theRef,theGauss,aFun); TInt aConnDim = theCellInfo.GetConnDim(); INITMSG(MYDEBUG,"aDim = "<GetDim(); static TInt aNbGauss = 1; bool anIsSubMesh = !theElemNum.empty(); TInt aNbElem; if(anIsSubMesh) aNbElem = theElemNum.size(); else aNbElem = theCellInfo.GetNbElem(); theGaussCoord.Init(aNbElem,aNbGauss,aDim,theMode); TInt aConnDim = theCellInfo.GetConnDim(); INITMSGA(MYDEBUG,0, "- aDim = "<GetDim(); static TInt aNbGauss = 1; bool anIsSubMesh = !theElemNum.empty(); TInt aNbElem; if(anIsSubMesh) aNbElem = theElemNum.size(); else aNbElem = thePolygoneInfo.GetNbElem(); theGaussCoord.Init(aNbElem,aNbGauss,aDim,theMode); INITMSGA(MYDEBUG,0, "- aDim = "<GetDim(); static TInt aNbGauss = 1; bool anIsSubMesh = !theElemNum.empty(); TInt aNbElem; if(anIsSubMesh) aNbElem = theElemNum.size(); else aNbElem = thePolyedreInfo.GetNbElem(); theGaussCoord.Init(aNbElem,aNbGauss,aDim,theMode); INITMSGA(MYDEBUG,0, "- aDim = "<