CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   How to adress boundary patch from another region in chtMultiRegionFoam? (https://www.cfd-online.com/Forums/openfoam-programming-development/237476-how-adress-boundary-patch-another-region-chtmultiregionfoam.html)

Aniy July 20, 2021 06:17

How to adress boundary patch from another region in chtMultiRegionFoam?
 
Hello,

I am simulating a heat transfer model which includes one fluid region and one solid region, using the solver chtMultiRegionFoam in OFv8.

The boundary condition codedFixedValue is used for the temperature setting of one fluid region patch A. I need to access the temperature feld of another fluid region patch B and the wallHeatFlux feld of one solid region patch C.

It has worked wonderful with following code to read the temperature feld of patch B in fluid region:

Code:


word patchName_patchB = "patchB";

const label patchB_ID = this->patch().boundaryMesh().findPatchID(patchName_patchB);

const volScalarField &T = db().objectRegistry::lookupObject<volScalarField>("T");

const scalarField &T_patchB_sf = T.boundaryField()[patchB_ID];

scalar T_patchB = Foam::average(T_patchB_sf);

But when it comes to the wallHeatFlux feld of patch C in solid region, because the patch C is not in the fluid region like patch A and patch B, the function findPatchID returns -1 so that patch C cannot be found.

The question is:
  • How to adress patch C (which is located in solid region) to access the temperature feld of it?

Anyone has an idea how to solve this problem would be very appreciated, thanks. :)

Muerio October 7, 2021 07:56

Hi there,

I managed to find a solution to the problem. (Tested with a fixedValue BC in region fluid).

Basically you can access the mesh of a different region (i.e. solid) by creating a pointer:
Code:

const fvMesh &solidFvMesh =
            db().parent().objectRegistry::lookupObject<fvMesh>("solid");

Once the targeted region has been initialized, you can access fields and evaluate them at the individual patches (i.e. average temperature at patchC):
Code:

const volScalarField &solidT =
            solidFvMesh.thisDb().objectRegistry::lookupObject<volScalarField>(
                "T");

Info << "Average temperature in solid:patchC: "
    << gAverage(
        solidT.boundaryField()[solidFvMesh.boundaryMesh().findPatchID("patchC")])
    << endl;

If needed you could also access further information for the region, i.e. the thermophysicalProperties dictionary:
Code:

solidFvMesh.thisDb().lookupObject<IOdictionary>("thermophysicalProperties")


All times are GMT -4. The time now is 23:35.