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

Access refValue of Boundary condition

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 25, 2023, 11:39
Default Access refValue of Boundary condition
  #1
New Member
 
Peter Vorauer
Join Date: Jun 2023
Posts: 5
Rep Power: 3
Rudiy is on a distinguished road
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?
Rudiy is offline   Reply With Quote

Old   July 25, 2023, 14:54
Default
  #2
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Quote:
Originally Posted by Rudiy View Post
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?

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 ...
 }
The getObjectPtr method is very convenient since it combines a test-if-exists and a const_cast.

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.
olesen is offline   Reply With Quote

Old   July 26, 2023, 03:31
Default
  #3
New Member
 
Peter Vorauer
Join Date: Jun 2023
Posts: 5
Rep Power: 3
Rudiy is on a distinguished road
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))
Rudiy is offline   Reply With Quote

Old   July 27, 2023, 13:55
Default
  #4
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Quote:
Originally Posted by Rudiy View Post
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;

...
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))

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.
olesen 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
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


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