Implementation of boundary conditions for FVM
I am fairly new at CFD and want clear some personal misunderstandings on the implementation of boundary conditions. Any comments are most welcome indeed.
First of all, I am working with the Finite Volume Method (FVM) where boundaries are represented by cell faces on the "outside" of the mesh, i.e. faces not lying between two cells. I gather from various literature sources that there are 4 posibilities when specifying boundary conditions: (1) Fixed value (Dirichlet) (2) Fixed gradient (von Neumann) (3) Natural boundary condition (dependent on solution) (4) Extrapolated boundary value I also gather that each and every discretized equation to be solved requires either one or a combination of the above boundary conditions. Number (1) and (2) is fairly understandable and the implementation is not too obscured. Questions: [1] Am I right in saying that for (2) the boundary face value is calculated from the given gradient and the cell value lying along the boundary? [2] In the discretized equation we require the value of the cell lying outside the boundary. But we assume that this cell has a zero volume so that its centroid coincides with the boundary face centroid? Therefore the value at the boundary can be used directly in the discretized equation? [3] Another question on the fixed gradient boundary condition (2). Do we specify the FLUX at the boundary per unit area i.e. q=k d(phi)/d(n) = fixed value where n is a outward pointing init vector on the boundary face, or do we specify only the gradient of the dependent variable? d(phi)/d(n) [4] What is the difference between implicit and explicit treatment of boundary conditions and how does it effect the discretized equation? i.e. how is the diagonal influenced and and what about the explicit source term due to the boundary condition? [5] What is the deal with conditions (3) and (4) and where are they typically used? How will (3) be implemented? [6] Typically which conditions of (1) to (4) is used in which equations for example: momentum equation; pressure equation; pressure correction equation etc. etc. Looking forward to your replies. Tom 
Re: Implementation of boundary conditions for FVM
I GATHER FROM VARIOUS LITERATURE SOURCES THAT THERE ARE 4 POSIBILITIES WHEN SPECIFYING BOUNDARY CONDITIONS: (1) FIXED VALUE (DIRICHLET) (2) FIXED GRADIENT (VON NEUMANN) (3) NATURAL BOUNDARY CONDITION (DEPENDENT ON SOLUTION) (4) EXTRAPOLATED BOUNDARY VALUE
There are only the first two as all the others can be rewritten to one of the first two. For example, the extrapolated boundary value uses a gradient from the inside of the domain to predict the value at the face. Thus for that iteration this gradient is fixed and reduces to your number 2, Von Neumann condition. I ALSO GATHER THAT EACH AND EVERY DISCRETIZED EQUATION TO BE SOLVED REQUIRES EITHER ONE OR A COMBINATION OF THE ABOVE BOUNDARY CONDITIONS. Yes, but it is here where CFD sometimes got confused as text books and codes named these boundaries typically INLET, OUTLET, PRESSURE, CYCLIC etc. For the different properties, the combinations reduce to either DIRICHLET or VON NEUMANN. NUMBER (1) AND (2) IS FAIRLY UNDERSTANDABLE AND THE IMPLEMENTATION IS NOT TOO OBSCURED. QUESTIONS: [1] AM I RIGHT IN SAYING THAT FOR (2) THE BOUNDARY FACE VALUE IS CALCULATED FROM THE GIVEN GRADIENT AND THE CELL VALUE LYING ALONG THE BOUNDARY? Yes, that is right. [2] IN THE DISCRETIZED EQUATION WE REQUIRE THE VALUE OF THE CELL LYING OUTSIDE THE BOUNDARY. BUT WE ASSUME THAT THIS CELL HAS A ZERO VOLUME SO THAT ITS CENTROID COINCIDES WITH THE BOUNDARY FACE CENTROID? THEREFORE THE VALUE AT THE BOUNDARY CAN BE USED DIRECTLY IN THE DISCRETIZED EQUATION? Commercial CFD codes use two different techniques. Some use this methodology described by you. The more general approach is to define control volumes in terms of flat faces which are flagged to be baffles, inside cell faces, boundary faces etc. [3] ANOTHER QUESTION ON THE FIXED GRADIENT BOUNDARY CONDITION (2). DO WE SPECIFY THE FLUX AT THE BOUNDARY PER UNIT AREA I.E. Q=K D(PHI)/D(N) = FIXED VALUE WHERE N IS A OUTWARD POINTING INIT VECTOR ON THE BOUNDARY FACE, OR DO WE SPECIFY ONLY THE GRADIENT OF THE DEPENDENT VARIABLE? D(PHI)/D(N) At the end you will need/use the the gradient of the dependent variable at the face. [4] WHAT IS THE DIFFERENCE BETWEEN IMPLICIT AND EXPLICIT TREATMENT OF BOUNDARY CONDITIONS AND HOW DOES IT EFFECT THE DISCRETIZED EQUATION? I.E. HOW IS THE DIAGONAL INFLUENCED AND AND WHAT ABOUT THE EXPLICIT SOURCE TERM DUE TO THE BOUNDARY CONDITION? When deriving the finite volume method, the finite volume integration over a control volume reduces to an algebraic expression where the new value in a control volume is in terms of the old value of the control volume and the values at the faces. Neighbouring control volumes is then used to interpolate the values at the faces with different schemes such as Upwind differencing, Central Differencing Quick etc. The variables is then grouped together to give the well known expression _p phi_p = SIGMA a_nb phi_nb + S_p, where a_p is the central coefficient, a_nb the socalled neighbouring coefficients and S_p the source. Phi should be solved for. Now for boundary cells the face value is "replaced" by the particular boundary assumption. Thus, when rearranging the variables, you have the choice to either put the contribution in the source or in the matrix or to split it. Generally spoken, larger source terms (explicit) will slow convergence down. [5] WHAT IS THE DEAL WITH CONDITIONS (3) AND (4) AND WHERE ARE THEY TYPICALLY USED? HOW WILL (3) BE IMPLEMENTED? I will rewrite to options 1 and 2 and try to implement it as implicitly as possible. (Personal choice) [6] TYPICALLY WHICH CONDITIONS OF (1) TO (4) IS USED IN WHICH EQUATIONS FOR EXAMPLE: MOMENTUM EQUATION; PRESSURE EQUATION; PRESSURE CORRECTION EQUATION ETC. ETC. Try to find this in a good text book (say Ferziger and Peric)or the help pages of some commercial CFD code Typically for an INLET the velocity will be fixed and pressure extrapolated. LOOKING FORWARD TO YOUR REPLIES. TOM Hope this help 
Re: Implementation of boundary conditions for FVM
Thank you for your advice Onno. You cleared up many of my misunderstandings.
I have one more question regarding boundary conditions: Our general differential equation have convection term and diffusion term. When discretizing the equation we require both the face value of the dependent variable (convection term) and the gradient of the dependent variable over the face (diffusion term) My question is this. Do we specify both boundary conditions (the fixed value and the gradient). I think not. Is it correct to specify for example the face value and calculate the gradient from the previous iteration to get the face gradient for the diffusion term and the other way around? Can we do this implicitly? How would one decide whether to specify the fixed value or the gradient at the boundary? I recall from some notes that one may NOT specify both types of BC at a single face. There, I think i answered my own question!! But comments are welcome. Tank you Tom 
Re: Implementation of boundary conditions for FVM
OUR GENERAL DIFFERENTIAL EQUATION HAVE CONVECTION TERM AND DIFFUSION TERM. WHEN DISCRETIZING THE EQUATION WE REQUIRE BOTH THE FACE VALUE OF THE DEPENDENT VARIABLE (CONVECTION TERM) AND THE GRADIENT OF THE DEPENDENT VARIABLE OVER THE FACE (DIFFUSION TERM)
Thus you need for the convection term a value of the property and for the diffusion term a gradient at the face. In the case of fixed gradient for the property, the diffusion term is already sorted out and will most probably end up in the source term (may be not in the case of extrapolation). However, the convection term needs a value at the face. Now you should use the given gradient (phi_b – phi_c)/dx = given gradient to calculate phi_b. (phi_c value of boundary cell centre, phi_b value at boundary face, dx distance between boundary cell centre and face centre) . Note the term containing phi_c may end implicitly in the central coefficient. If you use the old value in the source, then your treatment is socalled explicitly. Similarly, if a fixed value is given then the convection term is sorted out. For the diffusion term you should use the boundary cell value and given boundary face value to calculate a boundary gradient = (phi_b – phi_c)/dx. Now the term containing phi_c might end up in the central coefficient – thus implicitly! MY QUESTION IS THIS. DO WE SPECIFY BOTH BOUNDARY CONDITIONS (THE FIXED VALUE AND THE GRADIENT). I THINK NOT. IS IT CORRECT TO SPECIFY FOR EXAMPLE THE FACE VALUE AND CALCULATE THE GRADIENT FROM THE PREVIOUS ITERATION TO GET THE FACE GRADIENT FOR THE DIFFUSION TERM AND THE OTHER WAY AROUND? CAN WE DO THIS IMPLICITLY? You confuse the need for a face value and face gradient when discretising the convection/diffusion terms with a given boundary condition. You should use the given boundary condition to approximate the derived need for either a face value or face gradient as described above. HOW WOULD ONE DECIDE WHETHER TO SPECIFY THE FIXED VALUE OR THE GRADIENT AT THE BOUNDARY? I RECALL FROM SOME NOTES THAT ONE MAY NOT SPECIFY BOTH TYPES OF BC AT A SINGLE FACE. THERE, I THINK I ANSWERED MY OWN QUESTION!! BUT COMMENTS ARE WELCOME. This you will find in the mentioned text book of the previous mail. You may not mix a dirichlet en von neuman boundary condition for a certain property for the different terms (such as convection and diffusion) in one equation. However, you should use different types for the different properties such as velocity and pressure as in the case of say an inlet. 
Re: Implementation of boundary conditions for FVM
Thank you
I now understand a great deal more about boundary conditions. There is one more problem that confuses me.Is then true that the extrapolated boundary condition determines both the face value and face gradient from the solution? And this we could also do implicitly or explicitly using the results from the current iteration or the previous iteration resp.? If we have unstructured non orthogonal mesh where only the cells nearest neighbours are stored in a list, how does the extrapolated boundary work??? We need the face value at the boundary to calculate the gradient over the boundary cell, but the face value at the boundary is what we want to calculate! (so both the cell gradient and face values are unknown) I know that in a structured orthogonal mesh its easy to extrapolate using the boundary cell value and its neighbour cell value and simply fitting a line through these values to the boundary face, but this method does not seem to be an option for unstructured non orthogonal mesh? Thank you Tom 
Re: Implementation of boundary conditions for FVM
Now you are talking – the solution will cost you!!!!
If familiar with unstructured mesh techniques (which I will assume, as you already experienced the lack of information) then the only information known is that of the two cells bracketing the face. The following procedure will do the thing. Approximate the boundary face with the boundary cell's value (thus zero gradient) Use thus value to calculate the gradient over the boundary cell and use this gradient at the face. Now you have a value on the boundary face and a gradient. The dot product of the gradient and the boundary face vector gives you the gradient of the property in the direction of the face area vector. A line with this (dotted) gradient through the approximated boundary value should on a regular grid goes through the value of the opposite cell of the boundary cell that you are looking for.  U  BC  (BC is the boundary cell and U the one that you try to trace) With some algebra, when guessing a dx (see later) you can calculate this U value. Use this calculated U value and the value at BC as well as the guessed dx to calculate the gradient that you need for the extrapolation. In order to guess a dx, you may become smart and calculate the average cell distances in the direction of the boundary face area vector. Quicker method is to say that the volume of a cube is V=dxdydz. Thus the dx needed is the Volume divided by the magnitude of the boundary face vector (dydz). Else, you can construct a list at the boundary face of cells that will be used for calculation of near boundary cell values. Construct on the boundary face (on the inside of the domain) two cubes with the volume of the boundary cell. Calculate volume overlapping with the near boundary cells and store for each boundary cell the cell number needed and the percentage of overlapping with the near boundary cells. Use this to calculate the value of the properties at the two cubes that you have placed on the boundary face. These values is then used for your boundary approximations. 
Question!!
I have a question about fix gradient boundary condition in FVM.
As I know the fix boundary condition is sth like this: k(TbTn)/deltaX = q which Tb: T at the boundary, Tn: T at the node near the boundary, deltaX: distance between these two This equation results in this equation for Tb: Tb = deltaX*(q/k) + Tn My question is, when deltaX goes to be much smaller, for example in micro Scales, the converging of this boundary condition and so the solution of the domain will be too slow(I use a simple Algorithm for convergence)!! What can I do about it?!! Any help would be highly appreciated. Thank you Mohammad reza Shetab 
how to apply orlanski's boundary condition using FVM ????

All times are GMT 4. The time now is 03:32. 