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

How to solve for components of Center of mass?

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 17, 2015, 11:53
Post How to solve for components of Center of mass?
  #1
Member
 
Muhammad Usman
Join Date: Feb 2014
Posts: 91
Rep Power: 0
13msmemusman is on a distinguished road
Hye Foamers, i calculated center of mass by writing following formula in interFoam.C

CoM = sum(rho*mesh.V()*mesh.C().dimensionedInternalField ())/sum(rho*mesh.V());

now i want to calculate acceleration of center of mass in each dimension. So first i tried to calculate x y and z components of CoM using following formula.

CoMx = CoM.x();
CoMy = CoM.y();
CoMz = CoM.z();

then i tried
volScalarField CoMx = CoM.component(vector::X);
volScalarField CoMy = CoM.component(vector::Y);
volScalarField CoMz = CoM.component(vector::Z);

there was still error
which was this
myInterFoamDDT.C: In function ‘int main(int, char**)’:
myInterFoamDDT.C:111:46: error: conversion from ‘Foam::dimensioned<double>’ to non-scalar type ‘Foam::volScalarField {aka Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>}’ requested
volScalarField CoMx = CoM.component(vector::X);

myInterFoamDDT.C:112:46: error: conversion from ‘Foam::dimensioned<double>’ to non-scalar type ‘Foam::volScalarField {aka Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>}’ requested
volScalarField CoMy = CoM.component(vector::Y);

myInterFoamDDT.C:113:46: error: conversion from ‘Foam::dimensioned<double>’ to non-scalar type ‘Foam::volScalarField {aka Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>}’ requested
volScalarField CoMz = CoM.component(vector::Z);


After that i tried

volScalarField CoMx = CoM.component(0);

Error was
myInterFoamDDT.C: In function ‘int main(int, char**)’:
myInterFoamDDT.C:111:38: error: conversion from ‘Foam::dimensioned<double>’ to non-scalar type ‘Foam::volScalarField {aka Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>}’ requested
volScalarField CoMx = CoM.component(0);


i Got following error please help me

myInterFoamDDT.C: In function ‘int main(int, char**)’:
myInterFoamDDT.C:111:1: error: ‘CoMx’ was not declared in this scope
CoMx = CoM.x();
^
myInterFoamDDT.C:111:12: error: ‘Foam::dimensionedVector’ has no member named ‘x’
CoMx = CoM.x();
^
13msmemusman is offline   Reply With Quote

Old   March 17, 2015, 12:26
Default
  #2
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,938
Rep Power: 39
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Hi,

Centre of mass is vector (in your particular case it is dimensionedVector due to the definition), so

Code:
volScalarField CoMx = CoM.component(vector::X); 
volScalarField CoMy = CoM.component(vector::Y);
volScalarField CoMz = CoM.component(vector::Z);
this is non-sence as you are trying to create field from scalar.

Code:
volScalarField CoMx = CoM.component(0);
is non-sence like the previous expressions.

Compiler tries to help you, gives you hints like this

Code:
myInterFoamDDT.C:111:12: error: ‘Foam::dimensionedVector’ has no member named ‘x’
CoMx = CoM.x();
but you ignore him.

If you would like to get components of dimensionedVector, you should use something like

Code:
scalar CoMx = CoM.value().x()
or if you would like component as dimensionedScalar:

Code:
dimensionedScalar CoMx
(
    "CoMx",
    CoM.dimensions(),
    CoM.value().x()
);
alexeym is offline   Reply With Quote

Old   March 17, 2015, 12:43
Post
  #3
Member
 
Muhammad Usman
Join Date: Feb 2014
Posts: 91
Rep Power: 0
13msmemusman is on a distinguished road
Thank you sir i got the point...... sorry i am new in openFoam
13msmemusman is offline   Reply With Quote

Old   March 17, 2015, 12:46
Post
  #4
Member
 
Muhammad Usman
Join Date: Feb 2014
Posts: 91
Rep Power: 0
13msmemusman is on a distinguished road
Thank you sir i got the point...... sorry i am new in openFoam
Please tell me how to define it in creatFields.H

as for center of mass i did
CoM = sum(rho*mesh.V()*mesh.C().dimensionedInternalField ())/sum(rho*mesh.V());

in interFoam.C

and specified
dimensionedVector CoM("CoM", dimLength, vector::zero);
in creatFields.H with the help of teachers like you :-)
13msmemusman is offline   Reply With Quote

Reply


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
Target Mass Flow Rate Nitin FLUENT 9 June 17, 2017 11:30
moving position for DFBI center of mass vince60270 STAR-CCM+ 11 June 25, 2014 06:45
Verifying Mass Balance in Fluent Noblek330 FLUENT 0 March 27, 2014 19:18
total mass loss/gain--simulating taylor couette flow nwpukaka OpenFOAM Programming & Development 0 February 12, 2014 19:57
is it possible to solve mass transfer problems in FLUENT travikiran FLUENT 2 August 11, 2010 05:46


All times are GMT -4. The time now is 23:38.