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

when should the cellVolume multiply a source term expression?

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 12, 2024, 13:31
Default when should the cellVolume multiply a source term expression?
  #1
Member
 
Marķa Rosales
Join Date: Mar 2023
Location: Spain
Posts: 48
Rep Power: 3
MMRC is on a distinguished road
Good day community,


I have seen implementations of fvOptions in OpenFOAM ESI, for scalarFields (TKE, epsilon, omega...) and vectorFields (U), where the theorethical expressions of the source terms we want to apply, there is no addition of product with cell volume, BUT, some solutions (files of source termns) from some users of CFD Online forum, they do consider to add the product of the cell volume to the theorethical expression.



For example, lets say in our code we define:
const scalarField& cellsV = mesh().V();
Then we make a loop over the cells of the cellSet or domain where the source term must be applied:
forAll(celli : cells_)
{


eqn.source()[celli] = TheorethicalFormula * cellV[celli];
}


There are ocassions where 'formula' is defined explicitly, and sometimes implicitly, and it is itself ONLY. Some coded sources I've seen in this blog (made by users), they add the volume of the cell just like the code I pasted above....


So, when would you recommend to consider or not cellV? maybe does it depend of the type of field we are handling with?



Big thanks for any info,
MMRC is offline   Reply With Quote

Old   September 13, 2024, 13:06
Default
  #2
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 745
Rep Power: 14
Tobermory will become famous soon enough
Quote:
Originally Posted by MMRC View Post
maybe does it depend of the type of field we are handling with?
Correct - it's just for ease of use. Sometimes you know that you want to apply a total amount of the variable into the source cells, and you will use an absolute amount (e.g. 100W for the whole source). Sometimes the value you want to apply is the per-volume amount (e.g. 20W/m3).

Note that the two approaches are identical, since if you supply a total (absolute) source amount, rather than a specific (per-volume) amount, the code just calculates the per-volume amount anyway and uses that. For example, in https://cpp.openfoam.org/v8/semiImpl...8C_source.html we have:

Code:
     // Explicit source function for the field
     UIndirectList<Type>(Su, cells_) = fieldSu_[fieldi].value<Type>(t)/VDash_;
 ....
     // Implicit source function for the field
     UIndirectList<scalar>(Sp, cells_) = fieldSp_[fieldi].value(t)/VDash_;
Note the normalisation by VDash_. The constructor initaliases VDash_ with value of 1:
Code:
 Foam::fv::semiImplicitSource::semiImplicitSource
 (
     const word& name,
     const word& modelType,
     const dictionary& dict,
     const fvMesh& mesh
 )
 :
     cellSetOption(name, modelType, dict, mesh),
     volumeMode_(volumeMode::absolute),
     VDash_(1)
 {
     read(dict);
 }
and this is overriden in the read() function if necessary:
Code:
         // Set volume normalisation
         if (volumeMode_ == volumeMode::absolute)
         {
             VDash_ = V_;
         }
Tobermory is offline   Reply With Quote

Reply

Tags
fvoption, openfoam, source terms


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] Tabulated thermophysicalProperties library chriss85 OpenFOAM Community Contributions 62 October 2, 2022 04:50
[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
[Other] Adding solvers from DensityBasedTurbo to foam-extend 3.0 Seroga OpenFOAM Community Contributions 9 June 12, 2015 18:18
Trouble compiling utilities using source-built OpenFOAM Artur OpenFOAM Programming & Development 14 October 29, 2013 11:59
[swak4Foam] funkySetFields compilation error tayo OpenFOAM Community Contributions 39 December 3, 2012 06:18


All times are GMT -4. The time now is 10:07.