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

How to set and read time-dependent source terms

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 16, 2012, 13:19
Default How to set and read time-dependent source terms
  #1
New Member
 
Dean Meyer
Join Date: Jul 2012
Posts: 4
Rep Power: 13
DeanM is on a distinguished road
Dear Foamers,

I would like to read a time-dependent source term, which can be defined by a function in a file in the case directory and read from the solver itself.
So far I managed to set the source term using funkySetFields, but only as initial condition. My approach is the following: In createFields.H the field of the mass source is defined as follows:
Code:
       
        volScalarField massSource
        (
        IOobject
        (
            "massSource",
            runTime.timeName(),
            mesh,
            IOobject::MUST_READ_IF_MODIFIED,
            IOobject::NO_WRITE
        ),
        mesh
        );
The equation to solve looks like
Code:
    fvScalarMatrix rhoEqn
    (
      fvm::ddt(rho) 
    + some terms
    == massSource
    );
    rhoEqn.solve();
Finally the user should be able to define "massSource" with a mathematical expression as function of time and space in a file in the case directory. I tried to do it with funkySetFields, it works well for time 0, but I need it for all times. Example:
Code:
    massSource
    {
        field massS;
        expression    "sin(pi*time())*(pos().x+pos().y"; //arbitrary function 
        //condition    "...";
    }
In conclusion: How can I define and read time-dependent source terms from the case directory?
Thank you for any ideas.
D.
DeanM is offline   Reply With Quote

Old   September 18, 2012, 05:33
Default
  #2
New Member
 
shakil ahmmed
Join Date: Sep 2009
Posts: 5
Rep Power: 16
ahmmed04 is on a distinguished road
you can use the source term as a boundary condition, in that case you can easily use groovyBC.Or if you can access to the 'internalField' when creating source object, you might be able to do this.
ahmmed04 is offline   Reply With Quote

Old   September 20, 2012, 11:14
Default
  #3
Senior Member
 
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 437
Rep Power: 22
marupio is on a distinguished road
You could also use the equationReader extension. I'm working on a paper that will demonstrate this exact idea using it.
__________________
~~~
Follow me on twitter @DavidGaden
marupio is offline   Reply With Quote

Old   September 24, 2012, 17:37
Default
  #4
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by DeanM View Post
Dear Foamers,

I would like to read a time-dependent source term, which can be defined by a function in a file in the case directory and read from the solver itself.
So far I managed to set the source term using funkySetFields, but only as initial condition. My approach is the following: In createFields.H the field of the mass source is defined as follows:
Code:
       
        volScalarField massSource
        (
        IOobject
        (
            "massSource",
            runTime.timeName(),
            mesh,
            IOobject::MUST_READ_IF_MODIFIED,
            IOobject::NO_WRITE
        ),
        mesh
        );
The equation to solve looks like
Code:
    fvScalarMatrix rhoEqn
    (
      fvm::ddt(rho) 
    + some terms
    == massSource
    );
    rhoEqn.solve();
Finally the user should be able to define "massSource" with a mathematical expression as function of time and space in a file in the case directory. I tried to do it with funkySetFields, it works well for time 0, but I need it for all times. Example:
Code:
    massSource
    {
        field massS;
        expression    "sin(pi*time())*(pos().x+pos().y"; //arbitrary function 
        //condition    "...";
    }
In conclusion: How can I define and read time-dependent source terms from the case directory?
Thank you for any ideas.
D.
In addition to the two other solutions given (equationReader and groovyBC) you can search the forum for expressionSource which comes with swak4Foam and does what you want (I've explained the usage in one of those threads ... you'll find it)
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider 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 to read field files from the two different time directories fumiya OpenFOAM 1 August 1, 2021 06:58
TimeVaryingMappedFixedValue irishdave OpenFOAM Running, Solving & CFD 32 June 16, 2021 06:55
How to show the transient case? H.P.LIU Phoenics 7 July 13, 2010 04:31
contribution of convective source in total source? Antony Phoenics 4 July 30, 2008 05:15
How to set environment variables kanishka OpenFOAM Installation 1 September 4, 2005 10:15


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