Back to index

salome-med  6.5.0
Public Member Functions | Private Member Functions
ParaMEDMEMTest Class Reference

#include <ParaMEDMEMTest.hxx>

Inheritance diagram for ParaMEDMEMTest:
Inheritance graph
[legend]
Collaboration diagram for ParaMEDMEMTest:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ParaMEDMEMTest ()
 ~ParaMEDMEMTest ()
void setUp ()
void tearDown ()
void testMPIProcessorGroup_constructor ()
void testMPIProcessorGroup_boolean ()
void testMPIProcessorGroup_rank ()
void testBlockTopology_constructor ()
void testBlockTopology_serialize ()
void testInterpKernelDEC_1D ()
void testInterpKernelDEC_2DCurve ()
void testInterpKernelDEC_2D ()
void testInterpKernelDEC2_2D ()
void testInterpKernelDEC_2DP0P1 ()
void testInterpKernelDEC_3D ()
void testInterpKernelDECNonOverlapp_2D_P0P0 ()
void testInterpKernelDECNonOverlapp_2D_P0P1P1P0 ()
void testInterpKernelDEC2DM1D_P0P0 ()
void testInterpKernelDECPartialProcs ()
void testInterpKernelDEC3DSurfEmptyBBox ()
 This test reproduces bug of Gauthier on 13/9/2010 concerning 3DSurf meshes.
void testOverlapDEC1 ()
void testStructuredCoincidentDEC ()
void testSynchronousEqualInterpKernelWithoutInterpNativeDEC_2D ()
void testSynchronousEqualInterpKernelWithoutInterpDEC_2D ()
void testSynchronousEqualInterpKernelDEC_2D ()
void testSynchronousFasterSourceInterpKernelDEC_2D ()
void testSynchronousSlowerSourceInterpKernelDEC_2D ()
void testSynchronousSlowSourceInterpKernelDEC_2D ()
void testSynchronousFastSourceInterpKernelDEC_2D ()
void testAsynchronousEqualInterpKernelDEC_2D ()
void testAsynchronousFasterSourceInterpKernelDEC_2D ()
void testAsynchronousSlowerSourceInterpKernelDEC_2D ()
void testAsynchronousSlowSourceInterpKernelDEC_2D ()
void testAsynchronousFastSourceInterpKernelDEC_2D ()
void testICocoTrio1 ()
void testGauthier1 ()
void testGauthier2 ()
void testGauthier3 ()
 Non regression test testing copy constructor of InterpKernelDEC.
void testFabienAPI1 ()
void testFabienAPI2 ()
 Idem testFabienAPI1 except that procs are shuffled.
void testMEDLoaderRead1 ()
void testMEDLoaderPolygonRead ()
void testMEDLoaderPolyhedronRead ()
void testMEDLoaderWrite1 ()
void testMEDLoaderPolygonWrite ()
std::string getResourceFile (const std::string &)
 Get path to the resources file.
std::string getTmpDirectory ()
 Returns writable temporary directory.
std::string makeTmpFile (const std::string &, const std::string &="")
 Creates a copy of source file (if source file is specified) in the temporary directory and returns a path to the tmp file.

Private Member Functions

 CPPUNIT_TEST_SUITE (ParaMEDMEMTest)
 CPPUNIT_TEST (testMPIProcessorGroup_constructor)
 CPPUNIT_TEST (testMPIProcessorGroup_boolean)
 CPPUNIT_TEST (testMPIProcessorGroup_rank)
 CPPUNIT_TEST (testBlockTopology_constructor)
 CPPUNIT_TEST (testBlockTopology_serialize)
 CPPUNIT_TEST (testInterpKernelDEC_1D)
 CPPUNIT_TEST (testInterpKernelDEC_2DCurve)
 CPPUNIT_TEST (testInterpKernelDEC_2D)
 CPPUNIT_TEST (testInterpKernelDEC2_2D)
 CPPUNIT_TEST (testInterpKernelDEC_2DP0P1)
 CPPUNIT_TEST (testInterpKernelDEC_3D)
 CPPUNIT_TEST (testInterpKernelDECNonOverlapp_2D_P0P0)
 CPPUNIT_TEST (testInterpKernelDECNonOverlapp_2D_P0P1P1P0)
 CPPUNIT_TEST (testInterpKernelDEC2DM1D_P0P0)
 CPPUNIT_TEST (testInterpKernelDECPartialProcs)
 CPPUNIT_TEST (testInterpKernelDEC3DSurfEmptyBBox)
 CPPUNIT_TEST (testOverlapDEC1)
 CPPUNIT_TEST (testSynchronousEqualInterpKernelWithoutInterpNativeDEC_2D)
 CPPUNIT_TEST (testSynchronousEqualInterpKernelWithoutInterpDEC_2D)
 CPPUNIT_TEST (testSynchronousEqualInterpKernelDEC_2D)
 CPPUNIT_TEST (testSynchronousFasterSourceInterpKernelDEC_2D)
 CPPUNIT_TEST (testSynchronousSlowerSourceInterpKernelDEC_2D)
 CPPUNIT_TEST (testSynchronousSlowSourceInterpKernelDEC_2D)
 CPPUNIT_TEST (testSynchronousFastSourceInterpKernelDEC_2D)
 CPPUNIT_TEST (testAsynchronousEqualInterpKernelDEC_2D)
 CPPUNIT_TEST (testAsynchronousFasterSourceInterpKernelDEC_2D)
 CPPUNIT_TEST (testAsynchronousSlowerSourceInterpKernelDEC_2D)
 CPPUNIT_TEST (testAsynchronousSlowSourceInterpKernelDEC_2D)
 CPPUNIT_TEST (testAsynchronousFastSourceInterpKernelDEC_2D)
 CPPUNIT_TEST (testStructuredCoincidentDEC)
 CPPUNIT_TEST (testStructuredCoincidentDEC)
 CPPUNIT_TEST (testICocoTrio1)
 CPPUNIT_TEST (testGauthier1)
 CPPUNIT_TEST (testGauthier2)
 CPPUNIT_TEST (testGauthier3)
 CPPUNIT_TEST (testFabienAPI1)
 CPPUNIT_TEST (testFabienAPI2)
 CPPUNIT_TEST (testMEDLoaderRead1)
 CPPUNIT_TEST (testMEDLoaderPolygonRead)
 CPPUNIT_TEST (testMEDLoaderPolyhedronRead)
 CPPUNIT_TEST_SUITE_END ()
void testAsynchronousInterpKernelDEC_2D (double dtA, double tmaxA, double dtB, double tmaxB, bool WithPointToPoint, bool Asynchronous, bool WithInterp, const char *srcMeth, const char *targetMeth)
 Tests an asynchronous exchange between two codes one sends data with dtA as an interval, the max time being tmaxA the other one receives with dtB as an interval, the max time being tmaxB.
void testInterpKernelDEC_2D_ (const char *srcMeth, const char *targetMeth)
void testInterpKernelDEC2_2D_ (const char *srcMeth, const char *targetMeth)
void testInterpKernelDEC_3D_ (const char *srcMeth, const char *targetMeth)

Detailed Description

Definition at line 31 of file ParaMEDMEMTest.hxx.


Constructor & Destructor Documentation

Definition at line 85 of file ParaMEDMEMTest.hxx.

:CppUnit::TestFixture(){}

Definition at line 86 of file ParaMEDMEMTest.hxx.

{}  

Member Function Documentation

std::string ParaMEDMEMTest::getResourceFile ( const std::string &  filename)

Get path to the resources file.

When running 'make test' source file is taken from MED_SRC/resources folder. Otherwise, file is searched in ${MED_ROOT_DIR}/share/salome/resources/med folder.

Parameters:
filenamename of the resource file (should not include a path)
Returns:
full path to the resource file

Definition at line 41 of file ParaMEDMEMTest.cxx.

{
  std::string resourceFile = "";

  if ( getenv("top_srcdir") ) {
    // we are in 'make check' step
    resourceFile = getenv("top_srcdir");
    resourceFile += "/resources/";
  }
  else if ( getenv("MED_ROOT_DIR") ) {
    // use MED_ROOT_DIR env.var
    resourceFile = getenv("MED_ROOT_DIR");
    resourceFile += "/share/salome/resources/med/";
  }
  resourceFile += filename;
  return resourceFile;
}

Returns writable temporary directory.

Returns:
full path to the temporary directory

Definition at line 67 of file ParaMEDMEMTest.cxx.

{
  std::string path;

  std::list<std::string> dirs;
  if ( getenv("TMP") )    dirs.push_back( getenv("TMP" ));
  if ( getenv("TMPDIR") ) dirs.push_back( getenv("TMPDIR" ));
  dirs.push_back( "/tmp" );

  std::string tmpd = "";
  for ( std::list<std::string>::iterator dir = dirs.begin(); dir != dirs.end() && tmpd == "" ; ++dir ) {
    if ( access( dir->data(), W_OK ) == 0 ) {
      tmpd = dir->data();
    }
  }

  if ( tmpd == "" )
    throw std::runtime_error("Can't find writable temporary directory. Set TMP environment variable");

  return tmpd;
}

Here is the caller graph for this function:

std::string ParaMEDMEMTest::makeTmpFile ( const std::string &  tmpfile,
const std::string &  srcfile = "" 
)

Creates a copy of source file (if source file is specified) in the temporary directory and returns a path to the tmp file.

Parameters:
tmpfilename of the temporary file (without path)
srcfilesource file
Returns:
path to the temporary file

Definition at line 99 of file ParaMEDMEMTest.cxx.

{
  std::string tmpf = getTmpDirectory() + "/" + tmpfile;
  if ( srcfile != "" ) {
    std::string cmd  = "cp " + srcfile + " " + tmpf + " ; chmod +w " + tmpf;
    system( cmd.c_str() );
  }
  return tmpf;
}

Here is the call graph for this function:

void ParaMEDMEMTest::setUp ( ) [inline]

Definition at line 87 of file ParaMEDMEMTest.hxx.

{}
void ParaMEDMEMTest::tearDown ( ) [inline]

Definition at line 88 of file ParaMEDMEMTest.hxx.

{}

Definition at line 1055 of file ParaMEDMEMTest_InterpKernelDEC.cxx.

{
  testAsynchronousInterpKernelDEC_2D(0.1,1,0.1,1,true,true,true,"P0","P0");
}

Definition at line 1059 of file ParaMEDMEMTest_InterpKernelDEC.cxx.

{
  testAsynchronousInterpKernelDEC_2D(0.09,1,0.1,1,true,true,true,"P0","P0");
}

Definition at line 1071 of file ParaMEDMEMTest_InterpKernelDEC.cxx.

{
  testAsynchronousInterpKernelDEC_2D(0.01,1,0.11,1,true,true,true,"P0","P0");
}
void ParaMEDMEMTest::testAsynchronousInterpKernelDEC_2D ( double  dtA,
double  tmaxA,
double  dtB,
double  tmaxB,
bool  WithPointToPoint,
bool  Asynchronous,
bool  WithInterp,
const char *  srcMeth,
const char *  targetMeth 
) [private]

Tests an asynchronous exchange between two codes one sends data with dtA as an interval, the max time being tmaxA the other one receives with dtB as an interval, the max time being tmaxB.

Definition at line 2070 of file ParaMEDMEMTest_InterpKernelDEC.cxx.

{
  std::string srcM(srcMeth);
  std::string targetM(targetMeth);
  int size;
  int rank;
  MPI_Comm_size(MPI_COMM_WORLD,&size);
  MPI_Comm_rank(MPI_COMM_WORLD,&rank);
 
  //the test is meant to run on five processors
  if (size !=5) return ;
   
  int nproc_source = 3;
  set<int> self_procs;
  set<int> procs_source;
  set<int> procs_target;
  
  for (int i=0; i<nproc_source; i++)
    procs_source.insert(i);
  for (int i=nproc_source; i<size; i++)
    procs_target.insert(i);
  self_procs.insert(rank);
  
  ParaMEDMEM::CommInterface interface;
    
  ParaMEDMEM::ProcessorGroup* self_group = new ParaMEDMEM::MPIProcessorGroup(interface,self_procs);
  ParaMEDMEM::ProcessorGroup* target_group = new ParaMEDMEM::MPIProcessorGroup(interface,procs_target);
  ParaMEDMEM::ProcessorGroup* source_group = new ParaMEDMEM::MPIProcessorGroup(interface,procs_source);
    
  //loading the geometry for the source group

  ParaMEDMEM::InterpKernelDEC dec (*source_group,*target_group);
  
  ParaMEDMEM::MEDCouplingUMesh* mesh;
  ParaMEDMEM::ParaMESH* paramesh;
  ParaMEDMEM::ParaFIELD* parafield;
  
  ICoCo::Field* icocofield ;

  string tmp_dir                    = getenv("TMP");
  if (tmp_dir == "")
    tmp_dir = "/tmp";
  string filename_xml1              = getResourceFile("square1_split");
  string filename_xml2              = getResourceFile("square2_split"); 
  //string filename_seq_wr            = makeTmpFile("");
  //string filename_seq_med           = makeTmpFile("myWrField_seq_pointe221.med");
  
  // To remove tmp files from disk
  ParaMEDMEMTest_TmpFilesRemover aRemover;
  
  MPI_Barrier(MPI_COMM_WORLD);

  if (source_group->containsMyRank())
    {
      string master = filename_xml1;
      
      ostringstream strstream;
      strstream <<master<<rank+1<<".med";
      ostringstream meshname ;
      meshname<< "Mesh_2_"<< rank+1;
      
      mesh=MEDLoader::ReadUMeshFromFile(strstream.str().c_str(),meshname.str().c_str(),0);

      paramesh=new ParaMESH (mesh,*source_group,"source mesh");
    
      //      ParaMEDMEM::ParaSUPPORT* parasupport=new UnstructuredParaSUPPORT( support,*source_group);
      ParaMEDMEM::ComponentTopology comptopo;
      if(srcM=="P0")
        {
          parafield = new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo);
          parafield->getField()->setNature(ConservativeVolumic);//InvertIntegral);//ConservativeVolumic);
        }
      else
        parafield = new ParaFIELD(ON_NODES,NO_TIME,paramesh, comptopo);

      int nb_local;
      if(srcM=="P0")
        nb_local=mesh->getNumberOfCells();
      else
        nb_local=mesh->getNumberOfNodes();
      //      double * value= new double[nb_local];
      double *value=parafield->getField()->getArray()->getPointer();
      for(int ielem=0; ielem<nb_local;ielem++)
        value[ielem]=0.0;
    
      //      ICoCo::Field* icocofield=new ICoCo::MEDField(paramesh,parafield);
      icocofield=new ICoCo::MEDField((MEDCouplingUMesh *)paramesh->getCellMesh(),parafield->getField());
     
      dec.attachLocalField(icocofield);


    }
  
  //loading the geometry for the target group
  if (target_group->containsMyRank())
    {
      string master= filename_xml2;
      ostringstream strstream;
      strstream << master<<(rank-nproc_source+1)<<".med";
      ostringstream meshname ;
      meshname<< "Mesh_3_"<<rank-nproc_source+1;
      
      mesh = MEDLoader::ReadUMeshFromFile(strstream.str().c_str(),meshname.str().c_str(),0);

      paramesh=new ParaMESH (mesh,*target_group,"target mesh");
      //      ParaMEDMEM::ParaSUPPORT* parasupport=new UnstructuredParaSUPPORT(support,*target_group);
      ParaMEDMEM::ComponentTopology comptopo;
      if(targetM=="P0")
        {
          parafield = new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo);
          parafield->getField()->setNature(ConservativeVolumic);//InvertIntegral);//ConservativeVolumic);
        }
      else
        parafield = new ParaFIELD(ON_NODES,NO_TIME,paramesh, comptopo);
      
      int nb_local;
      if(targetM=="P0")
        nb_local=mesh->getNumberOfCells();
      else
        nb_local=mesh->getNumberOfNodes();
                        
      double *value=parafield->getField()->getArray()->getPointer();
      for(int ielem=0; ielem<nb_local;ielem++)
        value[ielem]=0.0;
      //      ICoCo::Field* icocofield=new ICoCo::MEDField(paramesh,parafield);
      icocofield=new ICoCo::MEDField((MEDCouplingUMesh *)paramesh->getCellMesh(),parafield->getField());
      
      dec.attachLocalField(icocofield);
    }
    
  
  //attaching a DEC to the source group 
  
  if (source_group->containsMyRank())
    { 
      cout<<"DEC usage"<<endl;
      dec.setAsynchronous(Asynchronous);
      if ( WithInterp ) {
        dec.setTimeInterpolationMethod(LinearTimeInterp);
      }
      if ( WithPointToPoint ) {
        dec.setAllToAllMethod(PointToPoint);
      }
      else {
        dec.setAllToAllMethod(Native);
      }
      dec.synchronize();
      dec.setForcedRenormalization(false);
      for (double time=0; time<tmaxA+1e-10; time+=dtA)
        {
          cout << "testAsynchronousInterpKernelDEC_2D" << rank << " time " << time
               << " dtA " << dtA << " tmaxA " << tmaxA << endl ;
          if ( time+dtA < tmaxA+1e-7 ) {
            dec.sendData( time , dtA );
          }
          else {
            dec.sendData( time , 0 );
          }
          double* value = parafield->getField()->getArray()->getPointer();
          int nb_local=parafield->getField()->getMesh()->getNumberOfCells();
          for (int i=0; i<nb_local;i++)
            value[i]= time+dtA;

       
        }
    }
  
  //attaching a DEC to the target group
  if (target_group->containsMyRank())
    {
      cout<<"DEC usage"<<endl;
      dec.setAsynchronous(Asynchronous);
      if ( WithInterp ) {
        dec.setTimeInterpolationMethod(LinearTimeInterp);
      }
      if ( WithPointToPoint ) {
        dec.setAllToAllMethod(PointToPoint);
      }
      else {
        dec.setAllToAllMethod(Native);
      }
      dec.synchronize();
      dec.setForcedRenormalization(false);
      vector<double> times;
      for (double time=0; time<tmaxB+1e-10; time+=dtB)
        {
          cout << "testAsynchronousInterpKernelDEC_2D" << rank << " time " << time
               << " dtB " << dtB << " tmaxB " << tmaxB << endl ;
          dec.recvData( time );
          double vi = parafield->getVolumeIntegral(0,true);
          cout << "testAsynchronousInterpKernelDEC_2D" << rank << " time " << time
               << " VolumeIntegral " << vi
               << " time*10000 " << time*10000 << endl ;
          
          CPPUNIT_ASSERT_DOUBLES_EQUAL(vi,time*10000,0.001);
        }
      
    }
  
  delete source_group;
  delete target_group;
  delete self_group;
  delete parafield ;
  delete paramesh ;
  mesh->decrRef() ;
  delete icocofield ;

  cout << "testAsynchronousInterpKernelDEC_2D" << rank << " MPI_Barrier " << endl ;
 
  if (Asynchronous) MPI_Barrier(MPI_COMM_WORLD);
  cout << "end of InterpKernelDEC_2D test"<<endl;
}

Here is the call graph for this function:

Definition at line 1063 of file ParaMEDMEMTest_InterpKernelDEC.cxx.

{
  testAsynchronousInterpKernelDEC_2D(0.11,1,0.1,1,true,true,true,"P0","P0");
}

Definition at line 1067 of file ParaMEDMEMTest_InterpKernelDEC.cxx.

{
  testAsynchronousInterpKernelDEC_2D(0.11,1,0.01,1,true,true,true,"P0","P0");
}

Definition at line 62 of file ParaMEDMEMTest_BlockTopology.cxx.

{
  //test constructor
  int size;
  MPI_Comm_size(MPI_COMM_WORLD,&size);
  int rank;
  MPI_Comm_rank(MPI_COMM_WORLD,&rank);
  CommInterface interface;
  MPIProcessorGroup group(interface);
  BlockTopology blocktopo(group,1);
  CPPUNIT_ASSERT_EQUAL(1,blocktopo.getNbLocalElements());
  CPPUNIT_ASSERT_EQUAL(size,blocktopo.getNbElements());
  CPPUNIT_ASSERT_EQUAL(1,blocktopo.getDimension());
  
  //checking access methods
  BlockTopology blocktopo2(group,2);
  std::pair<int,int> local= blocktopo2.globalToLocal(0);
  CPPUNIT_ASSERT_EQUAL(local.first,0);
  CPPUNIT_ASSERT_EQUAL(local.second,0);
  int global=blocktopo2.localToGlobal(local);
  CPPUNIT_ASSERT_EQUAL(global,0);
  
  local = blocktopo2.globalToLocal(1);
  CPPUNIT_ASSERT_EQUAL(local.first,0);
  CPPUNIT_ASSERT_EQUAL(local.second,1);
  global=blocktopo2.localToGlobal(local);
  CPPUNIT_ASSERT_EQUAL(global,1);
  
  local = blocktopo2.globalToLocal(2*size-1);
  CPPUNIT_ASSERT_EQUAL(local.first,size-1);
  CPPUNIT_ASSERT_EQUAL(local.second,1);
  global=blocktopo2.localToGlobal(local);
  CPPUNIT_ASSERT_EQUAL(global,2*size-1);

  std::vector<std::pair<int,int> > bounds = blocktopo2.getLocalArrayMinMax();
  int vecsize = bounds.size();
  CPPUNIT_ASSERT_EQUAL(1,vecsize);
  CPPUNIT_ASSERT_EQUAL(2*rank, (bounds[0]).first);
  CPPUNIT_ASSERT_EQUAL(2*rank+2, (bounds[0]).second);
 }

Here is the call graph for this function:

Definition at line 103 of file ParaMEDMEMTest_BlockTopology.cxx.

{

  int size;
  MPI_Comm_size(MPI_COMM_WORLD,&size);
  int rank;
  MPI_Comm_rank(MPI_COMM_WORLD,&rank);
  CommInterface interface;
  MPIProcessorGroup group(interface);
  BlockTopology blocktopo(group,3);

//testing the serialization process that is used to transfer a
//block topology via a MPI_Send/Recv comm  
  BlockTopology blocktopo_recv;
  int* serializer;
  int sersize;
  blocktopo.serialize(serializer,sersize);
  blocktopo_recv.unserialize(serializer,interface);
  CPPUNIT_ASSERT_EQUAL(blocktopo.getNbElements(),blocktopo_recv.getNbElements());
  delete [] serializer;
}

Here is the call graph for this function:

Definition at line 34 of file ParaMEDMEMTest_FabienAPI.cxx.

