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

How to add a source term for driving the flow in periodic model by DPMFoam?

Register Blogs Community New Posts Updated Threads Search

Like Tree4Likes
  • 3 Post By RobertHB
  • 1 Post By ktron

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 9, 2019, 05:13
Default How to add a source term for driving the flow in periodic model by DPMFoam?
  #1
New Member
 
Matthew
Join Date: Aug 2017
Posts: 28
Rep Power: 9
zhangxc0223 is on a distinguished road
Hi, all

I am struggle in a two-phase pipe model with cyclic boundary conditions. I would like to solve it using DPMFoam. The problem is that it doesn't work if I add a momentumSource in 'fvOptions' file like the following code.
Code:
momentumSource
{
    type            meanVelocityForce;
    active          true;

    meanVelocityForceCoeffs
    {
        selectionMode   all;

        fields          (U.air);
        Ubar            (0 -24 0);
    }
}
It gives the warning message as below when running, and the bulk velocity are continuously decreasing from the initial velocity to 0.
Code:
--> FOAM Warning : 
    From function virtual void Foam::fv::option::checkApplied() const
    in file cfdTools/general/fvOptions/fvOption.C at line 118
    Source momentumSource defined for field U.air but never used
So, I have two questions about that.

1. is there any way to fix the problem of using 'fvOptions'?
2. is that possible to add a certain value in the 'UcEqn.H' file, to drive the flow with a constant bulk velocity? If so, please give me a hit how to modify it.

Very appreciate for any help.
Regards.
zhangxc0223 is offline   Reply With Quote

Old   January 9, 2019, 07:30
Default
  #2
Senior Member
 
Robert
Join Date: May 2015
Location: Bremen, GER
Posts: 292
Rep Power: 12
RobertHB is on a distinguished road
Idea 1: Change active true; to active yes; and try again. At least that is my fvOptions setup and its working.



Quote:
Originally Posted by zhangxc0223 View Post
It gives the warning message as below when running, and the bulk velocity are continuously decreasing from the initial velocity to 0.

Code:
--> FOAM Warning : 
   [...]
     Source momentumSource defined for field U.air but never used
Idea 2: Are you sure your velocity file is called U.air? Your error clearly states that the field you define your fvOptions for does not exist.
__________________
If you liked my answer to your question, please consider leaving a "Like" in return
RobertHB is offline   Reply With Quote

Old   January 9, 2019, 07:47
Default
  #3
New Member
 
Matthew
Join Date: Aug 2017
Posts: 28
Rep Power: 9
zhangxc0223 is on a distinguished road
Quote:
Originally Posted by RobertHB View Post
Idea 1: Change active true; to active yes; and try again. At least that is my fvOptions setup and its working.

Idea 2: Are you sure your velocity file is called U.air? Your error clearly states that the field you define your fvOptions for does not exist.
Thanks Robert for your reply. I have checked to type 'true', 'yes', and 'on', all of them don't work for it. May I ask what version of OpenFOAM are you using for your fvOptions?

In my DPMFoam solver, the velocity field is U.air for my air phase. That really puzzles me for not exist. I have also tried to use 'U','Uc', still doesn't work.
zhangxc0223 is offline   Reply With Quote

Old   January 9, 2019, 09:07
Default
  #4
Senior Member
 
Robert
Join Date: May 2015
Location: Bremen, GER
Posts: 292
Rep Power: 12
RobertHB is on a distinguished road
Quote:
Originally Posted by zhangxc0223 View Post
Thanks Robert for your reply. I have checked to type 'true', 'yes', and 'on', all of them don't work for it. May I ask what version of OpenFOAM are you using for your fvOptions?
I'm using OF 5.0 and 6.0. But i think i have found your "problem". Take a look at the UEqn.H (Link) used by e.g. simpleFoam, with which fvSolution works:
Code:
tmp<fvVectorMatrix> tUEqn
(
    fvm::div(phi, U)
    + MRF.DDt(U)
    + turbulence->divDevReff(U)
    ==
    fvOptions(U)
 );
and the UcEqn.H (Link) used by DMPFoam
Code:
fvVectorMatrix UcEqn
(
    fvm::ddt(alphac, Uc) + fvm::div(alphaPhic, Uc)
    - fvm::Sp(fvc::ddt(alphac) + fvc::div(alphaPhic), Uc)
    + continuousPhaseTurbulence->divDevRhoReff(Uc)
    ==
    (1.0/rhoc)*cloudSU
 );
