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

problem in defining the field

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 15, 2015, 09:17
Post problem in defining the field
  #1
Member
 
Muhammad Usman
Join Date: Feb 2014
Posts: 91
Rep Power: 0
13msmemusman is on a distinguished road
i entered following equation in interFoam.C
CoM = sum(rho*mesh.V()*mesh.C().dimensionedInternalField ())/sum(rho*mesh.V());
then defined it in creatFields.H as following
dimensionedVector CoM("CoM", dimLength, vector::zero);
then i compiled it works well. but now i want to take its gradient. i wrote
gradCoM = grad (CoM);
and defined it in creatFields.H as following
uniformDimensionedVectorField gradCoM("gradCoM", dimLength, vector::zero);
now it gives following error please help
In file included from myInterFoamDDT.C:60:0:
createFields.H: In function ‘int main(int, char**)’:
createFields.H:2:73: error: no matching function for call to ‘Foam::UniformDimensionedField<Foam::Vector<double > >::UniformDimensionedField(const char [8], const Foam::dimensionSet&, const Foam::Vector<double>&)’
uniformDimensionedVectorField gradCoM("gradCoM", dimLength, vector::zero);
one thing is obvious in my views that problem is in defining the field as UniformDimensionedField...... please help
13msmemusman is offline   Reply With Quote

Old   March 15, 2015, 13:17
Default
  #2
New Member
 
Bruno Kassar
Join Date: Apr 2014
Location: Rio de Janeiro
Posts: 9
Rep Power: 12
bkassar is on a distinguished road
Hi Muhammad,
The compiler is complaining about the constructor of uniformDimensionedVectorField.
However, I think your main problem is not that.
The main issue is that you are trying to compute the gradient of a vector. Notice that the variable 'CoM' is not a Field.
cheers,
Bruno
bkassar is offline   Reply With Quote

Old   March 16, 2015, 02:12
Default
  #3
Member
 
Mattia de\' Michieli Vitturi
Join Date: Mar 2009
Posts: 51
Rep Power: 17
demichie is on a distinguished road
In addition if you have a field A the gradient of A should have the units of A divided by the unit of lenght.

Ciao
Mattia
demichie is offline   Reply With Quote

Old   March 16, 2015, 11:26
Post
  #4
Member
 
Muhammad Usman
Join Date: Feb 2014
Posts: 91
Rep Power: 0
13msmemusman is on a distinguished road
Sir you are right that its not a field. i am taking gradient of a vector. then what should i use instead of DimensionedVector???? actually i read that gradient of a vector is a tensor thats why i wrote that
13msmemusman is offline   Reply With Quote

Old   March 16, 2015, 12:08
Default
  #5
New Member
 
Bruno Kassar
Join Date: Apr 2014
Location: Rio de Janeiro
Posts: 9
Rep Power: 12
bkassar is on a distinguished road
Hi Muhammad,
As far as I see, you computed the center of mass and stored it in 'CoM'.
Could you tell us what you want to compute?
It is not clear to me why you need the gradient...
cheers,
Bruno
bkassar is offline   Reply With Quote

Old   March 16, 2015, 12:13
Post
  #6
Member
 
Muhammad Usman
Join Date: Feb 2014
Posts: 91
Rep Power: 0
13msmemusman is on a distinguished road
Sir i want to take double derivative of every component of this vector as i have to put it in a formulae
13msmemusman is offline   Reply With Quote

Old   March 16, 2015, 12:15
Post
  #7
Member
 
Muhammad Usman
Join Date: Feb 2014
Posts: 91
Rep Power: 0
13msmemusman is on a distinguished road
Sir i want to take double derivative of every component of this vector as i have to put it in a formulae. i am sorry at first i was wrong. i was thinking that formulae requires double spacial derivative of COM completely. i want to take double derivative of every component of CoM. thank you sir
13msmemusman is offline   Reply With Quote

Old   March 16, 2015, 12:30
Default
  #8
New Member
 
Bruno Kassar
Join Date: Apr 2014
Location: Rio de Janeiro
Posts: 9
Rep Power: 12
bkassar is on a distinguished road
I see. So, by double derivative you mean double derivative with respect to time? You want the acceleration of this center of mass?
If the answer is yes, you could store the values of CoM in three different time steps and perform the derivatives by a second-order differencing scheme you may choose.
Hope that helps.
bkassar is offline   Reply With Quote