{
  int size;
  int rank;
  MPI_Comm_size(MPI_COMM_WORLD,&size);
  MPI_Comm_rank(MPI_COMM_WORLD,&rank);
  //
  if(size!=3)
    return ;
  int procs_source_c[1]={0};
  std::set<int> procs_source(procs_source_c,procs_source_c+1);
  int procs_target_c[1]={1};
  std::set<int> procs_target(procs_target_c,procs_target_c+1);
  //
  ParaMEDMEM::MEDCouplingUMesh *mesh=0;
  ParaMEDMEM::ParaMESH *paramesh=0;
  ParaMEDMEM::ParaFIELD *parafield=0;
  //
  ParaMEDMEM::CommInterface interface;
  //
  MPI_Barrier(MPI_COMM_WORLD);
  double targetCoords[8]={ 0.,0., 1., 0., 0., 1., 1., 1. };
  CommInterface comm;
  //
  ParaMEDMEM::InterpKernelDEC *dec=new ParaMEDMEM::InterpKernelDEC(procs_source,procs_target);
  if(dec->isInSourceSide())
    {    
      mesh=MEDCouplingUMesh::New();
      mesh->setMeshDimension(2);
      DataArrayDouble *myCoords=DataArrayDouble::New();
      myCoords->alloc(4,2);
      std::copy(targetCoords,targetCoords+8,myCoords->getPointer());
      mesh->setCoords(myCoords);
      myCoords->decrRef();
      int targetConn[4]={0,2,3,1};
      mesh->allocateCells(1);
      mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn);
      mesh->finishInsertingCells();
      ParaMEDMEM::ComponentTopology comptopo;
      paramesh=new ParaMESH(mesh,*dec->getSourceGrp(),"source mesh");
      parafield=new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo);
      parafield->getField()->setNature(ConservativeVolumic);
      double *vals=parafield->getField()->getArray()->getPointer();
      vals[0]=7.;
    }
  if(dec->isInTargetSide())
    {
      mesh=MEDCouplingUMesh::New();
      mesh->setMeshDimension(2);
      DataArrayDouble *myCoords=DataArrayDouble::New();
      myCoords->alloc(4,2);
      std::copy(targetCoords,targetCoords+8,myCoords->getPointer());
      mesh->setCoords(myCoords);
      myCoords->decrRef();
      int targetConn[6]={0,2,1,2,3,1};
      mesh->allocateCells(2);
      mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn);
      mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+3);
      mesh->finishInsertingCells();
      ParaMEDMEM::ComponentTopology comptopo;
      paramesh=new ParaMESH(mesh,*dec->getTargetGrp(),"target mesh");
      parafield=new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo);
      parafield->getField()->setNature(ConservativeVolumic);
    }
  dec->attachLocalField(parafield);
  dec->synchronize();
  dec->sendRecvData();
  if(dec->isInTargetSide())
    {
      const double *valsToTest=parafield->getField()->getArray()->getConstPointer();
      CPPUNIT_ASSERT_DOUBLES_EQUAL(valsToTest[0],7.,1e-14);
      CPPUNIT_ASSERT_DOUBLES_EQUAL(valsToTest[1],7.,1e-14);
    }
  //
  delete parafield;
  delete paramesh;
  if(mesh)
    mesh->decrRef();
  delete dec;
  MPI_Barrier(MPI_COMM_WORLD);
}

Here is the call graph for this function:

Idem testFabienAPI1 except that procs are shuffled.

Test of the good management of group translation in newly created communicator.

Definition at line 119 of file ParaMEDMEMTest_FabienAPI.cxx.

{
  int size;
  int rank;
  MPI_Comm_size(MPI_COMM_WORLD,&size);
  MPI_Comm_rank(MPI_COMM_WORLD,&rank);
  //
  if(size!=3)
    return ;
  int procs_source_c[1]={2};//difference with testFabienAPI1
  std::set<int> procs_source(procs_source_c,procs_source_c+1);
  int procs_target_c[1]={1};
  std::set<int> procs_target(procs_target_c,procs_target_c+1);
  //
  ParaMEDMEM::MEDCouplingUMesh *mesh=0;
  ParaMEDMEM::ParaMESH *paramesh=0;
  ParaMEDMEM::ParaFIELD *parafield=0;
  //
  ParaMEDMEM::CommInterface interface;
  //
  MPI_Barrier(MPI_COMM_WORLD);
  double targetCoords[8]={ 0.,0., 1., 0., 0., 1., 1., 1. };
  CommInterface comm;
  //
  ParaMEDMEM::InterpKernelDEC *dec=new ParaMEDMEM::InterpKernelDEC(procs_source,procs_target);
  if(dec->isInSourceSide())
    {    
      mesh=MEDCouplingUMesh::New();
      mesh->setMeshDimension(2);
      DataArrayDouble *myCoords=DataArrayDouble::New();
      myCoords->alloc(4,2);
      std::copy(targetCoords,targetCoords+8,myCoords->getPointer());
      mesh->setCoords(myCoords);
      myCoords->decrRef();
      int targetConn[4]={0,2,3,1};
      mesh->allocateCells(1);
      mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn);
      mesh->finishInsertingCells();
      ParaMEDMEM::ComponentTopology comptopo;
      paramesh=new ParaMESH(mesh,*dec->getSourceGrp(),"source mesh");
      parafield=new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo);
      parafield->getField()->setNature(ConservativeVolumic);
      double *vals=parafield->getField()->getArray()->getPointer();
      vals[0]=7.;
    }
  if(dec->isInTargetSide())
    {
      mesh=MEDCouplingUMesh::New();
      mesh->setMeshDimension(2);
      DataArrayDouble *myCoords=DataArrayDouble::New();
      myCoords->alloc(4,2);
      std::copy(targetCoords,targetCoords+8,myCoords->getPointer());
      mesh->setCoords(myCoords);
      myCoords->decrRef();
      int targetConn[6]={0,2,1,2,3,1};
      mesh->allocateCells(2);
      mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn);
      mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+3);
      mesh->finishInsertingCells();
      ParaMEDMEM::ComponentTopology comptopo;
      paramesh=new ParaMESH(mesh,*dec->getTargetGrp(),"target mesh");
      parafield=new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo);
      parafield->getField()->setNature(ConservativeVolumic);
    }
  dec->attachLocalField(parafield);
  dec->synchronize();
  dec->sendRecvData();
  if(dec->isInTargetSide())
    {
      const double *valsToTest=parafield->getField()->getArray()->getConstPointer();
      CPPUNIT_ASSERT_DOUBLES_EQUAL(valsToTest[0],7.,1e-14);
      CPPUNIT_ASSERT_DOUBLES_EQUAL(valsToTest[1],7.,1e-14);
    }
  //
  delete parafield;
  delete paramesh;
  if(mesh)
    mesh->decrRef();
  delete dec;
  MPI_Barrier(MPI_COMM_WORLD);
}

Here is the call graph for this function:

Definition at line 173 of file ParaMEDMEMTest_Gauthier1.cxx.

{
  int num_cas=0;
  int rank, size;
  MPI_Comm_rank(MPI_COMM_WORLD,&rank);
  MPI_Comm_size(MPI_COMM_WORLD,&size);
  
  int is_master=0;

  CommInterface comm;
  set<int> emetteur_ids;
  set<int> recepteur_ids;
  emetteur_ids.insert(0);
  if(size!=4)
    return;
  recepteur_ids.insert(1);
  if (size >2) 
    recepteur_ids.insert(2);
  if (size >2) 
    emetteur_ids.insert(3);
  if ((rank==0)||(rank==1)) 
    is_master=1;
  
  MPIProcessorGroup recepteur_group(comm,recepteur_ids);
  MPIProcessorGroup emetteur_group(comm,emetteur_ids);


  string cas;
  if (recepteur_group.containsMyRank())
    {
      cas="recepteur";
      //freopen("recpeteur.out","w",stdout);
      //freopen("recepteur.err","w",stderr);
      
    }
  else
    {
      cas="emetteur";
      // freopen("emetteur.out","w",stdout);
      //freopen("emetteur.err","w",stderr);
    }
  double expected[8][4]={
    {1.,1.,1.,1.},
    {40., 40., 1., 1.},
    {1.,1.,1e200,1e200},
    {40.,1.,1e200,1e200},
    {1.,1.,1.,1.},
    {40.,1.,1.,1.},
    {1.,1.,1e200,1e200},
    {20.5,1.,1e200,1e200}
  };

  int expectedLgth[8]={4,4,2,2,4,4,2,2};
  
  for (int send=0;send<2;send++)
    for (int rec=0;rec<2;rec++)
      {
        InterpKernelDEC dec_emetteur(emetteur_group, recepteur_group);
        dec_emetteur.setOrientation(2);
        TrioField champ_emetteur, champ_recepteur;
   
        if (send==0)
          init_quadGauthier1(champ_emetteur,is_master);
        else
          init_triangleGauthier1(champ_emetteur,is_master);
        if (rec==0)
          init_triangleGauthier1(champ_recepteur,is_master);
        else
          init_quadGauthier1(champ_recepteur,is_master);
  
        if (cas=="emetteur") 
          {
            champ_emetteur._field=new double[champ_emetteur._nb_elems];
            for (int ele=0;ele<champ_emetteur._nb_elems;ele++)
              champ_emetteur._field[ele]=1;
      
            champ_emetteur._has_field_ownership=true;
          }
  
  
        MPI_Barrier(MPI_COMM_WORLD);

        //clock_t clock0= clock ();
        int compti=0;

        bool init=true; // first time step ??
        bool stop=false;
        //boucle sur les pas de quads
        while (!stop) {
  
          compti++;
          //clock_t clocki= clock ();
          //cout << compti << " CLOCK " << (clocki-clock0)*1.e-6 << endl; 
          for (int non_unif=0;non_unif<2;non_unif++)
            {
              // if (champ_recepteur._field)
              //   delete [] champ_recepteur._field;
              champ_recepteur._field=0;
              // champ_recepteur._has_field_ownership=false;
  

  
              if (cas=="emetteur") 
                {
                  if (non_unif)
                    if(rank!=3)
                      champ_emetteur._field[0]=40;
                }
              //bool ok=false; // Is the time interval successfully solved ?
    
              // Loop on the time interval tries
              if(1) {
      

                if (cas=="emetteur")
                  dec_emetteur.attachLocalField((ICoCo::Field*) &champ_emetteur);
                else
                  dec_emetteur.attachLocalField((ICoCo::Field*) &champ_recepteur);


                if(init) dec_emetteur.synchronize();
                init=false;

                if (cas=="emetteur") {
                  //    affiche(champ_emetteur);
                  dec_emetteur.sendData();
                }
                else if (cas=="recepteur")
                  {
                    dec_emetteur.recvData();
                    if (is_master)
                      afficheGauthier1(champ_recepteur,expected[num_cas],expectedLgth[num_cas]);
                  }
                else
                  throw 0;
                MPI_Barrier(MPI_COMM_WORLD);
              }
              stop=true;
              num_cas++;
            }
          // destruction des champs, des DEC, et des tableaux associés
        }
      }
}

Here is the call graph for this function:

Definition at line 318 of file ParaMEDMEMTest_Gauthier1.cxx.

{
  const char save_vit_in_2[]="VITESSE_P1_OUT\n1\n2\n3\n63\n3\n80\n0\n 0 1 2\n 3 4 5\n 6 7 8\n 9 10 11\n 12 13 14\n 15 16 17\n 18 19 20\n 21 22 23\n 24 25 26\n 27 28 29\n 30 2 1\n 31 5 4\n 32 8 7\n 33 11 10\n 34 14 13\n 35 17 16\n 36 20 19\n 37 23 22\n 38 26 25\n 39 29 28\n 30 40 2\n 31 41 5\n 32 42 8\n 33 43 11\n 34 44 14\n 35 45 17\n 36 46 20\n 37 47 23\n 38 48 26\n 39 49 29\n 31 2 40\n 32 5 41\n 33 8 42\n 34 11 43\n 35 14 44\n 36 17 45\n 37 20 46\n 38 23 47\n 39 26 48\n 50 29 49\n 3 2 4\n 6 5 7\n 9 8 10\n 12 11 13\n 15 14 16\n 18 17 19\n 21 20 22\n 24 23 25\n 27 26 28\n 51 29 52\n 31 4 2\n 32 7 5\n 33 10 8\n 34 13 11\n 35 16 14\n 36 19 17\n 37 22 20\n 38 25 23\n 39 28 26\n 50 52 29\n 0 2 53\n 3 5 54\n 6 8 55\n 9 11 56\n 12 14 57\n 15 17 58\n 18 20 59\n 21 23 60\n 24 26 61\n 27 29 62\n 3 53 2\n 6 54 5\n 9 55 8\n 12 56 11\n 15 57 14\n 18 58 17\n 21 59 20\n 24 60 23\n 27 61 26\n 51 62 29\n 0 0 0\n 0.5 0 0\n 0.5 0.05 0\n 0 0.1 0\n 0.5 0.1 0\n 0.5 0.15 0\n 0 0.2 0\n 0.5 0.2 0\n 0.5 0.25 0\n 0 0.3 0\n 0.5 0.3 0\n 0.5 0.35 0\n 0 0.4 0\n 0.5 0.4 0\n 0.5 0.45 0\n 0 0.5 0\n 0.5 0.5 0\n 0.5 0.55 0\n 0 0.6 0\n 0.5 0.6 0\n 0.5 0.65 0\n 0 0.7 0\n 0.5 0.7 0\n 0.5 0.75 0\n 0 0.8 0\n 0.5 0.8 0\n 0.5 0.85 0\n 0 0.9 0\n 0.5 0.9 0\n 0.5 0.95 0\n 1 0 0\n 1 0.1 0\n 1 0.2 0\n 1 0.3 0\n 1 0.4 0\n 1 0.5 0\n 1 0.6 0\n 1 0.7 0\n 1 0.8 0\n 1 0.9 0\n 1 0.05 0\n 1 0.15 0\n 1 0.25 0\n 1 0.35 0\n 1 0.45 0\n 1 0.55 0\n 1 0.65 0\n 1 0.75 0\n 1 0.85 0\n 1 0.95 0\n 1 1 0\n 0 1 0\n 0.5 1 0\n 0 0.05 0\n 0 0.15 0\n 0 0.25 0\n 0 0.35 0\n 0 0.45 0\n 0 0.55 0\n 0 0.65 0\n 0 0.75 0\n 0 0.85 0\n 0 0.95 0\n2.9268\n3.1707\n3\n1\n 0 0 0\n 0 0 0\n 0 0 0.05\n 0 0 0.1\n 0 0 0.1\n 0 0 0.15\n 0 0 0.2\n 0 0 0.2\n 0 0 0.25\n 0 0 0.3\n 0 0 0.3\n 0 0 0.35\n 0 0 0.4\n 0 0 0.4\n 0 0 0.45\n 0 0 0.5\n 0 0 0.5\n 0 0 0.55\n 0 0 0.6\n 0 0 0.6\n 0 0 0.65\n 0 0 0.7\n 0 0 0.7\n 0 0 0.75\n 0 0 0.8\n 0 0 0.8\n 0 0 0.85\n 0 0 0.9\n 0 0 0.9\n 0 0 0.95\n 0 0 0\n 0 0 0.1\n 0 0 0.2\n 0 0 0.3\n 0 0 0.4\n 0 0 0.5\n 0 0 0.6\n 0 0 0.7\n 0 0 0.8\n 0 0 0.9\n 0 0 0.05\n 0 0 0.15\n 0 0 0.25\n 0 0 0.35\n 0 0 0.45\n 0 0 0.55\n 0 0 0.65\n 0 0 0.75\n 0 0 0.85\n 0 0 0.95\n 0 0 1\n 0 0 1\n 0 0 1\n 0 0 0.05\n 0 0 0.15\n 0 0 0.25\n 0 0 0.35\n 0 0 0.45\n 0 0 0.55\n 0 0 0.65\n 0 0 0.75\n 0 0 0.85\n 0 0 0.95\n1\n";

  const char save_vit_out_0_2[]="vitesse_in_chaude\n0\n2\n3\n22\n4\n10\n-1081737852\n 0 1 3 2\n 2 3 5 4\n 4 5 7 6\n 6 7 9 8\n 8 9 11 10\n 10 11 13 12\n 12 13 15 14\n 14 15 17 16\n 16 17 19 18\n 18 19 21 20\n 0 0 0\n 1 0 0\n 0 0.1 0\n 1 0.1 0\n 0 0.2 0\n 1 0.2 0\n 0 0.3 0\n 1 0.3 0\n 0 0.4 0\n 1 0.4 0\n 0 0.5 0\n 1 0.5 0\n 0 0.6 0\n 1 0.6 0\n 0 0.7 0\n 1 0.7 0\n 0 0.8 0\n 1 0.8 0\n 0 0.9 0\n 1 0.9 0\n 0 1 0\n 1 1 0\n2.9268\n3.1707\n3\n1\n 0 0 0.05\n 0 0 0.15\n 0 0 0.25\n 0 0 0.35\n 0 0 0.45\n 0 0 0.55\n 0 0 0.65\n 0 0 0.75\n 0 0 0.85\n 0 0 0.95\n0\n";
  const char save_vit_out_1_2[]="vitesse_in_chaude\n1\n2\n3\n22\n4\n10\n-1081737852\n 0 1 3 2\n 2 3 5 4\n 4 5 7 6\n 6 7 9 8\n 8 9 11 10\n 10 11 13 12\n 12 13 15 14\n 14 15 17 16\n 16 17 19 18\n 18 19 21 20\n 0 0 0\n 1 0 0\n 0 0.1 0\n 1 0.1 0\n 0 0.2 0\n 1 0.2 0\n 0 0.3 0\n 1 0.3 0\n 0 0.4 0\n 1 0.4 0\n 0 0.5 0\n 1 0.5 0\n 0 0.6 0\n 1 0.6 0\n 0 0.7 0\n 1 0.7 0\n 0 0.8 0\n 1 0.8 0\n 0 0.9 0\n 1 0.9 0\n 0 1 0\n 1 1 0\n2.9268\n3.1707\n3\n1\n 0 0 0.029375\n 0 0 0.029375\n 0 0 0.1\n 0 0 0.1\n 0 0 0.2\n 0 0 0.2\n 0 0 0.3\n 0 0 0.3\n 0 0 0.4\n 0 0 0.4\n 0 0 0.5\n 0 0 0.5\n 0 0 0.6\n 0 0 0.6\n 0 0 0.7\n 0 0 0.7\n 0 0 0.8\n 0 0 0.8\n 0 0 0.9\n 0 0 0.9\n 0 0 0.970625\n 0 0 0.970625\n0\n";

  const char *save_vit_outs[2]={save_vit_out_1_2,save_vit_out_0_2};

  const char save_vit_out_1_0[]="vitesse_in_chaude\n1\n2\n3\n22\n4\n10\n-1081737852\n 0 1 3 2\n 2 3 5 4\n 4 5 7 6\n 6 7 9 8\n 8 9 11 10\n 10 11 13 12\n 12 13 15 14\n 14 15 17 16\n 16 17 19 18\n 18 19 21 20\n 0 0 0\n 1 0 0\n 0 0.1 0\n 1 0.1 0\n 0 0.2 0\n 1 0.2 0\n 0 0.3 0\n 1 0.3 0\n 0 0.4 0\n 1 0.4 0\n 0 0.5 0\n 1 0.5 0\n 0 0.6 0\n 1 0.6 0\n 0 0.7 0\n 1 0.7 0\n 0 0.8 0\n 1 0.8 0\n 0 0.9 0\n 1 0.9 0\n 0 1 0\n 1 1 0\n2.9268\n3.1707\n3\n1\n 0 0 0.029375\n 0 0 0.029375\n 0 0 0.1\n 0 0 0.1\n 0 0 0.2\n 0 0 0.2\n 0 0 0.3\n 0 0 0.3\n 0 0 0.4\n 0 0 0.4\n 0 0 0.5\n 0 0 0.5\n 0 0 0.6\n 0 0 0.6\n 0 0 0.7\n 0 0 0.7\n 0 0 0.8\n 0 0 0.8\n 0 0 0.9\n 0 0 0.9\n 0 0 0.970625\n 0 0 0.970625\n0\n";
  
  const char save_vit_in[]="VITESSE_P1_OUT\n1\n2\n3\n63\n3\n80\n0\n 0 1 2\n 3 4 5\n 6 7 8\n 9 10 11\n 12 13 14\n 15 16 17\n 18 19 20\n 21 22 23\n 24 25 26\n 27 28 29\n 30 2 1\n 31 5 4\n 32 8 7\n 33 11 10\n 34 14 13\n 35 17 16\n 36 20 19\n 37 23 22\n 38 26 25\n 39 29 28\n 30 40 2\n 31 41 5\n 32 42 8\n 33 43 11\n 34 44 14\n 35 45 17\n 36 46 20\n 37 47 23\n 38 48 26\n 39 49 29\n 31 2 40\n 32 5 41\n 33 8 42\n 34 11 43\n 35 14 44\n 36 17 45\n 37 20 46\n 38 23 47\n 39 26 48\n 50 29 49\n 3 2 4\n 6 5 7\n 9 8 10\n 12 11 13\n 15 14 16\n 18 17 19\n 21 20 22\n 24 23 25\n 27 26 28\n 51 29 52\n 31 4 2\n 32 7 5\n 33 10 8\n 34 13 11\n 35 16 14\n 36 19 17\n 37 22 20\n 38 25 23\n 39 28 26\n 50 52 29\n 0 2 53\n 3 5 54\n 6 8 55\n 9 11 56\n 12 14 57\n 15 17 58\n 18 20 59\n 21 23 60\n 24 26 61\n 27 29 62\n 3 53 2\n 6 54 5\n 9 55 8\n 12 56 11\n 15 57 14\n 18 58 17\n 21 59 20\n 24 60 23\n 27 61 26\n 51 62 29\n 0 0 0\n 0.5 0 0\n 0.5 0.05 0\n 0 0.1 0\n 0.5 0.1 0\n 0.5 0.15 0\n 0 0.2 0\n 0.5 0.2 0\n 0.5 0.25 0\n 0 0.3 0\n 0.5 0.3 0\n 0.5 0.35 0\n 0 0.4 0\n 0.5 0.4 0\n 0.5 0.45 0\n 0 0.5 0\n 0.5 0.5 0\n 0.5 0.55 0\n 0 0.6 0\n 0.5 0.6 0\n 0.5 0.65 0\n 0 0.7 0\n 0.5 0.7 0\n 0.5 0.75 0\n 0 0.8 0\n 0.5 0.8 0\n 0.5 0.85 0\n 0 0.9 0\n 0.5 0.9 0\n 0.5 0.95 0\n 1 0 0\n 1 0.1 0\n 1 0.2 0\n 1 0.3 0\n 1 0.4 0\n 1 0.5 0\n 1 0.6 0\n 1 0.7 0\n 1 0.8 0\n 1 0.9 0\n 1 0.05 0\n 1 0.15 0\n 1 0.25 0\n 1 0.35 0\n 1 0.45 0\n 1 0.55 0\n 1 0.65 0\n 1 0.75 0\n 1 0.85 0\n 1 0.95 0\n 1 1 0\n 0 1 0\n 0.5 1 0\n 0 0.05 0\n 0 0.15 0\n 0 0.25 0\n 0 0.35 0\n 0 0.45 0\n 0 0.55 0\n 0 0.65 0\n 0 0.75 0\n 0 0.85 0\n 0 0.95 0\n2.9268\n3.1707\n3\n1\n 0 0 0\n 0 0 0\n 0 0 0.05\n 0 0 0.1\n 0 0 0.1\n 0 0 0.15\n 0 0 0.2\n 0 0 0.2\n 0 0 0.25\n 0 0 0.3\n 0 0 0.3\n 0 0 0.35\n 0 0 0.4\n 0 0 0.4\n 0 0 0.45\n 0 0 0.5\n 0 0 0.5\n 0 0 0.55\n 0 0 0.6\n 0 0 0.6\n 0 0 0.65\n 0 0 0.7\n 0 0 0.7\n 0 0 0.75\n 0 0 0.8\n 0 0 0.8\n 0 0 0.85\n 0 0 0.9\n 0 0 0.9\n 0 0 0.95\n 0 0 0\n 0 0 0.1\n 0 0 0.2\n 0 0 0.3\n 0 0 0.4\n 0 0 0.5\n 0 0 0.6\n 0 0 0.7\n 0 0 0.8\n 0 0 0.9\n 0 0 0.05\n 0 0 0.15\n 0 0 0.25\n 0 0 0.35\n 0 0 0.45\n 0 0 0.55\n 0 0 0.65\n 0 0 0.75\n 0 0 0.85\n 0 0 0.95\n 0 0 1\n 0 0 1\n 0 0 1\n 0 0 0.05\n 0 0 0.15\n 0 0 0.25\n 0 0 0.35\n 0 0 0.45\n 0 0 0.55\n 0 0 0.65\n 0 0 0.75\n 0 0 0.85\n 0 0 0.95\n1\n";

  double valuesExpected1[2]={0.,0.};
  double valuesExpected2[2]={0.95,0.970625};
  
  double valuesExpected30[]={0., 0., 0.05, 0., 0., 0.15, 0., 0., 0.25, 0., 0., 0.35, 0., 0., 0.45, 0., 0., 0.55, 0., 0., 0.65, 0., 0., 0.75, 0., 0., 0.85, 0., 0., 0.95};
  double valuesExpected31[]={0.,  0.,  0.029375,  0.,  0.,  0.029375,  0.,  0.,  0.1,  0.,  0.,  0.1,  0.,  0.,  0.2,  0.,  0.,  0.2,  0.,  0.,  0.3,  0.,  0.,  0.3,  0.,  0.,  0.4,  0.,  0.,  0.4,  0.,  0.,  0.5,  0.,  0.,  0.5,  0.,  0.,  0.6,  0.,  0.,  0.6,  0.,  0.,  0.7,  0.,  0.,  0.7,  0.,  0.,  0.8,  0.,  0.,  0.8,  0.,  0.,  0.9,  0.,  0.,  0.9,  0.,  0.,  0.970625,  0.,  0.,  0.970625 };

  double *valuesExpected3[2]={valuesExpected30,valuesExpected31};

  int rank, size;
  MPI_Comm_rank(MPI_COMM_WORLD,&rank);
  MPI_Comm_size(MPI_COMM_WORLD,&size);
  if (size <2)
    return ;
  CommInterface comm;
  set<int> Genepi_ids;
  set<int> entree_chaude_ids;
  Genepi_ids.insert(0);
  for (int i=1;i<size;i++)
    entree_chaude_ids.insert(i);
  for (int type=0;type<2;type++)
    {
      MPIProcessorGroup entree_chaude_group(comm,entree_chaude_ids);
      MPIProcessorGroup Genepi_group(comm,Genepi_ids);

      TrioField vitesse;
      InterpKernelDEC dec_vit_in_chaude(entree_chaude_group, Genepi_group);

      if ( entree_chaude_group.containsMyRank())
        {
          istringstream save_vit(save_vit_in);
          vitesse.restore(save_vit);
        }
      else
        {
          istringstream save_vit(save_vit_out_1_0);
          vitesse.restore(save_vit);
          vitesse._has_field_ownership=false;
      
          if (vitesse._field)
            {
              delete [] vitesse._field;
              // cette ligne est super importante sinon c'est tout faux !!!!!!!
              vitesse._field=0;
            }
          // pour tester P1->P0
          vitesse._type=type;  
        }
  
      if (vitesse._type==1)
        dec_vit_in_chaude.setMethod("P1");
  
  

      dec_vit_in_chaude.attachLocalField((ICoCo::Field*) &vitesse);
      
      dec_vit_in_chaude.synchronize();
  
  
      // Envois - receptions
      if (entree_chaude_group.containsMyRank())
        {
          dec_vit_in_chaude.sendData();
        }
      else
        {
          dec_vit_in_chaude.recvData(); 
        }
      if (entree_chaude_group.containsMyRank() )
        {
          if (1)
            {
              ostringstream save_vit(save_vit_in_2);
              vitesse.save(save_vit);
            }
        }
      else
        {
      
          double pmin=1e38, pmax=-1e38;
      
          for(int i=0;i<vitesse.nb_values()*vitesse._nb_field_components;i++)
            {
              double p=*(vitesse._field+i);
              if (p<pmin) pmin=p;
              if (p>pmax) pmax=p;
            }
          CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesExpected1[type],pmin,1e-12);
          CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesExpected2[type],pmax,1e-12);
      
          ostringstream save_vit(save_vit_outs[type]);
          vitesse.save(save_vit);

          for(int i=0;i<vitesse.nb_values();i++)
            {
              for(int c=0;c<vitesse._nb_field_components;c++)
                {
                  double p=vitesse._field[i*vitesse._nb_field_components+c];
                  CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesExpected3[type][i*vitesse._nb_field_components+c],p,1e-12);
                }
            }
      
        }
    }
}

