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

How to define a spatial source in ScalarTransportFoam?

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 18, 2013, 12:08
Default How to define a spatial source in ScalarTransportFoam?
  #1
Member
 
Yijiu Jiang
Join Date: Jan 2013
Location: Michigan, US
Posts: 49
Rep Power: 13
y_jiang is on a distinguished road
Hi,

I am working on ScalarTransportFoam trying to add a distribution of source term.
For example, considering 1D convection-diffusion problem, if the source term is define as follow:

S(x)=ax+b (x1<x<x2)
S(x)=cx+d (x2<x<x3)
a, b, c, d are all constants

How to add this distribution in ScalarTransportFoam? Anyone made something similar?

Thank you and best regards
y_jiang is offline   Reply With Quote

Old   December 19, 2013, 07:54
Default
  #2
Senior Member
 
Lieven
Join Date: Dec 2011
Location: Leuven, Belgium
Posts: 299
Rep Power: 22
Lieven will become famous soon enough
Hi Jiang,

You can try something like:
Code:
volScalarField S
(
    IOobject
    (
        "S",
        runTime_.timeName(),
        mesh_,
        IOobject::NO_READ,
        IOobject::NO_WRITE
    ),
    mesh_,
    dimensionedScalar("S", pow(dimTime,-1)*T.dimensions(), 0.0)
)

forAll(mesh.C(),cellI)
{
    const point& Ccell = mesh.C()[cellI];
    if(Ccell.x() > x1 && Ccell.x() <= x2)
    {
        S[cellI] = a*Ccell.x() + b;
    }
    else if(Ccell.x() > x2 && Ccell.x() < x3)
    {
        S[cellI] = c*Ccell.x() + d;
    }
}
And next add
Code:
==
S
to the scalar transport equation. I wrote this from the top of my head so I didn't check if it compiles (actually, it won't since you need to define a,b,c and d among a few other things). But at least it might help you in the right direction.

Cheers,

L
Lieven is offline   Reply With Quote

Old   April 3, 2014, 22:08
Default
  #3
Member
 
Yijiu Jiang
Join Date: Jan 2013
Location: Michigan, US
Posts: 49
Rep Power: 13
y_jiang is on a distinguished road
Hi Lieven,

Thank you very much for your idea. It works for me. Sorry for the late reply cause I have been doing a different project for the last several months. Now I got a new problem about mesh manipulation. It is a kind of same as the previous one which I asked you. The thing is:
I am trying generate bedforms for my case, basically, the Mesh is just a 3D box and I want to modify the bottom from flat bottom to a sine wave surface. I have already written a utility for the bedform generation. I attached the .C file for you. But I want to make it more general, for example, if I just want generate the sine wave for the part which a<x<b. I have tried, but unfortunately didn't make it. Do you have any idea on this?

Thank you.

Yijiu

Quote:
Originally Posted by Lieven View Post
Hi Jiang,

You can try something like:
Code:
volScalarField S
(
    IOobject
    (
        "S",
        runTime_.timeName(),
        mesh_,
        IOobject::NO_READ,
        IOobject::NO_WRITE
    ),
    mesh_,
    dimensionedScalar("S", pow(dimTime,-1)*T.dimensions(), 0.0)
)

forAll(mesh.C(),cellI)
{
    const point& Ccell = mesh.C()[cellI];
    if(Ccell.x() > x1 && Ccell.x() <= x2)
    {
        S[cellI] = a*Ccell.x() + b;
    }
    else if(Ccell.x() > x2 && Ccell.x() < x3)
    {
        S[cellI] = c*Ccell.x() + d;
    }
}
And next add
Code:
==
S
to the scalar transport equation. I wrote this from the top of my head so I didn't check if it compiles (actually, it won't since you need to define a,b,c and d among a few other things). But at least it might help you in the right direction.

Cheers,

L

Last edited by y_jiang; April 4, 2014 at 01:33.
y_jiang is offline   Reply With Quote

Old   April 4, 2014, 01:35
Default
  #4
Member
 
Yijiu Jiang
Join Date: Jan 2013
Location: Michigan, US
Posts: 49
Rep Power: 13
y_jiang is on a distinguished road
Hi Lieven,

I have already solved this problem. It is pretty simple. I just thought it in a wrong way at the very beginning.

Cheers,
Yijiu
y_jiang is offline   Reply With Quote

Old   October 19, 2016, 10:11
Default
  #5
New Member
 
Sana Ullah
Join Date: Sep 2014
Location: Daejeon,South Korea
Posts: 28
Blog Entries: 2
Rep Power: 11
Mehar is on a distinguished road
Quote:
Originally Posted by y_jiang View Post
Hi Lieven,

I have already solved this problem. It is pretty simple. I just thought it in a wrong way at the very beginning.

Cheers,
Yijiu
Hi, y_jiang...
Its an old thread, but I hope I can get a reply from you for how you actually solved your problem, and
I am also working on scalarTransportFoam, and I want to include a sink to it, any suggestion on how I can implement this.

Thanks
mehar
__________________
Mehar, Phd Scholar
KAIST, Korea
Mehar 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
GPU Linear Solvers for OpenFOAM gocarts OpenFOAM Announcements from Other Sources 37 August 17, 2022 14:22
[swak4Foam] swak4Foam-groovyBC build problem zxj160 OpenFOAM Community Contributions 18 July 30, 2013 13:14
[swak4Foam] problem on installing swak4Foam navid2 OpenFOAM Community Contributions 2 May 30, 2012 04:32
OpenFOAM on MinGW crosscompiler hosted on Linux allenzhao OpenFOAM Installation 127 January 30, 2009 19:08
Missing math.h header Travis FLUENT 4 January 15, 2009 11:48


All times are GMT -4. The time now is 06:09.