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

Proper way to add a settling scalar field

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 27, 2021, 12:18
Default Proper way to add a settling scalar field
  #1
New Member
 
Roie Ezraty
Join Date: Oct 2020
Posts: 4
Rep Power: 5
Roie_E is on a distinguished road
Hello all,

I want to add to my solver a diffusion equation for the field "C" which settles in a constant velocity V. In order to assign a constant velocity to the field I go by the thread:
How a scalar FIeld can be moved at constant velocity

So in my case:
Code:
    fvScalarMatrix CEqn
    (
        fvm::ddt(C) // changed - C
      + fvm::div(phiC, C) // changed - phiC & C
      - fvm::laplacian(kappaC, C) // changed - kappaC & C
     ==
        fvOptions(C) // changed - C
    );
where phiC is defined as

Code:
surfaceScalarField phiC
(
    IOobject
    (
        "phiC",
        runTime.timeName(),
        mesh,
        IOobject::READ_IF_PRESENT,
        IOobject::AUTO_WRITE
    ),
    fvc::flux(U+V)
);
and V is another vector field that has constant values all across the domain.

My problem is this:
If I define phiC, as a check, to be exactly like phi (meaning the last line only has fvc::flux(U)) I should get the same results as if I take phi instead of phiC in the diffusion equation itself - but I actually get different results!

Did I miss something on the way?
Thanks in advance,
Roie
Roie_E is offline   Reply With Quote

Old   September 28, 2021, 07:43
Default
  #2
Member
 
Hosein
Join Date: Nov 2011
Location: Germany
Posts: 93
Rep Power: 14
einstein_zee is on a distinguished road
Quote:
Originally Posted by Roie_E View Post
Hello all,

I want to add to my solver a diffusion equation for the field "C" which settles in a constant velocity V. In order to assign a constant velocity to the field I go by the thread:
How a scalar FIeld can be moved at constant velocity

So in my case:
Code:
    fvScalarMatrix CEqn
    (
        fvm::ddt(C) // changed - C
      + fvm::div(phiC, C) // changed - phiC & C
      - fvm::laplacian(kappaC, C) // changed - kappaC & C
     ==
        fvOptions(C) // changed - C
    );
where phiC is defined as

Code:
surfaceScalarField phiC
(
    IOobject
    (
        "phiC",
        runTime.timeName(),
        mesh,
        IOobject::READ_IF_PRESENT,
        IOobject::AUTO_WRITE
    ),
    fvc::flux(U+V)
);
and V is another vector field that has constant values all across the domain.

My problem is this:
If I define phiC, as a check, to be exactly like phi (meaning the last line only has fvc::flux(U)) I should get the same results as if I take phi instead of phiC in the diffusion equation itself - but I actually get different results!

Did I miss something on the way?
Thanks in advance,
Roie
In principle you are right if the definitions are identical... But depending on your solver phi might get changed along the way... For example if you are using multiphase solvers like interFoam, CorrectPhi will change phi along the way... you may look here "https://github.com/OpenFOAM/OpenFOAM...i/CorrectPhi.C".
einstein_zee is offline   Reply With Quote

Old   September 28, 2021, 08:14
Default
  #3
New Member
 
Roie Ezraty
Join Date: Oct 2020
Posts: 4
Rep Power: 5
Roie_E is on a distinguished road
Thanks a lot Hosein!

So yes, I am using a modified solver built upon buoyantBoussinesqPimpleFoam - Does buoyantBoussinesqPimpleFoam use CorrectPhi? and if so, how can I add phiC to the correction procedure as well?

Thanks again,
Roie
Roie_E is offline   Reply With Quote

Reply

Tags
constant velocity, diffusion equation, phi, scalar field


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
Foam::error::PrintStack almir OpenFOAM Running, Solving & CFD 92 May 21, 2024 07:56
Velocity inlet boundary condition kit607 OpenFOAM Pre-Processing 1 November 20, 2019 05:04
Steady Advection-diffusion equation, with scalar velocity field, openfoam andrea5 OpenFOAM Programming & Development 0 September 17, 2019 04:10
problem during mpi in server: expected Scalar, found on line 0 the word 'nan' muth OpenFOAM Running, Solving & CFD 3 August 27, 2018 04:18
Issue symmetryPlane 2.5d extruded airfoil simulation 281419 OpenFOAM Running, Solving & CFD 5 November 28, 2015 13:09


All times are GMT -4. The time now is 20:27.