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 __PlanarIntersectorP1P0Bary_TXX__
20 #define __PlanarIntersectorP1P0Bary_TXX__
22 #include "PlanarIntersectorP1P0Bary.hxx"
23 #include "InterpolationUtils.hxx"
25 #define PLAN_INTERSECTOR PlanarIntersectorP1P0Bary<MyMeshType,MyMatrix,ConcreteP1P0Intersector>
26 #define PLAN_INTER_TEMPLATE template<class MyMeshType, class MyMatrix, class ConcreteP1P0Intersector>
28 namespace INTERP_KERNEL
31 PLAN_INTERSECTOR::PlanarIntersectorP1P0Bary(const MyMeshType& meshT, const MyMeshType& meshS,
32 double dimCaracteristic, double precision,
33 double md3DSurf, double medianPlane,
34 bool doRotate, int orientation, int printLevel):
35 PlanarIntersector<MyMeshType,MyMatrix>(meshT,meshS,dimCaracteristic,precision,md3DSurf,
36 medianPlane,doRotate,orientation,printLevel)
39 // "Limitation. For the P1P0 barycentric improvement only triangle source cells in 2D and
40 // tetrahedrons in 3D will be supported by interpolators. If a non
41 // triangle/tetrahedron source cell is detected an INTERP_KERNEL::Exception should be thrown."
43 // Check types of source elements here rather than in intersectCells() since a wrong type can be
44 // found late after a long time of calculation.
46 const unsigned long numSrcElems = meshS.getNumberOfElements();
47 for(unsigned long i = 0 ; i < numSrcElems ; ++i)
48 if ( meshS.getTypeOfElement( OTT<ConnType,numPol>::indFC( i )) != NORM_TRI3 )
49 throw INTERP_KERNEL::Exception("P1P0 barycentric algorithm works only with triangular source meshes");
53 int PLAN_INTERSECTOR::getNumberOfRowsOfResMatrix() const
55 return PlanarIntersector<MyMeshType,MyMatrix>::_meshT.getNumberOfElements();
59 int PLAN_INTERSECTOR::getNumberOfColsOfResMatrix() const
61 return PlanarIntersector<MyMeshType,MyMatrix>::_meshS.getNumberOfNodes();
65 * This method computes a value per each node of each source triangle for target.
68 void PLAN_INTERSECTOR::intersectCells(ConnType icellT,
69 const std::vector<ConnType>& icellsS,
73 std::vector<double> srcTriaCoords, tgtCellCoords, tgtCellCoordsTmp, nodeCeffs;
76 PlanarIntersector<MyMeshType,MyMatrix>::getRealTargetCoordinates(OTT<ConnType,numPol>::indFC(icellT),tgtCellCoords);
77 std::vector<double> * tgtCoords = & tgtCellCoords;
78 int tgtNbNodes = tgtCellCoords.size()/SPACEDIM;
79 NormalizedCellType tT=PlanarIntersector<MyMeshType,MyMatrix>::_meshT.getTypeOfElement(OTT<ConnType,numPol>::indFC(icellT));
80 bool isTargetQuad=CellModel::GetCellModel(tT).isQuadratic();
82 typename MyMatrix::value_type& resRow=res[icellT];
84 // treat each source triangle
85 for(typename std::vector<ConnType>::const_iterator iter=icellsS.begin();iter!=icellsS.end();iter++)
88 PlanarIntersector<MyMeshType,MyMatrix>::getRealSourceCoordinates(OTT<ConnType,numPol>::indFC(iS),srcTriaCoords);
89 const ConnType *startOfCellNodeConn=PlanarIntersector<MyMeshType,MyMatrix>::_connectS+OTT<ConnType,numPol>::conn2C(PlanarIntersector<MyMeshType,MyMatrix>::_connIndexS[iS]);
92 tgtCellCoordsTmp = tgtCellCoords;
93 tgtCoords = & tgtCellCoordsTmp;
94 orientation=PlanarIntersector<MyMeshType,MyMatrix>::projectionThis(&tgtCellCoordsTmp[0], &srcTriaCoords[0],
97 //double surf=orientation*intersectGeometryWithQuadrangle(quadrangle,targetCellCoordsTmp,isTargetQuad);
98 double surf=orientation*intersectGeoBary( *tgtCoords, isTargetQuad, &srcTriaCoords[0], nodeCeffs );
99 surf=PlanarIntersector<MyMeshType,MyMatrix>::getValueRegardingOption(surf);
102 for(int nodeIdS=0;nodeIdS<3;nodeIdS++)
104 ConnType curNodeS=startOfCellNodeConn[nodeIdS];
105 typename MyMatrix::value_type::const_iterator iterRes=resRow.find(curNodeS);
106 if(iterRes!=resRow.end())
108 nodeCeffs[nodeIdS] += iterRes->second;
109 resRow.erase( curNodeS );
111 resRow.insert(std::make_pair(curNodeS,nodeCeffs[nodeIdS]));