
[Sponsors] 
October 10, 2006, 08:51 
Hi all,
I've got some doubt

#1 
New Member
Miriam
Join Date: Mar 2009
Posts: 15
Rep Power: 8 
Hi all,
I've got some doubts about fvMatrix coefficients. Are equations, in the system that's to be solved, ordered in the same manner of the cell centres list (given by mesh.C()) : that's to say does equation n°1 correspond to the balance in the cell whose centre is the first element in the cell centres list, does equation n°2 correspond to the balance in the cell whose centre is the second element in the cell centres list, etc.? Is the array of the unknown field values (evaluated in cell centres) ordered in the same manner of the cell centres list order? In a fvMatrix with elements aij does the element aij represent the coefficient by which the field, evaluated in the cell centre of index j in the cell centres list, is multiplied and that is present in the balance equation of the cell whose centre has index i in the cell centres list? Besides, which is the order of aij in the arrays representing the upper ad lower triangle of the fvMatrix? That addressing is not clear to me. Thanks a lot in advance Miriam 

October 11, 2006, 05:45 
Yes, for most solvers the unkn

#2 
Super Moderator
Mattijs Janssens
Join Date: Mar 2009
Posts: 1,416
Rep Power: 16 
Yes, for most solvers the unknowns are ordered as the cells. (the exception being amg where the unknowns represent the value of some agglomeration of cells)
The coefficients are to neighbouring cells so correspond to the faces between the cells (every cell pair is uniquely identified by a face) upperlower addressing: upper is the owner of the face, lower the neighbour of the face. (again for nonamg solvers) 

October 11, 2006, 09:44 
I really thank you for your an

#3 
New Member
Miriam
Join Date: Mar 2009
Posts: 15
Rep Power: 8 
I really thank you for your answer but I'm still confused about fvMatrix addressing.
First of all is not l array (used for the addressing of the array Lower, for the lower triangle of the matrix) in which the owner cell index is stored (for each face), whereas the array u (for the upper addressing) stores the neighbour cell index? Then let's take into account, as example, a very simple mesh: a 2D mesh made up of 4 cells. In that case the number of edges (faces in 3D speaking) to consider is 12. The number of offdiag elements in the upper triangle of the matrix is 6 and the same happens for the lower triangle. If I consider all the faces and for each face the index (relative to the cell position in the cell centre list) of the owner cell is stored in the array l used for the addressing of the array Lower (and that index also represents the number of row of the coefficient in the matrix), whereas the index of the neighbour cell is stored in the array u used for the addressing of the array Upper of matrix offdiag coefficients (and that index represents the number of column of the offdiag coefficient in the matrix),then the arrays Lower and Upper (in which the offdiag coefficients of the matrix are stored) must have the same dimension of l and u, so equal to the total number of faces: 12 (which is also the total number of offdiag elements in the matrix). So are all offdiag coefficients stored twice, in the arrays Upper and Lower? Furthermore let's consider the cells with indexes 0 and 2 that have only a vertex (an edge in 3D view) in common , and no common edge (face in 3D view). Let's consider the matrix coefficient a02 in the following position in the matrix: row=0, col=2; relative to that coefficient 0 is stored in array l at a certain index j, 2 in array u at index k. So can I find the coefficient a02 at index j of the array Lower and at index k of array Upper? There must be a face with cell of index 0 as cell owner and cell of index 2 as cell neighbour. But which one if these cells have only a vertex (edge) in common? Thanks again Miriam 

October 11, 2006, 09:51 
What you are missing is the se

