CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   complicated boundary condition (https://www.cfd-online.com/Forums/openfoam/87659-complicated-boundary-condition.html)

daviderzen April 26, 2011 04:02

complicated boundary condition
 
Hi!

I would like to create a velocity boundary condition (on a wing profile) with following properties:
- tangential slip
- normal velocity calculated from a formula that contains two imported, precalculated velocity fields.

I have tried using fixedNormalSlip bc, but I had problems with imported velocity fields (volVectorField). I couldn't match the field types. :(

Does anybody have similar bc already implemented?

David

benk April 26, 2011 09:21

Although I don't have much experience with your application, normally the implementation of complicated boundary conditions are made much easier using groovyBC (http://openfoamwiki.net/index.php/Contrib_groovyBC). This is like an add on module that you have to install.

daviderzen May 4, 2011 05:38

Excellent!!!!

that's what i need

thank you very very much


ehm, is ti possible to access also scalars from this groovyBC, not just scalar (or other) fields?

benk May 4, 2011 08:53

Quote:

Originally Posted by daviderzen (Post 306205)
ehm, is ti possible to access also scalars from this groovyBC, not just scalar (or other) fields?

This is something that I also want to do (so that I can set a flag within my solver and change the boundary condition based on this flag) but groovyBC cannot read in scalars, it only has access to the field data.

Check out this thread: http://www.cfd-online.com/Forums/ope...tml#post290824

As a workaround, I set up a dummy volScalarField filled with all 0 values except for the boundary which I set to 1 or 0 in my solver depending on whether I want a gradient or fixedvalue BC. Then, in groovyBC, you can just treat that volScalarField like a scalar. This is a bit of a workaround though and wouldn't work well if you want to read in a lot of scalar values.

If Bernhard is reading this: +1 for this feature (when you have some time ;) )

gschaider May 5, 2011 12:23

Quote:

Originally Posted by benk (Post 306231)
This is something that I also want to do (so that I can set a flag within my solver and change the boundary condition based on this flag) but groovyBC cannot read in scalars, it only has access to the field data.

Check out this thread: http://www.cfd-online.com/Forums/ope...tml#post290824

As a workaround, I set up a dummy volScalarField filled with all 0 values except for the boundary which I set to 1 or 0 in my solver depending on whether I want a gradient or fixedvalue BC. Then, in groovyBC, you can just treat that volScalarField like a scalar. This is a bit of a workaround though and wouldn't work well if you want to read in a lot of scalar values.

If Bernhard is reading this: +1 for this feature (when you have some time ;) )

I don't quite get what you want to achieve? Do these 1s and 0s change during the simulation (by the solver or so) and therefor you can't use a plain fractionExpression? With "plain" groovyBC this would be hard (and your solution would be the only choice). With the groovyBC in swak you can achieve something similar if the switches depend on the state of the simulation: Using "external" variables you can say stuff like "if the maximum value of the temperature is above 342 then this BC should be a zeroGradient otherwise fixed"

With the release that I pushed to the SVN a couple of weeks ago (never properly announced it I'm afraid) I introduced "stored variables" with which you can implement stuff like "if the maximum temperature is above 342 then this BC should BECOME a zeroGradient and STAY that way even if the temperature falls"

This and other features of swak4Foam I'll explain during my talk at the Workshop at Penn State next month. I hear that they still accept registrations

Accessing "a scalar variable of the solver" from groovyBC would only be possible if it was exposed via the objectRegistry (and this is currently not implemented). Accessing a variable that is only defined as "scalar switchBC=0;" in the code is technically not possible

About feature wishes: I may sound like a broken record, but I tend to take these more seriously if they pop up in the BugReporting-Mantis of swak4foam (see the Wiki-page)

Bernhard

benk May 5, 2011 12:43

Thanks Berhard,

Quote:

Originally Posted by gschaider (Post 306394)
I don't quite get what you want to achieve? Do these 1s and 0s change during the simulation (by the solver or so) and therefor you can't use a plain fractionExpression? With "plain" groovyBC this would be hard (and your solution would be the only choice). With the groovyBC in swak you can achieve something similar if the switches depend on the state of the simulation: Using "external" variables you can say stuff like "if the maximum value of the temperature is above 342 then this BC should be a zeroGradient otherwise fixed"

I'm modelling batteries and I want to be able to switch between a constant current (which requires a fixedGradient BC) and a constant voltage (which requires a fixedValue BC) during the simulation. So I have a flag, defined as scalar flag = 0; During runtime, if a certain condition is met, I want to set the flag = 1; and switch between constant current to constant voltage (and vice-versa) and in groovyBC boundary condition, I would have something like:

Code:

fractionExpression "(flag > 0) ? 0 : 1"

Quote:

Originally Posted by gschaider (Post 306394)
This and other features of swak4Foam I'll explain during my talk at the Workshop at Penn State next month. I hear that they still accept registrations.

I can't go but I hope somehow this info will extend beyond the workshop.

Quote:

Originally Posted by gschaider (Post 306394)
Accessing "a scalar variable of the solver" from groovyBC would only be possible if it was exposed via the objectRegistry (and this is currently not implemented). Accessing a variable that is only defined as "scalar switchBC=0;" in the code is technically not possible

This is what I want to do. But I think a workaround of making a dummy volumeScalar field (as I explained above) and setting the fixedValue boundary condition to either 1 or 0 should work.


All times are GMT -4. The time now is 11:05.