|
[Sponsors] |
March 19, 2015, 00:26 |
use ‘-fpermissive’. How to do it
|
#1 |
Member
Muhammad Usman
Join Date: Feb 2014
Posts: 91
Rep Power: 0 |
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’ |
|
March 19, 2015, 04:14 |
|
#2 |
Member
ali alkebsi
Join Date: Jan 2012
Location: Strasbourg, France
Posts: 82
Rep Power: 14 |
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. |
|
March 19, 2015, 09:49 |
|
#3 |
Member
Muhammad Usman
Join Date: Feb 2014
Posts: 91
Rep Power: 0 |
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????.
|
|
March 19, 2015, 10:14 |
|
#4 |
Member
ali alkebsi
Join Date: Jan 2012
Location: Strasbourg, France
Posts: 82
Rep Power: 14 |
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 |
|
March 19, 2015, 11:52 |
|
#5 |
Member
Muhammad Usman
Join Date: Feb 2014
Posts: 91
Rep Power: 0 |
:-) thank you so much sir for your precious time. At last now i am thinking about using Libre Office :-D
|
|
March 20, 2015, 11:45 |
|
#6 |
Member
Muhammad Usman
Join Date: Feb 2014
Posts: 91
Rep Power: 0 |
Sir kebsiali please give me your email id i want to send you my case
|
|
March 20, 2015, 11:48 |
|
#7 |
Member
ali alkebsi
Join Date: Jan 2012
Location: Strasbourg, France
Posts: 82
Rep Power: 14 |
||
March 20, 2015, 11:53 |
|
#8 |
Member
Muhammad Usman
Join Date: Feb 2014
Posts: 91
Rep Power: 0 |
Ok sorry bro i have sent you mail plz have a look on it
|
|
March 20, 2015, 13:32 |
|
#9 |
Member
Muhammad Usman
Join Date: Feb 2014
Posts: 91
Rep Power: 0 |
please watch your mail bro
|
|
Thread Tools | Search this Thread |
Display Modes | |
|
|