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

Cell close to a boundary

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

Like Tree1Likes
  • 1 Post By Phicau

Reply
 
LinkBack Thread Tools Display Modes
Old   June 8, 2011, 08:26
Default Cell close to a boundary
  #1
Senior Member
 
Andrea Ferrari
Join Date: Dec 2010
Posts: 275
Rep Power: 7
Andrea_85 is on a distinguished road
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
Andrea_85 is offline   Reply With Quote

Old   June 8, 2011, 09:20
Default
  #2
New Member
 
Vojtech Betak
Join Date: Mar 2009
Location: Czech republic
Posts: 28
Rep Power: 9
betakv is on a distinguished road
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.
betakv is offline   Reply With Quote

Old   June 8, 2011, 09:35
Default
  #3
Senior Member
 
Andrea Ferrari
Join Date: Dec 2010
Posts: 275
Rep Power: 7
Andrea_85 is on a distinguished road
Hi Vojtech, thanks for reply.
Where can i find this utility?

Thanks again

andrea
Andrea_85 is offline   Reply With Quote

Old   June 8, 2011, 10:07
Default
  #4
New Member
 
Vojtech Betak
Join Date: Mar 2009
Location: Czech republic
Posts: 28
Rep Power: 9
betakv is on a distinguished road
You can find it tutorials/heatTransfer/pmipleBuoyantFoam
betakv is offline   Reply With Quote

Old   June 8, 2011, 12:19
Default Try this
  #5
Senior Member
 
Pablo Higuera
Join Date: Jan 2011
Posts: 233
Rep Power: 7
Phicau is on a distinguished road
Code:
const labelList cells = patch().faceCells();
Gives you the indices of the cells owned by the patch faces, then you can easily compare.

Credit:
http://www.cfd-online.com/Forums/ope...ext-patch.html
mm.abdollahzadeh likes this.
Phicau is offline   Reply With Quote

Old   June 8, 2011, 12:22
Default
  #6
Senior Member
 
Andrea Ferrari
Join Date: Dec 2010
Posts: 275
Rep Power: 7
Andrea_85 is on a distinguished road
Thanks a lot, is exactly what I was looking for!

andrea
Andrea_85 is offline   Reply With Quote

Old   June 10, 2011, 05:16
Default
  #7
Senior Member
 
Andrea Ferrari
Join Date: Dec 2010
Posts: 275
Rep Power: 7
Andrea_85 is on a distinguished road
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
Andrea_85 is offline   Reply With Quote

Old   June 10, 2011, 06:06
Default
  #8
Senior Member
 
Pablo Higuera
Join Date: Jan 2011
Posts: 233
Rep Power: 7
Phicau is on a distinguished road
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);
Hope it helps
Phicau is offline   Reply With Quote

Old   June 10, 2011, 06:58
Default
  #9
Senior Member
 
Andrea Ferrari
Join Date: Dec 2010
Posts: 275
Rep Power: 7
Andrea_85 is on a distinguished road
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
Andrea_85 is offline   Reply With Quote

Old   June 10, 2011, 07:14
Default
  #10
Senior Member
 
Pablo Higuera
Join Date: Jan 2011
Posts: 233
Rep Power: 7
Phicau is on a distinguished road
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
Phicau is offline   Reply With Quote

Old   June 10, 2011, 07:53
Default
  #11
Senior Member
 
Join Date: Nov 2010
Posts: 113
Rep Power: 6
lindstroem is on a distinguished road
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 boundary-cells. In other words: a list of the cells and their coordinates where alpha = 0.5 at the first cell-layer. I want to store it for the next timestep in order to compare it there..

Thanks in advance!
lindstroem is offline   Reply With Quote

Old   June 10, 2011, 08:44
Default
  #12
Senior Member
 
Andrea Ferrari
Join Date: Dec 2010
Posts: 275
Rep Power: 7
Andrea_85 is on a distinguished road
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
Andrea_85 is offline   Reply With Quote

Old   June 14, 2011, 08:59
Default
  #13
Senior Member
 
Andrea Ferrari
Join Date: Dec 2010
Posts: 275
Rep Power: 7
Andrea_85 is on a distinguished road
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
Andrea_85 is offline   Reply With Quote

Old   June 14, 2011, 10:33
Default
  #14
Senior Member
 
Pablo Higuera
Join Date: Jan 2011
Posts: 233
Rep Power: 7
Phicau is on a distinguished road
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: read-if-exists, 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.
Phicau is offline   Reply With Quote

Old   June 14, 2011, 10:47
Default
  #15
Senior Member
 
Join Date: Nov 2010
Posts: 113
Rep Power: 6
lindstroem is on a distinguished road
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!
lindstroem is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


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 CD-adapco 6 November 15, 2004 05:41


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