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

How to access the value from previous node (cell)

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 24, 2020, 09:17
Question How to access the value from previous node (cell)
  #1
Senior Member
 
Kumaresh
Join Date: Oct 2016
Posts: 355
Rep Power: 12
Kummi is on a distinguished road
Send a message via Yahoo to Kummi
Hello Foamers,
Here is my code sample below.
Quote:
if ((T_[cellI] == Tliq) && (alpha_[cellI] > scalar(0.0)))
{
QB_[cellI] = K_[cellI]* (T_[cellI] - Tliq) / DX.value();
/*
const Foam::List<int> neigbhorcellI = regionMesh().cellCells(cellI);
forAll(neigbhorcellI, I)
{
if (regionMesh().cellCentres()[I][0] < regionMesh().cellCentres()[cellI][0])
//if (regionMesh().X[I][0] < regionMesh().X[cellI][0])
{
//compute QB
QB_[cellI] = K_[I]* ((T_[I] - Tliq) /DX.value());
break ;
}
}*/


QBMAX_[cellI] = (Lboil.value()* (DX.value() - XB) *rho_[cellI] *alpha_[cellI] ) /dtime; //alpha

if (QB_[cellI] > QBMAX_[cellI])
{
QB_[cellI] = QBMAX_[cellI];
XB = scalar(0.0);
alpha_[cellI] = scalar(0.0); //alpha
}
else
{
XB = XB + ((QB_[cellI]*dtime) / (rho_[cellI]*alpha_[cellI] *Lboil.value())); //alpha
}
}
In blue highlighted QB_[cellI] equation, the values of conductivity (K_[cellI]) and temperature (T_[cellI]) are updated based on previous cell values. One of my well wisher suggested to use the code highlighted in Red commented out. But, this code doesn't worked out to access value from previous node.

Kindly someone suggest me how to access the value of K_[cellI] and T_[cellI] from previous node alone (not from all neighboring nodes).
Thank you
Kummi is offline   Reply With Quote

Old   July 27, 2020, 12:00
Question Boundary and Internal cells
  #2
Senior Member
 
Kumaresh
Join Date: Oct 2016
Posts: 355
Rep Power: 12
Kummi is on a distinguished road
Send a message via Yahoo to Kummi
Hello Foamers,
The discussion is about calculation of QBK here highlighted in blue. The image in the attachment gives clear overview. In the image, 2 cells are pictured with both cells possess its own cell centered node points. In cell 1, the calculation of QBK requires values of K_ and T_ from boundary cell (from wall) and in cell 2, the QBK calculation requires values of K_ and T_ from previous cell 1 (internal cells) and calculation prolongs among internal cells.


Below I have code written to extract values from boundary and internal cells. Code for boundary cell needed just for the calculation in NODE 1 alone, whereas code for internal cell prolongs inside the main domain for other NODES (from NODE 2 - till end).

How to adopt the phenomenon separately for boundary and internal cells based on QBK value?



Quote:
if ((T_[cellI] == Tliq) && (alpha_[cellI] > scalar(0.0)))
{

//************ Code to extract value from BOUNDARY cell ************//
forAll (regionMesh().boundaryMesh(), patchI)
{
forAll(T_.boundaryField()[patchI], faceI)
{
scalar tK_ = K_.boundaryField()[patchI][faceI];
scalar tT_ = T_.boundaryField()[patchI][faceI];
QBK = tK_* (tT_ - Tliq) / DX.value();
}
}
//************ Code to extract value from BOUNDARY cell ************//



//************ Code to extract value from INTERNAL cell ************//
const Foam::List<int> neigbhorcellI = regionMesh().cellCells(cellI);
forAll(neigbhorcellI, I)
{
if (regionMesh().cellCentres()[I][0] < regionMesh().cellCentres()[cellI][0])
{
QBK = K_[I]* ((T_[I] - Tliq) /DX.value());
break ;
}
}
//************Code to extract value from INTERNAL cell ************//
QBMAXK = (Lboil.value()* (DX.value() - XB) *den.value() *alpha_[cellI] ) /dtime;
if (QBK > QBMAXK)
{
QBK = QBMAXK;
XB = scalar(0.0);
alpha_[cellI] = scalar(0.0);
}
else
{
XB = XB + ((QBK *dtime) / (den.value() *alpha_[cellI] *Lboil.value()));
} }
kindly someone share the thoughts.
Thank you
Attached Images
File Type: png Nodes.png (108.6 KB, 3 views)

Last edited by Kummi; July 27, 2020 at 14:15.
Kummi 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
Node and cell in cell centred system lucamirtanini Main CFD Forum 20 November 24, 2018 07:36
interFoam running blowing up sandy13 OpenFOAM Running, Solving & CFD 2 May 5, 2015 08:16
How to access previous time waku2005 OpenFOAM Programming & Development 3 December 16, 2014 20:06
How to access the Cell numbers OpenFOAM framework? pradeepramesh OpenFOAM Programming & Development 8 August 25, 2014 23:32
Journal file error magicalmarshmallow FLUENT 3 April 4, 2014 13:25


All times are GMT -4. The time now is 11:49.