Пример #1
0
int main(int argc, char* argv[]) {
  struct sigaction sa;
  sigemptyset(&sa.sa_mask);
  sa.sa_handler = SIG_IGN;
  sa.sa_flags = 0;
  sigaction( SIGPIPE, &sa, 0 );

  Communicator* comm = Communicator::instance();
  if (comm->init() == -1)
    return -1;

  // Identity's arg must correspond to the class name in Hello.idl
  // Endpoind's arg: protocal, ip, port of the server end
  // in case of async call, timeout option is not needed
  Reference ref (comm, Identity("MyHello"), Endpoint("TCP", "127.0.0.1", 3000));
  IcmProxy::demo::MyHello myHello;
  myHello.setReference (&ref);

  unsigned long u =  1024ul * 1024 * 1024 * 12;

  // invoke async calls
  myHello.sayHello_async(new AMI_MyHello_sayHelloI, "Hello, async", u);
  myHello.sayBye_async(new AMI_MyHello_sayByeI, "Bye, async");

  // run() will enter a cycle to wait and process server reply, callback classes's response() will be invoked automatically
  // so usually this can be put into a new created thread 
  comm->run();

  return 0;
}
Пример #2
0
int
main (int argc, char* argv[])
{
  Communicator* comm = Communicator::instance();
  if (comm->init () == -1)
    return -1;
  
  Endpoint endpoint ("TCP", "", 3000);
  ObjectAdapter* oa = comm->createObjectAdapterWithEndpoint ("MyHello", &endpoint);
  Object* object = new demo::MyHelloI;
  oa->add (object, "MyHello");

  comm->run ();

  return 0;
}
Пример #3
0
int physics_run(real t)
{
  //output.write("Running %e\n", t);
  // Run communications
  comms.run();

  // Density
  
  F_N = -V_dot_Grad(V, N) - N*Div(V);
 
  //output.write("N ");
 
  // Velocity 
  
  F_V = -V_dot_Grad(V, V) - Grad(P)/N + g;

  if(sub_initial) {
    F_V += Grad(P0)/N0 - g;
  }

  //output.write("V ");

  if(include_viscosity) {
    // Add viscosity
    
    F_V.y += nu*Laplacian(V.y);
    F_V.z += nu*Laplacian(V.z);

    //output.write("nu ");
  }
  
  // Pressure

  F_P = -V_dot_Grad(V, P) - gamma_ratio*P*Div(V);

  //output.write("P\n");

  // Set boundary conditions
  apply_boundary(F_N, "density");
  apply_boundary(F_P, "pressure");
  F_V.to_contravariant();
  apply_boundary(F_V, "v");

  //output.write("finished\n");

  return 0;
}
Пример #4
0
int physics_run(real t)
{
  // Run communications
  comms.run();

  msg_stack.push("F_rho");
  
  F_rho = -V_dot_Grad(v, rho) - rho*Div(v);

  msg_stack.pop(); msg_stack.push("F_p");

  F_p = -V_dot_Grad(v, p) - gamma*p*Div(v);
  
  msg_stack.pop(); msg_stack.push("F_v");
  
  F_v = -V_dot_Grad(v, v) + ((Curl(B)^B) - Grad(p))/rho;

  if(include_viscos) {
    F_v.x += viscos * Laplacian(F_v.x);
    F_v.y += viscos * Laplacian(F_v.y);
    F_v.z += viscos * Laplacian(F_v.z);
  }
  
  msg_stack.pop(); msg_stack.push("F_B");
  
  F_B = Curl(v^B);

  // boundary conditions

  apply_boundary(F_rho, "density");
  apply_boundary(F_p, "pressure");
  F_v.to_covariant();
  apply_boundary(F_v, "v");
  F_B.to_contravariant();
  apply_boundary(F_B, "B");

  msg_stack.pop(); msg_stack.push("DivB");
  
  divB = Div(B); // Just for diagnostic
  bndry_inner_zero(divB);
  bndry_sol_zero(divB);

  return 0;
}
Пример #5
0
int
main (int argc, char* argv[])
{
  Communicator* comm = Communicator::instance();
  if (comm->init () == -1)
    return -1;

  demo::DelayResponse* task = new demo::DelayResponse;

  Endpoint endpoint ("TCP", "", 3000);
  ObjectAdapter* oa = comm->createObjectAdapterWithEndpoint ("MyHello", &endpoint);

  demo::AmhMyHelloI*  amh = new demo::AmhMyHelloI;
  amh->set(task);
  oa->add (amh, "MyHello");

  task->activate();

  comm->run ();

  delete task;

  return 0;
}
Пример #6
0
int
Subscriber::run(int argc, char* argv[]) {
  Communicator* comm = Communicator::instance();
  if (comm->init (true) == -1)
    return -1;

  Reference ref (comm, Identity("TopicManager"), Endpoint("TCP", "127.0.0.1", 5555));
  IcmProxy::IcmMsg::TopicManager topicManager;
  topicManager.setReference (&ref);

  ObjectAdapter* adapter = comm->createObjectAdapterWithEndpoint("Subscriber", "127.0.0.1 8888");
  IcmProxy::Object* networkProxy = adapter->add(new NetworkI(), "NetworkTopic");

  ::IcmProxy::IcmMsg::Topic* topic = topicManager.retrieve("NetworkTopic");
  if(topic == 0)
	  topic = topicManager.create("NetworkTopic");
  if (topic == 0)
    return -1;
  topic->subscribe(networkProxy);

  comm->run();

  return 0;
}
Пример #7
0
int physics_run(real t)
{
  //real bmk_t = MPI_Wtime();
  
  // Communicate variables
  comms.run();
  
  // Update profiles
  Nit = Ni0  + Ni.DC();
  Tit = Ti0  + Ti.DC();
  Tet = Te0  + Te.DC();
  Vit = Vi0  + Vi.DC();

  // Update non-linear coefficients on the mesh
  kapa_Te = 3.2*(1./fmei)*(wci/nueix)*(Tet^2.5);
  kapa_Ti = 3.9*(wci/nuiix)*(Tit^2.5);

  // note: nonlinear terms are not here
  peit = (Tet+Tit)*Nit;

  // DENSITY EQUATION
  F_Ni = -Vpar_Grad_par(Vit, Nit) 
    -Nit*Div_par(Vit) 
    +Div_X_K_Grad_X(D_perp*(Nit*0.0+1.0), Nit)
    ;


  // ION VELOCITY
  //F_Vi = -Grad_par(peit)/Nit -Vpar_Grad_par(Vit, Vit) + mu_perp*Delp2(Nit*Vit)/Nit;
  F_Vi = (
	  -Grad_par(peit) 
	  +Div_X_K_Grad_X(mu_perp*Nit, Vit)
	  )/Nit 
    -Vpar_Grad_par(Vit, Nit*Vit)/Nit 
    - F_Ni*Vit/Nit
    ;


  // ELECTRON TEMPERATURE
  F_Te = (Div_par_K_Grad_par(kapa_Te, Tet) 
	  +Div_X_K_Grad_X(chi_perp*Nit, Tet)
	  )/(1.5*Nit) 
    - F_Ni*Tet/Nit;


  // ION TEMPERATURE
  F_Ti = (Div_par_K_Grad_par(kapa_Ti, Tit) 
	  +Div_X_K_Grad_X(chi_perp*Nit, Tit)
	  )/(1.5*Nit)
    - F_Ni*Tit/Nit;


  // INNER TARGET PLATE
  
  bndry_ydown_flat(F_Ni); // Zero-gradient Ni
  bndry_ydown_relax_val(F_Vi, Vit, -3.095e4/Vi_x);
  bndry_ydown_relax_val(F_Te, Tet, 10./Te_x);
  bndry_ydown_relax_val(F_Ti, Tit, 10./Te_x);

  // OUTER TARGET PLATE

  bndry_yup_flat(F_Ni);
  bndry_yup_relax_val(F_Vi, Vit, 3.095e4/Vi_x);
  bndry_yup_relax_val(F_Te, Tet, 10./Te_x);
  bndry_yup_relax_val(F_Ti, Tit, 10./Te_x);
  
  // CORE BOUNDARY

  bndry_core_relax_val(F_Ni, Nit, 1e13/Ni_x);
  bndry_core_flat(F_Vi);
  bndry_core_relax_val(F_Te, Tet, 100./Te_x, lambda_relax);
  bndry_core_relax_val(F_Ti, Tit, 100./Te_x, lambda_relax);
  
  // PF BOUNDARY

  bndry_pf_relax_val(F_Ni, Nit, 1e12/Ni_x);
  bndry_pf_flat(F_Vi);
  bndry_pf_relax_val(F_Te, Tet, 10./Te_x);
  bndry_pf_relax_val(F_Ti, Tit, 10./Te_x);
  
  // OUTER BOUNDARY

  bndry_sol_relax_val(F_Ni, Nit, 1e12/Ni_x);
  bndry_sol_flat(F_Vi);
  bndry_sol_relax_val(F_Te, Tet, 10./Te_x);
  bndry_sol_relax_val(F_Ti, Tit, 10./Te_x);

  //output.write("TIMING: %e\n", MPI_Wtime() - bmk_t);

  return(0);
}