CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Pass value to BC (https://www.cfd-online.com/Forums/openfoam-programming-development/88667-pass-value-bc.html)

Phicau May 23, 2011 10:36

Pass value to BC
 
Dear all,

this is my first thread, although I have been reading this forum for over a year now, finding always very useful info.

I am currently developing some specific BCs to generate waves for interFoam. In order to do so I have modified interFoam to read the variables I needed and to perform some calculations which have to be done only once.

The problem is how to pass those values (a couple of dimensionedScalar, a word and maybe a scalar) to the BC.

Currently I was looking at a piece of code which does not seem to work for such data types:
Code:

const surfaceScalarField& phi =
        db().lookupObject<surfaceScalarField>(phiName_);

Can anyone give me a hint?

Thanks

Pablo H

gwierink May 24, 2011 03:35

Hi Pablo,

I'm not a very wavy person, but the first thing that comes to mind is groovyBC's groovyWaveTank ... Hope it's of any help :)

Phicau May 24, 2011 03:53

Thanks a lot gwierink,

of course when I started making waves I used groovyBC and it is indeed very handy, but when you get to a point when solving some equations iteratively is very convenient (i.e. cnoidal waves) and the profiles increase their complexity (Stokes V) then the only way is to code it yourself.

Of course I could make external calculations and add those values to the dictionary, or even hard-code them (as I am doing now) but my goal is to develop a very robust automatic BC to generate waves. I could also read the values from the dictionary and perform all the iterative calculations each time the BC needs correction, but that will be highly inefficient.

So I modified interFoam to calculate iteratively the elliptical parameter on startup, and my only need is to pass it along with wave height and so on (in order to read them only once) and the word which states the wave theory to use.

In other words, my BC has to access a couple of variables created by interFoam in order to be efficient.
Is there any way to define the variables as global or to pass them directly to my BC?

Pablo H


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