# How to extract variables at boundary and internal cells !!

 Register Blogs Members List Search Today's Posts Mark Forums Read

August 14, 2020, 08:07
How to extract variables at boundary and internal cells !!
#1
Senior Member

Kumaresh
Join Date: Oct 2016
Posts: 347
Rep Power: 11
Hello Foamers, Hope everyone doing good. Here in the attachment, the image contains nodal points at boundary and internal cells for 1D problem.
POINT 0 - Boundary node
POINTS 1,2,3 - Internal nodes

In order to extract variables at the boundary node (@ POINT 0), the below code was implemented, compiled good and end with reasonable results.
Quote:
 forAll (regionMesh().boundaryMesh(), patchI) { forAll(T_.boundaryField()[patchI], faceI) { scalar tK_ = K_.boundaryField()[patchI][faceI]; //VARIABLE K_ extracted from boundary POINT 0 scalar tT_ = T_.boundaryField()[patchI][faceI]; //VARIABLE T_ extracted from boundary POINT 0 QB_[cellI] = tK_* (tT_ - Tliq) / DX.value(); //Heat evaluation based on K_ & T_ } }
However, I would like to have some clue as how to extract the variables at the internal nodes (POINTS 1,2,3). Correct me if I'm wrong anywhere please.
Kindly someone share some ideas.
Thank you
Attached Images
 Boundary and Internal nodes.PNG (16.6 KB, 23 views)

 August 14, 2020, 13:52 #2 New Member   Jaganathan Join Date: Sep 2019 Posts: 2 Rep Power: 0 I have similar issues with 3D model. Cell-centred calculation for internal cells is optable in my case. Kummi likes this.

August 14, 2020, 22:30
#3
Member

Ran
Join Date: Aug 2016
Posts: 69
Rep Power: 9
Quote:
 Originally Posted by Kummi Hello Foamers, Hope everyone doing good. Here in the attachment, the image contains nodal points at boundary and internal cells for 1D problem. POINT 0 - Boundary node POINTS 1,2,3 - Internal nodes In order to extract variables at the boundary node (@ POINT 0), the below code was implemented, compiled good and end with reasonable results.However, I would like to have some clue as how to extract the variables at the internal nodes (POINTS 1,2,3). Correct me if I'm wrong anywhere please. Kindly someone share some ideas. Thank you

You can access the `k` value by referencing the cellId`

`scalar k = turbulence->k()()[cellId];`

Then interpolated it to the patch face. After that, interpolated it to
the node of your interest. I never did this before, but I speculate
there's mature functions to let you do this within native OpenFOAM.
__________________
Yours in CFD,

Ran

August 15, 2020, 11:49
#4
Senior Member

Kumaresh
Join Date: Oct 2016
Posts: 347
Rep Power: 11
Thank you for your response, Jaganathan and Ran.

Accessing the cellId may be required for specific purpose (for example, to imply the source term). Near the boundary, the cell ids are accessed through the boundary condition. So, I have created a patch based on boundaryMesh and obtained the values at the boundary.

For obtaining values at internal cells, I tried accessing neighbor cells, as in code below.
Quote:
 const Foam::List neigbhorcellI = regionMesh().cellCells(cellI);//gives the neighbours of cell cellI forAll(neigbhorcellI, I) //Loop inside internal cells { QB_[cellI] = K_[I]* ((T_[I] - Tliq) /DX.value()); break ; }
But the problem here is, the code doesn't loop over all the cells and as a result, the results are not good as expected.

Thank you