|
[Sponsors] |
July 25, 2023, 11:39 |
Access refValue of Boundary condition
|
#1 |
New Member
Peter Vorauer
Join Date: Jun 2023
Posts: 5
Rep Power: 3 |
Hallo, i am working at a chtMultiRegionSimpleFoam Solver to calculate the jouleHeating at a boundary with contact resistance.
For the calculations i would need to access the refValue of a certain boundary in the boundaryField. I managed to get the average Value at the boundary field with: const fvMesh &PoP1 = V_.db().parent().objectRegistry::lookupObject<fvMe sh>(region1); const volScalarField &solidT1 = PoP1.thisDb().objectRegistry::lookupObject<volScal arField>(field); double Pot1 = gAverage(solidT1.boundaryField()[patchID]); but i would need the refValue of solidT1.boundaryField()[patchID] does someone know how to do this? |
|
July 25, 2023, 14:54 |
|
#2 | |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40 |
Quote:
I would typically code something like this: Code:
const auto& mesh = V_.db().time().lookupObject<fvMesh>(region1); auto* solidT1 = mesh.getObjectPtr<volScalarField>(field); double Pot1 = 0; if (solidT1) { auto& bfld = solidT1->boundaryFieldRef()[patchID]); Pot1 = gAverage(bfld); bfld = Zero; // Or whatever ... } If you stick with most of your own code, you will need to do a const_cast on the volScalarField in order to use the boundaryFieldRef() access. |
||
July 26, 2023, 03:31 |
|
#3 |
New Member
Peter Vorauer
Join Date: Jun 2023
Posts: 5
Rep Power: 3 |
Thank you very much for your reply. I would have an other question.
If i use your code i get for the bfld variable with: Info << bfld << " = bfld" << endl; the following result: type compressible::PotentialRadCoupledMixed; refValue uniform 0.571153; refGradient uniform 0; valueFraction uniform 0.0161289; source uniform 0; value uniform 0.923078; Tnbr myjouleHeatingSource:V; sigmaLayer constant 66666; sigma constant 200000; kappaMethod solidThermo; = bfld now i would need the values of refValue uniform 0.571153; and sigmaLayer constant 66666; is there a way to get these values ? (instead of using gAverage(bfld)) |
|
July 27, 2023, 13:55 |
|
#4 | |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40 |
Quote:
You will definitely need to read some documents there. The general boundary field is generally derived from a Field of Type, so that part is fairly straight forward to get at. The other bits such as "refValue uniform ..." and "sigmaLayer constant ..." are either still available as plain dictionary entries that you can scrape back together (if you have a coded access to a dictionary, for example), or if you know what the underlying boundary type actually is, you can dynamic_cast (or refCast for OpenFOAM) into the corresponding type. However, I don't know offhand if these elements are directly exposed as methods for any particular subclass. In either case, they are a PatchFunction1 or Function1, which means you will need to evaluate them with a given time value. |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Fatal overflow in linear solver. | iamnotfajar | CFX | 9 | October 28, 2020 05:47 |
Constant mass flow rate boundary condition | sahm | OpenFOAM | 0 | June 20, 2018 23:45 |
How access member variable of a boundary condition | Vesposo | OpenFOAM Programming & Development | 1 | March 13, 2014 08:49 |
Question about heat transfer coefficient setting for CFX | Anna Tian | CFX | 1 | June 16, 2013 07:28 |
Error finding variable "THERMX" | sunilpatil | CFX | 8 | April 26, 2013 08:00 |