# problem in defining the field

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

 March 15, 2015, 13:17 #2 New Member   Bruno Kassar Join Date: Apr 2014 Location: Rio de Janeiro Posts: 9 Rep Power: 10 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 Member   Mattia de\' Michieli Vitturi Join Date: Mar 2009 Posts: 48 Rep Power: 15 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: 91 Rep Power: 10 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: 9 Rep Power: 10 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: 91 Rep Power: 10 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: 91 Rep Power: 10 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: 9 Rep Power: 10 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.

 March 16, 2015, 13:26 #9 Member   Muhammad Usman Join Date: Feb 2014 Posts: 91 Rep Power: 10 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, 15:07 #11 New Member   Bruno Kassar Join Date: Apr 2014 Location: Rio de Janeiro Posts: 9 Rep Power: 10 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: 91 Rep Power: 10 yes sir its with respect to time

 March 18, 2015, 11:32 #13 Member   Muhammad Usman Join Date: Feb 2014 Posts: 91 Rep Power: 10 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: 9 Rep Power: 10 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

 March 18, 2015, 13:49 #15 Member   Muhammad Usman Join Date: Feb 2014 Posts: 91 Rep Power: 10 Thank you very much sir....

 Tags field creatfields.h