]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
First factorization agy/mergefields_on_gp
authorAnthony Geay <anthony.geay@edf.fr>
Mon, 17 Dec 2018 13:04:28 +0000 (14:04 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Mon, 17 Dec 2018 13:04:28 +0000 (14:04 +0100)
src/MEDCoupling/MEDCouplingFieldDouble.cxx
src/MEDCoupling/Test/MEDCouplingBasicsTest1.cxx
src/MEDCoupling_Swig/MEDCouplingBasicsTest1.py

index 6e6d5dc21c5c55c1b0e7802e9846071fa86940a4..15bdffd94942813db3229854fd859f97b5c0386e 100644 (file)
@@ -2361,24 +2361,9 @@ void MEDCouplingFieldDouble::sortPerTuple(bool asc)
  */
 MEDCouplingFieldDouble *MEDCouplingFieldDouble::MergeFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2)
 {
-  if(!f1->areCompatibleForMerge(f2))
-    throw INTERP_KERNEL::Exception("Fields are not compatible. Unable to apply MergeFields on them ! Check support mesh, field nature, and spatial and time discretisation.");
-  const MEDCouplingMesh *m1(f1->getMesh()),*m2(f2->getMesh());
-  if(!f1->timeDiscr())
-    throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::MergeFields : no time discr of f1 !");
-  if(!f1->_type)
-    throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::MergeFields : no spatial discr of f1 !");
-  MEDCouplingTimeDiscretization *td(f1->timeDiscr()->aggregate(f2->timeDiscr()));
-  td->copyTinyAttrFrom(*f1->timeDiscr());
-  MCAuto<MEDCouplingFieldDouble> ret(new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone()));
-  ret->setName(f1->getName());
-  ret->setDescription(f1->getDescription());
-  if(m1)
-    {
-      MCAuto<MEDCouplingMesh> m=m1->mergeMyselfWith(m2);
-      ret->setMesh(m);
-    }
-  return ret.retn();
+  std::vector<const MEDCouplingFieldDouble *> a(2);
+  a[0]=f1; a[1]=f2;
+  return MergeFields(a);
 }
 
 /*!
index 99abe4394994778fa51f475a6dffebe686d2898c..4e859d3225f69168f53e482843643b9e08640f58 100644 (file)
@@ -1373,6 +1373,7 @@ void MEDCouplingBasicsTest1::testMergeField1()
   MEDCouplingFieldDouble *f3=MEDCouplingFieldDouble::MergeFields(f1,f2);
   f3->checkConsistencyLight();
   MEDCouplingUMesh *m4=build2DTargetMeshMerged_1();
+  m4->setName(f1->getMesh()->getName());
   CPPUNIT_ASSERT(f3->getMesh()->isEqual(m4,1.e-12));
   std::string name=f3->getName();
   CPPUNIT_ASSERT(name=="MeasureOfMesh_");
index 2d6a4c0cb3b4294c5ad28f1d6d7e93ad0f5e5dea..ae07b6d34464c5997133b83b26d69f62b672d2dc 100644 (file)
@@ -1030,6 +1030,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase):
         f3=MEDCouplingFieldDouble.MergeFields(f1,f2);
         f3.checkConsistencyLight();
         m4=MEDCouplingDataForTest.build2DTargetMeshMerged_1();
+        m4.setName(f1.getMesh().getName())
         self.assertTrue(f3.getMesh().isEqual(m4,1.e-12));
         name=f3.getName();
         self.assertEqual(name,"MeasureOfMesh_");