use ‘-fpermissive’. How to do it
I have a scalar CoMx which is value of x component of center of mass. i wanted to find its acceleration. For this purpose i wrote following code
scalar Ax = (CoMx(i)-2*CoMx(i-1)+CoMx(i-2))/(dt^2); Info << "Accelleration in x direction = " << Ax << nl << endl; But i got following error myInterFoamDDTNumerical.C:123:19: error: name lookup of ‘i’ changed for ISO ‘for’ scoping [-fpermissive] scalar Ax = (CoMx(i)-2*CoMx(i-1)+CoMx(i-2))/(dt^2); ^ myInterFoamDDTNumerical.C:123:19: note: (if you use ‘-fpermissive’ G++ will accept your code) myInterFoamDDTNumerical.C:123:20: error: ‘CoMx’ cannot be used as a function scalar Ax = (CoMx(i)-2*CoMx(i-1)+CoMx(i-2))/(dt^2); ^ myInterFoamDDTNumerical.C:123:32: error: ‘CoMx’ cannot be used as a function scalar Ax = (CoMx(i)-2*CoMx(i-1)+CoMx(i-2))/(dt^2); ^ myInterFoamDDTNumerical.C:123:42: error: ‘CoMx’ cannot be used as a function scalar Ax = (CoMx(i)-2*CoMx(i-1)+CoMx(i-2))/(dt^2); ^ myInterFoamDDTNumerical.C:123:46: error: ‘dt’ was not declared in this scope scalar Ax = (CoMx(i)-2*CoMx(i-1)+CoMx(i-2))/(dt^2); ^ Plz guide me how to use ‘-fpermissive’ |
Hello again,
You are presuming that OpenFoam is saving your CoMx at each time step in an array, well, he does not. you are also accessing your array with something called i, if you did some programing before you should understand that this variable should be declared and given a value. and why do you pass from one post to another, if you keep your work in one post people will understand your problems better. I advice you to either create an array to save your CoMx at each time step or save the three ones you need and replace them through each step. |
Sir you are right i should not switch between posts. sir i am new in openfoam with no or little interaction with programming. Can you guide me how to write an array in openfoam????.
|
if you send your case it would be better and easier
but in general you can declare 3 variables (double) called CoMx1, CoMx2, and CoMx3 and define an int i=0; before the time loop and then inside the loop do the following i++; if (i==1){ CoMx1=CoMx} else if (i==2){CoMx2=CoMx} else { CoMx3=CoMx; Ax=(CoMx3-2.0*CoMx2+CoMx1)/(well this is also a problem dt^2); CoMx1=CoMx2; CoMx2=CoMx3; } The problem above is that the program does not know your dt like this |
:-) thank you so much sir for your precious time. At last now i am thinking about using Libre Office :-D
|
Sir kebsiali please give me your email id i want to send you my case
|
|
Ok sorry bro i have sent you mail plz have a look on it
|
please watch your mail bro
|
All times are GMT -4. The time now is 06:53. |