#4 
Senior Member
Hrvoje Jasak
Join Date: Mar 2009
Location: London, England
Posts: 1,768
Rep Power: 21 
What you are missing is the separation between the Finite Volume support and discretisation and generic matrix format. In the FVM, coefficients will only exist if cells share a face, so your question does not arise. However, the matrix classes in OpenFOAM are written in a general way and will work for whatever addressing you provide  but you'll have to do some work. Look, for example at all the Finite element stuff I did with the matrix classes remaining unchanged.
Example: for the FVM, we've got the fvMesh, which dictates the addressing. Thus, an fvMatrix is derived from an lduMatrix and grabs the addressing from an fvMesh. In general, you can specify an lduMatrix with whatever addressing you wish to use but you will have to build the addressing yourself. Thus, if you need corner neighbours, this is no longer standard FVM and you cannot reuse the FVM machinery. Please note that the sparse matrix is NOT dynamic, ie. its sparseness pattern is defined at creation. For the details of the matrix support and coefficient organisation you may want to take a look at the code in detail (or speak to someone who knows). Hrv
__________________
Hrvoje Jasak Providing commercial FOAM/OpenFOAM and CFD Consulting: http://wikki.co.uk 

October 11, 2006, 11:31 
I Know that I cannot have corn

#5 
New Member
Miriam
Join Date: Mar 2009
Posts: 15
Rep Power: 8 
I Know that I cannot have corner neighbours in FVM
since the values on a face of a cell is obtained as a function (along a certain direction and different according to the interpolation scheme or BC if it's a border face ) of the values of the fields evaluated in the centres of cells that share a face with that cell. Let's consider the matrix of the system (to solve to find the field in the cellcentres) for the 2D case, with 4 cells, I reported before. a02 represents the coefficient by which the field, evaluated in the cell centre of index 2, in the cell centres list, is multiplied and that is present in the balance equation of the cell whose centre has index 0 in the cell centres list. Since cells 0 and 2 are corner neighbours, and for ex. value of the field evaluated in the centre of cell 2 is not used to find the interpolation values of the field on the faces of cell 0, the coefficient a02 is equal to zero. So for all corner neighbours coefficinets are zero in the matrix. For the case reported before the total number of faces is 12, but only 4 (the internal faces) can have both owner and neighbour, since a patch face has only an owner. So 4 couples cell ownercell neighbour are to be considered (relative to the 4 internal faces). In the matrix there are 4 non zero diagoff coefficients in the upper triangle, 4 non zero diagoff coefficients in the lower triangle of the matrix, since the coefficients for corner neighbours are zero. So l (of sise 4) is used for the addressing of the array Lower that contains the 4 non zero diagoff coefficients of the lower triangle of the matrix,u (of sise 4) is used for the addressing of the array Upper that contains the 4 non zero diagoff coefficients of the upper triangle. Is that all correct? Thanks a lot Miriam 

October 12, 2006, 03:16 
Yup, correct. All you need to

#6 
Senior Member
Hrvoje Jasak
Join Date: Mar 2009
Location: London, England
Posts: 1,768
Rep Power: 21 
Yup, correct. All you need to know on top of that is now to find the matrix position of (say) the third offdiagonal coefficient in the upper triangle (the lower triangular coefficients are in the same order).
This brings you to coupled interfaces, but that's another topic :) Hrv
__________________
Hrvoje Jasak Providing commercial FOAM/OpenFOAM and CFD Consulting: http://wikki.co.uk 

October 12, 2006, 08:11 
Hi,
first of all thank you

#7 
New Member
Miriam
Join Date: Mar 2009
Posts: 15
Rep Power: 8 
Hi,
first of all thank you very much for your advice. I suppose to have understood how to adress the cell near the border cell, for the addressing (in the fvMatrix) of the coefficients that the coefficient evaluation functions must return, in the case of the boundary condition class I talked about in my previous message " BC coefficients evaluation functions". I report here what I understood. In the array Upper only non zero diagoff coefficients belonging to the upper triangle of the matrix are stored, whereas only non zero diagoff coefficients belonging to the lower triangle are stored in the array Lower. The addressing can be achieved by looking at arrays l and u. For every internal face the index of the owner cell (that is the index of the cell centre in the cell centre List returned by the function mesh.C()) is stored in the array l, while the neighbour cell index is stored in the array u. For every internal face the relative elements stored in l and u arrays also represent the number of row and column of the coefficient, relative to that face and that belongs to the upper triangle, in the matrix. I can say that it belongs to the upper triangle since the cell owner index (row number) is always lower than the cell neighbour index (number of column). So if I consider a face with cell owner index=i and cell neighbour index=j, stored at index=k of arrays l and u respectively, I find the element aij stored at position k of array Upper and aji stored at index k of array Lower. As a matter of fact the coefficients relative to that internal face are aij and aji. They are in symmetric position relative to the diagonal because they represent the influence that the field Fi and Fj (field evaluated in cell centre i and in cell j) exert on each other(Fj on balance equation for cell i and vice versa), considering the direction that encounters the face shared by these cells. Furthermore the equations in the system are order in in the same manner of the cell centre list returned by mesh.C(). So the balance equation for cell of index i (whose centre has index i in the list of cell cetres) corresponds to row=i. So, as I said in my previous message, in a fvMatrix the coefficient aij represent the coefficient by which the field, evaluated in the cell centre of index j in the cell centres list, is multiplied and that is present in the balance equation of the cell whose centre has index i in the cell centres list. So, since in Upper and Lower symmetric elements are stored with the same order, in the case of a symmetrix matrix the arrays Upper and Lower are identical and only one is to be saved, by saving memory. Let's return to my BC. In the case of my BC I want to impose a linear profile of the field in the last to cells near the border(I impose that the gradient on the border face is equal to the gradient on the internal face of the border cell). So, for the evaluation of the field on the border I find: Fbord=KA FA+ KB FB where KA and KB are values obtained by imposing that condition. Fbord : field on the border face FA : field evaluated in the border cell (cell of index A, so whose centre has index A in the cell centre list); that is the nearest internal field to the border (and it is given by this>patchInternalField()) FB: field evaluated in the internal cell, near the border cell, an that shares a face with it. Fbord is taken into account in the balance of cell A, represented by equation A in the system (row number A in the fvMatrix). KA has to be taken into account for the evaluation of the diagonal coefficient aAA in the matrix (the coefficient by which FA is mutiplied in equation A). The contribution to the source array is zero. KB has to be taken into account for the evaluation the coefficient by which FB is mutiplied in equation A, so for the evaluation of the matrix coefficient aAB KB does not influence aBA, which is relative to equation on cell B (the value of the field on the shared face is already taken into account in the interpolation scheme). I have to find the position of aAB in Upper or Lower, it depends if it belongs to the upper or lower triangle of the matrix. So cell A and cell B share a face, an the coefficients relative to that internal face are aAB, aBA. If A<B A is cell owner index, B cell neighbour index. If the couple of cell indexes A and B are stored at index k of arrays l and u respectively, I can find aAB at index k of array Upper,aBA at index k of array Lower. So in that case the contribution given by KB must be "added" to the coefficient aAB, which is at index k of array Upper. If A>B B is cell owner index, A cell neighbour index. If the couple of cell indexes B and A are stored at index k of arrays l and u respectively, I can find aBA at index k of array Upper,aAB at index k of array Lower. So in that case the contribution given by KB must be "added" to the coefficient aAB, which is at index k of array Lower. I have to find the correct syntax to add that contribution to the element of array Upper of Lower, according to the case. The same procedure is adopted if on the border face the gradient is evaluated. First of all do you think that it is all correct? Then could you please give me some clues about the correct syntax to achieve that. Thank you very much again Bye Miriam 

November 22, 2006, 11:17 
Hi all,
please, could anyone

#8 
New Member
Miriam
Join Date: Mar 2009
Posts: 15
Rep Power: 8 
Hi all,
please, could anyone tell me first if what I wrote in my previous message is correct?. The arrays Lower and Upper, used to represent the fvMatrix, have dimensions equal to the number of internal faces: the off diagonal coefficients they store express the influence of a field evaluated in a cell centre (f evaluated in cell A is called fA) on the equation of a cell (called cell B) that share a face with it (with cell A). The common face represents the means by which the fields evaluatated in the two cells can influence each other, In the balance equation for cell A there is the term aAB*fB, that expresses the influence of fB on the equation used to evaluate fA. Instead in the balance equation for cell B there is the term aBA*fA, that expresses the influence of fA on the equation used to evaluate fB. aAB and aBA refer to the the face shared by the two cells (A and B, where A and B are the indexes of the cells in the cell centres list), and so they are stored in Upper and Lower respectivly (if A<b,)>B). The index of the face (the index in vectors l and u to which that cells couple, and so that common face refers) is given by triIndex function : index=f.mesh().ldu.triIndex(A,B) aAB and aBA are at that index of Upper and Lower if A<B, or Lower and Upper if B<A. Consider now the case I have along a mesh direction cells A,B,C in that order, and, for a cetain Boundary Condition I have to write in the equation of the cell border A the term aAC*fC: how can I do that? Where should I store aAC? Cells A and C do not share a face. The influence of a cell on the other, which is along a mesh direction, but not the first neighbour, may be considered also in certain interpolation schemes when 3 or more points are used to evaluate a value on a face. Where should I store the coefficients relative to these second neighbours (they are not corner neighbours, but second neighbours along a mesh direction), since it seems that Lower and Upper, relative to that addressing just take into account the first neigbours? Could anyone help me? Please!!! Thanks in advance Miriam 

