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

groovyBC controlled by scalar

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree2Likes
  • 2 Post By gschaider

Reply
 
LinkBack Thread Tools Display Modes
Old   April 20, 2012, 04:13
Default groovyBC controlled by scalar
  #1
New Member
 
Jaroslav Volavy
Join Date: May 2009
Posts: 2
Rep Power: 0
Jaroslav is on a distinguished road
Hi all,

could somebody help me? I'm trying to implement thermostat function in OpenFOAM. I'm using groovyBC.
I want something like this (in the 0/T file):
Code:
hotWall
    {
          type         groovyBC;
          variables     "Thot=Burner*373.15 + (1-Burner)*293.15;";
          valueExpression "Thot";
    }
where Burner is parameter defining the state of burner (1-on,0-off) and its value is determined in the solver code (controlled by algorithm).
If I declare Burner as volScalarField in the solver and change the value on the corresponding patch (hotWall), it works fine.
But this is quite complicated and IMHO nasty way how to do it.

So my question is: Is there any way how to achieve this using variable Burner only as a scalar?

I tried this (and many other variation):
Code:
dimensionedScalar Burner
    (
      "Burner",
       scalar(1)
    );
but it ended with parser error (Burner was not recognized).

Do you have any idea how to use only scalar in the groovyBC?
Thank very much for your help

regards
Jaroslav
Jaroslav is offline   Reply With Quote

Old   April 20, 2012, 20:23
Default
  #2
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by Jaroslav View Post
Hi all,

could somebody help me? I'm trying to implement thermostat function in OpenFOAM. I'm using groovyBC.
I want something like this (in the 0/T file):
Code:
hotWall
    {
          type         groovyBC;
          variables     "Thot=Burner*373.15 + (1-Burner)*293.15;";
          valueExpression "Thot";
    }
where Burner is parameter defining the state of burner (1-on,0-off) and its value is determined in the solver code (controlled by algorithm).
If I declare Burner as volScalarField in the solver and change the value on the corresponding patch (hotWall), it works fine.
But this is quite complicated and IMHO nasty way how to do it.

So my question is: Is there any way how to achieve this using variable Burner only as a scalar?

I tried this (and many other variation):
Code:
dimensionedScalar Burner
    (
      "Burner",
       scalar(1)
    );
but it ended with parser error (Burner was not recognized).

Do you have any idea how to use only scalar in the groovyBC?
Thank very much for your help

regards
Jaroslav
Unfortunately there is no way to register a single scalar value with an objectRegistry (which would be the requirement for this to work). But there is a way using the global variables mechanism in swak4Foam. The problem is that you'll have to link it to the swak4FoamParsers-library (with -lswak4FoamParsers). If you can live with chaining your solver to that monster: fine

You'll have to make the place were global variables are stored known to the solver with
Code:
#include "GlobalVariablesRepository.C"
then where it is appropriate you can store your variable in a global scope (I assume you have a variable called "burner")
Code:
GlobalVariablesRepository::getGlobalVariables().addValue(
   "Burner",
   "BurnerControl",
   ExpressionResult(dimensionedScalar("burner",dimless,burner))
);
(the interface to GlobalVariablesRepository was not really designed to be used by end-users)

Now in the boundary condition you've got to make the global scope known with
Code:
globalScopes ( BurnerControl );
and the variable Burner should be known and have the last value that has been set.

If you want to keep your solver "swak-free" then an alternative would be to implement the burner algorithm in a functionObject and set the global variable there. This is possible with the swakCoded-functionObject (which basically is the usual coded-FO with the possibility to set globals) or the pythonIntegration-functionObject.
Jaroslav and argonaut like this.
gschaider is offline   Reply With Quote

Old   April 25, 2012, 12:16
Default
  #3
New Member
 
Jaroslav Volavy
Join Date: May 2009
Posts: 2
Rep Power: 0
Jaroslav is on a distinguished road
Hi Bernhard,

thank you very much for your help! It works. My monster code is alive! (thunder in background )

Jaroslav
Jaroslav is offline   Reply With Quote

Old   April 25, 2012, 12:56
Default
  #4
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by Jaroslav View Post
Hi Bernhard,

thank you very much for your help! It works. My monster code is alive! (thunder in background )
You mean: like this http://www.youtube.com/watch?v=9AFf0ysgNiM (that's me on the right, BTW)
gschaider is offline   Reply With Quote

Old   May 28, 2012, 07:05
Default
  #5
New Member
 
Raimonds Vilums
Join Date: Oct 2010
Posts: 17
Rep Power: 7
argonaut is on a distinguished road
Quote:
Originally Posted by gschaider View Post
Code:
GlobalVariablesRepository::getGlobalVariables().addValue(
   "Burner",
   "BurnerControl",
   ExpressionResult(dimensionedScalar("burner",dimless,burner))
);
Can the ExpressionResult contain other type of a variable except dimensionedScalar, e.g. scalar or int?
argonaut is offline   Reply With Quote

Old   May 28, 2012, 10:24
Default
  #6
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by argonaut View Post
Can the ExpressionResult contain other type of a variable except dimensionedScalar, e.g. scalar or int?
int (or how us Foamers call it: label) is definitely not supported (reason is that there is no such thing as a volLabelField). But if you don't count too high a scalar might serve this purpose too.

Currently the constructor only supports dimensioned values. But as you see above (dimless) this is no problem. The constructor is templated to accept any dimensioned-thing, but the internals (ugly, but serves its purpose) of ExpressionResult only accept scalar, vector, tensor, symmTensor and sphericalThensor
gschaider is offline   Reply With Quote

Reply

Tags
groovybc, scalar, thermostat

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
dieselFoam problem!! trying to introduce a new heat transfer model vivek070176 OpenFOAM Programming & Development 10 December 24, 2014 00:48
Solving for an additional species CO in coalChemistryFoam N. A. OpenFOAM Programming & Development 2 November 13, 2014 09:43
Specifying nonuniform boundary condition maka OpenFOAM Running, Solving & CFD 59 October 22, 2014 14:52
Climbing inlet pressure with simpleFoam and directMappedPatches chegdan OpenFOAM Running, Solving & CFD 1 January 2, 2012 20:35
CFX12 rif errors romance CFX 4 October 26, 2009 14:41


All times are GMT -4. The time now is 01:34.