Here is the call graph for this function:

Non regression test testing copy constructor of InterpKernelDEC.

Definition at line 439 of file ParaMEDMEMTest_Gauthier1.cxx.

{
  int num_cas=0;
  int rank, size;
  MPI_Comm_rank(MPI_COMM_WORLD,&rank);
  MPI_Comm_size(MPI_COMM_WORLD,&size);
  
  int is_master=0;

  CommInterface comm;
  set<int> emetteur_ids;
  set<int> recepteur_ids;
  emetteur_ids.insert(0);
  if(size!=4)
    return;
  recepteur_ids.insert(1);
  if (size >2) 
    recepteur_ids.insert(2);
  if (size >2) 
    emetteur_ids.insert(3);
  if ((rank==0)||(rank==1)) 
    is_master=1;
  
  MPIProcessorGroup recepteur_group(comm,recepteur_ids);
  MPIProcessorGroup emetteur_group(comm,emetteur_ids);


  string cas;
  if (recepteur_group.containsMyRank())
    {
      cas="recepteur";
      //freopen("recpeteur.out","w",stdout);
      //freopen("recepteur.err","w",stderr);
      
    }
  else
    {
      cas="emetteur";
      // freopen("emetteur.out","w",stdout);
      //freopen("emetteur.err","w",stderr);
    }
  double expected[8][4]={
    {1.,1.,1.,1.},
    {40., 40., 1., 1.},
    {1.,1.,1e200,1e200},
    {40.,1.,1e200,1e200},
    {1.,1.,1.,1.},
    {40.,1.,1.,1.},
    {1.,1.,1e200,1e200},
    {20.5,1.,1e200,1e200}
  };

  int expectedLgth[8]={4,4,2,2,4,4,2,2};
  
  for (int send=0;send<2;send++)
    for (int rec=0;rec<2;rec++)
      {
        
        std::vector<InterpKernelDEC> decu(1);
        decu[0]=InterpKernelDEC(emetteur_group, recepteur_group);
        InterpKernelDEC& dec_emetteur=decu[0];

        //InterpKernelDEC dec_emetteur(emetteur_group, recepteur_group);
        dec_emetteur.setOrientation(2);
        TrioField champ_emetteur, champ_recepteur;
   
        if (send==0)
          init_quadGauthier1(champ_emetteur,is_master);
        else
          init_triangleGauthier1(champ_emetteur,is_master);
        if (rec==0)
          init_triangleGauthier1(champ_recepteur,is_master);
        else
          init_quadGauthier1(champ_recepteur,is_master);
  
        if (cas=="emetteur") 
          {
            champ_emetteur._field=new double[champ_emetteur._nb_elems];
            for (int ele=0;ele<champ_emetteur._nb_elems;ele++)
              champ_emetteur._field[ele]=1;
      
            champ_emetteur._has_field_ownership=true;
          }
  
  
        MPI_Barrier(MPI_COMM_WORLD);

        //clock_t clock0= clock ();
        int compti=0;

        bool init=true; // first time step ??
        bool stop=false;
        //boucle sur les pas de quads
        while (!stop) {
  
          compti++;
          //clock_t clocki= clock ();
          //cout << compti << " CLOCK " << (clocki-clock0)*1.e-6 << endl; 
          for (int non_unif=0;non_unif<2;non_unif++)
            {
              // if (champ_recepteur._field)
              //   delete [] champ_recepteur._field;
              champ_recepteur._field=0;
              // champ_recepteur._has_field_ownership=false;
  

  
              if (cas=="emetteur") 
                {
                  if (non_unif)
                    if(rank!=3)
                      champ_emetteur._field[0]=40;
                }
              //bool ok=false; // Is the time interval successfully solved ?
    
              // Loop on the time interval tries
              if(1) {
      

                if (cas=="emetteur")
                  dec_emetteur.attachLocalField((ICoCo::Field*) &champ_emetteur);
                else
                  dec_emetteur.attachLocalField((ICoCo::Field*) &champ_recepteur);


                if(init) dec_emetteur.synchronize();
                init=false;

                if (cas=="emetteur") {
                  //    affiche(champ_emetteur);
                  dec_emetteur.sendData();
                }
                else if (cas=="recepteur")
                  {
                    dec_emetteur.recvData();
                    if (is_master)
                      afficheGauthier1(champ_recepteur,expected[num_cas],expectedLgth[num_cas]);
                  }
                else
                  throw 0;
                MPI_Barrier(MPI_COMM_WORLD);
              }
              stop=true;
              num_cas++;
            }
          // destruction des champs, des DEC, et des tableaux associés
        }
      }
}

Here is the call graph for this function:

Definition at line 166 of file ParaMEDMEMTest_ICocoTrio.cxx.

{
  int size;
  int rank;
  MPI_Comm_size(MPI_COMM_WORLD,&size);
  MPI_Comm_rank(MPI_COMM_WORLD,&rank);

  //the test is meant to run on five processors
  if (size !=2) return ;
  
  CommInterface comm;
  set<int> emetteur_ids;
  set<int> recepteur_ids;
  emetteur_ids.insert(0);
  recepteur_ids.insert(1);

  MPIProcessorGroup recepteur_group(comm,recepteur_ids);
  MPIProcessorGroup emetteur_group(comm,emetteur_ids);


  string cas;
  if (recepteur_group.containsMyRank())
    {
      cas="recepteur";
      
    }
  else
    cas="emetteur";

  InterpKernelDEC dec_emetteur(emetteur_group, recepteur_group);

  TrioField champ_emetteur, champ_recepteur;
   
  init_triangle(champ_emetteur);
  //init_triangle(champ_emetteur);
  init_quad(champ_recepteur);
  //init_emetteur(champ_recepteur);
  
  if (cas=="emetteur") 
    {
      champ_emetteur._field=new double[champ_emetteur._nb_elems];
      for (int ele=0;ele<champ_emetteur._nb_elems;ele++)
        champ_emetteur._field[ele]=1;
      
      champ_emetteur._has_field_ownership=true;
    }
  
  
  MPI_Barrier(MPI_COMM_WORLD);

  clock_t clock0= clock ();
  int compti=0;

  bool init=true; // first time step ??
  bool stop=false;
  //boucle sur les pas de quads
  while (!stop) {
  
    compti++;
    clock_t clocki= clock ();
    cout << compti << " CLOCK " << (clocki-clock0)*1.e-6 << endl; 
    for (int non_unif=0;non_unif<2;non_unif++)
      {
        // if (champ_recepteur._field)
        //   delete [] champ_recepteur._field;
        champ_recepteur._field=0;
        // champ_recepteur._has_field_ownership=false;
  

  
        if (cas=="emetteur") 
          if (non_unif)
            champ_emetteur._field[0]=40;
        //bool ok=false; // Is the time interval successfully solved ?
    
        // Loop on the time interval tries
        if(1)
          {
            if (cas=="emetteur")
              dec_emetteur.attachLocalField((ICoCo::Field*) &champ_emetteur);
            else
              dec_emetteur.attachLocalField((ICoCo::Field*) &champ_recepteur);
            
            dec_emetteur.setNature(ConservativeVolumic);
            
            if(init)
              dec_emetteur.synchronize();
            init=false;
            
            if (cas=="emetteur")
              {
                dec_emetteur.sendData();
                affiche(champ_emetteur);
              }
            else if (cas=="recepteur")
              {
                dec_emetteur.recvData();
                affiche(champ_recepteur);
              }
            else
              throw 0;
          }
        stop=true;
      }
  }
}

Here is the call graph for this function:

Definition at line 56 of file ParaMEDMEMTest_InterpKernelDEC.cxx.

{
  testInterpKernelDEC2_2D_("P0","P0");
}
void ParaMEDMEMTest::testInterpKernelDEC2_2D_ ( const char *  srcMeth,
const char *  targetMeth 
) [private]

Definition at line 667 of file ParaMEDMEMTest_InterpKernelDEC.cxx.

{
  std::string srcM(srcMeth);
  std::string targetM(targetMeth);
  int size;
  int rank;
  MPI_Comm_size(MPI_COMM_WORLD,&size);
  MPI_Comm_rank(MPI_COMM_WORLD,&rank);

  //the test is meant to run on five processors
  if (size !=5) return ;
   
  int nproc_source = 3;
  set<int> self_procs;
  set<int> procs_source;
  set<int> procs_target;
  
  for (int i=0; i<nproc_source; i++)
    procs_source.insert(i);
  for (int i=nproc_source; i<size; i++)
    procs_target.insert(i);
  self_procs.insert(rank);
  
  ParaMEDMEM::CommInterface interface;
    
  ParaMEDMEM::ProcessorGroup* self_group = new ParaMEDMEM::MPIProcessorGroup(interface,self_procs);
  ParaMEDMEM::ProcessorGroup* target_group = new ParaMEDMEM::MPIProcessorGroup(interface,procs_target);
  ParaMEDMEM::ProcessorGroup* source_group = new ParaMEDMEM::MPIProcessorGroup(interface,procs_source);
  
  //loading the geometry for the source group

  ParaMEDMEM::InterpKernelDEC dec (*source_group,*target_group);

  ParaMEDMEM::MEDCouplingUMesh* mesh;
  ParaMEDMEM::MEDCouplingFieldDouble* mcfield;
  
  string filename_xml1              = getResourceFile("square1_split");
  string filename_xml2              = getResourceFile("square2_split");
  
  // To remove tmp files from disk
  ParaMEDMEMTest_TmpFilesRemover aRemover;
  
  MPI_Barrier(MPI_COMM_WORLD);
  if (source_group->containsMyRank())
    {
      string master = filename_xml1;
      
      ostringstream strstream;
      strstream <<master<<rank+1<<".med";
      ostringstream meshname ;
      meshname<< "Mesh_2_"<< rank+1;
      
      mesh=MEDLoader::ReadUMeshFromFile(strstream.str().c_str(),meshname.str().c_str(),0);
      ParaMEDMEM::ComponentTopology comptopo;
      if(srcM=="P0")
        {
          mcfield = MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME);
          mcfield->setMesh(mesh);
          DataArrayDouble *array=DataArrayDouble::New();
          array->alloc(mcfield->getNumberOfTuples(),1);
          mcfield->setArray(array);
          array->decrRef();
          mcfield->setNature(ConservativeVolumic);
        }
      else
        {
          mcfield = MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME);
          mcfield->setMesh(mesh);
          DataArrayDouble *array=DataArrayDouble::New();
          array->alloc(mcfield->getNumberOfTuples(),1);
          mcfield->setArray(array);
          array->decrRef();
        }
      int nb_local;
      if(srcM=="P0")
        nb_local=mesh->getNumberOfCells();
      else
        nb_local=mesh->getNumberOfNodes();
      double *value=mcfield->getArray()->getPointer();
      for(int ielem=0; ielem<nb_local;ielem++)
        value[ielem]=1.0;
      dec.setMethod(srcMeth);
      dec.attachLocalField(mcfield);
      dec.attachLocalField(mcfield);
    }
  
  //loading the geometry for the target group
  if (target_group->containsMyRank())
    {
      string master= filename_xml2;
      ostringstream strstream;
      strstream << master<<(rank-nproc_source+1)<<".med";
      ostringstream meshname ;
      meshname<< "Mesh_3_"<<rank-nproc_source+1;
      mesh = MEDLoader::ReadUMeshFromFile(strstream.str().c_str(),meshname.str().c_str(),0);
      ParaMEDMEM::ComponentTopology comptopo;
      if(targetM=="P0")
        {
          mcfield = MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME);
          mcfield->setMesh(mesh);
          DataArrayDouble *array=DataArrayDouble::New();
          array->alloc(mcfield->getNumberOfTuples(),1);
          mcfield->setArray(array);
          array->decrRef();
          mcfield->setNature(ConservativeVolumic);
        }
      else
        {
          mcfield = MEDCouplingFieldDouble::New(ON_NODES,NO_TIME);
          mcfield->setMesh(mesh);
          DataArrayDouble *array=DataArrayDouble::New();
          array->alloc(mcfield->getNumberOfTuples(),1);
          mcfield->setArray(array);
          array->decrRef();
        }
      int nb_local;
      if(targetM=="P0")
        nb_local=mesh->getNumberOfCells();
      else
        nb_local=mesh->getNumberOfNodes();
      double *value=mcfield->getArray()->getPointer();
      for(int ielem=0; ielem<nb_local;ielem++)
        value[ielem]=0.0;
      dec.setMethod(targetMeth);
      dec.attachLocalField(mcfield);
      dec.attachLocalField(mcfield);
    }
    
  
  //attaching a DEC to the source group 

  if (source_group->containsMyRank())
    { 
      dec.synchronize();
      dec.setForcedRenormalization(false);
      dec.sendData();
      dec.recvData();
    }
  
  //attaching a DEC to the target group
  if (target_group->containsMyRank())
    {
      dec.synchronize();
      dec.setForcedRenormalization(false);
      dec.recvData();
      dec.sendData();
    }
  delete source_group;
  delete target_group;
  delete self_group;
  mcfield->decrRef();
  mesh->decrRef();

  MPI_Barrier(MPI_COMM_WORLD);
  cout << "end of InterpKernelDEC2_2D test"<<endl;
}

Here is the call graph for this function:

Definition at line 1589 of file ParaMEDMEMTest_InterpKernelDEC.cxx.

{
  int size;
  int rank;
  MPI_Comm_size(MPI_COMM_WORLD,&size);
  MPI_Comm_rank(MPI_COMM_WORLD,&rank);
  //
  if(size!=3)
    return ;
  int nproc_source=2;
  set<int> procs_source;
  set<int> procs_target;
  //
  for (int i=0; i<nproc_source; i++)
    procs_source.insert(i);
  for (int i=nproc_source;i<size; i++)
    procs_target.insert(i);
  //
  ParaMEDMEM::MEDCouplingUMesh *mesh=0;
  ParaMEDMEM::ParaMESH *paramesh=0;
  ParaMEDMEM::ParaFIELD *parafield=0;
  //
  ParaMEDMEM::CommInterface interface;
  //
  ProcessorGroup* target_group = new ParaMEDMEM::MPIProcessorGroup(interface,procs_target);
  ProcessorGroup* source_group = new ParaMEDMEM::MPIProcessorGroup(interface,procs_source);
  //
  MPI_Barrier(MPI_COMM_WORLD);
  if(source_group->containsMyRank())
    {
      double targetCoords[18]={-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 };
      mesh=MEDCouplingUMesh::New();
      mesh->setMeshDimension(2);
      DataArrayDouble *myCoords=DataArrayDouble::New();
      myCoords->alloc(9,2);
      std::copy(targetCoords,targetCoords+18,myCoords->getPointer());
      mesh->setCoords(myCoords);
      myCoords->decrRef();
      if(rank==0)
        {
          int targetConn[7]={0,3,4,1, 1,4,2};
          mesh->allocateCells(2);
          mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn);
          mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+4);
          mesh->finishInsertingCells();
        }
      else
        { 
          int targetConn[11]={4,5,2, 6,7,4,3, 7,8,5,4};
          mesh->allocateCells(3);
          mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn);
          mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+3);
          mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+7);
          mesh->finishInsertingCells();
        }
      ParaMEDMEM::ComponentTopology comptopo;
      paramesh=new ParaMESH(mesh,*source_group,"source mesh");
      parafield=new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo);
      parafield->getField()->setNature(ConservativeVolumic);
      double *vals=parafield->getField()->getArray()->getPointer();
      if(rank==0)
        { vals[0]=7.; vals[1]=8.; }
      else
        { vals[0]=9.; vals[1]=10.; vals[2]=11.; }
    }
  else
    {
      mesh=MEDCouplingUMesh::New("an example of -1 D mesh",-1);
      ParaMEDMEM::ComponentTopology comptopo;
      paramesh=new ParaMESH(mesh,*target_group,"target mesh");
      parafield=new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo);
      parafield->getField()->setNature(ConservativeVolumic);
    }
  ParaMEDMEM::InterpKernelDEC dec(*source_group,*target_group);
  if(source_group->containsMyRank())
    {
      dec.setMethod("P0");
      dec.attachLocalField(parafield);
      dec.synchronize();
      dec.setForcedRenormalization(false);
      dec.sendData();
      dec.recvData();
      const double *res=parafield->getField()->getArray()->getConstPointer();
      if(rank==0)
        {
          CPPUNIT_ASSERT_DOUBLES_EQUAL(9.125,res[0],1e-12);
          CPPUNIT_ASSERT_DOUBLES_EQUAL(9.125,res[1],1e-12);
        }
      else
        {
          CPPUNIT_ASSERT_DOUBLES_EQUAL(9.125,res[0],1e-12);
          CPPUNIT_ASSERT_DOUBLES_EQUAL(9.125,res[1],1e-12);
          CPPUNIT_ASSERT_DOUBLES_EQUAL(9.125,res[2],1e-12);
        }
    }
  else
    {
      dec.setMethod("P0");
      dec.attachLocalField(parafield);
      dec.synchronize();
      dec.setForcedRenormalization(false);
      dec.recvData();
      const double *res=parafield->getField()->getArray()->getConstPointer();
      CPPUNIT_ASSERT_DOUBLES_EQUAL(9.125,res[0],1e-12);
      dec.sendData();
    }
  ParaMEDMEM::InterpKernelDEC dec2(*source_group,*target_group);
  dec2.setMethod("P0");
  parafield->getField()->setNature(IntegralGlobConstraint);
  if(source_group->containsMyRank())
    {
      double *vals=parafield->getField()->getArray()->getPointer();
      if(rank==0)
        { vals[0]=7.; vals[1]=8.; }
      else
        { vals[0]=9.; vals[1]=10.; vals[2]=11.; }
      dec2.attachLocalField(parafield);
      dec2.synchronize();
      dec2.sendData();
      dec2.recvData();
      const double *res=parafield->getField()->getArray()->getConstPointer();
      if(rank==0)
        {
          CPPUNIT_ASSERT_DOUBLES_EQUAL(11.25,res[0],1e-12);
          CPPUNIT_ASSERT_DOUBLES_EQUAL(5.625,res[1],1e-12);
        }
      else
        {
          CPPUNIT_ASSERT_DOUBLES_EQUAL(5.625,res[0],1e-12);
          CPPUNIT_ASSERT_DOUBLES_EQUAL(11.25,res[1],1e-12);
          CPPUNIT_ASSERT_DOUBLES_EQUAL(11.25,res[2],1e-12);
        }
    }
  else
    {
      dec2.attachLocalField(parafield);
      dec2.synchronize();
      dec2.recvData();
      const double *res=parafield->getField()->getArray()->getConstPointer();
      CPPUNIT_ASSERT_DOUBLES_EQUAL(45.,res[0],1e-12);
      dec2.sendData();
    }
  //
  ParaMEDMEM::InterpKernelDEC dec3(*source_group,*target_group);
  dec3.setMethod("P0");
  parafield->getField()->setNature(Integral);
  if(source_group->containsMyRank())
    {
      double *vals=parafield->getField()->getArray()->getPointer();
      if(rank==0)
        { vals[0]=7.; vals[1]=8.; }
      else
        { vals[0]=9.; vals[1]=10.; vals[2]=11.; }
      dec3.attachLocalField(parafield);
      dec3.synchronize();
      dec3.sendData();
      dec3.recvData();
      const double *res=parafield->getField()->getArray()->getConstPointer();
      if(rank==0)
        {
          CPPUNIT_ASSERT_DOUBLES_EQUAL(11.25,res[0],1e-12);
          CPPUNIT_ASSERT_DOUBLES_EQUAL(5.625,res[1],1e-12);
        }
      else
        {
          CPPUNIT_ASSERT_DOUBLES_EQUAL(5.625,res[0],1e-12);
          CPPUNIT_ASSERT_DOUBLES_EQUAL(11.25,res[1],1e-12);
          CPPUNIT_ASSERT_DOUBLES_EQUAL(11.25,res[2],1e-12);
        }
    }
  else
    {
      dec3.attachLocalField(parafield);
      dec3.synchronize();
      dec3.recvData();
      const double *res=parafield->getField()->getArray()->getConstPointer();
      CPPUNIT_ASSERT_DOUBLES_EQUAL(45.,res[0],1e-12);
      dec3.sendData();
    }
  //
  ParaMEDMEM::InterpKernelDEC dec4(*source_group,*target_group);
  dec4.setMethod("P0");
  parafield->getField()->setNature(RevIntegral);
  if(source_group->containsMyRank())
    {
      double *vals=parafield->getField()->getArray()->getPointer();
      if(rank==0)
        { vals[0]=7.; vals[1]=8.; }
      else
        { vals[0]=9.; vals[1]=10.; vals[2]=11.; }
      dec4.attachLocalField(parafield);
      dec4.synchronize();
      dec4.sendData();
      dec4.recvData();
      const double *res=parafield->getField()->getArray()->getConstPointer();
       if(rank==0)
        {
          CPPUNIT_ASSERT_DOUBLES_EQUAL(9.125,res[0],1e-12);
          CPPUNIT_ASSERT_DOUBLES_EQUAL(9.125,res[1],1e-12);
        }
      else
        {
          CPPUNIT_ASSERT_DOUBLES_EQUAL(9.125,res[0],1e-12);
          CPPUNIT_ASSERT_DOUBLES_EQUAL(9.125,res[1],1e-12);
          CPPUNIT_ASSERT_DOUBLES_EQUAL(9.125,res[2],1e-12);
        }
    }
  else
    {
      dec4.attachLocalField(parafield);
      dec4.synchronize();
      dec4.recvData();
      const double *res=parafield->getField()->getArray()->getConstPointer();
      CPPUNIT_ASSERT_DOUBLES_EQUAL(9.125,res[0],1e-12);
      dec4.sendData();
    }
  delete parafield;
  delete paramesh;
  mesh->decrRef();
  delete target_group;
  delete source_group;
  //
  MPI_Barrier(MPI_COMM_WORLD);
}

