|
[Sponsors] |
December 1, 2011, 06:02 |
accessing value in BC of another patch
|
#1 |
New Member
Kathrin
Join Date: Nov 2011
Posts: 15
Rep Power: 15 |
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 |
|
December 1, 2011, 12:43 |
|
#2 |
Senior Member
Sandeep Menon
Join Date: Mar 2009
Location: Amherst, MA
Posts: 403
Rep Power: 25 |
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?
|
|
December 1, 2011, 15:41 |
|
#3 |
New Member
Kathrin
Join Date: Nov 2011
Posts: 15
Rep Power: 15 |
within the BC itself
|
|
December 1, 2011, 16:10 |
|
#4 |
Senior Member
Sandeep Menon
Join Date: Mar 2009
Location: Amherst, MA
Posts: 403
Rep Power: 25 |
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. |
|
December 3, 2011, 12:45 |
|
#5 |
New Member
Kathrin
Join Date: Nov 2011
Posts: 15
Rep Power: 15 |
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. |
|
December 5, 2011, 05:14 |
|
#6 |
New Member
Ola Widlund
Join Date: Jun 2011
Location: Sweden
Posts: 13
Rep Power: 15 |
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 |
|
|
|
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 |