LorranSutter / CVFEM

Control finite volume element method - problem solving

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Control Volume Finite Element Method

Project presented as part of the Final Term Paper in Exact Sciences of the Universidade Federal de Juiz de Fora

CVFEM  |   Problem presentation  |   Dependencies  |   How to run  |   Technologies  |   References  

✏️ What is CVFEM?

Control Volume Finite Element Method is a combination of two well known numerical methods: Finite Element Method (FEM) and Finite Volume Method (FVM). These methods aims to represent and evaluate partial differential equations (PDE) in the form of algebric equations.

The problems that these methods solve are usually two or three dimensional physical problems, such as heat transfer, fluid dynamics and magnetic flux, which are represented by complex and difficult to solve PDE. Therefore, numerical methods are generally used to discretize the domain in numerous elements and solving the equations for each of them.

CVFEM uses unstructured meshes, starting with a conservation equation in integral form. The solution domain is divided in an finite number of control volumes (CV) and the conservation equation is applied to each CV.

πŸ“Œ Problem presentation

In this problem, CVFEM was used to obtain the discrete form of the conservation equation for a scalar quantity. Each integral represents, respectively, conservation of linear momentum, source, diffusion and advection:

$$\frac{d}{dt}\int_{V}\phi dV \ - \ \int_{V}Q dV \ - \ \int_{A}\kappa\nabla\phi\cdot\boldsymbol{n}dA \ + \ B\int_{A}(\boldsymbol{v}\cdot \boldsymbol{n})\phi dA \ = \ 0$$

This process is employed in the discretization of this equation generating a linear system of algebric equations. Thus, it is possible to obtain the following equation:

$$a_{i}\phi_{i} \ = \ \sum_{j=1}^{n_i}a_{i,j}\phi_{S_{i,j}} \ + \ b_i$$

Where $a_i$ and $a_{ij}$ are the coefficients of the linear system of equations for the variable $\phi$, and $b_i$ represents all source, transient and boundary terms contributions.

The figure bellow illustrates the relationship of a node $i$ with its adjacent nodes in the support matrix $S_{ij}$ and its CV:

The case studied is a steady state advection-diffusion problem withoud sources. The domain geometry is a quarter of a circular crown, and considering a field of velocities and diffusivity varying radially and not including sources, the problem can be solved analytically for comparison criteria:

Finally, follow the numerical solution compared to analytical solution:

Solution

πŸ“ Dependencies

Besides, of course, Python, you will need NumPy library for numerical operations and Matplotlib library for plotting.

Also, if you want to generate your own mesh you may use the free mesh generator Gmsh.

πŸƒ How to run

After install dependencies, open your terminal in the folder you want to clone the project:

# Clone this repo
git clone https://github.com/LorranSutter/CVFEM.git

# Go to the project folder
cd CVFEM

The following command read a .msh file generate by Gmsh to be read by the solver code:

python3 readGmsh.py mesh.msh

Then, run the solver code having the output of the previous code as an input:

python3 cvfem.py outputMesh.dat

πŸ’» Technologies

  • Python - interpreted, high-level, general-purpose programming language
  • NumPy - general-purpose array-processing package
  • Matplotlib - plotting library for the Python
  • Gmsh - three-dimensional finite element mesh generator

πŸ“– References

  • Voller, Vaughan R, Basic control volume finite element methods for fluids and solids
  • Versteeg, Henk Kaarle and Malalasekera, Weeratunge, An introduction to computational fluid dynamics: The Finite Volume Method

About

Control finite volume element method - problem solving


Languages

Language:Python 100.0%