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

accessing value in BC of another patch

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 1, 2011, 06:02
Default accessing value in BC of another patch
  #1
New Member
 
Kathrin
Join Date: Nov 2011
Posts: 15
Rep Power: 15
Katl is on a distinguished road
Hello,

I would like to use/access a value (an integer called sonderBw) which is specified in the boundary conditions of a patch (in my case the upstreamPatch) within the boundary condition of another patch (downstreamPatch).
The goal is to make a loop through all patches in order to find the matching patch with a specific value of sonderBw_

hope anybody can help me

btw. I'm using my own BCs
Katl is offline   Reply With Quote

Old   December 1, 2011, 12:43
Default
  #2
Senior Member
 
Sandeep Menon
Join Date: Mar 2009
Location: Amherst, MA
Posts: 403
Rep Power: 25
deepsterblue will become famous soon enough
It's certainly possible, but at what level do you intend to do this - a higher solver level (eg. icoFoam) or within the BC itself?
__________________
Sandeep Menon
University of Massachusetts Amherst
https://github.com/smenon
deepsterblue is offline   Reply With Quote

Old   December 1, 2011, 15:41
Default
  #3
New Member
 
Kathrin
Join Date: Nov 2011
Posts: 15
Rep Power: 15
Katl is on a distinguished road
within the BC itself
Katl is offline   Reply With Quote

Old   December 1, 2011, 16:10
Default
  #4
Senior Member
 
Sandeep Menon
Join Date: Mar 2009
Location: Amherst, MA
Posts: 403
Rep Power: 25
deepsterblue will become famous soon enough
The polyPatch/fvPatch class has a boundaryMesh() member function which can be used to loop over all patches. Then, you can use the isA<> template test (take a look at typeInfo.H) to check for specific patch types, and refCast<> to convert a generic polyPatch/fvPatch into your specific BC type.

If your data member (sonderBw_) is private within the BC, you would want to provide an access interface to it so that it can be modified externally.

This appears to be a pretty round-about approach, but it will get the job done. I would also look into storing sonderBw_ member centrally (using the objectRegistry), and update that at a global level, but it's all just a matter of preference, really.
__________________
Sandeep Menon
University of Massachusetts Amherst
https://github.com/smenon
deepsterblue is offline   Reply With Quote

Old   December 3, 2011, 12:45
Default
  #5
New Member
 
Kathrin
Join Date: Nov 2011
Posts: 15
Rep Power: 15
Katl is on a distinguished road
how do I use isA<> template test and refCast<> ?
I'm using U.boundaryField()[j] to loop over all patches j. Is it also possible to use these functions in my case? Or are there other possibilities?

Sorry, but I'm still new to openFoam and the codes.

Last edited by Katl; December 4, 2011 at 09:42.
Katl is offline   Reply With Quote

Old   December 5, 2011, 05:14
Default
  #6
New Member
 
Ola Widlund
Join Date: Jun 2011
Location: Sweden
Posts: 13
Rep Power: 15
Ola Widlund is on a distinguished road
Hi Kathrin,

What you want to do is rather common and not very difficult. For example, go through the source code for the BC called "totalTemperature" (class totalTemperatureFvPatchScalarField). In there you will see that you can easily pick up a pointer references to other fields, and use them as you like.

/Ola
Ola Widlund is offline   Reply With Quote

Reply


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
[Commercial meshers] Using starToFoam clo OpenFOAM Meshing & Mesh Conversion 33 September 26, 2012 05:04
[Other] StarToFoam error Kart OpenFOAM Meshing & Mesh Conversion 1 February 4, 2010 05:38
CheckMeshbs errors ivanyao OpenFOAM Running, Solving & CFD 2 March 11, 2009 03:34
[Gmsh] Import gmsh msh to Foam adorean OpenFOAM Meshing & Mesh Conversion 24 April 27, 2005 09:19
Multicomponent fluid Andrea CFX 2 October 11, 2004 06:12


All times are GMT -4. The time now is 04:36.