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

Fix the scalar variable in a rectangular region during simulation

Register Blogs Community New Posts Updated Threads Search

Like Tree3Likes
  • 1 Post By alexeym
  • 1 Post By rapierrz
  • 1 Post By alexeym

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 20, 2016, 11:03
Default Fix the scalar variable in a rectangular region during simulation
  #1
New Member
 
invadoria's Avatar
 
Ender Demirel
Join Date: Jun 2009
Location: Turkey
Posts: 20
Rep Power: 16
invadoria is on a distinguished road
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..
invadoria is offline   Reply With Quote

Old   February 20, 2016, 15:46
Default
  #2
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,930
Rep Power: 38
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
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.
invadoria likes this.
alexeym is offline   Reply With Quote

Old   February 21, 2016, 23:33
Default
  #3
Senior Member
 
Hesam
Join Date: Feb 2015
Posts: 139
Rep Power: 11
rapierrz is on a distinguished road
Hi Ender,

You can use of ForAll loop and if statement for this purpose.
invadoria likes this.
rapierrz is offline   Reply With Quote

Old   February 22, 2016, 22:08
Default
  #4
New Member
 
invadoria's Avatar
 
Ender Demirel
Join Date: Jun 2009
Location: Turkey
Posts: 20
Rep Power: 16
invadoria is on a distinguished road
Quote:
Originally Posted by alexeym View Post
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.
I used the following body in fvOptions to set the C in the cellSet named Inlet. But it gives zero value for the C when I run the code. I'm not sure that the code is correct..

scalarVariableC
{
type scalarExplicitSetValue;
active true;
timeStart 0;
duration 10;
selectionMode cellSet;
cellSet Inlet;

scalarExplicitSetValueCoeffs
{
volumeMode absolute;
injectionRate
{
C 100;
}
}
}
invadoria is offline   Reply With Quote

Old   February 23, 2016, 04:38
Default
  #5
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,930
Rep Power: 38
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
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();
with this fvOptions description:

Code:
setTValue
{
   type             scalarExplicitSetValue;
   active           true;

   scalarExplicitSetValueCoeffs
   {
       timeStart        0;
       duration         10;
       selectionMode    cellSet;
       cellSet          inlet;
       injectionRate
       {
           T 100;
       }
   }
}
it works fine.

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;
}
before solve block could do the trick. Code above sets T value in the cells adjacent to inlet patch.
invadoria likes this.

Last edited by alexeym; February 23, 2016 at 10:16. Reason: typo
alexeym is offline   Reply With Quote

Old   February 23, 2016, 10:14
Smile
  #6
New Member
 
invadoria's Avatar
 
Ender Demirel
Join Date: Jun 2009
Location: Turkey
Posts: 20
Rep Power: 16
invadoria is on a distinguished road
Quote:
Originally Posted by alexeym View Post
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();
with this fvOptions description:

Code:
setTValue
{
   type             scalarExplicitSetValue;
   active           true;

   scalarExplicitSetValueCoeffs
   {
       timeStart        0;
       duration         10;
       selectionMode    cellSet;
       cellSet          inlet;
       injectionRate
       {
           T 100;
       }
   }
}
it work fine.

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;
}
before solve block could do the trick. Code above sets T value in the cells adjacent to inlet patch.
Hello Alexey;
I used the fvOptions description and it works fine. Thank you for your suggestions..
invadoria 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
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


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