There is no connection to the fvOptions file. Maybe you can add this connection by adding "+ fvOptions(U)". So that it becomes

Code:
fvVectorMatrix UcEqn
(
    fvm::ddt(alphac, Uc) + fvm::div(alphaPhic, Uc)
    - fvm::Sp(fvc::ddt(alphac) + fvc::div(alphaPhic), Uc)
    + continuousPhaseTurbulence->divDevRhoReff(Uc)
    ==
    (1.0/rhoc)*cloudSU
    + fvOptions(U)
);
But i'm not sure about this.
__________________
If you liked my answer to your question, please consider leaving a "Like" in return
RobertHB is offline   Reply With Quote

Old   January 9, 2019, 22:57
Default
  #5
New Member
 
Matthew
Join Date: Aug 2017
Posts: 28
Rep Power: 9
zhangxc0223 is on a distinguished road
Quote:
Originally Posted by RobertHB View Post
So that it becomes

Code:
fvVectorMatrix UcEqn
(
    fvm::ddt(alphac, Uc) + fvm::div(alphaPhic, Uc)
    - fvm::Sp(fvc::ddt(alphac) + fvc::div(alphaPhic), Uc)
    + continuousPhaseTurbulence->divDevRhoReff(Uc)
    ==
    (1.0/rhoc)*cloudSU
    + fvOptions(U)
);
But i'm not sure about this.
Thanks Robert, I have try to do following your suggestion, but it gives the error that:
Code:
UcEqn.H: In function 'int main(int, char**)':
UcEqn.H:7:38: error: 'fvOptions' was not declared in this scope
     (1.0/rhoc)*cloudSU + fvOptions(Uc)
                                      ^
Here I use the 'Uc' instead of 'U' to avoid that 'U' was not declared in this scope. So What else can I do to fix this? Sorry that I am pretty new on the C++ in OpenFOAM.
zhangxc0223 is offline   Reply With Quote

Old   January 10, 2019, 04:01
Default
  #6
Senior Member
 
Robert
Join Date: May 2015
Location: Bremen, GER
Posts: 292
Rep Power: 12
RobertHB is on a distinguished road
Try adding #include "fvOptions.H" to your DPMFoam.C
__________________
If you liked my answer to your question, please consider leaving a "Like" in return
RobertHB is offline   Reply With Quote

Old   October 7, 2020, 08:30
Default
  #7
Senior Member
 
Farzad Faraji
Join Date: Nov 2019
Posts: 206
Rep Power: 8
farzadmech is on a distinguished road
Dear Matthew
Did you find your answer? I mean how to use fvOption in DPMfoam Solver?


Thanks,
Farzad



Quote:
Originally Posted by zhangxc0223 View Post
Thanks Robert, I have try to do following your suggestion, but it gives the error that:
Code:
UcEqn.H: In function 'int main(int, char**)':
UcEqn.H:7:38: error: 'fvOptions' was not declared in this scope
     (1.0/rhoc)*cloudSU + fvOptions(Uc)
                                      ^
Here I use the 'Uc' instead of 'U' to avoid that 'U' was not declared in this scope. So What else can I do to fix this? Sorry that I am pretty new on the C++ in OpenFOAM.
farzadmech is offline   Reply With Quote

Old   October 7, 2020, 21:35
Default
  #8
Member
 
Utkan Caliskan
Join Date: Aug 2014
Posts: 42
Rep Power: 12
dscian is on a distinguished road
fvOptions is already added in DPMFoam/MPPICFoam by the following commit:
https://github.com/OpenFOAM/OpenFOAM...714fa03dc67e10

Though it is not in the cell momentum equation, and I don't know why. I guess it should have been added but I don't really know how fvOptions works code-wise.

The options I have encountered in other solvers are; fvOptions(U), fvOptions(rho, U), fvOptions(alpha, rho, U). But I didn't see fvOptions(alpha, U). You might try that one or alphac*fvOptions(U).

Please share the solution if you find out.

Utkan
dscian is offline   Reply With Quote

Old   October 9, 2020, 18:07
Default
  #9
Senior Member
 
Farzad Faraji
Join Date: Nov 2019
Posts: 206
Rep Power: 8
farzadmech is on a distinguished road
Dear Utkan Caliskan
Thanks for your response. Which OpenFOAM version you are using? I am using version 6.0 and in version 6.0, in DPMFOAM.c we have;

Code:
#include "fvCFD.H"
#include "singlePhaseTransportModel.H"
#include "PhaseIncompressibleTurbulenceModel.H"
#include "pimpleControl.H"

