1 // Copyright (C) 2007-2020 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony Geay (CEA/DEN)
20 #ifndef __PLANARINTERSECTORP1P0_TXX__
21 #define __PLANARINTERSECTORP1P0_TXX__
23 #include "PlanarIntersectorP1P0.hxx"
24 #include "InterpolationUtils.hxx"
26 namespace INTERP_KERNEL
28 template<class MyMeshType, class MyMatrix, class ConcreteP1P0Intersector>
29 PlanarIntersectorP1P0<MyMeshType,MyMatrix,ConcreteP1P0Intersector>::PlanarIntersectorP1P0(const MyMeshType& meshT, const MyMeshType& meshS,
30 double dimCaracteristic, double precision, double md3DSurf, double minDot3DSurf, double medianPlane,
31 bool doRotate, int orientation, int printLevel):
32 PlanarIntersector<MyMeshType,MyMatrix>(meshT,meshS,dimCaracteristic,precision,md3DSurf,minDot3DSurf,medianPlane,doRotate,orientation,printLevel)
36 template<class MyMeshType, class MyMatrix, class ConcreteP1P0Intersector>
37 typename MyMeshType::MyConnType PlanarIntersectorP1P0<MyMeshType,MyMatrix,ConcreteP1P0Intersector>::getNumberOfRowsOfResMatrix() const
39 return PlanarIntersector<MyMeshType,MyMatrix>::_meshT.getNumberOfElements();
42 template<class MyMeshType, class MyMatrix, class ConcreteP1P0Intersector>
43 typename MyMeshType::MyConnType PlanarIntersectorP1P0<MyMeshType,MyMatrix,ConcreteP1P0Intersector>::getNumberOfColsOfResMatrix() const
45 return PlanarIntersector<MyMeshType,MyMatrix>::_meshS.getNumberOfNodes();
49 * This methods split on the fly, into triangles in order to compute dual mesh of target cell (with icellT id in target mesh in C mode).
51 template<class MyMeshType, class MyMatrix, class ConcreteP1P0Intersector>
52 void PlanarIntersectorP1P0<MyMeshType,MyMatrix,ConcreteP1P0Intersector>::intersectCells(ConnType icellT, const std::vector<ConnType>& icellsS, MyMatrix& res)
55 double quadrangle[12];
56 std::vector<double> targetCellCoords;
58 PlanarIntersector<MyMeshType,MyMatrix>::getRealTargetCoordinates(OTT<ConnType,numPol>::indFC(icellT),targetCellCoords);
59 NormalizedCellType tT=PlanarIntersector<MyMeshType,MyMatrix>::_meshT.getTypeOfElement(OTT<ConnType,numPol>::indFC(icellT));
60 bool isTargetQuad=CellModel::GetCellModel(tT).isQuadratic();
61 typename MyMatrix::value_type& resRow=res[icellT];
62 for(typename std::vector<ConnType>::const_iterator iter=icellsS.begin();iter!=icellsS.end();iter++)
65 ConnType nbNodesS=PlanarIntersector<MyMeshType,MyMatrix>::_connIndexS[iS+1]-PlanarIntersector<MyMeshType,MyMatrix>::_connIndexS[iS];
66 const ConnType *startOfCellNodeConn=PlanarIntersector<MyMeshType,MyMatrix>::_connectS+OTT<ConnType,numPol>::conn2C(PlanarIntersector<MyMeshType,MyMatrix>::_connIndexS[iS]);
67 for(ConnType nodeIdS=0;nodeIdS<nbNodesS;nodeIdS++)
69 ConnType curNodeSInCmode=OTT<ConnType,numPol>::coo2C(startOfCellNodeConn[nodeIdS]);
70 std::copy(PlanarIntersector<MyMeshType,MyMatrix>::_coordsS+curNodeSInCmode*SPACEDIM,
71 PlanarIntersector<MyMeshType,MyMatrix>::_coordsS+curNodeSInCmode*SPACEDIM+SPACEDIM,triangle);
72 for(ConnType subTriS=1;subTriS<=nbNodesS-2;subTriS++)
74 std::copy(PlanarIntersector<MyMeshType,MyMatrix>::_coordsS+OTT<ConnType,numPol>::coo2C(startOfCellNodeConn[(nodeIdS+subTriS)%nbNodesS])*SPACEDIM,
75 PlanarIntersector<MyMeshType,MyMatrix>::_coordsS+OTT<ConnType,numPol>::coo2C(startOfCellNodeConn[(nodeIdS+subTriS)%nbNodesS])*SPACEDIM+SPACEDIM,
77 std::copy(PlanarIntersector<MyMeshType,MyMatrix>::_coordsS+OTT<ConnType,numPol>::coo2C(startOfCellNodeConn[(nodeIdS+subTriS+1)%nbNodesS])*SPACEDIM,
78 PlanarIntersector<MyMeshType,MyMatrix>::_coordsS+OTT<ConnType,numPol>::coo2C(startOfCellNodeConn[(nodeIdS+subTriS+1)%nbNodesS])*SPACEDIM+SPACEDIM,
80 fillDualCellOfTri<SPACEDIM>(triangle,quadrangle);
81 std::vector<double> targetCellCoordsTmp(targetCellCoords);
83 orientation=PlanarIntersector<MyMeshType,MyMatrix>::projectionThis(&targetCellCoordsTmp[0],quadrangle,ToConnType(targetCellCoords.size())/SPACEDIM,4);
84 double surf=orientation*intersectGeometryWithQuadrangle(quadrangle,targetCellCoordsTmp,isTargetQuad);
85 surf=PlanarIntersector<MyMeshType,MyMatrix>::getValueRegardingOption(surf);
88 typename MyMatrix::value_type::const_iterator iterRes=resRow.find(OTT<ConnType,numPol>::indFC(curNodeSInCmode));
89 if(iterRes==resRow.end())
90 resRow.insert(std::make_pair(OTT<ConnType,numPol>::indFC(curNodeSInCmode),surf));
93 double val=(*iterRes).second+surf;
94 resRow.erase(OTT<ConnType,numPol>::indFC(curNodeSInCmode));
95 resRow.insert(std::make_pair(OTT<ConnType,numPol>::indFC(curNodeSInCmode),val));