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 Members List Search Today's Posts Mark Forums Read

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: 10
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: 689
Rep Power: 8
HPE is on a distinguished road
I would create a new fvOptions instead of modifying simpleFoam.
HPE is offline   Reply With Quote

Reply

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

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 4 February 25, 2020 00:44
no current magnetic magnet force term in N-S body force in COMSOL 7363 Electromagnetics 3 December 22, 2019 18:19
EHD + body force + vectorCodedSource Pavithra OpenFOAM Running, Solving & CFD 0 September 4, 2019 04:39
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 05:46.