November 22, 2006, 11:31 
lduMatrix (which is what you a

#9  
Senior Member
Hrvoje Jasak
Join Date: Mar 2009
Location: London, England
Posts: 1,768
Rep Power: 21 
lduMatrix (which is what you are using) is constructed with an addressing object which tells it the location of nonzero coefficients. The one from the fvMesh allows nonzero offdiagonal entries only for cells that share a face.
If you wish to have a coefficient between two cells that do not share a face, you will need to build your own addressing object and your own matrix. Alternatively (a MUCH better idea, in my opinion), you can make the bit referring to C explicit and put it into the righthand side). Quote:
Hrv
__________________
Hrvoje Jasak Providing commercial FOAM/OpenFOAM and CFD Consulting: http://wikki.co.uk 

August 25, 2013, 01:20 
Matrix in OpenFoam

#10 
Member
Hassan
Join Date: Oct 2012
Location: Iran
Posts: 62
Rep Power: 5 
Hello,
According to the reference that it's address link is below, in page 53; http://www.divaportal.org/smash/get...T01.pdf I can,t undrestand that what is the placeholder matrix in openFoam? and how get this equations: u(0)=[2,0] u(1)=[3,1] l(0)=[0,2] l(1)=[1,3] UpperAddr=(2,3) LowerAddr=(0,1) If it is possible for you, please explain a little about this concept. Best regards, Hassan 

October 3, 2013, 14:38 

#11  
Member
Hassan
Join Date: Oct 2012
Location: Iran
Posts: 62
Rep Power: 5 
Quote:


Thread Tools  
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Question about the fvmatrix and Laplacian operator  liuhuafei  OpenFOAM Running, Solving & CFD  6  October 3, 2009 06:58 
How to convert from GeometricField to fvMatrix  waynezw0618  OpenFOAM Running, Solving & CFD  1  January 22, 2009 12:12 
How to look at the coefficients from fvMatrix  marco7  OpenFOAM Running, Solving & CFD  2  September 11, 2008 03:58 
Assembling a fvMatrix for a preconditioner  srinath  OpenFOAM Running, Solving & CFD  0  July 30, 2008 07:23 
FvMatrix A D whats the difference  hjasak  OpenFOAM Running, Solving & CFD  0  June 20, 2007 06:12 