
[Sponsors] 
March 15, 2015, 09:17 
problem in defining the field

#1 
Member
Muhammad Usman
Join Date: Feb 2014
Posts: 67
Rep Power: 3 
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 

March 15, 2015, 13:17 

#2 
New Member
Bruno Kassar
Join Date: Apr 2014
Location: Rio de Janeiro
Posts: 8
Rep Power: 3 
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 

March 16, 2015, 02:12 

#3 
New Member
Mattia de\' Michieli Vitturi
Join Date: Mar 2009
Posts: 23
Rep Power: 8 
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 

March 16, 2015, 11:26 

#4 
Member
Muhammad Usman
Join Date: Feb 2014
Posts: 67
Rep Power: 3 
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


March 16, 2015, 12:08 

#5 
New Member
Bruno Kassar
Join Date: Apr 2014
Location: Rio de Janeiro
Posts: 8
Rep Power: 3 
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 

March 16, 2015, 12:13 

#6 
Member
Muhammad Usman
Join Date: Feb 2014
Posts: 67
Rep Power: 3 
Sir i want to take double derivative of every component of this vector as i have to put it in a formulae


March 16, 2015, 12:15 

#7 
Member
Muhammad Usman
Join Date: Feb 2014
Posts: 67
Rep Power: 3 
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


March 16, 2015, 12:30 

#8 
New Member
Bruno Kassar
Join Date: Apr 2014
Location: Rio de Janeiro
Posts: 8
Rep Power: 3 
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 secondorder differencing scheme you may choose. Hope that helps. 

March 16, 2015, 13:26 

#9 
Member
Muhammad Usman
Join Date: Feb 2014
Posts: 67
Rep Power: 3 
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. 

March 17, 2015, 11:26 

#10 
Member
Muhammad Usman
Join Date: Feb 2014
Posts: 67
Rep Power: 3 
please help


March 17, 2015, 15:07 

#11 
New Member
Bruno Kassar
Join Date: Apr 2014
Location: Rio de Janeiro
Posts: 8
Rep Power: 3 
Hi Muhammad,
The second derivative you want to take is with respect to time? 

March 18, 2015, 11:17 

#12 
Member
Muhammad Usman
Join Date: Feb 2014
Posts: 67
Rep Power: 3 
yes sir its with respect to time


March 18, 2015, 11:32 

#13 
Member
Muhammad Usman
Join Date: Feb 2014
Posts: 67
Rep Power: 3 
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.


March 18, 2015, 13:43 

#14 
New Member
Bruno Kassar
Join Date: Apr 2014
Location: Rio de Janeiro
Posts: 8
Rep Power: 3 
So now, you just need the value of CoM at three consecutive time steps; let's say CoM(i2), CoM(i1) and CoM(i). Choose a secondorder differencing scheme and use these three values to obtain the acceleration. There are many ways to do it. The easiest one would be the secondorder backward scheme. For your problem, it would give something like:
A = (CoM(i)2*CoM(i1)+CoM(i2))/(dt^2) Hope that helps! cheers, Bruno 

March 18, 2015, 13:49 

#15 
Member
Muhammad Usman
Join Date: Feb 2014
Posts: 67
Rep Power: 3 
Thank you very much sir....


Tags 
field creatfields.h 
Thread Tools  
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Moving mesh  Niklas Wikstrom (Wikstrom)  OpenFOAM Running, Solving & CFD  122  June 15, 2014 06:20 
Defining convergent gravity field! please Help me  adambarfi  OpenFOAM  24  August 1, 2012 12: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 08:31 
Aeroacustic problem in Automotive field  Gabriele Velenich  Main CFD Forum  5  December 11, 2001 04:43 