Here is the call graph for this function:

This test reproduces bug of Gauthier on 13/9/2010 concerning 3DSurf meshes.

It is possible to lead to dead lock in InterpKernelDEC when 3DSurfMeshes global bounding boxes intersects whereas cell bounding box intersecting only on one side.

Definition at line 1917 of file ParaMEDMEMTest_InterpKernelDEC.cxx.

{
  int size;
  int rank;
  MPI_Comm_size(MPI_COMM_WORLD,&size);
  MPI_Comm_rank(MPI_COMM_WORLD,&rank);
  //
  if(size!=3)
    return ;
  int nproc_source = 1;
  set<int> self_procs;
  set<int> procs_source;
  set<int> procs_target;
  
  for (int i=0; i<nproc_source; i++)
    procs_source.insert(i);
  for (int i=nproc_source; i<size; i++)
    procs_target.insert(i);
  self_procs.insert(rank);
  //
  ParaMEDMEM::MEDCouplingUMesh *mesh=0;
  ParaMEDMEM::ParaMESH *paramesh=0;
  ParaMEDMEM::ParaFIELD *parafieldP0=0;
  //
  ParaMEDMEM::CommInterface interface;
  //
  ProcessorGroup* self_group = new ParaMEDMEM::MPIProcessorGroup(interface,self_procs);
  ProcessorGroup* target_group = new ParaMEDMEM::MPIProcessorGroup(interface,procs_target);
  ProcessorGroup* source_group = new ParaMEDMEM::MPIProcessorGroup(interface,procs_source);
  //
  MPI_Barrier(MPI_COMM_WORLD);
  if(source_group->containsMyRank())
    {
      double coords[15]={1.,0.,0., 2.,0.,0., 2.,2.,0., 0.,2.,0., 0.5,0.5,1.};
      int conn[7]={0,1,2,3,0,3,4};
      mesh=MEDCouplingUMesh::New("Source mesh Proc0",2);
      mesh->allocateCells(2);
      mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn);
      mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,conn+4);
      mesh->finishInsertingCells();
      DataArrayDouble *myCoords=DataArrayDouble::New();
      myCoords->alloc(5,3);
      std::copy(coords,coords+15,myCoords->getPointer());
      mesh->setCoords(myCoords);
      myCoords->decrRef();
      //
      paramesh=new ParaMESH(mesh,*source_group,"source mesh");
      ParaMEDMEM::ComponentTopology comptopo;
      parafieldP0 = new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo);
      double *valueP0=parafieldP0->getField()->getArray()->getPointer();
      parafieldP0->getField()->setNature(ConservativeVolumic);
      valueP0[0]=7.; valueP0[1]=8.;
    }
  else
    {
      const char targetMeshName[]="target mesh";
      if(rank==1)
        {
          double coords[12]={0.25,0.25,0.5, 0.,0.25,0.5, 0.,0.,0.5, 0.25,0.,0.5};
          int conn[4]={0,1,2,3};
          mesh=MEDCouplingUMesh::New("Target mesh Proc1",2);
          mesh->allocateCells(1);
          mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn);
          mesh->finishInsertingCells();
          DataArrayDouble *myCoords=DataArrayDouble::New();
          myCoords->alloc(4,3);
          std::copy(coords,coords+12,myCoords->getPointer());
          mesh->setCoords(myCoords);
          myCoords->decrRef();
          paramesh=new ParaMESH(mesh,*target_group,targetMeshName);
        }
      if(rank==2)
        {
          double coords[12]={0.,0.25,0.5, 0.,0.,0.5, -1.,0.,0.5, -1.,0.25,0.5};
          int conn[4]={0,1,2,3};
          mesh=MEDCouplingUMesh::New("Target mesh Proc2",2);
          mesh->allocateCells(1);
          mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn);
          mesh->finishInsertingCells();
          DataArrayDouble *myCoords=DataArrayDouble::New();
          myCoords->alloc(4,3);
          std::copy(coords,coords+12,myCoords->getPointer());
          mesh->setCoords(myCoords);
          myCoords->decrRef();
          paramesh=new ParaMESH(mesh,*target_group,targetMeshName);
        }
      ParaMEDMEM::ComponentTopology comptopo;
      parafieldP0 = new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo);
      parafieldP0->getField()->setNature(ConservativeVolumic);
    }
  // test 1
  ParaMEDMEM::InterpKernelDEC dec(*source_group,*target_group);
  if (source_group->containsMyRank())
    { 
      dec.setMethod("P0");
      dec.attachLocalField(parafieldP0);
      dec.synchronize();
      // dec.setForcedRenormalization(false);
      // dec.sendData();
      // dec.recvData();
      // const double *valueP0=parafieldP0->getField()->getArray()->getPointer();
      // if(rank==0)
      //   {
      //     CPPUNIT_ASSERT_DOUBLES_EQUAL(7.4,valueP0[0],1e-7);
      //     CPPUNIT_ASSERT_DOUBLES_EQUAL(9.0540540540540544,valueP0[1],1e-7);
      //   }
      // if(rank==1)
      //   {
      //     CPPUNIT_ASSERT_DOUBLES_EQUAL(8.64054054054054,valueP0[0],1e-7);
      //   }
      // if(rank==2)
      //   {
      //     CPPUNIT_ASSERT_DOUBLES_EQUAL(9.0540540540540544,valueP0[0],1e-7);
      //   }
    }
  else
    {
      dec.setMethod("P0");
      dec.attachLocalField(parafieldP0);
      dec.synchronize();
      // dec.setForcedRenormalization(false);
      // dec.recvData();
      // const double *res=parafieldP0->getField()->getArray()->getConstPointer();
      // if(rank==3)
      //   {
      //     CPPUNIT_ASSERT_EQUAL(1,parafieldP0->getField()->getNumberOfTuples());
      //     CPPUNIT_ASSERT_EQUAL(1,parafieldP0->getField()->getNumberOfComponents());
      //     CPPUNIT_ASSERT_DOUBLES_EQUAL(7.4,res[0],1e-12);
      //   }
      // if(rank==4)
      //   {
      //     CPPUNIT_ASSERT_EQUAL(1,parafieldP0->getField()->getNumberOfTuples());
      //     CPPUNIT_ASSERT_EQUAL(1,parafieldP0->getField()->getNumberOfComponents());
      //     CPPUNIT_ASSERT_DOUBLES_EQUAL(9.0540540540540526,res[0],1e-12);
      //   }
      // dec.sendData();
    }
  //
  delete parafieldP0;
  mesh->decrRef();
  delete paramesh;
  delete self_group;
  delete target_group;
  delete source_group;
  //
  MPI_Barrier(MPI_COMM_WORLD);
}

Here is the call graph for this function:

Definition at line 71 of file ParaMEDMEMTest_InterpKernelDEC.cxx.

{
  int size;
  int rank;
  MPI_Comm_size(MPI_COMM_WORLD,&size);
  MPI_Comm_rank(MPI_COMM_WORLD,&rank);
  //
  if(size!=5)
    return ;
  int nproc_source = 3;
  set<int> self_procs;
  set<int> procs_source;
  set<int> procs_target;
  
  for (int i=0; i<nproc_source; i++)
    procs_source.insert(i);
  for (int i=nproc_source; i<size; i++)
    procs_target.insert(i);
  self_procs.insert(rank);
  //
  ParaMEDMEM::MEDCouplingUMesh *mesh=0;
  ParaMEDMEM::ParaMESH *paramesh=0;
  ParaMEDMEM::ParaFIELD *parafieldP0=0;
  //
  ParaMEDMEM::CommInterface interface;
  //
  ProcessorGroup* self_group = new ParaMEDMEM::MPIProcessorGroup(interface,self_procs);
  ProcessorGroup* target_group = new ParaMEDMEM::MPIProcessorGroup(interface,procs_target);
  ProcessorGroup* source_group = new ParaMEDMEM::MPIProcessorGroup(interface,procs_source);
  //
  MPI_Barrier(MPI_COMM_WORLD);
  if(source_group->containsMyRank())
    {
      if(rank==0)
        {
          double coords[4]={0.3,0.7, 0.9,1.0};
          int conn[4]={0,1,2,3};
          mesh=MEDCouplingUMesh::New("Source mesh Proc0",1);
          mesh->allocateCells(2);
          mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn);
          mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+2);
          mesh->finishInsertingCells();
          DataArrayDouble *myCoords=DataArrayDouble::New();
          myCoords->alloc(4,1);
          std::copy(coords,coords+4,myCoords->getPointer());
          mesh->setCoords(myCoords);
          myCoords->decrRef();
        }
      if(rank==1)
        {
          double coords[2]={0.7,0.9};
          int conn[2]={0,1};
          mesh=MEDCouplingUMesh::New("Source mesh Proc1",1);
          mesh->allocateCells(1);
          mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn);
          mesh->finishInsertingCells();
          DataArrayDouble *myCoords=DataArrayDouble::New();
          myCoords->alloc(2,1);
          std::copy(coords,coords+2,myCoords->getPointer());
          mesh->setCoords(myCoords);
          myCoords->decrRef();
        }
      if(rank==2)
        {
          double coords[2]={1.,1.12};
          int conn[2]={0,1};
          mesh=MEDCouplingUMesh::New("Source mesh Proc2",1);
          mesh->allocateCells(1);
          mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn);
          mesh->finishInsertingCells();
          DataArrayDouble *myCoords=DataArrayDouble::New();
          myCoords->alloc(2,1);
          std::copy(coords,coords+2,myCoords->getPointer());
          mesh->setCoords(myCoords);
          myCoords->decrRef();
        }
      paramesh=new ParaMESH(mesh,*source_group,"source mesh");
      ParaMEDMEM::ComponentTopology comptopo;
      parafieldP0 = new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo);
      double *valueP0=parafieldP0->getField()->getArray()->getPointer();
      parafieldP0->getField()->setNature(ConservativeVolumic);
      if(rank==0)
        {
          valueP0[0]=7.; valueP0[1]=8.;
        }
      if(rank==1)
        {
          valueP0[0]=9.;
        }
      if(rank==2)
        {
          valueP0[0]=10.;
        }
    }
  else
    {
      const char targetMeshName[]="target mesh";
      if(rank==3)
        {
          double coords[2]={0.5,0.75};
          int conn[2]={0,1};
          mesh=MEDCouplingUMesh::New("Target mesh Proc3",1);
          mesh->allocateCells(1);
          mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn);
          mesh->finishInsertingCells();
          DataArrayDouble *myCoords=DataArrayDouble::New();
          myCoords->alloc(2,1);
          std::copy(coords,coords+2,myCoords->getPointer());
          mesh->setCoords(myCoords);
          myCoords->decrRef();
          paramesh=new ParaMESH(mesh,*target_group,targetMeshName);
        }
      if(rank==4)
        {
          double coords[2]={0.75,1.2};
          int conn[2]={0,1};
          mesh=MEDCouplingUMesh::New("Target mesh Proc4",1);
          mesh->allocateCells(1);
          mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn);
          mesh->finishInsertingCells();
          DataArrayDouble *myCoords=DataArrayDouble::New();
          myCoords->alloc(2,1);
          std::copy(coords,coords+2,myCoords->getPointer());
          mesh->setCoords(myCoords);
          myCoords->decrRef();
          paramesh=new ParaMESH(mesh,*target_group,targetMeshName);
        }
      ParaMEDMEM::ComponentTopology comptopo;
      parafieldP0 = new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo);
      parafieldP0->getField()->setNature(ConservativeVolumic);
    }
  // test 1
  ParaMEDMEM::InterpKernelDEC dec(*source_group,*target_group);
  if (source_group->containsMyRank())
    { 
      dec.setMethod("P0");
      dec.attachLocalField(parafieldP0);
      dec.synchronize();
      dec.setForcedRenormalization(false);
      dec.sendData();
      dec.recvData();
      const double *valueP0=parafieldP0->getField()->getArray()->getPointer();
      if(rank==0)
        {
          CPPUNIT_ASSERT_DOUBLES_EQUAL(7.4,valueP0[0],1e-7);
          CPPUNIT_ASSERT_DOUBLES_EQUAL(9.0540540540540544,valueP0[1],1e-7);
        }
      if(rank==1)
        {
          CPPUNIT_ASSERT_DOUBLES_EQUAL(8.64054054054054,valueP0[0],1e-7);
        }
      if(rank==2)
        {
          CPPUNIT_ASSERT_DOUBLES_EQUAL(9.0540540540540544,valueP0[0],1e-7);
        }
    }
  else
    {
      dec.setMethod("P0");
      dec.attachLocalField(parafieldP0);
      dec.synchronize();
      dec.setForcedRenormalization(false);
      dec.recvData();
      const double *res=parafieldP0->getField()->getArray()->getConstPointer();
      if(rank==3)
        {
          CPPUNIT_ASSERT_EQUAL(1,parafieldP0->getField()->getNumberOfTuples());
          CPPUNIT_ASSERT_EQUAL(1,parafieldP0->getField()->getNumberOfComponents());
          CPPUNIT_ASSERT_DOUBLES_EQUAL(7.4,res[0],1e-12);
        }
      if(rank==4)
        {
          CPPUNIT_ASSERT_EQUAL(1,parafieldP0->getField()->getNumberOfTuples());
          CPPUNIT_ASSERT_EQUAL(1,parafieldP0->getField()->getNumberOfComponents());
          CPPUNIT_ASSERT_DOUBLES_EQUAL(9.0540540540540526,res[0],1e-12);
        }
      dec.sendData();
    }
  //
  delete parafieldP0;
  mesh->decrRef();
  delete paramesh;
  delete self_group;
  delete target_group;
  delete source_group;
  //
  MPI_Barrier(MPI_COMM_WORLD);
}

Here is the call graph for this function:

Definition at line 51 of file ParaMEDMEMTest_InterpKernelDEC.cxx.

{
  testInterpKernelDEC_2D_("P0","P0");
}
void ParaMEDMEMTest::testInterpKernelDEC_2D_ ( const char *  srcMeth,
const char *  targetMeth 
) [private]

Definition at line 461 of file ParaMEDMEMTest_InterpKernelDEC.cxx.

{
  std::string srcM(srcMeth);
  std::string targetM(targetMeth);
  int size;
  int rank;
  MPI_Comm_size(MPI_COMM_WORLD,&size);
  MPI_Comm_rank(MPI_COMM_WORLD,&rank);

  //the test is meant to run on five processors
  if (size !=5) return ;
   
  int nproc_source = 3;
  set<int> self_procs;
  set<int> procs_source;
  set<int> procs_target;
  
  for (int i=0; i<nproc_source; i++)
    procs_source.insert(i);
  for (int i=nproc_source; i<size; i++)
    procs_target.insert(i);
  self_procs.insert(rank);
  
  ParaMEDMEM::CommInterface interface;
    
  ParaMEDMEM::ProcessorGroup* self_group = new ParaMEDMEM::MPIProcessorGroup(interface,self_procs);
  ParaMEDMEM::ProcessorGroup* target_group = new ParaMEDMEM::MPIProcessorGroup(interface,procs_target);
  ParaMEDMEM::ProcessorGroup* source_group = new ParaMEDMEM::MPIProcessorGroup(interface,procs_source);
  
  //loading the geometry for the source group

  ParaMEDMEM::InterpKernelDEC dec (*source_group,*target_group);

  ParaMEDMEM::MEDCouplingUMesh* mesh;
  ParaMEDMEM::ParaMESH* paramesh;
  ParaMEDMEM::ParaFIELD* parafield;
  ICoCo::Field* icocofield ;
  
  string filename_xml1              = getResourceFile("square1_split");
  string filename_xml2              = getResourceFile("square2_split");
  //string filename_seq_wr            = makeTmpFile("");
  //string filename_seq_med           = makeTmpFile("myWrField_seq_pointe221.med");
  
  // To remove tmp files from disk
  ParaMEDMEMTest_TmpFilesRemover aRemover;
  
  MPI_Barrier(MPI_COMM_WORLD);
  if (source_group->containsMyRank())
    {
      string master = filename_xml1;
      
      ostringstream strstream;
      strstream <<master<<rank+1<<".med";
      ostringstream meshname ;
      meshname<< "Mesh_2_"<< rank+1;
      
      mesh=MEDLoader::ReadUMeshFromFile(strstream.str().c_str(),meshname.str().c_str(),0);
      
    
      paramesh=new ParaMESH (mesh,*source_group,"source mesh");
    
      //      ParaMEDMEM::ParaSUPPORT* parasupport=new UnstructuredParaSUPPORT( support,*source_group);
      ParaMEDMEM::ComponentTopology comptopo;
      if(srcM=="P0")
        {
          parafield = new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo);
          parafield->getField()->setNature(ConservativeVolumic);
        }
      else
        parafield = new ParaFIELD(ON_NODES,NO_TIME,paramesh, comptopo);
      int nb_local;
      if(srcM=="P0")
        nb_local=mesh->getNumberOfCells();
      else
        nb_local=mesh->getNumberOfNodes();
      //      double * value= new double[nb_local];
      double *value=parafield->getField()->getArray()->getPointer();
      for(int ielem=0; ielem<nb_local;ielem++)
        value[ielem]=1.0;
    
      //      ICoCo::Field* icocofield=new ICoCo::MEDField(paramesh,parafield);
      icocofield=new ICoCo::MEDField((MEDCouplingUMesh *)paramesh->getCellMesh(),parafield->getField());
      dec.setMethod(srcMeth);
      dec.attachLocalField(icocofield);
    }
  
  //loading the geometry for the target group
  if (target_group->containsMyRank())
    {
      string master= filename_xml2;
      ostringstream strstream;
      strstream << master<<(rank-nproc_source+1)<<".med";
      ostringstream meshname ;
      meshname<< "Mesh_3_"<<rank-nproc_source+1;
      mesh = MEDLoader::ReadUMeshFromFile(strstream.str().c_str(),meshname.str().c_str(),0);
      
      paramesh=new ParaMESH (mesh,*target_group,"target mesh");
      //      ParaMEDMEM::ParaSUPPORT* parasupport=new UnstructuredParaSUPPORT(support,*target_group);
      ParaMEDMEM::ComponentTopology comptopo;
      if(targetM=="P0")
        {
          parafield = new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo);
          parafield->getField()->setNature(ConservativeVolumic);
        }
      else
        parafield = new ParaFIELD(ON_NODES,NO_TIME,paramesh, comptopo);
      int nb_local;
      if(targetM=="P0")
        nb_local=mesh->getNumberOfCells();
      else
        nb_local=mesh->getNumberOfNodes();
      //      double * value= new double[nb_local];
      double *value=parafield->getField()->getArray()->getPointer();
      for(int ielem=0; ielem<nb_local;ielem++)
        value[ielem]=0.0;
      //      ICoCo::Field* icocofield=new ICoCo::MEDField(paramesh,parafield);
      icocofield=new ICoCo::MEDField((MEDCouplingUMesh *)paramesh->getCellMesh(),parafield->getField());
      dec.setMethod(targetMeth);
      dec.attachLocalField(icocofield);
    }
    
  
  //attaching a DEC to the source group 
  double field_before_int;
  double field_after_int;
  
  if (source_group->containsMyRank())
    { 
      field_before_int = parafield->getVolumeIntegral(0,true);
      dec.synchronize();
      cout<<"DEC usage"<<endl;
      dec.setForcedRenormalization(false);

      dec.sendData();
      ParaMEDLoader::WriteParaMesh("./sourcesquareb",paramesh);
      if (source_group->myRank()==0)
        aRemover.Register("./sourcesquareb");
      ostringstream filename;
      filename<<"./sourcesquareb_"<<source_group->myRank()+1;
      aRemover.Register(filename.str().c_str());
      //MEDLoader::WriteField("./sourcesquareb",parafield->getField());
   
      dec.recvData();
      cout <<"writing"<<endl;
      ParaMEDLoader::WriteParaMesh("./sourcesquare",paramesh);
      if (source_group->myRank()==0)
        aRemover.Register("./sourcesquare");
      //MEDLoader::WriteField("./sourcesquare",parafield->getField());
      
     
      filename<<"./sourcesquare_"<<source_group->myRank()+1;
      aRemover.Register(filename.str().c_str());
      field_after_int = parafield->getVolumeIntegral(0,true);
      
      
      //      MPI_Bcast(&field_before_int,1,MPI_DOUBLE,0,MPI_COMM_WORLD);
      //       MPI_Bcast(&field_after_int,1,MPI_DOUBLE,0,MPI_COMM_WORLD);

      CPPUNIT_ASSERT_DOUBLES_EQUAL(field_before_int, field_after_int, 1e-6);
    
    }
  
  //attaching a DEC to the target group
  if (target_group->containsMyRank())
    {
      dec.synchronize();
      dec.setForcedRenormalization(false);

      dec.recvData();
      ParaMEDLoader::WriteParaMesh("./targetsquareb",paramesh);
      //MEDLoader::WriteField("./targetsquareb",parafield->getField());
      if (target_group->myRank()==0)
        aRemover.Register("./targetsquareb");
      ostringstream filename;
      filename<<"./targetsquareb_"<<target_group->myRank()+1;
      aRemover.Register(filename.str().c_str());
      dec.sendData();
      ParaMEDLoader::WriteParaMesh("./targetsquare",paramesh);
      //MEDLoader::WriteField("./targetsquare",parafield->getField());
      
      if (target_group->myRank()==0)
        aRemover.Register("./targetsquareb");
      
      filename<<"./targetsquareb_"<<target_group->myRank()+1;
      aRemover.Register(filename.str().c_str());
      //    double field_before_int, field_after_int;
      //       MPI_Bcast(&field_before_int,1,MPI_DOUBLE,0,MPI_COMM_WORLD);
      //       MPI_Bcast(&field_after_int,1,MPI_DOUBLE,0,MPI_COMM_WORLD);
      
      //      CPPUNIT_ASSERT_DOUBLES_EQUAL(field_before_int, field_after_int, 1e-6);
    
    }
  
  delete source_group;
  delete target_group;
  delete self_group;
  delete parafield;
  delete paramesh;
  mesh->decrRef();

  delete icocofield;

  MPI_Barrier(MPI_COMM_WORLD);
  cout << "end of InterpKernelDEC_2D test"<<endl;
}

