1 // Copyright (C) 2007-2013 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 __POLYHEDRON3D2DINTERSECTORP0P0_TXX__
20 #define __POLYHEDRON3D2DINTERSECTORP0P0_TXX__
22 #include "Polyhedron3D2DIntersectorP0P0.hxx"
23 #include "Intersector3DP0P0.txx"
24 #include "MeshUtils.hxx"
26 #include "SplitterTetra.txx"
28 namespace INTERP_KERNEL
32 * Constructor creating object from target cell global number
33 * The constructor first calculates the necessary nodes,
34 * (depending on the splitting policy) and then splits the hexahedron into
35 * tetrahedra, placing these in the internal vector _tetra.
37 * @param targetMesh mesh containing the target elements
38 * @param srcMesh mesh containing the source elements
39 * @param policy splitting policy to be used
41 template<class MyMeshType, class MyMatrixType>
42 Polyhedron3D2DIntersectorP0P0<MyMeshType,MyMatrixType>::Polyhedron3D2DIntersectorP0P0(const MyMeshType& targetMesh,
43 const MyMeshType& srcMesh,
44 const double dimCaracteristic,
45 const double precision,
46 DuplicateFacesType& intersectFaces,
47 SplittingPolicy policy)
48 : Intersector3DP0P0<MyMeshType,MyMatrixType>(targetMesh,srcMesh),
49 _split(targetMesh,srcMesh,policy),
50 _dim_caracteristic(dimCaracteristic),
51 _precision(precision),
52 _intersect_faces(intersectFaces)
58 * Liberates the SplitterTetra objects and potential sub-node points that have been allocated.
61 template<class MyMeshType, class MyMatrixType>
62 Polyhedron3D2DIntersectorP0P0<MyMeshType,MyMatrixType>::~Polyhedron3D2DIntersectorP0P0()
67 template<class MyMeshType, class MyMatrixType>
68 void Polyhedron3D2DIntersectorP0P0<MyMeshType,MyMatrixType>::releaseArrays()
70 for(typename std::vector< SplitterTetra<MyMeshType>* >::iterator iter = _tetra.begin(); iter != _tetra.end(); ++iter)
72 _split.releaseArrays();
77 * Calculates the volume of intersection of an element in the source mesh and the target element
78 * represented by the object.
79 * The calculation is performed by calling the corresponding method for
80 * each SplitterTetra object created by the splitting.
82 * @param targetCell in C mode.
83 * @param srcCells in C mode.
86 template<class MyMeshType, class MyMatrixType>
87 void Polyhedron3D2DIntersectorP0P0<MyMeshType,MyMatrixType>::intersectCells(ConnType targetCell,
88 const std::vector<ConnType>& srcCells,
91 int nbOfNodesT=Intersector3D<MyMeshType,MyMatrixType>::_target_mesh.getNumberOfNodesOfElement(OTT<ConnType,numPol>::indFC(targetCell));
93 _split.splitTargetCell(targetCell,nbOfNodesT,_tetra);
95 for(typename std::vector<ConnType>::const_iterator iterCellS=srcCells.begin();iterCellS!=srcCells.end();iterCellS++)
98 std::multiset<TriangleFaceKey> listOfTetraFacesTreated;
99 std::set<TriangleFaceKey> listOfTetraFacesColinear;
101 // calculate the coordinates of the nodes
102 typename MyMeshType::MyConnType cellSrc = *iterCellS;
103 int cellSrcIdx = OTT<ConnType,numPol>::indFC(cellSrc);
104 NormalizedCellType normCellType=Intersector3D<MyMeshType,MyMatrixType>::_src_mesh.getTypeOfElement(cellSrcIdx);
105 const CellModel& cellModelCell=CellModel::GetCellModel(normCellType);
106 const MyMeshType& src_mesh = Intersector3D<MyMeshType,MyMatrixType>::_src_mesh;
107 unsigned nbOfNodes4Type=cellModelCell.isDynamic() ? src_mesh.getNumberOfNodesOfElement(cellSrcIdx) : cellModelCell.getNumberOfNodes();
108 int *polyNodes=new int[nbOfNodes4Type];
109 double **polyCoords = new double*[nbOfNodes4Type];
110 for(int i = 0;i<(int)nbOfNodes4Type;++i)
112 // we could store mapping local -> global numbers too, but not sure it is worth it
113 const int globalNodeNum = getGlobalNumberOfNode(i, OTT<ConnType,numPol>::indFC(*iterCellS), src_mesh);
114 polyNodes[i]=globalNodeNum;
115 polyCoords[i] = const_cast<double*>(src_mesh.getCoordinatesPtr()+MyMeshType::MY_SPACEDIM*globalNodeNum);
118 for(typename std::vector<SplitterTetra<MyMeshType>*>::iterator iter = _tetra.begin(); iter != _tetra.end(); ++iter)
119 surface += (*iter)->intersectSourceFace(normCellType,
125 listOfTetraFacesTreated,
126 listOfTetraFacesColinear);
130 matrix[targetCell].insert(std::make_pair(cellSrcIdx, surface));
132 bool isSrcFaceColinearWithFaceOfTetraTargetCell = false;
133 std::set<TriangleFaceKey>::iterator iter;
134 for (iter = listOfTetraFacesColinear.begin(); iter != listOfTetraFacesColinear.end(); ++iter)
136 if (listOfTetraFacesTreated.count(*iter) != 1)
138 isSrcFaceColinearWithFaceOfTetraTargetCell = false;
143 isSrcFaceColinearWithFaceOfTetraTargetCell = true;
147 if (isSrcFaceColinearWithFaceOfTetraTargetCell)
149 DuplicateFacesType::iterator intersectFacesIter = _intersect_faces.find(cellSrcIdx);
150 if (intersectFacesIter != _intersect_faces.end())
152 intersectFacesIter->second.insert(targetCell);
156 std::set<int> targetCellSet;
157 targetCellSet.insert(targetCell);
158 _intersect_faces.insert(std::make_pair(cellSrcIdx, targetCellSet));
169 _split.releaseArrays();