1 // Copyright (C) 2007-2012 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.
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 #ifndef __PLANARINTERSECTORP1P0_TXX__
20 #define __PLANARINTERSECTORP1P0_TXX__
22 #include "PlanarIntersectorP1P0.hxx"
23 #include "InterpolationUtils.hxx"
25 namespace INTERP_KERNEL
27 template<class MyMeshType, class MyMatrix, class ConcreteP1P0Intersector>
28 PlanarIntersectorP1P0<MyMeshType,MyMatrix,ConcreteP1P0Intersector>::PlanarIntersectorP1P0(const MyMeshType& meshT, const MyMeshType& meshS,
29 double dimCaracteristic, double precision, double md3DSurf, double medianPlane,
30 bool doRotate, int orientation, int printLevel):
31 PlanarIntersector<MyMeshType,MyMatrix>(meshT,meshS,dimCaracteristic,precision,md3DSurf,medianPlane,doRotate,orientation,printLevel)
35 template<class MyMeshType, class MyMatrix, class ConcreteP1P0Intersector>
36 int PlanarIntersectorP1P0<MyMeshType,MyMatrix,ConcreteP1P0Intersector>::getNumberOfRowsOfResMatrix() const
38 return PlanarIntersector<MyMeshType,MyMatrix>::_meshT.getNumberOfElements();
41 template<class MyMeshType, class MyMatrix, class ConcreteP1P0Intersector>
42 int PlanarIntersectorP1P0<MyMeshType,MyMatrix,ConcreteP1P0Intersector>::getNumberOfColsOfResMatrix() const
44 return PlanarIntersector<MyMeshType,MyMatrix>::_meshS.getNumberOfNodes();
48 * 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).
50 template<class MyMeshType, class MyMatrix, class ConcreteP1P0Intersector>
51 void PlanarIntersectorP1P0<MyMeshType,MyMatrix,ConcreteP1P0Intersector>::intersectCells(ConnType icellT, const std::vector<ConnType>& icellsS, MyMatrix& res)
54 double quadrangle[12];
55 std::vector<double> targetCellCoords;
57 PlanarIntersector<MyMeshType,MyMatrix>::getRealTargetCoordinates(OTT<ConnType,numPol>::indFC(icellT),targetCellCoords);
58 NormalizedCellType tT=PlanarIntersector<MyMeshType,MyMatrix>::_meshT.getTypeOfElement(OTT<ConnType,numPol>::indFC(icellT));
59 bool isTargetQuad=CellModel::GetCellModel(tT).isQuadratic();
60 typename MyMatrix::value_type& resRow=res[icellT];
61 for(typename std::vector<ConnType>::const_iterator iter=icellsS.begin();iter!=icellsS.end();iter++)
64 int nbNodesS=PlanarIntersector<MyMeshType,MyMatrix>::_connIndexS[iS+1]-PlanarIntersector<MyMeshType,MyMatrix>::_connIndexS[iS];
65 const ConnType *startOfCellNodeConn=PlanarIntersector<MyMeshType,MyMatrix>::_connectS+OTT<ConnType,numPol>::conn2C(PlanarIntersector<MyMeshType,MyMatrix>::_connIndexS[iS]);
66 for(int nodeIdS=0;nodeIdS<nbNodesS;nodeIdS++)
68 ConnType curNodeSInCmode=OTT<ConnType,numPol>::coo2C(startOfCellNodeConn[nodeIdS]);
69 std::copy(PlanarIntersector<MyMeshType,MyMatrix>::_coordsS+curNodeSInCmode*SPACEDIM,
70 PlanarIntersector<MyMeshType,MyMatrix>::_coordsS+curNodeSInCmode*SPACEDIM+SPACEDIM,triangle);
71 for(int subTriS=1;subTriS<=nbNodesS-2;subTriS++)
73 std::copy(PlanarIntersector<MyMeshType,MyMatrix>::_coordsS+OTT<ConnType,numPol>::coo2C(startOfCellNodeConn[(nodeIdS+subTriS)%nbNodesS])*SPACEDIM,
74 PlanarIntersector<MyMeshType,MyMatrix>::_coordsS+OTT<ConnType,numPol>::coo2C(startOfCellNodeConn[(nodeIdS+subTriS)%nbNodesS])*SPACEDIM+SPACEDIM,
76 std::copy(PlanarIntersector<MyMeshType,MyMatrix>::_coordsS+OTT<ConnType,numPol>::coo2C(startOfCellNodeConn[(nodeIdS+subTriS+1)%nbNodesS])*SPACEDIM,
77 PlanarIntersector<MyMeshType,MyMatrix>::_coordsS+OTT<ConnType,numPol>::coo2C(startOfCellNodeConn[(nodeIdS+subTriS+1)%nbNodesS])*SPACEDIM+SPACEDIM,
79 fillDualCellOfTri<SPACEDIM>(triangle,quadrangle);
80 std::vector<double> targetCellCoordsTmp(targetCellCoords);
82 orientation=PlanarIntersector<MyMeshType,MyMatrix>::projectionThis(&targetCellCoordsTmp[0],quadrangle,targetCellCoords.size()/SPACEDIM,4);
83 double surf=orientation*intersectGeometryWithQuadrangle(quadrangle,targetCellCoordsTmp,isTargetQuad);
84 surf=PlanarIntersector<MyMeshType,MyMatrix>::getValueRegardingOption(surf);
87 typename MyMatrix::value_type::const_iterator iterRes=resRow.find(OTT<ConnType,numPol>::indFC(curNodeSInCmode));
88 if(iterRes==resRow.end())
89 resRow.insert(std::make_pair(OTT<ConnType,numPol>::indFC(curNodeSInCmode),surf));
92 double val=(*iterRes).second+surf;
93 resRow.erase(OTT<ConnType,numPol>::indFC(curNodeSInCmode));
94 resRow.insert(std::make_pair(OTT<ConnType,numPol>::indFC(curNodeSInCmode),val));