Access to TensorField2D

Hello all,

I am trying to have access to Tensorfield2D through get(iX,iY) function which return reference tensor type. However, the compilator gives me the error cpp:131: error: invalid array assignment

Could you comment something or just explain how can I have access to TensorField2D to each node.

Here is the piece of code:

void calculateforce(TensorField2D<T,2>& force,BlockStructure2D<T,DESCRIPTOR>& lattice)
{

//TensorField2D<T,2> calc;
T calc[2];
for(int iX=0;iX<nx;iX++)
{
	for(int iY=0;iY<ny;iY++)
	{
		for (int m=0;m < DESCRIPTOR<T>::d;m++)
		{			
			calc[0]=0.0;calc[1]=0.0;
			for(int k=0;k < DESCRIPTOR<T>::q; k++)
			{
				calc[m]=calc[m]+DESCRIPTOR<T>::t[k]*((T)1-            exp(lattice.get(iX,iY).computeRho()))*DESCRIPTOR<T>::c[k][m];
			}
			
			calc[m]= -G*calc[m]*((T)1-exp(lattice.get(iX,iY).computeRho()));
			//force[m][iX][iY]=calc[m];
		}		
		force.get(iX,iY)=calc;
	}

}

}

Thank you,
Alex

Hi Alex,
you cannot do equalities with array in c++. You should add a for loop to have something like :

for (iD=0; iD < DESCRIPTOR::d; ++iD)
{
force.get(iX,iY)[iD] = calc[iD];
}

Thank you Orestis!

It was 8 years since I’ve not working with C and C++.

Alex