
[Sponsors] 
June 8, 2011, 08:26 
Cell close to a boundary

#1 
Senior Member
Andrea Ferrari
Join Date: Dec 2010
Posts: 275
Rep Power: 7 
Hi all,
Is there a way to identify cells close to a boundary (cells that have at least one face on a boundary)? I have a list of cell label and i want to know which of these are closed to a boundary. Thanks andrea 

June 8, 2011, 09:20 

#2 
New Member
Vojtech Betak
Join Date: Mar 2009
Location: Czech republic
Posts: 28
Rep Power: 9 
Try to look at utility setHotRoom. There is shown how to get index of boundary faces. Then you can use mesh.owner()[idxOfBoundaryFaces] to get idx of boundary cell
V.B. 

June 8, 2011, 09:35 

#3 
Senior Member
Andrea Ferrari
Join Date: Dec 2010
Posts: 275
Rep Power: 7 
Hi Vojtech, thanks for reply.
Where can i find this utility? Thanks again andrea 

June 8, 2011, 10:07 

#4 
New Member
Vojtech Betak
Join Date: Mar 2009
Location: Czech republic
Posts: 28
Rep Power: 9 
You can find it tutorials/heatTransfer/pmipleBuoyantFoam


June 8, 2011, 12:19 
Try this

#5 
Senior Member
Pablo Higuera
Join Date: Jan 2011
Posts: 237
Rep Power: 7 
Code:
const labelList cells = patch().faceCells(); Credit: http://www.cfdonline.com/Forums/ope...extpatch.html 

June 8, 2011, 12:22 

#6 
Senior Member
Andrea Ferrari
Join Date: Dec 2010
Posts: 275
Rep Power: 7 
Thanks a lot, is exactly what I was looking for!
andrea 

June 10, 2011, 05:16 

#7 
Senior Member
Andrea Ferrari
Join Date: Dec 2010
Posts: 275
Rep Power: 7 
Hi again,
another question. Now i have a volVectorField defined in all cells. If I specify nothing for the boundary, it puts automatically zero: boundaryField { atm { type calculated; value uniform 0; } This of course is not what i want! So now i would like simply to put the value in cell close to boundary also on the face that belongs to that boundary (replace all zeros with corresponding cell value). Any idea? thanks andrea 

June 10, 2011, 06:06 

#8 
Senior Member
Pablo Higuera
Join Date: Jan 2011
Posts: 237
Rep Power: 7 
Hi
the easy way out will be to set the BC to zeroGradient. The pro way will be the following: Code:
const labelList cells = patch().faceCells(); volVectorField whatever = patch().Cf()*0; const volVectorField& U = db().lookupObject<volVectorField>("U"); label cellN = 0; forAll(cells, patchCells) { cellN = cells[patchCells]; whatever[patchCells] = U[cellN]...; } operator == (whatever); 

June 10, 2011, 06:58 

#9 
Senior Member
Andrea Ferrari
Join Date: Dec 2010
Posts: 275
Rep Power: 7 
Hi thanks for the answer. sorry but i think i did not understand much your advice. I try to explain better my problem. I'm inside interfaceProperties.C (using interFoam) and i need to perform some calculation on the alpha1 field. so i define alpha1* as a volVectorField, then i perform some calculation using the cell value of alpha1 to get the alpha1* field. The problem now is that, if i specify nothing for the boundary, it puts automatically zero for all the boundary faces of alpha1*.
What i want to do is to access the boundary value of alpha1* and replace zero with the value at the center of the corresponding cell. now two question 1)if i write alpha1*.correctBoundaryConditions(); at the end of the calculation is sufficient to get the correct values on the boundary? 2) If no, i have manually to set these values. I try to follow your example: if i understand, ""whatever" are the values that i want and "U" is my alpha1*. is correct?. now what does it mean "operator==whatever"? after filling "whatever" with the values that i want, what i have to do to replace the alpha1* boundary values with the new value?¨ hope is clear andrea 

June 10, 2011, 07:14 

