|
[Sponsors] |
adding a constant volumetric source term to transport equation in a particular region |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
November 17, 2014, 06:02 |
adding a constant volumetric source term to transport equation in a particular region
|
#1 |
Senior Member
Mohsen KiaMansouri
Join Date: Jan 2010
Location: CFD Lab
Posts: 118
Rep Power: 16 |
Dear Foamers
Hi! I want to add a constant volumetric source term to the scalar transport equation which acts only in a particular volumetric region of the domain. I modified the scalar transport equation as follows: Code:
solve ( fvm::ddt(T) + fvm::div(phi, T) - fvm::laplacian(DT, T) == sourceValue ); Code:
dimensionedScalar sourceValue(twoPhaseProperties.lookup("sourceValue")); Code:
sourceValue sourceValue [0 0 -1 0 0 0 0] 0.42; I have two questions: 1) How can I define this volumetric region inside my domain? is there any utility? 2) How can I change the transportProperties file to consider sourceValue=0.42 only for this specific volumetric region and sourceValue=0 for the rest of the domain? Any help in this regard would be much appreciated. Thank you so much in advance.
__________________
“If you have an apple and I have an apple and we exchange these apples then you and I will still each have one apple. But if you have an idea and I have an idea and we exchange these ideas, then each of us will have two ideas.” |
|
November 17, 2014, 11:25 |
|
#2 |
Senior Member
Alex
Join Date: Oct 2013
Posts: 337
Rep Power: 22 |
Maybe your approach would be to create your source region by using topoSet utility first. Then, once you have created your zone where you want to locate your source, you can use the fvOption framework in order to create the source (I assume it's a heat source). It's an easy approach and you don't need to modify your solver!
Regards, Alex
__________________
Web site where I present my Master's Thesis: foamingtime.wordpress.com The case I talk about in this site was solved with chtMultiRegionSimpleFoam solver and involves radiation. Some basic tutorials are also resolved step by step in the web. If you are interested in these matters, you are invited to come in! |
|
November 17, 2014, 18:23 |
|
#3 |
Senior Member
Cyprien
Join Date: Feb 2010
Location: Stanford University
Posts: 299
Rep Power: 18 |
or declare your sourceTerm as a volScalarField and assign it different values (0 and 0.42) with setField
|
|
November 18, 2014, 03:22 |
fvOption source with cellZones
|
#4 |
Senior Member
Fabian Roesler
Join Date: Mar 2009
Location: Germany
Posts: 213
Rep Power: 18 |
The tip with the cellZone is correct. You can add whatever source you like throughout a fvOption:
Code:
energySource { type scalarSemiImplicitSource; active true; selectionMode cellZone; cellZone porosity; scalarSemiImplicitSourceCoeffs { volumeMode absolute; injectionRateSuSp { h (10 0); } } }
Fabian |
|
November 18, 2014, 04:18 |
|
#5 |
Senior Member
Mohsen KiaMansouri
Join Date: Jan 2010
Location: CFD Lab
Posts: 118
Rep Power: 16 |
Thanks Cyprien
I thought that setFields can only be used for initial conditions (initialization) like the dam break example in the user guide? Am I wrong? Because my source exists there all the time not only at t=0. I quote the user guide: Code:
setFields Set values on a selected set of cells/patchfaces through a dictionary It's so kind of you.
__________________
“If you have an apple and I have an apple and we exchange these apples then you and I will still each have one apple. But if you have an idea and I have an idea and we exchange these ideas, then each of us will have two ideas.” |
|
November 18, 2014, 04:27 |
|
#6 |
Senior Member
Fabian Roesler
Join Date: Mar 2009
Location: Germany
Posts: 213
Rep Power: 18 |
No you can't. As a source term is not just setting a simple value but solving for it implicit during the solution process, setFields will not help you much. It's only a tool to set initial conditions.
Create a cellZone and use fvOptions or change your solver code to implement a source to your equation. Cheers Fabian |
|
November 18, 2014, 13:23 |
|
#7 |
Senior Member
Cyprien
Join Date: Feb 2010
Location: Stanford University
Posts: 299
Rep Power: 18 |
Once you have assign different values to your "sourceTerm" with setFields your source term will have the same value for all the time steps.
|
|
November 20, 2014, 04:56 |
|
#8 |
Member
Artem Shaklein
Join Date: Feb 2010
Location: Russia, Izhevsk
Posts: 43
Rep Power: 16 |
Also you can use more general approach, if e.g. you have a function describing the source distribution S = f(x,y,z). You should edit createFields.H by adding
Code:
volScalarField S ( IOobject ( "S", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE ), mesh, // yourSourceDimension is dimensionSet(0,0,0,0,0) with appropriate dimensions dimensionedScalar("S",yourSourceDimension,scalar(0)) ); forAll(mesh.C(), celli) { vector Ci = mesh.C()[celli]; // For a general case // S[celli] = yourFunction(Ci.x(), Ci.y(), Ci.z()); // For your case if(Ci.x() > x1 && Ci.x() < x2) S[celli] = S1; else S[celli] = S2; } S.write() // Writing just ones for checking S distribution in paraview |
|
November 22, 2014, 04:43 |
|
#9 | |
Senior Member
Mohsen KiaMansouri
Join Date: Jan 2010
Location: CFD Lab
Posts: 118
Rep Power: 16 |
Quote:
But I think you are wrong! When you assign different values to your field with setFields, It will not have the same value for all the time steps! setFields is only designed for setting the initial conditions on your fields as stated by fabian_roesler in this post and also by Bernhard in #4 and also in #5. If you take a look at Figure 2.21 on page U-60 of the user guide and compare it with Figure 2.22, you will see that it will change. Thanks you so much again.
__________________
“If you have an apple and I have an apple and we exchange these apples then you and I will still each have one apple. But if you have an idea and I have an idea and we exchange these ideas, then each of us will have two ideas.” |
||
November 22, 2014, 05:22 |
|
#10 |
Senior Member
Mohsen KiaMansouri
Join Date: Jan 2010
Location: CFD Lab
Posts: 118
Rep Power: 16 |
Thank you all.
I think I can not use setFields as stated by Cyp for this purpose. Then I have two options: 1) fvOptions and topoSet utilities as stated by zfaraday and fabian_roesler which is only available after OpenFOAM v2.2.0. 2) Modifying my solver to implement my source into the equation as stated by ARTem and fabian_roesler. Since I use OF 2.1.1., I prefer to use the second approach as suggested by ARTem. Any further advice and suggestions will be highly appreciated.
__________________
“If you have an apple and I have an apple and we exchange these apples then you and I will still each have one apple. But if you have an idea and I have an idea and we exchange these ideas, then each of us will have two ideas.” |
|
November 22, 2014, 17:03 |
|
#11 | |
Senior Member
Cyprien
Join Date: Feb 2010
Location: Stanford University
Posts: 299
Rep Power: 18 |
Quote:
Of course it will have the same value at all the time steps!! In the tutorial you mentioned, setFields is used to initialise your field alpha1, that will be modified later with the solver interFoam. In your case, you want to assign different value to your volScalarField called "sourceTerm". You CAN do that with setFields (and it is actually the fastest way and is kind of similar to the method suggested by ARTem). Since there is no equation that will modify "sourceTerm", it will keep the same value for all the time step. Best, |
||
November 23, 2014, 03:27 |
|
#12 | |
Senior Member
Mohsen KiaMansouri
Join Date: Jan 2010
Location: CFD Lab
Posts: 118
Rep Power: 16 |
Quote:
It's so nice of you.
__________________
“If you have an apple and I have an apple and we exchange these apples then you and I will still each have one apple. But if you have an idea and I have an idea and we exchange these ideas, then each of us will have two ideas.” |
||
September 2, 2015, 07:33 |
source
|
#13 |
New Member
Michal
Join Date: Jul 2015
Location: Poland
Posts: 5
Rep Power: 11 |
Hi,
The topic is quite old and probably obvious for more advanced users yet I don't see final answer. Recently I had to add a source term in the enthalpy equation in the OF 2.1.1 (so no fvOption yet). I merge discussed solution of cfdonline2mohsen and ARTem. I added my source in createFields.H (like in ARTem post #8) and used setFields to set a constant value of my source in certain region only. It worked, but the problem was that in the next time step the value of the source was 0 again. The problem was the following line: Code:
dimensionedScalar("S",yourSourceDimension,scalar(0)) 1) Add "source" to your equation 2) Modify createFields.H: Code:
volScalarField hSource ( IOobject ( "hSource", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE ), mesh ); 3) Compile 4) Use setFields So this is working solution in my case. |
|
November 24, 2015, 01:11 |
|
#14 |
Member
Robert Ong
Join Date: Aug 2010
Posts: 86
Rep Power: 16 |
Hi,
Is there a way to specify the actual initial value of a variable (i.e. concentration) and its diffusivity in the fvOptions? Thanks and regards, Robert |
|
December 14, 2015, 04:13 |
|
#15 |
Senior Member
Fabian Roesler
Join Date: Mar 2009
Location: Germany
Posts: 213
Rep Power: 18 |
I didn't get your question entirely. Initial values are defined in the fields them selves.
In fvOptions you can define extra sources acting inside the conservation equations. Cheers Fabian |
|
February 16, 2017, 10:55 |
|
#16 |
Member
Sebastian Trunk
Join Date: Mar 2015
Location: Erlangen, Germany
Posts: 60
Rep Power: 11 |
Hey everybody,
thank you for the discretion how to add the source to solver. I am trying to modify the scalarTransport solver. The goal is to add the tracer directly in front of an obstacle and not at the inlet patch. I want to set the value of the tracer to 1 to obtain same info as from common scalarTransportFoam. I managed to add a tracer source (T_source) to scalarTransportFoam and to set its value to 1 in my domain. When I run the modified scalarTransportFoam, my T_source stays constant at 1 and the tracer is spread through the volume. BUT: the values for T are very small (around 5e-3). Do you have an idea to fix this? Is there maybe something wring with the dimensions? Thank you for your time Best regards |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[swak4Foam] funkySetFields compilation error | tayo | OpenFOAM Community Contributions | 39 | December 3, 2012 06:18 |
How to write UDF to add a source term to the new transport equation ? | 89566008 | Fluent UDF and Scheme Programming | 2 | October 22, 2012 08:23 |
"parabolicVelocity" in OpenFoam 2.1.0 ? | sawyer86 | OpenFOAM Running, Solving & CFD | 21 | February 7, 2012 12:44 |
Source Term on Scalar Transport Equation | alessio.nz | OpenFOAM Programming & Development | 9 | January 31, 2011 08:56 |
[Gmsh] Import gmsh msh to Foam | adorean | OpenFOAM Meshing & Mesh Conversion | 24 | April 27, 2005 09:19 |