Salome HOME
Implementation of P0P1Bary
authorageay <ageay>
Tue, 12 Nov 2013 15:11:39 +0000 (15:11 +0000)
committerageay <ageay>
Tue, 12 Nov 2013 15:11:39 +0000 (15:11 +0000)
src/INTERP_KERNEL/ConvexIntersector.hxx
src/INTERP_KERNEL/ConvexIntersector.txx
src/INTERP_KERNEL/Geometric2DIntersector.hxx
src/INTERP_KERNEL/Geometric2DIntersector.txx
src/INTERP_KERNEL/PlanarIntersectorP0P1Bary.hxx [new file with mode: 0644]
src/INTERP_KERNEL/PlanarIntersectorP0P1Bary.txx [new file with mode: 0644]

index 3b12cdf8b07a6a85e041c3aafca6067a2c90ae99..dd842b553c47f49f291d07f0fceebe432c37f5f0 100644 (file)
@@ -26,6 +26,7 @@
 #include "PlanarIntersectorP1P0.hxx"
 #include "PlanarIntersectorP1P1.hxx"
 #include "PlanarIntersectorP1P0Bary.hxx"
+#include "PlanarIntersectorP0P1Bary.hxx"
 
 namespace INTERP_KERNEL
 {
index 817677b605483c6b857097eee75fcbcf4813a534..f9ee8d44d9d98afc6b43cd4a882c635f0ddde439 100644 (file)
@@ -26,6 +26,7 @@
 #include "PlanarIntersectorP1P0.txx"
 #include "PlanarIntersectorP1P1.txx"
 #include "PlanarIntersectorP1P0Bary.txx"
+#include "PlanarIntersectorP0P1Bary.txx"
 
 #include "PolygonAlgorithms.txx"
 
index 5a0c9f8ff6031dc2ffa27e312054936b8b9a1431..7c077aeaef75e46622013e1fa5661c234cd646b2 100644 (file)
@@ -26,6 +26,7 @@
 #include "PlanarIntersectorP1P0.hxx"
 #include "PlanarIntersectorP1P1.hxx"
 #include "PlanarIntersectorP1P0Bary.hxx"
+#include "PlanarIntersectorP0P1Bary.hxx"
 
 namespace INTERP_KERNEL
 {
index ba4b238b13da3ee58bd095d70b175ca3bbcdd672..b6bed16a9acb0ac875727125cad44721fbe4a800 100644 (file)
@@ -27,6 +27,7 @@
 #include "PlanarIntersectorP1P0.txx"
 #include "PlanarIntersectorP1P1.txx"
 #include "PlanarIntersectorP1P0Bary.txx"
+#include "PlanarIntersectorP0P1Bary.txx"
 #include "CellModel.hxx"
 
 #include "InterpKernelGeo2DQuadraticPolygon.hxx"
diff --git a/src/INTERP_KERNEL/PlanarIntersectorP0P1Bary.hxx b/src/INTERP_KERNEL/PlanarIntersectorP0P1Bary.hxx
new file mode 100644 (file)
index 0000000..31ee765
--- /dev/null
@@ -0,0 +1,55 @@
+// 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 __PlanarIntersectorP0P1Bary_HXX__
+#define __PlanarIntersectorP0P1Bary_HXX__
+
+#include "PlanarIntersector.hxx"
+
+namespace INTERP_KERNEL
+{
+  template<class MyMeshType, class MyMatrix, class ConcreteP0P1Intersector>
+  class PlanarIntersectorP0P1Bary : public PlanarIntersector<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;
+  protected:
+    PlanarIntersectorP0P1Bary(const MyMeshType& meshT, const MyMeshType& meshS, double dimCaracteristic, double precision, double md3DSurf, double medianPlane, bool doRotate, int orientation, int printLevel);
+  public:
+    void intersectCells(ConnType icellT, const std::vector<ConnType>& icellsS, MyMatrix& res);
+    int getNumberOfRowsOfResMatrix() const;
+    int getNumberOfColsOfResMatrix() const;
+    /*!
+     * Contrary to intersectCells method here icellS and icellT are \b not in \b C mode but in mode of MyMeshType.
+     */
+    double intersectGeoBary(const std::vector<double>&  sourceCell,
+                            bool                        sourceCellQuadratic,
+                            const double *              targetTria,
+                            std::vector<double>&        res)
+    { return asLeaf().intersectGeoBary(sourceCell,sourceCellQuadratic,targetTria,res); }
+  protected:
+    ConcreteP0P1Intersector& asLeaf() { return static_cast<ConcreteP0P1Intersector&>(*this); }
+  };
+}
+
+#endif
diff --git a/src/INTERP_KERNEL/PlanarIntersectorP0P1Bary.txx b/src/INTERP_KERNEL/PlanarIntersectorP0P1Bary.txx
new file mode 100644 (file)
index 0000000..b69294d
--- /dev/null
@@ -0,0 +1,115 @@
+// 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 __PlanarIntersectorP0P1Bary_TXX__
+#define __PlanarIntersectorP0P1Bary_TXX__
+
+#include "PlanarIntersectorP0P1Bary.hxx"
+#include "InterpolationUtils.hxx"
+
+namespace INTERP_KERNEL
+{
+  template<class MyMeshType, class MyMatrix, class ConcreteP0P1Intersector>
+  PlanarIntersectorP0P1Bary<MyMeshType,MyMatrix,ConcreteP0P1Intersector>::PlanarIntersectorP0P1Bary(const MyMeshType& meshT, const MyMeshType& meshS,
+                                                                                                    double dimCaracteristic, double precision,
+                                                                                                    double md3DSurf, double medianPlane,
+                                                                                                    bool doRotate, int orientation, int printLevel):
+    PlanarIntersector<MyMeshType,MyMatrix>(meshT,meshS,dimCaracteristic,precision,md3DSurf,
+                                           medianPlane,doRotate,orientation,printLevel)
+  {
+    // SPEC:
+    // "Limitation. For the P0P1 barycentric improvement only triangle target cells in 2D and
+    // tetrahedrons in 3D will be supported by interpolators. If a non
+    // triangle/tetrahedron source cell is detected an INTERP_KERNEL::Exception should be thrown."
+
+    // Check types of source elements here rather than in intersectCells() since a wrong type can be
+    // found late after a long time of calculation.
+
+    const unsigned long numTrgElems = meshT.getNumberOfElements();
+    for(unsigned long i = 0 ; i < numTrgElems ; ++i)
+      if ( meshT.getTypeOfElement( OTT<ConnType,numPol>::indFC( i )) != NORM_TRI3 )
+        throw INTERP_KERNEL::Exception("P0P1 barycentric algorithm works only with triangular target meshes");
+  }
+
+  template<class MyMeshType, class MyMatrix, class ConcreteP0P1Intersector>
+  int PlanarIntersectorP0P1Bary<MyMeshType,MyMatrix,ConcreteP0P1Intersector>::getNumberOfRowsOfResMatrix() const
+  {
+    return PlanarIntersector<MyMeshType,MyMatrix>::_meshT.getNumberOfNodes();
+  }
+
+  template<class MyMeshType, class MyMatrix, class ConcreteP0P1Intersector>
+  int PlanarIntersectorP0P1Bary<MyMeshType,MyMatrix,ConcreteP0P1Intersector>::getNumberOfColsOfResMatrix() const
+  {
+    return PlanarIntersector<MyMeshType,MyMatrix>::_meshS.getNumberOfElements();
+  }
+
+  /*!
+   * This method computes a value per each node of each source triangle for target.
+   */
+  template<class MyMeshType, class MyMatrix, class ConcreteP0P1Intersector>
+  void PlanarIntersectorP0P1Bary<MyMeshType,MyMatrix,ConcreteP0P1Intersector>::intersectCells(ConnType icellT, const std::vector<ConnType>& icellsS, MyMatrix& res)
+  {
+    int orientation=1;
+    std::vector<double> trgTriaCoords,trgTriaCoordsTmp;
+    // target cell data
+    PlanarIntersector<MyMeshType,MyMatrix>::getRealTargetCoordinates(OTT<ConnType,numPol>::indFC(icellT),trgTriaCoords);
+    std::vector<double> *tgtCoords(&trgTriaCoords);
+    const ConnType *startOfCellNodeConn=PlanarIntersector<MyMeshType,MyMatrix>::_connectT+OTT<ConnType,numPol>::conn2C(PlanarIntersector<MyMeshType,MyMatrix>::_connIndexT[icellT]);
+    // treat each source cells
+    for(typename std::vector<ConnType>::const_iterator iter=icellsS.begin();iter!=icellsS.end();iter++)
+    {
+      std::vector<double> srcCellCoords,srcCellCoordsTmp,nodeCeffs;
+      int iS=*iter;
+      NormalizedCellType tS=PlanarIntersector<MyMeshType,MyMatrix>::_meshS.getTypeOfElement(OTT<ConnType,numPol>::indFC(iS));
+      bool isSourceQuad=CellModel::GetCellModel(tS).isQuadratic();
+      PlanarIntersector<MyMeshType,MyMatrix>::getRealSourceCoordinates(OTT<ConnType,numPol>::indFC(iS),srcCellCoords);
+      std::vector<double> *srcCoords(&srcCellCoords);
+      int srcNbNodes = srcCellCoords.size()/SPACEDIM;
+      if(SPACEDIM==3)
+        {
+          srcCellCoordsTmp=srcCellCoords;
+          trgTriaCoordsTmp=trgTriaCoords;
+          srcCoords=&srcCellCoordsTmp;
+          tgtCoords=&trgTriaCoordsTmp;
+          orientation=PlanarIntersector<MyMeshType,MyMatrix>::projectionThis(&trgTriaCoordsTmp[0],&srcCellCoordsTmp[0],
+                                                                             3,srcNbNodes);
+        }
+      //double surf=orientation*intersectGeometryWithQuadrangle(quadrangle,targetCellCoordsTmp,isTargetQuad);
+      double surf=orientation*intersectGeoBary(*srcCoords,isSourceQuad,&((*tgtCoords)[0]),nodeCeffs);
+      surf=PlanarIntersector<MyMeshType,MyMatrix>::getValueRegardingOption(surf);
+      if(surf!=0.)
+      {
+        for(int nodeIdT=0;nodeIdT<3;nodeIdT++)
+        {
+          ConnType curNodeT=startOfCellNodeConn[nodeIdT];
+          typename MyMatrix::value_type& resRow=res[curNodeT];
+          typename MyMatrix::value_type::const_iterator iterRes=resRow.find(*iter);
+          if(iterRes!=resRow.end())
+          {
+            nodeCeffs[*iter] += iterRes->second;
+            resRow.erase(*iter);
+          }
+          resRow.insert(std::make_pair(*iter,nodeCeffs[nodeIdT]));
+        }
+      }
+    }
+  }
+}
+#endif