// 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, 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 // // Author : Anthony Geay (CEA/DEN) #ifndef __PLANARINTERSECTORP1P0PL_TXX__ #define __PLANARINTERSECTORP1P0PL_TXX__ #include "PlanarIntersectorP1P0PL.hxx" #include "PlanarIntersector.txx" #include "CellModel.hxx" #include "PointLocatorAlgos.txx" #include "InterpKernelGeo2DQuadraticPolygon.hxx" #include "MeshUtils.hxx" namespace INTERP_KERNEL { template PlanarIntersectorP1P0PL::PlanarIntersectorP1P0PL(const MyMeshType& meshT, const MyMeshType& meshS, double dimCaracteristic, double md3DSurf, double minDot3DSurf, double medianPlane, double precision, int orientation): PlanarIntersector(meshT,meshS,dimCaracteristic,precision,md3DSurf,minDot3DSurf,medianPlane,true,orientation,0) { } template void PlanarIntersectorP1P0PL::intersectCells(ConnType icellT, const std::vector& icellsS, MyMatrix& res) { std::vector CoordsT; typename MyMatrix::value_type& resRow=res[icellT]; PlanarIntersector::getRealTargetCoordinates(OTT::indFC(icellT),CoordsT); double baryT[SPACEDIM]; double baryTTmp[SPACEDIM]; calculateBarycenterDyn2(&CoordsT[0],ToConnType(CoordsT.size())/SPACEDIM,baryT); for(typename std::vector::const_iterator iter=icellsS.begin();iter!=icellsS.end();iter++) { NormalizedCellType tS=PlanarIntersector::_meshS.getTypeOfElement(OTT::indFC(*iter)); if(tS!=NORM_TRI3) throw INTERP_KERNEL::Exception("Invalid source cell detected for meshdim==2. Only TRI3 supported !"); std::vector CoordsS; PlanarIntersector::getRealSourceCoordinates(OTT::indFC(*iter),CoordsS); if(SPACEDIM==2) { std::copy(baryT,baryT+SPACEDIM,baryTTmp); } else { double littleTargetCell[9]; std::copy(baryT,baryT+SPACEDIM,littleTargetCell); std::copy(CoordsT.begin(),CoordsT.begin()+3,littleTargetCell+3); std::copy(CoordsT.begin()+3,CoordsT.begin()+6,littleTargetCell+6); PlanarIntersector::projectionThis(&CoordsS[0],littleTargetCell,3,3); std::copy(littleTargetCell,littleTargetCell+3,baryTTmp); } if(PointLocatorAlgos::isElementContainsPointAlg2D(baryTTmp,&CoordsS[0],3,PlanarIntersector::_precision)) { double resLoc[3]; barycentric_coords(&CoordsS[0],baryTTmp,resLoc); const ConnType *startOfCellNodeConnS=PlanarIntersector::_connectS+OTT::conn2C(PlanarIntersector::_connIndexS[*iter]); for(int nodeIdS=0;nodeIdS<3;nodeIdS++) { if(fabs(resLoc[nodeIdS])>PlanarIntersector::_precision) { ConnType curNodeSInCmode=OTT::coo2C(startOfCellNodeConnS[nodeIdS]); typename MyMatrix::value_type::const_iterator iterRes=resRow.find(OTT::indFC(curNodeSInCmode)); if(iterRes==resRow.end()) resRow.insert(std::make_pair(OTT::indFC(curNodeSInCmode),resLoc[nodeIdS])); else { double val=(*iterRes).second+resLoc[nodeIdS]; resRow.erase(OTT::indFC(curNodeSInCmode)); resRow.insert(std::make_pair(OTT::indFC(curNodeSInCmode),val)); } } } } } } template typename MyMeshType::MyConnType PlanarIntersectorP1P0PL::getNumberOfRowsOfResMatrix() const { return PlanarIntersector::_meshT.getNumberOfElements(); } template typename MyMeshType::MyConnType PlanarIntersectorP1P0PL::getNumberOfColsOfResMatrix() const { return PlanarIntersector::_meshS.getNumberOfNodes(); } } #endif