Here is the call graph for this function:

Definition at line 260 of file ParaMEDMEMTest_InterpKernelDEC.cxx.

{
  int size;
  int rank;
  MPI_Comm_size(MPI_COMM_WORLD,&size);
  MPI_Comm_rank(MPI_COMM_WORLD,&rank);
  //
  if(size!=5)
    return ;
  int nproc_source = 3;
  set<int> self_procs;
  set<int> procs_source;
  set<int> procs_target;
  
  for (int i=0; i<nproc_source; i++)
    procs_source.insert(i);
  for (int i=nproc_source; i<size; i++)
    procs_target.insert(i);
  self_procs.insert(rank);
  //
  ParaMEDMEM::MEDCouplingUMesh *mesh=0;
  ParaMEDMEM::ParaMESH *paramesh=0;
  ParaMEDMEM::ParaFIELD *parafieldP0=0;
  //
  ParaMEDMEM::CommInterface interface;
  //
  ProcessorGroup* self_group = new ParaMEDMEM::MPIProcessorGroup(interface,self_procs);
  ProcessorGroup* target_group = new ParaMEDMEM::MPIProcessorGroup(interface,procs_target);
  ProcessorGroup* source_group = new ParaMEDMEM::MPIProcessorGroup(interface,procs_source);
  //
  MPI_Barrier(MPI_COMM_WORLD);
  if(source_group->containsMyRank())
    {
      if(rank==0)
        {
          double coords[8]={0.3,0.3,0.7,0.7, 0.9,0.9,1.0,1.0};
          int conn[4]={0,1,2,3};
          mesh=MEDCouplingUMesh::New("Source mesh Proc0",1);
          mesh->allocateCells(2);
          mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn);
          mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+2);
          mesh->finishInsertingCells();
          DataArrayDouble *myCoords=DataArrayDouble::New();
          myCoords->alloc(4,2);
          std::copy(coords,coords+8,myCoords->getPointer());
          mesh->setCoords(myCoords);
          myCoords->decrRef();
        }
      if(rank==1)
        {
          double coords[4]={0.7,0.7,0.9,0.9};
          int conn[2]={0,1};
          mesh=MEDCouplingUMesh::New("Source mesh Proc1",1);
          mesh->allocateCells(1);
          mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn);
          mesh->finishInsertingCells();
          DataArrayDouble *myCoords=DataArrayDouble::New();
          myCoords->alloc(2,2);
          std::copy(coords,coords+4,myCoords->getPointer());
          mesh->setCoords(myCoords);
          myCoords->decrRef();
        }
      if(rank==2)
        {
          double coords[4]={1.,1.,1.12,1.12};
          int conn[2]={0,1};
          mesh=MEDCouplingUMesh::New("Source mesh Proc2",1);
          mesh->allocateCells(1);
          mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn);
          mesh->finishInsertingCells();
          DataArrayDouble *myCoords=DataArrayDouble::New();
          myCoords->alloc(2,2);
          std::copy(coords,coords+4,myCoords->getPointer());
          mesh->setCoords(myCoords);
          myCoords->decrRef();
        }
      paramesh=new ParaMESH(mesh,*source_group,"source mesh");
      ParaMEDMEM::ComponentTopology comptopo;
      parafieldP0 = new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo);
      double *valueP0=parafieldP0->getField()->getArray()->getPointer();
      parafieldP0->getField()->setNature(ConservativeVolumic);
      if(rank==0)
        {
          valueP0[0]=7.; valueP0[1]=8.;
        }
      if(rank==1)
        {
          valueP0[0]=9.;
        }
      if(rank==2)
        {
          valueP0[0]=10.;
        }
    }
  else
    {
      const char targetMeshName[]="target mesh";
      if(rank==3)
        {
          double coords[4]={0.5,0.5,0.75,0.75};
          int conn[2]={0,1};
          mesh=MEDCouplingUMesh::New("Target mesh Proc3",1);
          mesh->allocateCells(1);
          mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn);
          mesh->finishInsertingCells();
          DataArrayDouble *myCoords=DataArrayDouble::New();
          myCoords->alloc(2,2);
          std::copy(coords,coords+4,myCoords->getPointer());
          mesh->setCoords(myCoords);
          myCoords->decrRef();
          paramesh=new ParaMESH(mesh,*target_group,targetMeshName);
        }
      if(rank==4)
        {
          double coords[4]={0.75,0.75,1.2,1.2};
          int conn[2]={0,1};
          mesh=MEDCouplingUMesh::New("Target mesh Proc4",1);
          mesh->allocateCells(1);
          mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn);
          mesh->finishInsertingCells();
          DataArrayDouble *myCoords=DataArrayDouble::New();
          myCoords->alloc(2,2);
          std::copy(coords,coords+4,myCoords->getPointer());
          mesh->setCoords(myCoords);
          myCoords->decrRef();
          paramesh=new ParaMESH(mesh,*target_group,targetMeshName);
        }
      ParaMEDMEM::ComponentTopology comptopo;
      parafieldP0 = new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo);
      parafieldP0->getField()->setNature(ConservativeVolumic);
    }
  // test 1
  ParaMEDMEM::InterpKernelDEC dec(*source_group,*target_group);
  if (source_group->containsMyRank())
    { 
      dec.setMethod("P0");
      dec.attachLocalField(parafieldP0);
      dec.synchronize();
      dec.setForcedRenormalization(false);
      dec.sendData();
      dec.recvData();
      const double *valueP0=parafieldP0->getField()->getArray()->getPointer();
      if(rank==0)
        {
          CPPUNIT_ASSERT_DOUBLES_EQUAL(7.4,valueP0[0],1e-7);
          CPPUNIT_ASSERT_DOUBLES_EQUAL(9.0540540540540544,valueP0[1],1e-7);
        }
      if(rank==1)
        {
          CPPUNIT_ASSERT_DOUBLES_EQUAL(8.64054054054054,valueP0[0],1e-7);
        }
      if(rank==2)
        {
          CPPUNIT_ASSERT_DOUBLES_EQUAL(9.0540540540540544,valueP0[0],1e-7);
        }
    }
  else
    {
      dec.setMethod("P0");
      dec.attachLocalField(parafieldP0);
      dec.synchronize();
      dec.setForcedRenormalization(false);
      dec.recvData();
      const double *res=parafieldP0->getField()->getArray()->getConstPointer();
      if(rank==3)
        {
          CPPUNIT_ASSERT_EQUAL(1,parafieldP0->getField()->getNumberOfTuples());
          CPPUNIT_ASSERT_EQUAL(1,parafieldP0->getField()->getNumberOfComponents());
          CPPUNIT_ASSERT_DOUBLES_EQUAL(7.4,res[0],1e-12);
        }
      if(rank==4)
        {
          CPPUNIT_ASSERT_EQUAL(1,parafieldP0->getField()->getNumberOfTuples());
          CPPUNIT_ASSERT_EQUAL(1,parafieldP0->getField()->getNumberOfComponents());
          CPPUNIT_ASSERT_DOUBLES_EQUAL(9.0540540540540526,res[0],1e-12);
        }
      dec.sendData();
    }
  //
  delete parafieldP0;
  mesh->decrRef();
  delete paramesh;
  delete self_group;
  delete target_group;
  delete source_group;
  //
  MPI_Barrier(MPI_COMM_WORLD);
}

Here is the call graph for this function:

Definition at line 66 of file ParaMEDMEMTest_InterpKernelDEC.cxx.

{
  //testInterpKernelDEC_2D_("P0","P1");
}

Definition at line 61 of file ParaMEDMEMTest_InterpKernelDEC.cxx.

{
  testInterpKernelDEC_3D_("P0","P0");
}
void ParaMEDMEMTest::testInterpKernelDEC_3D_ ( const char *  srcMeth,
const char *  targetMeth 
) [private]

Definition at line 824 of file ParaMEDMEMTest_InterpKernelDEC.cxx.

{
  std::string srcM(srcMeth);
  std::string targetM(targetMeth);
  int size;
  int rank;
  MPI_Comm_size(MPI_COMM_WORLD,&size);
  MPI_Comm_rank(MPI_COMM_WORLD,&rank);

  //the test is meant to run on five processors
  if (size !=3) return ;
   
  int nproc_source = 2;
  set<int> self_procs;
  set<int> procs_source;
  set<int> procs_target;
  
  for (int i=0; i<nproc_source; i++)
    procs_source.insert(i);
  for (int i=nproc_source; i<size; i++)
    procs_target.insert(i);
  self_procs.insert(rank);
  
  ParaMEDMEM::CommInterface interface;
    
  ParaMEDMEM::ProcessorGroup* self_group = new ParaMEDMEM::MPIProcessorGroup(interface,self_procs);
  ParaMEDMEM::ProcessorGroup* target_group = new ParaMEDMEM::MPIProcessorGroup(interface,procs_target);
  ParaMEDMEM::ProcessorGroup* source_group = new ParaMEDMEM::MPIProcessorGroup(interface,procs_source);
  
  //loading the geometry for the source group

  ParaMEDMEM::InterpKernelDEC dec (*source_group,*target_group);

  ParaMEDMEM::MEDCouplingUMesh* mesh;
  ParaMEDMEM::ParaMESH* paramesh;
  ParaMEDMEM::ParaFIELD* parafield;
  ICoCo::Field* icocofield ;
  
  string tmp_dir                    = getenv("TMP");
  if (tmp_dir == "")
    tmp_dir = "/tmp";
  string filename_xml1              = getResourceFile("Mesh3D_10_2d");
  string filename_xml2              = getResourceFile("Mesh3D_11");
  //string filename_seq_wr            = makeTmpFile("");
  //string filename_seq_med           = makeTmpFile("myWrField_seq_pointe221.med");
  
  // To remove tmp files from disk
  ParaMEDMEMTest_TmpFilesRemover aRemover;
  
  MPI_Barrier(MPI_COMM_WORLD);
  if (source_group->containsMyRank())
    {
      string master = filename_xml1;
      
      ostringstream strstream;
      strstream <<master<<rank+1<<".med";
      ostringstream meshname ;
      meshname<< "Mesh_3_"<< rank+1;
      
      mesh=MEDLoader::ReadUMeshFromFile(strstream.str().c_str(),meshname.str().c_str(),0);
      
    
      paramesh=new ParaMESH (mesh,*source_group,"source mesh");
    
      //      ParaMEDMEM::ParaSUPPORT* parasupport=new UnstructuredParaSUPPORT( support,*source_group);
      ParaMEDMEM::ComponentTopology comptopo;
      if(srcM=="P0")
        {
          parafield = new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo);
          parafield->getField()->setNature(ConservativeVolumic);
        }
      else
        parafield = new ParaFIELD(ON_NODES,NO_TIME,paramesh, comptopo);
      int nb_local;
      if(srcM=="P0")
        nb_local=mesh->getNumberOfCells();
      else
        nb_local=mesh->getNumberOfNodes();
      //      double * value= new double[nb_local];
      double *value=parafield->getField()->getArray()->getPointer();
      for(int ielem=0; ielem<nb_local;ielem++)
        value[ielem]=1.0;
    
      //      ICoCo::Field* icocofield=new ICoCo::MEDField(paramesh,parafield);
      icocofield=new ICoCo::MEDField((MEDCouplingUMesh *)paramesh->getCellMesh(),parafield->getField());
      dec.setMethod(srcMeth);
      dec.attachLocalField(icocofield);
    }
  
  //loading the geometry for the target group
  if (target_group->containsMyRank())
    {
      string master= filename_xml2;
      ostringstream strstream;
      strstream << master << ".med";
      ostringstream meshname ;
      meshname<< "Mesh_6";
      mesh = MEDLoader::ReadUMeshFromFile(strstream.str().c_str(),meshname.str().c_str(),0);
      
      paramesh=new ParaMESH (mesh,*target_group,"target mesh");
      //      ParaMEDMEM::ParaSUPPORT* parasupport=new UnstructuredParaSUPPORT(support,*target_group);
      ParaMEDMEM::ComponentTopology comptopo;
      if(targetM=="P0")
        {
          parafield = new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo);
          parafield->getField()->setNature(ConservativeVolumic);
        }
      else
        parafield = new ParaFIELD(ON_NODES,NO_TIME,paramesh, comptopo);
      int nb_local;
      if(targetM=="P0")
        nb_local=mesh->getNumberOfCells();
      else
        nb_local=mesh->getNumberOfNodes();
      //      double * value= new double[nb_local];
      double *value=parafield->getField()->getArray()->getPointer();
      for(int ielem=0; ielem<nb_local;ielem++)
        value[ielem]=0.0;
      //      ICoCo::Field* icocofield=new ICoCo::MEDField(paramesh,parafield);
      icocofield=new ICoCo::MEDField((MEDCouplingUMesh *)paramesh->getCellMesh(),parafield->getField());
      dec.setMethod(targetMeth);
      dec.attachLocalField(icocofield);
    }  
  //attaching a DEC to the source group 
  double field_before_int;
  double field_after_int;
  
  if (source_group->containsMyRank())
    { 
      field_before_int = parafield->getVolumeIntegral(0,true);
      dec.synchronize();
      cout<<"DEC usage"<<endl;
      dec.setForcedRenormalization(false);

      dec.sendData();
      ParaMEDLoader::WriteParaMesh("./sourcesquareb",paramesh);
      if (source_group->myRank()==0)
        aRemover.Register("./sourcesquareb");
      ostringstream filename;
      filename<<"./sourcesquareb_"<<source_group->myRank()+1;
      aRemover.Register(filename.str().c_str());
      //MEDLoader::WriteField("./sourcesquareb",parafield->getField());
   
      dec.recvData();
      cout <<"writing"<<endl;
      ParaMEDLoader::WriteParaMesh("./sourcesquare",paramesh);
      if (source_group->myRank()==0)
        aRemover.Register("./sourcesquare");
      //MEDLoader::WriteField("./sourcesquare",parafield->getField());
      
     
      filename<<"./sourcesquare_"<<source_group->myRank()+1;
      aRemover.Register(filename.str().c_str());
      field_after_int = parafield->getVolumeIntegral(0,true);

      CPPUNIT_ASSERT_DOUBLES_EQUAL(field_before_int, field_after_int, 1e-6);
    
    }
  
  //attaching a DEC to the target group
  if (target_group->containsMyRank())
    {
      dec.synchronize();
      dec.setForcedRenormalization(false);

      dec.recvData();
      ParaMEDLoader::WriteParaMesh("./targetsquareb",paramesh);
      //MEDLoader::WriteField("./targetsquareb",parafield->getField());
      if (target_group->myRank()==0)
        aRemover.Register("./targetsquareb");
      ostringstream filename;
      filename<<"./targetsquareb_"<<target_group->myRank()+1;
      aRemover.Register(filename.str().c_str());
      dec.sendData();
      ParaMEDLoader::WriteParaMesh("./targetsquare",paramesh);
      //MEDLoader::WriteField("./targetsquare",parafield->getField());
      
      if (target_group->myRank()==0)
        aRemover.Register("./targetsquareb");
      
      filename<<"./targetsquareb_"<<target_group->myRank()+1;
      aRemover.Register(filename.str().c_str());
    }
  delete source_group;
  delete target_group;
  delete self_group;
  delete parafield;
  delete paramesh;
  mesh->decrRef();

  delete icocofield;

  MPI_Barrier(MPI_COMM_WORLD);
  cout << "end of InterpKernelDEC_3D test"<<endl;
}

Here is the call graph for this function:

Definition at line 1076 of file ParaMEDMEMTest_InterpKernelDEC.cxx.

{
  //
  const double sourceCoordsAll[2][8]={{0.4,0.5,0.4,1.5,1.6,1.5,1.6,0.5},
                                      {0.3,-0.5,1.6,-0.5,1.6,-1.5,0.3,-1.5}};
  const double targetCoordsAll[3][16]={{0.7,1.45,0.7,1.65,0.9,1.65,0.9,1.45,  1.1,1.4,1.1,1.6,1.3,1.6,1.3,1.4},
                                       {0.7,-0.6,0.7,0.7,0.9,0.7,0.9,-0.6,  1.1,-0.7,1.1,0.6,1.3,0.6,1.3,-0.7},
                                       {0.7,-1.55,0.7,-1.35,0.9,-1.35,0.9,-1.55,  1.1,-1.65,1.1,-1.45,1.3,-1.45,1.3,-1.65}};
  int conn4All[8]={0,1,2,3,4,5,6,7};
  double targetResults[3][2]={{34.,34.},{38.333333333333336,42.666666666666664},{47.,47.}};
  double targetResults2[3][2]={{0.28333333333333344,0.56666666666666687},{1.8564102564102569,2.0128205128205132},{1.0846153846153845,0.36153846153846159}};
  double targetResults3[3][2]={{3.7777777777777781,7.5555555555555562},{24.511111111111113,26.355555555555558},{14.1,4.7}};
  double targetResults4[3][2]={{8.5,17},{8.8461538461538431, 9.8461538461538449},{35.25,11.75}};
  //
  int size;
  int rank;
  MPI_Comm_size(MPI_COMM_WORLD,&size);
  MPI_Comm_rank(MPI_COMM_WORLD,&rank);
  //
  if(size!=5)
    return ;
  int nproc_source = 2;
  set<int> self_procs;
  set<int> procs_source;
  set<int> procs_target;
  
  for (int i=0; i<nproc_source; i++)
    procs_source.insert(i);
  for (int i=nproc_source; i<size; i++)
    procs_target.insert(i);
  self_procs.insert(rank);
  //
  ParaMEDMEM::MEDCouplingUMesh *mesh=0;
  ParaMEDMEM::ParaMESH *paramesh=0;
  ParaMEDMEM::ParaFIELD* parafield=0;
  //
  ParaMEDMEM::CommInterface interface;
  //
  ProcessorGroup* self_group = new ParaMEDMEM::MPIProcessorGroup(interface,self_procs);
  ProcessorGroup* target_group = new ParaMEDMEM::MPIProcessorGroup(interface,procs_target);
  ProcessorGroup* source_group = new ParaMEDMEM::MPIProcessorGroup(interface,procs_source);
  //
  MPI_Barrier(MPI_COMM_WORLD);
  if(source_group->containsMyRank())
    {
      std::ostringstream stream; stream << "sourcemesh2D proc " << rank;
      mesh=MEDCouplingUMesh::New(stream.str().c_str(),2);
      mesh->allocateCells(2);
      mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn4All);
      mesh->finishInsertingCells();
      DataArrayDouble *myCoords=DataArrayDouble::New();
      myCoords->alloc(4,2);
      const double *sourceCoords=sourceCoordsAll[rank];
      std::copy(sourceCoords,sourceCoords+8,myCoords->getPointer());
      mesh->setCoords(myCoords);
      myCoords->decrRef();
      paramesh=new ParaMESH(mesh,*source_group,"source mesh");
      ParaMEDMEM::ComponentTopology comptopo;
      parafield = new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo);
      double *value=parafield->getField()->getArray()->getPointer();
      value[0]=34+13*((double)rank);
    }
  else
    {
      std::ostringstream stream; stream << "targetmesh2D proc " << rank-nproc_source;
      mesh=MEDCouplingUMesh::New(stream.str().c_str(),2);
      mesh->allocateCells(2);
      mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn4All);
      mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn4All+4);
      mesh->finishInsertingCells();
      DataArrayDouble *myCoords=DataArrayDouble::New();
      myCoords->alloc(8,2);
      const double *targetCoords=targetCoordsAll[rank-nproc_source];
      std::copy(targetCoords,targetCoords+16,myCoords->getPointer());
      mesh->setCoords(myCoords);
      myCoords->decrRef();
      paramesh=new ParaMESH (mesh,*target_group,"target mesh");
      ParaMEDMEM::ComponentTopology comptopo;
      parafield = new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo);
    }
  //test 1 - Conservative volumic
  ParaMEDMEM::InterpKernelDEC dec(*source_group,*target_group);
  parafield->getField()->setNature(ConservativeVolumic);
  if (source_group->containsMyRank())
    { 
      dec.setMethod("P0");
      dec.attachLocalField(parafield);
      dec.synchronize();
      dec.setForcedRenormalization(false);
      dec.sendData();
    }
  else
    {
      dec.setMethod("P0");
      dec.attachLocalField(parafield);
      dec.synchronize();
      dec.setForcedRenormalization(false);
      dec.recvData();
      const double *res=parafield->getField()->getArray()->getConstPointer();
      const double *expected=targetResults[rank-nproc_source];
      CPPUNIT_ASSERT_DOUBLES_EQUAL(expected[0],res[0],1e-13);
      CPPUNIT_ASSERT_DOUBLES_EQUAL(expected[1],res[1],1e-13);
    }
  //test 2 - Integral
  ParaMEDMEM::InterpKernelDEC dec2(*source_group,*target_group);
  parafield->getField()->setNature(Integral);
  if (source_group->containsMyRank())
    { 
      dec2.setMethod("P0");
      dec2.attachLocalField(parafield);
      dec2.synchronize();
      dec2.setForcedRenormalization(false);
      dec2.sendData();
    }
  else
    {
      dec2.setMethod("P0");
      dec2.attachLocalField(parafield);
      dec2.synchronize();
      dec2.setForcedRenormalization(false);
      dec2.recvData();
      const double *res=parafield->getField()->getArray()->getConstPointer();
      const double *expected=targetResults2[rank-nproc_source];
      CPPUNIT_ASSERT_DOUBLES_EQUAL(expected[0],res[0],1e-13);
      CPPUNIT_ASSERT_DOUBLES_EQUAL(expected[1],res[1],1e-13);
    }
  //test 3 - Integral with global constraint
  ParaMEDMEM::InterpKernelDEC dec3(*source_group,*target_group);
  parafield->getField()->setNature(IntegralGlobConstraint);
  if (source_group->containsMyRank())
    { 
      dec3.setMethod("P0");
      dec3.attachLocalField(parafield);
      dec3.synchronize();
      dec3.setForcedRenormalization(false);
      dec3.sendData();
    }
  else
    {
      dec3.setMethod("P0");
      dec3.attachLocalField(parafield);
      dec3.synchronize();
      dec3.setForcedRenormalization(false);
      dec3.recvData();
      const double *res=parafield->getField()->getArray()->getConstPointer();
      const double *expected=targetResults3[rank-nproc_source];
      CPPUNIT_ASSERT_DOUBLES_EQUAL(expected[0],res[0],1e-13);
      CPPUNIT_ASSERT_DOUBLES_EQUAL(expected[1],res[1],1e-13);
    }
  //test 4 - RevIntegral
  ParaMEDMEM::InterpKernelDEC dec4(*source_group,*target_group);
  parafield->getField()->setNature(RevIntegral);
  if (source_group->containsMyRank())
    { 
      dec4.setMethod("P0");
      dec4.attachLocalField(parafield);
      dec4.synchronize();
      dec4.setForcedRenormalization(false);
      dec4.sendData();
    }
  else
    {
      dec4.setMethod("P0");
      dec4.attachLocalField(parafield);
      dec4.synchronize();
      dec4.setForcedRenormalization(false);
      dec4.recvData();
      const double *res=parafield->getField()->getArray()->getConstPointer();
      const double *expected=targetResults4[rank-nproc_source];
      CPPUNIT_ASSERT_DOUBLES_EQUAL(expected[0],res[0],1e-13);
      CPPUNIT_ASSERT_DOUBLES_EQUAL(expected[1],res[1],1e-13);
    }
  //test 5 - Conservative volumic reversed
  ParaMEDMEM::InterpKernelDEC dec5(*source_group,*target_group);
  parafield->getField()->setNature(ConservativeVolumic);
  if (source_group->containsMyRank())
    { 
      dec5.setMethod("P0");
      dec5.attachLocalField(parafield);
      dec5.synchronize();
      dec5.setForcedRenormalization(false);
      dec5.recvData();
      const double *res=parafield->getField()->getArray()->getConstPointer();
      CPPUNIT_ASSERT_EQUAL(1,parafield->getField()->getNumberOfTuples());
      const double expected[]={37.8518518518519,43.5333333333333};
      CPPUNIT_ASSERT_DOUBLES_EQUAL(expected[rank],res[0],1e-13);
    }
  else
    {
      dec5.setMethod("P0");
      dec5.attachLocalField(parafield);
      dec5.synchronize();
      dec5.setForcedRenormalization(false);
      double *res=parafield->getField()->getArray()->getPointer();
      const double *toSet=targetResults[rank-nproc_source];
      res[0]=toSet[0];
      res[1]=toSet[1];
      dec5.sendData();
    }
  //test 6 - Integral reversed
  ParaMEDMEM::InterpKernelDEC dec6(*source_group,*target_group);
  parafield->getField()->setNature(Integral);
  if (source_group->containsMyRank())
    { 
      dec6.setMethod("P0");
      dec6.attachLocalField(parafield);
      dec6.synchronize();
      dec6.setForcedRenormalization(false);
      dec6.recvData();
      const double *res=parafield->getField()->getArray()->getConstPointer();
      CPPUNIT_ASSERT_EQUAL(1,parafield->getField()->getNumberOfTuples());
      const double expected[]={0.794600591715977,1.35631163708087};
      CPPUNIT_ASSERT_DOUBLES_EQUAL(expected[rank],res[0],1e-13);
    }
  else
    {
      dec6.setMethod("P0");
      dec6.attachLocalField(parafield);
      dec6.synchronize();
      dec6.setForcedRenormalization(false);
      double *res=parafield->getField()->getArray()->getPointer();
      const double *toSet=targetResults2[rank-nproc_source];
      res[0]=toSet[0];
      res[1]=toSet[1];
      dec6.sendData();
    }
  //test 7 - Integral with global constraint reversed
  ParaMEDMEM::InterpKernelDEC dec7(*source_group,*target_group);
  parafield->getField()->setNature(IntegralGlobConstraint);
  if (source_group->containsMyRank())
    { 
      dec7.setMethod("P0");
      dec7.attachLocalField(parafield);
      dec7.synchronize();
      dec7.setForcedRenormalization(false);
      dec7.recvData();
      const double *res=parafield->getField()->getArray()->getConstPointer();
      CPPUNIT_ASSERT_EQUAL(1,parafield->getField()->getNumberOfTuples());
      const double expected[]={36.4592592592593,44.5407407407407};
      CPPUNIT_ASSERT_DOUBLES_EQUAL(expected[rank],res[0],1e-13);
    }
  else
    {
      dec7.setMethod("P0");
      dec7.attachLocalField(parafield);
      dec7.synchronize();
      dec7.setForcedRenormalization(false);
      double *res=parafield->getField()->getArray()->getPointer();
      const double *toSet=targetResults3[rank-nproc_source];
      res[0]=toSet[0];
      res[1]=toSet[1];
      dec7.sendData();
    }
  //test 8 - Integral with RevIntegral reversed
  ParaMEDMEM::InterpKernelDEC dec8(*source_group,*target_group);
  parafield->getField()->setNature(RevIntegral);
  if (source_group->containsMyRank())
    { 
      dec8.setMethod("P0");
      dec8.attachLocalField(parafield);
      dec8.synchronize();
      dec8.setForcedRenormalization(false);
      dec8.recvData();
      const double *res=parafield->getField()->getArray()->getConstPointer();
      CPPUNIT_ASSERT_EQUAL(1,parafield->getField()->getNumberOfTuples());
      const double expected[]={0.81314102564102553,1.3428994082840233};
      CPPUNIT_ASSERT_DOUBLES_EQUAL(expected[rank],res[0],1e-13);
    }
  else
    {
      dec8.setMethod("P0");
      dec8.attachLocalField(parafield);
      dec8.synchronize();
      dec8.setForcedRenormalization(false);
      double *res=parafield->getField()->getArray()->getPointer();
      const double *toSet=targetResults4[rank-nproc_source];
      res[0]=toSet[0];
      res[1]=toSet[1];
      dec8.sendData();
    }
  //
  delete parafield;
  mesh->decrRef();
  delete paramesh;
  delete self_group;
  delete target_group;
  delete source_group;
  //
  MPI_Barrier(MPI_COMM_WORLD);
}

