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

how to add varying sourceTerm?

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By divyesh

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 30, 2020, 07:53
Default how to add varying sourceTerm?
  #1
New Member
 
divyesh's Avatar
 
Divyesh Variya
Join Date: May 2018
Location: INDIA
Posts: 16
Rep Power: 7
divyesh is on a distinguished road
Hello Foamers,

I want to add a source Term in laplacianFoam. exp(time)*(Sqr(valueOfMesh(X))-2)

Anyone have idea how to do that?

Can I use funkySetFields?
But still, I have to define something in solver...
divyesh is offline   Reply With Quote

Old   January 30, 2020, 07:58
Default
  #2
Senior Member
 
anonymous
Join Date: Jan 2016
Posts: 416
Rep Power: 14
simrego is on a distinguished road
Hi!


I think you are looking for this:
https://www.openfoam.com/documentati...dedSource.html


EDIT:
I did not compiled it but I hope it'll work. I wrote it for you with loop so you can see some general way to set the source. You can do it without loop but maybe you will need it in the future so you can do it like this. I hope it helps.


Code:
 codeAddSup
#{
              const Time& time = mesh().time();
             const vectorField& C = mesh().C();

              const scalarField& V = mesh_.V();
              scalarField& Source = eqn.source();
             forAll(C, i)
             {
                            Source[i] -= exp(time)*(sqr(C[i].x())-2.0)*V[i];
             }

  #};
simrego is offline   Reply With Quote

Old   January 30, 2020, 22:54
Default
  #3
New Member
 
divyesh's Avatar
 
Divyesh Variya
Join Date: May 2018
Location: INDIA
Posts: 16
Rep Power: 7
divyesh is on a distinguished road
Code:
source
{
    type    scalarCodedSource;
    
    scalarCodedSourceCoeffs
    {
        selectionMode    all;
        fields    (T);
        //name    internalField;
    codeInclude
    #{
    #};

    codeCorrect
    #{
        Pout<< "**codeCorrect**" << endl;
    #};


 codeAddSup
#{
    const Time& time = mesh().time();
    const vectorField& C = mesh().C();
    const scalarField& V = mesh_.V();
    scalarField& source = eqn.source();
             forAll(C, i)
             {
                            source[i] -= exp(time)*(sqr(C[i].x())-2.0)*V[i];
             }

  #};
 
codeConstrain
    #{
        Pout<< "**codeConstrain**"<< endl;
    #};
}
}
I put this code in fvOptions...It is showing error...


Code:
Creating finite volume options from "system/fvOptions"

Selecting finite volume options model type scalarCodedSource
    Source: source
    - selecting all cells
    - selected 50 cell(s) with volume 0.01


--> FOAM FATAL IO ERROR: 
keyword name is undefined in dictionary "/system/fvOptions.source"
ztdep likes this.

Last edited by divyesh; February 3, 2020 at 03:54.
divyesh is offline   Reply With Quote

Old   February 11, 2020, 16:25
Default
  #4
HPE
Senior Member
 
HPE's Avatar
 
Herpes Free Engineer
Join Date: Sep 2019
Location: The Home Under The Ground with the Lost Boys
Posts: 932
Rep Power: 12
HPE is on a distinguished road
the error message is quite clear? comment out 'name' entry?
HPE is offline   Reply With Quote

Old   February 12, 2020, 02:44
Default
  #5
Senior Member
 
anonymous
Join Date: Jan 2016
Posts: 416
Rep Power: 14
simrego is on a distinguished road
Hi!


Sorry for the late answer. HPE is correct, it should be clear from the error. But there is an another problem which is the missing '}' after the scalarCodedSourceCoeffs.
simrego is offline   Reply With Quote

Old   February 12, 2020, 03:24
Default
  #6
New Member
 
divyesh's Avatar
 
Divyesh Variya
Join Date: May 2018
Location: INDIA
Posts: 16
Rep Power: 7
divyesh is on a distinguished road
thanks. problem solved.
another thing i add is time.value() instead of just time.
__________________
Divyesh Variya
divyesh 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
[PyFoam] and paraview eelcovv OpenFOAM Community Contributions 28 May 30, 2016 09:23
How to add Exner equation in settlingFoam jimbean OpenFOAM Running, Solving & CFD 1 October 6, 2013 09:59
.setSet problems Grimoli OpenFOAM 9 July 31, 2013 13:24
How to add source for UDS on a virtual surface? SimulatingFlow Fluent UDF and Scheme Programming 1 May 22, 2013 08:11
How to add fire source in STAR-CD?? raymond Siemens 2 February 22, 2002 13:49


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