accessing value in BC of another patch
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 |
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?
|
within the BC itself
|
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. |
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. |
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 |
All times are GMT -4. The time now is 04:36. |