]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
WIP
authorAnthony Geay <anthony.geay@edf.fr>
Tue, 24 Jan 2023 07:45:50 +0000 (08:45 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Tue, 24 Jan 2023 07:45:50 +0000 (08:45 +0100)
src/INTERP_KERNEL/GaussPoints/InterpKernelGaussCoords.cxx
src/INTERP_KERNEL/InterpKernelDenseMatrix.hxx
src/INTERP_KERNEL/InterpKernelDenseMatrix.txx
src/MEDCoupling/MEDCouplingFieldDiscretization.cxx

index 657e4a898befd9ab820f4e3b9d3d0abcdf827b49..fbb224eebfb81f1d72150d7e21441bf2952fa1d8 100644 (file)
@@ -1103,8 +1103,24 @@ void GaussInfo::quad4aInit()
   funValue[0] = 0.25*(1.0 + gc[1])*(1.0 - gc[0]);
   funValue[1] = 0.25*(1.0 - gc[1])*(1.0 - gc[0]);
   funValue[2] = 0.25*(1.0 - gc[1])*(1.0 + gc[0]);
-  funValue[3] = 0.25*(1.0 + gc[0])*(1.0 + gc[1]);
+  funValue[3] = 0.25*(1.0 + gc[1])*(1.0 + gc[0]);
   SHAPE_FUN_MACRO_END;
+  
+  DEV_SHAPE_FUN_MACRO_BEGIN;
+
+  devFunValue[0] = -0.25*(1.0 + gc[1]);
+  devFunValue[1] = 0.25*(1.0 - gc[0]);
+
+  devFunValue[2] = -0.25*(1.0 - gc[1]);
+  devFunValue[3] = -0.25*(1.0 - gc[0]);
+
+  devFunValue[4] = 0.25*(1.0 + gc[1]);
+  devFunValue[5] = -0.25*(1.0 - gc[0]);
+
+  devFunValue[6] = 0.25*(1.0 + gc[1]);
+  devFunValue[7] = 0.25*(1.0 + gc[0]);
+  
+  DEV_SHAPE_FUN_MACRO_END;
 }
 
 /*!
@@ -1253,6 +1269,34 @@ void GaussInfo::quad8aInit()
   funValue[6] = 0.5*(1.0 + gc[0])*(1.0 - gc[1])*(1.0 + gc[1]);
   funValue[7] = 0.5*(1.0 + gc[1])*(1.0 - gc[0])*(1.0 + gc[0]);
   SHAPE_FUN_MACRO_END;
+
+  DEV_SHAPE_FUN_MACRO_BEGIN;
+
+  devFunValue[0] = 0.25*(1.0 + gc[1])*(2*gc[0]-gc[1]);
+  devFunValue[1] = 0.25*(1.0 - gc[0])*(2*gc[1]+gc[0]);
+
+  devFunValue[2] = 0.25*(1.0 - gc[1])*(2*gc[0]+gc[1]);
+  devFunValue[3] = 0.25*(1.0 - gc[0])*(2*gc[1]+gc[0]);
+
+  devFunValue[4] = 0.25*(1.0 - gc[1])*(2*gc[0]-gc[1]);
+  devFunValue[5] = 0.25*(1.0 + gc[0])*(2*gc[1]-gc[0]);
+
+  devFunValue[6] = 0.25*(1.0 + gc[1])*(2*gc[0]+gc[1]);
+  devFunValue[7] = 0.25*(1.0 + gc[0])*(2*gc[1]+gc[0]);
+
+  devFunValue[8] = -0.5*(1.0 - gc[1])*(1.0 + gc[1]);
+  devFunValue[9] = 0.5*(1.0 - gc[0])*(-2*gc[1]);
+
+  devFunValue[10] = 0.5*(1.0 - gc[1])*(-2*gc[0]);
+  devFunValue[11] = -0.5*(1.0 - gc[0])*(1.0 + gc[0]);
+
+  devFunValue[12] = 0.5*(1.0 - gc[1])*(1.0 + gc[1]);
+  devFunValue[13] = 0.5*(1.0 + gc[0])*(-2*gc[1]);
+
+  devFunValue[14] = 0.5*(1.0 + gc[1])*(-2*gc[0]);
+  devFunValue[15] = 0.5*(1.0 - gc[0])*(1.0 + gc[0]);
+
+  DEV_SHAPE_FUN_MACRO_END;
 }
 
 /*!
index 38e4a61281f777a887ae4e7711ed0d5d5a9808a2..63080077f3c0d39c472f6f4e8d3255987177f3bc 100644 (file)
@@ -47,6 +47,7 @@ namespace INTERP_KERNEL
     void resize(mcIdType newn, mcIdType newm);
     void assign(mcIdType newn, mcIdType newm, const T &a);
     ~DenseMatrixT();
+    T determinant() const;
   };
 
   using DenseMatrix = DenseMatrixT<double>;
index 9705f4fdbacb7910a17fd04cf3371d36caaf9613..2a262c31b14648b9a9ba5aecb3f736040bb2f609 100644 (file)
@@ -20,6 +20,7 @@
 #pragma once
 
 #include "InterpKernelDenseMatrix.hxx"
+#include "InterpKernelException.hxx"
 
 namespace INTERP_KERNEL
 {
@@ -138,4 +139,22 @@ namespace INTERP_KERNEL
       delete[] (v);
     }
   }
+
+  template<class T>
+  T Determinant22(const T *m)
+  { return m[0]*m[3]-m[1]*m[2]; }
+
+  template<class T>
+  T Determinant33(const T *m)
+  { return m[0]*(m[4]*m[8]-m[7]*m[5])-m[1]*(m[3]*m[8]-m[6]*m[5])+m[2]*(m[3]*m[7]-m[6]*m[4]);}
+  
+  template <class T>
+  T DenseMatrixT<T>::determinant() const
+  {
+    if(nn==2 && mm==2)
+      return Determinant22(v[0]);
+    if(nn==3 && mm==3)
+      return Determinant33(v[0]);
+    THROW_IK_EXCEPTION("DenseMatrixT::determinant : only 2x2 and 3x3 implemented !");
+  }
 }
index bf1397a4c053e0b394913cf62206f0df1f47c007..9fdf4ece72ccadb231fdd49b817355fbf23baed3 100755 (executable)
@@ -1745,8 +1745,8 @@ MEDCouplingFieldDouble *MEDCouplingFieldDiscretizationGauss::getMeasureField(con
           const MEDCouplingGaussLocalization& loc=_loc[locId];
           mcIdType nbOfGaussPt=loc.getNumberOfGaussPt();
           INTERP_KERNEL::AutoPtr<double> weights=new double[nbOfGaussPt];
-          double sum=std::accumulate(loc.getWeights().begin(),loc.getWeights().end(),0.);
-          std::transform(loc.getWeights().begin(),loc.getWeights().end(),(double *)weights,std::bind(std::multiplies<double>(),std::placeholders::_1,1./sum));
+          //double sum=std::accumulate(loc.getWeights().begin(),loc.getWeights().end(),0.);
+          //std::transform(loc.getWeights().begin(),loc.getWeights().end(),(double *)weights,std::bind(std::multiplies<double>(),std::placeholders::_1,1./sum));
           for(const mcIdType *cellId=curIds->begin();cellId!=curIds->end();cellId++)
           {
             std::vector<mcIdType> conn;
@@ -1756,18 +1756,18 @@ MEDCouplingFieldDouble *MEDCouplingFieldDiscretizationGauss::getMeasureField(con
             std::size_t nbPtsInCell(ptsInCell.size()/3);
             INTERP_KERNEL::DenseMatrix jacobian(2,2);
             MCAuto<DataArrayDouble> shapeFunc = loc.getDerivativeOfShapeFunctionValues();
-            for(std::size_t i = 0 ; i < 2 ; ++i)
-              for(std::size_t j = 0 ; j < 2 ; ++j)
-              {
-                double res = 0.0;
-                for( std::size_t k = 0 ; k < nbPtsInCell ; ++k )
-                  res += ptsInCell[k*2+i] * shapeFunc->getIJ(0,2*k+j);
-                jacobian[ i ][ j ] = res;
-              }
-
-
-            for(mcIdType j=0;j<nbOfGaussPt;j++)
-              arrPtr[offsetPtr[*cellId]+j]=weights[j];//*volPtr[*cellId]
+            for(mcIdType iGPt = 0 ; iGPt < nbOfGaussPt ; ++iGPt)
+            {
+              for(std::size_t i = 0 ; i < 2 ; ++i)
+                for(std::size_t j = 0 ; j < 2 ; ++j)
+                {
+                  double res = 0.0;
+                  for( std::size_t k = 0 ; k < nbPtsInCell ; ++k )
+                    res += ptsInCell[k*2+i] * shapeFunc->getIJ(iGPt,2*k+j);
+                  jacobian[ i ][ j ] = res;
+                }
+              arrPtr[offsetPtr[*cellId]+iGPt]=jacobian.determinant();
+            }
           }
         }
       else