]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
[EDF27859] : Improve management of GENERAL_24
authorAnthony Geay <anthony.geay@edf.fr>
Wed, 9 Aug 2023 08:18:49 +0000 (10:18 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Wed, 9 Aug 2023 08:18:49 +0000 (10:18 +0200)
src/INTERP_KERNEL/PolyhedronIntersectorP1P0.txx
src/MEDCoupling/Test/MEDCouplingBasicsTestInterp.cxx

index 7c4776d369d3dc346b7be8f15de627514d52dcdd..858b253dae0b75d4b3ca625d2adda247140afecc 100644 (file)
@@ -98,46 +98,50 @@ namespace INTERP_KERNEL
   void PolyhedronIntersectorP1P0<MyMeshType,MyMatrix>::intersectCells(ConnType targetCell, const std::vector<ConnType>& srcCells, MyMatrix& res)
   {
     typename MyMatrix::value_type& resRow=res[targetCell];
-    if( _split.getSplittingPolicy() != GENERAL_24)
+    INTERP_KERNEL::SplittingPolicy sp( _split.getSplittingPolicy() );
+    if( sp == GENERAL_48 )
+      THROW_IK_EXCEPTION("GENERAL_28 spliting is not supported for P1P0 interpolation");
+    SplitterTetra<MyMeshType>* subTetras[24];
+    for(typename std::vector<ConnType>::const_iterator iterCellS=srcCells.begin();iterCellS!=srcCells.end();iterCellS++)
     {
-      SplitterTetra<MyMeshType>* subTetras[24];
-      for(typename std::vector<ConnType>::const_iterator iterCellS=srcCells.begin();iterCellS!=srcCells.end();iterCellS++)
-        {
-          releaseArrays();
-          ConnType nbOfNodesS=Intersector3D<MyMeshType,MyMatrix>::_src_mesh.getNumberOfNodesOfElement(OTT<ConnType,numPol>::indFC(*iterCellS));
-          _split.splitTargetCell(*iterCellS,nbOfNodesS,_tetra);
-          for(typename std::vector<SplitterTetra<MyMeshType>*>::const_iterator iter = _tetra.cbegin(); iter != _tetra.cend(); ++iter)
-            {
-              (*iter)->splitIntoDualCells(subTetras);
-              double vol2 = 0.;
-              for(int i=0;i<24;i++)
-                {
-                  SplitterTetra<MyMeshType> *tmp=subTetras[i];
-                  double volume = tmp->intersectSourceCell(targetCell);
-                  vol2 += volume;
-                  ConnType sourceNode=tmp->getId(0);
-                  AddContributionInRow(resRow,OTT<ConnType,numPol>::indFC(sourceNode),volume);
-                  delete tmp;
-                }
-            }
-        }
-    }
-    else
-    {
-      for(typename std::vector<ConnType>::const_iterator iterCellS=srcCells.begin();iterCellS!=srcCells.end();iterCellS++)
-        {
-          releaseArrays();
-          ConnType nbOfNodesS=Intersector3D<MyMeshType,MyMatrix>::_src_mesh.getNumberOfNodesOfElement(OTT<ConnType,numPol>::indFC(*iterCellS));
-          _split.splitTargetCell(*iterCellS,nbOfNodesS,_tetra);
-          for(typename std::vector<SplitterTetra<MyMeshType>*>::const_iterator iter = _tetra.cbegin(); iter != _tetra.cend(); ++iter)
-            {
-              double volume = std::abs( (*iter)->intersectSourceCell(targetCell) );
-              // node #0 is for internal node node #1 is for the node at the middle of the face
-              ConnType sourceNode0( (*iter)->getId(2) ), sourceNode1( (*iter)->getId(3) );
-              AddContributionInRow(resRow,OTT<ConnType,numPol>::indFC(sourceNode0),volume/2.);
-              AddContributionInRow(resRow,OTT<ConnType,numPol>::indFC(sourceNode1),volume/2.);
-            }
-        }
+      releaseArrays();
+      ConnType nbOfNodesS=this->_src_mesh.getNumberOfNodesOfElement(OTT<ConnType,numPol>::indFC(*iterCellS));
+      _split.splitTargetCell(*iterCellS,nbOfNodesS,_tetra);
+      INTERP_KERNEL::NormalizedCellType srcType = this->_src_mesh.getTypeOfElement( OTT<ConnType,numPol>::indFC(*iterCellS) );
+      if( srcType == NORM_TETRA4 || (srcType == NORM_HEXA8 && sp != GENERAL_24 ))
+      {
+        for(typename std::vector<SplitterTetra<MyMeshType>*>::const_iterator iter = _tetra.cbegin(); iter != _tetra.cend(); ++iter)
+          {
+            (*iter)->splitIntoDualCells(subTetras);
+            double vol2 = 0.;
+            for(int i=0;i<24;i++)
+              {
+                SplitterTetra<MyMeshType> *tmp=subTetras[i];
+                double volume = tmp->intersectSourceCell(targetCell);
+                vol2 += volume;
+                ConnType sourceNode=tmp->getId(0);
+                AddContributionInRow(resRow,OTT<ConnType,numPol>::indFC(sourceNode),volume);
+                delete tmp;
+              }
+          }
+      }
+      else
+      {
+        for(typename std::vector<ConnType>::const_iterator iterCellS=srcCells.begin();iterCellS!=srcCells.end();iterCellS++)
+          {
+            releaseArrays();
+            ConnType nbOfNodesS=Intersector3D<MyMeshType,MyMatrix>::_src_mesh.getNumberOfNodesOfElement(OTT<ConnType,numPol>::indFC(*iterCellS));
+            _split.splitTargetCell(*iterCellS,nbOfNodesS,_tetra);
+            for(typename std::vector<SplitterTetra<MyMeshType>*>::const_iterator iter = _tetra.cbegin(); iter != _tetra.cend(); ++iter)
+              {
+                double volume = std::abs( (*iter)->intersectSourceCell(targetCell) );
+                // node #0 is for internal node node #1 is for the node at the middle of the face
+                ConnType sourceNode0( (*iter)->getId(2) ), sourceNode1( (*iter)->getId(3) );
+                AddContributionInRow(resRow,OTT<ConnType,numPol>::indFC(sourceNode0),volume/2.);
+                AddContributionInRow(resRow,OTT<ConnType,numPol>::indFC(sourceNode1),volume/2.);
+              }
+          }
+      }
     }
   }
 }
index 1977fabd8319537629b76a2c5e5eae194cf66f71..a188997b6dec4e3f4845a023c250acc02d45e57c 100644 (file)
@@ -1287,8 +1287,8 @@ void MEDCouplingBasicsTestInterp::test3DInterpP1P0_1()
   INTERP_KERNEL::Interpolation3D myInterpolator;
   std::vector<std::map<mcIdType,double> > res;
   myInterpolator.setPrecision(1e-12);
-  INTERP_KERNEL::SplittingPolicy sp[] = { INTERP_KERNEL::PLANAR_FACE_5, INTERP_KERNEL::PLANAR_FACE_6, INTERP_KERNEL::GENERAL_24, INTERP_KERNEL::GENERAL_48 };
-  for ( int i = 0; i < 4; ++i )
+  INTERP_KERNEL::SplittingPolicy sp[] = { INTERP_KERNEL::PLANAR_FACE_5, INTERP_KERNEL::PLANAR_FACE_6, INTERP_KERNEL::GENERAL_24};
+  for ( int i = 0; i < 3; ++i )
   {
     myInterpolator.setSplittingPolicy( sp[i] );
     res.clear();