Beispiel #1
0
void ActionWithAveraging::update() {
  if( (clearstride!=1 && getStep()==0) || !onStep() ) return;
  // Clear if it is time to reset
  if( myaverage ) {
    if( myaverage->wasreset() ) clearAverage();
  }
  // Calculate the weight for all reweighting
  if ( weights.size()>0 ) {
    double sum=0; for(unsigned i=0; i<weights.size(); ++i) sum+=weights[i]->get();
    lweight=sum; cweight = exp( sum );
  } else {
    lweight=0; cweight=1.0;
  }
  // Prepare to do the averaging
  prepareForAveraging();
  // Run all the tasks (if required
  if( useRunAllTasks ) runAllTasks();
  // This the averaging if it is not done using task list
  else performOperations( true );
  // Update the norm
  if( myaverage ) myaverage->setNorm( cweight + myaverage->getNorm() );
  // Finish the averaging
  finishAveraging();
  // By resetting here we are ensuring that the grid will be cleared at the start of the next step
  if( myaverage ) {
    if( getStride()==0 || (clearstride>0 && getStep()%clearstride==0) ) myaverage->reset();
  }
}
//callable object to receive string or byte buffer
void Reciever::operator()(Socket& socket_)
{
	Message m;
	bool flag = false;
  while (true)
  {
    // interpret test command
    std::string command = socket_.recvString();
	std::string header = "";
	std::stringstream ss(command);
	std::string item;
	std::vector<std::string> vec = m.splitting(command,'\n');
	std::map<std::string, std::string> map = m.makeMap(vec);
	std::string mapCommand = map["Command"];
	std::string fileName = map["FileName"];
	if (command.size() == 0)//if there is no command
	{
		break;
	}
	else
	{
		performOperations(socket_, m,command, mapCommand, map);
	}
  }
}
Beispiel #3
0
void ActionWithGrid::calculate(){
  // Do nothing if derivatives are not required
  if( doNotCalculateDerivatives() ) return;
  // Clear on every step
  if( mygrid ) clearAverage();
  // Should not be any reweighting so just set these accordingly
  lweight=0; cweight=1.0;
  // Prepare to do the averaging
  prepareForAveraging();
  // Run all the tasks (if required
  if( useRunAllTasks ) runAllTasks();
  // This the averaging if it is not done using task list
  else performOperations( true );
  // Update the norm
  if( mygrid ) mygrid->setNorm( cweight );
  // Finish the averaging
  finishAveraging();
  // And reset for next step
  if( mygrid ) mygrid->reset();
}