Also, I am thinking in the Uceqn.C there must be fvOption in the momentum equation, but I cannot find such a thing.



Thanks,
Farzad




Quote:
Originally Posted by dscian View Post
fvOptions is already added in DPMFoam/MPPICFoam by the following commit:
https://github.com/OpenFOAM/OpenFOAM...714fa03dc67e10

Though it is not in the cell momentum equation, and I don't know why. I guess it should have been added but I don't really know how fvOptions works code-wise.

The options I have encountered in other solvers are; fvOptions(U), fvOptions(rho, U), fvOptions(alpha, rho, U). But I didn't see fvOptions(alpha, U). You might try that one or alphac*fvOptions(U).

Please share the solution if you find out.

Utkan
farzadmech is offline   Reply With Quote

Old   October 19, 2020, 15:51
Default
  #10
Senior Member
 
Farzad Faraji
Join Date: Nov 2019
Posts: 206
Rep Power: 8
farzadmech is on a distinguished road
Dear Utkan Caliskan
I did everything to make fvOption work in my simulation. I exactly copied what was in OF8(I mean I have add extra lines to my code). my code compiles fine, but it does not have any effect on the momentum of the specific region which I need.
I think, I will stop using fvOption and I will code instead.



Thanks,
Farzad



Quote:
Originally Posted by dscian View Post
fvOptions is already added in DPMFoam/MPPICFoam by the following commit:
https://github.com/OpenFOAM/OpenFOAM...714fa03dc67e10

Though it is not in the cell momentum equation, and I don't know why. I guess it should have been added but I don't really know how fvOptions works code-wise.

The options I have encountered in other solvers are; fvOptions(U), fvOptions(rho, U), fvOptions(alpha, rho, U). But I didn't see fvOptions(alpha, U). You might try that one or alphac*fvOptions(U).

Please share the solution if you find out.

Utkan
farzadmech is offline   Reply With Quote

Old   October 20, 2020, 02:47
Default
  #11
Member
 
Utkan Caliskan
Join Date: Aug 2014
Posts: 42
Rep Power: 12
dscian is on a distinguished road
Can you tell me which modification you made in the solver?

I suggest you add fvOptions in the cell momentum equation (UcEqn).

Code:
fvVectorMatrix UcEqn
(
    fvm::ddt(alphac, Uc) + fvm::div(alphaPhic, Uc)
  - fvm::Sp(fvc::ddt(alphac) + fvc::div(alphaPhic), Uc)
  + continuousPhaseTurbulence->divDevRhoReff(Uc)
 ==
    (1.0/rhoc)*cloudSU
  + alphac*fvOptions(U)
);
I've studied its code a bit and think that the way the source added (addSup) depends on the fvOptions options. Moreover, there is no fvOptions(alpha, U). Depending on what you are trying to add, the term above may solve your problem.

Utkan
dscian is offline   Reply With Quote

Old   October 20, 2020, 09:46
Default
  #12
Senior Member
 
Farzad Faraji
Join Date: Nov 2019
Posts: 206
Rep Power: 8
farzadmech is on a distinguished road
Dear Utkan Caliskan
I did like this;

Code:
fvVectorMatrix UcEqn
(
    fvm::ddt(alphac, Uc) + fvm::div(alphaPhic, Uc)
  - fvm::Sp(fvc::ddt(alphac) + fvc::div(alphaPhic), Uc)
  + continuousPhaseTurbulence->divDevRhoReff(Uc)
 ==
    (1.0/rhoc)*cloudSU 

);

UcEqn.relax();

fvOptions.constrain(UcEqn);   //new for momentum purpose

volScalarField rAUc(1.0/UcEqn.A());
surfaceScalarField rAUcf("Dp", fvc::interpolate(rAUc));

surfaceScalarField phicForces
(
   fvc::flux(rAUc*cloudVolSUSu/rhoc) + rAUcf*(g & mesh.Sf())
);

if (pimple.momentumPredictor())
{
    solve
    (
        UcEqn
     ==
        fvc::reconstruct
        (
            phicForces/rAUcf - fvc::snGrad(p)*mesh.magSf()
        )
    );

fvOptions.correct(Uc);    //new for momentum purpose

}
By adding fvOption directly to the momentum equation, it gives me error, so I used what I have found for OF8 for DPMFoam as I wrote by RED in the code, but it did not worked. Also, I have included fvOptions.H to the code.


