CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

use ‘-fpermissive’. How to do it

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree4Likes
  • 2 Post By 13msmemusman
  • 2 Post By kebsiali

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 19, 2015, 00:26
Post use ‘-fpermissive’. How to do it
  #1
Member
 
Muhammad Usman
Join Date: Feb 2014
Posts: 91
Rep Power: 0
13msmemusman is on a distinguished road
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’
Kummi and Petey like this.
13msmemusman is offline   Reply With Quote

Old   March 19, 2015, 04:14
Default
  #2
Member
 
ali alkebsi
Join Date: Jan 2012
Location: Strasbourg, France
Posts: 82
Rep Power: 14
kebsiali is on a distinguished road
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.
13msmemusman and Petey like this.
kebsiali is offline   Reply With Quote

Old   March 19, 2015, 09:49
Post
  #3
Member
 
Muhammad Usman
Join Date: Feb 2014
Posts: 91
Rep Power: 0
13msmemusman is on a distinguished road
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????.
13msmemusman is offline   Reply With Quote

Old   March 19, 2015, 10:14
Default
  #4
Member
 
ali alkebsi
Join Date: Jan 2012
Location: Strasbourg, France
Posts: 82
Rep Power: 14
kebsiali is on a distinguished road
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
kebsiali is offline   Reply With Quote

Old   March 19, 2015, 11:52
Post
  #5
Member
 
Muhammad Usman
Join Date: Feb 2014
Posts: 91
Rep Power: 0
13msmemusman is on a distinguished road
:-) thank you so much sir for your precious time. At last now i am thinking about using Libre Office :-D
13msmemusman is offline   Reply With Quote

Old   March 20, 2015, 11:45
Post
  #6
Member
 
Muhammad Usman
Join Date: Feb 2014
Posts: 91
Rep Power: 0
13msmemusman is on a distinguished road
Sir kebsiali please give me your email id i want to send you my case
13msmemusman is offline   Reply With Quote

Old   March 20, 2015, 11:48
Default
  #7
Member
 
ali alkebsi
Join Date: Jan 2012
Location: Strasbourg, France
Posts: 82
Rep Power: 14
kebsiali is on a distinguished road
HI Muhammad
stop saying sir sir, im just helping with what i can,
my email is kebsiali@gmail.com
kebsiali is offline   Reply With Quote

Old   March 20, 2015, 11:53
Post
  #8
Member
 
Muhammad Usman
Join Date: Feb 2014
Posts: 91
Rep Power: 0
13msmemusman is on a distinguished road
Ok sorry bro i have sent you mail plz have a look on it
13msmemusman is offline   Reply With Quote

Old   March 20, 2015, 13:32
Post
  #9
Member
 
Muhammad Usman
Join Date: Feb 2014
Posts: 91
Rep Power: 0
13msmemusman is on a distinguished road
please watch your mail bro
13msmemusman is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 16:25.