From: eap Date: Tue, 29 Sep 2009 14:39:51 +0000 (+0000) Subject: 0020441: [CEA 349] P1P1 barycentric interpolators X-Git-Tag: V5_1_main_FINAL~333 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1438abc36cd62718b3e4d8fd65de548735921e2c;p=tools%2Fmedcoupling.git 0020441: [CEA 349] P1P1 barycentric interpolators +Intersector3DP1P1.hxx \ +Intersector3DP1P1.txx \ +PolyhedronIntersectorP1P1.hxx \ +PolyhedronIntersectorP1P1.txx \ --- diff --git a/src/INTERP_KERNEL/Intersector3DP1P1.hxx b/src/INTERP_KERNEL/Intersector3DP1P1.hxx new file mode 100644 index 000000000..2da83f373 --- /dev/null +++ b/src/INTERP_KERNEL/Intersector3DP1P1.hxx @@ -0,0 +1,36 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#ifndef __Intersector3DP1P1_HXX__ +#define __Intersector3DP1P1_HXX__ + +#include "Intersector3D.hxx" + +namespace INTERP_KERNEL +{ + template + class Intersector3DP1P1 : public Intersector3D + { + public: + Intersector3DP1P1(const MyMeshType& targetMesh, const MyMeshType& srcMesh); + int getNumberOfRowsOfResMatrix() const; + int getNumberOfColsOfResMatrix() const; + }; +} + +#endif diff --git a/src/INTERP_KERNEL/Intersector3DP1P1.txx b/src/INTERP_KERNEL/Intersector3DP1P1.txx new file mode 100644 index 000000000..90f75b472 --- /dev/null +++ b/src/INTERP_KERNEL/Intersector3DP1P1.txx @@ -0,0 +1,45 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#ifndef __Intersector3DP1P1_TXX__ +#define __Intersector3DP1P1_TXX__ + +#include "Intersector3DP1P1.hxx" +#include "Intersector3D.txx" + +namespace INTERP_KERNEL +{ + template + Intersector3DP1P1::Intersector3DP1P1(const MyMeshType& targetMesh, const MyMeshType& srcMesh):Intersector3D(targetMesh,srcMesh) + { + } + + template + int Intersector3DP1P1::getNumberOfRowsOfResMatrix() const + { + return Intersector3D::_target_mesh.getNumberOfNodes(); + } + + template + int Intersector3DP1P1::getNumberOfColsOfResMatrix() const + { + return Intersector3D::_src_mesh.getNumberOfNodes(); + } +} + +#endif diff --git a/src/INTERP_KERNEL/Makefile.am b/src/INTERP_KERNEL/Makefile.am index 1492b0730..86b0880f6 100644 --- a/src/INTERP_KERNEL/Makefile.am +++ b/src/INTERP_KERNEL/Makefile.am @@ -62,6 +62,8 @@ Intersector3DP1P0.hxx \ Intersector3DP1P0.txx \ Intersector3DP1P0Bary.hxx \ Intersector3DP1P0Bary.txx \ +Intersector3DP1P1.hxx \ +Intersector3DP1P1.txx \ Log.hxx \ MeshElement.hxx \ MeshElement.txx \ @@ -90,6 +92,8 @@ PolyhedronIntersectorP1P0.hxx \ PolyhedronIntersectorP1P0.txx \ PolyhedronIntersectorP1P0Bary.hxx \ PolyhedronIntersectorP1P0Bary.txx \ +PolyhedronIntersectorP1P1.hxx \ +PolyhedronIntersectorP1P1.txx \ RegionNode.hxx \ SplitterTetra.hxx \ SplitterTetra.txx \ @@ -107,10 +111,6 @@ VTKNormalizedUnstructuredMesh.hxx \ VTKNormalizedUnstructuredMesh.txx \ VectorUtils.hxx -#PolyhedronIntersectorP1P1.hxx -#PolyhedronIntersectorP1P1.txx -#Intersector3DP1P1.hxx -#Intersector3DP1P1.txx EXTRA_DIST += \ InterpKernelUtilities.hxx \ diff --git a/src/INTERP_KERNEL/PolyhedronIntersectorP1P1.hxx b/src/INTERP_KERNEL/PolyhedronIntersectorP1P1.hxx new file mode 100644 index 000000000..c5ed826b3 --- /dev/null +++ b/src/INTERP_KERNEL/PolyhedronIntersectorP1P1.hxx @@ -0,0 +1,54 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#ifndef __PolyhedronIntersectorP1P1_HXX__ +#define __PolyhedronIntersectorP1P1_HXX__ + +#include "Intersector3DP1P1.hxx" +#include "SplitterTetra.hxx" +#include "NormalizedUnstructuredMesh.hxx" + +namespace INTERP_KERNEL +{ + + + /** + * \brief Class responsible for calculating intersection between a hexahedron target element and + * the source elements. + * + */ + template + class PolyhedronIntersectorP1P1 : public Intersector3DP1P1 + { + public: + static const int SPACEDIM=MyMeshType::MY_SPACEDIM; + static const int MESHDIM=MyMeshType::MY_MESHDIM; + typedef typename MyMeshType::MyConnType ConnType; + static const NumberingPolicy numPol=MyMeshType::My_numPol; + public: + + PolyhedronIntersectorP1P1(const MyMeshType& targetMesh, const MyMeshType& srcMesh, SplittingPolicy policy = GENERAL_24); + + ~PolyhedronIntersectorP1P1(); + + void intersectCells(ConnType targetCell, const std::vector& srcCells, MyMatrix& res); + + }; +} + +#endif diff --git a/src/INTERP_KERNEL/PolyhedronIntersectorP1P1.txx b/src/INTERP_KERNEL/PolyhedronIntersectorP1P1.txx new file mode 100644 index 000000000..914885d5f --- /dev/null +++ b/src/INTERP_KERNEL/PolyhedronIntersectorP1P1.txx @@ -0,0 +1,123 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#ifndef __PolyhedronIntersectorP1P1_TXX__ +#define __PolyhedronIntersectorP1P1_TXX__ + +#include "PolyhedronIntersectorP1P1.hxx" +#include "Intersector3DP1P1.txx" +#include "MeshUtils.hxx" + +#include "SplitterTetra.txx" + +namespace INTERP_KERNEL +{ + + /** + * Constructor creating object from target cell global number + * The constructor first calculates the necessary nodes, + * (depending on the splitting policy) and then splits the hexahedron into + * tetrahedra, placing these in the internal vector _tetra. + * + * @param targetMesh mesh containing the target elements + * @param srcMesh mesh containing the source elements + * @param policy splitting policy to be used + * + * WARNING : in _split attribute, sourceMesh and targetMesh are switched in order to fit intersectCells feature. + */ + template + PolyhedronIntersectorP1P1::PolyhedronIntersectorP1P1(const MyMeshType& targetMesh, const MyMeshType& srcMesh, SplittingPolicy policy):Intersector3DP1P1(targetMesh,srcMesh) + { + } + + /** + * Destructor. + * Liberates the SplitterTetra objects and potential sub-node points that have been allocated. + * + */ + template + PolyhedronIntersectorP1P1::~PolyhedronIntersectorP1P1() + { + } + + /** + * Calculates the volume of intersection of an element in the source mesh and the target element + * represented by the object. + * The calculation is performed by calling the corresponding method for + * each SplitterTetra object created by the splitting. + * + * @param targetCell in C mode. + * @param srcCells in C mode. + * + * WARNING : for all methods on _split object source and target are switched ! + */ + template + void PolyhedronIntersectorP1P1::intersectCells(ConnType targetCell, const std::vector& srcCells, MyMatrix& res) + { + // split the targetCell into dual cells + std::pair< int, double[12] > subTetraNodes[24]; // a node of sub tetra and its coordinates + const double* nodes[4]; int conn[4]; + for(int node = 0; node < 4 ; ++node) + nodes[node]=getCoordsOfNode2(node, OTT::indFC(targetCell), + Intersector3D::_target_mesh,conn[node]); + SplitterTetra tgtTetra(Intersector3D::_src_mesh, nodes, conn); + for (int i=0; i<24; i++) + tgtTetra.splitMySelfForDual(subTetraNodes[i].second,i,subTetraNodes[i].first); + + // intersect each source tetrahedron with each of target dual cells + SplitterTetra* subTetrasS[24]; + for(typename std::vector::const_iterator iterCellS=srcCells.begin();iterCellS!=srcCells.end();iterCellS++) + { + // split a source cell into dual cells + for(int node = 0; node < 4 ; ++node) + nodes[node]=getCoordsOfNode2(node, OTT::indFC(*iterCellS), + Intersector3D::_src_mesh,conn[node]); + + SplitterTetra srcTetra(Intersector3D::_target_mesh, nodes, conn); + srcTetra.splitIntoDualCells(subTetrasS); + + // intersect each target subTetra with each source one + for(int i=0;i<24;i++) + { + SplitterTetra *tmp=subTetrasS[i]; + ConnType sourceNode=OTT::indFC(tmp->getId(0)); + for(int j=0;j<24;j++) + { + const double* tetraNodes12 = subTetraNodes[j].second; + const double* tetraNodesT[4]={ tetraNodes12, tetraNodes12+3, tetraNodes12+6, tetraNodes12+9 }; + double volume = tmp->intersectTetra( tetraNodesT ); + if(volume!=0.) + { + ConnType tgtNode=OTT::indFC( subTetraNodes[j].first ); + typename MyMatrix::value_type& resRow = res[tgtNode]; + typename MyMatrix::value_type::const_iterator iterRes=resRow.find( sourceNode ); + if(iterRes!=resRow.end()) + { + volume += (*iterRes).second; + resRow.erase(sourceNode); + } + resRow.insert(std::make_pair(sourceNode,volume)); + } + } + delete tmp; + } + } + } +} + +#endif