CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Community Contributions

[swak4Foam] groovyBC controlled by scalar

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 2 Post By gschaider

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 20, 2012, 05: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, 21:23
Default
  #2
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 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, 13: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, 13:56
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 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, 08:05
Default
  #5
New Member
 
Raimonds Vilums
Join Date: Oct 2010
Posts: 17
Rep Power: 17
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, 11:24
Default
  #6
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 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

Old   July 13, 2016, 14:50
Default
  #7
Senior Member
 
Manu Chakkingal
Join Date: Feb 2016
Location: Delft, Netherlands
Posts: 129
Rep Power: 10
manuc is on a distinguished road
Hi Bernhard,

I followed the steps as shown. I added the libraries and the paths correctly. I also added the "include" file at the top of .C file before main(). Now if I add

GlobalVariablesRepository::getGlobalVariables().ad dValue( "Burner", "BurnerControl", ExpressionResult(dimensionedScalar("burner",dimles s,burner)) );
to the createFields, I get the 'No matching function for call to 'Foam::GlobalVariableRepository'' error.

Could you please let me know where do I make the function call?
__________________
Regards
Manu
manuc is offline   Reply With Quote

Reply

Tags
groovybc, scalar, thermostat


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
problem during mpi in server: expected Scalar, found on line 0 the word 'nan' muth OpenFOAM Running, Solving & CFD 3 August 27, 2018 05:18
Division by zero exception - loop over scalarField Pat84 OpenFOAM Programming & Development 6 February 18, 2017 06:57
Issue symmetryPlane 2.5d extruded airfoil simulation 281419 OpenFOAM Running, Solving & CFD 5 November 28, 2015 14:09
Diverging solution in transonicMRFDyMFoam tsalter OpenFOAM Running, Solving & CFD 30 July 7, 2014 07:20
compressible flow in turbocharger riesotto OpenFOAM 50 May 26, 2014 02:47


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