Here is the call graph for this function:

Definition at line 1367 of file ParaMEDMEMTest_InterpKernelDEC.cxx.

{
  int size;
  int rank;
  MPI_Comm_size(MPI_COMM_WORLD,&size);
  MPI_Comm_rank(MPI_COMM_WORLD,&rank);
  //
  if(size!=5)
    return ;
  int nproc_source = 2;
  set<int> self_procs;
  set<int> procs_source;
  set<int> procs_target;
  
  for (int i=0; i<nproc_source; i++)
    procs_source.insert(i);
  for (int i=nproc_source; i<size; i++)
    procs_target.insert(i);
  self_procs.insert(rank);
  //
  ParaMEDMEM::MEDCouplingUMesh *mesh=0;
  ParaMEDMEM::ParaMESH *paramesh=0;
  ParaMEDMEM::ParaFIELD *parafieldP0=0,*parafieldP1=0;
  //
  ParaMEDMEM::CommInterface interface;
  //
  ProcessorGroup* self_group = new ParaMEDMEM::MPIProcessorGroup(interface,self_procs);
  ProcessorGroup* target_group = new ParaMEDMEM::MPIProcessorGroup(interface,procs_target);
  ProcessorGroup* source_group = new ParaMEDMEM::MPIProcessorGroup(interface,procs_source);
  //
  MPI_Barrier(MPI_COMM_WORLD);
  if(source_group->containsMyRank())
    {
      if(rank==0)
        {
          double coords[6]={-0.3,-0.3, 0.7,0.7, 0.7,-0.3};
          int conn[3]={0,1,2};
          //int globalNode[3]={1,2,0};
          mesh=MEDCouplingUMesh::New("Source mesh Proc0",2);
          mesh->allocateCells(1);
          mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,conn);
          mesh->finishInsertingCells();
          DataArrayDouble *myCoords=DataArrayDouble::New();
          myCoords->alloc(3,2);
          std::copy(coords,coords+6,myCoords->getPointer());
          mesh->setCoords(myCoords);
          myCoords->decrRef();
        }
      if(rank==1)
        {
          double coords[6]={-0.3,-0.3, -0.3,0.7, 0.7,0.7};
          int conn[3]={0,1,2};
          //int globalNode[3]={1,3,2};
          mesh=MEDCouplingUMesh::New("Source mesh Proc1",2);
          mesh->allocateCells(1);
          mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,conn);
          mesh->finishInsertingCells();
          DataArrayDouble *myCoords=DataArrayDouble::New();
          myCoords->alloc(3,2);
          std::copy(coords,coords+6,myCoords->getPointer());
          mesh->setCoords(myCoords);
          myCoords->decrRef();
        }
      paramesh=new ParaMESH(mesh,*source_group,"source mesh");
      ParaMEDMEM::ComponentTopology comptopo;
      parafieldP0 = new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo);
      parafieldP1 = new ParaFIELD(ON_NODES,NO_TIME,paramesh, comptopo);
      double *valueP0=parafieldP0->getField()->getArray()->getPointer();
      double *valueP1=parafieldP1->getField()->getArray()->getPointer();
      parafieldP0->getField()->setNature(ConservativeVolumic);
      parafieldP1->getField()->setNature(ConservativeVolumic);
      if(rank==0)
        {
          valueP0[0]=31.;
          valueP1[0]=34.; valueP1[1]=77.; valueP1[2]=53.;
        }
      if(rank==1)
        {
          valueP0[0]=47.;
          valueP1[0]=34.; valueP1[1]=57.; valueP1[2]=77.;
        }
    }
  else
    {
      const char targetMeshName[]="target mesh";
      if(rank==2)
        {
          double coords[10]={-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2 };
          int conn[7]={0,3,4,1, 1,4,2};
          //int globalNode[5]={4,3,0,2,1};
          mesh=MEDCouplingUMesh::New("Target mesh Proc2",2);
          mesh->allocateCells(2);
          mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn);
          mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,conn+4);
          mesh->finishInsertingCells();
          DataArrayDouble *myCoords=DataArrayDouble::New();
          myCoords->alloc(5,2);
          std::copy(coords,coords+10,myCoords->getPointer());
          mesh->setCoords(myCoords);
          myCoords->decrRef();
          paramesh=new ParaMESH(mesh,*target_group,targetMeshName);
          DataArrayInt *da=DataArrayInt::New();
          const int globalNumberingP2[5]={0,1,2,3,4};
          da->useArray(globalNumberingP2,false,CPP_DEALLOC,5,1);
          paramesh->setNodeGlobal(da);
          da->decrRef();
        }
      if(rank==3)
        {
          double coords[6]={0.2,0.2, 0.7,-0.3, 0.7,0.2};
          int conn[3]={0,2,1};
          //int globalNode[3]={1,0,5};
          mesh=MEDCouplingUMesh::New("Target mesh Proc3",2);
          mesh->allocateCells(1);
          mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,conn);
          mesh->finishInsertingCells();
          DataArrayDouble *myCoords=DataArrayDouble::New();
          myCoords->alloc(3,2);
          std::copy(coords,coords+6,myCoords->getPointer());
          mesh->setCoords(myCoords);
          myCoords->decrRef();
          paramesh=new ParaMESH(mesh,*target_group,targetMeshName);
          DataArrayInt *da=DataArrayInt::New();
          const int globalNumberingP3[3]={4,2,5};
          da->useArray(globalNumberingP3,false,CPP_DEALLOC,3,1);
          paramesh->setNodeGlobal(da);
          da->decrRef();
        }
      if(rank==4)
        {
          double coords[12]={-0.3,0.2, -0.3,0.7, 0.2,0.7, 0.2,0.2, 0.7,0.7, 0.7,0.2};
          int conn[8]={0,1,2,3, 3,2,4,5};
          //int globalNode[6]={2,6,7,1,8,5};
          mesh=MEDCouplingUMesh::New("Target mesh Proc4",2);
          mesh->allocateCells(2);
          mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn);
          mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+4);
          mesh->finishInsertingCells();
          DataArrayDouble *myCoords=DataArrayDouble::New();
          myCoords->alloc(6,2);
          std::copy(coords,coords+12,myCoords->getPointer());
          mesh->setCoords(myCoords);
          myCoords->decrRef();
          paramesh=new ParaMESH(mesh,*target_group,targetMeshName);
          DataArrayInt *da=DataArrayInt::New();
          const int globalNumberingP4[6]={3,6,7,4,8,5};
          da->useArray(globalNumberingP4,false,CPP_DEALLOC,6,1);
          paramesh->setNodeGlobal(da);
          da->decrRef();
        }
      ParaMEDMEM::ComponentTopology comptopo;
      parafieldP0 = new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo);
      parafieldP1 = new ParaFIELD(ON_NODES,NO_TIME,paramesh, comptopo);
      parafieldP0->getField()->setNature(ConservativeVolumic);
      parafieldP1->getField()->setNature(ConservativeVolumic);
    }
  // test 1 - P0 P1
  ParaMEDMEM::InterpKernelDEC dec(*source_group,*target_group);
  if (source_group->containsMyRank())
    { 
      dec.setMethod("P0");
      dec.attachLocalField(parafieldP0);
      dec.synchronize();
      dec.setForcedRenormalization(false);
      dec.sendData();
      dec.recvData();
      const double *valueP0=parafieldP0->getField()->getArray()->getPointer();
      if(rank==0)
        {
          CPPUNIT_ASSERT_DOUBLES_EQUAL(34.42857143,valueP0[0],1e-7);
        }
      if(rank==1)
        {
          CPPUNIT_ASSERT_DOUBLES_EQUAL(44.,valueP0[0],1e-7);
        }
    }
  else
    {
      dec.setMethod("P1");
      dec.attachLocalField(parafieldP1);
      dec.synchronize();
      dec.setForcedRenormalization(false);
      dec.recvData();
      const double *res=parafieldP1->getField()->getArray()->getConstPointer();
      if(rank==2)
        {
          const double expectP2[5]={39.0, 31.0, 31.0, 47.0, 39.0};
          CPPUNIT_ASSERT_EQUAL(5,parafieldP1->getField()->getNumberOfTuples());
          CPPUNIT_ASSERT_EQUAL(1,parafieldP1->getField()->getNumberOfComponents());
          for(int kk=0;kk<5;kk++)
            CPPUNIT_ASSERT_DOUBLES_EQUAL(expectP2[kk],res[kk],1e-12);
        }
      if(rank==3)
        {
          const double expectP3[3]={39.0, 31.0, 31.0};
          CPPUNIT_ASSERT_EQUAL(3,parafieldP1->getField()->getNumberOfTuples());
          CPPUNIT_ASSERT_EQUAL(1,parafieldP1->getField()->getNumberOfComponents());
          for(int kk=0;kk<3;kk++)
            CPPUNIT_ASSERT_DOUBLES_EQUAL(expectP3[kk],res[kk],1e-12);
        }
      if(rank==4)
        {
          const double expectP4[6]={47.0, 47.0, 47.0, 39.0, 39.0, 31.0};
          CPPUNIT_ASSERT_EQUAL(6,parafieldP1->getField()->getNumberOfTuples());
          CPPUNIT_ASSERT_EQUAL(1,parafieldP1->getField()->getNumberOfComponents());
          for(int kk=0;kk<6;kk++)
            CPPUNIT_ASSERT_DOUBLES_EQUAL(expectP4[kk],res[kk],1e-12);
        }
      dec.sendData();
    }
  //
  delete parafieldP0;
  delete parafieldP1;
  mesh->decrRef();
  delete paramesh;
  delete self_group;
  delete target_group;
  delete source_group;
  //
  MPI_Barrier(MPI_COMM_WORLD);
}

Here is the call graph for this function:

Definition at line 1814 of file ParaMEDMEMTest_InterpKernelDEC.cxx.

{
  int size;
  int rank;
  MPI_Comm_size(MPI_COMM_WORLD,&size);
  MPI_Comm_rank(MPI_COMM_WORLD,&rank);
  //
  if(size!=3)
    return ;
  set<int> procs_source;
  set<int> procs_target;
  //
  procs_source.insert(0);
  procs_target.insert(1);
  //
  ParaMEDMEM::MEDCouplingUMesh *mesh=0;
  ParaMEDMEM::ParaMESH *paramesh=0;
  ParaMEDMEM::ParaFIELD *parafield=0;
  //
  ParaMEDMEM::CommInterface interface;
  //
  MPI_Barrier(MPI_COMM_WORLD);
  double targetCoords[8]={ 0.,0., 1., 0., 0., 1., 1., 1. };
  CommInterface comm;
  int grpIds[2]={0,1};
  MPI_Group grp,group_world;
  comm.commGroup(MPI_COMM_WORLD,&group_world);
  comm.groupIncl(group_world,2,grpIds,&grp);
  MPI_Comm partialComm;
  comm.commCreate(MPI_COMM_WORLD,grp,&partialComm);
  //
  ProcessorGroup* target_group=0;
  ProcessorGroup* source_group=0;
  //
  ParaMEDMEM::InterpKernelDEC *dec=0;
  if(rank==0 || rank==1)
    {
      target_group = new ParaMEDMEM::MPIProcessorGroup(interface,procs_target,partialComm);
      source_group = new ParaMEDMEM::MPIProcessorGroup(interface,procs_source,partialComm);
      if(source_group->containsMyRank())
        {    
          mesh=MEDCouplingUMesh::New();
          mesh->setMeshDimension(2);
          DataArrayDouble *myCoords=DataArrayDouble::New();
          myCoords->alloc(4,2);
          std::copy(targetCoords,targetCoords+8,myCoords->getPointer());
          mesh->setCoords(myCoords);
          myCoords->decrRef();
          int targetConn[4]={0,2,3,1};
          mesh->allocateCells(1);
          mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn);
          mesh->finishInsertingCells();
          ParaMEDMEM::ComponentTopology comptopo;
          paramesh=new ParaMESH(mesh,*source_group,"source mesh");
          parafield=new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo);
          parafield->getField()->setNature(ConservativeVolumic);
          double *vals=parafield->getField()->getArray()->getPointer();
          vals[0]=7.;
          dec=new ParaMEDMEM::InterpKernelDEC(*source_group,*target_group);
          dec->attachLocalField(parafield);
          dec->synchronize();
          dec->sendData();
          dec->recvData();
        }
      else
        {
          mesh=MEDCouplingUMesh::New();
          mesh->setMeshDimension(2);
          DataArrayDouble *myCoords=DataArrayDouble::New();
          myCoords->alloc(4,2);
          std::copy(targetCoords,targetCoords+8,myCoords->getPointer());
          mesh->setCoords(myCoords);
          myCoords->decrRef();
          int targetConn[6]={0,2,1,2,3,1};
          mesh->allocateCells(2);
          mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn);
          mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+3);
          mesh->finishInsertingCells();
          ParaMEDMEM::ComponentTopology comptopo;
          paramesh=new ParaMESH(mesh,*target_group,"target mesh");
          parafield=new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo);
          parafield->getField()->setNature(ConservativeVolumic);
          dec=new ParaMEDMEM::InterpKernelDEC(*source_group,*target_group);
          dec->attachLocalField(parafield);
          dec->synchronize();
          dec->recvData();
          dec->sendData();
        }
    }
  delete parafield;
  delete paramesh;
  if(mesh)
    mesh->decrRef();
  delete target_group;
  delete source_group;
  delete dec;
  MPI_Barrier(MPI_COMM_WORLD);
}

Here is the call graph for this function:

Definition at line 257 of file ParaMEDMEMTest_MEDLoader.cxx.

{
  string fileName=getResourceFile("polygones.med");
  vector<string> meshNames=MEDLoader::GetMeshNames(fileName.c_str());
  CPPUNIT_ASSERT_EQUAL(1,(int)meshNames.size());
  CPPUNIT_ASSERT(meshNames[0]=="Bord");
  MEDCouplingUMesh *mesh=MEDLoader::ReadUMeshFromFile(fileName.c_str(),meshNames[0].c_str(),0);
  mesh->checkCoherency();
  CPPUNIT_ASSERT_EQUAL(3,mesh->getSpaceDimension());
  CPPUNIT_ASSERT_EQUAL(2,mesh->getMeshDimension());
  CPPUNIT_ASSERT_EQUAL(538,mesh->getNumberOfCells());
  CPPUNIT_ASSERT_EQUAL(579,mesh->getNumberOfNodes());
  CPPUNIT_ASSERT_EQUAL(2,(int)mesh->getAllTypes().size());
  for(int i=0;i<514;i++)
    CPPUNIT_ASSERT_EQUAL(NORM_QUAD4,mesh->getTypeOfCell(i));
  for(int i=514;i<538;i++)
    CPPUNIT_ASSERT_EQUAL(NORM_POLYGON,mesh->getTypeOfCell(i));
  CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,std::accumulate(mesh->getCoords()->getPointer(),mesh->getCoords()->getPointer()+1737,0),1e-12);
  const double expectedVals1[12]={1.4851585216522212,-0.5,0.,1.4851585216522212,-0.4,0.,1.4851585216522212,-0.3,0., 1.5741585216522211, -0.5, 0. };
  double diffValue1[12];
  std::transform(mesh->getCoords()->getPointer(),mesh->getCoords()->getPointer()+12,expectedVals1,diffValue1,std::minus<double>());
  CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,*std::max_element(diffValue1,diffValue1+12),1e-12);
  CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,*std::min_element(diffValue1,diffValue1+12),1e-12);
  CPPUNIT_ASSERT_EQUAL(2768,mesh->getNodalConnectivity()->getNbOfElems());
  CPPUNIT_ASSERT_EQUAL(651050,std::accumulate(mesh->getNodalConnectivity()->getPointer(),mesh->getNodalConnectivity()->getPointer()+2768,0));
  CPPUNIT_ASSERT_EQUAL(725943,std::accumulate(mesh->getNodalConnectivityIndex()->getPointer(),mesh->getNodalConnectivityIndex()->getPointer()+539,0));
  mesh->decrRef();
  //
  std::vector<std::string> fieldsName=MEDLoader::GetCellFieldNamesOnMesh(fileName.c_str(),meshNames[0].c_str());
  CPPUNIT_ASSERT_EQUAL(3,(int)fieldsName.size());
  CPPUNIT_ASSERT(fieldsName[0]=="bord_:_distorsion");
  CPPUNIT_ASSERT(fieldsName[1]=="bord_:_familles");
  CPPUNIT_ASSERT(fieldsName[2]=="bord_:_non-ortho");
  std::vector<std::pair<int,int> > its0=MEDLoader::GetCellFieldIterations(fileName.c_str(),meshNames[0].c_str(),fieldsName[0].c_str());
  CPPUNIT_ASSERT_EQUAL(1,(int)its0.size());
  MEDCouplingFieldDouble *field=MEDLoader::ReadFieldCell(fileName.c_str(),meshNames[0].c_str(),0,fieldsName[0].c_str(),its0[0].first,its0[0].second);
  field->checkCoherency();
  CPPUNIT_ASSERT(field->getName()==fieldsName[0]);
  CPPUNIT_ASSERT_EQUAL(1,field->getNumberOfComponents());
  CPPUNIT_ASSERT_EQUAL(538,field->getNumberOfTuples());
  const MEDCouplingUMesh *constMesh=dynamic_cast<const MEDCouplingUMesh *>(field->getMesh());
  CPPUNIT_ASSERT(constMesh);
  CPPUNIT_ASSERT_EQUAL(3,constMesh->getSpaceDimension());
  CPPUNIT_ASSERT_EQUAL(2,constMesh->getMeshDimension());
  CPPUNIT_ASSERT_EQUAL(538,constMesh->getNumberOfCells());
  CPPUNIT_ASSERT_EQUAL(579,constMesh->getNumberOfNodes());
  CPPUNIT_ASSERT_EQUAL(2,(int)constMesh->getAllTypes().size());
  for(int i=0;i<514;i++)
    CPPUNIT_ASSERT_EQUAL(NORM_QUAD4,constMesh->getTypeOfCell(i));
  for(int i=514;i<538;i++)
    CPPUNIT_ASSERT_EQUAL(NORM_POLYGON,constMesh->getTypeOfCell(i));
  CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,std::accumulate(constMesh->getCoords()->getConstPointer(),constMesh->getCoords()->getConstPointer()+1737,0),1e-12);
  std::transform(constMesh->getCoords()->getConstPointer(),constMesh->getCoords()->getConstPointer()+12,expectedVals1,diffValue1,std::minus<double>());
  CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,*std::max_element(diffValue1,diffValue1+12),1e-12);
  CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,*std::min_element(diffValue1,diffValue1+12),1e-12);
  CPPUNIT_ASSERT_EQUAL(2768,constMesh->getNodalConnectivity()->getNbOfElems());
  CPPUNIT_ASSERT_EQUAL(651050,std::accumulate(constMesh->getNodalConnectivity()->getConstPointer(),constMesh->getNodalConnectivity()->getConstPointer()+2768,0));
  CPPUNIT_ASSERT_EQUAL(725943,std::accumulate(constMesh->getNodalConnectivityIndex()->getConstPointer(),constMesh->getNodalConnectivityIndex()->getConstPointer()+539,0));
  const double *values=field->getArray()->getPointer();
  CPPUNIT_ASSERT_DOUBLES_EQUAL(2.87214203182918,std::accumulate(values,values+538,0.),1e-12);
  field->decrRef();
}

Here is the call graph for this function:

Definition at line 320 of file ParaMEDMEMTest_MEDLoader.cxx.

{
  string fileName=getResourceFile("poly3D.med");
  vector<string> meshNames=MEDLoader::GetMeshNames(fileName.c_str());
  CPPUNIT_ASSERT_EQUAL(1,(int)meshNames.size());
  CPPUNIT_ASSERT(meshNames[0]=="poly3D");
  MEDCouplingUMesh *mesh=MEDLoader::ReadUMeshFromFile(fileName.c_str(),meshNames[0].c_str(),0);
  mesh->checkCoherency();
  CPPUNIT_ASSERT_EQUAL(3,mesh->getSpaceDimension());
  CPPUNIT_ASSERT_EQUAL(3,mesh->getMeshDimension());
  CPPUNIT_ASSERT_EQUAL(3,mesh->getNumberOfCells());
  CPPUNIT_ASSERT_EQUAL(19,mesh->getNumberOfNodes());
  CPPUNIT_ASSERT_EQUAL(2,(int)mesh->getAllTypes().size());
  CPPUNIT_ASSERT_EQUAL(NORM_TETRA4,mesh->getTypeOfCell(0));
  CPPUNIT_ASSERT_EQUAL(NORM_POLYHED,mesh->getTypeOfCell(1));
  CPPUNIT_ASSERT_EQUAL(NORM_POLYHED,mesh->getTypeOfCell(2));
  CPPUNIT_ASSERT_EQUAL(98,mesh->getNodalConnectivity()->getNbOfElems());
  CPPUNIT_ASSERT_EQUAL(725,std::accumulate(mesh->getNodalConnectivity()->getPointer(),mesh->getNodalConnectivity()->getPointer()+98,0));
  CPPUNIT_ASSERT_DOUBLES_EQUAL(110.,std::accumulate(mesh->getCoords()->getPointer(),mesh->getCoords()->getPointer()+57,0),1e-12);
  CPPUNIT_ASSERT_EQUAL(155,std::accumulate(mesh->getNodalConnectivityIndex()->getPointer(),mesh->getNodalConnectivityIndex()->getPointer()+4,0));
  mesh->decrRef();
  //
  mesh=MEDLoader::ReadUMeshFromFile(fileName.c_str(),meshNames[0].c_str(),-1);
  mesh->checkCoherency();
  CPPUNIT_ASSERT_EQUAL(3,mesh->getSpaceDimension());
  CPPUNIT_ASSERT_EQUAL(2,mesh->getMeshDimension());
  CPPUNIT_ASSERT_EQUAL(17,mesh->getNumberOfCells());
  CPPUNIT_ASSERT_EQUAL(19,mesh->getNumberOfNodes());
  CPPUNIT_ASSERT_EQUAL(3,(int)mesh->getAllTypes().size());
  CPPUNIT_ASSERT_EQUAL(NORM_POLYGON,mesh->getTypeOfCell(0));
  CPPUNIT_ASSERT_EQUAL(NORM_QUAD4,mesh->getTypeOfCell(1));
  CPPUNIT_ASSERT_EQUAL(NORM_QUAD4,mesh->getTypeOfCell(2));
  CPPUNIT_ASSERT_EQUAL(NORM_QUAD4,mesh->getTypeOfCell(3));
  CPPUNIT_ASSERT_EQUAL(NORM_QUAD4,mesh->getTypeOfCell(4));
  CPPUNIT_ASSERT_EQUAL(NORM_QUAD4,mesh->getTypeOfCell(5));
  CPPUNIT_ASSERT_EQUAL(NORM_QUAD4,mesh->getTypeOfCell(6));
  CPPUNIT_ASSERT_EQUAL(NORM_TRI3,mesh->getTypeOfCell(7));
  CPPUNIT_ASSERT_EQUAL(NORM_POLYGON,mesh->getTypeOfCell(8));
  CPPUNIT_ASSERT_EQUAL(NORM_POLYGON,mesh->getTypeOfCell(9));
  CPPUNIT_ASSERT_EQUAL(NORM_QUAD4,mesh->getTypeOfCell(10));
  CPPUNIT_ASSERT_EQUAL(NORM_TRI3,mesh->getTypeOfCell(11));
  CPPUNIT_ASSERT_EQUAL(NORM_TRI3,mesh->getTypeOfCell(12));
  CPPUNIT_ASSERT_EQUAL(NORM_TRI3,mesh->getTypeOfCell(13));
  CPPUNIT_ASSERT_EQUAL(NORM_TRI3,mesh->getTypeOfCell(14));
  CPPUNIT_ASSERT_EQUAL(NORM_QUAD4,mesh->getTypeOfCell(15));
  CPPUNIT_ASSERT_EQUAL(NORM_TRI3,mesh->getTypeOfCell(16));
  CPPUNIT_ASSERT_DOUBLES_EQUAL(110.,std::accumulate(mesh->getCoords()->getPointer(),mesh->getCoords()->getPointer()+57,0),1e-12);
  CPPUNIT_ASSERT_EQUAL(83,mesh->getNodalConnectivity()->getNbOfElems());
  CPPUNIT_ASSERT_EQUAL(619,std::accumulate(mesh->getNodalConnectivity()->getPointer(),mesh->getNodalConnectivity()->getPointer()+83,0));
  mesh->decrRef();
  //
  vector<string> families=MEDLoader::GetMeshFamiliesNames(fileName.c_str(),meshNames[0].c_str());
  CPPUNIT_ASSERT_EQUAL(4,(int)families.size());
  CPPUNIT_ASSERT(families[0]=="FAMILLE_FACE_POLYGONS3");
  CPPUNIT_ASSERT(families[1]=="FAMILLE_FACE_QUAD41");
  CPPUNIT_ASSERT(families[2]=="FAMILLE_FACE_TRIA32");
  CPPUNIT_ASSERT(families[3]=="FAMILLE_ZERO");
  vector<string> families2;
  families2.push_back(families[0]);
  mesh=MEDLoader::ReadUMeshFromFamilies(fileName.c_str(),meshNames[0].c_str(),-1,families2);
  mesh->checkCoherency();
  CPPUNIT_ASSERT_EQUAL(3,mesh->getSpaceDimension());
  CPPUNIT_ASSERT_EQUAL(2,mesh->getMeshDimension());
  CPPUNIT_ASSERT_EQUAL(3,mesh->getNumberOfCells());
  CPPUNIT_ASSERT_EQUAL(19,mesh->getNumberOfNodes());
  CPPUNIT_ASSERT_EQUAL(1,(int)mesh->getAllTypes().size());
  for(int i=0;i<3;i++)
    CPPUNIT_ASSERT_EQUAL(NORM_POLYGON,mesh->getTypeOfCell(i));
  CPPUNIT_ASSERT_EQUAL(19,mesh->getNodalConnectivity()->getNbOfElems());
  CPPUNIT_ASSERT_EQUAL(117,std::accumulate(mesh->getNodalConnectivity()->getPointer(),mesh->getNodalConnectivity()->getPointer()+19,0));
  mesh->decrRef();
  //
  mesh=MEDLoader::ReadUMeshFromFamilies(fileName.c_str(),meshNames[0].c_str(),0,families2);
  CPPUNIT_ASSERT_EQUAL(3,mesh->getSpaceDimension());
  CPPUNIT_ASSERT_EQUAL(0,mesh->getNumberOfCells());
  CPPUNIT_ASSERT_EQUAL(19,mesh->getNumberOfNodes());
  CPPUNIT_ASSERT_EQUAL(3,mesh->getMeshDimension());
  CPPUNIT_ASSERT_EQUAL(0,(int)mesh->getAllTypes().size());
  mesh->decrRef();
}

Here is the call graph for this function:

Definition at line 36 of file ParaMEDMEMTest_MEDLoader.cxx.

{
  string fileName=getResourceFile("pointe.med");
  vector<string> meshNames=MEDLoader::GetMeshNames(fileName.c_str());
  CPPUNIT_ASSERT_EQUAL(1,(int)meshNames.size());
  MEDCouplingUMesh *mesh=MEDLoader::ReadUMeshFromFile(fileName.c_str(),meshNames[0].c_str(),0);
  CPPUNIT_ASSERT_EQUAL(3,mesh->getSpaceDimension());
  CPPUNIT_ASSERT_EQUAL(3,mesh->getMeshDimension());
  CPPUNIT_ASSERT_EQUAL(16,mesh->getNumberOfCells());
  CPPUNIT_ASSERT_EQUAL(19,mesh->getNumberOfNodes());
  CPPUNIT_ASSERT_EQUAL(3,(int)mesh->getAllTypes().size());
  for(int i=0;i<12;i++)
    CPPUNIT_ASSERT_EQUAL(NORM_TETRA4,mesh->getTypeOfCell(i));
  CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,mesh->getTypeOfCell(12));
  CPPUNIT_ASSERT_EQUAL(NORM_HEXA8,mesh->getTypeOfCell(13));
  CPPUNIT_ASSERT_EQUAL(NORM_HEXA8,mesh->getTypeOfCell(14));
  CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,mesh->getTypeOfCell(15));
  CPPUNIT_ASSERT_EQUAL(90,mesh->getNodalConnectivity()->getNbOfElems());
  CPPUNIT_ASSERT_EQUAL(701,std::accumulate(mesh->getNodalConnectivity()->getPointer(),mesh->getNodalConnectivity()->getPointer()+90,0));
  CPPUNIT_ASSERT_EQUAL(705,std::accumulate(mesh->getNodalConnectivityIndex()->getPointer(),mesh->getNodalConnectivityIndex()->getPointer()+17,0));
  CPPUNIT_ASSERT_DOUBLES_EQUAL(46.,std::accumulate(mesh->getCoords()->getPointer(),mesh->getCoords()->getPointer()+57,0),1e-12);
  mesh->decrRef();
  //
  vector<string> families=MEDLoader::GetMeshFamiliesNames(fileName.c_str(),meshNames[0].c_str());
  CPPUNIT_ASSERT_EQUAL(8,(int)families.size());
  CPPUNIT_ASSERT(families[2]=="FAMILLE_ELEMENT_3");
  //
  vector<string> families2;
  families2.push_back(families[2]);
  mesh=MEDLoader::ReadUMeshFromFamilies(fileName.c_str(),meshNames[0].c_str(),0,families2);
  CPPUNIT_ASSERT_EQUAL(3,mesh->getSpaceDimension());
  CPPUNIT_ASSERT_EQUAL(3,mesh->getMeshDimension());
  CPPUNIT_ASSERT_EQUAL(2,mesh->getNumberOfCells());
  CPPUNIT_ASSERT_EQUAL(19,mesh->getNumberOfNodes());
  CPPUNIT_ASSERT_EQUAL(2,(int)mesh->getAllTypes().size());
  CPPUNIT_ASSERT_EQUAL(NORM_TETRA4,mesh->getTypeOfCell(0));
  CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,mesh->getTypeOfCell(1));
  CPPUNIT_ASSERT_EQUAL(11,mesh->getNodalConnectivity()->getNbOfElems());
  CPPUNIT_ASSERT_EQUAL(132,std::accumulate(mesh->getNodalConnectivity()->getPointer(),mesh->getNodalConnectivity()->getPointer()+11,0));
  CPPUNIT_ASSERT_EQUAL(16,std::accumulate(mesh->getNodalConnectivityIndex()->getPointer(),mesh->getNodalConnectivityIndex()->getPointer()+3,0));
  CPPUNIT_ASSERT_DOUBLES_EQUAL(46.,std::accumulate(mesh->getCoords()->getPointer(),mesh->getCoords()->getPointer()+57,0),1e-12);
  mesh->decrRef();
  //
  vector<string> groups=MEDLoader::GetMeshGroupsNames(fileName.c_str(),meshNames[0].c_str());
  CPPUNIT_ASSERT_EQUAL(5,(int)groups.size());
  CPPUNIT_ASSERT(groups[0]=="groupe1");
  CPPUNIT_ASSERT(groups[1]=="groupe2");
  CPPUNIT_ASSERT(groups[2]=="groupe3");
  CPPUNIT_ASSERT(groups[3]=="groupe4");
  CPPUNIT_ASSERT(groups[4]=="groupe5");
  vector<string> groups2;
  groups2.push_back(groups[0]);
  mesh=MEDLoader::ReadUMeshFromGroups(fileName.c_str(),meshNames[0].c_str(),0,groups2);
  CPPUNIT_ASSERT_EQUAL(3,mesh->getSpaceDimension());
  CPPUNIT_ASSERT_EQUAL(3,mesh->getMeshDimension());
  CPPUNIT_ASSERT_EQUAL(7,mesh->getNumberOfCells());
  CPPUNIT_ASSERT_EQUAL(19,mesh->getNumberOfNodes());
  CPPUNIT_ASSERT_EQUAL(2,(int)mesh->getAllTypes().size());
  for(int i=0;i<6;i++)
    CPPUNIT_ASSERT_EQUAL(NORM_TETRA4,mesh->getTypeOfCell(i));
  CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,mesh->getTypeOfCell(6));
  CPPUNIT_ASSERT_EQUAL(36,mesh->getNodalConnectivity()->getNbOfElems());
  CPPUNIT_ASSERT_EQUAL(254,std::accumulate(mesh->getNodalConnectivity()->getPointer(),mesh->getNodalConnectivity()->getPointer()+36,0));
  CPPUNIT_ASSERT_EQUAL(141,std::accumulate(mesh->getNodalConnectivityIndex()->getPointer(),mesh->getNodalConnectivityIndex()->getPointer()+8,0));
  CPPUNIT_ASSERT_DOUBLES_EQUAL(46.,std::accumulate(mesh->getCoords()->getPointer(),mesh->getCoords()->getPointer()+57,0),1e-12);
  mesh->decrRef();
  //
  std::vector<std::string> fieldsName=MEDLoader::GetCellFieldNamesOnMesh(fileName.c_str(),meshNames[0].c_str());
  CPPUNIT_ASSERT_EQUAL(2,(int)fieldsName.size());
  CPPUNIT_ASSERT(fieldsName[0]=="fieldcelldoublescalar");
  CPPUNIT_ASSERT(fieldsName[1]=="fieldcelldoublevector");
  std::vector<std::pair<int,int> > its0=MEDLoader::GetCellFieldIterations(fileName.c_str(),meshNames[0].c_str(),fieldsName[0].c_str());
  CPPUNIT_ASSERT_EQUAL(1,(int)its0.size());
  CPPUNIT_ASSERT_EQUAL(-1,its0[0].first);
  CPPUNIT_ASSERT_EQUAL(-1,its0[0].second);
  std::vector<std::pair<int,int> > its1=MEDLoader::GetCellFieldIterations(fileName.c_str(),meshNames[0].c_str(),fieldsName[1].c_str());
  CPPUNIT_ASSERT_EQUAL(1,(int)its1.size());
  CPPUNIT_ASSERT_EQUAL(-1,its1[0].first);
  CPPUNIT_ASSERT_EQUAL(-1,its1[0].second);
  //
  MEDCouplingFieldDouble *field0=MEDLoader::ReadFieldCell(fileName.c_str(),meshNames[0].c_str(),0,fieldsName[0].c_str(),its0[0].first,its0[0].second);
  field0->checkCoherency();
  CPPUNIT_ASSERT(field0->getName()==fieldsName[0]);
  CPPUNIT_ASSERT_EQUAL(1,field0->getNumberOfComponents());
  CPPUNIT_ASSERT_EQUAL(16,field0->getNumberOfTuples());
  const double expectedValues[16]={1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,2.,3.,3.,2.};
  double diffValue[16];
  std::transform(field0->getArray()->getPointer(),field0->getArray()->getPointer()+16,expectedValues,diffValue,std::minus<double>());
  CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,*std::max_element(diffValue,diffValue+16),1e-12);
  CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,*std::min_element(diffValue,diffValue+16),1e-12);
  const MEDCouplingUMesh *constMesh=dynamic_cast<const MEDCouplingUMesh *>(field0->getMesh());
  CPPUNIT_ASSERT(constMesh);
  CPPUNIT_ASSERT_EQUAL(3,constMesh->getSpaceDimension());
  CPPUNIT_ASSERT_EQUAL(3,constMesh->getMeshDimension());
  CPPUNIT_ASSERT_EQUAL(16,constMesh->getNumberOfCells());
  CPPUNIT_ASSERT_EQUAL(19,constMesh->getNumberOfNodes());
  CPPUNIT_ASSERT_EQUAL(3,(int)constMesh->getAllTypes().size());
  for(int i=0;i<12;i++)
    CPPUNIT_ASSERT_EQUAL(NORM_TETRA4,constMesh->getTypeOfCell(i));
  CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,constMesh->getTypeOfCell(12));
  CPPUNIT_ASSERT_EQUAL(NORM_HEXA8,constMesh->getTypeOfCell(13));
  CPPUNIT_ASSERT_EQUAL(NORM_HEXA8,constMesh->getTypeOfCell(14));
  CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,constMesh->getTypeOfCell(15));
  CPPUNIT_ASSERT_EQUAL(90,constMesh->getNodalConnectivity()->getNbOfElems());
  CPPUNIT_ASSERT_EQUAL(701,std::accumulate(constMesh->getNodalConnectivity()->getConstPointer(),constMesh->getNodalConnectivity()->getConstPointer()+90,0));
  CPPUNIT_ASSERT_EQUAL(705,std::accumulate(constMesh->getNodalConnectivityIndex()->getConstPointer(),constMesh->getNodalConnectivityIndex()->getConstPointer()+17,0));
  CPPUNIT_ASSERT_DOUBLES_EQUAL(46.,std::accumulate(constMesh->getCoords()->getConstPointer(),constMesh->getCoords()->getConstPointer()+57,0),1e-12);
  field0->decrRef();
  //
  MEDCouplingFieldDouble *field1=MEDLoader::ReadFieldCell(fileName.c_str(),meshNames[0].c_str(),0,fieldsName[1].c_str(),its1[0].first,its1[0].second);
  field1->checkCoherency();
  CPPUNIT_ASSERT(field1->getName()==fieldsName[1]);
  CPPUNIT_ASSERT_EQUAL(3,field1->getNumberOfComponents());
  CPPUNIT_ASSERT_EQUAL(16,field1->getNumberOfTuples());
  const double expectedValues2[48]={1.,0.,1.,1.,0.,1.,1.,0.,1.,2.,1.,0.,2.,1.,0.,2.,1.,0.,3.,0.,1.,3.,0.,1.,3.,0.,1.,4.,1.,0.,4.,1.,0.,4.,1.,0.,5.,0.,0.,6.,1.,1.,6.,0.,0.,5.,1.,1.};
  double diffValue2[48];
  std::transform(field1->getArray()->getPointer(),field1->getArray()->getPointer()+48,expectedValues2,diffValue2,std::minus<double>());
  CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,*std::max_element(diffValue2,diffValue2+48),1e-12);
  CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,*std::min_element(diffValue2,diffValue2+48),1e-12);
  constMesh=dynamic_cast<const MEDCouplingUMesh *>(field1->getMesh());
  CPPUNIT_ASSERT(constMesh);
  CPPUNIT_ASSERT_EQUAL(3,constMesh->getSpaceDimension());
  CPPUNIT_ASSERT_EQUAL(3,constMesh->getMeshDimension());
  CPPUNIT_ASSERT_EQUAL(16,constMesh->getNumberOfCells());
  CPPUNIT_ASSERT_EQUAL(19,constMesh->getNumberOfNodes());
  CPPUNIT_ASSERT_EQUAL(3,(int)constMesh->getAllTypes().size());
  for(int i=0;i<12;i++)
    CPPUNIT_ASSERT_EQUAL(NORM_TETRA4,constMesh->getTypeOfCell(i));
  CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,constMesh->getTypeOfCell(12));
  CPPUNIT_ASSERT_EQUAL(NORM_HEXA8,constMesh->getTypeOfCell(13));
  CPPUNIT_ASSERT_EQUAL(NORM_HEXA8,constMesh->getTypeOfCell(14));
  CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,constMesh->getTypeOfCell(15));
  CPPUNIT_ASSERT_EQUAL(90,constMesh->getNodalConnectivity()->getNbOfElems());
  CPPUNIT_ASSERT_EQUAL(701,std::accumulate(constMesh->getNodalConnectivity()->getConstPointer(),constMesh->getNodalConnectivity()->getConstPointer()+90,0));
  CPPUNIT_ASSERT_EQUAL(705,std::accumulate(constMesh->getNodalConnectivityIndex()->getConstPointer(),constMesh->getNodalConnectivityIndex()->getConstPointer()+17,0));
  CPPUNIT_ASSERT_DOUBLES_EQUAL(46.,std::accumulate(constMesh->getCoords()->getConstPointer(),constMesh->getCoords()->getConstPointer()+57,0),1e-12);
  field1->decrRef();
  //fields on nodes
  std::vector<std::string> fieldsNameNode=MEDLoader::GetNodeFieldNamesOnMesh(fileName.c_str(),meshNames[0].c_str());
  CPPUNIT_ASSERT_EQUAL(2,(int)fieldsNameNode.size());
  CPPUNIT_ASSERT(fieldsNameNode[0]=="fieldnodedouble");
  CPPUNIT_ASSERT(fieldsNameNode[1]=="fieldnodeint");
  std::vector<std::pair<int,int> > its0Node=MEDLoader::GetNodeFieldIterations(fileName.c_str(),meshNames[0].c_str(),fieldsNameNode[0].c_str());
  CPPUNIT_ASSERT_EQUAL(3,(int)its0Node.size());
  CPPUNIT_ASSERT_EQUAL(-1,its0Node[0].first);
  CPPUNIT_ASSERT_EQUAL(-1,its0Node[0].second);
  CPPUNIT_ASSERT_EQUAL(1,its0Node[1].first);
  CPPUNIT_ASSERT_EQUAL(-1,its0Node[1].second);
  CPPUNIT_ASSERT_EQUAL(2,its0Node[2].first);
  CPPUNIT_ASSERT_EQUAL(-1,its0Node[2].second);
  MEDCouplingFieldDouble *field0Nodes=MEDLoader::ReadFieldNode(fileName.c_str(),meshNames[0].c_str(),0,fieldsNameNode[0].c_str(),its0Node[0].first,its0Node[0].second);
  field0Nodes->checkCoherency();
  CPPUNIT_ASSERT(field0Nodes->getName()==fieldsNameNode[0]);
  CPPUNIT_ASSERT_EQUAL(1,field0Nodes->getNumberOfComponents());
  CPPUNIT_ASSERT_EQUAL(19,field0Nodes->getNumberOfTuples());
  const double expectedValues3[19]={1.,1.,1.,2.,2.,2.,3.,3.,3.,4.,4.,4.,5.,5.,5.,6.,6.,6.,7.};
  double diffValue3[19];
  std::transform(field0Nodes->getArray()->getPointer(),field0Nodes->getArray()->getPointer()+19,expectedValues3,diffValue3,std::minus<double>());
  CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,*std::max_element(diffValue3,diffValue3+19),1e-12);
  CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,*std::min_element(diffValue3,diffValue3+19),1e-12);
  constMesh=dynamic_cast<const MEDCouplingUMesh *>(field0Nodes->getMesh());
  CPPUNIT_ASSERT(constMesh);
  field0Nodes->decrRef();
  //
  field0Nodes=MEDLoader::ReadFieldNode(fileName.c_str(),meshNames[0].c_str(),0,fieldsNameNode[0].c_str(),its0Node[2].first,its0Node[2].second);
  field0Nodes->checkCoherency();
  CPPUNIT_ASSERT(field0Nodes->getName()==fieldsNameNode[0]);
  CPPUNIT_ASSERT_EQUAL(1,field0Nodes->getNumberOfComponents());
  CPPUNIT_ASSERT_EQUAL(19,field0Nodes->getNumberOfTuples());
  const double expectedValues4[19]={1.,2.,2.,2.,3.,3.,3.,4.,4.,4.,5.,5.,5.,6.,6.,6.,7.,7.,7.};
  std::transform(field0Nodes->getArray()->getPointer(),field0Nodes->getArray()->getPointer()+19,expectedValues4,diffValue3,std::minus<double>());
  CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,*std::max_element(diffValue3,diffValue3+19),1e-12);
  CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,*std::min_element(diffValue3,diffValue3+19),1e-12);
  constMesh=dynamic_cast<const MEDCouplingUMesh *>(field0Nodes->getMesh());
  CPPUNIT_ASSERT(constMesh);
  CPPUNIT_ASSERT_EQUAL(3,constMesh->getSpaceDimension());
  CPPUNIT_ASSERT_EQUAL(3,constMesh->getMeshDimension());
  CPPUNIT_ASSERT_EQUAL(16,constMesh->getNumberOfCells());
  CPPUNIT_ASSERT_EQUAL(19,constMesh->getNumberOfNodes());
  CPPUNIT_ASSERT_EQUAL(3,(int)constMesh->getAllTypes().size());
  for(int i=0;i<12;i++)
    CPPUNIT_ASSERT_EQUAL(NORM_TETRA4,constMesh->getTypeOfCell(i));
  CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,constMesh->getTypeOfCell(12));
  CPPUNIT_ASSERT_EQUAL(NORM_HEXA8,constMesh->getTypeOfCell(13));
  CPPUNIT_ASSERT_EQUAL(NORM_HEXA8,constMesh->getTypeOfCell(14));
  CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,constMesh->getTypeOfCell(15));
  CPPUNIT_ASSERT_EQUAL(90,constMesh->getNodalConnectivity()->getNbOfElems());
  CPPUNIT_ASSERT_EQUAL(701,std::accumulate(constMesh->getNodalConnectivity()->getConstPointer(),constMesh->getNodalConnectivity()->getConstPointer()+90,0));
  CPPUNIT_ASSERT_EQUAL(705,std::accumulate(constMesh->getNodalConnectivityIndex()->getConstPointer(),constMesh->getNodalConnectivityIndex()->getConstPointer()+17,0));
  CPPUNIT_ASSERT_DOUBLES_EQUAL(46.,std::accumulate(constMesh->getCoords()->getConstPointer(),constMesh->getCoords()->getConstPointer()+57,0),1e-12);
  field0Nodes->decrRef();
  //
  field0Nodes=MEDLoader::ReadFieldNode(fileName.c_str(),meshNames[0].c_str(),0,fieldsNameNode[0].c_str(),its0Node[0].first,its0Node[0].second);
  field0Nodes->checkCoherency();
  CPPUNIT_ASSERT(field0Nodes->getName()==fieldsNameNode[0]);
  CPPUNIT_ASSERT_EQUAL(1,field0Nodes->getNumberOfComponents());
  CPPUNIT_ASSERT_EQUAL(19,field0Nodes->getNumberOfTuples());
  const double expectedValues5[19]={1.,1.,1.,2.,2.,2.,3.,3.,3.,4.,4.,4.,5.,5.,5.,6.,6.,6.,7.};
  std::transform(field0Nodes->getArray()->getPointer(),field0Nodes->getArray()->getPointer()+19,expectedValues5,diffValue3,std::minus<double>());
  CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,*std::max_element(diffValue3,diffValue3+19),1e-12);
  CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,*std::min_element(diffValue3,diffValue3+19),1e-12);
  constMesh=dynamic_cast<const MEDCouplingUMesh *>(field0Nodes->getMesh());
  CPPUNIT_ASSERT(constMesh);
  CPPUNIT_ASSERT_EQUAL(3,constMesh->getSpaceDimension());
  CPPUNIT_ASSERT_EQUAL(3,constMesh->getMeshDimension());
  CPPUNIT_ASSERT_EQUAL(16,constMesh->getNumberOfCells());
  CPPUNIT_ASSERT_EQUAL(19,constMesh->getNumberOfNodes());
  CPPUNIT_ASSERT_EQUAL(3,(int)constMesh->getAllTypes().size());
  for(int i=0;i<12;i++)
    CPPUNIT_ASSERT_EQUAL(NORM_TETRA4,constMesh->getTypeOfCell(i));
  CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,constMesh->getTypeOfCell(12));
  CPPUNIT_ASSERT_EQUAL(NORM_HEXA8,constMesh->getTypeOfCell(13));
  CPPUNIT_ASSERT_EQUAL(NORM_HEXA8,constMesh->getTypeOfCell(14));
  CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,constMesh->getTypeOfCell(15));
  CPPUNIT_ASSERT_EQUAL(90,constMesh->getNodalConnectivity()->getNbOfElems());
  CPPUNIT_ASSERT_EQUAL(701,std::accumulate(constMesh->getNodalConnectivity()->getConstPointer(),constMesh->getNodalConnectivity()->getConstPointer()+90,0));
  CPPUNIT_ASSERT_EQUAL(705,std::accumulate(constMesh->getNodalConnectivityIndex()->getConstPointer(),constMesh->getNodalConnectivityIndex()->getConstPointer()+17,0));
  CPPUNIT_ASSERT_DOUBLES_EQUAL(46.,std::accumulate(constMesh->getCoords()->getConstPointer(),constMesh->getCoords()->getConstPointer()+57,0),1e-12);
  field0Nodes->decrRef();
}