Old   March 16, 2015, 13:26
Post
  #9
Member
 
Muhammad Usman
Join Date: Feb 2014
Posts: 91
Rep Power: 0
13msmemusman is on a distinguished road
sir i stored components of Varible CoM in 3 different varibles in following way

CoM = sum(rho*mesh.V()*mesh.C().dimensionedInternalField ())/sum(rho*mesh.V());
Info << "Center of Mass " << CoM.dimensions() << " = " << CoM << nl << endl;
vector CoMx = CoM.x();
vector CoMy = CoM.y();
vector CoMz = CoM.z();


but it gives following error

myInterFoamDDT.C: In function ‘int main(int, char**)’:
myInterFoamDDT.C:111:19: error: ‘Foam::dimensionedVector’ has no member named ‘x’
vector CoMx = CoM.x();
^
myInterFoamDDT.C:112:19: error: ‘Foam::dimensionedVector’ has no member named ‘y’
vector CoMy = CoM.y();
^
myInterFoamDDT.C:113:19: error: ‘Foam::dimensionedVector’ has no member named ‘z’


Please help me.
13msmemusman is offline   Reply With Quote

Old   March 17, 2015, 11:26
Default
  #10
Member
 
Muhammad Usman
Join Date: Feb 2014
Posts: 91
Rep Power: 0
13msmemusman is on a distinguished road
please help
13msmemusman is offline   Reply With Quote

Old   March 17, 2015, 15:07
Default
  #11
New Member
 
Bruno Kassar
Join Date: Apr 2014
Location: Rio de Janeiro
Posts: 9
Rep Power: 12
bkassar is on a distinguished road
Hi Muhammad,
The second derivative you want to take is with respect to time?
bkassar is offline   Reply With Quote

Old   March 18, 2015, 11:17
Post
  #12
Member
 
Muhammad Usman
Join Date: Feb 2014
Posts: 91
Rep Power: 0
13msmemusman is on a distinguished road
yes sir its with respect to time
13msmemusman is offline   Reply With Quote

Old   March 18, 2015, 11:32
Default
  #13
Member
 
Muhammad Usman
Join Date: Feb 2014
Posts: 91
Rep Power: 0
13msmemusman is on a distinguished road
The problem specified above is solved.... now i just want to take its derivative with respect to time. means i need acceleration of center of mass.
13msmemusman is offline   Reply With Quote

Old   March 18, 2015, 13:43
Default
  #14
New Member
 
Bruno Kassar
Join Date: Apr 2014
Location: Rio de Janeiro
Posts: 9
Rep Power: 12
bkassar is on a distinguished road
So now, you just need the value of CoM at three consecutive time steps; let's say CoM(i-2), CoM(i-1) and CoM(i). Choose a second-order differencing scheme and use these three values to obtain the acceleration. There are many ways to do it. The easiest one would be the second-order backward scheme. For your problem, it would give something like:
A = (CoM(i)-2*CoM(i-1)+CoM(i-2))/(dt^2)
Hope that helps!
cheers,
Bruno
bkassar is offline   Reply With Quote

Old   March 18, 2015, 13:49
Post
  #15
Member
 
Muhammad Usman
Join Date: Feb 2014
Posts: 91
Rep Power: 0
13msmemusman is on a distinguished road
Thank you very much sir....
13msmemusman is offline   Reply With Quote

Reply

Tags
field creatfields.h


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Moving mesh Niklas Wikstrom (Wikstrom) OpenFOAM Running, Solving & CFD 122 June 15, 2014 07:20
Defining convergent gravity field! please Help me adambarfi OpenFOAM 24 August 1, 2012 13:34
Defining "cyclic" B.C. problem maysmech OpenFOAM 20 March 14, 2011 11:28
Surface Vector Field Problem at Parallel cwang5 OpenFOAM Bugs 6 July 12, 2010 09:31
Aeroacustic problem in Automotive field Gabriele Velenich Main CFD Forum 5 December 11, 2001 04:43


All times are GMT -4. The time now is 18:48.