]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Addition of barycentric P1P1 intersector in 3D.
authorageay <ageay>
Mon, 19 Aug 2013 10:23:07 +0000 (10:23 +0000)
committerageay <ageay>
Mon, 19 Aug 2013 10:23:07 +0000 (10:23 +0000)
src/INTERP_KERNEL/Barycentric3DIntersectorP1P1.hxx [new file with mode: 0644]
src/INTERP_KERNEL/Barycentric3DIntersectorP1P1.txx [new file with mode: 0644]
src/INTERP_KERNEL/Interpolation3D.txx

diff --git a/src/INTERP_KERNEL/Barycentric3DIntersectorP1P1.hxx b/src/INTERP_KERNEL/Barycentric3DIntersectorP1P1.hxx
new file mode 100644 (file)
index 0000000..080e105
--- /dev/null
@@ -0,0 +1,46 @@
+// Copyright (C) 2007-2013  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
+//
+// Author : Anthony Geay (CEA/DEN)
+
+#ifndef __BARYCENTRIC3DINTERSECTORP1P1_HXX__
+#define __BARYCENTRIC3DINTERSECTORP1P1_HXX__
+
+#include "Intersector3DP1P1.hxx"
+#include "NormalizedUnstructuredMesh.hxx"
+
+namespace INTERP_KERNEL
+{
+  template<class MyMeshType, class MyMatrix>
+  class Barycentric3DIntersectorP1P1 : public Intersector3DP1P1<MyMeshType,MyMatrix>
+  { 
+  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:
+    Barycentric3DIntersectorP1P1(const MyMeshType& targetMesh, const MyMeshType& srcMesh, double precision);
+    ~Barycentric3DIntersectorP1P1();
+    void intersectCells(ConnType targetCell, const std::vector<ConnType>& srcCells, MyMatrix& res);
+  protected:
+    double _precision;
+  };
+}
+
+#endif
diff --git a/src/INTERP_KERNEL/Barycentric3DIntersectorP1P1.txx b/src/INTERP_KERNEL/Barycentric3DIntersectorP1P1.txx
new file mode 100644 (file)
index 0000000..15b5ca0
--- /dev/null
@@ -0,0 +1,98 @@
+// Copyright (C) 2007-2013  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
+//
+// Author : Anthony Geay (CEA/DEN)
+
+#ifndef __BARYCENTRIC3DINTERSECTORP1P1_TXX__
+#define __BARYCENTRIC3DINTERSECTORP1P1_TXX__
+
+#include "Barycentric3DIntersectorP1P1.hxx"
+#include "Intersector3DP1P1.txx"
+#include "MeshUtils.hxx"
+
+namespace INTERP_KERNEL
+{
+
+  /**
+   * Constructor creating object from target cell global number 
+   * 
+   * @param targetMesh  mesh containing the target elements
+   * @param srcMesh     mesh containing the source elements
+   * @param policy      splitting policy to be used
+   */
+  template<class MyMeshType, class MyMatrix>
+  Barycentric3DIntersectorP1P1<MyMeshType,MyMatrix>::Barycentric3DIntersectorP1P1(const MyMeshType& targetMesh, const MyMeshType& srcMesh, double precision):
+    Intersector3DP1P1<MyMeshType,MyMatrix>(targetMesh,srcMesh),_precision(precision)
+  {
+  }
+
+  template<class MyMeshType, class MyMatrix>
+  Barycentric3DIntersectorP1P1<MyMeshType,MyMatrix>::~Barycentric3DIntersectorP1P1()
+  {
+  }
+
+  /**
+   * @param targetCell in C mode.
+   * @param srcCells in C mode.
+   */
+  template<class MyMeshType, class MyMatrix>
+  void Barycentric3DIntersectorP1P1<MyMeshType,MyMatrix>::intersectCells(ConnType targetCell, const std::vector<ConnType>& srcCells, MyMatrix& res)
+  {
+    std::vector<double> CoordsT;
+    const ConnType *startOfCellNodeConnT=Intersector3DP1P1<MyMeshType,MyMatrix>::getStartConnOfTargetCell(targetCell);
+    Intersector3DP1P1<MyMeshType,MyMatrix>::getRealTargetCoordinates(OTT<ConnType,numPol>::indFC(targetCell),CoordsT);
+    int nbOfNodesT=CoordsT.size()/SPACEDIM;
+    const double *coordsS=Intersector3DP1P1<MyMeshType,MyMatrix>::_src_mesh.getCoordinatesPtr();
+    for(int nodeIdT=0;nodeIdT<nbOfNodesT;nodeIdT++)
+      {
+        typename MyMatrix::value_type& resRow=res[OTT<ConnType,numPol>::ind2C(startOfCellNodeConnT[nodeIdT])];
+        if(!resRow.empty())
+          continue;
+        for(typename std::vector<ConnType>::const_iterator iterCellS=srcCells.begin();iterCellS!=srcCells.end();iterCellS++)
+          {
+            NormalizedCellType tS=Intersector3DP1P1<MyMeshType,MyMatrix>::_src_mesh.getTypeOfElement(OTT<ConnType,numPol>::indFC(*iterCellS));
+            if(tS!=NORM_TETRA4)
+              throw INTERP_KERNEL::Exception("Invalid source cell detected for meshdim==3. Only TETRA4 supported !");
+            const CellModel& cmTypeS=CellModel::GetCellModel(tS);
+            //
+            std::vector<ConnType> connOfCurCellS;
+            Intersector3DP1P1<MyMeshType,MyMatrix>::getConnOfSourceCell(OTT<ConnType,numPol>::indFC(*iterCellS),connOfCurCellS);
+            if( PointLocatorAlgos<MyMeshType>::isElementContainsPointAlg3D(&CoordsT[nodeIdT*SPACEDIM],&connOfCurCellS[0],connOfCurCellS.size(),coordsS,cmTypeS,_precision) )
+              {
+                double resLoc[4];
+                std::vector<double> localCoordsS;
+                Intersector3DP1P1<MyMeshType,MyMatrix>::getRealSourceCoordinates(OTT<ConnType,numPol>::indFC(*iterCellS),localCoordsS);
+                std::vector<const double*> eap(4);
+                eap[0]=&localCoordsS[0]; eap[1]=&localCoordsS[3]; eap[2]=&localCoordsS[6]; eap[3]=&localCoordsS[9];
+                barycentric_coords(eap,&CoordsT[nodeIdT*SPACEDIM],resLoc);
+                const ConnType *startOfCellNodeConnS=Intersector3DP1P1<MyMeshType,MyMatrix>::getStartConnOfSourceCell(*iterCellS);
+                for(int nodeIdS=0;nodeIdS<4;nodeIdS++)
+                  {
+                    if(fabs(resLoc[nodeIdS])>_precision)
+                      {
+                        ConnType curNodeSInCmode=OTT<ConnType,numPol>::coo2C(startOfCellNodeConnS[nodeIdS]);
+                        resRow.insert(std::make_pair(OTT<ConnType,numPol>::indFC(curNodeSInCmode),resLoc[nodeIdS]));
+                      }
+                  }
+              }
+          }
+      }
+  }
+}
+
+#endif
index 9edf10b4579e2fcef6b01ec712733de4de18b803..851cb7902212fda3c8ef660c752f0dc3bd9b708d 100644 (file)
@@ -33,6 +33,7 @@
 #include "PointLocator3DIntersectorP1P0.txx"
 #include "PolyhedronIntersectorP1P1.txx"
 #include "PointLocator3DIntersectorP1P1.txx"
+#include "Barycentric3DIntersectorP1P1.txx"
 #include "Log.hxx"
 /// If defined, use recursion to traverse the binary search tree, else use the BBTree class
 //#define USE_RECURSIVE_BBOX_FILTER
@@ -149,6 +150,9 @@ namespace INTERP_KERNEL
           case PointLocator:
             intersector=new PointLocator3DIntersectorP1P1<MyMeshType,MatrixType>(targetMesh, srcMesh, getPrecision());
             break;
+          case Barycentric:
+            intersector=new Barycentric3DIntersectorP1P1<MyMeshType,MatrixType>(targetMesh, srcMesh, getPrecision());
+            break;
           default:
             throw INTERP_KERNEL::Exception("Invalid 3D intersection type for P1P1 interp specified : must be Triangle or PointLocator.");
           }