1 // Copyright (C) 2007-2008 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
18 #ifndef __PLANARINTERSECTORP0P1_TXX__
19 #define __PLANARINTERSECTORP0P1_TXX__
21 #include "PlanarIntersectorP0P1.hxx"
22 #include "InterpolationUtils.hxx"
23 #include "CellModel.hxx"
25 namespace INTERP_KERNEL
27 template<class MyMeshType, class MyMatrix, class ConcreteP0P1Intersector>
28 PlanarIntersectorP0P1<MyMeshType,MyMatrix,ConcreteP0P1Intersector>::PlanarIntersectorP0P1(const MyMeshType& meshT, const MyMeshType& meshS,
29 double dimCaracteristic, double precision, double medianPlane,
30 bool doRotate, int orientation, int printLevel):
31 PlanarIntersector<MyMeshType,MyMatrix>(meshT,meshS,dimCaracteristic,precision,medianPlane,doRotate,orientation,printLevel)
35 template<class MyMeshType, class MyMatrix, class ConcreteP0P1Intersector>
36 int PlanarIntersectorP0P1<MyMeshType,MyMatrix,ConcreteP0P1Intersector>::getNumberOfRowsOfResMatrix() const
38 return PlanarIntersector<MyMeshType,MyMatrix>::_meshT.getNumberOfNodes();
41 template<class MyMeshType, class MyMatrix, class ConcreteP0P1Intersector>
42 int PlanarIntersectorP0P1<MyMeshType,MyMatrix,ConcreteP0P1Intersector>::getNumberOfColsOfResMatrix() const
44 return PlanarIntersector<MyMeshType,MyMatrix>::_meshS.getNumberOfElements();
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 ConcreteP0P1Intersector>
51 void PlanarIntersectorP0P1<MyMeshType,MyMatrix,ConcreteP0P1Intersector>::intersectCells(ConnType icellT, const std::vector<ConnType>& icellsS, MyMatrix& res)
53 int nbNodesT=PlanarIntersector<MyMeshType,MyMatrix>::_connIndexT[icellT+1]-PlanarIntersector<MyMeshType,MyMatrix>::_connIndexT[icellT];
55 double quadrangle[12];
56 std::vector<double> sourceCellCoords;
58 const ConnType *startOfCellNodeConn=PlanarIntersector<MyMeshType,MyMatrix>::_connectT+OTT<ConnType,numPol>::conn2C(PlanarIntersector<MyMeshType,MyMatrix>::_connIndexT[icellT]);
59 for(int nodeIdT=0;nodeIdT<nbNodesT;nodeIdT++)
61 ConnType curNodeTInCmode=OTT<ConnType,numPol>::coo2C(startOfCellNodeConn[nodeIdT]);
62 std::copy(PlanarIntersector<MyMeshType,MyMatrix>::_coordsT+curNodeTInCmode*SPACEDIM,
63 PlanarIntersector<MyMeshType,MyMatrix>::_coordsT+curNodeTInCmode*SPACEDIM+SPACEDIM,triangle);
64 typename MyMatrix::value_type& resRow=res[curNodeTInCmode];
65 for(typename std::vector<ConnType>::const_iterator iter=icellsS.begin();iter!=icellsS.end();iter++)
68 PlanarIntersector<MyMeshType,MyMatrix>::getRealSourceCoordinates(OTT<ConnType,numPol>::indFC(iS),sourceCellCoords);
69 for(int subTriT=1;subTriT<=nbNodesT-2;subTriT++)
71 std::copy(PlanarIntersector<MyMeshType,MyMatrix>::_coordsT+OTT<ConnType,numPol>::coo2C(startOfCellNodeConn[(nodeIdT+subTriT)%nbNodesT])*SPACEDIM,
72 PlanarIntersector<MyMeshType,MyMatrix>::_coordsT+OTT<ConnType,numPol>::coo2C(startOfCellNodeConn[(nodeIdT+subTriT)%nbNodesT])*SPACEDIM+SPACEDIM,
74 std::copy(PlanarIntersector<MyMeshType,MyMatrix>::_coordsT+OTT<ConnType,numPol>::coo2C(startOfCellNodeConn[(nodeIdT+subTriT+1)%nbNodesT])*SPACEDIM,
75 PlanarIntersector<MyMeshType,MyMatrix>::_coordsT+OTT<ConnType,numPol>::coo2C(startOfCellNodeConn[(nodeIdT+subTriT+1)%nbNodesT])*SPACEDIM+SPACEDIM,
77 fillDualCellOfTri<SPACEDIM>(triangle,quadrangle);
78 std::vector<double> sourceCellCoordsTmp(sourceCellCoords);
80 orientation=PlanarIntersector<MyMeshType,MyMatrix>::projectionThis(&sourceCellCoordsTmp[0],quadrangle,sourceCellCoords.size()/SPACEDIM,4);
81 NormalizedCellType tS=PlanarIntersector<MyMeshType,MyMatrix>::_meshS.getTypeOfElement(iS);
82 double surf=orientation*intersectGeometryWithQuadrangle(quadrangle,sourceCellCoordsTmp,CellModel::getCellModel(tS).isQuadratic());
83 //filtering out zero surfaces and badly oriented surfaces
84 // _orientation = -1,0,1
85 // -1 : the intersection is taken into account if target and cells have different orientation
86 // 0 : the intersection is always taken into account
87 // 1 : the intersection is taken into account if target and cells have the same orientation
88 if (( surf > 0.0 && PlanarIntersector<MyMeshType,MyMatrix>::_orientation >=0 ) || ( surf < 0.0 && PlanarIntersector<MyMeshType,MyMatrix>::_orientation <=0 ))
90 typename MyMatrix::value_type::const_iterator iterRes=resRow.find(OTT<ConnType,numPol>::indFC(iS));
91 if(iterRes==resRow.end())
92 resRow.insert(std::make_pair(OTT<ConnType,numPol>::indFC(iS),surf));
95 double val=(*iterRes).second+surf;
96 resRow.erase(OTT<ConnType,numPol>::indFC(iS));
97 resRow.insert(std::make_pair(OTT<ConnType,numPol>::indFC(iS),val));