+void prepareData2_buildOneSquare(MEDCouplingUMesh* & meshS_0, MEDCouplingUMesh* & meshT_0)
+{
+ const double coords[10] = {0.0,0.0, 0.0,1.0, 1.0,1.0, 1.0,0.0, 0.5,0.5};
+ meshS_0 = MEDCouplingUMesh::New("source", 2);
+ DataArrayDouble *myCoords=DataArrayDouble::New();
+ myCoords->alloc(5,2);
+ std::copy(coords,coords+10,myCoords->getPointer());
+ meshS_0->setCoords(myCoords); myCoords->decrRef();
+ int connS[4]={0,1,2,3};
+ meshS_0->allocateCells(2);
+ meshS_0->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,connS);
+ //
+ meshT_0 = MEDCouplingUMesh::New("target", 2);
+ myCoords=DataArrayDouble::New();
+ myCoords->alloc(5,2);
+ std::copy(coords,coords+10,myCoords->getPointer());
+ meshT_0->setCoords(myCoords);
+ myCoords->decrRef();
+ int connT[12]={0,1,4, 1,2,4, 2,3,4, 3,0,4};
+ meshT_0->allocateCells(4);
+ meshT_0->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,connT);
+ meshT_0->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,connT+3);
+ meshT_0->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,connT+6);
+ meshT_0->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,connT+9);
+}
+
+/**
+ * Prepare five (detached) QUAD4 disposed like this:
+ * (0) (1) (2)
+ * (3) (4)
+ *
+ * On the target side the global mesh is identical except that each QUAD4 is split in 4 TRI3 (along the diagonals).
+ * This is a case for two procs:
+ * - proc #0 has source squares 0,1,2 and target squares 0,3 (well, sets of TRI3s actually)
+ * - proc #1 has source squares 3,4 and target squares 1,2,4
+ */
+void prepareData2(int rank, ProcessorGroup * grp, NatureOfField nature,
+ MEDCouplingUMesh *& meshS, MEDCouplingUMesh *& meshT,
+ ParaMESH*& parameshS, ParaMESH*& parameshT,
+ ParaFIELD*& parafieldS, ParaFIELD*& parafieldT,
+ bool stripPartOfSource=false,
+ int fieldCompoNum=1)
+{
+ MEDCouplingUMesh *meshS_0 = 0, *meshT_0 = 0;
+ prepareData2_buildOneSquare(meshS_0, meshT_0);
+
+ if(rank==0)
+ {
+ const double tr1[] = {1.5, 0.0};
+ MEDCouplingUMesh *meshS_1 = static_cast<MEDCouplingUMesh*>(meshS_0->deepCopy());
+ meshS_1->translate(tr1);
+ const double tr2[] = {3.0, 0.0};
+ MEDCouplingUMesh *meshS_2 = static_cast<MEDCouplingUMesh*>(meshS_0->deepCopy());
+ meshS_2->translate(tr2);
+
+ std::vector<const MEDCouplingUMesh*> vec;
+ vec.push_back(meshS_0);vec.push_back(meshS_1);
+ if (!stripPartOfSource)
+ vec.push_back(meshS_2);
+ meshS = MEDCouplingUMesh::MergeUMeshes(vec);
+ meshS_1->decrRef(); meshS_2->decrRef();
+
+ ComponentTopology comptopo(fieldCompoNum);
+ parameshS=new ParaMESH(meshS, *grp,"source mesh");
+ parafieldS=new ParaFIELD(ON_CELLS,ONE_TIME,parameshS,comptopo);
+ parafieldS->getField()->setNature(nature);
+ double *valsS=parafieldS->getField()->getArray()->getPointer();
+ for(int i=0; i < fieldCompoNum; i++)
+ {
+ valsS[i] = 1. * (10^i);
+ valsS[fieldCompoNum+i] = 2. * (10^i);
+ if (!stripPartOfSource)
+ {
+ valsS[2*fieldCompoNum+i] = 3. * (10^i);
+ }
+ }
+
+ //
+ const double tr3[] = {0.0, -1.5};
+ MEDCouplingUMesh *meshT_3 = static_cast<MEDCouplingUMesh*>(meshT_0->deepCopy());
+ meshT_3->translate(tr3);
+ vec.clear();
+ vec.push_back(meshT_0);vec.push_back(meshT_3);
+ meshT = MEDCouplingUMesh::MergeUMeshes(vec);
+ meshT_3->decrRef();
+
+ parameshT=new ParaMESH(meshT,*grp,"target mesh");
+ parafieldT=new ParaFIELD(ON_CELLS,ONE_TIME,parameshT,comptopo);
+ parafieldT->getField()->setNature(nature);
+ }
+ //
+ if(rank==1)
+ {
+ const double tr3[] = {0.0, -1.5};
+ MEDCouplingUMesh *meshS_3 = static_cast<MEDCouplingUMesh*>(meshS_0->deepCopy());
+ meshS_3->translate(tr3);
+ const double tr4[] = {1.5, -1.5};
+ MEDCouplingUMesh *meshS_4 = static_cast<MEDCouplingUMesh*>(meshS_0->deepCopy());
+ meshS_4->translate(tr4);
+
+ std::vector<const MEDCouplingUMesh*> vec;
+ vec.push_back(meshS_3);vec.push_back(meshS_4);
+ meshS = MEDCouplingUMesh::MergeUMeshes(vec);
+ meshS_3->decrRef(); meshS_4->decrRef();
+
+ ComponentTopology comptopo(fieldCompoNum);
+ parameshS=new ParaMESH(meshS, *grp,"source mesh");
+ parafieldS=new ParaFIELD(ON_CELLS,ONE_TIME,parameshS,comptopo);
+ parafieldS->getField()->setNature(nature);
+ double *valsS=parafieldS->getField()->getArray()->getPointer();
+ for(int i=0; i < fieldCompoNum; i++)
+ {
+ valsS[i] = 4. * (10^i);
+ valsS[fieldCompoNum+i] = 5. * (10^i);
+ }
+
+ //
+ const double tr5[] = {1.5, 0.0};
+ MEDCouplingUMesh *meshT_1 = static_cast<MEDCouplingUMesh*>(meshT_0->deepCopy());
+ meshT_1->translate(tr5);
+ const double tr6[] = {3.0, 0.0};
+ MEDCouplingUMesh *meshT_2 = static_cast<MEDCouplingUMesh*>(meshT_0->deepCopy());
+ meshT_2->translate(tr6);
+ const double tr7[] = {1.5, -1.5};
+ MEDCouplingUMesh *meshT_4 = static_cast<MEDCouplingUMesh*>(meshT_0->deepCopy());
+ meshT_4->translate(tr7);
+
+ vec.clear();
+ vec.push_back(meshT_1);vec.push_back(meshT_2);vec.push_back(meshT_4);
+ meshT = MEDCouplingUMesh::MergeUMeshes(vec);
+ meshT_1->decrRef(); meshT_2->decrRef(); meshT_4->decrRef();
+
+ parameshT=new ParaMESH(meshT,*grp,"target mesh");
+ parafieldT=new ParaFIELD(ON_CELLS,ONE_TIME,parameshT,comptopo);
+ parafieldT->getField()->setNature(nature);
+ }
+ meshS_0->decrRef();
+ meshT_0->decrRef();