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

Swak4Foam - PatchValueExpressionDriver::evaluate

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

Reply
 
LinkBack Thread Tools Display Modes
Old   December 14, 2012, 14:18
Default Swak4Foam - PatchValueExpressionDriver::evaluate
  #1
Member
 
Vitor Vasconcelos
Join Date: Jan 2012
Posts: 33
Rep Power: 5
vitors is on a distinguished road
Hello all,

I've been studying swak4foam and groovyBC source codes in order to implement a boundary condition in which I define a non-uniform profile in my patch.

I did it using groovyBC and it works. Since I need this feature coded in a BC, I am trying to the same as groovyBC implementation. But I'm stucked in PatchValueExpressionDriverI.H file trying to figure out how the PatchResultExpressionDriver::evaluate method works.

My question: after evaluating the expression, how (and where) groovyBC creates a patch with the calculated values and write it in the boundary condition?

Thanks,

Vitor
vitors is offline   Reply With Quote

Old   December 14, 2012, 15:58
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 vitors View Post
Hello all,

I've been studying swak4foam and groovyBC source codes in order to implement a boundary condition in which I define a non-uniform profile in my patch.

I did it using groovyBC and it works. Since I need this feature coded in a BC, I am trying to the same as groovyBC implementation. But I'm stucked in PatchValueExpressionDriverI.H file trying to figure out how the PatchResultExpressionDriver::evaluate method works.

My question: after evaluating the expression, how (and where) groovyBC creates a patch with the calculated values and write it in the boundary condition?

Thanks,

Vitor
Don't think that the swak-stuff is the best place to learn how boundary conditions are being implemented because there is a lot of other stuff around it.

But the actual setting of the boundary condition (as in all BCs) happens in the updateCoeffs-method of the groovyBCFvPatchField
__________________
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

Old   December 14, 2012, 16:19
Default
  #3
Member
 
Vitor Vasconcelos
Join Date: Jan 2012
Posts: 33
Rep Power: 5
vitors is on a distinguished road
Thanks for your reply.

But I think now I'm in trouble... I came to patchValueExpressionDriver because groovyBCFvPatchField::updateCoeffs() encapsulates its work doing:

Code:
this->refValue() = driver_.evaluate<type>(this->valueExpression_);
Since driver_ is a PatchValueExpressionDriver I saw no other way.

It's still a mystery for me how to be able to set a direction (like z) in my patch independent of its surface is structured or not. I'll keep seeking into the source code to realize, after parsing for example cos(pos().z), the cos function results are set into the patch.

ANY suggestions are welcome.

And thanks for your very fast reply!
vitors is offline   Reply With Quote

Old   December 16, 2012, 20:22
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 vitors View Post
Thanks for your reply.

But I think now I'm in trouble... I came to patchValueExpressionDriver because groovyBCFvPatchField::updateCoeffs() encapsulates its work doing:

Code:
this->refValue() = driver_.evaluate<type>(this->valueExpression_);
Since driver_ is a PatchValueExpressionDriver I saw no other way.

It's still a mystery for me how to be able to set a direction (like z) in my patch independent of its surface is structured or not. I'll keep seeking into the source code to realize, after parsing for example cos(pos().z), the cos function results are set into the patch.

ANY suggestions are welcome.

And thanks for your very fast reply!
If you want to understand the OF-side of things (and that is what you said you want to understand) it is sufficient to understand that the refValue on the left hand side is set to a specific value. That value is a Field<Type> of exactly the right size (size of the patch). Then these values are used to set up the matrix correctly (that is done by calling the updateCoeffs of the superclass). Where the values come from depends on the implementation of the BC. With groovyBC that implementation is a bit more complicated than in the "usual" BCs so I'd recommend looking there
__________________
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

Old   December 17, 2012, 08:36
Post
  #5
Member
 
