1 // Copyright (C) 2007-2014 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 __POLYHEDRONINTERSECTORP1P0_TXX__
21 #define __POLYHEDRONINTERSECTORP1P0_TXX__
23 #include "PolyhedronIntersectorP1P0.hxx"
24 #include "Intersector3DP1P0.txx"
25 #include "MeshUtils.hxx"
27 #include "SplitterTetra.txx"
29 namespace INTERP_KERNEL
33 * Constructor creating object from target cell global number
34 * The constructor first calculates the necessary nodes,
35 * (depending on the splitting policy) and then splits the hexahedron into
36 * tetrahedra, placing these in the internal vector _tetra.
38 * @param targetMesh mesh containing the target elements
39 * @param srcMesh mesh containing the source elements
40 * @param policy splitting policy to be used
42 * WARNING : in _split attribute, sourceMesh and targetMesh are switched in order to fit intersectCells feature.
44 template<class MyMeshType, class MyMatrix>
45 PolyhedronIntersectorP1P0<MyMeshType,MyMatrix>::PolyhedronIntersectorP1P0(const MyMeshType& targetMesh, const MyMeshType& srcMesh, SplittingPolicy policy):Intersector3DP1P0<MyMeshType,MyMatrix>(targetMesh,srcMesh),_split(srcMesh,targetMesh,policy)
51 * Liberates the SplitterTetra objects and potential sub-node points that have been allocated.
54 template<class MyMeshType, class MyMatrix>
55 PolyhedronIntersectorP1P0<MyMeshType,MyMatrix>::~PolyhedronIntersectorP1P0()
60 template<class MyMeshType, class MyMatrix>
61 void PolyhedronIntersectorP1P0<MyMeshType,MyMatrix>::releaseArrays()
63 for(typename std::vector< SplitterTetra<MyMeshType>* >::iterator iter = _tetra.begin(); iter != _tetra.end(); ++iter)
65 _split.releaseArrays();
70 * Calculates the volume of intersection of an element in the source mesh and the target element
71 * represented by the object.
72 * The calculation is performed by calling the corresponding method for
73 * each SplitterTetra object created by the splitting.
75 * @param targetCell in C mode.
76 * @param srcCells in C mode.
78 * WARNING : for all methods on _split object source and target are switched !
80 template<class MyMeshType, class MyMatrix>
81 void PolyhedronIntersectorP1P0<MyMeshType,MyMatrix>::intersectCells(ConnType targetCell, const std::vector<ConnType>& srcCells, MyMatrix& res)
83 SplitterTetra<MyMeshType>* subTetras[24];
84 typename MyMatrix::value_type& resRow=res[targetCell];
85 for(typename std::vector<ConnType>::const_iterator iterCellS=srcCells.begin();iterCellS!=srcCells.end();iterCellS++)
88 int nbOfNodesS=Intersector3D<MyMeshType,MyMatrix>::_src_mesh.getNumberOfNodesOfElement(OTT<ConnType,numPol>::indFC(*iterCellS));
89 _split.splitTargetCell(*iterCellS,nbOfNodesS,_tetra);
90 for(typename std::vector<SplitterTetra<MyMeshType>*>::iterator iter = _tetra.begin(); iter != _tetra.end(); ++iter)
92 (*iter)->splitIntoDualCells(subTetras);
95 SplitterTetra<MyMeshType> *tmp=subTetras[i];
96 double volume = tmp->intersectSourceCell(targetCell);
97 ConnType sourceNode=tmp->getId(0);
100 typename MyMatrix::value_type::const_iterator iterRes=resRow.find(OTT<ConnType,numPol>::indFC(sourceNode));
101 if(iterRes==resRow.end())
102 resRow.insert(std::make_pair(OTT<ConnType,numPol>::indFC(sourceNode),volume));
105 double val=(*iterRes).second+volume;
106 resRow.erase(OTT<ConnType,numPol>::indFC(sourceNode));
107 resRow.insert(std::make_pair(OTT<ConnType,numPol>::indFC(sourceNode),val));