# initialization of scalar source using volume integral of source cells

 Register Blogs Members List Search Today's Posts Mark Forums Read

 March 22, 2013, 08:21 initialization of scalar source using volume integral of source cells #1 Member   Marcus Letzel Join Date: Sep 2012 Location: Aurich Posts: 35 Rep Power: 6 Dear All, my modified pisoFoam solver includes a passive scalar transport equation for LES: Code: ```... turbulence->correct(); solve ( fvm::ddt(s1) + fvm::div(phi, s1) - fvm::laplacian(turbulence->nut(), s1) == s1Source ); runTime.write(); ...``` In createFields.H, both s1 and s1Source are defined per Volume (m^-3): Code: ``` volScalarField s1 ( IOobject ( "s1", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE ), mesh, dimensionedScalar("s1", dimensionSet(1,-3,0,0,0,0,0), scalar(0)) ); Info<< "Reading field s1Source\n" << endl; volScalarField s1Source ( IOobject ( "s1Source", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE ), mesh, dimensionedScalar("s1Source", dimensionSet(1,-3,-1,0,0,0,0), scalar(0)) );``` My practical scenario is an air pollution simulation where I know the source volume and its (total) emission rate in kg/s. So far, I initialize s1Source using a region in setFieldsDict: Code: ``` boxToCell { box (35.75 0.0 27.5) (36.25 0.5 28.5); fieldValues ( volScalarFieldValue s1Source 0.001 ); };``` In my current mesh, setFields finds and sets two cells, and the total emission rate depends on the size of these cells. This is not what I want. Instead, I need an algorithm that sets s1Source in these cells to values so that the volume integral of s1Source over these cells matches a prescribed total emission rate. Can this be achieved using setFields, or perhaps funkySetFields? If not, how and in which file could it be coded? Best regards, Marcus

March 24, 2013, 11:33
#2
Assistant Moderator

Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,972
Rep Power: 41
Quote:
 Originally Posted by letzel Dear All, my modified pisoFoam solver includes a passive scalar transport equation for LES: My practical scenario is an air pollution simulation where I know the source volume and its (total) emission rate in kg/s. So far, I initialize s1Source using a region in setFieldsDict: In my current mesh, setFields finds and sets two cells, and the total emission rate depends on the size of these cells. This is not what I want. Instead, I need an algorithm that sets s1Source in these cells to values so that the volume integral of s1Source over these cells matches a prescribed total emission rate. Can this be achieved using setFields, or perhaps funkySetFields? If not, how and in which file could it be coded?
Somewhere between funkySetFields, coded and your solution: swak4Foam has something called expressionSource (search for that on the forum and you'll find an explanation how to integrate that) that you insert into your solver (at the place where you insert the field). That evaluates a funkySetFields-like expression and adds it as a source term. Built on that swak offers you child classes to basicSource (in OF up to 2.1) and fvOption (since 2.1) which you could add to your solver similarly. With that your solver doesn't need swak, but it can choose to use it via runtime selection.

If you don't want to change the solver anymore there is always the possibility to modify the s1-field with the modifyField-functionObject
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request

May 13, 2015, 03:58
#3
Member

Yan Wang
Join Date: May 2015
Location: Beijing
Posts: 40
Rep Power: 3
Quote:
 Originally Posted by letzel Dear All, my modified pisoFoam solver includes a passive scalar transport equation for LES: Code: ```... turbulence->correct(); solve ( fvm::ddt(s1) + fvm::div(phi, s1) - fvm::laplacian(turbulence->nut(), s1) == s1Source ); runTime.write(); ...``` In createFields.H, both s1 and s1Source are defined per Volume (m^-3): Code: ``` volScalarField s1 ( IOobject ( "s1", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE ), mesh, dimensionedScalar("s1", dimensionSet(1,-3,0,0,0,0,0), scalar(0)) ); Info<< "Reading field s1Source\n" << endl; volScalarField s1Source ( IOobject ( "s1Source", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE ), mesh, dimensionedScalar("s1Source", dimensionSet(1,-3,-1,0,0,0,0), scalar(0)) );``` My practical scenario is an air pollution simulation where I know the source volume and its (total) emission rate in kg/s. So far, I initialize s1Source using a region in setFieldsDict: Code: ``` boxToCell { box (35.75 0.0 27.5) (36.25 0.5 28.5); fieldValues ( volScalarFieldValue s1Source 0.001 ); };``` In my current mesh, setFields finds and sets two cells, and the total emission rate depends on the size of these cells. This is not what I want. Instead, I need an algorithm that sets s1Source in these cells to values so that the volume integral of s1Source over these cells matches a prescribed total emission rate. Can this be achieved using setFields, or perhaps funkySetFields? If not, how and in which file could it be coded? Best regards, Marcus
Hi Marcus,

I met the same problem. Did you find any solution?

Thank you!

 Thread Tools Display Modes Linear Mode

 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 OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post ofslcm OpenFOAM Pre-Processing 24 August 23, 2015 22:41 GGerber OpenFOAM Installation 54 April 24, 2015 16:02 ofslcm OpenFOAM 3 April 7, 2012 10:57 Greg Givogue OpenFOAM Programming & Development 3 March 4, 2011 18:18 kris CD-adapco 2 August 3, 2005 00:32

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