Exemplo n.º 1
0
ReturnType SendCouplingMDCommand::executeProcessing()
{
	logger->debug() << "starting SendCouplingMDCommand::executeProcessing" << std::endl;
	CouplingInformationType* couplingInfo = (CouplingInformationType*) this->getData(0);
	Simulation* theSim = (Simulation*) this->getData(1);
	ParticleContainer* moleculeContainer = theSim->getMolecules();

	if (transferContainer == NULL)
	{
		transferContainer = new std::vector<Molecule>[couplingInfo->numberOfBoundaries];
	}

/*	int dim = borderToLook / 2;
	int dir = borderToLook % 2;*/
	int dim, dir;
	outmin = 0;
	outmax = 0;
	double rmin =  moleculeContainer->getBoundingBoxMin(dim);
	double rmax =  moleculeContainer->getBoundingBoxMax(dim);

	logger->debug() << "dim is " << dim << ", dir is " << dir << std::endl;
	logger->debug() << "halo is " << moleculeContainer->get_halo_L(dim) << std::endl;
	Molecule* currentMolecule;

	double low_limit = rmin; // particles below this limit have to be copied or moved to the lower process
	double high_limit = rmax; // particles above(or equal) this limit have to be copied or moved to the higher process

	currentMolecule = moleculeContainer->begin();

	logger->debug() << "low_limit: " << low_limit << " / high_limit: " << high_limit << std::endl;
	while(currentMolecule!=moleculeContainer->end()){
		for (int i = 0; i < couplingInfo->numberOfBoundaries; i++)
		{
			CouplingBoundary currentBoundary = couplingInfo->boundaries[i];
			//const double& rd=currentMolecule->r(dim);
			const double& rd = currentMolecule->r(currentBoundary.outFlowDirection);
			const double& ro1 = currentMolecule->r(currentBoundary.otherDirection[0]);
			const double& ro2 = currentMolecule->r(currentBoundary.otherDirection[1]);
			if ((currentBoundary.lowerHigher == 1) && (rd > high_limit) && isInBounds(ro1,ro2, &currentBoundary))
			{
				outmax++;
				transferContainer[i].push_back(*currentMolecule);
				currentMolecule = moleculeContainer->deleteCurrent ();
				break;
			}
			else if ((currentBoundary.lowerHigher == 0) && (rd < low_limit) && isInBounds(ro1,ro2, &currentBoundary))
			{
				transferContainer[i].push_back(*currentMolecule);
				currentMolecule = moleculeContainer->deleteCurrent();
				outmin++;
				break;
			}
			else
			{
				currentMolecule = moleculeContainer->next();
			}
		}
	}
	logger->debug() << "outmin["<< dim << "] = " << outmin << std::endl;
	logger->debug() << "outmax["<< dim << "] = " << outmax << std::endl;
	//logger->debug() << "there are now " << transferContainer.size() << " molecules to transfer " << std::endl;
	if (getStepInterval() > 0)
	{
		return REPETITION_REQUESTED;
	}
	else
	{
		return EXECUTED;
	}

}