Personal tools
You are here: Home Forum Use Make a client that use calculator module

Make a client that use calculator module

Up to Use

Make a client that use calculator module

Posted by Thomas PEDOT at October 27. 2012

Hello,

I want to write a client that use calculator module. The goal is to learn how to use MED CORBA API : MED for interpolation librairies and Corba to use salome capabilites over the network.

Here is what I do :

1 - Make a simple mesh

2 - Apply a simple field on it

3 - Use Calculator component  to calculate, for example, printField or applyLin methods.

 

I am able to make steps 1 and 2 but "failed" to succeed the third. The module/component loads well (I can see it in the registery).
But the client seems to stay idle in this component... There is no error, but no response either...

I remove the headers for clarity :

using namespace ParaMEDMEM;

int main(int argc, char **argv) {
      //Connexion avec SALOME
  CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
  CORBA::Object_var obj = orb->resolve_initial_references("RootPOA") ;
  PortableServer::POA_var poa = PortableServer::POA::_narrow(obj) ;
  SALOME_NamingService _NS(orb) ;
  SALOME_LifeCycleCORBA _LCC(&_NS) ;

// Connexion au module COMPONENT
  Engines::EngineComponent_var Calculator = _LCC.FindOrLoad_Component( "FactoryServer" ,
                                                                        "CALCULATOR");
// CALCULATOR_ORB : Module idl
//CALCULATOR_Gen : interface idl
  CALCULATOR_ORB::CALCULATOR_Gen_var CalcInterface ;
  CalcInterface = CALCULATOR_ORB::CALCULATOR_Gen::_narrow( Calculator );

// Mesh1
double coords[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 };
int conn[18]={0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4};

static MEDCouplingUMesh *sourceMesh=MEDCouplingUMesh::New();
sourceMesh->setName("My2DsourceMesh");
sourceMesh->setMeshDimension(2);
sourceMesh->allocateCells(5);//You can put more than 5 if you want but not less.
sourceMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn);
sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,conn+4);
sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,conn+7);
sourceMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+10);
sourceMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+14);
sourceMesh->finishInsertingCells();
DataArrayDouble *myCoords=DataArrayDouble::New();
myCoords->alloc(9,2);
std::copy(coords,coords+18,myCoords->getPointer());
sourceMesh->setCoords(myCoords);
myCoords->decrRef();
  MEDCouplingFieldDouble *field1=MEDCouplingFieldDouble::New(ON_CELLS);
//
  field1->setNature(ConservativeVolumic);
  field1->setMesh(sourceMesh);
  DataArrayDouble *array=DataArrayDouble::New();
  array->alloc(sourceMesh->getNumberOfCells(),1);
  field1->setArray(array);
  double *ptr=array->getPointer();
  for(int i=0;i<sourceMesh->getNumberOfCells();i++)
    ptr[i]=(double)(i+7);
  array->decrRef();

  printf ("DEBUT : Norm2\n");

// field1 will be a Servant of the method printField, right ?

    ParaMEDMEM::MEDCouplingFieldDoubleServant *NewField=NULL;
    SALOME_MED::MEDCouplingFieldDoubleCorbaInterface_ptr field1CORBA = NULL;
    NewField = new ParaMEDMEM::MEDCouplingFieldDoubleServant(field1);
    // activate object
    field1CORBA = NewField->_this() ;

  CalcInterface->printField(field1CORBA);

 

  printf ("FIN : Norm2 ");

 

  sourceMesh->decrRef();

 

  field1->decrRef();

 

return 0;

}

 

Can anybody explain me what I am doing wrong ?

 

Any help will be appreciated.

 

Regards

Thomas

Re: Make a client that use calculator module

Posted by Thomas PEDOT at October 29. 2012

Hi,

I am still experiencing troubles but I don't know where to go. I hope someone can help me so I can use this powerful MED/CORBA API. If not, I will not be able to use Salome at all for coupling... 

Thanks in advance.

Thomas

Powered by Ploneboard
Document Actions