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

Add a source term to UEqn.H

Register Blogs Community New Posts Updated Threads Search

Like Tree19Likes
  • 18 Post By mkraposhin
  • 1 Post By mkraposhin

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 6, 2016, 02:20
Default Add a source term to UEqn.H
  #1
Member
 
Join Date: Jul 2015
Posts: 33
Rep Power: 11
KeiJun is on a distinguished road
Dear Sir,

I'm trying to add a source term to the UEqn.H, which is named "ASm".

ASm = C * ∂q/∂t, which is a tensol and is calculated in advance (C is a constant coefficient).

Then, I want to add ASm * U as a source term, but it is a product of tensol and vector.

What should I describe this product to the UEqn.H source code?

I checked "DarcyForchheimer", which also calculate a product of a tensol and U, but I don't understand how to do.

Could you advise me, please.


KeiJun
KeiJun is offline   Reply With Quote

Old   January 7, 2016, 19:13
Default
  #2
Member
 
Join Date: Jul 2015
Posts: 33
Rep Power: 11
KeiJun is on a distinguished road
Dear Sir,

I keep trying making my solver, but cannot compile.

I want to add a new source term to UEqn.H, which is ASm * U.

ASm is C * ∂q/∂t, in which C is a constant (scalar) and ∂q/∂t is calculate by another equation (in qEqn.H) in advance.
q is the reaction amount per catalyst weight (the unit is mol/kg), so ∂q/∂t is the reaction rate.

Then, is the type of calculated ∂q/∂t fvScalarMatrix?
If so, is the type of ASm also fvScalarMatrix?
And then, is the type of new source term I want to add, ASm * U, defined as volVectorField? (which is inner product of fvScalarMatrix and volVectorField, and described as ASm & U.)

When I compile this solver, the error message:
no match for 'operator&' (operand types are 'Foam::fvScalarMatrix {aka ~}' and 'Foam::volVecorField {aka ~}')
has come.

I have no idea why this error occurs.

Could you advise me how to descibe this new source term.
I am really looking forward to your reply.


Sincerely,

KeiJun
KeiJun is offline   Reply With Quote

Old   January 8, 2016, 08:06
Default
  #3
Senior Member
 
mkraposhin's Avatar
 
Matvey Kraposhin
Join Date: Mar 2009
Location: Moscow, Russian Federation
Posts: 355
Rep Power: 21
mkraposhin is on a distinguished road
Hi,

when you are adding source term to any equation, you must decid on how this term will be discretized: in explicit or implicit way?

If you want to discretize you source in explicit way, then you must create volVectorField for UEqn, with dimensions equal to density*acceleration:

Code:
solve
(
    fvm::ddt(rho,U)
    +
    fvm::div(phi,U)
    ==
    SourceU
);
Where SourceU - volVectorField

If you know, that your source field depends on velocity and you can write it like next expression:
SourceU = C*U,
then you can discretize source in implicit way:
Code:
solve
(
    fvm::ddt(rho,U)
    +
    fvm::div(phi,U)
    ==
    fvm::Sp(C,U)
);
U - is a volVectorField, C - volScalarField, dimensions of C is "density/time", so that C*U dimensions will be density*acceleration,
operator fvm::Sp(C,U) will return fvVectorMatrix. It is a good practice to be sure that C field is negative in implicit formulation

Next, if you know that field C can be positive, then it means that it's values will be subtracted from the diagonal, and this will lead to ill-conditioned matrix. Then, you can make semi-implicit formulation, which switches betweeb implicit/explicit depending on sign of C:
Code:
solve
(
    fvm::ddt(rho,U)
    +
    fvm::div(phi,U)
    +
    fvm::SuSp(-C,U)        
);
mkraposhin is offline   Reply With Quote

Old   November 5, 2021, 18:48
Default
  #4
Member
 
Join Date: Feb 2020
Posts: 90
Rep Power: 6
Shibi is on a distinguished road
Hi,

