1 // Copyright (C) 2007-2016 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 __INTEGRALUNIFORMINTERSECTOR_TXX__
21 #define __INTEGRALUNIFORMINTERSECTOR_TXX__
23 #include "IntegralUniformIntersector.hxx"
24 #include "VolSurfUser.txx"
26 namespace INTERP_KERNEL
28 template<class MyMeshType, class MyMatrix>
29 IntegralUniformIntersector<MyMeshType,MyMatrix>::IntegralUniformIntersector(const MyMeshType& mesh, bool isAbs):_mesh(mesh),_from_to(false),_is_abs(isAbs)
33 template<class MyMeshType, class MyMatrix>
34 void IntegralUniformIntersector<MyMeshType,MyMatrix>::putValueIn(ConnType iInCMode, double val1, MyMatrix& res) const
36 static const NumberingPolicy numPol=MyMeshType::My_numPol;
37 double val=performNormalization(val1);
40 typename MyMatrix::value_type& resRow=res[0];
41 typename MyMatrix::value_type::const_iterator iterRes=resRow.find(OTT<ConnType,numPol>::indFC(iInCMode));
42 if(iterRes==resRow.end())
43 resRow.insert(std::make_pair(OTT<ConnType,numPol>::indFC(iInCMode),val));
46 double val2=(*iterRes).second+val;
47 resRow.erase(OTT<ConnType,numPol>::indFC(iInCMode));
48 resRow.insert(std::make_pair(OTT<ConnType,numPol>::indFC(iInCMode),val2));
53 typename MyMatrix::value_type& resRow=res[iInCMode];
54 typename MyMatrix::value_type::const_iterator iterRes=resRow.find(OTT<ConnType,numPol>::indFC(0));
55 if(iterRes==resRow.end())
56 resRow.insert(std::make_pair(OTT<ConnType,numPol>::indFC(0),val));
59 double val2=(*iterRes).second+val;
60 resRow.erase(OTT<ConnType,numPol>::indFC(0));
61 resRow.insert(std::make_pair(OTT<ConnType,numPol>::indFC(0),val2));
66 template<class MyMeshType, class MyMatrix>
67 IntegralUniformIntersectorP0<MyMeshType,MyMatrix>::IntegralUniformIntersectorP0(const MyMeshType& mesh, bool isAbs):IntegralUniformIntersector<MyMeshType,MyMatrix>(mesh,isAbs)
71 template<class MyMeshType, class MyMatrix>
72 int IntegralUniformIntersectorP0<MyMeshType,MyMatrix>::getNumberOfRowsOfResMatrix() const
74 if(IntegralUniformIntersector<MyMeshType,MyMatrix>::_from_to)
77 return IntegralUniformIntersector<MyMeshType,MyMatrix>::_mesh.getNumberOfElements();
80 template<class MyMeshType, class MyMatrix>
81 int IntegralUniformIntersectorP0<MyMeshType,MyMatrix>::getNumberOfColsOfResMatrix() const
83 if(IntegralUniformIntersector<MyMeshType,MyMatrix>::_from_to)
84 return IntegralUniformIntersector<MyMeshType,MyMatrix>::_mesh.getNumberOfElements();
89 template<class MyMeshType, class MyMatrix>
90 void IntegralUniformIntersectorP0<MyMeshType,MyMatrix>::intersectCells(ConnType targetCell, const std::vector<ConnType>& srcCells, MyMatrix& res)
92 static const NumberingPolicy numPol=MyMeshType::My_numPol;
93 res.resize(getNumberOfRowsOfResMatrix());
94 unsigned long nbelem=IntegralUniformIntersector<MyMeshType,MyMatrix>::_mesh.getNumberOfElements();
95 const ConnType *connIndx=IntegralUniformIntersector<MyMeshType,MyMatrix>::_mesh.getConnectivityIndexPtr();
96 const ConnType *conn=IntegralUniformIntersector<MyMeshType,MyMatrix>::_mesh.getConnectivityPtr();
97 const double *coords=IntegralUniformIntersector<MyMeshType,MyMatrix>::_mesh.getCoordinatesPtr();
98 for(unsigned long i=0;i<nbelem;i++)
100 INTERP_KERNEL::NormalizedCellType t=IntegralUniformIntersector<MyMeshType,MyMatrix>::_mesh.getTypeOfElement(OTT<ConnType,numPol>::indFC(i));
101 double val=computeVolSurfOfCell<ConnType,numPol,MyMeshType::MY_SPACEDIM>(t,conn+OTT<ConnType,numPol>::ind2C(connIndx[i]),connIndx[i+1]-connIndx[i],coords);
102 IntegralUniformIntersector<MyMeshType,MyMatrix>::putValueIn(i,val,res);
106 template<class MyMeshType, class MyMatrix>
107 IntegralUniformIntersectorP1<MyMeshType,MyMatrix>::IntegralUniformIntersectorP1(const MyMeshType& mesh, bool isAbs):IntegralUniformIntersector<MyMeshType,MyMatrix>(mesh,isAbs)
111 template<class MyMeshType, class MyMatrix>
112 int IntegralUniformIntersectorP1<MyMeshType,MyMatrix>::getNumberOfRowsOfResMatrix() const
114 if(IntegralUniformIntersector<MyMeshType,MyMatrix>::_from_to)
117 return IntegralUniformIntersector<MyMeshType,MyMatrix>::_mesh.getNumberOfNodes();
120 template<class MyMeshType, class MyMatrix>
121 int IntegralUniformIntersectorP1<MyMeshType,MyMatrix>::getNumberOfColsOfResMatrix() const
123 if(IntegralUniformIntersector<MyMeshType,MyMatrix>::_from_to)
124 return IntegralUniformIntersector<MyMeshType,MyMatrix>::_mesh.getNumberOfNodes();
129 template<class MyMeshType, class MyMatrix>
130 void IntegralUniformIntersectorP1<MyMeshType,MyMatrix>::intersectCells(ConnType targetCell, const std::vector<ConnType>& srcCells, MyMatrix& res)
132 static const NumberingPolicy numPol=MyMeshType::My_numPol;
133 res.resize(getNumberOfRowsOfResMatrix());
134 unsigned long nbelem=IntegralUniformIntersector<MyMeshType,MyMatrix>::_mesh.getNumberOfElements();
135 const ConnType *connIndx=IntegralUniformIntersector<MyMeshType,MyMatrix>::_mesh.getConnectivityIndexPtr();
136 const ConnType *conn=IntegralUniformIntersector<MyMeshType,MyMatrix>::_mesh.getConnectivityPtr();
137 const double *coords=IntegralUniformIntersector<MyMeshType,MyMatrix>::_mesh.getCoordinatesPtr();
138 for(unsigned long i=0;i<nbelem;i++)
140 INTERP_KERNEL::NormalizedCellType t=IntegralUniformIntersector<MyMeshType,MyMatrix>::_mesh.getTypeOfElement(OTT<ConnType,numPol>::indFC(i));
141 int lgth=connIndx[i+1]-connIndx[i];
142 const ConnType *locConn=conn+OTT<ConnType,numPol>::ind2C(connIndx[i]);
143 double val=computeVolSurfOfCell<ConnType,numPol,MyMeshType::MY_SPACEDIM>(t,locConn,lgth,coords);
146 else if(t==NORM_TETRA4)
149 throw INTERP_KERNEL::Exception("Invalid cell type detected : must be TRI3 or TETRA4 ! ");
150 for(int j=0;j<lgth;j++)
151 IntegralUniformIntersector<MyMeshType,MyMatrix>::putValueIn(OTT<ConnType,numPol>::coo2C(locConn[j]),val,res);