# Accelerate the assembling of 3D convection matrix

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

 December 22, 2005, 07:52 Accelerate the assembling of 3D convection matrix #1 Isabel Guest   Posts: n/a Hello everybody, I have to solve 3D time dependent Navier Stokes equations with finite element method. There are 68921 nodes and in each node I have to calculate velocity field (u,v,w) and pressure (p). After every time step I have to calculate the convection (or advection) matrix because the velocity field has changed and, the assembling of this convection matrix takes a lot of time, more than solve the velocity system and the pressure system (I work with a decoupled method). Could someone give me an advice to accelerate its computation?. Thank-you very much, best regards and Merry Christmas! Isabel

 December 22, 2005, 08:02 Re: Accelerate the assembling of 3D convection mat #2 MÃ¡rcio Ricardo Guest   Posts: n/a If you're working with an explicit method, you can use the following aproximation: x direction: Conv(u,v,w) = Grad_x(u*u) + Grad_y(v*u) + Grad_z(w*u) and so on for the y- and z- directions. This way you would have a geometric matrix for the convective term regards Márcio

 December 22, 2005, 08:25 Re: Accelerate the assembling of 3D convection mat #3 Renato. Guest   Posts: n/a Hy Isabel, Why don't you try to use element-by-element (EBE) data structure and avoid the need to assembly your matrices? It's very simple to implement and use and you'll cut a lot of time and memory storage. By the way, are you using iterative or direct linear solver? I'm asking for that because if you're using an iterative solver you'll need to implement a specific matrix-vector routine to compute it in an EBE way. But it's also easy to do... Cheers and Merry Christmas! Renato.

 December 22, 2005, 10:21 Re: Accelerate the assembling of 3D convection mat #4 diaw Guest   Posts: n/a A neat trick we use is that of assembling using 'tensor' forms instead of 'matrix' forms. This often seems to vectorise rather well under the compiler. diaw...

 December 22, 2005, 10:55 Re: Accelerate the assembling of 3D convection mat #5 Renato. Guest   Posts: n/a When using element-by-element (or edge-by-edge) data structures we can reach vectorization (or OpenMP parallelism) after applying some kind of mesh coloring algorithm. In this case, the elements (or edges) are reordered and grouped in such a way that none of the elements inside a group/block share the same node. Regards Renato.

 December 22, 2005, 11:41 Re: Accelerate the assembling of 3D convection mat #6 Isabel Guest   Posts: n/a Hi! I am using an iterative method to solve the momentum equation. Renato, could you give any references where the EBE scheme and matrix-vector method are explained and that explains how not assembling the nonlinear convection term, i.e. (in Finite Element Method nomenclature)? I would be really greatful. Thank-you. Isa

 December 22, 2005, 12:22 Re: Accelerate the assembling of 3D convection mat #7 Renato. Guest   Posts: n/a The idea behind EBE data structure is not so complicated to understand and I'll try to sketch something here: * * * STORING THE MATRIX * * * - Imagine you have a mesh with a mesh formed by triangles with 1 degrees of freedom per node. In order to build your "stiffness" matrix you'll have to perform a loop over the elements computing the contributions of the mass, convective, diffusive terms, etc... . Thus, instead of assembling the coefficients you'll store each element matrix separately to use later inside the iterative solver for the matrix-vector product. Therefore, you'll need an array like the following: A(nnoel*ngl, nnoel*ngl, nel) (instead of A(neq,neq) in a assembled solution) where: nel is the number of elements, nnoel is the number of nodes per element (3 for linear triangles), ngl is the number of degrees of freedom (1 in this example) and neq the number of active equations. - The vector force will remain by neq as you're used in your assembled solution. * * * USING THE EBE FOR MATRIX-VECTOR PRODUCT * * * - In order to perform the matvec product in your iterative solver see the following pseudo-code: z <-- A*x DO i=1,nel c. recover number of equations from your connectivity matrix (IEN) c. recover local vector force coefficients (from x) c. recover element-based stiffness coefficients (from A) c. multiply your element gathered matrix and vector (A*x) c. scatter your multiplication (in z) ENDDO I've found the following link where Marek Behr discusses EBE related issues http://www.cats.rwth-aachen.de:8080/pdf/para-l21.pdf Cheers Renato