Thanks,
Farzad




Quote:
Originally Posted by dscian View Post
Can you tell me which modification you made in the solver?

I suggest you add fvOptions in the cell momentum equation (UcEqn).

Code:
fvVectorMatrix UcEqn
(
    fvm::ddt(alphac, Uc) + fvm::div(alphaPhic, Uc)
  - fvm::Sp(fvc::ddt(alphac) + fvc::div(alphaPhic), Uc)
  + continuousPhaseTurbulence->divDevRhoReff(Uc)
 ==
    (1.0/rhoc)*cloudSU
  + alphac*fvOptions(U)
);
I've studied its code a bit and think that the way the source added (addSup) depends on the fvOptions options. Moreover, there is no fvOptions(alpha, U). Depending on what you are trying to add, the term above may solve your problem.

Utkan
farzadmech is offline   Reply With Quote

Old   October 20, 2020, 09:48
Default Coding instead of fvOption
  #13
Senior Member
 
Farzad Faraji
Join Date: Nov 2019
Posts: 206
Rep Power: 8
farzadmech is on a distinguished road
Dear Utkan Caliskan
Finally I decided to code instead of using fvOption, and I did the coding and I have add externalMomentum to the momentum equation in that specific region like this;


Code:
forAll(mesh.C(),i)
{
	scalar x = mesh.C()[i].component(0);
	scalar y = mesh.C()[i].component(1);
	scalar z = mesh.C()[i].component(2);

	
	if(x>0.096 && x<0.404 && y>0.10 && y<0.20 && z>0.0357 && z<0.0643)
	{
	externalMomentum[i] = (1.0 ,0.0 ,0.0);
    }
	
}
But it gives me below error;

Code:
ExMom.H:10:22: error: no match for ‘operator=’ (operand types are ‘Foam::Vector<double>’ and ‘double’)
  externalMomentum[i] = (1.0 ,0.0 ,0.0);
by the way, externalMomentum is a volVectorField. Do you know why this problem happens?


Thanks,
Farzad
farzadmech is offline   Reply With Quote

Old   October 26, 2020, 20:29
Default
  #14
Member
 
Utkan Caliskan
Join Date: Aug 2014
Posts: 42
Rep Power: 12
dscian is on a distinguished road
Sorry for the late reply. The system didn't allow me to send a reply a few days ago.


I was able to recompile it with that addition.

For that one try the following:

Code:
forAll(mesh.C(),i)
{
    scalar x = mesh.C()[i].component(0);
    scalar y = mesh.C()[i].component(1);
    scalar z = mesh.C()[i].component(2);

    
    if(x>0.096 && x<0.404 && y>0.10 && y<0.20 && z>0.0357 && z<0.0643)
    {
    externalMomentum[i] = vector(1.0 ,0.0 ,0.0);
    }
    
}
dscian is offline   Reply With Quote

Old   January 25, 2022, 09:03
Default Success for OF8
  #15
New Member
 
Kathrin Skinder
Join Date: Apr 2021
Location: Germany, Clausthal-Zellerfeld
Posts: 12
Rep Power: 5
ktron is on a distinguished road
Hi, the approach dscian suggested works for me, with the minimal modification of usig Uc instead of U.



Code:
fvVectorMatrix UcEqn
(
    fvm::ddt(alphac, Uc) + fvm::div(alphaPhic, Uc)
  - fvm::Sp(fvc::ddt(alphac) + fvc::div(alphaPhic), Uc)
  + continuousPhaseTurbulence->divDevRhoReff(Uc)
 ==
    (1.0/rhoc)*cloudSU
  + alphac*fvOptions(Uc)
);
Nicole Yu likes this.
ktron is offline   Reply With Quote

Old   January 25, 2022, 10:05
Default How to do this in OpenFOAM 9?
  #16
New Member
 
Kathrin Skinder
Join Date: Apr 2021
Location: Germany, Clausthal-Zellerfeld
Posts: 12
Rep Power: 5
ktron is on a distinguished road
I tried to do the same in OpenFOAM 9, but was somewhat confused.


In OF9, the solver DPMFoam is replaced by the solver denseParticleFoam.
Also, fvOptions is replaced by fvModels and fvConstraints.


I am using the momentum source correction "meanVelocityForce", which used to be in fvOptions in OF8. Now, In OF9, it seems to be in fvConstraints, according to:


https://cpp.openfoam.org/v9/meanVelo...8H_source.html


I wanted to try and modify denseParticleFoam in the way that the source correction is done in simpleFoam, which ist