Vitor Vasconcelos
Join Date: Jan 2012
Posts: 33
Rep Power: 5
vitors is on a distinguished road
Quote:
Originally Posted by gschaider View Post
If you want to understand the OF-side of things (and that is what you said you want to understand) it is sufficient to understand that the refValue on the left hand side is set to a specific value. That value is a Field<Type> of exactly the right size (size of the patch). Then these values are used to set up the matrix correctly (that is done by calling the updateCoeffs of the superclass). Where the values come from depends on the implementation of the BC. With groovyBC that implementation is a bit more complicated than in the "usual" BCs so I'd recommend looking there
Thanks Bernhard. You got my point. I want to know how to set a profile function in a specific direction of my patch. Basically, I want to know how to set matrix values correctly since I don't know how to manipulate the data strucutures from a fvPatch to a fvField.

I'm trying to check how this is done in groovyBC and my start point is: after parsing the expression value (I'm not interested in the parsing itself), how groovyBC come from an expression like
Code:
cos(pos().z)
and sets the profile in the patch. My guess is check how thinks are done in CommonValueExpressionDriver, PatchResult, PatchValueExpressionDriver and GroovyBCFvPatchField.

Thanks for you valuable comments. I feel more confident I'm going in the right way. I'll let you know about my progress (probably you'll see more questions here before this progress I think...).

Regards,

Vitor
vitors is offline   Reply With Quote

Old   December 17, 2012, 13:21
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 vitors View Post
Thanks Bernhard. You got my point. I want to know how to set a profile function in a specific direction of my patch. Basically, I want to know how to set matrix values correctly since I don't know how to manipulate the data strucutures from a fvPatch to a fvField.

I'm trying to check how this is done in groovyBC and my start point is: after parsing the expression value (I'm not interested in the parsing itself), how groovyBC come from an expression like
Code:
cos(pos().z)
and sets the profile in the patch. My guess is check how thinks are done in CommonValueExpressionDriver, PatchResult, PatchValueExpressionDriver and GroovyBCFvPatchField.

Thanks for you valuable comments. I feel more confident I'm going in the right way. I'll let you know about my progress (probably you'll see more questions here before this progress I think...).
I think you're looking at a much too complicated thing: for examples on assembling a Field to assign to the refValue (and similar) have a look at totalPressure or other BCs in $FOAM_SRC/finiteVolume/fields/fvPatch/derived

In order to be flexible groovyBC does certain things in a way that is more complicated than is necessary if you want to write your own hardcoded BCs. And understanding all these details is only necessary if you want to write a better version of the swak-parsers
__________________
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

Old   December 17, 2012, 13:41
Default
  #7
Member
 
Vitor Vasconcelos
Join Date: Jan 2012
Posts: 33
Rep Power: 5
vitors is on a distinguished road
Quote:
Originally Posted by gschaider View Post
I think you're looking at a much too complicated thing: for examples on assembling a Field to assign to the refValue (and similar) have a look at totalPressure or other BCs in $FOAM_SRC/finiteVolume/fields/fvPatch/derived

In order to be flexible groovyBC does certain things in a way that is more complicated than is necessary if you want to write your own hardcoded BCs. And understanding all these details is only necessary if you want to write a better version of the swak-parsers
Thanks for the pointers Bernhard.

I've been through many different OpenFOAM BC's. But for some simple questions it's difficult to find answers. Answers which make things much simpler. For example, I took I lot of time to realize that I can use a fixedGradient class for my problem instead of more complex like mixed. (I hope, at least...)

I'll check totalPressure.

For instance, I found no way to initialize my patch values (or gradients) in a function profile correctly without doing it hard-coded. Moreover, since I'm trying to implement a very particular boundary condition simulating a fuel rod I don't want to leave more than the heat flux specification to the potential users of my BC.

One more time, thanks again for your comments.

Regards,

Vitor
vitors is offline   Reply With Quote

Reply

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
swak4foam newbie29 OpenFOAM Installation 82 July 18, 2015 17:16
groovyBC and funkySetFields married and got a kid named swak4Foam gschaider OpenFOAM 164 January 13, 2015 03:52
swak4foam callahance OpenFOAM 28 August 4, 2013 11:40
Installing swak4Foam to OpenFOAM in mac Kaquesang OpenFOAM Installation on Windows, Mac and other Unsupported Platforms 22 January 21, 2013 12:51
swak4Foam for calculating velocity transformations santoshgoku OpenFOAM 4 June 20, 2012 05:39


All times are GMT -4. The time now is 00:20.