# FvMatrix coefficients

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

 October 10, 2006, 08:51 Hi all, I've got some doubt #1 New Member   Miriam Join Date: Mar 2009 Posts: 15 Rep Power: 15 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 Senior Member   Mattijs Janssens Join Date: Mar 2009 Posts: 1,419 Rep Power: 24 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) upper-lower addressing: upper is the owner of the face, lower the neighbour of the face. (again for non-amg 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: 15 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 off-diag 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 off-diag coefficients (and that index represents the number of column of the off-diag coefficient in the matrix),then the arrays Lower and Upper (in which the off-diag 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 off-diag elements in the matrix). So are all off-diag 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,879 Rep Power: 31 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 re-use 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: 15 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 cell-centres) 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 owner-cell neighbour are to be considered (relative to the 4 internal faces). In the matrix there are 4 non zero diag-off coefficients in the upper triangle, 4 non zero diag-off 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 diag-off 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 diag-off coefficients of the upper triangle. Is that all correct? Thanks a lot Miriam songwukong likes this.

 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,879 Rep Power: 31 Yup, correct. All you need to know on top of that is now to find the matrix position of (say) the third off-diagonal 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

 November 22, 2006, 10:17 Hi all, please, could anyone #8 New Member   Miriam Join Date: Mar 2009 Posts: 15 Rep Power: 15 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 AB). 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

November 22, 2006, 10:31
lduMatrix (which is what you a
#9
Senior Member

Hrvoje Jasak
Join Date: Mar 2009
Location: London, England
Posts: 1,879
Rep Power: 31
lduMatrix (which is what you are using) is constructed with an addressing object which tells it the location of non-zero coefficients. The one from the fvMesh allows non-zero off-diagonal 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 right-hand side).

Quote:
Sounds like you need a break and a cup of tea...

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: 63 Rep Power: 11 Hello, According to the reference that it's address link is below, in page 53; http://www.diva-portal.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: 63
Rep Power: 11
Quote:
 Originally Posted by luckycfd Hello, According to the reference that it's address link is below, in page 53; http://www.diva-portal.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
I undrestand