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

add a force in momentum equation

Register Blogs Community New Posts Updated Threads Search

Like Tree4Likes
  • 1 Post By pferro
  • 2 Post By pferro
  • 1 Post By Mahmoud Abbaszadeh

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 6, 2021, 20:11
Default add a force in momentum equation
  #1
New Member
 
simona
Join Date: Apr 2021
Posts: 21
Rep Power: 5
carolee is on a distinguished road
Hi everybody,
I am new to openfoam, I am studying a laminar flow of water in a cylindrical tube with velocity 1m / s using simpleFoam and I need to add a source term in the momentum equation which is a force in the same direction of flow which should increase the velocity of the fluid flow a little bit, I tried with this method but the velocity remains at the same value and the flow becomes non-laminar, please who can help me to solve this problem

dimensionedVector F("F", dimensionSet(0,1,-2,0,0,0,0), vector(0,0,30));

tmp<fvVectorMatrix> tUEqn
(
fvm::div(phi, U)
+ MRF.DDt(U)
+ turbulence->divDevReff(U)
- fvm::laplacian(mu, U)
==
fvOptions(U)
+ F

);

fvVectorMatrix& UEqn = tUEqn.ref();
carolee is offline   Reply With Quote

Old   May 7, 2021, 06:42
Default
  #2
New Member
 
simona
Join Date: Apr 2021
Posts: 21
Rep Power: 5
carolee is on a distinguished road
any reply will be appreciated, I really want help
carolee is offline   Reply With Quote

Old   May 7, 2021, 06:54
Default
  #3
Senior Member
 
Hojatollah Gholami
Join Date: Jan 2019
Posts: 171
Rep Power: 7
Hgholami is on a distinguished road
Hello
may you can use temple of bodyForce() in fsi of foam-extend4.0 (unsTotalLagrangianSolid.C).

bodyForce() = dimensionedVector(solidProperties().lookup("g"));

fvVectorMatrix DEqn
(
rho_*fvm::d2dt2(D_)
== fvm::laplacian(2*muf_ + lambdaf_, D_, "laplacian(DD,D)")
+ fvc::div
(
mesh().Sf()
& (
- (muf_ + lambdaf_)*gradDf_
+ muf_*gradDf_.T()
+ lambdaf_*(I*tr(gradDf_))
)
)
+ rho_*bodyForce()
);
Hgholami is offline   Reply With Quote

Old   May 7, 2021, 11:48
Default
  #4
New Member
 
simona
Join Date: Apr 2021
Posts: 21
Rep Power: 5
carolee is on a distinguished road
thank you gholami for your reply
carolee is offline   Reply With Quote

Old   May 15, 2021, 14:31
Default a bit of help
  #5
New Member
 
Paulin FERRO
Join Date: May 2021
Location: France
Posts: 21
Rep Power: 4
pferro is on a distinguished road
Hello,


For instance you can :
1 : declare a volVectorField mySource.

2 : loop over the cells and fill mySource. Here you can loop on a specific zone of your mesh.

3 : add in the left member of Ueqn the source mySource.

Good luck !
carolee likes this.
pferro is offline   Reply With Quote

Old   May 17, 2021, 04:09
Default solution
  #6
New Member
 
Paulin FERRO
Join Date: May 2021
Location: France
Posts: 21
Rep Power: 4
pferro is on a distinguished road
Hello,

Please find below some details of a possible implementation. Note that I didn't have tested the code since I am directly writing it here. Also note that there are other ways for doing it.

I assume that we use an incompressible solver such as simpleFoam or pimpleFoam. In this case each member of the momentum equation is divided by rho. As rho is uniform the solver use the kinematic viscosity and a modified pressure : [p/rho] = m^2 / s^2.

The source term in the momentum equation has the dimension of an acceleration i.e = m/s^2.

First step : creating the momentum source

In createField.H of the solver we declare a volVectorField and we call it force.

Quote:
volVectorField force
(
IOobject
(
"force",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh,
dimensionedVector("0", dimVelocity/dimTime, Zero)
);
On the code above we use
Quote:
AUTO_WRITE
this will be useful for visualizing the field in paraview.

Second step : filing the momentum source

The force volVectorField is initialized in createField.H and is equal to 0 on the whole mesh. Now we need to fill it according to what we want to do. Thus we need to create a loop over cells. For example we can do that in the UEqn.H file. This means that the source will be updated for each SIMPLE loop.

Quote:
forAll(mesh.cells(),cellI)
{
// here do whatever you want to do
// for example we calculate force only if x > 0.5
// you can obtain cell center coordinates

const vector& cCenterCoor = mesh.C()[cellI];

// and create a test on the cell position
scalar xMax = 0.5 ;
if ( (pos(cCenterCoor[0] - xMax) )
{
force[cellI] = vector(1.,-1.,0.05); // again it's an example
}
else
{
force[cellI] = vector(0.,0.,0.); // if the condition above is not valid then the source remains zero
}
}
;
Third step : adding the source in Ueqn

Very simple :
Quote:
fvVectorMatrix UEqn
(
fvm::ddt(U)
+ fvm::div(phi,U)
+ turbulence->divDevReff(U)
- force
==
fvOptions(U)
);
Final step : compile

Quote:
wmake
Good luck !

Paulin
oumnion and mllokloks like this.
pferro is offline   Reply With Quote

Old   June 20, 2022, 08:14
Default
  #7
Member
 
Mahmoud
Join Date: Nov 2020
Location: United Kingdom
Posts: 43
Rep Power: 5
Mahmoud Abbaszadeh is on a distinguished road
Quote:
Originally Posted by pferro View Post
Hello,

Please find below some details of a possible implementation. Note that I didn't have tested the code since I am directly writing it here. Also note that there are other ways for doing it.

I assume that we use an incompressible solver such as simpleFoam or pimpleFoam. In this case each member of the momentum equation is divided by rho. As rho is uniform the solver use the kinematic viscosity and a modified pressure : [p/rho] = m^2 / s^2.

The source term in the momentum equation has the dimension of an acceleration i.e = m/s^2.

First step : creating the momentum source

In createField.H of the solver we declare a volVectorField and we call it force.



On the code above we use this will be useful for visualizing the field in paraview.

Second step : filing the momentum source

The force volVectorField is initialized in createField.H and is equal to 0 on the whole mesh. Now we need to fill it according to what we want to do. Thus we need to create a loop over cells. For example we can do that in the UEqn.H file. This means that the source will be updated for each SIMPLE loop.



Third step : adding the source in Ueqn

Very simple :


Final step : compile



Good luck !

Paulin

Hi Paulin,

I am wondering why you have not used fvOptions to introduce the body force into your equations?
Haitham Osman CFD likes this.
Mahmoud Abbaszadeh 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
ActuatorDiskExplicitForce in OF2.1. Help be_inspired OpenFOAM Programming & Development 10 September 14, 2018 11:12
Can not add force to Equn in interFoam,Help zhibin.wang OpenFOAM Running, Solving & CFD 0 August 22, 2016 07:10
how to add source-term in momentum equation for interFoam? anon_g OpenFOAM 9 October 18, 2011 12:47
how to add a force in the momentum equation guillaumem OpenFOAM 0 June 14, 2010 03:49
Viscosity and the Energy Equation Rich Main CFD Forum 0 December 16, 2009 14:01


All times are GMT -4. The time now is 07:04.