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

Adding a body force term in the SIMPLE algorithm

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By HPE

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 9, 2020, 11:47
Default Adding a body force term in the SIMPLE algorithm
  #1
New Member
 
Join Date: Jan 2013
Posts: 7
Rep Power: 13
karman is on a distinguished road
Hi all,

I need to add an electric body force term (let's call it Fci) in the Navier-Stokes momentum equation and I chose the simpleFoam solver because I have an incompressible and steady-state flow...so I first modified the createFields.H file in this solver by adding the new entries highlighted in red:

Code:
Info<< "Reading field p\n" << endl;
volScalarField p
(
    IOobject
    (
        "p",
        runTime.timeName(),
        mesh,
        IOobject::MUST_READ,
        IOobject::AUTO_WRITE
    ),
    mesh
);

Info<< "Reading field U\n" << endl;
volVectorField U
(
    IOobject
    (
        "U",
        runTime.timeName(),
        mesh,
        IOobject::MUST_READ,
        IOobject::AUTO_WRITE
    ),
    mesh
);

Info<< "Reading field Fci\n" << endl;
volVectorField Fci
(
    IOobject
    (
        "Fci",
        runTime.timeName(),
        mesh,
        IOobject::MUST_READ,
        IOobject::AUTO_WRITE
    ),
    mesh
);

volScalarField rho
(
    IOobject
    (
        "rho",
        runTime.timeName(),
        mesh,
        IOobject::NO_READ,
        IOobject::NO_WRITE
    ),
    mesh
);

#include "createPhi.H"


label pRefCell = 0;
scalar pRefValue = 0.0;
setRefCell(p, simple.dict(), pRefCell, pRefValue);
mesh.setFluxRequired(p.name());


singlePhaseTransportModel laminarTransport(U, phi);

autoPtr<incompressible::turbulenceModel> turbulence
(
    incompressible::turbulenceModel::New(U, phi, laminarTransport)
);

#include "createMRF.H"
 #include "createFvOptions.H"
(Guess I need the fluid density rho so that dimensions match...)


Afterwards I added the bodyforce term Fci divided by rho (also highlighted in red) in the UEqn.H file:


Code:
    // Momentum predictor

    MRF.correctBoundaryVelocity(U);

    tmp<fvVectorMatrix> tUEqn
    (
        fvm::div(phi, U)
      + MRF.DDt(U)
      + turbulence->divDevReff(U)
     ==
        fvOptions(U)
    );
    fvVectorMatrix& UEqn = tUEqn.ref();

    UEqn.relax();

    fvOptions.constrain(UEqn);

    if (simple.momentumPredictor())
    {
        solve(UEqn == -fvc::grad(p)+Fci/rho);

        fvOptions.correct(U);
     }
But now I'm a little bit confused because (in at least one former post here in this forum) I've also seen a different approach of implementing a source term into the momentum equation, accordingly:


Code:
    tmp<fvVectorMatrix> tUEqn
    (
        fvm::div(phi, U)
      + MRF.DDt(U)
      + turbulence->divDevReff(U)
     ==
        fvOptions(U)
      + Fci/rho
       );
Anyone knows which of these two approaches is the right way to add a source term??
Guess underrelaxation and the command fvOptions.constrain(UEqn) have the effect that I get different results...


Many thanks in advance and stay healthy in these difficult times!
__________________
Kind Regards
Karman
karman is offline   Reply With Quote

Old   April 10, 2020, 14:34
Default
  #2
HPE
Senior Member
 
HPE's Avatar
 
Herpes Free Engineer
Join Date: Sep 2019
Location: The Home Under The Ground with the Lost Boys
Posts: 931
Rep Power: 13
HPE is on a distinguished road
I would create a new fvOptions instead of modifying simpleFoam.
Mahmoud Abbaszadeh likes this.
HPE is offline   Reply With Quote

Old   June 20, 2022, 09:11
Default
  #3
Member
 
Mahmoud
Join Date: Nov 2020
Location: United Kingdom
Posts: 43
Rep Power: 6
Mahmoud Abbaszadeh is on a distinguished road
Quote:
Originally Posted by HPE View Post
I would create a new fvOptions instead of modifying simpleFoam.

Hi,

I am simulating an open channel flow with simpleFoam.
I used fvOptions to add gravity as a momentum source. What I'd like to know is how to set the outlet BC? I can set it as zero fixedValue as we have hydrostatic Pressure there. Do you have any idea how to set HP pressure at the outlet?

Cheers
Mahmoud Abbaszadeh is offline   Reply With Quote

Reply

Tags
body force, momentum equation, openfoam, simple algorithm, source term


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
SIMPLE algorithm in collocated non orthogonal body fitted grid Waliur Rahman Main CFD Forum 5 April 6, 2022 09:33
EHD + body force + vectorCodedSource Pavithra OpenFOAM Running, Solving & CFD 2 May 17, 2021 07:32
no current magnetic magnet force term in N-S body force in COMSOL 7363 Electromagnetics 3 December 22, 2019 18:19
body force term Goutam OpenFOAM Programming & Development 0 February 1, 2012 10:13
Problems with SUPG body force term FEM question Main CFD Forum 0 January 21, 2006 18:51


All times are GMT -4. The time now is 16:52.