|
[Sponsors] |
Fix the scalar variable in a rectangular region during simulation |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
February 20, 2016, 11:03 |
Fix the scalar variable in a rectangular region during simulation
|
#1 |
New Member
Ender Demirel
Join Date: Jun 2009
Location: Turkey
Posts: 20
Rep Power: 16 |
Hi all.
I'm solving transport equation for a scalar variable C. I want to fix this scalar variable C in a rectangular region of the computational domain during simulation to keep the variable unchanged in this region during solution. Can you tell me how I can do it? Do I have to modify the source code? Thank you in advance.. |
|
February 20, 2016, 15:46 |
|
#2 |
Senior Member
|
Hi,
Take a look at $FOAM_SRC/fvOptions/constraints/general/explicitSetValue. It uses fvMatrix::setValues (http://foam.sourceforge.net/docs/cpp...a6b05660da9bc2) to fix values in a cellSet. |
|
February 21, 2016, 23:33 |
|
#3 |
Senior Member
Hesam
Join Date: Feb 2015
Posts: 139
Rep Power: 11 |
Hi Ender,
You can use of ForAll loop and if statement for this purpose. |
|
February 22, 2016, 22:08 |
|
#4 | |
New Member
Ender Demirel
Join Date: Jun 2009
Location: Turkey
Posts: 20
Rep Power: 16 |
Quote:
scalarVariableC { type scalarExplicitSetValue; active true; timeStart 0; duration 10; selectionMode cellSet; cellSet Inlet; scalarExplicitSetValueCoeffs { volumeMode absolute; injectionRate { C 100; } } } |
||
February 23, 2016, 04:38 |
|
#5 |
Senior Member
|
Hi,
If you are using scalarTransportFoam, unfortunately it does not support setting values explicitly (since in fact it does not create matrix object for equation, just uses solve(...) function). If you would like to use fvOptions with scalarTransportFoam, you need the following modification of the solver (instead of just solve call): Code:
fvScalarMatrix TEqn ( fvm::ddt(T) + fvm::div(phi, T) - fvm::laplacian(DT, T) == fvOptions(T) ); fvOptions.constrain(TEqn); TEqn.solve(); Code:
setTValue { type scalarExplicitSetValue; active true; scalarExplicitSetValueCoeffs { timeStart 0; duration 10; selectionMode cellSet; cellSet inlet; injectionRate { T 100; } } } Another way is to use forAll loop, as proposed by rapierrz, something like this: Code:
word inletPatchName("inlet"); scalar TValue = 100; const polyPatch& inlet = mesh.boundaryMesh()[inletPatchName]; forAll(inlet, idx) { label cellI = inlet.faceCells()[idx]; T.internalField()[cellI] = TValue; } Last edited by alexeym; February 23, 2016 at 10:16. Reason: typo |
|
February 23, 2016, 10:14 |
|
#6 | |
New Member
Ender Demirel
Join Date: Jun 2009
Location: Turkey
Posts: 20
Rep Power: 16 |
Quote:
I used the fvOptions description and it works fine. Thank you for your suggestions.. |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How I can introduce my power heat (W) in chtMultiRegionFoam? | aminem | OpenFOAM Pre-Processing | 32 | August 29, 2019 02:23 |
FATAL ERROR:Maximum number of iterations exceeded | zqlhzx | OpenFOAM Running, Solving & CFD | 4 | July 13, 2016 15:53 |
Best way to pass a scalar variable to a runtime selectionnable class? | Yann | OpenFOAM Programming & Development | 0 | October 22, 2014 08:53 |
Diverging solution in transonicMRFDyMFoam | tsalter | OpenFOAM Running, Solving & CFD | 30 | July 7, 2014 06:20 |
is internalField(U) equivalent to zeroGradient? | immortality | OpenFOAM Running, Solving & CFD | 7 | March 29, 2013 01:27 |