Code:
     tmp<fvVectorMatrix> tUEqn
     (
         fvm::div(phi, U)
       + MRF.DDt(U)
       + turbulence->divDevSigma(U)
      ==
         fvModels.source(U)
     );

But of course, this does not include the corrections from fvConstraints. Trying to do something like



+ fvConstraints.source(Uc)



in denseParticleFoam gives the error, that 'class Foam::fvConstraints' has no member 'source'. Simply


+ fvConstraints(Uc)



does not work either, and putting 'meanVelocityForce' in fvModels does not work either. I have to admit, I was just blindly trying some things here, without much knowledge about the background.


However, when running the case with simpleFoam the source term corrections ARE taken into account. I suspect, that there is something to these fat printed parts in denseParticleFoam, which has been mentioned before by farzadmech:



Code:
 fvVectorMatrix UcEqn
 (
     fvm::ddt(alphac, Uc) + fvm::div(alphaPhic, Uc)
   - fvm::Sp(fvc::ddt(alphac) + fvc::div(alphaPhic), Uc)
   + continuousPhaseTurbulence->divDevTau(Uc)
  ==
     (1.0/rhoc)*cloudSU
 );
 
 UcEqn.relax();
 
 fvConstraints.constrain(UcEqn);
 
 volScalarField rAUc(1.0/UcEqn.A());
 volScalarField rASpUc(1.0/(UcEqn.A() - cloudSUp/rhoc));
 surfaceScalarField rASpUcf("Dp", fvc::interpolate(rASpUc));
 
 surfaceScalarField phicSUSu
 (
     fvc::flux(rASpUc*cloudSUu/rhoc)
   + rASpUcf*(g & mesh.Sf())
 );
 surfaceScalarField phicSUSp
 (
     fvc::interpolate(rASpUc*cloudSUp/rhoc)
 );
 
 if (pimple.momentumPredictor())
 {
     solve
     (
         UcEqn
      ==
         fvc::reconstruct
         (
             (phicSUSu + phicSUSp*phic)/rASpUcf
           - fvc::snGrad(p)*mesh.magSf()
         )
       + (1.0/rhoc)*(fvm::Sp(cloudSUp, Uc) - cloudSUp*Uc)
     );
 
     fvConstraints.constrain(Uc);
 }


But, since it does not work, I suspect something in 'constain' is somehow not implemented yet for denseParticleFoam. Please excuse the long post. Can anyone provide some clarity?
ktron is offline   Reply With Quote

Old   June 27, 2023, 03:38
Default
  #17
New Member
 
Kathrin Skinder
Join Date: Apr 2021
Location: Germany, Clausthal-Zellerfeld
Posts: 12
Rep Power: 5
ktron is on a distinguished road
It also works to do this:


Code:
fvVectorMatrix UcEqn
(
    fvm::ddt(alphac, Uc) + fvm::div(alphaPhic, Uc)
  - fvm::Sp(fvc::ddt(alphac) + fvc::div(alphaPhic), Uc)
  + continuousPhaseTurbulence->divDevRhoReff(Uc)
 ==
    (1.0/rhoc)*cloudSU
  + fvOptions(alphac, Uc)
 );

Quote:
Originally Posted by ktron View Post
Hi, the approach dscian suggested works for me, with the minimal modification of usig Uc instead of U.



Code:
fvVectorMatrix UcEqn
(
    fvm::ddt(alphac, Uc) + fvm::div(alphaPhic, Uc)
  - fvm::Sp(fvc::ddt(alphac) + fvc::div(alphaPhic), Uc)
  + continuousPhaseTurbulence->divDevRhoReff(Uc)
 ==
    (1.0/rhoc)*cloudSU
  + alphac*fvOptions(Uc)
);
ktron 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
[swak4Foam] swak4foam for OpenFOAM 4.0 mnikku OpenFOAM Community Contributions 80 May 17, 2022 09:06
source in SA model(or one equation model) lostking18 CFX 3 August 27, 2018 07:39
polynomial BC srv537 OpenFOAM Pre-Processing 4 December 3, 2016 10:07
[Other] How to use finite area method in official OpenFOAM 2.2.0? Detian Liu OpenFOAM Meshing & Mesh Conversion 4 November 3, 2015 04:04
[foam-extend.org] problem when installing foam-extend-1.6 Thomas pan OpenFOAM Installation 7 September 9, 2015 22:53


All times are GMT -4. The time now is 00:59.