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 __INTEGRALUNIFORMINTERSECTOR_TXX__
20 #define __INTEGRALUNIFORMINTERSECTOR_TXX__
22 #include "IntegralUniformIntersector.hxx"
23 #include "VolSurfUser.txx"
25 namespace INTERP_KERNEL
27 template<class MyMeshType, class MyMatrix>
28 IntegralUniformIntersector<MyMeshType,MyMatrix>::IntegralUniformIntersector(const MyMeshType& mesh, bool isAbs):_mesh(mesh),_from_to(false),_is_abs(isAbs)
32 template<class MyMeshType, class MyMatrix>
33 void IntegralUniformIntersector<MyMeshType,MyMatrix>::putValueIn(ConnType iInCMode, double val1, MyMatrix& res) const
35 static const NumberingPolicy numPol=MyMeshType::My_numPol;
36 double val=performNormalization(val1);
39 typename MyMatrix::value_type& resRow=res[0];
40 typename MyMatrix::value_type::const_iterator iterRes=resRow.find(OTT<ConnType,numPol>::indFC(iInCMode));
41 if(iterRes==resRow.end())
42 resRow.insert(std::make_pair(OTT<ConnType,numPol>::indFC(iInCMode),val));
45 double val2=(*iterRes).second+val;
46 resRow.erase(OTT<ConnType,numPol>::indFC(iInCMode));
47 resRow.insert(std::make_pair(OTT<ConnType,numPol>::indFC(iInCMode),val2));
52 typename MyMatrix::value_type& resRow=res[iInCMode];
53 typename MyMatrix::value_type::const_iterator iterRes=resRow.find(OTT<ConnType,numPol>::indFC(0));
54 if(iterRes==resRow.end())
55 resRow.insert(std::make_pair(OTT<ConnType,numPol>::indFC(0),val));
58 double val2=(*iterRes).second+val;
59 resRow.erase(OTT<ConnType,numPol>::indFC(0));
60 resRow.insert(std::make_pair(OTT<ConnType,numPol>::indFC(0),val2));
65 template<class MyMeshType, class MyMatrix>
66 IntegralUniformIntersectorP0<MyMeshType,MyMatrix>::IntegralUniformIntersectorP0(const MyMeshType& mesh, bool isAbs):IntegralUniformIntersector<MyMeshType,MyMatrix>(mesh,isAbs)
70 template<class MyMeshType, class MyMatrix>
71 int IntegralUniformIntersectorP0<MyMeshType,MyMatrix>::getNumberOfRowsOfResMatrix() const
73 if(IntegralUniformIntersector<MyMeshType,MyMatrix>::_from_to)
76 return IntegralUniformIntersector<MyMeshType,MyMatrix>::_mesh.getNumberOfElements();
79 template<class MyMeshType, class MyMatrix>
80 int IntegralUniformIntersectorP0<MyMeshType,MyMatrix>::getNumberOfColsOfResMatrix() const
82 if(IntegralUniformIntersector<MyMeshType,MyMatrix>::_from_to)
83 return IntegralUniformIntersector<MyMeshType,MyMatrix>::_mesh.getNumberOfElements();
88 template<class MyMeshType, class MyMatrix>
89 void IntegralUniformIntersectorP0<MyMeshType,MyMatrix>::intersectCells(ConnType targetCell, const std::vector<ConnType>& srcCells, MyMatrix& res)
91 static const NumberingPolicy numPol=MyMeshType::My_numPol;
92 res.resize(getNumberOfRowsOfResMatrix());
93 unsigned long nbelem=IntegralUniformIntersector<MyMeshType,MyMatrix>::_mesh.getNumberOfElements();
94 const ConnType *connIndx=IntegralUniformIntersector<MyMeshType,MyMatrix>::_mesh.getConnectivityIndexPtr();
95 const ConnType *conn=IntegralUniformIntersector<MyMeshType,MyMatrix>::_mesh.getConnectivityPtr();
96 const double *coords=IntegralUniformIntersector<MyMeshType,MyMatrix>::_mesh.getCoordinatesPtr();
97 for(unsigned long i=0;i<nbelem;i++)
99 INTERP_KERNEL::NormalizedCellType t=IntegralUniformIntersector<MyMeshType,MyMatrix>::_mesh.getTypeOfElement(OTT<ConnType,numPol>::indFC(i));
100 double val=computeVolSurfOfCell<ConnType,numPol,MyMeshType::MY_SPACEDIM>(t,conn+OTT<ConnType,numPol>::ind2C(connIndx[i]),connIndx[i+1]-connIndx[i],coords);
101 IntegralUniformIntersector<MyMeshType,MyMatrix>::putValueIn(i,val,res);
105 template<class MyMeshType, class MyMatrix>
106 IntegralUniformIntersectorP1<MyMeshType,MyMatrix>::IntegralUniformIntersectorP1(const MyMeshType& mesh, bool isAbs):IntegralUniformIntersector<MyMeshType,MyMatrix>(mesh,isAbs)
110 template<class MyMeshType, class MyMatrix>
111 int IntegralUniformIntersectorP1<MyMeshType,MyMatrix>::getNumberOfRowsOfResMatrix() const
113 if(IntegralUniformIntersector<MyMeshType,MyMatrix>::_from_to)
116 return IntegralUniformIntersector<MyMeshType,MyMatrix>::_mesh.getNumberOfNodes();
119 template<class MyMeshType, class MyMatrix>
120 int IntegralUniformIntersectorP1<MyMeshType,MyMatrix>::getNumberOfColsOfResMatrix() const
122 if(IntegralUniformIntersector<MyMeshType,MyMatrix>::_from_to)
123 return IntegralUniformIntersector<MyMeshType,MyMatrix>::_mesh.getNumberOfNodes();
128 template<class MyMeshType, class MyMatrix>
129 void IntegralUniformIntersectorP1<MyMeshType,MyMatrix>::intersectCells(ConnType targetCell, const std::vector<ConnType>& srcCells, MyMatrix& res)
131 static const NumberingPolicy numPol=MyMeshType::My_numPol;
132 res.resize(getNumberOfRowsOfResMatrix());
133 unsigned long nbelem=IntegralUniformIntersector<MyMeshType,MyMatrix>::_mesh.getNumberOfElements();
134 const ConnType *connIndx=IntegralUniformIntersector<MyMeshType,MyMatrix>::_mesh.getConnectivityIndexPtr();
135 const ConnType *conn=IntegralUniformIntersector<MyMeshType,MyMatrix>::_mesh.getConnectivityPtr();
136 const double *coords=IntegralUniformIntersector<MyMeshType,MyMatrix>::_mesh.getCoordinatesPtr();
137 for(unsigned long i=0;i<nbelem;i++)
139 INTERP_KERNEL::NormalizedCellType t=IntegralUniformIntersector<MyMeshType,MyMatrix>::_mesh.getTypeOfElement(OTT<ConnType,numPol>::indFC(i));
140 int lgth=connIndx[i+1]-connIndx[i];
141 const ConnType *locConn=conn+OTT<ConnType,numPol>::ind2C(connIndx[i]);
142 double val=computeVolSurfOfCell<ConnType,numPol,MyMeshType::MY_SPACEDIM>(t,locConn,lgth,coords);
145 else if(t==NORM_TETRA4)
148 throw INTERP_KERNEL::Exception("Invalid cell type detected : must be TRI3 or TETRA4 ! ");
149 for(int j=0;j<lgth;j++)
150 IntegralUniformIntersector<MyMeshType,MyMatrix>::putValueIn(OTT<ConnType,numPol>::coo2C(locConn[j]),val,res);