Sorry is this is too basic, but is the there any difference if the explicit/ or any of the other sources is made as:

Code:
solve
(
    fvm::ddt(rho,U)
    +
    fvm::div(phi,U)
    -
    SourceU
);


instead of

Code:
solve
(
    fvm::ddt(rho,U)
    +
    fvm::div(phi,U)
    ==
    SourceU
);
They will both assemble a matrix and enter the solve function. The "==" is just to make it with closer resemblance to the mathematical equation, right?
Shibi is offline   Reply With Quote

Old   November 6, 2021, 09:17
Default
  #5
Senior Member
 
mkraposhin's Avatar
 
Matvey Kraposhin
Join Date: Mar 2009
Location: Moscow, Russian Federation
Posts: 355
Rep Power: 21
mkraposhin is on a distinguished road
Yes '==' is just an alias to '-'
Michael@UW likes this.
mkraposhin is offline   Reply With Quote

Old   July 3, 2022, 14:45
Default
  #6
Member
 
Uttam
Join Date: May 2020
Location: Southampton, United Kingdom
Posts: 35
Rep Power: 6
openfoam_aero is on a distinguished road
Quote:
Originally Posted by mkraposhin View Post
Hi,

when you are adding source term to any equation, you must decid on how this term will be discretized: in explicit or implicit way?

If you want to discretize you source in explicit way, then you must create volVectorField for UEqn, with dimensions equal to density*acceleration:

Code:
solve
(
    fvm::ddt(rho,U)
    +
    fvm::div(phi,U)
    ==
    SourceU
);
Where SourceU - volVectorField

If you know, that your source field depends on velocity and you can write it like next expression:
SourceU = C*U,
then you can discretize source in implicit way:
Code:
solve
(
    fvm::ddt(rho,U)
    +
    fvm::div(phi,U)
    ==
    fvm::Sp(C,U)
);
U - is a volVectorField, C - volScalarField, dimensions of C is "density/time", so that C*U dimensions will be density*acceleration,
operator fvm::Sp(C,U) will return fvVectorMatrix. It is a good practice to be sure that C field is negative in implicit formulation

Next, if you know that field C can be positive, then it means that it's values will be subtracted from the diagonal, and this will lead to ill-conditioned matrix. Then, you can make semi-implicit formulation, which switches betweeb implicit/explicit depending on sign of C:
Code:
solve
(
    fvm::ddt(rho,U)
    +
    fvm::div(phi,U)
    +
    fvm::SuSp(-C,U)        
);
what if C is a vector here?
__________________
Best Regards
Uttam

-----------------------------------------------------------------

“When everything seem to be going against you, remember that the airplane takes off against the wind, not with it.” – Henry Ford.
openfoam_aero is offline   Reply With Quote

Old   December 2, 2022, 23:55
Default
  #7
New Member
 
shouvik ghorui
Join Date: Oct 2019
Posts: 15
Rep Power: 6
shouvik ghorui is on a distinguished road
Hi,
How to hendle if the source term is (gammaPsi)*grad(C), where equation is
fvm::ddt(C)
+fvm::div(phiup,C)
-fvm::laplacian(gammaPsi,C)
Thanks
shouvik ghorui 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
[Other] How to use finite area method in official OpenFOAM 2.2.0? Detian Liu OpenFOAM Meshing & Mesh Conversion 4 November 3, 2015 03:04
[foam-extend.org] problem when installing foam-extend-1.6 Thomas pan OpenFOAM Installation 7 September 9, 2015 21:53
add source term in energy equation chaolian OpenFOAM Programming & Development 4 November 8, 2012 22:22
DecomposePar links against liblamso0 with OpenMPI jens_klostermann OpenFOAM Bugs 11 June 28, 2007 17:51
Add source term in species equation zhou1 FLUENT 1 October 21, 2003 06:28


All times are GMT -4. The time now is 23:12.