#10 
Senior Member
Pablo Higuera
Join Date: Jan 2011
Posts: 237
Rep Power: 7 
OK, now it's clear.
First, alpha1 is a volScalarField not a vector one, so my latest post is still of use changing Vector for Scalar and U for your alpha1* name. Since you have to modify the boundary value I think you should program your own boundary condition so you can set your boundary to that value. In order to do so the best thing is to copy an existing BC and to modify it. I guess totalPressure might be fine to start. updateCoeffs is the place where the correction takes place, so your final patch values are overwritten by setting operator == (whatever); (so use the code above) And first of all you could try zeroGradient to see if it does the job, because it will save you a lot of time. Pablo 

June 10, 2011, 07:53 

#11 
Senior Member
Join Date: Nov 2010
Posts: 113
Rep Power: 6 
Hi all,
I have a question which is kind of connected to what you are doing, therefore I just want to add it here. I work as well with interFoam and the boundary cells. Does anyone of you has an idea, how to get the coordinates of the alpha1=0.5 boundarycells. In other words: a list of the cells and their coordinates where alpha = 0.5 at the first celllayer. I want to store it for the next timestep in order to compare it there.. Thanks in advance! 

June 10, 2011, 08:44 

#12 
Senior Member
Andrea Ferrari
Join Date: Dec 2010
Posts: 275
Rep Power: 7 
Hi, thanks again. Sorry for "Vector", you are right of course..
You mean the BC on alpha1 or i have to define a new field with its boundary condition?. The boundary condition on alpha1* must be the same as alpha1. If in alpha1 i specify constantContactAngle boundary condition i would like that also alpha1* had the correct contact angle (basically i use the new alpha for calculate the curvature..). what alpha1*.correctBoundaryConditions() means? is not an update for the coefficient on the boundary? Suppose to leave zero everywhere on the boundary (get the values of alpha1* only at the cell center). Using alpha1*.correctBoundaryConditions() the coefficients are updated on the boundary?at the end for me is not so important to have the same values in the cells adjacent to the boundary and on the face boundary....what I thought is that leaving zero (without specify any values for them) could be a problem. i'm little bit confused... andrea 

June 14, 2011, 08:59 

#13 
Senior Member
Andrea Ferrari
Join Date: Dec 2010
Posts: 275
Rep Power: 7 
Hi,
finally i solved the problem. Was a simply bug in my "Calculation.H" function. Now i get the alpha1* correct also on the boundary. Thanks a lot for your help. Only the last question: to speed up my simulation i would like to create my list of cells close to a boundary only once time (at the beginning of the simualtion for example) and then read the list during the simulation and perform the calcualtion that i want to do for every time step. (What i'm doing now is to create the list every time step). So my question is: How to create a list of cell labels and then call this list from my "Calculation.H" ? thanks for any help andrea 

June 14, 2011, 10:33 

#14 
Senior Member
Pablo Higuera
Join Date: Jan 2011
Posts: 237
Rep Power: 7 
I once tried to do it by creating a list within a dictionary and I never got it to work, that would be the easiest thing to do: readifexists, else calculate it and write it in the dictionary.
Another way is to save a file, as you said, I have never tried this approach because reading a file is very time consuming, you should check if it is quicker than your current approach. I hope someone else can give you a feedback on how to save/read a file. 

June 14, 2011, 10:47 

#15 
Senior Member
Join Date: Nov 2010
Posts: 113
Rep Power: 6 
Hi Pablo,
thanks for your comment. Your right  reading from a file is very time consuming  therefore I wanted to avoid this procedure. I got a hint from andrea how to extract the alpha1 values of a patch which would be my first step. I did not get it to work yet, but I'm working on that. I also keep an eye on the twoPhasemixture transport model, where the use alpha1 within the function.. Hope I get this to work as a first step and afterwards I'll think about a transfer. Much more complex than I thought Thanks again! 

Thread Tools  
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
inlet velocity boundary condition  murali  CFX  5  August 3, 2012 08:56 
CFX does not continue  Shafiul  CFX  10  February 17, 2011 08:57 
Boundary layer generation problems  ivan_cozza  OpenFOAM Native Meshers: snappyHexMesh and Others  0  October 6, 2010 13:47 
How to identify a boundary cell?  pctopcool  FLUENT  1  August 23, 2010 04:31 
Warning 097  AB  CDadapco  6  November 15, 2004 05:41 