*/
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);
}
/*!
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_");
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_");