示例#1
0
Epetra_Map_Ptr CreateWavefunctionMultiVectorEpetraMap(typename Wavefunction<Rank>::Ptr psi, int opRank)
{
	typedef blitz::Array<cplx, Rank> ArrayType;
	
	//Create a comm object from wavefunction distribution. Only involves procs with
	//data for current operation rank
	typename DistributedModel<Rank>::Ptr distr = psi->GetRepresentation()->GetDistributedModel();
	Epetra_Comm_Ptr comm = CreateDistributedModelEpetraComm<Rank>(distr, opRank);

	//Local size of wavefunction (opRank)
	ArrayType data = psi->GetData();
	int localSize = data.extent(opRank);

	//Get global start idx for opRank
	int rankSizeGlobal = psi->GetRepresentation()->GetFullShape()(opRank);
	int globalStartIdx = distr->GetLocalStartIndex(rankSizeGlobal, opRank);

	//Create index map for local elements (local idx -> global idx) 
	int* myElems = new int[localSize];

	//Setup local->global index map
	for (int i=0; i<localSize; i++)	
	{
		myElems[i] = i + globalStartIdx;
	}

	return Epetra_Map_Ptr( new Epetra_Map(-1, localSize, myElems, 0, *comm) );
}
示例#2
0
/*
 * Maps the given wavefunction to one where the particles are exchanged
 * psi(1,2) -> psi(2,1)
 */
Wavefunction<3>::Ptr GetWavefunctionParticleExchange(Wavefunction<3>::Ptr psi, list angularSymmetrizationPairs)
{
	typedef Array<cplx, 3> ArrayType;
	ArrayType data = psi->GetData();

	int countr = data.extent(1);
	typedef stl_input_iterator<tuple> Iterator;
	Iterator begin(angularSymmetrizationPairs);
	Iterator end;

	Wavefunction<3>::Ptr exchgPsi = psi->Copy();
	ArrayType exchgData = exchgPsi->GetData();

	for (Iterator i=begin; i!=end; i++)
	{
		int a1 = extract<int>((*i)[0]);
		int a2 = extract<int>((*i)[1]);

		for (int r1=0; r1<countr; r1++)
		{
			for (int r2=0; r2<countr; r2++)
			{
				exchgData(a1, r1, r2) = data(a2, r2, r1);
			}
		}
	}
	
	return exchgPsi;
}