Here is the call graph for this function:

Definition at line 98 of file ParaMEDMEMTest_MPIProcessorGroup.cxx.

{
  int size;
  MPI_Comm_size(MPI_COMM_WORLD, &size);
  
  CommInterface comm_interface;
  MPIProcessorGroup group(comm_interface,0,0);
  MPIProcessorGroup group2(comm_interface,size-1,size-1);
  ProcessorGroup* group_fuse=group.fuse(group2);
  int group_fuse_size=(size==1)?1:2;
  CPPUNIT_ASSERT_EQUAL(group_fuse_size,group_fuse->size());
 
  ProcessorGroup* group_complement=((MPIProcessorGroup*)group_fuse)->createComplementProcGroup();
  CPPUNIT_ASSERT_EQUAL(group_complement->size(),size-group_fuse_size);
  
  delete group_fuse;
  delete group_complement;

  //intersect not implemented yet
  //   if (size>1)
  //   {
  //     MPIProcessorGroup group3(comm_interface,0,size-2);
  //     MPIProcessorGroup group4(comm_interface,1,size-1);
  //     group3.intersect(group4);
  //     CPPUNIT_ASSERT_EQUAL(group3.size(),size-2);
  //   }
}

Here is the call graph for this function:

Definition at line 58 of file ParaMEDMEMTest_MPIProcessorGroup.cxx.

{
  CommInterface comm_interface;
  MPIProcessorGroup* group= new MPIProcessorGroup(comm_interface);
  int size;
  MPI_Comm_size(MPI_COMM_WORLD, &size);
  CPPUNIT_ASSERT_EQUAL(size,group->size());
  int size2;
  const MPI_Comm* communicator=group->getComm();
  MPI_Comm_size(*communicator, &size2);
  CPPUNIT_ASSERT_EQUAL(size,size2);
  delete group;
  
  set <int> procs;
  
  procs.insert(0);
  procs.insert(1);
  if (size==1)
    CPPUNIT_ASSERT_THROW(group=new MPIProcessorGroup(comm_interface,procs),INTERP_KERNEL::Exception);
  else
    {
      CPPUNIT_ASSERT_NO_THROW(  group=new MPIProcessorGroup(comm_interface,procs));
      CPPUNIT_ASSERT_EQUAL (group->size(),2);
      delete group;
    }
  
  
  //throws because plast<pfirst
  CPPUNIT_ASSERT_THROW(group=new MPIProcessorGroup(comm_interface,1,0),INTERP_KERNEL::Exception);
  //throws because plast is beyond size-1
  CPPUNIT_ASSERT_THROW(group=new MPIProcessorGroup(comm_interface,0,size),INTERP_KERNEL::Exception);
  if (size>1)
    {
      group=new MPIProcessorGroup(comm_interface,0,size-2);
      CPPUNIT_ASSERT_EQUAL(group->size(),size-1);
      delete group;
    }
  
}

Here is the call graph for this function:

Definition at line 126 of file ParaMEDMEMTest_MPIProcessorGroup.cxx.

{
  int size;
  MPI_Comm_size(MPI_COMM_WORLD, &size);
  int rank;
  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
  
  CommInterface comm_interface;
  MPIProcessorGroup group(comm_interface,0,0);
  MPIProcessorGroup group2(comm_interface,size-1,size-1);
  ProcessorGroup* group_fuse=group2.fuse(group);
  
  if (group.containsMyRank())
    CPPUNIT_ASSERT_EQUAL (group.myRank(), rank);

  if (group2.containsMyRank())
    {
      int trank=group_fuse->translateRank(&group2,0);
      if (size==1)
        CPPUNIT_ASSERT_EQUAL(trank,0);
      else  
        CPPUNIT_ASSERT_EQUAL(trank,1);
    }
  delete group_fuse;
}

Here is the call graph for this function:

Definition at line 36 of file ParaMEDMEMTest_OverlapDEC.cxx.

{
  std::string srcM("P0");
  std::string targetM("P0");
  int size;
  int rank;
  MPI_Comm_size(MPI_COMM_WORLD,&size);
  MPI_Comm_rank(MPI_COMM_WORLD,&rank);

  if (size != 3) return ;
   
  int nproc = 3;
  std::set<int> procs;
  
  for (int i=0; i<nproc; i++)
    procs.insert(i);
  
  ParaMEDMEM::CommInterface interface;

  ParaMEDMEM::OverlapDEC dec(procs);

  ParaMEDMEM::MEDCouplingUMesh* meshS=0;
  ParaMEDMEM::MEDCouplingUMesh* meshT=0;
  ParaMEDMEM::ParaMESH* parameshS=0;
  ParaMEDMEM::ParaMESH* parameshT=0;
  ParaMEDMEM::ParaFIELD* parafieldS=0;
  ParaMEDMEM::ParaFIELD* parafieldT=0;
  
  MPI_Barrier(MPI_COMM_WORLD);
  if(rank==0)
    {
      const double coordsS[10]={0.,0.,0.5,0.,1.,0.,0.,0.5,0.5,0.5};
      const double coordsT[6]={0.,0.,1.,0.,1.,1.};
      meshS=ParaMEDMEM::MEDCouplingUMesh::New();
      meshS->setMeshDimension(2);
      ParaMEDMEM::DataArrayDouble *myCoords=ParaMEDMEM::DataArrayDouble::New();
      myCoords->alloc(5,2);
      std::copy(coordsS,coordsS+10,myCoords->getPointer());
      meshS->setCoords(myCoords);
      myCoords->decrRef();
      int connS[7]={0,3,4,1, 1,4,2};
      meshS->allocateCells(2);
      meshS->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,connS);
      meshS->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,connS+4);
      meshS->finishInsertingCells();
      ParaMEDMEM::ComponentTopology comptopo;
      parameshS=new ParaMEDMEM::ParaMESH(meshS,*dec.getGrp(),"source mesh");
      parafieldS=new ParaMEDMEM::ParaFIELD(ParaMEDMEM::ON_CELLS,ParaMEDMEM::NO_TIME,parameshS,comptopo);
      parafieldS->getField()->setNature(ParaMEDMEM::ConservativeVolumic);//IntegralGlobConstraint
      double *valsS=parafieldS->getField()->getArray()->getPointer();
      valsS[0]=7.; valsS[1]=8.;
      //
      meshT=ParaMEDMEM::MEDCouplingUMesh::New();
      meshT->setMeshDimension(2);
      myCoords=ParaMEDMEM::DataArrayDouble::New();
      myCoords->alloc(3,2);
      std::copy(coordsT,coordsT+6,myCoords->getPointer());
      meshT->setCoords(myCoords);
      myCoords->decrRef();
      int connT[3]={0,2,1};
      meshT->allocateCells(1);
      meshT->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,connT);
      meshT->finishInsertingCells();
      parameshT=new ParaMEDMEM::ParaMESH(meshT,*dec.getGrp(),"target mesh");
      parafieldT=new ParaMEDMEM::ParaFIELD(ParaMEDMEM::ON_CELLS,ParaMEDMEM::NO_TIME,parameshT,comptopo);
      parafieldT->getField()->setNature(ParaMEDMEM::ConservativeVolumic);//IntegralGlobConstraint
      double *valsT=parafieldT->getField()->getArray()->getPointer();
      valsT[0]=7.;
    }
  //
  if(rank==1)
    {
      const double coordsS[10]={1.,0.,0.5,0.5,1.,0.5,0.5,1.,1.,1.};
      const double coordsT[6]={0.,0.,0.5,0.5,0.,1.};
      meshS=ParaMEDMEM::MEDCouplingUMesh::New();
      meshS->setMeshDimension(2);
      ParaMEDMEM::DataArrayDouble *myCoords=ParaMEDMEM::DataArrayDouble::New();
      myCoords->alloc(5,2);
      std::copy(coordsS,coordsS+10,myCoords->getPointer());
      meshS->setCoords(myCoords);
      myCoords->decrRef();
      int connS[7]={0,1,2, 1,3,4,2};
      meshS->allocateCells(2);
      meshS->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,connS);
      meshS->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,connS+3);
      meshS->finishInsertingCells();
      ParaMEDMEM::ComponentTopology comptopo;
      parameshS=new ParaMEDMEM::ParaMESH(meshS,*dec.getGrp(),"source mesh");
      parafieldS=new ParaMEDMEM::ParaFIELD(ParaMEDMEM::ON_CELLS,ParaMEDMEM::NO_TIME,parameshS,comptopo);
      parafieldS->getField()->setNature(ParaMEDMEM::ConservativeVolumic);//IntegralGlobConstraint
      double *valsS=parafieldS->getField()->getArray()->getPointer();
      valsS[0]=9.; valsS[1]=11.;
      //
      meshT=ParaMEDMEM::MEDCouplingUMesh::New();
      meshT->setMeshDimension(2);
      myCoords=ParaMEDMEM::DataArrayDouble::New();
      myCoords->alloc(3,2);
      std::copy(coordsT,coordsT+6,myCoords->getPointer());
      meshT->setCoords(myCoords);
      myCoords->decrRef();
      int connT[3]={0,2,1};
      meshT->allocateCells(1);
      meshT->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,connT);
      meshT->finishInsertingCells();
      parameshT=new ParaMEDMEM::ParaMESH(meshT,*dec.getGrp(),"target mesh");
      parafieldT=new ParaMEDMEM::ParaFIELD(ParaMEDMEM::ON_CELLS,ParaMEDMEM::NO_TIME,parameshT,comptopo);
      parafieldT->getField()->setNature(ParaMEDMEM::ConservativeVolumic);//IntegralGlobConstraint
      double *valsT=parafieldT->getField()->getArray()->getPointer();
      valsT[0]=8.;
    }
  //
  if(rank==2)
    {
      const double coordsS[8]={0.,0.5, 0.5,0.5, 0.,1., 0.5,1.};
      const double coordsT[6]={0.5,0.5,0.,1.,1.,1.};
      meshS=ParaMEDMEM::MEDCouplingUMesh::New();
      meshS->setMeshDimension(2);
      ParaMEDMEM::DataArrayDouble *myCoords=ParaMEDMEM::DataArrayDouble::New();
      myCoords->alloc(4,2);
      std::copy(coordsS,coordsS+8,myCoords->getPointer());
      meshS->setCoords(myCoords);
      myCoords->decrRef();
      int connS[4]={0,2,3,1};
      meshS->allocateCells(1);
      meshS->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,connS);
      meshS->finishInsertingCells();
      ParaMEDMEM::ComponentTopology comptopo;
      parameshS=new ParaMEDMEM::ParaMESH(meshS,*dec.getGrp(),"source mesh");
      parafieldS=new ParaMEDMEM::ParaFIELD(ParaMEDMEM::ON_CELLS,ParaMEDMEM::NO_TIME,parameshS,comptopo);
      parafieldS->getField()->setNature(ParaMEDMEM::ConservativeVolumic);//IntegralGlobConstraint
      double *valsS=parafieldS->getField()->getArray()->getPointer();
      valsS[0]=10.;
      //
      meshT=ParaMEDMEM::MEDCouplingUMesh::New();
      meshT->setMeshDimension(2);
      myCoords=ParaMEDMEM::DataArrayDouble::New();
      myCoords->alloc(3,2);
      std::copy(coordsT,coordsT+6,myCoords->getPointer());
      meshT->setCoords(myCoords);
      myCoords->decrRef();
      int connT[3]={0,1,2};
      meshT->allocateCells(1);
      meshT->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,connT);
      meshT->finishInsertingCells();
      parameshT=new ParaMEDMEM::ParaMESH(meshT,*dec.getGrp(),"target mesh");
      parafieldT=new ParaMEDMEM::ParaFIELD(ParaMEDMEM::ON_CELLS,ParaMEDMEM::NO_TIME,parameshT,comptopo);
      parafieldT->getField()->setNature(ParaMEDMEM::ConservativeVolumic);//IntegralGlobConstraint
      double *valsT=parafieldT->getField()->getArray()->getPointer();
      valsT[0]=9.;
    }
  dec.attachSourceLocalField(parafieldS);
  dec.attachTargetLocalField(parafieldT);
  dec.synchronize();
  dec.sendRecvData(true);
  //
  if(rank==0)
    {
      CPPUNIT_ASSERT_DOUBLES_EQUAL(8.75,parafieldT->getField()->getArray()->getIJ(0,0),1e-12);
    }
  if(rank==1)
    {
      CPPUNIT_ASSERT_DOUBLES_EQUAL(8.5,parafieldT->getField()->getArray()->getIJ(0,0),1e-12);
    }
  if(rank==2)
    {
      CPPUNIT_ASSERT_DOUBLES_EQUAL(10.5,parafieldT->getField()->getArray()->getIJ(0,0),1e-12);
    }
  delete parafieldS;
  delete parafieldT;
  delete parameshS;
  delete parameshT;
  meshS->decrRef();
  meshT->decrRef();

  MPI_Barrier(MPI_COMM_WORLD);
}

Here is the call graph for this function:

Definition at line 57 of file ParaMEDMEMTest_StructuredCoincidentDEC.cxx.

                                                 {
  string testname="ParaMEDMEM - testStructured CoincidentDEC";
  //  MPI_Init(&argc, &argv); 
  int size;
  int rank;
  MPI_Comm_size(MPI_COMM_WORLD, &size);
  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
  if (size<4) {
    return;
  }

  ParaMEDMEM::CommInterface interface;

  ParaMEDMEM::MPIProcessorGroup self_group (interface,rank,rank);
  ParaMEDMEM::MPIProcessorGroup target_group(interface,3,size-1);
  ParaMEDMEM::MPIProcessorGroup source_group (interface,0,2);

  ParaMEDMEM::MEDCouplingUMesh* mesh;
  ParaMEDMEM::ParaMESH* paramesh;
  ParaMEDMEM::ParaFIELD* parafield;

  string filename_xml1 = getResourceFile("square1_split");
  string filename_2    = getResourceFile("square1.med");
  //string filename_seq_wr  = makeTmpFile("");
  //string filename_seq_med = makeTmpFile("myWrField_seq_pointe221.med");

  // To remove tmp files from disk
  ParaMEDMEMTest_TmpFilesRemover aRemover;

  //loading the geometry for the source group

  ParaMEDMEM::StructuredCoincidentDEC dec(source_group, target_group);

  MPI_Barrier(MPI_COMM_WORLD);
  if (source_group.containsMyRank()) {
    string master = filename_xml1;

    ostringstream strstream;
    strstream <<master<<rank+1<<".med";
    ostringstream meshname;
    meshname<< "Mesh_2_"<< rank+1;

    mesh=MEDLoader::ReadUMeshFromFile(strstream.str().c_str(),meshname.str().c_str(),0);
    

    paramesh=new ParaMESH (mesh,source_group,"source mesh");

    ParaMEDMEM::ComponentTopology comptopo(6);
    parafield = new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo);

    int nb_local=mesh->getNumberOfCells();
    const int* global_numbering = paramesh->getGlobalNumberingCell();
    
    double *value=parafield->getField()->getArray()->getPointer();
    for(int ielem=0; ielem<nb_local;ielem++)
      for (int icomp=0; icomp<6; icomp++)
        value[ielem*6+icomp]=global_numbering[ielem]*6+icomp;

    //ICoCo::Field* icocofield=new ICoCo::MEDField((MEDCouplingUMesh *)paramesh->getCellMesh(),parafield->getField());

    dec.attachLocalField(parafield);
    dec.synchronize();
    dec.sendData();
    //delete icocofield;
  }

  //loading the geometry for the target group
  if (target_group.containsMyRank()) {

    string meshname2("Mesh_2");
    mesh = MEDLoader::ReadUMeshFromFile(filename_2.c_str(),meshname2.c_str(),0);
    
    paramesh=new ParaMESH (mesh,self_group,"target mesh");
    ParaMEDMEM::ComponentTopology comptopo(6, &target_group);

    parafield = new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo);

    int nb_local=mesh->getNumberOfCells();
    double *value=parafield->getField()->getArray()->getPointer();
    for (int ielem=0; ielem<nb_local; ielem++)
      for (int icomp=0; icomp<comptopo.nbLocalComponents(); icomp++)
        value[ielem*comptopo.nbLocalComponents()+icomp]=0.0;
    //ICoCo::Field* icocofield=new ICoCo::MEDField((MEDCouplingUMesh *)paramesh->getCellMesh(),parafield->getField());

    dec.attachLocalField(parafield);
    dec.synchronize();
    dec.recvData();

    //checking validity of field
    const double* recv_value = parafield->getField()->getArray()->getPointer();
    for (int i=0; i< nb_local; i++) {
      int first = comptopo.firstLocalComponent();
      for (int icomp = 0; icomp < comptopo.nbLocalComponents(); icomp++)
        CPPUNIT_ASSERT_DOUBLES_EQUAL(recv_value[i*comptopo.nbLocalComponents()+icomp],(double)(i*6+icomp+first),1e-12);
    }
    //delete icocofield;
  }
  delete parafield;
  delete paramesh;
  mesh->decrRef();

  //  MPI_Barrier(MPI_COMM_WORLD);

}

Here is the call graph for this function:

Definition at line 1033 of file ParaMEDMEMTest_InterpKernelDEC.cxx.

{
  testAsynchronousInterpKernelDEC_2D(0.1,1,0.1,1,true,false,true,"P0","P0");
}

Definition at line 1027 of file ParaMEDMEMTest_InterpKernelDEC.cxx.

{
  testAsynchronousInterpKernelDEC_2D(0.1,1,0.1,1,true,false,false,"P0","P0");
}

Definition at line 1021 of file ParaMEDMEMTest_InterpKernelDEC.cxx.

{
  testAsynchronousInterpKernelDEC_2D(0.1,1,0.1,1,false,false,false,"P0","P0");
}

Definition at line 1037 of file ParaMEDMEMTest_InterpKernelDEC.cxx.

{
  testAsynchronousInterpKernelDEC_2D(0.09,1,0.1,1,true,false,true,"P0","P0");
}

Definition at line 1049 of file ParaMEDMEMTest_InterpKernelDEC.cxx.

{
  testAsynchronousInterpKernelDEC_2D(0.01,1,0.11,1,true,false,true,"P0","P0");
}

Definition at line 1041 of file ParaMEDMEMTest_InterpKernelDEC.cxx.

{
  testAsynchronousInterpKernelDEC_2D(0.11,1,0.1,1,true,false,true,"P0","P0");
}

Definition at line 1045 of file ParaMEDMEMTest_InterpKernelDEC.cxx.

{
  testAsynchronousInterpKernelDEC_2D(0.11,1,0.01,1,true,false,true,"P0","P0");
}

The documentation for this class was generated from the following files: